Commit e794b2c
committed
sql/schemachanger: support complex ALTER COLUMN … SET TYPE in DSC
Previously, complex column type changes that required a backfill reverted to
the legacy schema changer. This update now enables support for such changes in
the declarative schema changer (DSC).
As with the legacy process, a complex type change involves dropping the column
being modified and adding a new one with the updated type. A temporary compute
expression is used to map the old column to the new one for backfilling. The
process includes performing a double backfill for the primary key (PK): first,
both the old and new columns are included in the PK, and then a second backfill
is done after the old column is removed. This staged approach is required due
to a rule that prevents dropping the column’s compute expression before the
dependent column is removed, keeping the expression until after the first
backfill.
Since the old and new columns coexist temporarily, the old column is renamed to
avoid ambiguity in the PK. A transient name is assigned to the dropped column
(e.g., <col>_shadow), which is automatically cleaned up later. This ensures
clear differentiation during the transition. A new field was also added to
ColumnName to restore the original name if the operation is undone, avoiding
the use of a placeholder.
However, there are a few limitations with the current implementation:
- No support for columns that already have a compute expression
- No support for columns with ON UPDATE or DEFAULT expressions
- No support for conversions to enum types
- While column order is preserved in the catalog for SELECT * queries, the
order within the column family is not maintained, with the new column being
added at the end of the internal ordering.
Some tests, designed for the legacy schema changer, couldn’t easily be adapted for the DSC.
These limitations are planned to be addressed in future changes.
Epic: CRDB-40232
Closes #127014
Release notes: none1 parent d50ca11 commit e794b2c
File tree
48 files changed
+4091
-87
lines changed- pkg
- ccl
- changefeedccl/cdcevent
- schemachangerccl
- testdata/decomp
- sql
- logictest/testdata/logic_test
- schemachanger
- scbuild
- internal/scbuildstmt
- testdata
- scdecomp/testdata
- scdeps/sctestutils
- scexec/scmutationexec
- scpb
- uml
- scplan
- internal
- opgen
- rules/current
- testdata
- testdata
- sctest
- testdata/end_to_end/alter_table_alter_column_type_general
- sqlerrors
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
48 files changed
+4091
-87
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
598 | 598 | | |
599 | 599 | | |
600 | 600 | | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
601 | 604 | | |
602 | 605 | | |
603 | 606 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
| 193 | + | |
193 | 194 | | |
194 | 195 | | |
195 | 196 | | |
196 | 197 | | |
197 | 198 | | |
| 199 | + | |
198 | 200 | | |
199 | 201 | | |
200 | 202 | | |
201 | 203 | | |
202 | 204 | | |
| 205 | + | |
203 | 206 | | |
204 | 207 | | |
205 | 208 | | |
206 | 209 | | |
207 | 210 | | |
| 211 | + | |
208 | 212 | | |
209 | 213 | | |
210 | 214 | | |
211 | 215 | | |
212 | 216 | | |
| 217 | + | |
213 | 218 | | |
214 | 219 | | |
215 | 220 | | |
216 | 221 | | |
217 | 222 | | |
| 223 | + | |
218 | 224 | | |
219 | 225 | | |
220 | 226 | | |
| |||
579 | 585 | | |
580 | 586 | | |
581 | 587 | | |
| 588 | + | |
582 | 589 | | |
583 | 590 | | |
584 | 591 | | |
585 | 592 | | |
586 | 593 | | |
| 594 | + | |
587 | 595 | | |
588 | 596 | | |
589 | 597 | | |
590 | 598 | | |
591 | 599 | | |
| 600 | + | |
592 | 601 | | |
593 | 602 | | |
594 | 603 | | |
595 | 604 | | |
596 | 605 | | |
| 606 | + | |
597 | 607 | | |
598 | 608 | | |
599 | 609 | | |
600 | 610 | | |
601 | 611 | | |
| 612 | + | |
602 | 613 | | |
603 | 614 | | |
604 | 615 | | |
605 | 616 | | |
606 | 617 | | |
| 618 | + | |
607 | 619 | | |
608 | 620 | | |
609 | 621 | | |
| |||
997 | 1009 | | |
998 | 1010 | | |
999 | 1011 | | |
| 1012 | + | |
1000 | 1013 | | |
1001 | 1014 | | |
1002 | 1015 | | |
1003 | 1016 | | |
1004 | 1017 | | |
| 1018 | + | |
1005 | 1019 | | |
1006 | 1020 | | |
1007 | 1021 | | |
1008 | 1022 | | |
1009 | 1023 | | |
| 1024 | + | |
1010 | 1025 | | |
1011 | 1026 | | |
1012 | 1027 | | |
1013 | 1028 | | |
1014 | 1029 | | |
| 1030 | + | |
1015 | 1031 | | |
1016 | 1032 | | |
1017 | 1033 | | |
1018 | 1034 | | |
1019 | 1035 | | |
| 1036 | + | |
1020 | 1037 | | |
1021 | 1038 | | |
1022 | 1039 | | |
1023 | 1040 | | |
1024 | 1041 | | |
| 1042 | + | |
1025 | 1043 | | |
1026 | 1044 | | |
1027 | 1045 | | |
1028 | 1046 | | |
1029 | 1047 | | |
| 1048 | + | |
1030 | 1049 | | |
1031 | 1050 | | |
1032 | 1051 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| 114 | + | |
114 | 115 | | |
115 | 116 | | |
116 | 117 | | |
117 | 118 | | |
118 | 119 | | |
| 120 | + | |
119 | 121 | | |
120 | 122 | | |
121 | 123 | | |
122 | 124 | | |
123 | 125 | | |
| 126 | + | |
124 | 127 | | |
125 | 128 | | |
126 | 129 | | |
127 | 130 | | |
128 | 131 | | |
| 132 | + | |
129 | 133 | | |
130 | 134 | | |
131 | 135 | | |
132 | 136 | | |
133 | 137 | | |
| 138 | + | |
134 | 139 | | |
135 | 140 | | |
136 | 141 | | |
137 | 142 | | |
138 | 143 | | |
| 144 | + | |
139 | 145 | | |
140 | 146 | | |
141 | 147 | | |
142 | 148 | | |
143 | 149 | | |
| 150 | + | |
144 | 151 | | |
145 | 152 | | |
146 | 153 | | |
| |||
617 | 624 | | |
618 | 625 | | |
619 | 626 | | |
| 627 | + | |
620 | 628 | | |
621 | 629 | | |
622 | 630 | | |
623 | 631 | | |
624 | 632 | | |
| 633 | + | |
625 | 634 | | |
626 | 635 | | |
627 | 636 | | |
628 | 637 | | |
629 | 638 | | |
| 639 | + | |
630 | 640 | | |
631 | 641 | | |
632 | 642 | | |
633 | 643 | | |
634 | 644 | | |
| 645 | + | |
635 | 646 | | |
636 | 647 | | |
637 | 648 | | |
638 | 649 | | |
639 | 650 | | |
| 651 | + | |
640 | 652 | | |
641 | 653 | | |
642 | 654 | | |
643 | 655 | | |
644 | 656 | | |
| 657 | + | |
645 | 658 | | |
646 | 659 | | |
647 | 660 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | 35 | | |
40 | 36 | | |
41 | 37 | | |
| |||
216 | 212 | | |
217 | 213 | | |
218 | 214 | | |
219 | | - | |
| 215 | + | |
220 | 216 | | |
221 | 217 | | |
222 | 218 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
78 | 81 | | |
79 | 82 | | |
80 | 83 | | |
| |||
151 | 154 | | |
152 | 155 | | |
153 | 156 | | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
154 | 160 | | |
155 | 161 | | |
156 | 162 | | |
| |||
203 | 209 | | |
204 | 210 | | |
205 | 211 | | |
206 | | - | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
207 | 216 | | |
208 | 217 | | |
209 | 218 | | |
| |||
259 | 268 | | |
260 | 269 | | |
261 | 270 | | |
262 | | - | |
| 271 | + | |
263 | 272 | | |
264 | 273 | | |
265 | 274 | | |
| |||
0 commit comments