The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.
TypeScript budget-trackercollaborativedockeritinerarymcp-serveroffline-firstopen-sourceopenstreetmappacking-listpwareal-timeself-hostedselfhostedtraveltravel-apptravel-journaltravel-plannertripitwanderlog
docs(plugin-sdk): state the transaction-control and NUL rules of ctx.db
Maurice363889b97aa4
diff --git a/plugin-sdk/README.md b/plugin-sdk/README.mdindex a085f37c7..c077a9da1 100644--- a/plugin-sdk/README.md+++ b/plugin-sdk/README.md@@ -127,6 +127,20 @@ Your plugin runs in an **isolated child process**. `ctx` is the only way to reacTREK, and it grants exactly the permissions your `trek-plugin.json` declares — anungranted call throws `PERMISSION_DENIED`.+Two rules of your own database (`db:own`) hold on every engine, SQLite included, and in+`dev` and the mock host:++- **No transaction control in your SQL.** Each `query`, `exec`, `tx` and `migrate` call runs+ in a transaction of its own, so `BEGIN`, `START`, `COMMIT`, `END`, `ROLLBACK`, `ABORT`,+ `SAVEPOINT` and `RELEASE` are refused in every statement with+ `PLUGIN_DATA_ERRORS.txControl`. An `exec('BEGIN; INSERT ...; UPDATE ...; COMMIT;')` script,+ which TREK before 5.2 ran on SQLite, now throws: pass those statements to one `ctx.db.tx([...])`+ call instead, which commits them all or none.+- **No NUL (U+0000) in SQL, bound values or `migrate` ids.** Such a call is refused rather+ than stored, since Postgres text cannot hold the character and TREK will not change a value+ you asked to store. Bind binary data as a `Buffer` and use another separator than `'\0'` in+ composite keys. Rows an older TREK already stored with a NUL are still read as they are.+### What a ctx call returnsEvery ctx method falls into one of three kinds, listed per method in the exporteddiff --git a/plugin-sdk/src/index.ts b/plugin-sdk/src/index.tsindex 025719def..12612a1f2 100644--- a/plugin-sdk/src/index.ts+++ b/plugin-sdk/src/index.ts@@ -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[]>;