Skip to content
Open
Show file tree
Hide file tree
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
12 changes: 12 additions & 0 deletions packages/shared/src/nodeSqliteClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,18 @@ it.effect("keeps the reader read-only even if a statement turns query_only off",
),
);

it.effect("keeps a reader's sorts and temp tables in memory, not in temp files", () =>
withReaderClient((sql) =>
Effect.gen(function* () {
const rows = yield* sql<{ temp_store: number }>`PRAGMA temp_store`.pipe(
sql.withTransaction,
SqliteClient.readOnly,
);
assert.equal(rows[0]?.temp_store, 2);
}),
),
);

it.effect("keeps read-only work inside a write transaction on the writer", () =>
withReaderClient((sql) =>
sql.withTransaction(
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/src/nodeSqliteClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ try {
allowExtension: workerData.allowExtension,
});
next.exec("PRAGMA busy_timeout = 5000;");
// Callers set pragmas only on the writer, so a reader would sort and build temp tables in files.
next.exec("PRAGMA temp_store = MEMORY;");
// Reads the header, so a file that is not a database fails here rather than on first use.
const mode = String(next.prepare("PRAGMA journal_mode").get().journal_mode).toLowerCase();
// Without WAL a reader's shared lock blocks the writer's commits, so refuse.
Expand Down
Loading