Skip to content

Commit 891f6ef

Browse files
craig[bot]fqazi
andcommitted
Merge #146726
146726: sql/schemachanger: support partitions and RBR tables for alter PK r=fqazi a=fqazi Previously, ALTER PRIMARY KEY in the declarative schema changer did not support partitioned / RBR tables, which would cause it to fallback. This meant that ALTER PRIMARY KEY would always use the legacy schema changer on multi-region environments. To address this, this patch adds partitioning and RBR support into the declarative ALTER PRIMARY KEY. This includes logic to generate subzone config for replacement indexes and generating zone configurations for new primary keys. Additionally, to help support this change we are going to refactor logic used to generated partitioned zone configurations to work on top of indexSpec and introduce a indexSpecMutator for index column management. This allows us to also simplify and de-duplicate code. Fixes: #146725 Release note: None Co-authored-by: Faizan Qazi <[email protected]>
2 parents 5d6a056 + 6e7d450 commit 891f6ef

File tree

107 files changed

+12143
-3161
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+12143
-3161
lines changed

pkg/ccl/partitionccl/zone_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,10 +1022,12 @@ func TestPrimaryKeyChangeZoneConfigs(t *testing.T) {
10221022
// dropped copy of i2, new copy of i1, and new copy of i2.
10231023
// These have ID's 2, 3, 6 and 8 respectively.
10241024
expectedSpans := []roachpb.Key{
1025-
table.IndexSpan(codec, 2 /* indexID */).Key,
1026-
table.IndexSpan(codec, 3 /* indexID */).Key,
1027-
table.IndexSpan(codec, 6 /* indexID */).Key,
1028-
table.IndexSpan(codec, 8 /* indexID */).Key,
1025+
table.IndexSpan(codec, 2 /* indexID */).Key, // index: old_i1
1026+
table.IndexSpan(codec, 3 /* indexID */).Key, // index: old_i2
1027+
table.IndexSpan(codec, 4 /* indexID */).Key, // index: i1
1028+
table.IndexSpan(codec, 5 /* indexID */).Key, // index: i1_tmp
1029+
table.IndexSpan(codec, 6 /* indexID */).Key, // index: i2
1030+
table.IndexSpan(codec, 7 /* indexID */).Key, // index: i2_tmp
10291031
}
10301032
if len(zone.SubzoneSpans) != len(expectedSpans) {
10311033
t.Fatalf("expected subzones to have length %d", len(expectedSpans))

pkg/ccl/schemachangerccl/ccl_generated_test.go

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

pkg/ccl/schemachangerccl/sctestbackupccl/backup_multiregion_generated_test.go

Lines changed: 28 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)