@quereus/quereus 4.7.0 → 4.9.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 (218) hide show
  1. package/dist/src/common/types.d.ts +19 -0
  2. package/dist/src/common/types.d.ts.map +1 -1
  3. package/dist/src/common/types.js.map +1 -1
  4. package/dist/src/core/database.d.ts +45 -1
  5. package/dist/src/core/database.d.ts.map +1 -1
  6. package/dist/src/core/database.js +212 -2
  7. package/dist/src/core/database.js.map +1 -1
  8. package/dist/src/core/statement.d.ts.map +1 -1
  9. package/dist/src/core/statement.js +86 -0
  10. package/dist/src/core/statement.js.map +1 -1
  11. package/dist/src/func/builtins/aggregate.d.ts.map +1 -1
  12. package/dist/src/func/builtins/aggregate.js +3 -2
  13. package/dist/src/func/builtins/aggregate.js.map +1 -1
  14. package/dist/src/func/builtins/conversion.d.ts +5 -0
  15. package/dist/src/func/builtins/conversion.d.ts.map +1 -1
  16. package/dist/src/func/builtins/conversion.js +16 -2
  17. package/dist/src/func/builtins/conversion.js.map +1 -1
  18. package/dist/src/func/builtins/index.d.ts.map +1 -1
  19. package/dist/src/func/builtins/index.js +5 -2
  20. package/dist/src/func/builtins/index.js.map +1 -1
  21. package/dist/src/func/builtins/string.d.ts +2 -0
  22. package/dist/src/func/builtins/string.d.ts.map +1 -1
  23. package/dist/src/func/builtins/string.js +60 -4
  24. package/dist/src/func/builtins/string.js.map +1 -1
  25. package/dist/src/index.d.ts +11 -4
  26. package/dist/src/index.d.ts.map +1 -1
  27. package/dist/src/index.js +18 -3
  28. package/dist/src/index.js.map +1 -1
  29. package/dist/src/planner/building/constraint-builder.js +1 -1
  30. package/dist/src/planner/building/constraint-builder.js.map +1 -1
  31. package/dist/src/planner/rules/retrieve/rule-grow-retrieve.d.ts.map +1 -1
  32. package/dist/src/planner/rules/retrieve/rule-grow-retrieve.js +121 -51
  33. package/dist/src/planner/rules/retrieve/rule-grow-retrieve.js.map +1 -1
  34. package/dist/src/planner/rules/shared/index-style-context.d.ts +14 -4
  35. package/dist/src/planner/rules/shared/index-style-context.d.ts.map +1 -1
  36. package/dist/src/planner/rules/shared/index-style-context.js +14 -4
  37. package/dist/src/planner/rules/shared/index-style-context.js.map +1 -1
  38. package/dist/src/runtime/emit/alter-table.d.ts.map +1 -1
  39. package/dist/src/runtime/emit/alter-table.js +212 -155
  40. package/dist/src/runtime/emit/alter-table.js.map +1 -1
  41. package/dist/src/runtime/emit/assertion-drop-guard.d.ts +26 -12
  42. package/dist/src/runtime/emit/assertion-drop-guard.d.ts.map +1 -1
  43. package/dist/src/runtime/emit/assertion-drop-guard.js +45 -26
  44. package/dist/src/runtime/emit/assertion-drop-guard.js.map +1 -1
  45. package/dist/src/runtime/emit/assertion-rename-helpers.d.ts +6 -6
  46. package/dist/src/runtime/emit/assertion-rename-helpers.d.ts.map +1 -1
  47. package/dist/src/runtime/emit/assertion-rename-helpers.js +18 -20
  48. package/dist/src/runtime/emit/assertion-rename-helpers.js.map +1 -1
  49. package/dist/src/runtime/emit/binary.d.ts.map +1 -1
  50. package/dist/src/runtime/emit/binary.js +12 -10
  51. package/dist/src/runtime/emit/binary.js.map +1 -1
  52. package/dist/src/runtime/emit/column-rename-cascade.d.ts +84 -0
  53. package/dist/src/runtime/emit/column-rename-cascade.d.ts.map +1 -0
  54. package/dist/src/runtime/emit/column-rename-cascade.js +134 -0
  55. package/dist/src/runtime/emit/column-rename-cascade.js.map +1 -0
  56. package/dist/src/runtime/emit/drop-column-guards.d.ts +82 -53
  57. package/dist/src/runtime/emit/drop-column-guards.d.ts.map +1 -1
  58. package/dist/src/runtime/emit/drop-column-guards.js +155 -90
  59. package/dist/src/runtime/emit/drop-column-guards.js.map +1 -1
  60. package/dist/src/runtime/emit/drop-table.d.ts.map +1 -1
  61. package/dist/src/runtime/emit/drop-table.js +5 -0
  62. package/dist/src/runtime/emit/drop-table.js.map +1 -1
  63. package/dist/src/runtime/emit/drop-view.d.ts.map +1 -1
  64. package/dist/src/runtime/emit/drop-view.js +5 -0
  65. package/dist/src/runtime/emit/drop-view.js.map +1 -1
  66. package/dist/src/runtime/emit/expression-drop-guard.d.ts +57 -0
  67. package/dist/src/runtime/emit/expression-drop-guard.d.ts.map +1 -0
  68. package/dist/src/runtime/emit/expression-drop-guard.js +82 -0
  69. package/dist/src/runtime/emit/expression-drop-guard.js.map +1 -0
  70. package/dist/src/runtime/emit/materialized-view-helpers.d.ts +26 -9
  71. package/dist/src/runtime/emit/materialized-view-helpers.d.ts.map +1 -1
  72. package/dist/src/runtime/emit/materialized-view-helpers.js +37 -17
  73. package/dist/src/runtime/emit/materialized-view-helpers.js.map +1 -1
  74. package/dist/src/runtime/emit/materialized-view.d.ts.map +1 -1
  75. package/dist/src/runtime/emit/materialized-view.js +3 -0
  76. package/dist/src/runtime/emit/materialized-view.js.map +1 -1
  77. package/dist/src/runtime/emit/remote-query.d.ts.map +1 -1
  78. package/dist/src/runtime/emit/remote-query.js +8 -3
  79. package/dist/src/runtime/emit/remote-query.js.map +1 -1
  80. package/dist/src/runtime/emit/scan.d.ts.map +1 -1
  81. package/dist/src/runtime/emit/scan.js +4 -1
  82. package/dist/src/runtime/emit/scan.js.map +1 -1
  83. package/dist/src/runtime/emit/schema-declarative.js +2 -2
  84. package/dist/src/runtime/emit/schema-declarative.js.map +1 -1
  85. package/dist/src/runtime/parallel-driver.d.ts +4 -3
  86. package/dist/src/runtime/parallel-driver.d.ts.map +1 -1
  87. package/dist/src/runtime/parallel-driver.js +8 -3
  88. package/dist/src/runtime/parallel-driver.js.map +1 -1
  89. package/dist/src/runtime/types.d.ts +10 -0
  90. package/dist/src/runtime/types.d.ts.map +1 -1
  91. package/dist/src/runtime/types.js.map +1 -1
  92. package/dist/src/runtime/utils.d.ts.map +1 -1
  93. package/dist/src/runtime/utils.js +11 -0
  94. package/dist/src/runtime/utils.js.map +1 -1
  95. package/dist/src/schema/assertion.d.ts +58 -0
  96. package/dist/src/schema/assertion.d.ts.map +1 -1
  97. package/dist/src/schema/assertion.js +78 -0
  98. package/dist/src/schema/assertion.js.map +1 -1
  99. package/dist/src/schema/catalog-persistability.d.ts +11 -3
  100. package/dist/src/schema/catalog-persistability.d.ts.map +1 -1
  101. package/dist/src/schema/catalog-persistability.js +48 -29
  102. package/dist/src/schema/catalog-persistability.js.map +1 -1
  103. package/dist/src/schema/catalog.d.ts +22 -0
  104. package/dist/src/schema/catalog.d.ts.map +1 -1
  105. package/dist/src/schema/catalog.js +4 -1
  106. package/dist/src/schema/catalog.js.map +1 -1
  107. package/dist/src/schema/column-republication.d.ts +126 -0
  108. package/dist/src/schema/column-republication.d.ts.map +1 -0
  109. package/dist/src/schema/column-republication.js +121 -0
  110. package/dist/src/schema/column-republication.js.map +1 -0
  111. package/dist/src/schema/column-source-resolver.d.ts +29 -6
  112. package/dist/src/schema/column-source-resolver.d.ts.map +1 -1
  113. package/dist/src/schema/column-source-resolver.js +78 -9
  114. package/dist/src/schema/column-source-resolver.js.map +1 -1
  115. package/dist/src/schema/expression-dependents.d.ts +160 -0
  116. package/dist/src/schema/expression-dependents.d.ts.map +1 -0
  117. package/dist/src/schema/expression-dependents.js +228 -0
  118. package/dist/src/schema/expression-dependents.js.map +1 -0
  119. package/dist/src/schema/object-dependency-closure.d.ts +127 -0
  120. package/dist/src/schema/object-dependency-closure.d.ts.map +1 -0
  121. package/dist/src/schema/object-dependency-closure.js +117 -0
  122. package/dist/src/schema/object-dependency-closure.js.map +1 -0
  123. package/dist/src/schema/object-ref-resolver.d.ts +83 -0
  124. package/dist/src/schema/object-ref-resolver.d.ts.map +1 -0
  125. package/dist/src/schema/object-ref-resolver.js +135 -0
  126. package/dist/src/schema/object-ref-resolver.js.map +1 -0
  127. package/dist/src/schema/rename/column-rename.d.ts +228 -0
  128. package/dist/src/schema/rename/column-rename.d.ts.map +1 -0
  129. package/dist/src/schema/rename/column-rename.js +1225 -0
  130. package/dist/src/schema/rename/column-rename.js.map +1 -0
  131. package/dist/src/schema/rename/self-qualifier-strip.d.ts +29 -0
  132. package/dist/src/schema/rename/self-qualifier-strip.d.ts.map +1 -0
  133. package/dist/src/schema/rename/self-qualifier-strip.js +267 -0
  134. package/dist/src/schema/rename/self-qualifier-strip.js.map +1 -0
  135. package/dist/src/schema/rename/shared.d.ts +108 -0
  136. package/dist/src/schema/rename/shared.d.ts.map +1 -0
  137. package/dist/src/schema/rename/shared.js +49 -0
  138. package/dist/src/schema/rename/shared.js.map +1 -0
  139. package/dist/src/schema/rename/table-rename.d.ts +263 -0
  140. package/dist/src/schema/rename/table-rename.d.ts.map +1 -0
  141. package/dist/src/schema/rename/table-rename.js +860 -0
  142. package/dist/src/schema/rename/table-rename.js.map +1 -0
  143. package/dist/src/schema/rename-rewriter.d.ts +18 -278
  144. package/dist/src/schema/rename-rewriter.d.ts.map +1 -1
  145. package/dist/src/schema/rename-rewriter.js +17 -1506
  146. package/dist/src/schema/rename-rewriter.js.map +1 -1
  147. package/dist/src/schema/schema-differ.d.ts.map +1 -1
  148. package/dist/src/schema/schema-differ.js +228 -21
  149. package/dist/src/schema/schema-differ.js.map +1 -1
  150. package/dist/src/types/builtin-types.d.ts.map +1 -1
  151. package/dist/src/types/builtin-types.js +12 -28
  152. package/dist/src/types/builtin-types.js.map +1 -1
  153. package/dist/src/types/cast-semantics.d.ts +7 -5
  154. package/dist/src/types/cast-semantics.d.ts.map +1 -1
  155. package/dist/src/types/cast-semantics.js +20 -9
  156. package/dist/src/types/cast-semantics.js.map +1 -1
  157. package/dist/src/types/index.d.ts +1 -1
  158. package/dist/src/types/index.d.ts.map +1 -1
  159. package/dist/src/types/index.js +1 -1
  160. package/dist/src/types/index.js.map +1 -1
  161. package/dist/src/types/registry.d.ts.map +1 -1
  162. package/dist/src/types/registry.js +2 -1
  163. package/dist/src/types/registry.js.map +1 -1
  164. package/dist/src/types/temporal-types.d.ts +11 -0
  165. package/dist/src/types/temporal-types.d.ts.map +1 -1
  166. package/dist/src/types/temporal-types.js +82 -0
  167. package/dist/src/types/temporal-types.js.map +1 -1
  168. package/dist/src/util/abort-signal.d.ts +25 -0
  169. package/dist/src/util/abort-signal.d.ts.map +1 -0
  170. package/dist/src/util/abort-signal.js +40 -0
  171. package/dist/src/util/abort-signal.js.map +1 -0
  172. package/dist/src/util/affinity.d.ts +2 -1
  173. package/dist/src/util/affinity.d.ts.map +1 -1
  174. package/dist/src/util/affinity.js +16 -5
  175. package/dist/src/util/affinity.js.map +1 -1
  176. package/dist/src/util/ast-spine-clone.d.ts +2 -2
  177. package/dist/src/util/ast-spine-clone.js +2 -2
  178. package/dist/src/util/value-text.d.ts +48 -0
  179. package/dist/src/util/value-text.d.ts.map +1 -0
  180. package/dist/src/util/value-text.js +35 -0
  181. package/dist/src/util/value-text.js.map +1 -0
  182. package/dist/src/vtab/concurrency.d.ts +15 -0
  183. package/dist/src/vtab/concurrency.d.ts.map +1 -1
  184. package/dist/src/vtab/concurrency.js +17 -0
  185. package/dist/src/vtab/concurrency.js.map +1 -1
  186. package/dist/src/vtab/memory/layer/base.d.ts +10 -0
  187. package/dist/src/vtab/memory/layer/base.d.ts.map +1 -1
  188. package/dist/src/vtab/memory/layer/base.js +10 -0
  189. package/dist/src/vtab/memory/layer/base.js.map +1 -1
  190. package/dist/src/vtab/memory/layer/interface.d.ts +24 -0
  191. package/dist/src/vtab/memory/layer/interface.d.ts.map +1 -1
  192. package/dist/src/vtab/memory/layer/manager.d.ts +21 -3
  193. package/dist/src/vtab/memory/layer/manager.d.ts.map +1 -1
  194. package/dist/src/vtab/memory/layer/manager.js +118 -93
  195. package/dist/src/vtab/memory/layer/manager.js.map +1 -1
  196. package/dist/src/vtab/memory/layer/transaction.d.ts +11 -0
  197. package/dist/src/vtab/memory/layer/transaction.d.ts.map +1 -1
  198. package/dist/src/vtab/memory/layer/transaction.js +19 -0
  199. package/dist/src/vtab/memory/layer/transaction.js.map +1 -1
  200. package/dist/src/vtab/memory/module.d.ts +41 -0
  201. package/dist/src/vtab/memory/module.d.ts.map +1 -1
  202. package/dist/src/vtab/memory/module.js +41 -0
  203. package/dist/src/vtab/memory/module.js.map +1 -1
  204. package/dist/src/vtab/memory/table.d.ts +12 -1
  205. package/dist/src/vtab/memory/table.d.ts.map +1 -1
  206. package/dist/src/vtab/memory/table.js +12 -1
  207. package/dist/src/vtab/memory/table.js.map +1 -1
  208. package/dist/src/vtab/module.d.ts +33 -0
  209. package/dist/src/vtab/module.d.ts.map +1 -1
  210. package/dist/src/vtab/test-support/commit-stall.d.ts +53 -0
  211. package/dist/src/vtab/test-support/commit-stall.d.ts.map +1 -0
  212. package/dist/src/vtab/test-support/commit-stall.js +73 -0
  213. package/dist/src/vtab/test-support/commit-stall.js.map +1 -0
  214. package/dist/src/vtab/test-support/committed-read-conformance.d.ts +96 -0
  215. package/dist/src/vtab/test-support/committed-read-conformance.d.ts.map +1 -0
  216. package/dist/src/vtab/test-support/committed-read-conformance.js +364 -0
  217. package/dist/src/vtab/test-support/committed-read-conformance.js.map +1 -0
  218. package/package.json +3 -3
