IF Commons GitHub

physical/redump

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0008-sql-dump FR-006

A dump written in the plain INSERTs of an engine: what the rows a dump holds become as text for SQLite, PostgreSQL or DuckDB, so that the engine's own client replays them with no library code. It writes text and runs nothing.

import { redump } from "./redump.ts";
const text = redump({ versions: [], blobs: [] }, "postgres", naming);

Source: commons/anyfs-sql/src/physical/redump.ts

0 of 3 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

Dumptypeno test imports it
type Dump = { readonly versions: readonly DumpedVersion[]; readonly blobs: readonly { readonly sha: string; readonly bytes: Uint8Array }[] };

What a dump holds: its version rows and its blobs.

DumpedVersiontypeno test imports it
type DumpedVersion = readonly [string, string, string, number, string, string | null, string, string, string | null];

A version row as a dump gives it: its nine values in the order of the columns.

redumpfunctionno test imports it
function redump(dump: Dump, target: "duckdb" | "postgres" | "sqlite", naming: Naming): string

A dump (the rows parseDump read) written as the plain INSERTs of an engine, in key order, so that the engine's own client replays it with no library code: SQLite's form is what the real sqlite3 writes (X'hex' for bytes); PostgreSQL's is what pg_dump --data-only --inserts --on-conflict-do-nothing writes ('\xhex' and ON CONFLICT DO NOTHING); DuckDB's is INSERT OR IGNORE with unhex. Every row of every form replays as a union.

Titles, headings, exports, tables, columns and requirements. Esc closes.