@quereus/isolation 4.3.0 → 4.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import type { Database, VirtualTableModule, BaseModuleConfig, TableSchema, TableIndexSchema as IndexSchema, ModuleCapabilities, VirtualTable, BestAccessPlanRequest, BestAccessPlanResult, SchemaChangeInfo, Schema, MappingAdvertisement, LensDeploymentSnapshot, VtabConcurrencyMode, VirtualTableConnection, BackingHost } from '@quereus/quereus';
1
+ import type { Database, VirtualTableModule, BaseModuleConfig, TableSchema, TableIndexSchema as IndexSchema, ModuleCapabilities, VirtualTable, BestAccessPlanRequest, BestAccessPlanResult, SchemaChangeInfo, Schema, MappingAdvertisement, LensDeploymentSnapshot, VtabConcurrencyMode, VirtualTableConnection, BackingHost, EffectiveRowSource } from '@quereus/quereus';
2
2
  import type { IsolationModuleConfig } from './isolation-types.js';
3
3
  import { IsolatedTable } from './isolated-table.js';
4
4
  /**
@@ -35,12 +35,24 @@ export interface ConnectionOverlayState {
35
35
  overlayTable: VirtualTable;
36
36
  hasChanges: boolean;
37
37
  /**
38
- * Set by a cross-connection ALTER that could not migrate this (foreign)
39
- * overlay to the post-alter column layout. The overlay still holds
40
- * PRE-alter rows, so it is structurally inconsistent with the now-committed
41
- * schema; any data op that would merge or flush it must throw this message.
42
- * Undefined = healthy. Cleared only by discarding the overlay (rollback /
43
- * commit-failure → rollback).
38
+ * The `Database` this overlay was created against — carried so
39
+ * {@link IsolationModule.releaseOverlayTable} can free the overlay's staging
40
+ * table on ANY discard path, including {@link IsolationModule.destroy} and
41
+ * {@link IsolationModule.closeAll}, which sweep overlays across multiple db ids
42
+ * and so have no single ambient `db` to hand the overlay module's `destroy`.
43
+ * Set at every real creation site (`ensureOverlay`, the two rebuild builders);
44
+ * the default `MemoryTableModule` overlay ignores it, but a host-injected
45
+ * `config.overlay` keyed per-db needs the overlay's OWN db, not the sweeper's.
46
+ */
47
+ db: Database;
48
+ /**
49
+ * Set by a cross-connection DDL that left this (foreign) overlay unflushable:
50
+ * an ALTER that could not migrate it to the post-alter column layout (the overlay
51
+ * still holds PRE-alter rows, structurally inconsistent with the now-committed
52
+ * schema), or a DROP TABLE that removed the table it stages rows for. Either way
53
+ * any data op that would merge or flush it must throw this message. Undefined =
54
+ * healthy. Cleared only by discarding the overlay (rollback / commit-failure →
55
+ * rollback).
44
56
  */
