-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
schemachanger: refactor subzone config elements
TODO
- Loading branch information
Showing
29 changed files
with
823 additions
and
113 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...tion_configure_zone_subpartitions/alter_partition_configure_zone_subpartitions.definition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
setup | ||
CREATE TABLE person ( | ||
name STRING, | ||
country STRING, | ||
birth_date DATE, | ||
PRIMARY KEY (country, birth_date, name) | ||
) | ||
PARTITION BY LIST (country) ( | ||
PARTITION australia | ||
VALUES IN ('AU', 'NZ') | ||
PARTITION BY RANGE (birth_date) | ||
( | ||
PARTITION old_au VALUES FROM (minvalue) TO ('1995-01-01'), | ||
PARTITION yung_au VALUES FROM ('1995-01-01') TO (maxvalue) | ||
), | ||
PARTITION north_america | ||
VALUES IN ('US', 'CA') | ||
PARTITION BY RANGE (birth_date) | ||
( | ||
PARTITION old_na VALUES FROM (minvalue) TO ('1995-01-01'), | ||
PARTITION yung_na VALUES FROM ('1995-01-01') TO (maxvalue) | ||
), | ||
PARTITION default | ||
VALUES IN (default) | ||
); | ||
---- | ||
|
||
test | ||
ALTER PARTITION australia OF TABLE person CONFIGURE ZONE USING gc.ttlseconds = 2; | ||
ALTER PARTITION old_au OF TABLE person CONFIGURE ZONE USING gc.ttlseconds = 4; | ||
ALTER PARTITION yung_au OF TABLE person CONFIGURE ZONE USING gc.ttlseconds = 5; | ||
ALTER PARTITION old_au OF TABLE person CONFIGURE ZONE USING gc.ttlseconds = 6; | ||
---- |
103 changes: 103 additions & 0 deletions
103
...on_configure_zone_subpartitions/alter_partition_configure_zone_subpartitions.side_effects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/* setup */ | ||
CREATE TABLE person ( | ||
name STRING, | ||
country STRING, | ||
birth_date DATE, | ||
PRIMARY KEY (country, birth_date, name) | ||
) | ||
PARTITION BY LIST (country) ( | ||
PARTITION australia | ||
VALUES IN ('AU', 'NZ') | ||
PARTITION BY RANGE (birth_date) | ||
( | ||
PARTITION old_au VALUES FROM (minvalue) TO ('1995-01-01'), | ||
PARTITION yung_au VALUES FROM ('1995-01-01') TO (maxvalue) | ||
), | ||
PARTITION north_america | ||
VALUES IN ('US', 'CA') | ||
PARTITION BY RANGE (birth_date) | ||
( | ||
PARTITION old_na VALUES FROM (minvalue) TO ('1995-01-01'), | ||
PARTITION yung_na VALUES FROM ('1995-01-01') TO (maxvalue) | ||
), | ||
PARTITION default | ||
VALUES IN (default) | ||
); | ||
---- | ||
... | ||
+object {100 101 person} -> 104 | ||
|
||
/* test */ | ||
ALTER PARTITION australia OF TABLE person CONFIGURE ZONE USING gc.ttlseconds = 2; | ||
ALTER PARTITION old_au OF TABLE person CONFIGURE ZONE USING gc.ttlseconds = 4; | ||
ALTER PARTITION yung_au OF TABLE person CONFIGURE ZONE USING gc.ttlseconds = 5; | ||
ALTER PARTITION old_au OF TABLE person CONFIGURE ZONE USING gc.ttlseconds = 6; | ||
---- | ||
begin transaction #1 | ||
# begin StatementPhase | ||
checking for feature: CONFIGURE ZONE | ||
write *eventpb.SetZoneConfig to event log: | ||
config: | ||
options: | ||
- '"gc.ttlseconds" = 2' | ||
target: PARTITION australia OF INDEX defaultdb.public.person@person_pkey | ||
resolvedOldConfig: 'inherited_constraints:false null_voter_constraints_is_empty:false inherited_lease_preferences:false ' | ||
sql: | ||
descriptorId: 104 | ||
statement: ALTER PARTITION ‹australia› OF INDEX ‹defaultdb›.‹public›.‹person›@‹person_pkey› CONFIGURE ZONE USING ‹"gc.ttlseconds"› = ‹2› | ||
tag: CONFIGURE ZONE | ||
user: root | ||
## StatementPhase stage 1 of 1 with 1 MutationType op | ||
upsert zone config for #104 | ||
checking for feature: CONFIGURE ZONE | ||
write *eventpb.SetZoneConfig to event log: | ||
config: | ||
options: | ||
- '"gc.ttlseconds" = 4' | ||
target: PARTITION old_au OF INDEX defaultdb.public.person@person_pkey | ||
resolvedOldConfig: 'inherited_constraints:false null_voter_constraints_is_empty:false inherited_lease_preferences:false ' | ||
sql: | ||
descriptorId: 104 | ||
statement: ALTER PARTITION ‹old_au› OF INDEX ‹defaultdb›.‹public›.‹person›@‹person_pkey› CONFIGURE ZONE USING ‹"gc.ttlseconds"› = ‹4› | ||
tag: CONFIGURE ZONE | ||
user: root | ||
## StatementPhase stage 1 of 1 with 1 MutationType op | ||
upsert zone config for #104 | ||
checking for feature: CONFIGURE ZONE | ||
write *eventpb.SetZoneConfig to event log: | ||
config: | ||
options: | ||
- '"gc.ttlseconds" = 5' | ||
target: PARTITION yung_au OF INDEX defaultdb.public.person@person_pkey | ||
resolvedOldConfig: 'inherited_constraints:false null_voter_constraints_is_empty:false inherited_lease_preferences:false ' | ||
sql: | ||
descriptorId: 104 | ||
statement: ALTER PARTITION ‹yung_au› OF INDEX ‹defaultdb›.‹public›.‹person›@‹person_pkey› CONFIGURE ZONE USING ‹"gc.ttlseconds"› = ‹5› | ||
tag: CONFIGURE ZONE | ||
user: root | ||
## StatementPhase stage 1 of 1 with 1 MutationType op | ||
upsert zone config for #104 | ||
checking for feature: CONFIGURE ZONE | ||
write *eventpb.SetZoneConfig to event log: | ||
config: | ||
options: | ||
- '"gc.ttlseconds" = 6' | ||
target: PARTITION old_au OF INDEX defaultdb.public.person@person_pkey | ||
resolvedOldConfig: 'inherited_constraints:false null_voter_constraints_is_empty:false inherited_lease_preferences:false ' | ||
sql: | ||
descriptorId: 104 | ||
statement: ALTER PARTITION ‹old_au› OF INDEX ‹defaultdb›.‹public›.‹person›@‹person_pkey› CONFIGURE ZONE USING ‹"gc.ttlseconds"› = ‹6› | ||
tag: CONFIGURE ZONE | ||
user: root | ||
## StatementPhase stage 1 of 1 with 1 MutationType op | ||
upsert zone config for #104 | ||
# end StatementPhase | ||
# begin PreCommitPhase | ||
## PreCommitPhase stage 1 of 2 with 1 MutationType op | ||
undo all catalog changes within txn #1 | ||
persist all catalog changes to storage | ||
## PreCommitPhase stage 2 of 2 with 4 MutationType ops | ||
upsert zone config for #104 | ||
persist all catalog changes to storage | ||
# end PreCommitPhase | ||
commit transaction #1 |
47 changes: 47 additions & 0 deletions
47
...zone_subpartitions/alter_partition_configure_zone_subpartitions__statement_1_of_4.explain
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* setup */ | ||
CREATE TABLE person ( | ||
name STRING, | ||
country STRING, | ||
birth_date DATE, | ||
PRIMARY KEY (country, birth_date, name) | ||
) | ||
PARTITION BY LIST (country) ( | ||
PARTITION australia | ||
VALUES IN ('AU', 'NZ') | ||
PARTITION BY RANGE (birth_date) | ||
( | ||
PARTITION old_au VALUES FROM (minvalue) TO ('1995-01-01'), | ||
PARTITION yung_au VALUES FROM ('1995-01-01') TO (maxvalue) | ||
), | ||
PARTITION north_america | ||
VALUES IN ('US', 'CA') | ||
PARTITION BY RANGE (birth_date) | ||
( | ||
PARTITION old_na VALUES FROM (minvalue) TO ('1995-01-01'), | ||
PARTITION yung_na VALUES FROM ('1995-01-01') TO (maxvalue) | ||
), | ||
PARTITION default | ||
VALUES IN (default) | ||
); | ||
|
||
/* test */ | ||
EXPLAIN (DDL) ALTER PARTITION australia OF TABLE person CONFIGURE ZONE USING gc.ttlseconds = 2; | ||
---- | ||
Schema change plan for ALTER PARTITION ‹australia› OF INDEX ‹defaultdb›.‹public›.‹person›@‹person_pkey› CONFIGURE ZONE USING ‹"gc.ttlseconds"› = ‹2›; | ||
├── StatementPhase | ||
│ └── Stage 1 of 1 in StatementPhase | ||
│ ├── 1 element transitioning toward PUBLIC | ||
│ │ └── ABSENT → PUBLIC PartitionZoneConfig:{DescID: 104 (person), IndexID: 1 (person_pkey), SeqNum: 1, PartitionName: "australia"} | ||
│ └── 1 Mutation operation | ||
│ └── AddPartitionZoneConfig {"TableID":104} | ||
└── PreCommitPhase | ||
├── Stage 1 of 2 in PreCommitPhase | ||
│ ├── 1 element transitioning toward PUBLIC | ||
│ │ └── PUBLIC → ABSENT PartitionZoneConfig:{DescID: 104 (person), IndexID: 1 (person_pkey), SeqNum: 1, PartitionName: "australia"} | ||
│ └── 1 Mutation operation | ||
│ └── UndoAllInTxnImmediateMutationOpSideEffects | ||
└── Stage 2 of 2 in PreCommitPhase | ||
├── 1 element transitioning toward PUBLIC | ||
│ └── ABSENT → PUBLIC PartitionZoneConfig:{DescID: 104 (person), IndexID: 1 (person_pkey), SeqNum: 1, PartitionName: "australia"} | ||
└── 1 Mutation operation | ||
└── AddPartitionZoneConfig {"TableID":104} |
Oops, something went wrong.