Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return await attachment.client.statusAction(async status => {
//// FIXME: options/flags, dialect
statement.statementHandle = await attachment!.attachmentHandle!.prepareAsync(status, transaction.transactionHandle,
0, sqlStmt, 3, fb.Statement.PREPARE_PREFETCH_ALL);
statement.inMetadata = fixMetadata(status, await statement.statementHandle!.getInputMetadataAsync(status));
statement.outMetadata = fixMetadata(status, await statement.statementHandle!.getOutputMetadataAsync(status));
if (statement.inMetadata) {
statement.inBuffer = new Uint8Array(statement.inMetadata.getMessageLengthSync(status));
statement.dataWriter = createDataWriter(createDescriptors(status, statement.inMetadata));
}
if (statement.outMetadata) {
statement.outBuffer = new Uint8Array(statement.outMetadata.getMessageLengthSync(status));
statement.dataReader = createDataReader(createDescriptors(status, statement.outMetadata));
}
return statement;
});
while (true) {
let nextFetch: number;
try {
nextFetch = await nextFetchPromise;
}
catch (e) {
if (rows.length == 0)
throw e;
else {
this.delayedError = e;
return { finished: false, rows };
}
}
if (nextFetch == fb.Status.RESULT_OK) {
const buffer1 = buffer;
buffer = ++buffer % 2;
const finish = options && options.fetchSize && rows.length + 1 >= options.fetchSize;
if (!finish)
nextFetchPromise = this.resultSetHandle!.fetchNextAsync(status, buffers[buffer]);
rows.push(await this.statement.dataReader(this.statement.attachment, this.transaction, buffers[buffer1]));
if (finish)
return { finished: false, rows };
}
else {
return { finished: true, rows };
}
return await this.attachment.client.statusAction(async status => {
const readingBytes = Math.min(buffer.length, MAX_SEGMENT_SIZE);
const segLength = new Uint32Array(1);
const result = await this.blobHandle!.getSegmentAsync(status, readingBytes, buffer, segLength);
if (result == fb.Status.RESULT_NO_DATA)
return -1;
return segLength[0];
});
}
protected async internalCancel(): Promise {
if (this.eventCallback) {
const { eventCallback } = this;
this.eventCallback = undefined!;
await fb.cancelEvent(eventCallback);
}
}
}
protected async internalDispose(): Promise {
this.dispatcher!.releaseSync();
fb.disposeMaster(this.master!);
this.util = undefined;
this.dispatcher = undefined;
this.master = undefined;
}
}
constructor(library: string) {
super();
this.master = fb.getMaster(library);
this.dispatcher = this.master.getDispatcherSync();
this.util = this.master.getUtilInterfaceSync();
}
static async queue(attachment: AttachmentImpl, names: string[], callBack: (counters: [string, number][]) => Promise):
Promise {
const events = new EventsImpl(attachment);
const { client } = attachment;
events.eventCallback = await fb.queueEvent(client.master!, attachment.attachmentHandle!, names, callBack);
return events;
}