@quereus/quereus 4.20.2 → 4.21.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.
- package/README.md +2 -0
- package/dist/src/common/constants.d.ts +8 -1
- package/dist/src/common/constants.d.ts.map +1 -1
- package/dist/src/common/constants.js +7 -0
- package/dist/src/common/constants.js.map +1 -1
- package/dist/src/core/database.d.ts +4 -1
- package/dist/src/core/database.d.ts.map +1 -1
- package/dist/src/core/database.js +10 -4
- package/dist/src/core/database.js.map +1 -1
- package/dist/src/core/statement.d.ts +12 -0
- package/dist/src/core/statement.d.ts.map +1 -1
- package/dist/src/core/statement.js +20 -2
- package/dist/src/core/statement.js.map +1 -1
- package/dist/src/func/builtins/scalar.d.ts.map +1 -1
- package/dist/src/func/builtins/scalar.js +3 -0
- package/dist/src/func/builtins/scalar.js.map +1 -1
- package/dist/src/func/registration.d.ts +4 -0
- package/dist/src/func/registration.d.ts.map +1 -1
- package/dist/src/func/registration.js +11 -1
- package/dist/src/func/registration.js.map +1 -1
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/planner/analysis/change-scope.d.ts +58 -2
- package/dist/src/planner/analysis/change-scope.d.ts.map +1 -1
- package/dist/src/planner/analysis/change-scope.js +94 -73
- package/dist/src/planner/analysis/change-scope.js.map +1 -1
- package/dist/src/planner/analysis/non-det-functions.d.ts +10 -0
- package/dist/src/planner/analysis/non-det-functions.d.ts.map +1 -0
- package/dist/src/planner/analysis/non-det-functions.js +17 -0
- package/dist/src/planner/analysis/non-det-functions.js.map +1 -0
- package/dist/src/planner/analysis/value-provenance.d.ts +119 -0
- package/dist/src/planner/analysis/value-provenance.d.ts.map +1 -0
- package/dist/src/planner/analysis/value-provenance.js +406 -0
- package/dist/src/planner/analysis/value-provenance.js.map +1 -0
- package/dist/src/planner/analysis/write-scope.d.ts +150 -0
- package/dist/src/planner/analysis/write-scope.d.ts.map +1 -0
- package/dist/src/planner/analysis/write-scope.js +95 -0
- package/dist/src/planner/analysis/write-scope.js.map +1 -0
- package/dist/src/planner/analysis/write-site-analysis.d.ts +67 -0
- package/dist/src/planner/analysis/write-site-analysis.d.ts.map +1 -0
- package/dist/src/planner/analysis/write-site-analysis.js +354 -0
- package/dist/src/planner/analysis/write-site-analysis.js.map +1 -0
- package/dist/src/planner/building/delete.d.ts.map +1 -1
- package/dist/src/planner/building/delete.js +9 -1
- package/dist/src/planner/building/delete.js.map +1 -1
- package/dist/src/planner/building/insert.d.ts.map +1 -1
- package/dist/src/planner/building/insert.js +8 -1
- package/dist/src/planner/building/insert.js.map +1 -1
- package/dist/src/planner/building/update.d.ts.map +1 -1
- package/dist/src/planner/building/update.js +9 -2
- package/dist/src/planner/building/update.js.map +1 -1
- package/dist/src/planner/nodes/dml-executor-node.d.ts +18 -1
- package/dist/src/planner/nodes/dml-executor-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/dml-executor-node.js +12 -2
- package/dist/src/planner/nodes/dml-executor-node.js.map +1 -1
- package/dist/src/runtime/emit/dml-executor.d.ts.map +1 -1
- package/dist/src/runtime/emit/dml-executor.js +39 -12
- package/dist/src/runtime/emit/dml-executor.js.map +1 -1
- package/dist/src/schema/assertion.d.ts +3 -1
- package/dist/src/schema/assertion.d.ts.map +1 -1
- package/dist/src/schema/assertion.js.map +1 -1
- package/dist/src/schema/schema-differ.d.ts.map +1 -1
- package/dist/src/schema/schema-differ.js +17 -69
- package/dist/src/schema/schema-differ.js.map +1 -1
- package/dist/src/vtab/table.d.ts +16 -0
- package/dist/src/vtab/table.d.ts.map +1 -1
- package/dist/src/vtab/table.js +7 -0
- package/dist/src/vtab/table.js.map +1 -1
- package/package.json +3 -3
- package/test/logic/50.2.1-declare-schema-index-renames.sqllogic +189 -152
|
@@ -1,173 +1,210 @@
|
|
|
1
|
-
-- 50.2.1-declare-schema-index-renames.sqllogic
|
|
2
|
-
--
|
|
3
|
-
-- requires-capability: standalone-index-ddl
|
|
4
|
-
--
|
|
5
|
-
-- Carved out of 50.2-declare-schema-renames: the declarative-schema rename/diff engine
|
|
6
|
-
-- treats tables, views and indexes as three parallel object kinds, and 50.2 exercises the
|
|
7
|
-
-- whole engine (hint resolution, drop+create ordering, in-diff column and table renames,
|
|
8
|
-
-- rename policies, ambiguity guards) on the table and view kinds with no index DDL.
|
|
9
|
-
-- These four sections are the INDEX-kind instances, so they live here.
|
|
10
|
-
--
|
|
11
|
-
-- Section numbers keep their original 50.2 labels so cross-references still resolve.
|
|
12
|
-
--
|
|
13
|
-
-- Subject: a hinted index rename becomes DROP INDEX + recreate, orders correctly against
|
|
14
|
-
-- an in-diff column or table rename of its source, and does not trip the require-hint
|
|
15
|
-
-- guard.
|
|
16
|
-
|
|
17
|
-
-- ===================================
|
|
18
|
-
-- 17. Hinted INDEX rename, body unchanged → drop + recreate
|
|
19
|
-
-- ===================================
|
|
20
|
-
|
|
21
|
-
create table ir_t (id integer primary key, category text);
|
|
22
|
-
create index ix_old on ir_t (category);
|
|
1
|
+
-- 50.2.1-declare-schema-index-renames.sqllogic
|
|
2
|
+
--
|
|
3
|
+
-- requires-capability: standalone-index-ddl
|
|
4
|
+
--
|
|
5
|
+
-- Carved out of 50.2-declare-schema-renames: the declarative-schema rename/diff engine
|
|
6
|
+
-- treats tables, views and indexes as three parallel object kinds, and 50.2 exercises the
|
|
7
|
+
-- whole engine (hint resolution, drop+create ordering, in-diff column and table renames,
|
|
8
|
+
-- rename policies, ambiguity guards) on the table and view kinds with no index DDL.
|
|
9
|
+
-- These four sections are the INDEX-kind instances, so they live here.
|
|
10
|
+
--
|
|
11
|
+
-- Section numbers keep their original 50.2 labels so cross-references still resolve.
|
|
12
|
+
--
|
|
13
|
+
-- Subject: a hinted index rename becomes DROP INDEX + recreate, orders correctly against
|
|
14
|
+
-- an in-diff column or table rename of its source, and does not trip the require-hint
|
|
15
|
+
-- guard.
|
|
16
|
+
|
|
17
|
+
-- ===================================
|
|
18
|
+
-- 17. Hinted INDEX rename, body unchanged → drop + recreate
|
|
19
|
+
-- ===================================
|
|
20
|
+
|
|
21
|
+
create table ir_t (id integer primary key, category text);
|
|
22
|
+
create index ix_old on ir_t (category);
|
|
23
|
+
|
|
24
|
+
declare schema main {
|
|
25
|
+
table ir_t {
|
|
26
|
+
id integer primary key,
|
|
27
|
+
category text
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
index ix_new on ir_t (category) with tags ("quereus.previous_name" = 'ix_old')
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
-- run
|
|
34
|
+
|
|
35
|
+
diff schema main;
|
|
36
|
+
→ [{"ddl": "DROP INDEX IF EXISTS ix_old"}, {"ddl": "create index ix_new on ir_t (category) with tags (\"quereus.previous_name\" = 'ix_old')"}]
|
|
37
|
+
|
|
38
|
+
apply schema main;
|
|
39
|
+
|
|
40
|
+
-- run
|
|
41
|
+
|
|
42
|
+
select name, tbl_name from schema() where type = 'index';
|
|
43
|
+
→ [{"name": "ix_new", "tbl_name": "ir_t"}]
|
|
44
|
+
|
|
45
|
+
diff schema main;
|
|
46
|
+
→ []
|
|
47
|
+
|
|
48
|
+
drop index ix_new;
|
|
49
|
+
drop table ir_t;
|
|
50
|
+
|
|
51
|
+
-- ===================================
|
|
52
|
+
-- 20. Hinted INDEX rename + in-diff COLUMN rename of its table
|
|
53
|
+
-- ===================================
|
|
54
|
+
|
|
55
|
+
create table irc_t (id integer primary key, amount integer not null);
|
|
56
|
+
create index irc_old on irc_t (amount);
|
|
57
|
+
|
|
58
|
+
declare schema main {
|
|
59
|
+
table irc_t {
|
|
60
|
+
id integer primary key,
|
|
61
|
+
qty integer not null with tags ("quereus.previous_name" = 'amount')
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
index irc_new on irc_t (qty) with tags ("quereus.previous_name" = 'irc_old')
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
-- run
|
|
68
|
+
|
|
69
|
+
-- The recreate names the NEW column (index creates run after RENAME COLUMN).
|
|
70
|
+
diff schema main;
|
|
71
|
+
→ [{"ddl": "DROP INDEX IF EXISTS irc_old"}, {"ddl": "ALTER TABLE irc_t RENAME COLUMN amount TO qty"}, {"ddl": "create index irc_new on irc_t (qty) with tags (\"quereus.previous_name\" = 'irc_old')"}]
|
|
72
|
+
|
|
73
|
+
apply schema main;
|
|
74
|
+
|
|
75
|
+
-- run
|
|
76
|
+
|
|
77
|
+
select name from schema() where type = 'index';
|
|
78
|
+
→ [{"name": "irc_new"}]
|
|
79
|
+
|
|
80
|
+
diff schema main;
|
|
81
|
+
→ []
|
|
82
|
+
|
|
83
|
+
drop index irc_new;
|
|
84
|
+
drop table irc_t;
|
|
85
|
+
|
|
86
|
+
-- ===================================
|
|
87
|
+
-- 21. require-hint: hinted view + index renames apply cleanly
|
|
88
|
+
-- ===================================
|
|
89
|
+
|
|
90
|
+
-- A hinted rename's drop+create pair is deliberate, not an ambiguous unhinted
|
|
91
|
+
-- rename — it must not trip the require-hint guard (excluded from the counts,
|
|
92
|
+
-- like the body-change recreates of §14).
|
|
93
|
+
|
|
94
|
+
create table rh2_t (id integer primary key, v integer);
|
|
95
|
+
create view rh2_vold as select id, v from rh2_t;
|
|
96
|
+
create index rh2_ixold on rh2_t (v);
|
|
97
|
+
|
|
98
|
+
declare schema main {
|
|
99
|
+
table rh2_t {
|
|
100
|
+
id integer primary key,
|
|
101
|
+
v integer
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
view rh2_vnew as select id, v from rh2_t with tags ("quereus.previous_name" = 'rh2_vold')
|
|
105
|
+
|
|
106
|
+
index rh2_ixnew on rh2_t (v) with tags ("quereus.previous_name" = 'rh2_ixold')
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
-- run
|
|
110
|
+
|
|
111
|
+
apply schema main options (rename_policy = 'require-hint');
|
|
112
|
+
|
|
113
|
+
-- run
|
|
114
|
+
|
|
115
|
+
diff schema main;
|
|
116
|
+
→ []
|
|
117
|
+
|
|
118
|
+
select name from schema() where type = 'view';
|
|
119
|
+
→ [{"name": "rh2_vnew"}]
|
|
120
|
+
|
|
121
|
+
select name from schema() where type = 'index';
|
|
122
|
+
→ [{"name": "rh2_ixnew"}]
|
|
123
|
+
|
|
124
|
+
drop view rh2_vnew;
|
|
125
|
+
drop index rh2_ixnew;
|
|
126
|
+
drop table rh2_t;
|
|
127
|
+
|
|
128
|
+
-- ===================================
|
|
129
|
+
-- 22. Hinted VIEW + INDEX rename + in-diff TABLE rename of their source
|
|
130
|
+
-- ===================================
|
|
131
|
+
|
|
132
|
+
-- The recreates keep the DECLARED table name (no inverse table pass): table
|
|
133
|
+
-- renames emit FIRST in migration order, so the new name is live by the time
|
|
134
|
+
-- the view/index creates plan their bodies.
|
|
135
|
+
|
|
136
|
+
create table src_old (id integer primary key, v integer);
|
|
137
|
+
create view trv_old as select id, v from src_old;
|
|
138
|
+
create index tri_old on src_old (v);
|
|
139
|
+
insert into src_old values (1, 10);
|
|
140
|
+
|
|
141
|
+
declare schema main {
|
|
142
|
+
table src_new {
|
|
143
|
+
id integer primary key,
|
|
144
|
+
v integer
|
|
145
|
+
} with tags ("quereus.previous_name" = 'src_old')
|
|
146
|
+
|
|
147
|
+
view trv_new as select id, v from src_new with tags ("quereus.previous_name" = 'trv_old')
|
|
148
|
+
|
|
149
|
+
index tri_new on src_new (v) with tags ("quereus.previous_name" = 'tri_old')
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
-- run
|
|
153
|
+
|
|
154
|
+
diff schema main;
|
|
155
|
+
→ [{"ddl": "ALTER TABLE src_old RENAME TO src_new"}, {"ddl": "DROP VIEW IF EXISTS trv_old"}, {"ddl": "DROP INDEX IF EXISTS tri_old"}, {"ddl": "create view trv_new as select id, v from src_new with tags (\"quereus.previous_name\" = 'trv_old')"}, {"ddl": "create index tri_new on src_new (v) with tags (\"quereus.previous_name\" = 'tri_old')"}]
|
|
156
|
+
|
|
157
|
+
apply schema main;
|
|
158
|
+
|
|
159
|
+
-- run
|
|
160
|
+
|
|
161
|
+
select * from trv_new order by id;
|
|
162
|
+
→ [{"id": 1, "v": 10}]
|
|
163
|
+
|
|
164
|
+
select name, tbl_name from schema() where type = 'index';
|
|
165
|
+
→ [{"name": "tri_new", "tbl_name": "src_new"}]
|
|
166
|
+
|
|
167
|
+
diff schema main;
|
|
168
|
+
→ []
|
|
169
|
+
|
|
170
|
+
drop view trv_new;
|
|
171
|
+
drop index tri_new;
|
|
172
|
+
drop table src_new;
|
|
173
|
+
|
|
174
|
+
-- Index creates run after the table-alter block, so one round can add a column
|
|
175
|
+
-- and index it (the create used to run before ADD COLUMN and failed with
|
|
176
|
+
-- "Column not found").
|
|
177
|
+
|
|
178
|
+
create table aci_t (id integer primary key);
|
|
179
|
+
insert into aci_t values (1);
|
|
23
180
|
|
|
24
181
|
declare schema main {
|
|
25
|
-
table
|
|
182
|
+
table aci_t {
|
|
26
183
|
id integer primary key,
|
|
27
|
-
|
|
184
|
+
b text null
|
|
28
185
|
}
|
|
29
186
|
|
|
30
|
-
index
|
|
187
|
+
index aci_b on aci_t (b)
|
|
31
188
|
}
|
|
32
189
|
|
|
33
190
|
-- run
|
|
34
191
|
|
|
35
192
|
diff schema main;
|
|
36
|
-
→ [{"ddl": "
|
|
193
|
+
→ [{"ddl": "ALTER TABLE aci_t ADD COLUMN b text null"}, {"ddl": "create index aci_b on aci_t (b)"}]
|
|
37
194
|
|
|
38
195
|
apply schema main;
|
|
39
196
|
|
|
40
197
|
-- run
|
|
41
198
|
|
|
42
199
|
select name, tbl_name from schema() where type = 'index';
|
|
43
|
-
→ [{"name": "
|
|
44
|
-
|
|
45
|
-
diff schema main;
|
|
46
|
-
→ []
|
|
47
|
-
|
|
48
|
-
drop index ix_new;
|
|
49
|
-
drop table ir_t;
|
|
50
|
-
|
|
51
|
-
-- ===================================
|
|
52
|
-
-- 20. Hinted INDEX rename + in-diff COLUMN rename of its table
|
|
53
|
-
-- ===================================
|
|
54
|
-
|
|
55
|
-
create table irc_t (id integer primary key, amount integer not null);
|
|
56
|
-
create index irc_old on irc_t (amount);
|
|
57
|
-
|
|
58
|
-
declare schema main {
|
|
59
|
-
table irc_t {
|
|
60
|
-
id integer primary key,
|
|
61
|
-
qty integer not null with tags ("quereus.previous_name" = 'amount')
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
index irc_new on irc_t (qty) with tags ("quereus.previous_name" = 'irc_old')
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
-- run
|
|
68
|
-
|
|
69
|
-
-- The recreate names the OLD column (RENAME COLUMN runs after creates); the
|
|
70
|
-
-- propagation rewrites the fresh index's columns.
|
|
71
|
-
diff schema main;
|
|
72
|
-
→ [{"ddl": "DROP INDEX IF EXISTS irc_old"}, {"ddl": "create index irc_new on irc_t (amount) with tags (\"quereus.previous_name\" = 'irc_old')"}, {"ddl": "ALTER TABLE irc_t RENAME COLUMN amount TO qty"}]
|
|
73
|
-
|
|
74
|
-
apply schema main;
|
|
75
|
-
|
|
76
|
-
-- run
|
|
77
|
-
|
|
78
|
-
select name from schema() where type = 'index';
|
|
79
|
-
→ [{"name": "irc_new"}]
|
|
80
|
-
|
|
81
|
-
diff schema main;
|
|
82
|
-
→ []
|
|
83
|
-
|
|
84
|
-
drop index irc_new;
|
|
85
|
-
drop table irc_t;
|
|
86
|
-
|
|
87
|
-
-- ===================================
|
|
88
|
-
-- 21. require-hint: hinted view + index renames apply cleanly
|
|
89
|
-
-- ===================================
|
|
90
|
-
|
|
91
|
-
-- A hinted rename's drop+create pair is deliberate, not an ambiguous unhinted
|
|
92
|
-
-- rename — it must not trip the require-hint guard (excluded from the counts,
|
|
93
|
-
-- like the body-change recreates of §14).
|
|
94
|
-
|
|
95
|
-
create table rh2_t (id integer primary key, v integer);
|
|
96
|
-
create view rh2_vold as select id, v from rh2_t;
|
|
97
|
-
create index rh2_ixold on rh2_t (v);
|
|
98
|
-
|
|
99
|
-
declare schema main {
|
|
100
|
-
table rh2_t {
|
|
101
|
-
id integer primary key,
|
|
102
|
-
v integer
|
|
103
|
-
}
|
|
200
|
+
→ [{"name": "aci_b", "tbl_name": "aci_t"}]
|
|
104
201
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
-- run
|
|
111
|
-
|
|
112
|
-
apply schema main options (rename_policy = 'require-hint');
|
|
113
|
-
|
|
114
|
-
-- run
|
|
115
|
-
|
|
116
|
-
diff schema main;
|
|
117
|
-
→ []
|
|
118
|
-
|
|
119
|
-
select name from schema() where type = 'view';
|
|
120
|
-
→ [{"name": "rh2_vnew"}]
|
|
121
|
-
|
|
122
|
-
select name from schema() where type = 'index';
|
|
123
|
-
→ [{"name": "rh2_ixnew"}]
|
|
124
|
-
|
|
125
|
-
drop view rh2_vnew;
|
|
126
|
-
drop index rh2_ixnew;
|
|
127
|
-
drop table rh2_t;
|
|
128
|
-
|
|
129
|
-
-- ===================================
|
|
130
|
-
-- 22. Hinted VIEW + INDEX rename + in-diff TABLE rename of their source
|
|
131
|
-
-- ===================================
|
|
132
|
-
|
|
133
|
-
-- The recreates keep the DECLARED table name (no inverse table pass): table
|
|
134
|
-
-- renames emit FIRST in migration order, so the new name is live by the time
|
|
135
|
-
-- the view/index creates plan their bodies.
|
|
136
|
-
|
|
137
|
-
create table src_old (id integer primary key, v integer);
|
|
138
|
-
create view trv_old as select id, v from src_old;
|
|
139
|
-
create index tri_old on src_old (v);
|
|
140
|
-
insert into src_old values (1, 10);
|
|
141
|
-
|
|
142
|
-
declare schema main {
|
|
143
|
-
table src_new {
|
|
144
|
-
id integer primary key,
|
|
145
|
-
v integer
|
|
146
|
-
} with tags ("quereus.previous_name" = 'src_old')
|
|
147
|
-
|
|
148
|
-
view trv_new as select id, v from src_new with tags ("quereus.previous_name" = 'trv_old')
|
|
149
|
-
|
|
150
|
-
index tri_new on src_new (v) with tags ("quereus.previous_name" = 'tri_old')
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
-- run
|
|
154
|
-
|
|
155
|
-
diff schema main;
|
|
156
|
-
→ [{"ddl": "ALTER TABLE src_old RENAME TO src_new"}, {"ddl": "DROP VIEW IF EXISTS trv_old"}, {"ddl": "DROP INDEX IF EXISTS tri_old"}, {"ddl": "create view trv_new as select id, v from src_new with tags (\"quereus.previous_name\" = 'trv_old')"}, {"ddl": "create index tri_new on src_new (v) with tags (\"quereus.previous_name\" = 'tri_old')"}]
|
|
157
|
-
|
|
158
|
-
apply schema main;
|
|
159
|
-
|
|
160
|
-
-- run
|
|
161
|
-
|
|
162
|
-
select * from trv_new order by id;
|
|
163
|
-
→ [{"id": 1, "v": 10}]
|
|
164
|
-
|
|
165
|
-
select name, tbl_name from schema() where type = 'index';
|
|
166
|
-
→ [{"name": "tri_new", "tbl_name": "src_new"}]
|
|
202
|
+
insert into aci_t values (2, 'x');
|
|
203
|
+
select id from aci_t where b = 'x';
|
|
204
|
+
→ [{"id": 2}]
|
|
167
205
|
|
|
168
206
|
diff schema main;
|
|
169
207
|
→ []
|
|
170
208
|
|
|
171
|
-
drop
|
|
172
|
-
drop
|
|
173
|
-
drop table src_new;
|
|
209
|
+
drop index aci_b;
|
|
210
|
+
drop table aci_t;
|