45
57
  poison?: {
46
58
  message: string;
@@ -62,7 +74,10 @@ export interface ConnectionOverlayState {
62
74
  *
63
75
  * This provides ACID semantics including:
64
76
  * - Read-your-own-writes within a transaction
65
- * - Snapshot isolation (reads see consistent state)
77
+ * - Read-committed reads of shared state (the underlying table is live and shared
78
+ * across connections — this is NOT snapshot isolation; another connection's commit
79
+ * can become visible mid-transaction, and there is no write-write conflict
80
+ * detection). A stable snapshot, if needed, is the underlying module's job.
66
81
  * - Savepoint support via overlay module's transaction support
67
82
  */
68
83
  export declare class IsolationModule implements VirtualTableModule<IsolatedTable, BaseModuleConfig> {
@@ -206,10 +221,30 @@ export declare class IsolationModule implements VirtualTableModule<IsolatedTable
206
221
  */
207
222
  setConnectionOverlay(db: Database, schemaName: string, tableName: string, state: ConnectionOverlayState): void;
208
223
  /**
209
- * Removes the overlay state for a specific connection and table.
210
- * Called after commit/rollback to clean up.
224
+ * Frees the in-memory staging (overlay) table backing `state` by calling the overlay
225
+ * module's `destroy`, so its manager entry (and the rows it holds) is removed from the
226
+ * overlay module's table registry rather than leaking there for the life of the
227
+ * `Database`. This is the single sink every overlay-discard path funnels through —
228
+ * without it, `MemoryTableModule.tables` accumulates one dead `_overlay_<table>_<id>`
229
+ * entry per writing transaction (and one more per rebuild), unbounded.
230
+ *
231
+ * `MemoryTableManager.destroy` rolls back the overlay's own pending layer and clears its
232
+ * connections; a later db-side teardown of the (now-detached) `MemoryVirtualTableConnection`
233
+ * is tolerated by `MemoryTableManager.disconnect` (`!connection` → no-op), so destroying
234
+ * here mid-commit/rollback does not throw when the connection is torn down afterwards.
235
+ *
236
+ * Defensive on a missing schema: real overlays always carry one (`createOverlaySchema`),
237
+ * so a schemaless state can only be a malformed/test-fabricated one — skip rather than throw.
238
+ */
239
+ private releaseOverlayTable;
240
+ /**
241
+ * Removes the overlay state for a specific connection and table, first releasing its
242
+ * staging table so it does not leak (see {@link releaseOverlayTable}). Async because the
243
+ * release drives the overlay module's `destroy`; all callers (`clearOverlay`, `alterSchema`)
244
+ * are already async and `await` it. Called on the rollback / alter-schema / rollback-to-
245
+ * pre-overlay-savepoint discard paths.
211
246
  */
212
- clearConnectionOverlay(db: Database, schemaName: string, tableName: string): void;
247
+ clearConnectionOverlay(db: Database, schemaName: string, tableName: string): Promise<void>;
213
248
  /**
214
249
  * Returns (creating if absent) the set of savepoint depths that pre-date the overlay
215
250
  * for this connection+table. Shared across all IsolatedTable instances in the
@@ -218,6 +253,72 @@ export declare class IsolationModule implements VirtualTableModule<IsolatedTable
218
253
  getPreOverlaySavepoints(db: Database, schemaName: string, tableName: string): Set<number>;
219
254
  /** Removes the pre-overlay savepoint set for a connection+table. */
220
255
  clearPreOverlaySavepoints(db: Database, schemaName: string, tableName: string): void;
256
+ /**
257
+ * Returns every key of a connection-scoped map (`<dbId>:<schema>.<table>`, the
258
+ * shape of {@link connectionOverlays} / {@link preOverlaySavepoints} /
259
+ * {@link connectionInFlight}) that belongs to `schemaName.tableName`, across ALL
260
+ * db ids. Those maps embed the db id as a prefix, so a per-table sweep is a suffix
261
+ * match on `:<schema>.<table>`. Keys are stored lowercased, so the suffix is too.
262
+ *
263
+ * The keys are materialized into an array rather than yielded, so callers may
264
+ * delete or re-key entries while walking the result.
265
+ */
266
+ private connectionScopedKeys;
267
+ /**
268
+ * Commits every overlay this db-transaction staged as ONE coordinated two-phase
269
+ * flush, instead of each table flushing+committing its own underlying
270
+ * independently. The per-table approach tears a multi-table commit: table A's
271
+ * underlying `commit()` durably lands (and, for a shared-coordinator
272
+ * `quereus-store`, flushes *every* pending table) before table B has even
273
+ * applied, so a failure in B leaves A committed. See the fix ticket and
274
+ * `quereus-store/README` § "Atomic multi-store commit".
275
+ *
276
+ * Phase 1 (apply): for every staged overlay, begin its underlying table and
277
+ * apply the overlay's rows WITHOUT committing (see {@link applyOverlayToUnderlying}).
278
+ * For a `quereus-store` underlying, every table's writes accumulate in the
279
+ * module's single shared coordinator (the first `begin()` opens it; the rest are
280
+ * idempotent no-ops).
281
+ *
282
+ * Phase 2 (commit): once ALL overlays have applied, commit the affected
283
+ * underlying tables. For `quereus-store` the first `commit()` flushes every
284
+ * table's ops in one atomic coordinator commit — a single `AtomicBatch.write()`
285
+ * on a provider that exposes `beginAtomicBatch` — and the rest no-op. For an
286
+ * underlying with per-table transaction domains (the memory vtab), each table
287
+ * commits independently.
288
+ *
289
+ * On any Phase-1 error, roll back every underlying begun so far and rethrow;
290
+ * nothing was committed, so the transaction aborts atomically. Because all the
291
+ * fallible data work (constraint re-checks, injected/IO write errors) happens in
292
+ * Phase 1 before any commit, a data-driven abort is always clean. Full
293
+ * crash-atomicity across the commit phase itself is contingent on the underlying
294
+ * exposing a shared atomic commit domain (see docs/design-isolation-layer.md
295
+ * § "Commit Failure Recovery").
296
+ *
297
+ * A poisoned overlay aborts the whole commit before any apply — mirroring the
298
+ * per-connection `assertOverlayUsable` check, now with the added benefit that no earlier
299
+ * table is left committed. The overlay is left intact so the ensuing rollback discards
300
+ * it. Two DDLs poison: a cross-connection ALTER (rows left in the pre-alter layout) and
301
+ * a cross-connection DROP TABLE (the table is gone; see {@link destroy}).
302
+ *
303
+ * Driven once per db-transaction: the first `IsolatedConnection.commit()` in the
304
+ * database's commit loop runs this whole flush and clears every overlay, so the
305
+ * remaining connections find no overlay for their table and this is a no-op — no
306
+ * explicit "already flushed" latch is needed, the cleared-overlay state guards
307
+ * itself.
308
+ *
309
+ * **Invariant: every staged overlay resolves to an underlying table here, or is
310
+ * poisoned.** The table-lifecycle hooks are what keep that true — {@link destroy}
311
+ * discards or poisons the overlays of a dropped table across every connection, and
312
+ * {@link renameTable} re-connects the underlying under the new name whenever it re-keys
313
+ * an overlay onto it. The poison check above is the enforcement point: it runs BEFORE
314
+ * the `underlyingTables` lookup, so a dropped table's surviving foreign overlay raises
315
+ * its poison message rather than the orphan error below. A miss that is neither resolved
316
+ * nor poisoned is therefore a layer-invariant violation, not a routine condition, and is
317
+ * raised as `StatusCode.INTERNAL`: the alternative — dropping the staged rows and letting
318
+ * the commit report success — is silent data loss. Only a CLEAN overlay
319
+ * (`hasChanges === false`) may miss harmlessly; it staged nothing, so it is discarded.
320
+ */
321
+ commitConnectionOverlays(db: Database): Promise<void>;
221
322
  /**
222
323
  * Coalesces concurrent covering-connection builds for one (db, table) onto a
223
324
  * single in-flight promise, keyed identically to {@link connectionOverlays}
@@ -248,6 +349,13 @@ export declare class IsolationModule implements VirtualTableModule<IsolatedTable
248
349
  private getDbId;
249
350
  /**
250
351
  * Returns capabilities combining underlying module with isolation guarantees.
352
+ *
353
+ * `ddlTransactionality` is forwarded verbatim through the spread — the wrapper
354
+ * NEVER upgrades it. The overlay stages DML outside the underlying module, so an
355
+ * underlying DDL-commit flushes only module-side ops, leaving overlay writes
356
+ * behind (the `bug-store-savepoint-ddl-drop-lost-insert` asymmetry). Forwarding
357
+ * the underlying's (pessimistic) value is the honest choice; only `isolation` /
358
+ * `savepoints` are augmented, since the wrapper genuinely adds those.
251
359
  */
252
360
  getCapabilities(): ModuleCapabilities;
253
361
  /**
@@ -324,25 +432,168 @@ export declare class IsolationModule implements VirtualTableModule<IsolatedTable
324
432
  */
325
433
  connect(db: Database, pAux: unknown, moduleName: string, schemaName: string, tableName: string, options: BaseModuleConfig, tableSchema?: TableSchema): Promise<IsolatedTable>;
326
434
  /**
327
- * Destroys the underlying table.
435
+ * Destroys the underlying table, then resolves every connection's staged state for it.
436
+ *
437
+ * DROP TABLE is not transaction-scoped: the table is gone for *every* connection the
438
+ * moment this returns, so no overlay staging writes against it can ever be flushed.
439
+ * What differs is who gets told. Per overlay key matching the dropped table (both maps
440
+ * are keyed `<dbId>:<schema>.<table>`, so the sweep spans all db ids):
441
+ *
442
+ * - **The dropping connection's own overlay** is discarded silently. It issued the DROP;
443
+ * there is nobody to notify.
444
+ * - **A foreign overlay with staged rows** (`hasChanges`) is **poisoned**, not swept.
445
+ * Sweeping it let that connection commit against an empty overlay set and report
446
+ * success after its rows were thrown away — silent cross-connection data loss. Poison
447
+ * makes its next read/write/commit throw `CONSTRAINT` (see
448
+ * {@link IsolatedTable.assertOverlayUsable} and the poison check at the head of
449
+ * {@link commitConnectionOverlays}, which precedes the `underlyingTables` lookup and so
450
+ * raises the poison message rather than the orphan INTERNAL error). An already-poisoned
451
+ * overlay keeps its original message — the first cause is the one worth reporting.
452
+ * - **A foreign overlay with no staged rows** is discarded: it staged nothing, so nothing
453
+ * is lost.
454
+ *
455
+ * `preOverlaySavepoints` is swept for every matching key whose overlay did NOT survive.
456
+ * A surviving poisoned overlay keeps its set: `ensureOverlay` padding still consults it,
457
+ * and the owning connection's `onConnectionRollback` reaps it when its failed commit
458
+ * rolls back. Without the sweep, an abandoned set outlived the table for the lifetime of
459
+ * the `Database` (nothing else is keyed to reap it once the table is gone).
460
+ *
461
+ * Nothing is discarded or poisoned until the underlying destroy SUCCEEDS. A throwing
462
+ * `underlying.destroy` means the table still exists, so every connection's staged
463
+ * writes are still flushable and every map entry must survive untouched — the same
464
+ * reason {@link renameTable} delegates before mutating its maps.
465
+ *
466
+ * NOTE: poison rides on the `ConnectionOverlayState`, not on its rows, so a foreign
467
+ * connection that later unwinds every staged row past the drop (rollback to a savepoint
468
+ * taken after the overlay existed) still fails its commit. Deliberately over-strict —
469
+ * the table is gone either way. If a caller ever needs the clean-unwind case to commit,
470
+ * re-evaluate the poison on `onConnectionRollbackToSavepoint` rather than special-casing
471
+ * here.
472
+ *
473
+ * NOTE: a connection whose own overlay was already poisoned (by another connection's
474
+ * ALTER) escapes that poison for this table by dropping it — the own-overlay branch
475
+ * deletes the state, poison and all. Correct as written: the rows it discards belong to
476
+ * a table this connection just asked to remove. If poison ever carries a cause that
477
+ * outlives the table, gate the own-overlay delete on it.
478
+ *
479
+ * NOTE: this mutates `connectionOverlays` while a foreign connection may be mid-scan in
480
+ * `IsolatedTable.query`'s merged branch — that scan will keep merging against an overlay
481
+ * whose underlying is now destroyed. The module clamps to `'reentrant-reads'`, so no
482
+ * in-tree host reaches it. If a host ever runs a DROP concurrently with a foreign scan,
483
+ * the merged iterator needs a per-scan snapshot of the overlay + underlying pair.
328
484
  */
329
485
  destroy(db: Database, pAux: unknown, moduleName: string, schemaName: string, tableName: string): Promise<void>;
486
+ /**
487
+ * Inserts one staged row into a freshly built overlay, raising on anything but success.
488
+ *
489
+ * `MemoryTable.update` RETURNS a `constraint` status rather than throwing it. Every overlay
490
+ * rebuild loop ignored that return, so a row the new schema forbids was dropped on the floor
491
+ * and the transaction committed without it — silent data loss, reachable today by
492
+ * `alter table … add constraint … unique` over pending duplicate rows. Convert it into a
493
+ * throw; {@link adoptRebuiltOverlay} decides whether that means INTERNAL (the issuer, whose
494
+ * rows the DDL's own validation pass already accepted) or poison (a foreign connection,
495
+ * which must roll back).
496
+ */
497
+ private insertIntoRebuiltOverlay;
498
+ /**
499
+ * Runs one overlay's rebuild and installs the result, routing a CONSTRAINT failure by who
500
+ * owns the overlay:
501
+ *
502
+ * - **The DDL-issuing connection.** Unreachable: the row source handed to the underlying
503
+ * (see {@link issuerEffectiveRows}) judged a superset of exactly these rows and accepted
504
+ * them, so a rejection here means validation and migration have drifted. Raise INTERNAL —
505
+ * loudly, because the alternative is the silent row loss this guard exists to end.
506
+ * - **A foreign connection.** Reachable and legitimate: its staged rows may violate a
507
+ * constraint another connection just declared. Poison that overlay and leave it
508
+ * unmigrated, so its owner errors on its next read/write/commit and rolls back. The
509
+ * issuer's DDL proceeds. Mirrors the tier-3 NOT NULL handling in {@link alterTable}.
510
+ *
511
+ * A rebuild that throws leaves the OLD overlay installed either way — the new table is
512
+ * simply discarded.
513
+ */
514
+ private adoptRebuiltOverlay;
515
+ /**
516
+ * Builds the poison message stamped onto a foreign overlay whose staged rows cannot be
517
+ * migrated under a constraint another connection's DDL just declared (see
518
+ * {@link adoptRebuiltOverlay}). Companion to {@link buildAlterPoisonMessage}, which covers
519
+ * the `addColumn` NOT NULL backfill rejected before the underlying is touched; this one
520
+ * covers a UNIQUE (or any other) violation raised by the rebuild itself.
521
+ */
522
+ private buildRebuildPoisonMessage;
523
+ /**
524
+ * Builds the poison message stamped onto a foreign overlay whose table was dropped out
525
+ * from under it (see {@link destroy}). Names the schema.table so the owning connection's
526
+ * eventual read/write/commit error is self-explanatory. Companion to
527
+ * {@link buildAlterPoisonMessage}: both poison sources raise the same
528
+ * `StatusCode.CONSTRAINT` and are told apart by their message, not their code.
529
+ */
530
+ private buildDropPoisonMessage;
330
531
  /**
331
532
  * Closes all resources held by the underlying module (if it supports closeAll).
332
533
  * Also clears connection overlay state.
333
534
  */
334
535
  closeAll(): Promise<void>;
335
536
  /**
336
- * Creates an index on the underlying table.
537
+ * The rows the connection owning `overlayState` can SEE — the underlying's committed rows
538
+ * merged with that overlay's staged writes. Re-callable, as `EffectiveRowSource` requires.
539
+ *
540
+ * This is the seam the whole fix turns on: the underlying module validates row-content DDL
541
+ * (UNIQUE duplicate detection, collation-rekey collisions) against its OWN rows, which under
542
+ * isolation are the committed rows only. The transaction's pending rows live here, in the
543
+ * overlay, where the underlying cannot reach them — so we hand them down.
544
+ *
545
+ * NOTE: each call re-materializes the overlay and re-scans the underlying. `alter column …
546
+ * set collate` calls once per UNIQUE constraint covering the altered column, so a table with
547
+ * many such constraints pays that many scans. If it ever shows up as slow, materialize the
548
+ * overlay's PK map once per DDL and share it across the calls.
549
+ */
550
+ private effectiveRowsFor;
551
+ /**
552
+ * The row source to hand a row-validating DDL on behalf of the connection issuing it, or
553
+ * undefined when that connection has nothing staged and the underlying's own rows already
554
+ * ARE its effective rows.
555
+ *
556
+ * **Only the issuing connection's overlay feeds validation.** A foreign connection's
557
+ * overlay may hold rows that collide with the new constraint; that is its problem when it
558
+ * commits, exactly as an ordinary concurrent duplicate insert would be. A poisoned issuer
559
+ * overlay is likewise skipped — its rows are structurally stale, and the connection can
560
+ * only recover by rolling back.
561
+ */
562
+ private issuerEffectiveRows;
563
+ /**
564
+ * Creates an index on the underlying table, then rebuilds every per-connection overlay so
565
+ * the new index (and, for a UNIQUE index, the constraint derived from it) is enforced for
566
+ * the rest of each open transaction.
567
+ *
568
+ * Two things the underlying cannot do for itself:
337
569
  *
338
- * Note: Indexes on per-connection overlays are created lazily when the
339
- * overlay is created, by copying from the underlying table's schema.
570
+ * 1. **Judge the right rows.** The issuing connection's pending rows are in its overlay,
571
+ * invisible to the underlying, so a duplicate it staged would slip past the build and a
572
+ * duplicate it deleted would spuriously reject it. {@link issuerEffectiveRows} supplies
573
+ * the merged view; the underlying builds its physical structure from its own committed
574
+ * rows, which is sound because every reader resolves an index entry back to its live row.
575
+ * 2. **Enforce the new constraint.** An overlay built before the index knows nothing of it,
576
+ * and `IsolatedTable.findMergedUniqueConflict` only scans the underlying — so a pending
577
+ * row colliding with another pending row is nobody's job until the overlay itself carries
578
+ * the index. Hence the rebuild, which is also what gives a merged secondary-index scan
579
+ * later in the transaction an overlay that can serve it.
580
+ *
581
+ * We use the stored table instance's createIndex() rather than the module-level method so
582
+ * that the MemoryTable's local tableSchema property stays in sync. That property is what
583
+ * ensureOverlay() reads when building the overlay schema.
584
+ */
585
+ createIndex(db: Database, schemaName: string, tableName: string, indexSchema: IndexSchema, rows?: EffectiveRowSource): Promise<void>;
586
+ /**
587
+ * Reads back the underlying table instance's post-`createIndex` schema, asserting it now
588
+ * carries the new index.
340
589
  *
341
- * We use the stored table instance's createIndex() rather than the module-level
342
- * method so that the MemoryTable's local tableSchema property stays in sync.
343
- * That property is what ensureOverlay() reads when building the overlay schema.
590
+ * Both bundled underlyings refresh the instance's cached `tableSchema` (memory through
591
+ * `MemoryTable.createIndex`, the store through `StoreTable.updateSchema`), and the overlay
592
+ * rebuild below copies its index/constraint set from it. A third-party underlying that
593
+ * refreshed only its module-level schema would silently rebuild overlays under the PRE-index
594
+ * schema, re-opening the very hole this method exists to close — so assert rather than assume.
344
595
  */
345
- createIndex(db: Database, schemaName: string, tableName: string, indexSchema: IndexSchema): Promise<void>;
596
+ private assertIndexPresent;
346
597
  /**
347
598
  * Drops an index on the underlying table.
348
599
  *
@@ -366,11 +617,24 @@ export declare class IsolationModule implements VirtualTableModule<IsolatedTable
366
617
  */
367
618
  dropIndex(db: Database, schemaName: string, tableName: string, indexName: string): Promise<void>;
368
619
  /**
369
- * Rebuilds an overlay table under the post-drop-index schema, preserving
370
- * staged rows (including tombstones). Column layout is unchanged by
371
- * DROP INDEX, so rows can be copied verbatim.
620
+ * Rebuilds every non-poisoned per-connection overlay of one table under a schema whose
621
+ * index / constraint set just changed (CREATE INDEX or DROP INDEX). Shared because the two
622
+ * directions differ only in which structures the new schema carries — the column layout is
623
+ * identical either way, so staged rows copy verbatim.
624
+ *
625
+ * A poisoned overlay (from a cross-connection ALTER, or a DROP TABLE) holds rows in the
626
+ * pre-alter column layout, narrower/wider than `updatedSchema`. Rebuilding it would copy
627
+ * layout-mismatched rows AND drop the poison flag (the new state carries none), silently
628
+ * un-poisoning a connection that must still roll back. Leave it as-is.
629
+ */
630
+ private rebuildOverlaysForIndexChange;
631
+ /**
632
+ * Rebuilds an overlay table under a post-CREATE/DROP-INDEX schema, preserving staged rows
633
+ * (including tombstones). Column layout is unchanged by either, so rows copy verbatim — but
634
+ * the new overlay's index/constraint set is not, so an insert here can legitimately raise
635
+ * UNIQUE (a foreign connection staged two rows the new index forbids).
372
636
  */
373
- private migrateOverlayForDropIndex;
637
+ private rebuildOverlayForIndexChange;
374
638
  /**
375
639
  * Delegates ALTER TABLE to the underlying module and migrates any per-connection
376
640
  * overlays to the post-alter schema without discarding staged rows.
@@ -392,15 +656,21 @@ export declare class IsolationModule implements VirtualTableModule<IsolatedTable
392
656
  * ALTER either fails clean or fully applies — base/catalog can no longer diverge.
393
657
  * This mirrors the engine's pre-mutation `validateNotNullBackfill` in
394
658
  * `runtime/emit/alter-table.ts`.
659
+ *
660
+ * **Row-content validation.** The row-validating arms (`add constraint … unique`,
661
+ * `alter column … set collate`) judge the ISSUING connection's effective rows, not the
662
+ * underlying's committed ones — see {@link issuerEffectiveRows}. The underlying runs that
663
+ * check before it mutates anything, so the atomic-abort guarantee above still holds.
395
664
  */
396
- alterTable(db: Database, schemaName: string, tableName: string, change: SchemaChangeInfo): Promise<TableSchema>;
665
+ alterTable(db: Database, schemaName: string, tableName: string, change: SchemaChangeInfo, rows?: EffectiveRowSource): Promise<TableSchema>;
397
666
  /**
398
667
  * Builds the poison message stamped onto a foreign overlay whose backfill could not
399
668
  * satisfy a cross-connection ALTER (see {@link alterTable} tier 3). Names the
400
669
  * schema.table and the offending column so the owning connection's eventual
401
- * read/write/commit error is self-explanatory. Poison only arises on the addColumn
402
- * NOT NULL path, so the column name is taken from the addColumn change; other change
403
- * types never reach here but are handled defensively.
670
+ * read/write/commit error is self-explanatory. Poison arises on the addColumn NOT NULL
671
+ * path (a new NOT-NULL column with no usable default) and the `set not null` tightening
672
+ * path (a staged NULL with no usable default); other change types never reach here but
673
+ * are handled defensively.
404
674
  */
405
675
  private buildAlterPoisonMessage;
406
676
  /**
@@ -414,16 +684,60 @@ export declare class IsolationModule implements VirtualTableModule<IsolatedTable
414
684
  * Done in this order so a failure in the underlying rename leaves our
415
685
  * internal maps untouched (the engine will not update the schema catalog
416
686
  * if this method throws).
687
+ *
688
+ * **Why the underlying is re-connected, not re-keyed.** A rename mid-transaction
689
+ * moves any staged overlay onto the new name, and `commitConnectionOverlays`
690
+ * resolves an overlay's underlying by that name. Simply re-keying
691
+ * `underlyingTables` old→new would be cheaper, but the cached `VirtualTable` may
692
+ * be dead: `StoreModule.renameTable` closes and re-opens the store, so the stale
693
+ * handle yields "store is closed". So we evict it and, when an overlay was
694
+ * carried onto the new name, immediately connect a fresh underlying under that
695
+ * name — otherwise the transaction commits against a table that is in neither
696
+ * map, and the overlay's rows vanish (see {@link commitConnectionOverlays}'s
697
+ * invariant). With no overlay carried over there is nothing to flush, so the
698
+ * eviction alone is enough and the next `connect()` re-resolves lazily.
417
699
  */
418
700
  renameTable(db: Database, schemaName: string, oldName: string, newName: string): Promise<void>;
701
+ /**
702
+ * Forward the engine's post-propagation rename finalize to the underlying (see
703
+ * {@link renameTable} for the two-phase split). The underlying (e.g. `StoreModule`)
704
+ * uses it to drop the old name's catalog entry only after the cross-table rewrites
705
+ * `propagateTableRename` enqueued are durable. `IsolationModule` owns no persistent
706
+ * catalog of its own and already evicted every old-name state in `renameTable`, so
707
+ * it simply delegates.
708
+ */
709
+ finalizeRename(db: Database, schemaName: string, oldName: string, newName: string): Promise<void>;
710
+ /**
711
+ * Connects a fresh underlying table under the post-rename name and records it in
712
+ * `underlyingTables`, restoring the "every staged overlay resolves to an underlying"
713
+ * invariant that {@link renameTable}'s eviction would otherwise break.
714
+ *
715
+ * `preRenameSchema` is the catalog's pre-rename `TableSchema`; it is cloned under the
716
+ * new name so the underlying module sees the same column layout, PK, and vtab args it
717
+ * was created with.
718
+ *
719
+ * NOTE: `pAux` is passed as `undefined`: the aux data the engine hands
720
+ * `IsolationModule.connect()` belongs to *this* wrapper's registration, not the
721
+ * underlying's, and both bundled underlyings (`MemoryTableModule`, `StoreModule`)
722
+ * ignore the parameter — the same assumption `connect()` already relies on when it
723
+ * forwards its own caller's `pAux` straight through. If a third-party underlying ever
724
+ * reads `pAux` in `connect()`, `IsolationModule` must capture the underlying's own aux
725
+ * data at registration and hand it back here.
726
+ */
727
+ private reconnectUnderlyingAfterRename;
419
728
  /**
420
729
  * Re-keys all entries of a connection-scoped map (`<dbId>:<schema>.<table>`)
421
730
  * from oldName to newName, leaving entries for other tables untouched.
731
+ * Returns how many entries moved.
422
732
  */
423
733
  private rekeyConnectionScopedMap;
424
734
  /**
425
735
  * Rebuilds an overlay table under the post-alter schema, translating each
426
736
  * staged row to the new column layout.
737
+ *
738
+ * A row the post-alter schema's constraints reject throws CONSTRAINT out of
739
+ * {@link insertIntoRebuiltOverlay} rather than being silently discarded; the caller
740
+ * ({@link adoptRebuiltOverlay}) maps that to INTERNAL or poison.
427
741
  */
428
742
  private migrateOverlayForAlter;
429
743
  /**
@@ -442,6 +756,20 @@ export declare class IsolationModule implements VirtualTableModule<IsolatedTable
442
756
  * BEFORE the irreversible underlying mutation and reused by the migration after.
443
757
  */
444
758
  private deriveAddColumnBackfill;
759
+ /**
760
+ * Precomputes the per-ALTER constants an `alter column … set not null` overlay migration needs:
761
+ * the now-NOT-NULL column's index and the folded literal DEFAULT (with `hasDefault` gating
762
+ * backfill vs reject). Returns undefined unless this is a NOT NULL *tightening*
763
+ * (`setNotNull: true`) with at least one overlay to migrate — a DROP NOT NULL loosens and
764
+ * needs no staged-row work, and with no overlays there is nothing to backfill or reject.
765
+ *
766
+ * `change` for `set not null` carries no default expression, so the DEFAULT is read from the
767
+ * column's PRE-alter schema (via a to-be-migrated overlay — the same source `dropColumnIdx`
768
+ * uses, and the same layout every migrated overlay shares). Folded exactly as
769
+ * {@link deriveAddColumnBackfill} folds its DEFAULT, so backfill and reject decisions here
770
+ * cannot drift from what the underlying enforces over its committed rows.
771
+ */
772
+ private deriveSetNotNullBackfill;
445
773
  /**
446
774
  * Dry-runs an overlay's ALTER migration-fallible work without mutating anything,
447
775
  * so the caller can run it for every affected overlay BEFORE the irreversible
@@ -456,8 +784,15 @@ export declare class IsolationModule implements VirtualTableModule<IsolatedTable
456
784
  * rows short-circuit to `null` (the evaluator never runs), and a NOT-NULL-violating
457
785
  * evaluated row throws CONSTRAINT here, atomically. Computed values are discarded.
458
786
  *
459
- * Non-addColumn changes (`addColumnCtx === undefined`) only run the tombstone guard;
460
- * their row translation appends/removes nothing fallible on data grounds.
787
+ * For `set not null` with NO usable DEFAULT (`setNotNullCtx.hasDefault === false`), a staged
788
+ * non-tombstone NULL at the now-NOT-NULL column throws CONSTRAINT here — for the issuer this
789
+ * aborts atomically before the underlying mutates; for a foreign overlay the caller maps it to
790
+ * poison. With a usable DEFAULT the staged NULLs are backfilled by {@link translateOverlayRow},
791
+ * so nothing is rejected here.
792
+ *
793
+ * Non-addColumn / non-tightening changes (`addColumnCtx === undefined` and no reject-mode
794
+ * `setNotNullCtx`) only run the tombstone guard; their row translation appends/removes nothing
795
+ * fallible on data grounds.
461
796
  */
462
797
  private validateOverlayMigration;
463
798
  /**
@@ -481,16 +816,43 @@ export declare class IsolationModule implements VirtualTableModule<IsolatedTable
481
816
  * `addColumnValue` is the per-row value the caller computed for an `addColumn`
482
817
  * (via {@link computeAddColumnValue}); it is `undefined` for every other change
483
818
  * type. Keeping the (async) backfill in the caller's loop lets this stay synchronous.
819
+ *
820
+ * `setNotNullCtx` (present only for a `set not null` tightening WITH a usable DEFAULT) maps a
821
+ * staged NULL at the now-NOT-NULL column to that DEFAULT — filling the issuer's own pending
822
+ * rows, which the underlying's committed-row backfill never touches. Reject-mode contexts (no
823
+ * DEFAULT) never reach here: {@link validateOverlayMigration} aborts/poisons first.
484
824
  */
485
825
  private translateOverlayRow;
486
- /** Creates a FilterInfo for a full table scan (no constraints). */
487
- private makeFullScanFilterInfo;
488
826
  /**
489
827
  * Creates overlay schema from underlying schema.
490
828
  * Adds tombstone column and uses unique name to avoid conflicts.
491
829
  *
492
- * Called by IsolatedTable when lazily creating its overlay.
830
+ * Called by IsolatedTable when lazily creating its overlay, and by the two overlay-rebuild
831
+ * paths (`rebuildOverlayForIndexChange`, `migrateOverlayForAlter`).
832
+ *
833
+ * Every copied secondary index — and every copied UNIQUE constraint, including the ones
834
+ * a UNIQUE index derives — is narrowed to a PARTIAL structure over live rows only
835
+ * (`<tombstone> = 0`), AND-ed onto whatever partial predicate it already carried. A
836
+ * tombstone is a deletion marker, not a row, so no uniqueness rule may be evaluated over
837
+ * it: it carries its row's PK and NULL everywhere else, so a UNIQUE structure whose
838
+ * columns all sit inside the PK would otherwise see two deleted rows as duplicates.
839
+ * (Non-PK unique columns escaped only because their tombstone key is NULL and SQL treats
840
+ * NULLs as distinct.) The overlay's PRIMARY KEY uniqueness is NOT narrowed — it must keep
841
+ * covering tombstones so a re-insert at a tombstoned PK is detected and converted.
842
+ *
843
+ * `IsolatedTable.mergedSecondaryIndexQuery` wants exactly the live overlay rows out of
844
+ * these indexes, so narrowing them is what it already expects.
493
845
  */
494
846
  createOverlaySchema(baseSchema: TableSchema): TableSchema;
847
+ /**
848
+ * `<tombstoneColumn> = 0` — the partial-structure predicate that scopes an overlay index
849
+ * or UNIQUE constraint to live rows. Built as an AST rather than parsed from text because
850
+ * the tombstone column name is host-configurable.
851
+ *
852
+ * NOTE: the default overlay is a `MemoryTableModule`, which honors `IndexSchema.predicate`
853
+ * and `UniqueConstraintSchema.predicate`. A host that injects its own `config.overlay`
854
+ * module must honor them too, or its overlay will re-enforce uniqueness over tombstones.
855
+ */
856
+ private liveRowPredicate;
495
857
  }
496
858
  //# sourceMappingURL=isolation-module.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"isolation-module.d.ts","sourceRoot":"","sources":["../../src/isolation-module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,WAAW,EAAE,gBAAgB,IAAI,WAAW,EAAE,kBAAkB,EAAE,YAAY,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,gBAAgB,EAA6B,MAAM,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEjX,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIpD;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAcD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,mBAAmB,EAAE,CAAC,EAAE,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