@quereus/store 4.4.1 → 4.6.0

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.
Files changed (104) hide show
  1. package/README.md +538 -491
  2. package/dist/src/common/encoding.d.ts +4 -3
  3. package/dist/src/common/encoding.d.ts.map +1 -1
  4. package/dist/src/common/encoding.js +17 -13
  5. package/dist/src/common/encoding.js.map +1 -1
  6. package/dist/src/common/events.d.ts +5 -1
  7. package/dist/src/common/events.d.ts.map +1 -1
  8. package/dist/src/common/events.js.map +1 -1
  9. package/dist/src/common/implicit-unique-index.d.ts +80 -0
  10. package/dist/src/common/implicit-unique-index.d.ts.map +1 -0
  11. package/dist/src/common/implicit-unique-index.js +148 -0
  12. package/dist/src/common/implicit-unique-index.js.map +1 -0
  13. package/dist/src/common/index.d.ts +7 -3
  14. package/dist/src/common/index.d.ts.map +1 -1
  15. package/dist/src/common/index.js +5 -2
  16. package/dist/src/common/index.js.map +1 -1
  17. package/dist/src/common/json-key.d.ts +2 -2
  18. package/dist/src/common/json-key.js +2 -2
  19. package/dist/src/common/key-builder.d.ts +40 -20
  20. package/dist/src/common/key-builder.d.ts.map +1 -1
  21. package/dist/src/common/key-builder.js +31 -23
  22. package/dist/src/common/key-builder.js.map +1 -1
  23. package/dist/src/common/kv-store.d.ts +10 -0
  24. package/dist/src/common/kv-store.d.ts.map +1 -1
  25. package/dist/src/common/pk-key-resolution.d.ts +275 -0
  26. package/dist/src/common/pk-key-resolution.d.ts.map +1 -0
  27. package/dist/src/common/pk-key-resolution.js +389 -0
  28. package/dist/src/common/pk-key-resolution.js.map +1 -0
  29. package/dist/src/common/store-module-access-plan.d.ts +32 -0
  30. package/dist/src/common/store-module-access-plan.d.ts.map +1 -0
  31. package/dist/src/common/store-module-access-plan.js +424 -0
  32. package/dist/src/common/store-module-access-plan.js.map +1 -0
  33. package/dist/src/common/store-module-alter-column.d.ts +23 -0
  34. package/dist/src/common/store-module-alter-column.d.ts.map +1 -0
  35. package/dist/src/common/store-module-alter-column.js +393 -0
  36. package/dist/src/common/store-module-alter-column.js.map +1 -0
  37. package/dist/src/common/store-module-alter.d.ts +55 -0
  38. package/dist/src/common/store-module-alter.d.ts.map +1 -0
  39. package/dist/src/common/store-module-alter.js +519 -0
  40. package/dist/src/common/store-module-alter.js.map +1 -0
  41. package/dist/src/common/store-module-base.d.ts +268 -0
  42. package/dist/src/common/store-module-base.d.ts.map +1 -0
  43. package/dist/src/common/store-module-base.js +362 -0
  44. package/dist/src/common/store-module-base.js.map +1 -0
  45. package/dist/src/common/store-module-catalog.d.ts +269 -0
  46. package/dist/src/common/store-module-catalog.d.ts.map +1 -0
  47. package/dist/src/common/store-module-catalog.js +462 -0
  48. package/dist/src/common/store-module-catalog.js.map +1 -0
  49. package/dist/src/common/store-module-index-build.d.ts +88 -0
  50. package/dist/src/common/store-module-index-build.d.ts.map +1 -0
  51. package/dist/src/common/store-module-index-build.js +280 -0
  52. package/dist/src/common/store-module-index-build.js.map +1 -0
  53. package/dist/src/common/store-module-index.d.ts +116 -0
  54. package/dist/src/common/store-module-index.d.ts.map +1 -0
  55. package/dist/src/common/store-module-index.js +373 -0
  56. package/dist/src/common/store-module-index.js.map +1 -0
  57. package/dist/src/common/store-module-rename.d.ts +49 -0
  58. package/dist/src/common/store-module-rename.d.ts.map +1 -0
  59. package/dist/src/common/store-module-rename.js +244 -0
  60. package/dist/src/common/store-module-rename.js.map +1 -0
  61. package/dist/src/common/store-module-schema-rewrite.d.ts +57 -0
  62. package/dist/src/common/store-module-schema-rewrite.d.ts.map +1 -0
  63. package/dist/src/common/store-module-schema-rewrite.js +140 -0
  64. package/dist/src/common/store-module-schema-rewrite.js.map +1 -0
  65. package/dist/src/common/store-module-schema-sync.d.ts +232 -0
  66. package/dist/src/common/store-module-schema-sync.d.ts.map +1 -0
  67. package/dist/src/common/store-module-schema-sync.js +529 -0
  68. package/dist/src/common/store-module-schema-sync.js.map +1 -0
  69. package/dist/src/common/store-module.d.ts +43 -909
  70. package/dist/src/common/store-module.d.ts.map +1 -1
  71. package/dist/src/common/store-module.js +184 -3194
  72. package/dist/src/common/store-module.js.map +1 -1
  73. package/dist/src/common/store-table-base.d.ts +523 -0
  74. package/dist/src/common/store-table-base.d.ts.map +1 -0
  75. package/dist/src/common/store-table-base.js +878 -0
  76. package/dist/src/common/store-table-base.js.map +1 -0
  77. package/dist/src/common/store-table-constraints.d.ts +237 -0
  78. package/dist/src/common/store-table-constraints.d.ts.map +1 -0
  79. package/dist/src/common/store-table-constraints.js +624 -0
  80. package/dist/src/common/store-table-constraints.js.map +1 -0
  81. package/dist/src/common/store-table-scan.d.ts +415 -0
  82. package/dist/src/common/store-table-scan.d.ts.map +1 -0
  83. package/dist/src/common/store-table-scan.js +821 -0
  84. package/dist/src/common/store-table-scan.js.map +1 -0
  85. package/dist/src/common/store-table.d.ts +71 -1044
  86. package/dist/src/common/store-table.d.ts.map +1 -1
  87. package/dist/src/common/store-table.js +130 -2131
  88. package/dist/src/common/store-table.js.map +1 -1
  89. package/dist/src/testing/index.d.ts +12 -0
  90. package/dist/src/testing/index.d.ts.map +1 -0
  91. package/dist/src/testing/index.js +12 -0
  92. package/dist/src/testing/index.js.map +1 -0
  93. package/dist/src/testing/kv-assert.d.ts +19 -0
  94. package/dist/src/testing/kv-assert.d.ts.map +1 -0
  95. package/dist/src/testing/kv-assert.js +25 -0
  96. package/dist/src/testing/kv-assert.js.map +1 -0
  97. package/dist/src/testing/kv-conformance.d.ts.map +1 -1
  98. package/dist/src/testing/kv-conformance.js +1 -15
  99. package/dist/src/testing/kv-conformance.js.map +1 -1
  100. package/dist/src/testing/kv-provider-conformance.d.ts +54 -0
  101. package/dist/src/testing/kv-provider-conformance.d.ts.map +1 -0
  102. package/dist/src/testing/kv-provider-conformance.js +183 -0
  103. package/dist/src/testing/kv-provider-conformance.js.map +1 -0
  104. package/package.json +9 -9
