docs(plugin-sdk): state the transaction-control and NUL rules of ctx.db

A plugin's own database refuses BEGIN/COMMIT in every call and NUL in SQL,
bound values and migration ids on every engine; the guide and the ctx.db types
now say so and point at ctx.db.tx() and Buffer binding instead.
This commit is contained in:
Maurice
2026-11-23 15:02:54 +01:00
parent 48e54d5a62
commit 363889b97a
2 changed files with 19 additions and 0 deletions
+5
View File
@@ -84,6 +84,11 @@ export interface PluginContext {
* before its next statement). An `exec` with bound args (one statement) and
* `migrate` are not timed, and no single statement can be stopped midway (a read
* only between its rows).
* Every call runs in a transaction of its own, so transaction control (`BEGIN`, `COMMIT`,
* `ROLLBACK`, `SAVEPOINT`, ...) is refused in every statement of every call, on both
* engines; batch atomic writes with `tx()` instead of a `BEGIN; ...; COMMIT;` script.
* SQL, a bound value or a `migrate` id holding the character U+0000 (NUL) is refused on
* both engines too: bind binary data as a Buffer and keep NUL out of composite keys.
* See `tx()` below for the atomic-batch cap and README § Runtime limits. */
db: {
query<T = unknown>(sql: string, ...args: unknown[]): Promise<T[]>;