Skip to content

Commit c11b16d

Browse files
committed
sql: implement new storage param in the schema changer
This commit implements the schema-change and validation logic for the new storage param for region-column inference. This involves looking up the referenced FK constraint on the table descriptor, and ensuring it has the correct columns, as well as that the locality is RBR and no computed columns reference the region column. This commit also adds a set of logic tests for the process of setting and unsetting the new storage param, without yet testing the (currently unimplemented) functionality. Informs #148243 Release note: None
1 parent 2fc5c62 commit c11b16d

File tree

25 files changed

+933
-14
lines changed

25 files changed

+933
-14
lines changed

docs/generated/settings/settings-for-tenants.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ feature.backup.enabled boolean true set to true to enable backups, false to disa
7373
feature.changefeed.enabled boolean true set to true to enable changefeeds, false to disable; default is true application
7474
feature.export.enabled boolean true set to true to enable exports, false to disable; default is true application
7575
feature.import.enabled boolean true set to true to enable imports, false to disable; default is true application
76+
feature.infer_rbr_region_col_using_constraint.enabled boolean false set to true to enable looking up the region column via a foreign key constraint in a REGIONAL BY ROW table, false to disable; default is false application
7677
feature.restore.enabled boolean true set to true to enable restore, false to disable; default is true application
7778
feature.schema_change.enabled boolean true set to true to enable schema changes, false to disable; default is true application
7879
feature.stats.enabled boolean true set to true to enable CREATE STATISTICS/ANALYZE, false to disable; default is true application

docs/generated/settings/settings.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
<tr><td><div id="setting-feature-changefeed-enabled" class="anchored"><code>feature.changefeed.enabled</code></div></td><td>boolean</td><td><code>true</code></td><td>set to true to enable changefeeds, false to disable; default is true</td><td>Serverless/Dedicated/Self-Hosted</td></tr>
7979
<tr><td><div id="setting-feature-export-enabled" class="anchored"><code>feature.export.enabled</code></div></td><td>boolean</td><td><code>true</code></td><td>set to true to enable exports, false to disable; default is true</td><td>Serverless/Dedicated/Self-Hosted</td></tr>
8080
<tr><td><div id="setting-feature-import-enabled" class="anchored"><code>feature.import.enabled</code></div></td><td>boolean</td><td><code>true</code></td><td>set to true to enable imports, false to disable; default is true</td><td>Serverless/Dedicated/Self-Hosted</td></tr>
81+
<tr><td><div id="setting-feature-infer-rbr-region-col-using-constraint-enabled" class="anchored"><code>feature.infer_rbr_region_col_using_constraint.enabled</code></div></td><td>boolean</td><td><code>false</code></td><td>set to true to enable looking up the region column via a foreign key constraint in a REGIONAL BY ROW table, false to disable; default is false</td><td>Serverless/Dedicated/Self-Hosted</td></tr>
8182
<tr><td><div id="setting-feature-restore-enabled" class="anchored"><code>feature.restore.enabled</code></div></td><td>boolean</td><td><code>true</code></td><td>set to true to enable restore, false to disable; default is true</td><td>Serverless/Dedicated/Self-Hosted</td></tr>
8283
<tr><td><div id="setting-feature-schema-change-enabled" class="anchored"><code>feature.schema_change.enabled</code></div></td><td>boolean</td><td><code>true</code></td><td>set to true to enable schema changes, false to disable; default is true</td><td>Serverless/Dedicated/Self-Hosted</td></tr>
8384
<tr><td><div id="setting-feature-stats-enabled" class="anchored"><code>feature.stats.enabled</code></div></td><td>boolean</td><td><code>true</code></td><td>set to true to enable CREATE STATISTICS/ANALYZE, false to disable; default is true</td><td>Serverless/Dedicated/Self-Hosted</td></tr>

pkg/ccl/logictestccl/testdata/logic_test/regional_by_row

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ statement ok
435435
ALTER TABLE regional_by_row_table ADD CONSTRAINT unique_b_a UNIQUE(b, a)
436436

437437
# Tests dropping a referenced column in REGIONAL BY ROW does not succeed.
438-
statement error cannot drop column crdb_region as it is used to store the region in a REGIONAL BY ROW table\nHINT: You must change the table locality before dropping this table
438+
statement error cannot drop column crdb_region as it is used to store the region in a REGIONAL BY ROW table\nHINT: You must change the table locality before dropping this column
439439
ALTER TABLE regional_by_row_table DROP COLUMN crdb_region
440440

441441
# Tests changing the PK of a regional by row table.
@@ -619,7 +619,7 @@ pk a b crdb_region_col
619619
20 NULL NULL ap-southeast-2
620620

621621
# Tests dropping a referenced column in REGIONAL BY ROW does not succeed.
622-
statement error cannot drop column crdb_region_col as it is used to store the region in a REGIONAL BY ROW table\nHINT: You must change the table locality before dropping this table
622+
statement error cannot drop column crdb_region_col as it is used to store the region in a REGIONAL BY ROW table\nHINT: You must change the table locality before dropping this column
623623
ALTER TABLE regional_by_row_table_as DROP COLUMN crdb_region_col
624624

625625
# Tests for altering the survivability of a REGIONAL BY ROW table.

pkg/ccl/logictestccl/testdata/logic_test/regional_by_row_foreign_key

Lines changed: 490 additions & 0 deletions
Large diffs are not rendered by default.

pkg/ccl/logictestccl/tests/multiregion-9node-3region-3azs-no-los/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ go_test(
99
"//pkg/ccl/logictestccl:testdata", # keep
1010
],
1111
exec_properties = {"test.Pool": "large"},
12-
shard_count = 21,
12+
shard_count = 22,
1313
tags = ["cpu:4"],
1414
deps = [
1515
"//pkg/base",

pkg/ccl/logictestccl/tests/multiregion-9node-3region-3azs-no-los/generated_test.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/ccl/logictestccl/tests/multiregion-9node-3region-3azs-tenant/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ go_test(
99
"//pkg/ccl/logictestccl:testdata", # keep
1010
],
1111
exec_properties = {"test.Pool": "large"},
12-
shard_count = 18,
12+
shard_count = 19,
1313
tags = ["cpu:4"],
1414
deps = [
1515
"//pkg/base",

pkg/ccl/logictestccl/tests/multiregion-9node-3region-3azs-tenant/generated_test.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/ccl/logictestccl/tests/multiregion-9node-3region-3azs-vec-off/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ go_test(
99
"//pkg/ccl/logictestccl:testdata", # keep
1010
],
1111
exec_properties = {"test.Pool": "large"},
12-
shard_count = 9,
12+
shard_count = 10,
1313
tags = ["cpu:4"],
1414
deps = [
1515
"//pkg/base",

pkg/ccl/logictestccl/tests/multiregion-9node-3region-3azs-vec-off/generated_test.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)