@@ -0,0 +1,519 @@
1
+ /**
2
+ * ALTER TABLE dispatch and every arm except ALTER COLUMN: add / drop / rename a column,
3
+ * change the primary key, and add / drop / rename a table constraint. Each arm returns
4
+ * the rewritten table schema; the dispatcher owns what is common to all of them
5
+ * (resolving the table, reconciling the implicit UNIQUE index stores afterwards).
6
+ *
7
+ * Sixth layer of the store-module chain:
8
+ * StoreModuleBase -> StoreModuleCatalog -> StoreModuleSchemaSync -> StoreModuleIndex
9
+ * -> StoreModuleAlterColumn -> StoreModuleAlter -> StoreModuleRename -> StoreModule
10
+ */
11
+ import { QuereusError, StatusCode, buildCheckConstraintSchema, buildColumnIndexMap, buildForeignKeyConstraintSchema, buildUniqueConstraintSchema, columnDefToSchema, foldDefaultToType, rekeySchemaPrimaryKey, renameColumnInCheckConstraints, renameColumnInIndexPredicates, resolveNamedConstraintClass, shiftSchemaIndicesForDrop, validateForeignKeyOverExistingRows, } from '@quereus/quereus';
12
+ import { withImplicitUniqueIndexes } from './implicit-unique-index.js';
13
+ import { StoreModuleAlterColumn } from './store-module-alter-column.js';
14
+ import { effectiveDdlRows, validateUniqueOverExistingRows } from './store-module-index-build.js';
15
+ import { buildColumnRemap, renameColumnInSelfForeignKeys } from './store-module-schema-rewrite.js';
16
+ export class StoreModuleAlter extends StoreModuleAlterColumn {
17
+ /**
18
+ * Alters an existing store table's structure. Resolves the table, captures the
19
+ * pre-alter schema, and dispatches to the per-change-type `alter*` helper below;
20
+ * the helper does the arm's work (row migration, physical re-key, constraint
21
+ * validation, DDL persist) and returns the updated TableSchema for the engine to
22
+ * register. The shared preamble (schema subscription, reconnect, not-found throw,
23
+ * `defaultNotNull`) lives here so every arm sees the same resolved state.
24
+ */
25
+ async alterTable(db, schemaName, tableName, change, rows) {
26
+ this.ensureSchemaSubscription(db);
27
+ const table = this.getOrReconnectTable(db, schemaName, tableName);
28
+ if (!table) {
29
+ throw new QuereusError(`Store table '${tableName}' not found in schema '${schemaName}'. Cannot alter.`, StatusCode.ERROR);
30
+ }
31
+ // The engine-facing schema carries no `_uc_*` (the store keeps the materialized
32
+ // enforcement copy internal), so the arms build `updatedSchema` off a clean schema
33
+ // exactly as before this feature; `table.updateSchema` recomputes the enforcement
34
+ // copy, and `StoreModuleIndex.reconcileImplicitUniqueIndexStores` moves the physical
35
+ // stores for any constraint-set change.
36
+ const oldSchema = table.getSchema();
37
+ const defaultNotNull = db.options.getStringOption('default_column_nullability') === 'not_null';
38
+ let updated;
39
+ switch (change.type) {
40
+ case 'addColumn':
41
+ updated = await this.alterAddColumn(db, schemaName, tableName, table, oldSchema, change, defaultNotNull);
42
+ break;
43
+ case 'dropColumn':
44
+ updated = await this.alterDropColumn(db, schemaName, tableName, table, oldSchema, change);
45
+ break;
46
+ case 'renameColumn':
47
+ updated = await this.alterRenameColumn(db, schemaName, tableName, table, oldSchema, change, defaultNotNull);
48
+ break;
49
+ case 'alterPrimaryKey':
50
+ updated = await this.alterPrimaryKeyChange(db, schemaName, tableName, table, oldSchema, change);
51
+ break;
52
+ case 'addConstraint':
53
+ updated = await this.alterAddConstraint(db, schemaName, tableName, table, oldSchema, change, rows);
54
+ break;
55
+ case 'dropConstraint':
56
+ updated = await this.alterDropConstraint(schemaName, tableName, table, oldSchema, change);
57
+ break;
58
+ case 'renameConstraint':
59
+ updated = await this.alterRenameConstraint(schemaName, tableName, table, oldSchema, change);
60
+ break;
61
+ case 'alterColumn':
62
+ updated = await this.alterColumnChange(db, schemaName, tableName, table, oldSchema, change, rows);
63
+ break;
64
+ default: {
65
+ const _exhaustive = change;
66
+ void _exhaustive;
67
+ throw new QuereusError(`Unhandled ALTER TABLE change type '${change.type}'`, StatusCode.INTERNAL);
68
+ }
69
+ }
70
+ // Move the physical `_uc_*` index stores to match the post-ALTER constraint set:
71
+ // the SCHEMA entries were re-materialized by the arm's `table.updateSchema`, but a
72
+ // newly-added constraint's store must be BUILT and a dropped/renamed one's TORN
73
+ // DOWN. `oldSchema` carries the pre-ALTER `uniqueConstraints`; `table.getSchema()`
74
+ // the post-ALTER set. A no-op when the implicit-index name set is unchanged (the
75
+ // common case, incl. PK/collation/type ALTERs whose physical re-encode is already
76
+ // handled by `rebuildSecondaryIndexes`).
77
+ await this.reconcileImplicitUniqueIndexStores(db, schemaName, tableName, table, oldSchema);
78
+ return updated;
79
+ }
80
+ /**
81
+ * ADD COLUMN arm of {@link alterTable}: append the new column, eagerly migrate
82
+ * each row (literal or per-row backfill), and persist. Behavior-preserving
83
+ * extraction of the former `switch` arm.
84
+ *
85
+ * The store always appends. A caller-chosen `insertAtIndex` (module-API only; SQL never
86
+ * produces one) is rejected unless it names the append position, rather than silently
87
+ * landing the column somewhere the caller did not ask for.
88
+ */
89
+ async alterAddColumn(db, schemaName, tableName, table, oldSchema, change, defaultNotNull) {
90
+ if (change.insertAtIndex !== undefined && change.insertAtIndex !== oldSchema.columns.length) {
91
+ throw new QuereusError(`Store-backed table '${schemaName}.${tableName}' can only ADD COLUMN at the end `
92
+ + `(position ${oldSchema.columns.length}), not at position ${change.insertAtIndex}`, StatusCode.UNSUPPORTED);
93
+ }
94
+ // Honor the session `default_collation` for an ADD COLUMN that omits an
95
+ // explicit COLLATE, matching the CREATE path so an ADD-COLUMN-ed text column
96
+ // gets the same collation a CREATE-d one would. The persisted DDL re-emits an
97
+ // explicit COLLATE for any non-BINARY collation, so reopen stays stable.
98
+ const newColSchema = columnDefToSchema(change.columnDef, defaultNotNull, db.options.getStringOption('default_collation'), (n) => db.isCollationRegistered(n));
99
+ // Extract default value from column def constraints. Use the shared
100
+ // `foldDefaultToType` helper so signed numerics like `-123.0`
101
+ // (a UnaryExpr in the AST) are recognized AND the folded literal is converted
102
+ // to the new column's declared type — matching the memory-mode path, the
103
+ // isolation overlay, and what a fresh INSERT under the same DEFAULT stores.
104
+ // An unconvertible literal (`integer default 'abc'`) throws MISMATCH here.
105
+ let defaultValue = null;
106
+ const defaultConstraint = change.columnDef.constraints?.find(c => c.type === 'default');
107
+ if (defaultConstraint?.expr) {
108
+ const folded = foldDefaultToType(defaultConstraint.expr, newColSchema.logicalType, newColSchema.name);
109
+ if (folded !== undefined) {
110
+ defaultValue = folded;
111
+ }
112
+ }
113
+ // A per-row value source — a non-foldable DEFAULT (e.g. `new.<col>`) or a
114
+ // `generated always as` expression — backfills each existing row from its own
115
+ // value via the engine-supplied evaluator (mirrors the memory path).
116
+ const backfillEvaluator = change.backfillEvaluator;
117
+ // Refuse NOT NULL without a usable value source on a non-empty table
118
+ // (SQLite-compatible). A per-row evaluator IS usable — its NOT NULL is enforced
119
+ // per row during migration — so it is exempt from this rejection.
120
+ if (newColSchema.notNull && defaultValue === null && !backfillEvaluator) {
121
+ if (await table.hasAnyRows()) {
122
+ throw new QuereusError(`Cannot add NOT NULL column '${newColSchema.name}' to non-empty table `
123
+ + `'${schemaName}.${tableName}' without a DEFAULT value`, StatusCode.CONSTRAINT);
124
+ }
125
+ }
126
+ // Build updated schema: append new column
127
+ const updatedColumns = Object.freeze([...oldSchema.columns, newColSchema]);
128
+ const updatedSchema = {
129
+ ...oldSchema,
130
+ columns: updatedColumns,
131
+ columnIndexMap: buildColumnIndexMap(updatedColumns),
132
+ };
133
+ // Physical rewrite ahead: flush the module's buffered writes so `migrateRows`
134
+ // (a committed-store scan + batch) sees this transaction's rows and re-encodes
135
+ // them under the new column layout. See `StoreModuleBase.ddlCommitPendingOps`. Placed
136
+ // after every throw-only check above — the NOT NULL rejection reads effectively
137
+ // (`hasAnyRows`) — so a rejected ALTER leaves the enclosing transaction intact.
138
+ await this.ddlCommitPendingOps();
139
+ // Migrate rows: append the new column's value — a single literal default, or a
140
+ // per-row value derived from the existing row when a backfill evaluator is set.
141
+ const remap = buildColumnRemap(oldSchema.columns.map(c => c.name), updatedColumns.map(c => c.name));
142
+ await table.migrateRows(remap, defaultValue, backfillEvaluator
143
+ ? { evaluator: backfillEvaluator, notNull: newColSchema.notNull, columnName: newColSchema.name }
144
+ : undefined);
145
+ // Update table schema (column-only) and persist DDL. Any constraint declared inline
146
+ // on the added column (UNIQUE / CHECK / FOREIGN KEY) arrives as its own follow-up
147
+ // `addConstraint` call from the engine's `runAddColumn`, which is what persists it —
148
+ // so this arm neither installs nor persists them, and the schema it hands back stays
149
+ // column-only.
150
+ table.updateSchema(updatedSchema);
151
+ await this.saveTableDDL(updatedSchema);
152
+ this.eventEmitter?.emitSchemaChange({
153
+ type: 'alter',
154
+ objectType: 'table',
155
+ schemaName,
156
+ objectName: tableName,
157
+ });
158
+ return updatedSchema;
159
+ }
160
+ /** DROP COLUMN arm of {@link alterTable}: drop the column slot, reindex PK / indexes /
161
+ * UNIQUE, migrate rows, re-encode or tear down the affected physical index stores,
162
+ * and persist. */
163
+ async alterDropColumn(db, schemaName, tableName, table, oldSchema, change) {
164
+ const colNameLower = change.columnName.toLowerCase();
165
+ const colIndex = oldSchema.columns.findIndex(c => c.name.toLowerCase() === colNameLower);
166
+ if (colIndex === -1) {
167
+ throw new QuereusError(`Column '${change.columnName}' not found.`, StatusCode.ERROR);
168
+ }
169
+ // Renumber every position-bearing field over the removed slot — shared with the
170
+ // memory module's `dropColumn`, the mirror of `shiftSchemaIndicesForInsert`. Store-backed
171
+ // UNIQUE is enforced by a full scan over `uniqueConstraints`, so a stranded constraint
172
+ // whose column index dangles past the column array would break the next insert's
173
+ // validation (and the persisted DDL); a foreign key left unshifted would either dangle
174
+ // the same way or silently slide onto an unrelated column and enforce against the parent
175
+ // there. `removedUniqueConstraints` is unused here: unlike the memory module, the store's
176
+ // engine-facing `.indexes` never carries the hidden `_uc_*` covering index for a plain
177
+ // UNIQUE (see `StoreModuleBase.materializedIndexNames`), so there is no by-name exclusion to apply —
178
+ // `StoreModuleIndex.reconcileImplicitUniqueIndexStores` tears down the physical `_uc_*` store
179
+ // generically, by diffing the old and new constraint sets after this arm returns. A *user*
180
+ // `CREATE UNIQUE INDEX` spanning the dropped column is removed from the schema by the helper
181
+ // itself.
182
+ const shifted = shiftSchemaIndicesForDrop(oldSchema, colIndex);
183
+ // Every physical consequence the schema rewrite implies for the `{table}_idx_{name}`
184
+ // stores falls out of one diff — see {@link partitionIndexesByDropFate}. Both inputs
185
+ // are ENGINE-FACING schemas, which carry no `_uc_*` (see
186
+ // `StoreModuleBase.materializedIndexNames`), so the implicit UNIQUE stores stay out of
187
+ // both buckets — they remain owned by `reconcileImplicitUniqueIndexStores`, which runs
188
+ // after this arm returns. A `_uc_*` never narrows anyway: a UNIQUE constraint spanning
189
+ // the dropped column is removed outright and a survivor keeps its whole column set.
190
+ const { removed: removedIndexes, narrowed: narrowedIndexes } = partitionIndexesByDropFate(oldSchema.indexes ?? [], shifted.indexes);
191
+ const updatedSchema = {
192
+ ...oldSchema,
193
+ columns: shifted.columns,
194
+ columnIndexMap: buildColumnIndexMap(shifted.columns),
195
+ primaryKeyDefinition: shifted.primaryKeyDefinition,
196
+ indexes: shifted.indexes,
197
+ uniqueConstraints: shifted.uniqueConstraints,
198
+ foreignKeys: shifted.foreignKeys,
199
+ };
200
+ // Physical rewrite ahead — flush buffered writes so `migrateRows` re-encodes
201
+ // this transaction's rows too. See `StoreModuleBase.ddlCommitPendingOps`.
202
+ await this.ddlCommitPendingOps();
203
+ // Migrate rows: remove the dropped column slot
204
+ const remap = buildColumnRemap(oldSchema.columns.map(c => c.name), shifted.columns.map(c => c.name));
205
+ await table.migrateRows(remap, null);
206
+ // Re-encode every narrowed index against the now-re-encoded data store. AFTER
207
+ // `migrateRows`: the rebuild reads the data store and encodes each entry from the
208
+ // NEW column layout. `rebuildSecondaryIndexes` clears and rebuilds every index in
209
+ // the schema it is handed, so a schema whose `.indexes` holds only the narrowed ones
210
+ // keeps the pass off the untouched indexes. A narrowed index is necessarily
211
+ // non-UNIQUE (a UNIQUE one spanning the slot was removed outright), so the build's
212
+ // in-pass duplicate check is never exercised; and the engine rejects a DROP COLUMN
213
+ // whose column is named by a partial index's WHERE clause, so the pass can never
214
+ // meet a predicate over the departed column.
215
+ //
216
+ // NOTE: this widens a failure window the arm already had — `migrateRows` above has
217
+ // already re-encoded the rows outside the coordinator while the catalog still
218
+ // describes the OLD schema, so an IO error anywhere from there to `saveTableDDL`
219
+ // leaves the two diverged until the statement is re-run. Same shape as
220
+ // `alterPrimaryKeyChange` (rekey → rebuild → persist). If either arm ever needs to
221
+ // be crash-safe, the fix is one durable marker covering the whole physical rewrite,
222
+ // not a reordering here.
223
+ if (narrowedIndexes.length > 0) {
224
+ await this.rebuildSecondaryIndexes(schemaName, tableName, table, { ...updatedSchema, indexes: narrowedIndexes }, db.getKeyNormalizerResolver());
225
+ }
226
+ // Update table schema and persist DDL
227
+ table.updateSchema(updatedSchema);
228
+ await this.saveTableDDL(updatedSchema);
229
+ // Tear down each removed index's physical store — after the catalog write, for the
230
+ // same reason `dropIndex` orders it that way: the bundle must already omit the index
231
+ // so a failed physical delete cannot resurrect it on reopen.
232
+ //
233
+ // No second `ddlCommitPendingOps()` here (unlike `dropIndex`, which flushes
234
+ // immediately before its own teardown): the flush above already ran, and both
235
+ // `migrateRows` and `rebuildSecondaryIndexes` write straight to their stores outside
236
+ // the coordinator — so no buffered ops have accumulated against the doomed index
237
+ // handles in between, and the teardown cannot strand any at commit.
238
+ for (const removed of removedIndexes) {
239
+ await this.tearDownIndexStore(schemaName, tableName, table, removed.name);
240
+ }
241
+ this.eventEmitter?.emitSchemaChange({
242
+ type: 'alter',
243
+ objectType: 'table',
244
+ schemaName,
245
+ objectName: tableName,
246
+ });
247
+ return updatedSchema;
248
+ }
249
+ /** RENAME COLUMN arm of {@link alterTable}: schema-only rewrite (columns, indexes, self-FK,
250
+ * in-place predicate / CHECK AST rewrite) and persist. Behavior-preserving extraction. */
251
+ async alterRenameColumn(db, schemaName, tableName, table, oldSchema, change, defaultNotNull) {
252
+ if (!change.newColumnDefAst) {
253
+ throw new QuereusError('RENAME COLUMN requires a new column definition AST', StatusCode.INTERNAL);
254
+ }
255
+ const oldNameLower = change.oldName.toLowerCase();
256
+ const colIndex = oldSchema.columns.findIndex(c => c.name.toLowerCase() === oldNameLower);
257
+ if (colIndex === -1) {
258
+ throw new QuereusError(`Column '${change.oldName}' not found.`, StatusCode.ERROR);
259
+ }
260
+ const newColSchema = columnDefToSchema(change.newColumnDefAst, defaultNotNull, 'BINARY', (n) => db.isCollationRegistered(n));
261
+ const updatedColumns = oldSchema.columns.map((c, i) => i === colIndex ? newColSchema : c);
262
+ const updatedIndexes = (oldSchema.indexes || []).map(idx => ({
263
+ ...idx,
264
+ columns: idx.columns.map(ic => ic.index === colIndex ? { ...ic, name: change.newName } : ic),
265
+ }));
266
+ const updatedSchema = {
267
+ ...oldSchema,
268
+ columns: Object.freeze(updatedColumns),
269
+ columnIndexMap: buildColumnIndexMap(updatedColumns),
270
+ indexes: Object.freeze(updatedIndexes),
271
+ // A self-referencing FK names the renamed column in `referencedColumnNames`
272
+ // and is persisted by name; the engine rewrites it only in the post-hook
273
+ // pass. Pure copy — no rollback needed, this schema is only adopted on the
274
+ // success path.
275
+ foreignKeys: renameColumnInSelfForeignKeys(oldSchema.foreignKeys, schemaName, tableName, change.oldName, change.newName),
276
+ };
277
+ // A partial index's WHERE clause and a CHECK constraint's expression both
278
+ // still name the OLD column: the engine's `propagateColumnRename` pass runs
279
+ // only after this hook returns. Persisting now would durably write a bundle
280
+ // naming a column the table no longer has, and only the later propagation's
281
+ // `table_modified` event would correct it — a crash in between leaves the
282
+ // catalog un-rehydratable. So rewrite first, in place: each `Expression` is
283
+ // shared by reference with the catalog's `TableSchema` and, for a unique
284
+ // partial index, with the `derivedFromIndex` UNIQUE constraint, so one
285
+ // rewrite covers all holders and makes the later propagation pass a no-op.
286
+ //
287
+ // The rewrites are the first statements in the `try`, and each walks its
288
+ // collection one item at a time, so a throw anywhere — including partway
289
+ // through a walk — must reverse them: restoring `oldSchema` cannot, since the
290
+ // ASTs are shared. Reversing is a no-op wherever nothing names the new column,
291
+ // and the engine has already rejected a rename onto an existing column name,
292
+ // so the reverse pass cannot collide with an expression that legitimately
293
+ // named it.
294
+ const resolveColumnInSource = (s, t, col) => db.schemaManager.getSchema(s)?.getTable(t)?.columnIndexMap.has(col.toLowerCase()) ?? false;
295
+ const rewriteColumn = (from, to) => {
296
+ renameColumnInIndexPredicates(updatedIndexes, tableName, from, to, schemaName, resolveColumnInSource);
297
+ renameColumnInCheckConstraints(oldSchema.checkConstraints, tableName, from, to, schemaName, resolveColumnInSource);
298
+ };
299
+ try {
300
+ rewriteColumn(change.oldName, change.newName);
301
+ // Rename is schema-only — no row migration needed
302
+ table.updateSchema(updatedSchema);
303
+ await this.saveTableDDL(updatedSchema);
304
+ }
305
+ catch (e) {
306
+ rewriteColumn(change.newName, change.oldName);
307
+ throw e;
308
+ }
309
+ this.eventEmitter?.emitSchemaChange({
310
+ type: 'alter',
311
+ objectType: 'table',
312
+ schemaName,
313
+ objectName: tableName,
314
+ });
315
+ return updatedSchema;
316
+ }
317
+ /** ALTER PRIMARY KEY arm of {@link alterTable}: physically re-key the data store, rebuild
318
+ * secondary indexes, and persist. Behavior-preserving extraction. */
319
+ async alterPrimaryKeyChange(db, schemaName, tableName, table, oldSchema, change) {
320
+ const newPkColumns = change.newPkColumns;
321
+ // Shared with the memory module's native arm: rebuilds `primaryKeyDefinition` AND the
322
+ // per-column `primaryKey` / `pkOrder` flags together, so the DDL this arm persists (and
323
+ // the planner's uniqueness hints) describe the NEW key. Each member also carries its
324
+ // column's collation, which this arm previously dropped — the store keys PK columns
325
+ // under their declared collation (`StoreTable.pkKeyCollations`).
326
+ const updatedSchema = rekeySchemaPrimaryKey(oldSchema, newPkColumns);
327
+ // Physical re-key ahead — flush buffered writes so every live row is
328
+ // re-keyed and no stale-schema op replays over the rewritten store.
329
+ // `rekeyRows`' duplicate-key pass runs against the flushed store, so a
330
+ // pending insert that collides under the new PK is caught. See
331
+ // `StoreModuleBase.ddlCommitPendingOps` for the transaction consequences.
332
+ await this.ddlCommitPendingOps();
333
+ // Re-key the data store. Throws CONSTRAINT on duplicates without
334
+ // mutating the store, giving us all-or-nothing semantics for the
335
+ // validation phase.
336
+ await table.rekeyRows(newPkColumns);
337
+ // Secondary index keys embed the PK suffix — clear + rebuild every
338
+ // index against the now-rekeyed data store. Rebuild the MATERIALIZED index list
339
+ // so each implicit `_uc_*` PK suffix is re-encoded too (`updatedSchema` is built
340
+ // off the de-materialized `oldSchema`, so it carries no `_uc_*` on its own).
341
+ await this.rebuildSecondaryIndexes(schemaName, tableName, table, withImplicitUniqueIndexes(updatedSchema), db.getKeyNormalizerResolver());
342
+ table.updateSchema(updatedSchema);
343
+ await this.saveTableDDL(updatedSchema);
344
+ this.eventEmitter?.emitSchemaChange({
345
+ type: 'alter',
346
+ objectType: 'table',
347
+ schemaName,
348
+ objectName: tableName,
349
+ });
350
+ return updatedSchema;
351
+ }
352
+ /** ADD CONSTRAINT arm of {@link alterTable}: validate existing rows as the constraint kind
353
+ * (UNIQUE / FOREIGN KEY / CHECK) requires, then persist. Behavior-preserving extraction. */
354
+ async alterAddConstraint(db, schemaName, tableName, table, oldSchema, change, rows) {
355
+ const constraint = change.constraint;
356
+ let updatedSchema;
357
+ if (constraint.type === 'unique') {
358
+ // Validate the existing rows against the new UNIQUE before persisting. The
359
+ // implicit `_uc_*` index that backs enforcement is materialized into the
360
+ // StoreTable schema by `table.updateSchema` below, and its PHYSICAL store is
361
+ // built by `reconcileImplicitUniqueIndexStores` after this arm returns — the
362
+ // validation here runs first, so a CONSTRAINT rejection never leaves a store
363
+ // behind.
364
+ //
365
+ // No `ddlCommitPendingOps()` here (unlike the row-rewriting arms): this
366
+ // writes no rows, and the validation scan already reads effectively, so
367
+ // the transaction survives a CONSTRAINT rejection.
368
+ const uc = buildUniqueConstraintSchema(constraint, oldSchema.columnIndexMap);
369
+ await validateUniqueOverExistingRows(effectiveDdlRows(table, rows), oldSchema, uc, db.getKeyNormalizerResolver());
370
+ updatedSchema = {
371
+ ...oldSchema,
372
+ uniqueConstraints: Object.freeze([...(oldSchema.uniqueConstraints ?? []), uc]),
373
+ };
374
+ }
375
+ else if (constraint.type === 'foreignKey') {
376
+ const fk = buildForeignKeyConstraintSchema(constraint, oldSchema.columnIndexMap, oldSchema.name, oldSchema.schemaName);
377
+ updatedSchema = {
378
+ ...oldSchema,
379
+ foreignKeys: Object.freeze([...(oldSchema.foreignKeys ?? []), fk]),
380
+ };
381
+ // Pragma-gated existing-row validation; throws before persistence on an orphan.
382
+ await validateForeignKeyOverExistingRows(db, updatedSchema, fk);
383
+ }
384
+ else if (constraint.type === 'check') {
385
+ // Schema-only: a CHECK has no physical structure and (matching the
386
+ // engine's prior in-emitter behavior) no existing-row scan. Routing it
387
+ // here — rather than catalog-only — keeps the persisted DDL and the
388
+ // connected-table schema in lock-step so DROP/RENAME CONSTRAINT resolve it.
389
+ const check = buildCheckConstraintSchema(constraint, oldSchema.checkConstraints.length);
390
+ updatedSchema = {
391
+ ...oldSchema,
392
+ checkConstraints: Object.freeze([...oldSchema.checkConstraints, check]),
393
+ };
394
+ }
395
+ else {
396
+ throw new QuereusError(`Store table ADD CONSTRAINT does not support constraint type '${constraint.type}'`, StatusCode.UNSUPPORTED);
397
+ }
398
+ table.updateSchema(updatedSchema);
399
+ await this.saveTableDDL(updatedSchema);
400
+ this.eventEmitter?.emitSchemaChange({
401
+ type: 'alter',
402
+ objectType: 'table',
403
+ schemaName,
404
+ objectName: tableName,
405
+ });
406
+ return updatedSchema;
407
+ }
408
+ /** DROP CONSTRAINT arm of {@link alterTable}: schema-only catalog rewrite dropping a named
409
+ * constraint, then persist. Behavior-preserving extraction. */
410
+ async alterDropConstraint(schemaName, tableName, table, oldSchema, change) {
411
+ // Schema-only catalog rewrite. Dropping a UNIQUE removes it from
412
+ // `uniqueConstraints`, so `table.updateSchema` below de-materializes its implicit
413
+ // `_uc_*` index and `reconcileImplicitUniqueIndexStores` (after this arm returns)
414
+ // tears down the now-orphaned physical store — without which a later re-ADD would
415
+ // reopen stale entries. That teardown DDL-commits the module's pending transaction
416
+ // first (a deleted store's buffered ops cannot be replayed at commit — see
417
+ // `StoreModuleIndex.reconcileImplicitUniqueIndexStores`), so this arm is schema-only for the
418
+ // CATALOG but not transaction-neutral. A UNIQUE derived from a CREATE UNIQUE INDEX
419
+ // is rejected upstream (drop the index instead), and has no `_uc_*` anyway.
420
+ const constraintClass = resolveNamedConstraintClass(oldSchema, change.constraintName);
421
+ const lower = change.constraintName.toLowerCase();
422
+ let updatedSchema;
423
+ if (constraintClass === 'check') {
424
+ updatedSchema = {
425
+ ...oldSchema,
426
+ checkConstraints: Object.freeze(oldSchema.checkConstraints.filter(c => c.name?.toLowerCase() !== lower)),
427
+ };
428
+ }
429
+ else if (constraintClass === 'foreignKey') {
430
+ const remaining = (oldSchema.foreignKeys ?? []).filter(c => c.name?.toLowerCase() !== lower);
431
+ updatedSchema = { ...oldSchema, foreignKeys: remaining.length > 0 ? Object.freeze(remaining) : undefined };
432
+ }
433
+ else {
434
+ const remaining = (oldSchema.uniqueConstraints ?? []).filter(c => c.name?.toLowerCase() !== lower);
435
+ updatedSchema = { ...oldSchema, uniqueConstraints: remaining.length > 0 ? Object.freeze(remaining) : undefined };
436
+ }
437
+ table.updateSchema(updatedSchema);
438
+ await this.saveTableDDL(updatedSchema);
439
+ this.eventEmitter?.emitSchemaChange({
440
+ type: 'alter',
441
+ objectType: 'table',
442
+ schemaName,
443
+ objectName: tableName,
444
+ });
445
+ return updatedSchema;
446
+ }
447
+ /** RENAME CONSTRAINT arm of {@link alterTable}: schema-only rename of a named constraint,
448
+ * then persist. A renamed named-UNIQUE changes its implicit `_uc_*` index name, so
449
+ * `reconcileImplicitUniqueIndexStores` (run after this arm) MOVES the physical store —
450
+ * tears down the old-named store and rebuilds the new-named one from effective rows. */
451
+ async alterRenameConstraint(schemaName, tableName, table, oldSchema, change) {
452
+ const constraintClass = resolveNamedConstraintClass(oldSchema, change.oldName);
453
+ const oldLower = change.oldName.toLowerCase();
454
+ let updatedSchema;
455
+ if (constraintClass === 'check') {
456
+ updatedSchema = {
457
+ ...oldSchema,
458
+ checkConstraints: Object.freeze(oldSchema.checkConstraints.map(c => (c.name?.toLowerCase() === oldLower ? { ...c, name: change.newName } : c))),
459
+ };
460
+ }
461
+ else if (constraintClass === 'foreignKey') {
462
+ updatedSchema = {
463
+ ...oldSchema,
464
+ foreignKeys: Object.freeze(oldSchema.foreignKeys.map(c => (c.name?.toLowerCase() === oldLower ? { ...c, name: change.newName } : c))),
465
+ };
466
+ }
467
+ else {
468
+ updatedSchema = {
469
+ ...oldSchema,
470
+ uniqueConstraints: Object.freeze(oldSchema.uniqueConstraints.map(c => (c.name?.toLowerCase() === oldLower ? { ...c, name: change.newName } : c))),
471
+ };
472
+ }
473
+ table.updateSchema(updatedSchema);
474
+ await this.saveTableDDL(updatedSchema);
475
+ this.eventEmitter?.emitSchemaChange({
476
+ type: 'alter',
477
+ objectType: 'table',
478
+ schemaName,
479
+ objectName: tableName,
480
+ });
481
+ return updatedSchema;
482
+ }
483
+ }
484
+ /**
485
+ * Which of `before`'s indexes DROP COLUMN's schema rewrite (`shiftSchemaIndicesForDrop`)
486
+ * left needing physical work, matched by lowercased name against the post-shift `after`:
487
+ *
488
+ * - `removed` — gone from `after` outright (UNIQUE spanning the dropped column, or a
489
+ * single-column index whose only column this was). Its store must be torn down,
490
+ * mirroring `DROP INDEX`: nothing else reclaims it, and a later `CREATE INDEX` of the
491
+ * same name would ADOPT the stale entries — `getIndexStore` hands back the existing
492
+ * store, `buildIndexEntries` appends, and `assertStoreNameFree` cannot catch it (it
493
+ * compares against REGISTERED schema objects, and this index is no longer one), so a
494
+ * range scan through the reused index yields each row twice. Carries the PRE-shift
495
+ * entry; only its name is used.
496
+ * - `narrowed` — survives with a different column COUNT, so its key layout lost one
497
+ * value ahead of the PK suffix while every pre-existing entry still carries the WIDE
498
+ * encoding: lookups miss those rows and deletes orphan their entries. Its store must be
499
+ * re-encoded. Carries the POST-shift entry, which is what the rebuild encodes from.
500
+ *
501
+ * A survivor whose column count is unchanged is in neither bucket: its column INDICES
502
+ * shifted, but it encodes the same values in the same order, so its key bytes do not move.
503
+ */
504
+ function partitionIndexesByDropFate(before, after) {
505
+ const survivors = new Map(after.map(ix => [ix.name.toLowerCase(), ix]));
506
+ const removed = [];
507
+ const narrowed = [];
508
+ for (const old of before) {
509
+ const survivor = survivors.get(old.name.toLowerCase());
510
+ if (!survivor) {
511
+ removed.push(old);
512
+ }
513
+ else if (survivor.columns.length !== old.columns.length) {
514
+ narrowed.push(survivor);
515
+ }
516
+ }
517
+ return { removed, narrowed };
518
+ }
519
+ //# sourceMappingURL=store-module-alter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store-module-alter.js","sourceRoot":"","sources":["../../../src/common/store-module-alter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAYH,OAAO,EACN,YAAY,EACZ,UAAU,EACV,0BAA0B,EAC1B,mBAAmB,EACnB,+BAA+B,EAC/B,2BAA2B,EAC3B,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACrB,8BAA8B,EAC9B,6BAA6B,EAC7B,2BAA2B,EAC3B,yBAAyB,EACzB,kCAAkC,GAClC,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,8BAA8B,EAAE,MAAM,+BAA+B,CAAC;AACjG,OAAO,EAAE,gBAAgB,EAAE,6BAA6B,EAAE,MAAM,kCAAkC,CAAC;AAEnG,MAAM,OAAgB,gBAAiB,SAAQ,sBAAsB;IACpE;;;;;;;OAOG;IACH,KAAK,CAAC,UAAU,CACf,EAAY,EACZ,UAAkB,EAClB,SAAiB,EACjB,MAAwB,EACxB,IAAyB;QAEzB,IAAI,CAAC,wBAAwB,CAAC,EAAE,CAAC,CAAC;QAClC,MAAM,KAAK,GAAG,IAAI,CAAC,mBAAmB,CAAC,EAAE,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;QAElE,IAAI,CAAC,KAAK,EAAE,CAAC;YACZ,MAAM,IAAI,YAAY,CACrB,gBAAgB,SAAS,0BAA0B,UAAU,kBAAkB,E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