Skip to content

RawStatement

Defined in: packages/client/src/index.ts:1982

One statement of a SyncClient.rawTransaction list: the SQL plus its bound params, and optionally the blob bytes a COPY statement ingests. Structured-clone safe by construction (a string, plain values and a Uint8Array), because on a worker-attached client the whole list crosses the bridge in a single RPC.

readonly optional blob?: Uint8Array<ArrayBuffer>

Defined in: packages/client/src/index.ts:2000

The bytes pgwasm reads for this statement’s /dev/blob — how a LOCAL-ONLY table an app owns is BULK-LOADED with COPY instead of one INSERT per row. It rides ONLY with a COPY … FROM '/dev/blob' statement; any other statement ignores it. Build the pair with buildCopyFromBlobStatement, which renders the statement and serializes the rows from ONE column list (and with the same COPY TEXT serializer the sync applier uses), so the SQL and the bytes cannot disagree.

On a worker-attached client the buffer is TRANSFERRED, not copied. It is listed on the RPC’s postMessage transfer list, so it is DETACHED (byteLength === 0) the moment the call dispatches: the caller must not read, reuse or re-send it afterwards — serialize a fresh chunk for each call. Zero-copy is the point: a 1000-row chunk crosses the bridge without a structured-clone copy.

Typed over a real ArrayBuffer (not the default ArrayBufferLike) because that IS the contract: a SharedArrayBuffer-backed view can neither be transferred nor read as a Blob part.


readonly optional params?: readonly unknown[]

Defined in: packages/client/src/index.ts:1984


readonly sql: string

Defined in: packages/client/src/index.ts:1983