Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 56 additions & 1 deletion src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1558,12 +1558,14 @@ export type SAHPoolUtil = {
/** Exception class for reporting WASM-side allocation errors. */
export class WasmAllocError extends Error {
constructor(message: string);

toss: (...args: unknown[]) => never;
}

/** Exception class used primarily by the oo1 API. */
export class SQLite3Error extends Error {
constructor(message: string);

resultCode: number;
}

Expand Down Expand Up @@ -2022,6 +2024,7 @@ export class sqlite3_vfs extends SQLiteStruct {
pAppData: WasmPointer;

constructor(pointer?: WasmPointer);

xOpen: (
vfsPtr: WasmPointer,
zName: WasmPointer,
Expand Down Expand Up @@ -2083,6 +2086,7 @@ export class sqlite3_io_methods extends SQLiteStruct {
iVersion: number;

constructor(pointer?: WasmPointer);

xClose: (file: WasmPointer) => Sqlite3Result;
xRead: (
file: WasmPointer,
Expand Down Expand Up @@ -2174,6 +2178,7 @@ export class sqlite3_module extends SQLiteStruct {
iVersion: number;

constructor(pointer?: WasmPointer);

xCreate: (
db: WasmPointer,
pAux: WasmPointer,
Expand Down Expand Up @@ -3790,6 +3795,37 @@ export type CAPI = {
*/
sqlite3_libversion: () => string;

/**
* Calls the given _synchronous_ callback function. If that function returns
* sqlite3.capi.SQLITE_BUSY _or_ throws an SQLite3Error which a resultCode
* property of that value then it will suppress that error and try again, up
* to the given maximum number of times. If the callback returns any other
* value than that, it is returned. If the maximum number of retries has been
* reached, an SQLite3Error with a resultCode value of
* sqlite3.capi.SQLITE_BUSY is thrown. If the callback throws any exception
* other than the aforementioned BUSY exception, it is propagated. If it
* throws a BUSY exception on its final attempt, that is propagated as well.
*
* If the beforeRetry argument is given, it must be a _synchronous_ function.
* It is called immediately before each retry of the callback (not for the
* initial call), passed the attempt number (so it starts with 2, not 1). If
* it throws, the exception is handled as described above. Its result value is
* ignored.
*
* To effectively retry "forever", pass a negative maxTimes value, with the
* caveat that there is no recovery from that if the code gets stuck in a
* deadlock situation.
*
* @param maxTimes Max retries (-1 for infinite).
* @param callback Function to retry.
* @param beforeRetry Optional function to call before each retry.
*/
sqlite3_js_retry_busy: <T>(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slight correction/clarification: it's still uncertain whether js_retry_busy() will be included at all.

bind_zeroblob() will be part of 3.53, not 3.52. Version 3.52.0 has been withdrawn, pending a decision from drh about how to deal with its floating-point discrepancies. It will return, in some form or other, but these JS changes won't be part of it.

maxTimes: number,
callback: () => T,
beforeRetry?: (retryCount: number) => void,
) => T;

/**
* Returns a string constant whose value is the same as the `SQLITE_SOURCE_ID`
* C preprocessor macro. Except if SQLite is built using an edited copy of the
Expand Down Expand Up @@ -4913,6 +4949,21 @@ export type CAPI = {
* See https://www.sqlite.org/c3ref/bind_parameter_name.html
*/
sqlite3_bind_parameter_name: (stmt: StmtPtr, N: number) => string | null;
/**
* The sqlite3_bind_zeroblob() routine binds a BLOB of length N that is filled
* with zeroes.
*
* @param stmt Statement to bind to.
* @param index 1-based index of the parameter to bind.
* @param N Number of zeroes to bind.
* @returns SQLITE_OK on success, or an error code.
* @see https://sqlite.org/c3ref/bind_blob.html
*/
sqlite3_bind_zeroblob: (
stmt: StmtPtr,
index: number,
N: number,
) => Sqlite3Result;

/**
* Use this routine to reset all host parameters to NULL.
Expand Down Expand Up @@ -8465,7 +8516,8 @@ export type CAPI = {
SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE: 1020;
SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE: 1021;
SQLITE_DBCONFIG_ENABLE_COMMENTS: 1022;
SQLITE_DBCONFIG_MAX: 1022;
SQLITE_DBCONFIG_FP_DIGITS: 1023;
SQLITE_DBCONFIG_MAX: 1023;
SQLITE_DBSTATUS_LOOKASIDE_USED: 0;
SQLITE_DBSTATUS_CACHE_USED: 1;
SQLITE_DBSTATUS_SCHEMA_USED: 2;
Expand Down Expand Up @@ -8569,6 +8621,8 @@ export type CAPI = {
SQLITE_MAX_VARIABLE_NUMBER: 32_766;
SQLITE_LIMIT_TRIGGER_DEPTH: 10;
SQLITE_MAX_TRIGGER_DEPTH: 1000;
SQLITE_LIMIT_PARSER_DEPTH: 14;
SQLITE_MAX_PARSER_DEPTH: 1000;
SQLITE_LIMIT_WORKER_THREADS: 11;
SQLITE_MAX_WORKER_THREADS: 0;
SQLITE_OPEN_READONLY: 1;
Expand All @@ -8595,6 +8649,7 @@ export type CAPI = {
SQLITE_PREPARE_PERSISTENT: 1;
SQLITE_PREPARE_NORMALIZE: 2;
SQLITE_PREPARE_NO_VTAB: 4;
SQLITE_PREPARE_FROM_DDL: 16;
SQLITE_OK: 0;
SQLITE_ERROR: 1;
SQLITE_INTERNAL: 2;
Expand Down
Loading