@@ -0,0 +1,228 @@
1
+ import type * as AST from '../../parser/ast.js';
2
+ import { type ResolveColumnInSource, type ResolveObjectRef, type RowImageContext } from './shared.js';
3
+ /**
4
+ * Rewrite column references inside a full statement/expression AST, resolving
5
+ * unqualified refs against the FROM scopes the walk descends (no implicit seed,
6
+ * unlike {@link renameColumnInCheckExpression}). The walk descends a select
7
+ * body's trailing `with defaults (…)` clause ({@link AST.SelectStmt.defaults}),
8
+ * whose entry exprs evaluate in the body's FROM scope.
9
+ *
10
+ * `rowImage` says what a bare, unbound `new.` / `old.` qualifier means in the
11
+ * walked expression — independent of the (absent) seed; see
12
+ * {@link RowImageContext} and {@link matchesRowImage}. A view / assertion body
13
+ * is `'none'` (no written-row context — `new.x` is an ordinary table
14
+ * reference); another table's CHECK / DEFAULT / generated body is `'foreign'`
15
+ * (written-row context whose image belongs to that table, so the qualifier
16
+ * names nothing this walk cares about).
17
+ *
18
+ * When `resolveColumnInSource` is supplied, the scope walk consults it at each
19
+ * inner FROM frame so an unqualified ref that legitimately binds to a like-named
20
+ * column on a subquery's own FROM source is NOT false-captured by an enclosing
21
+ * binding (e.g. a `with defaults` expr `cap + (select max(cap) from lim)` under
22
+ * a `t.cap` rename must leave the inner `lim.cap` untouched). The same callback
23
+ * infrastructure backs {@link renameColumnInCheckExpression}; both the forward
24
+ * propagation (live schema lookup) and the differ's inverse reconcile
25
+ * (declared-side resolver) pass it so the two stay in parity.
26
+ */
27
+ export declare function renameColumnInAst(node: AST.AstNode | undefined, tableName: string, oldColName: string, newColName: string, resolve: ResolveObjectRef, targetKey: string, rowImage: RowImageContext, resolveColumnInSource?: ResolveColumnInSource): boolean;
28
+ /**
29
+ * Rewrite a column reference inside a CHECK expression. Unlike
30
+ * `renameColumnInAst`, this entry point seeds the scope stack with an
31
+ * implicit unaliased binding to `tableName` so top-level unqualified
32
+ * `ColumnExpr` nodes resolve to the owning table. CHECK expressions
33
+ * cannot reference other tables at top level, so the implicit binding
34
+ * is safe there.
35
+ *
36
+ * When `resolveColumnInSource` is supplied, the scope walk consults it at
37
+ * each inner FROM frame: if any real-table source in that frame exposes
38
+ * `oldColName`, the unqualified ref binds inside the subquery and the
39
+ * walk stops before reaching the seed. This stops the rewriter from
40
+ * false-positively rewriting an inner unqualified ref that legitimately
41
+ * binds to a like-named column on the subquery's FROM (e.g.
42
+ * `check ((select min(v) from u) > 0)` when `u` also has a `v` column).
43
+ *
44
+ * Limitation: subquery / function-source inner sources are not asked (the
45
+ * rewriter would need recursive column-set inference on their bodies), so an
46
+ * unqualified ref binding only through one of those falls through to the seed.
47
+ * An ALIASED real source is asked like any other — an alias adds a qualifier,
48
+ * it does not take the source's columns out of scope. `renameColumnInAst`
49
+ * shares the same callback (passed by the view-body callers) and the same
50
+ * residual.
51
+ *
52
+ * The seed and the `new.` / `old.` **row-image** namespace are INDEPENDENT: the
53
+ * seed answers how *unqualified* refs bind, while the explicit `rowImage`
54
+ * argument answers what a bare, unbound `new.` / `old.` qualifier names (see
55
+ * {@link RowImageContext}). A CHECK / DEFAULT / generated body of the renamed
56
+ * table itself passes `'own'` — those expressions evaluate against the row
57
+ * being written, so `check (new.a > 0)` (`docs/sql-ddl.md` § CHECK Constraints)
58
+ * names the owning table's row image and matches. A partial-index predicate is
59
+ * seeded too but passes `'none'`: it describes rows already stored, with no
60
+ * written-row context.
61
+ *
62
+ * The `'own'` match is scope-**aware**, not depth-blind, because `new` and `old`
63
+ * are not reserved words in this parser: `create table "new" (…)` is legal, so a
64
+ * CHECK may legitimately contain `(select max("new".a) from "new")`. The match
65
+ * therefore requires that no FROM/WITH frame above the seed rebind the
66
+ * qualifier — see `matchesRowImage`.
67
+ */
68
+ export declare function renameColumnInCheckExpression(expr: AST.AstNode | undefined, tableName: string, oldColName: string, newColName: string, resolve: ResolveObjectRef, targetKey: string, rowImage: RowImageContext, resolveColumnInSource?: ResolveColumnInSource): boolean;
69
+ /**
70
+ * Sentinel rename target for the read-only column probes: the two below, and
71
+ * the drop verb's republication fixpoint
72
+ * (`schema/column-republication.ts`), which probes exposure the same way. No
73
+ * user column can hold this name, and the probe rewrites *to* it, so it can
74
+ * never collide with anything the walk is looking for.
75
+ */
76
+ export declare const PROBE_COLUMN_NAME = "__quereus_column_probe__";
77
+ /**
78
+ * Whether `node` refers to `tableName`.`columnName` — read-only with respect to
79
+ * the caller's AST; a throwaway {@link spineCloneAst} copy is what gets
80
+ * rewritten.
81
+ *
82
+ * Same equivalence {@link tableReferencedInAst} establishes for the table verb,
83
+ * and for the same reason: "refers to" must mean "would have been rewritten by
84
+ * `ALTER TABLE … RENAME COLUMN`", or a DROP guard built on it refuses a
85
+ * different set of cases than the rename follows. See that function's comment
86
+ * for why the column verb reaches it by clone+sentinel rather than by `dryRun`.
87
+ *
88
+ * `resolveColumnInSource` is **not optional in practice**: without it the walk
89
+ * has no way to tell that an unqualified ref inside a subquery binds to a
90
+ * like-named column on the subquery's own FROM source, and a caller asking
91
+ * "does this body name `t.v`?" gets `true` for a body whose only `v` is
92
+ * another table's. Every caller should pass the catalog-backed resolver
93
+ * (`buildColumnSourceResolver`).
94
+ *
95
+ * NOTE: one spine clone plus one walk per probe, and the DROP COLUMN guard probes every
96
+ * live assertion. Trivial at the handful-of-assertions scale schemas have today, and it
97
+ * only runs on DDL; if a schema ever carries assertions by the hundred, filter by
98
+ * `tableReferencedInAst` (no clone) before paying for the column probe.
99
+ */
100
+ export declare function columnReferencedInAst(node: AST.AstNode | undefined, tableName: string, columnName: string, resolve: ResolveObjectRef, targetKey: string, rowImage: RowImageContext, resolveColumnInSource?: ResolveColumnInSource): boolean;
101
+ /**
102
+ * {@link columnReferencedInAst} for an expression that resolves unqualified refs
103
+ * against an implicit binding to `tableName` — a CHECK expression or a
104
+ * partial-index predicate. Uses {@link renameColumnInCheckExpression}'s seeded
105
+ * entry point so the probe answers for exactly the scope that expression is
106
+ * planned in.
107
+ */
108
+ export declare function columnReferencedInCheckExpression(expr: AST.AstNode | undefined, tableName: string, columnName: string, resolve: ResolveObjectRef, targetKey: string, rowImage: RowImageContext, resolveColumnInSource?: ResolveColumnInSource): boolean;
109
+ /**
110
+ * Rewrite the renamed column inside every partial-index predicate of `indexes`,
111
+ * in place. A predicate resolves unqualified refs against the indexed table
112
+ * itself — the same implicit seed a CHECK expression uses — so
113
+ * {@link renameColumnInCheckExpression} is the correct entry point here, not
114
+ * {@link renameColumnInAst}.
115
+ *
116
+ * The predicate `Expression` is shared by reference between the catalog's
117
+ * `TableSchema`, any module-local copy of it, and — for a unique partial index —
118
+ * the `derivedFromIndex` UNIQUE constraint that carries the same predicate.
119
+ * Rewriting in place keeps all of them in step; cloning would strand the derived
120
+ * constraint on the old AST.
121
+ *
122
+ * Idempotent: once rewritten, nothing names `oldColName` any more, so a second
123
+ * call with the same pair returns false without touching the AST.
124
+ *
125
+ * The parameter is structurally typed rather than `IndexSchema[]` so this module
126
+ * stays free of catalog imports; `IndexSchema` satisfies it.
127
+ *
128
+ * Row-image mode is `'none'`: a partial-index predicate describes rows already
129
+ * stored, so it has no written-row context and a bare `new.` / `old.` qualifier
130
+ * there is an ordinary table reference — the same asymmetry
131
+ * {@link import('./table-rename.js').renameTableInIndexPredicates} records by
132
+ * passing no `rowImageContext`. (An indexed table literally named `new` still
133
+ * matches through the seed binding, so this changes no answer for the case
134
+ * that plans.)
135
+ */
136
+ export declare function renameColumnInIndexPredicates(indexes: ReadonlyArray<{
137
+ readonly predicate?: AST.Expression;
138
+ }> | undefined, tableName: string, oldColName: string, newColName: string, resolve: ResolveObjectRef, targetKey: string, resolveColumnInSource?: ResolveColumnInSource): boolean;
139
+ /**
140
+ * Rewrite the renamed column inside every CHECK constraint expression of `checks`
141
+ * belonging to the renamed table itself, in place. The seeded-scope entry point
142
+ * applies for the same reason it does for a partial-index predicate: a CHECK
143
+ * resolves unqualified refs against its owning table.
144
+ *
145
+ * Only pass the renamed table's OWN checks — a CHECK on a *different* table that
146
+ * happens to reference the renamed table needs {@link renameColumnInAst}, whose
147
+ * walk has no implicit seed. That own-table contract is also why the row-image
148
+ * mode is hardcoded `'own'` here: a CHECK evaluates against the row being
149
+ * written, whose image IS the renamed table's.
150
+ */
151
+ export declare function renameColumnInCheckConstraints(checks: ReadonlyArray<{
152
+ readonly expr: AST.Expression;
153
+ }> | undefined, tableName: string, oldColName: string, newColName: string, resolve: ResolveObjectRef, targetKey: string, resolveColumnInSource?: ResolveColumnInSource): boolean;
154
+ /**
155
+ * Rewrite the renamed column inside the two expressions a `ColumnSchema` can carry —
156
+ * a column DEFAULT (`b integer default (new.a + 1)`, however authored: inline, or via
157
+ * `ALTER TABLE … ALTER COLUMN … SET DEFAULT`, which writes the same field) and a
158
+ * generated column's body (`g integer generated always as (a + 1)`) — in place, for
159
+ * every column of the renamed table itself.
160
+ *
161
+ * The seeded {@link renameColumnInCheckExpression} entry point with row-image mode
162
+ * `'own'` is correct for both:
163
+ *
164
+ * - The implicit unaliased binding to the owning table is what makes a generated
165
+ * column's **bare** `a` resolve — it has no FROM clause to bind against, exactly like
166
+ * a CHECK.
167
+ * - The `'own'` mode is what makes a default's `new.a` resolve. A default is evaluated
168
+ * against the row being written, so that qualifier names this table's row image, not
169
+ * anything a FROM binds.
170
+ *
171
+ * Case folding (`NEW.A`) and the shadowing edge (a real table literally named `new`,
172
+ * reached from a subquery inside the expression) therefore behave exactly as they do for
173
+ * a CHECK, because the same walk decides all three.
174
+ *
175
+ * Only pass the renamed table's OWN columns. A default on a *different* table can reach
176
+ * this table only through a subquery, so an unqualified ref there must bind inside that
177
+ * subquery's FROM — that caller wants {@link renameColumnInAst}, whose walk has no seed.
178
+ *
179
+ * Same sharing and idempotence story as {@link renameColumnInCheckConstraints}: a
180
+ * module's rename hook rebuilds only the renamed column's `ColumnSchema` and keeps every
181
+ * other one by reference, and even the rebuilt one carries the SAME expression nodes
182
+ * (`buildConstraintsFromColumn` passes them into the reconstructed `ColumnDef` by
183
+ * reference and `columnDefToSchema` assigns them straight back), so one in-place rewrite
184
+ * reaches every holder and a second call with the same pair is a no-op.
185
+ *
186
+ * The parameter is structurally typed rather than `ColumnSchema[]` so this module stays
187
+ * free of catalog imports; `ColumnSchema` satisfies it.
188
+ */
189
+ export declare function renameColumnInColumnExpressions(columns: ReadonlyArray<{
190
+ readonly defaultValue?: AST.Expression | null;
191
+ readonly generatedExpr?: AST.Expression;
192
+ }> | undefined, tableName: string, oldColName: string, newColName: string, resolve: ResolveObjectRef, targetKey: string, resolveColumnInSource?: ResolveColumnInSource): boolean;
193
+ /**
194
+ * Whether `body`'s top-level result columns publish the renamed column under
195
+ * `newColName` — i.e. whether rewriting this body shifted the name its readers
196
+ * see. Call AFTER the body rewrite: the predicate compares against the NEW
197
+ * name, exactly as the CTE exposure analysis it shares its internals with
198
+ * ({@link cteExposesRenamedColumn} / `isResultColumnExposure`). An explicit
199
+ * result-column alias suppresses exposure; a bare projection of the renamed
200
+ * column, or a `*` / `t.*` / `a.*` whose frame binds the target, exposes it —
201
+ * a FROM alias is no obstacle, since it only changes which qualifier names the
202
+ * source.
203
+ *
204
+ * An explicit view / materialized-view column list pins the published names
205
+ * regardless of the body — that guard belongs at the call site
206
+ * (`ViewSchema.columns` / `TableDerivation.columns` play the role
207
+ * `cte.columns` plays inside the CTE analysis; this predicate never sees them).
208
+ */
209
+ export declare function bodyExposesRenamedColumn(body: AST.QueryExpr | undefined, tableName: string, oldColName: string, newColName: string, resolve: ResolveObjectRef, targetKey: string, resolveColumnInSource?: ResolveColumnInSource): boolean;
210
+ /**
211
+ * Whether `body`'s top-level result columns publish a column named
212
+ * `columnName`, from ANY origin: an explicit alias, an unaliased bare
213
+ * projection of a column so named (wherever it binds), or a `*` / `t.*` whose
214
+ * bound real-table source exposes it (asked through `resolveColumnInSource`).
215
+ *
216
+ * The collision half of the rename-cascade pre-flight
217
+ * (`runtime/emit/column-rename-cascade.ts`): run against the PRISTINE
218
+ * (pre-rewrite) body with `columnName = newCol` — the rename target cannot
219
+ * publish `newCol` before the rename, so anything found is necessarily a
220
+ * DIFFERENT column the shifted name would collide with.
221
+ *
222
+ * Shares the walker's scope residual: a `*` over a subquery or function source
223
+ * has no askable column set, so a publication arriving only that way is not
224
+ * seen. A `*` over an aliased REAL source is seen — the alias binds like any
225
+ * other qualifier.
226
+ */
227
+ export declare function bodyPublishesColumnNamed(body: AST.QueryExpr | undefined, columnName: string, resolve: ResolveObjectRef, resolveColumnInSource?: ResolveColumnInSource): boolean;
228
+ //# sourceMappingURL=column-rename.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"column-rename.d.ts","sourceRoot":"","sources":["../../../../src/schema/rename/column-rename.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAAuC,KAAK,qBAAqB,EAAE,KAAK,gBAAgB,EAAE,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAqD3I;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,iBAAiB,CAChC,IAAI,EAAE,GAAG,CAAC,OAAO,GAAG,SAAS,EA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