diff --git a/pkg/ccl/schemachangerccl/testdata/explain/create_index.rollback_1_of_7 b/pkg/ccl/schemachangerccl/testdata/explain/create_index.rollback_1_of_7 index 37238dbd85c1..632fd6ae84b1 100644 --- a/pkg/ccl/schemachangerccl/testdata/explain/create_index.rollback_1_of_7 +++ b/pkg/ccl/schemachangerccl/testdata/explain/create_index.rollback_1_of_7 @@ -22,13 +22,7 @@ Schema change plan for rolling back CREATE INDEX ‹id1› ON ‹defaultdb›.pu │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} │ └── PUBLIC → ABSENT IndexPartitioning:{DescID: 104, IndexID: 3} - └── 13 Mutation operations - ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} - ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"Ordinal":1,"TableID":104} - ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":3,"Kind":2,"TableID":104} - ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":104} - ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"Ordinal":1,"TableID":104} - ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":2,"Kind":2,"TableID":104} + └── 7 Mutation operations ├── LogEvent {"TargetStatus":1} ├── CreateGcJobForIndex {"IndexID":2,"TableID":104} ├── MakeIndexAbsent {"IndexID":2,"TableID":104} diff --git a/pkg/ccl/schemachangerccl/testdata/explain/create_index.rollback_2_of_7 b/pkg/ccl/schemachangerccl/testdata/explain/create_index.rollback_2_of_7 index 86ad782a81bf..149019011c38 100644 --- a/pkg/ccl/schemachangerccl/testdata/explain/create_index.rollback_2_of_7 +++ b/pkg/ccl/schemachangerccl/testdata/explain/create_index.rollback_2_of_7 @@ -22,14 +22,8 @@ Schema change plan for rolling back CREATE INDEX ‹id1› ON ‹defaultdb›.pu │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} │ │ └── PUBLIC → ABSENT IndexPartitioning:{DescID: 104, IndexID: 3} - │ └── 12 Mutation operations + │ └── 6 Mutation operations │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"Ordinal":1,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":3,"Kind":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"Ordinal":1,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":2,"Kind":2,"TableID":104} │ ├── LogEvent {"TargetStatus":1} │ ├── CreateGcJobForIndex {"IndexID":2,"TableID":104} │ ├── MakeIndexAbsent {"IndexID":2,"TableID":104} diff --git a/pkg/ccl/schemachangerccl/testdata/explain/create_index.rollback_3_of_7 b/pkg/ccl/schemachangerccl/testdata/explain/create_index.rollback_3_of_7 index 48e264957c54..28284da5d68e 100644 --- a/pkg/ccl/schemachangerccl/testdata/explain/create_index.rollback_3_of_7 +++ b/pkg/ccl/schemachangerccl/testdata/explain/create_index.rollback_3_of_7 @@ -22,14 +22,8 @@ Schema change plan for rolling back CREATE INDEX ‹id1› ON ‹defaultdb›.pu │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} │ │ └── PUBLIC → ABSENT IndexPartitioning:{DescID: 104, IndexID: 3} - │ └── 12 Mutation operations + │ └── 6 Mutation operations │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"Ordinal":1,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":3,"Kind":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"Ordinal":1,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":2,"Kind":2,"TableID":104} │ ├── LogEvent {"TargetStatus":1} │ ├── CreateGcJobForIndex {"IndexID":2,"TableID":104} │ ├── MakeIndexAbsent {"IndexID":2,"TableID":104} diff --git a/pkg/ccl/schemachangerccl/testdata/explain/create_index.rollback_4_of_7 b/pkg/ccl/schemachangerccl/testdata/explain/create_index.rollback_4_of_7 index 25ebc6bdab6f..309808a4d3e1 100644 --- a/pkg/ccl/schemachangerccl/testdata/explain/create_index.rollback_4_of_7 +++ b/pkg/ccl/schemachangerccl/testdata/explain/create_index.rollback_4_of_7 @@ -22,14 +22,8 @@ Schema change plan for rolling back CREATE INDEX ‹id1› ON ‹defaultdb›.pu │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} │ │ └── PUBLIC → ABSENT IndexPartitioning:{DescID: 104, IndexID: 3} - │ └── 12 Mutation operations - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"Ordinal":1,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":2,"Kind":2,"TableID":104} + │ └── 6 Mutation operations │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"Ordinal":1,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":3,"Kind":2,"TableID":104} │ ├── LogEvent {"TargetStatus":1} │ ├── CreateGcJobForIndex {"IndexID":2,"TableID":104} │ ├── MakeIndexAbsent {"IndexID":2,"TableID":104} diff --git a/pkg/ccl/schemachangerccl/testdata/explain/create_index.rollback_5_of_7 b/pkg/ccl/schemachangerccl/testdata/explain/create_index.rollback_5_of_7 index 2c1b78455a76..28221e63ee10 100644 --- a/pkg/ccl/schemachangerccl/testdata/explain/create_index.rollback_5_of_7 +++ b/pkg/ccl/schemachangerccl/testdata/explain/create_index.rollback_5_of_7 @@ -22,15 +22,9 @@ Schema change plan for rolling back CREATE INDEX ‹id1› ON ‹defaultdb›.pu │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} │ │ └── PUBLIC → ABSENT IndexPartitioning:{DescID: 104, IndexID: 3} - │ └── 10 Mutation operations + │ └── 4 Mutation operations │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"Ordinal":1,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":3,"Kind":2,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"Ordinal":1,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":2,"Kind":2,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} └── Stage 2 of 2 in PostCommitNonRevertiblePhase diff --git a/pkg/ccl/schemachangerccl/testdata/explain/create_index.rollback_6_of_7 b/pkg/ccl/schemachangerccl/testdata/explain/create_index.rollback_6_of_7 index 02db20c03d68..d7cbc34c509e 100644 --- a/pkg/ccl/schemachangerccl/testdata/explain/create_index.rollback_6_of_7 +++ b/pkg/ccl/schemachangerccl/testdata/explain/create_index.rollback_6_of_7 @@ -22,15 +22,9 @@ Schema change plan for rolling back CREATE INDEX ‹id1› ON ‹defaultdb›.pu │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} │ │ └── PUBLIC → ABSENT IndexPartitioning:{DescID: 104, IndexID: 3} - │ └── 10 Mutation operations + │ └── 4 Mutation operations │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"Ordinal":1,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":3,"Kind":2,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"Ordinal":1,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":2,"Kind":2,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} └── Stage 2 of 2 in PostCommitNonRevertiblePhase diff --git a/pkg/ccl/schemachangerccl/testdata/explain/create_index.rollback_7_of_7 b/pkg/ccl/schemachangerccl/testdata/explain/create_index.rollback_7_of_7 index 22a1f729f673..cbf8450f56a7 100644 --- a/pkg/ccl/schemachangerccl/testdata/explain/create_index.rollback_7_of_7 +++ b/pkg/ccl/schemachangerccl/testdata/explain/create_index.rollback_7_of_7 @@ -22,15 +22,9 @@ Schema change plan for rolling back CREATE INDEX ‹id1› ON ‹defaultdb›.pu │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} │ │ └── PUBLIC → ABSENT IndexPartitioning:{DescID: 104, IndexID: 3} - │ └── 10 Mutation operations + │ └── 4 Mutation operations │ ├── MakeDroppedIndexDeleteOnly {"IndexID":2,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"Ordinal":1,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":3,"Kind":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"Ordinal":1,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":2,"Kind":2,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} └── Stage 2 of 2 in PostCommitNonRevertiblePhase diff --git a/pkg/ccl/schemachangerccl/testdata/explain_verbose/create_index b/pkg/ccl/schemachangerccl/testdata/explain_verbose/create_index index 6783764029dd..701a66548ac8 100644 --- a/pkg/ccl/schemachangerccl/testdata/explain_verbose/create_index +++ b/pkg/ccl/schemachangerccl/testdata/explain_verbose/create_index @@ -19,52 +19,52 @@ EXPLAIN (ddl, verbose) CREATE INDEX id1 │ │ │ │ ABSENT → PUBLIC │ │ │ │ │ │ │ └── • Precedence dependency from BACKFILL_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} -│ │ │ rule: "index-column added to index after index exists" +│ │ │ rule: "index existence precedes index dependents" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} │ │ │ │ ABSENT → PUBLIC │ │ │ │ │ │ │ └── • Precedence dependency from BACKFILL_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} -│ │ │ rule: "index-column added to index after index exists" +│ │ │ rule: "index existence precedes index dependents" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} │ │ │ │ ABSENT → PUBLIC │ │ │ │ │ │ │ └── • Precedence dependency from BACKFILL_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} -│ │ │ rule: "index-column added to index after index exists" +│ │ │ rule: "index existence precedes index dependents" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ ABSENT → BACKFILL_ONLY │ │ │ │ │ ├── • IndexPartitioning:{DescID: 104, IndexID: 2} -│ │ │ ABSENT → PUBLIC +│ │ │ │ ABSENT → PUBLIC +│ │ │ │ +│ │ │ └── • Precedence dependency from BACKFILL_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ rule: "index existence precedes index dependents" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ │ │ ABSENT → PUBLIC │ │ │ │ │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 0, SourceIndexID: 1} -│ │ │ rule: "temp index exists before columns, partitioning, and partial" -│ │ │ rule: "index-column added to index after temp index exists" +│ │ │ rule: "temp index existence precedes index dependents" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} │ │ │ │ ABSENT → PUBLIC │ │ │ │ │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 0, SourceIndexID: 1} -│ │ │ rule: "temp index exists before columns, partitioning, and partial" -│ │ │ rule: "index-column added to index after temp index exists" +│ │ │ rule: "temp index existence precedes index dependents" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} │ │ │ │ ABSENT → PUBLIC │ │ │ │ │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 0, SourceIndexID: 1} -│ │ │ rule: "temp index exists before columns, partitioning, and partial" -│ │ │ rule: "index-column added to index after temp index exists" +│ │ │ rule: "temp index existence precedes index dependents" │ │ │ │ │ └── • IndexPartitioning:{DescID: 104, IndexID: 3} │ │ │ ABSENT → PUBLIC │ │ │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 0, SourceIndexID: 1} -│ │ rule: "temp index exists before columns, partitioning, and partial" +│ │ rule: "temp index existence precedes index dependents" │ │ │ ├── • 1 element transitioning toward TRANSIENT_ABSENT │ │ │ @@ -187,16 +187,7 @@ EXPLAIN (ddl, verbose) CREATE INDEX id1 │ │ ├── • 1 element transitioning toward TRANSIENT_ABSENT │ │ │ │ │ │ │ └── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 0, SourceIndexID: 1} -│ │ │ │ DELETE_ONLY → WRITE_ONLY -│ │ │ │ -│ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} -│ │ │ │ rule: "index-column added to index before temp index receives writes" -│ │ │ │ -│ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} -│ │ │ │ rule: "index-column added to index before temp index receives writes" -│ │ │ │ -│ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} -│ │ │ rule: "index-column added to index before temp index receives writes" +│ │ │ DELETE_ONLY → WRITE_ONLY │ │ │ │ │ └── • 3 Mutation operations │ │ │ @@ -333,14 +324,27 @@ EXPLAIN (ddl, verbose) CREATE INDEX id1 │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: id1, IndexID: 2} - │ │ │ rule: "index named right before index becomes public" + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: id1, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ rule: "index named right before index becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexPartitioning:{DescID: 104, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ │ │ └── • IndexName:{DescID: 104, Name: id1, IndexID: 2} │ │ │ ABSENT → PUBLIC │ │ │ │ │ └── • Precedence dependency from BACKFILL_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ rule: "index existence precedes index name and comment" + │ │ rule: "index existence precedes index dependents" │ │ │ ├── • 1 element transitioning toward TRANSIENT_ABSENT │ │ │ diff --git a/pkg/ccl/schemachangerccl/testdata/explain_verbose/create_index.rollback_1_of_7 b/pkg/ccl/schemachangerccl/testdata/explain_verbose/create_index.rollback_1_of_7 index e88db0a0ba87..2844e535fb07 100644 --- a/pkg/ccl/schemachangerccl/testdata/explain_verbose/create_index.rollback_1_of_7 +++ b/pkg/ccl/schemachangerccl/testdata/explain_verbose/create_index.rollback_1_of_7 @@ -19,34 +19,31 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 7; │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ │ PUBLIC → ABSENT │ │ │ - │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} │ │ │ PUBLIC → ABSENT │ │ │ - │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} │ │ │ PUBLIC → ABSENT │ │ │ - │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ BACKFILL_ONLY → ABSENT │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} - │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ rule: "dependents removed before index" │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} - │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ rule: "dependents removed before index" │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} - │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ rule: "dependents removed before index" │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: id1, IndexID: 2} @@ -74,52 +71,27 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 7; │ │ rule: "dependents removed before index" │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ └── • IndexPartitioning:{DescID: 104, IndexID: 3} │ PUBLIC → ABSENT │ - └── • 13 Mutation operations - │ - ├── • RemoveColumnFromIndex - │ ColumnID: 1 - │ IndexID: 3 - │ TableID: 104 - │ - ├── • RemoveColumnFromIndex - │ ColumnID: 2 - │ IndexID: 3 - │ Ordinal: 1 - │ TableID: 104 - │ - ├── • RemoveColumnFromIndex - │ ColumnID: 3 - │ IndexID: 3 - │ Kind: 2 - │ TableID: 104 - │ - ├── • RemoveColumnFromIndex - │ ColumnID: 1 - │ IndexID: 2 - │ TableID: 104 - │ - ├── • RemoveColumnFromIndex - │ ColumnID: 2 - │ IndexID: 2 - │ Ordinal: 1 - │ TableID: 104 - │ - ├── • RemoveColumnFromIndex - │ ColumnID: 3 - │ IndexID: 2 - │ Kind: 2 - │ TableID: 104 + └── • 7 Mutation operations │ ├── • LogEvent │ Element: diff --git a/pkg/ccl/schemachangerccl/testdata/explain_verbose/create_index.rollback_2_of_7 b/pkg/ccl/schemachangerccl/testdata/explain_verbose/create_index.rollback_2_of_7 index f4936990fb13..bf1e5f398cbf 100644 --- a/pkg/ccl/schemachangerccl/testdata/explain_verbose/create_index.rollback_2_of_7 +++ b/pkg/ccl/schemachangerccl/testdata/explain_verbose/create_index.rollback_2_of_7 @@ -19,34 +19,31 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 2 of 7; │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ │ BACKFILL_ONLY → ABSENT │ │ │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} - │ │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ │ rule: "dependents removed before index" │ │ │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} - │ │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ │ rule: "dependents removed before index" │ │ │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} - │ │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ │ rule: "dependents removed before index" │ │ │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: id1, IndexID: 2} @@ -62,57 +59,32 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 2 of 7; │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexPartitioning:{DescID: 104, IndexID: 3} │ │ PUBLIC → ABSENT │ │ - │ └── • 12 Mutation operations + │ └── • 6 Mutation operations │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 3 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 3 - │ │ Ordinal: 1 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 3 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 2 - │ │ Ordinal: 1 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 2 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ │ ├── • LogEvent │ │ Element: │ │ SecondaryIndex: diff --git a/pkg/ccl/schemachangerccl/testdata/explain_verbose/create_index.rollback_3_of_7 b/pkg/ccl/schemachangerccl/testdata/explain_verbose/create_index.rollback_3_of_7 index 8196b16a1fcb..acd0d09c0a35 100644 --- a/pkg/ccl/schemachangerccl/testdata/explain_verbose/create_index.rollback_3_of_7 +++ b/pkg/ccl/schemachangerccl/testdata/explain_verbose/create_index.rollback_3_of_7 @@ -19,34 +19,31 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 3 of 7; │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ │ BACKFILL_ONLY → ABSENT │ │ │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} - │ │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ │ rule: "dependents removed before index" │ │ │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} - │ │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ │ rule: "dependents removed before index" │ │ │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} - │ │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ │ rule: "dependents removed before index" │ │ │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: id1, IndexID: 2} @@ -62,57 +59,32 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 3 of 7; │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexPartitioning:{DescID: 104, IndexID: 3} │ │ PUBLIC → ABSENT │ │ - │ └── • 12 Mutation operations + │ └── • 6 Mutation operations │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 3 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 3 - │ │ Ordinal: 1 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 3 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 2 - │ │ Ordinal: 1 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 2 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ │ ├── • LogEvent │ │ Element: │ │ SecondaryIndex: diff --git a/pkg/ccl/schemachangerccl/testdata/explain_verbose/create_index.rollback_4_of_7 b/pkg/ccl/schemachangerccl/testdata/explain_verbose/create_index.rollback_4_of_7 index 2d994bb7bcbc..b603debb4505 100644 --- a/pkg/ccl/schemachangerccl/testdata/explain_verbose/create_index.rollback_4_of_7 +++ b/pkg/ccl/schemachangerccl/testdata/explain_verbose/create_index.rollback_4_of_7 @@ -19,34 +19,31 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 7; │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ │ DELETE_ONLY → ABSENT │ │ │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} - │ │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ │ rule: "dependents removed before index" │ │ │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} - │ │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ │ rule: "dependents removed before index" │ │ │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} - │ │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ │ rule: "dependents removed before index" │ │ │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: id1, IndexID: 2} @@ -62,57 +59,32 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 7; │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexPartitioning:{DescID: 104, IndexID: 3} │ │ PUBLIC → ABSENT │ │ - │ └── • 12 Mutation operations - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 2 - │ │ Ordinal: 1 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 2 - │ │ Kind: 2 - │ │ TableID: 104 + │ └── • 6 Mutation operations │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 3 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 3 - │ │ Ordinal: 1 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 3 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ │ ├── • LogEvent │ │ Element: │ │ SecondaryIndex: diff --git a/pkg/ccl/schemachangerccl/testdata/explain_verbose/create_index.rollback_5_of_7 b/pkg/ccl/schemachangerccl/testdata/explain_verbose/create_index.rollback_5_of_7 index fc6d120adda0..09293f3f4d99 100644 --- a/pkg/ccl/schemachangerccl/testdata/explain_verbose/create_index.rollback_5_of_7 +++ b/pkg/ccl/schemachangerccl/testdata/explain_verbose/create_index.rollback_5_of_7 @@ -19,20 +19,20 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 7; │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ MERGE_ONLY → DELETE_ONLY @@ -44,61 +44,36 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 7; │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexPartitioning:{DescID: 104, IndexID: 3} │ │ PUBLIC → ABSENT │ │ - │ └── • 10 Mutation operations + │ └── • 4 Mutation operations │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 3 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 3 - │ │ Ordinal: 1 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 3 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 2 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 2 - │ │ Ordinal: 1 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 2 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 104 │ │ @@ -115,15 +90,12 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 7; │ │ │ DELETE_ONLY → ABSENT │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} - │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ rule: "dependents removed before index" │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} - │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ rule: "dependents removed before index" │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} - │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ rule: "dependents removed before index" │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: id1, IndexID: 2} diff --git a/pkg/ccl/schemachangerccl/testdata/explain_verbose/create_index.rollback_6_of_7 b/pkg/ccl/schemachangerccl/testdata/explain_verbose/create_index.rollback_6_of_7 index 7f7a7b39a201..36888496a5ee 100644 --- a/pkg/ccl/schemachangerccl/testdata/explain_verbose/create_index.rollback_6_of_7 +++ b/pkg/ccl/schemachangerccl/testdata/explain_verbose/create_index.rollback_6_of_7 @@ -19,20 +19,20 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 7; │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ MERGE_ONLY → DELETE_ONLY @@ -44,61 +44,36 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 7; │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexPartitioning:{DescID: 104, IndexID: 3} │ │ PUBLIC → ABSENT │ │ - │ └── • 10 Mutation operations + │ └── • 4 Mutation operations │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 3 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 3 - │ │ Ordinal: 1 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 3 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 2 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 2 - │ │ Ordinal: 1 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 2 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 104 │ │ @@ -115,15 +90,12 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 7; │ │ │ DELETE_ONLY → ABSENT │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} - │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ rule: "dependents removed before index" │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} - │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ rule: "dependents removed before index" │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} - │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ rule: "dependents removed before index" │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: id1, IndexID: 2} diff --git a/pkg/ccl/schemachangerccl/testdata/explain_verbose/create_index.rollback_7_of_7 b/pkg/ccl/schemachangerccl/testdata/explain_verbose/create_index.rollback_7_of_7 index 0f82d4544241..b9b58944e79c 100644 --- a/pkg/ccl/schemachangerccl/testdata/explain_verbose/create_index.rollback_7_of_7 +++ b/pkg/ccl/schemachangerccl/testdata/explain_verbose/create_index.rollback_7_of_7 @@ -19,20 +19,20 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY @@ -44,18 +44,27 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexPartitioning:{DescID: 104, IndexID: 3} │ │ PUBLIC → ABSENT │ │ - │ └── • 10 Mutation operations + │ └── • 4 Mutation operations │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 2 @@ -65,40 +74,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ │ IndexID: 3 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 3 - │ │ Ordinal: 1 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 3 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 2 - │ │ Ordinal: 1 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 2 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 104 │ │ @@ -115,15 +90,12 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ │ │ DELETE_ONLY → ABSENT │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} - │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ rule: "dependents removed before index" │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} - │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ rule: "dependents removed before index" │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} - │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ rule: "dependents removed before index" │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: id1, IndexID: 2} diff --git a/pkg/ccl/schemachangerccl/testdata/explain_verbose/drop_database_multiregion_primary_region b/pkg/ccl/schemachangerccl/testdata/explain_verbose/drop_database_multiregion_primary_region index 47680cec306c..53bfdcd28f21 100644 --- a/pkg/ccl/schemachangerccl/testdata/explain_verbose/drop_database_multiregion_primary_region +++ b/pkg/ccl/schemachangerccl/testdata/explain_verbose/drop_database_multiregion_primary_region @@ -463,7 +463,7 @@ EXPLAIN (ddl, verbose) DROP DATABASE multi_region_test_db CASCADE; │ │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 108, ColumnID: 1} - │ │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ │ │ └── • skip PUBLIC → ABSENT operations │ │ │ rule: "skip column dependents removal ops on relation drop" @@ -475,7 +475,7 @@ EXPLAIN (ddl, verbose) DROP DATABASE multi_region_test_db CASCADE; │ │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 108, ColumnID: 1} - │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ ├── • Column:{DescID: 108, ColumnID: 4294967295} │ │ │ │ WRITE_ONLY → DELETE_ONLY @@ -490,7 +490,7 @@ EXPLAIN (ddl, verbose) DROP DATABASE multi_region_test_db CASCADE; │ │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 108, ColumnID: 4294967295} - │ │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ │ │ └── • skip PUBLIC → ABSENT operations │ │ │ rule: "skip column dependents removal ops on relation drop" @@ -502,7 +502,7 @@ EXPLAIN (ddl, verbose) DROP DATABASE multi_region_test_db CASCADE; │ │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 108, ColumnID: 4294967295} - │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ ├── • Column:{DescID: 108, ColumnID: 4294967294} │ │ │ │ WRITE_ONLY → DELETE_ONLY @@ -517,7 +517,7 @@ EXPLAIN (ddl, verbose) DROP DATABASE multi_region_test_db CASCADE; │ │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 108, ColumnID: 4294967294} - │ │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ │ │ └── • skip PUBLIC → ABSENT operations │ │ │ rule: "skip column dependents removal ops on relation drop" @@ -529,7 +529,7 @@ EXPLAIN (ddl, verbose) DROP DATABASE multi_region_test_db CASCADE; │ │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 108, ColumnID: 4294967294} - │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ ├── • IndexColumn:{DescID: 108, ColumnID: 1, IndexID: 1} │ │ │ │ PUBLIC → ABSENT @@ -537,11 +537,15 @@ EXPLAIN (ddl, verbose) DROP DATABASE multi_region_test_db CASCADE; │ │ │ ├── • SameStagePrecedence dependency from DROPPED Table:{DescID: 108} │ │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 108, ColumnID: 1} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 108, IndexID: 1, ConstraintID: 1} - │ │ │ │ rule: "index no longer public before dependents removed" + │ │ │ │ rule: "index no longer public before dependents" │ │ │ │ │ │ │ └── • skip PUBLIC → ABSENT operations │ │ │ rule: "skip index dependents removal ops on relation drop" + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 108, IndexID: 1, ConstraintID: 1} │ │ │ │ VALIDATED → DELETE_ONLY @@ -559,7 +563,7 @@ EXPLAIN (ddl, verbose) DROP DATABASE multi_region_test_db CASCADE; │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 108, IndexID: 1, ConstraintID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ rule: "index no longer public before dependents" │ │ │ │ │ └── • skip PUBLIC → ABSENT operations │ │ rule: "skip index dependents removal ops on relation drop" @@ -678,7 +682,10 @@ EXPLAIN (ddl, verbose) DROP DATABASE multi_region_test_db CASCADE; │ │ ├── • Precedence dependency from ABSENT ColumnName:{DescID: 108, Name: a, ColumnID: 1} │ │ │ rule: "dependents removed before column" │ │ │ - │ │ └── • Precedence dependency from ABSENT ColumnType:{DescID: 108, ColumnFamilyID: 0, ColumnID: 1} + │ │ ├── • Precedence dependency from ABSENT ColumnType:{DescID: 108, ColumnFamilyID: 0, ColumnID: 1} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 108, ColumnID: 1, IndexID: 1} │ │ rule: "dependents removed before column" │ │ │ ├── • Column:{DescID: 108, ColumnID: 4294967295} diff --git a/pkg/ccl/schemachangerccl/testdata/explain_verbose/drop_table_multiregion b/pkg/ccl/schemachangerccl/testdata/explain_verbose/drop_table_multiregion index 90d1c77bbe08..bb3167762916 100644 --- a/pkg/ccl/schemachangerccl/testdata/explain_verbose/drop_table_multiregion +++ b/pkg/ccl/schemachangerccl/testdata/explain_verbose/drop_table_multiregion @@ -163,7 +163,7 @@ EXPLAIN (ddl, verbose) DROP TABLE multi_region_test_db.public.table_regional_by_ │ │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 108, ColumnID: 1} - │ │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ │ │ └── • skip PUBLIC → ABSENT operations │ │ │ rule: "skip column dependents removal ops on relation drop" @@ -175,7 +175,7 @@ EXPLAIN (ddl, verbose) DROP TABLE multi_region_test_db.public.table_regional_by_ │ │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 108, ColumnID: 1} - │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ ├── • Column:{DescID: 108, ColumnID: 2} │ │ │ │ WRITE_ONLY → DELETE_ONLY @@ -190,7 +190,7 @@ EXPLAIN (ddl, verbose) DROP TABLE multi_region_test_db.public.table_regional_by_ │ │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 108, ColumnID: 2} - │ │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ │ │ └── • skip PUBLIC → ABSENT operations │ │ │ rule: "skip column dependents removal ops on relation drop" @@ -202,7 +202,7 @@ EXPLAIN (ddl, verbose) DROP TABLE multi_region_test_db.public.table_regional_by_ │ │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 108, ColumnID: 2} - │ │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from ABSENT ColumnDefaultExpression:{DescID: 108, ColumnID: 2} │ │ │ rule: "column type dependents removed right before column type" @@ -210,8 +210,11 @@ EXPLAIN (ddl, verbose) DROP TABLE multi_region_test_db.public.table_regional_by_ │ │ ├── • ColumnDefaultExpression:{DescID: 108, ColumnID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from DROPPED Table:{DescID: 108} - │ │ │ rule: "descriptor drop right before dependent element removal" + │ │ │ ├── • SameStagePrecedence dependency from DROPPED Table:{DescID: 108} + │ │ │ │ rule: "descriptor drop right before dependent element removal" + │ │ │ │ + │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 108, ColumnID: 2} + │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ ├── • Column:{DescID: 108, ColumnID: 4294967295} │ │ │ │ WRITE_ONLY → DELETE_ONLY @@ -226,7 +229,7 @@ EXPLAIN (ddl, verbose) DROP TABLE multi_region_test_db.public.table_regional_by_ │ │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 108, ColumnID: 4294967295} - │ │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ │ │ └── • skip PUBLIC → ABSENT operations │ │ │ rule: "skip column dependents removal ops on relation drop" @@ -238,7 +241,7 @@ EXPLAIN (ddl, verbose) DROP TABLE multi_region_test_db.public.table_regional_by_ │ │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 108, ColumnID: 4294967295} - │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ ├── • Column:{DescID: 108, ColumnID: 4294967294} │ │ │ │ WRITE_ONLY → DELETE_ONLY @@ -253,7 +256,7 @@ EXPLAIN (ddl, verbose) DROP TABLE multi_region_test_db.public.table_regional_by_ │ │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 108, ColumnID: 4294967294} - │ │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ │ │ └── • skip PUBLIC → ABSENT operations │ │ │ rule: "skip column dependents removal ops on relation drop" @@ -265,7 +268,7 @@ EXPLAIN (ddl, verbose) DROP TABLE multi_region_test_db.public.table_regional_by_ │ │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 108, ColumnID: 4294967294} - │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ ├── • IndexColumn:{DescID: 108, ColumnID: 2, IndexID: 1} │ │ │ │ PUBLIC → ABSENT @@ -273,11 +276,15 @@ EXPLAIN (ddl, verbose) DROP TABLE multi_region_test_db.public.table_regional_by_ │ │ │ ├── • SameStagePrecedence dependency from DROPPED Table:{DescID: 108} │ │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 108, ColumnID: 2} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 108, IndexID: 1, ConstraintID: 1} - │ │ │ │ rule: "index no longer public before dependents removed" + │ │ │ │ rule: "index no longer public before dependents" │ │ │ │ │ │ │ └── • skip PUBLIC → ABSENT operations │ │ │ rule: "skip index dependents removal ops on relation drop" + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 108, ColumnID: 1, IndexID: 1} │ │ │ │ PUBLIC → ABSENT @@ -285,11 +292,15 @@ EXPLAIN (ddl, verbose) DROP TABLE multi_region_test_db.public.table_regional_by_ │ │ │ ├── • SameStagePrecedence dependency from DROPPED Table:{DescID: 108} │ │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 108, ColumnID: 1} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 108, IndexID: 1, ConstraintID: 1} - │ │ │ │ rule: "index no longer public before dependents removed" + │ │ │ │ rule: "index no longer public before dependents" │ │ │ │ │ │ │ └── • skip PUBLIC → ABSENT operations │ │ │ rule: "skip index dependents removal ops on relation drop" + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 108, IndexID: 1, ConstraintID: 1} │ │ │ │ VALIDATED → DELETE_ONLY @@ -307,7 +318,7 @@ EXPLAIN (ddl, verbose) DROP TABLE multi_region_test_db.public.table_regional_by_ │ │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 108, IndexID: 1, ConstraintID: 1} - │ │ │ │ rule: "index no longer public before dependents removed" + │ │ │ │ rule: "index no longer public before dependents" │ │ │ │ │ │ │ └── • skip PUBLIC → ABSENT operations │ │ │ rule: "skip index dependents removal ops on relation drop" @@ -319,7 +330,7 @@ EXPLAIN (ddl, verbose) DROP TABLE multi_region_test_db.public.table_regional_by_ │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 108, IndexID: 1, ConstraintID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ rule: "index no longer public before dependents" │ │ │ │ │ └── • skip PUBLIC → ABSENT operations │ │ rule: "skip index dependents removal ops on relation drop" @@ -389,7 +400,10 @@ EXPLAIN (ddl, verbose) DROP TABLE multi_region_test_db.public.table_regional_by_ │ │ ├── • Precedence dependency from ABSENT ColumnName:{DescID: 108, Name: k, ColumnID: 1} │ │ │ rule: "dependents removed before column" │ │ │ - │ │ └── • Precedence dependency from ABSENT ColumnType:{DescID: 108, ColumnFamilyID: 0, ColumnID: 1} + │ │ ├── • Precedence dependency from ABSENT ColumnType:{DescID: 108, ColumnFamilyID: 0, ColumnID: 1} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 108, ColumnID: 1, IndexID: 1} │ │ rule: "dependents removed before column" │ │ │ ├── • Column:{DescID: 108, ColumnID: 2} @@ -401,7 +415,13 @@ EXPLAIN (ddl, verbose) DROP TABLE multi_region_test_db.public.table_regional_by_ │ │ ├── • Precedence dependency from ABSENT ColumnName:{DescID: 108, Name: crdb_region, ColumnID: 2} │ │ │ rule: "dependents removed before column" │ │ │ - │ │ └── • Precedence dependency from ABSENT ColumnType:{DescID: 108, ColumnFamilyID: 0, ColumnID: 2} + │ │ ├── • Precedence dependency from ABSENT ColumnType:{DescID: 108, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT ColumnDefaultExpression:{DescID: 108, ColumnID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 108, ColumnID: 2, IndexID: 1} │ │ rule: "dependents removed before column" │ │ │ ├── • Column:{DescID: 108, ColumnID: 4294967295} diff --git a/pkg/ccl/schemachangerccl/testdata/explain_verbose/drop_table_multiregion_primary_region b/pkg/ccl/schemachangerccl/testdata/explain_verbose/drop_table_multiregion_primary_region index fcb16bde64d8..b4fb0300d297 100644 --- a/pkg/ccl/schemachangerccl/testdata/explain_verbose/drop_table_multiregion_primary_region +++ b/pkg/ccl/schemachangerccl/testdata/explain_verbose/drop_table_multiregion_primary_region @@ -153,7 +153,7 @@ EXPLAIN (ddl, verbose) DROP TABLE multi_region_test_db.public.table_regional_by_ │ │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 108, ColumnID: 1} - │ │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ │ │ └── • skip PUBLIC → ABSENT operations │ │ │ rule: "skip column dependents removal ops on relation drop" @@ -165,7 +165,7 @@ EXPLAIN (ddl, verbose) DROP TABLE multi_region_test_db.public.table_regional_by_ │ │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 108, ColumnID: 1} - │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ ├── • Column:{DescID: 108, ColumnID: 4294967295} │ │ │ │ WRITE_ONLY → DELETE_ONLY @@ -180,7 +180,7 @@ EXPLAIN (ddl, verbose) DROP TABLE multi_region_test_db.public.table_regional_by_ │ │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 108, ColumnID: 4294967295} - │ │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ │ │ └── • skip PUBLIC → ABSENT operations │ │ │ rule: "skip column dependents removal ops on relation drop" @@ -192,7 +192,7 @@ EXPLAIN (ddl, verbose) DROP TABLE multi_region_test_db.public.table_regional_by_ │ │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 108, ColumnID: 4294967295} - │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ ├── • Column:{DescID: 108, ColumnID: 4294967294} │ │ │ │ WRITE_ONLY → DELETE_ONLY @@ -207,7 +207,7 @@ EXPLAIN (ddl, verbose) DROP TABLE multi_region_test_db.public.table_regional_by_ │ │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 108, ColumnID: 4294967294} - │ │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ │ │ └── • skip PUBLIC → ABSENT operations │ │ │ rule: "skip column dependents removal ops on relation drop" @@ -219,7 +219,7 @@ EXPLAIN (ddl, verbose) DROP TABLE multi_region_test_db.public.table_regional_by_ │ │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 108, ColumnID: 4294967294} - │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ ├── • IndexColumn:{DescID: 108, ColumnID: 1, IndexID: 1} │ │ │ │ PUBLIC → ABSENT @@ -227,11 +227,15 @@ EXPLAIN (ddl, verbose) DROP TABLE multi_region_test_db.public.table_regional_by_ │ │ │ ├── • SameStagePrecedence dependency from DROPPED Table:{DescID: 108} │ │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 108, ColumnID: 1} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 108, IndexID: 1, ConstraintID: 1} - │ │ │ │ rule: "index no longer public before dependents removed" + │ │ │ │ rule: "index no longer public before dependents" │ │ │ │ │ │ │ └── • skip PUBLIC → ABSENT operations │ │ │ rule: "skip index dependents removal ops on relation drop" + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 108, IndexID: 1, ConstraintID: 1} │ │ │ │ VALIDATED → DELETE_ONLY @@ -249,7 +253,7 @@ EXPLAIN (ddl, verbose) DROP TABLE multi_region_test_db.public.table_regional_by_ │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 108, IndexID: 1, ConstraintID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ rule: "index no longer public before dependents" │ │ │ │ │ └── • skip PUBLIC → ABSENT operations │ │ rule: "skip index dependents removal ops on relation drop" @@ -301,7 +305,10 @@ EXPLAIN (ddl, verbose) DROP TABLE multi_region_test_db.public.table_regional_by_ │ │ ├── • Precedence dependency from ABSENT ColumnName:{DescID: 108, Name: a, ColumnID: 1} │ │ │ rule: "dependents removed before column" │ │ │ - │ │ └── • Precedence dependency from ABSENT ColumnType:{DescID: 108, ColumnFamilyID: 0, ColumnID: 1} + │ │ ├── • Precedence dependency from ABSENT ColumnType:{DescID: 108, ColumnFamilyID: 0, ColumnID: 1} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 108, ColumnID: 1, IndexID: 1} │ │ rule: "dependents removed before column" │ │ │ ├── • Column:{DescID: 108, ColumnID: 4294967295} diff --git a/pkg/sql/backfill/index_backfiller_cols.go b/pkg/sql/backfill/index_backfiller_cols.go index 4f31d3ae38fa..5308d21866b6 100644 --- a/pkg/sql/backfill/index_backfiller_cols.go +++ b/pkg/sql/backfill/index_backfiller_cols.go @@ -71,10 +71,24 @@ func makeIndexBackfillColumns( var ib indexBackfillerCols ib.cols = make([]catalog.Column, 0, len(deletableColumns)) - var computedVirtual catalog.TableColSet + var computedVirtual, allIndexColumns catalog.TableColSet + primaryColumns := indexColumns(sourcePrimaryIndex) + for _, idx := range addedIndexes { + allIndexColumns.UnionWith(indexColumns(idx)) + } for _, column := range deletableColumns { if !column.Public() && - !(column.Adding() && column.WriteAndDeleteOnly()) { + // Include columns we are adding, in case we are adding them to a + // new primary index as part of an ADD COLUMN backfill. Later code + // will validate that we're allowed to be adding this column to the + // new index. + !(column.Adding() && column.WriteAndDeleteOnly()) && + // Include columns we're dropping if the column is already part of + // the current primary index and needs to be in the new index. Code + // elsewhere will enforce that the index we're building including this + // dropped column is allowed to include the dropped column. + !(column.Dropped() && primaryColumns.Contains(column.GetID()) && + allIndexColumns.Contains(column.GetID())) { continue } if column.IsComputed() && column.IsVirtual() { @@ -87,7 +101,6 @@ func makeIndexBackfillColumns( } // Find the adding columns which are being added to new primary indexes. - primaryColumns := indexColumns(sourcePrimaryIndex) var addedDefaultOrComputed catalog.TableColSet for _, idx := range addedIndexes { if idx.GetEncodingType() != descpb.PrimaryIndexEncoding { diff --git a/pkg/sql/backfill/index_backfiller_cols_test.go b/pkg/sql/backfill/index_backfiller_cols_test.go index 7cf3cf9b26e2..0aadef6ba7bf 100644 --- a/pkg/sql/backfill/index_backfiller_cols_test.go +++ b/pkg/sql/backfill/index_backfiller_cols_test.go @@ -186,15 +186,16 @@ func TestIndexBackfillerColumns(t *testing.T) { expNeeded: colIDs{1}, }, { - name: "dropped columns are excluded", + name: "dropped columns are excluded if not needed", cols: cols{ {id: 1, public: true}, {id: 2, writeAndDeleteOnly: true}, {id: 3, public: true, virtual: true, computed: true}, }, src: index{ - primary: true, - keyCols: colIDs{1, 3}, + primary: true, + keyCols: colIDs{2}, + primaryValueCols: colIDs{1, 3}, }, toEncode: indexes{ { @@ -206,6 +207,29 @@ func TestIndexBackfillerColumns(t *testing.T) { expComputed: colIDs{3}, expNeeded: colIDs{1}, }, + { + name: "dropped columns are included if needed", + cols: cols{ + {id: 1, public: true}, + {id: 2, writeAndDeleteOnly: true}, + {id: 3, public: true, virtual: true, computed: true}, + }, + src: index{ + primary: true, + keyCols: colIDs{2}, + primaryValueCols: colIDs{1, 3}, + }, + toEncode: indexes{ + { + primary: true, + keyCols: colIDs{1, 3}, + primaryValueCols: colIDs{2}, + }, + }, + expCols: colIDs{1, 2, 3}, + expComputed: colIDs{3}, + expNeeded: colIDs{1, 2}, + }, { // This is the case where we're building a new primary index as part // of an add column for a computed stored column. @@ -351,6 +375,7 @@ type fakeColumn struct { func (fc fakeColumn) Public() bool { return fc.public } func (fc fakeColumn) Adding() bool { return fc.adding } +func (fc fakeColumn) Dropped() bool { return fc.writeAndDeleteOnly } func (fc fakeColumn) WriteAndDeleteOnly() bool { return fc.writeAndDeleteOnly } func (fc fakeColumn) IsComputed() bool { return fc.computed } func (fc fakeColumn) IsVirtual() bool { return fc.virtual } diff --git a/pkg/sql/catalog/tabledesc/validate.go b/pkg/sql/catalog/tabledesc/validate.go index 5df795115fe0..aa50013a7ed9 100644 --- a/pkg/sql/catalog/tabledesc/validate.go +++ b/pkg/sql/catalog/tabledesc/validate.go @@ -13,7 +13,6 @@ package tabledesc import ( "sort" - "github.com/cockroachdb/cockroach/pkg/clusterversion" "github.com/cockroachdb/cockroach/pkg/keys" "github.com/cockroachdb/cockroach/pkg/roachpb" "github.com/cockroachdb/cockroach/pkg/settings" @@ -627,9 +626,7 @@ func (desc *wrapper) ValidateSelf(vea catalog.ValidationErrorAccumulator) { return } - columnNames := make(map[string]descpb.ColumnID, len(desc.Columns)) - columnIDs := make(map[descpb.ColumnID]*descpb.ColumnDescriptor, len(desc.Columns)) - if err := desc.validateColumns(columnNames, columnIDs); err != nil { + if err := desc.validateColumns(); err != nil { vea.Report(err) return } @@ -653,21 +650,25 @@ func (desc *wrapper) ValidateSelf(vea catalog.ValidationErrorAccumulator) { return } - mutationsHaveErrs := false - for _, m := range desc.Mutations { - if err := validateMutation(&m); err != nil { - vea.Report(err) - mutationsHaveErrs = true + // Validate mutations and exit early if any of these are deeply corrupted. + { + mutationsHaveErrs := false + for _, m := range desc.Mutations { + if err := validateMutation(&m); err != nil { + vea.Report(err) + mutationsHaveErrs = true + } } - switch desc := m.Descriptor_.(type) { - case *descpb.DescriptorMutation_Column: - col := desc.Column - columnIDs[col.ID] = col + if mutationsHaveErrs { + return } } - if mutationsHaveErrs { - return + // Build a mapping of column descriptors by ID. The columns have already been + // validated at this point, so we know that the mapping is 1-to-1. + columnsByID := make(map[descpb.ColumnID]catalog.Column, len(desc.Columns)) + for _, col := range desc.DeletableColumns() { + columnsByID[col.GetID()] = col } // TODO(dt): Validate each column only appears at-most-once in any FKs. @@ -676,10 +677,10 @@ func (desc *wrapper) ValidateSelf(vea catalog.ValidationErrorAccumulator) { // actually a table, not if it's just a view. if desc.IsPhysicalTable() { newErrs := []error{ - desc.validateColumnFamilies(columnIDs), - desc.validateCheckConstraints(columnIDs), - desc.validateUniqueWithoutIndexConstraints(columnIDs), - desc.validateTableIndexes(columnNames, vea), + desc.validateColumnFamilies(columnsByID), + desc.validateCheckConstraints(columnsByID), + desc.validateUniqueWithoutIndexConstraints(columnsByID), + desc.validateTableIndexes(columnsByID, vea), desc.validatePartitioning(), } hasErrs := false @@ -841,7 +842,7 @@ func (desc *wrapper) validateConstraintIDs(vea catalog.ValidationErrorAccumulato for _, name := range orderedNames { constraint := constraints[name] if constraint.ConstraintID == 0 { - vea.Report(errors.AssertionFailedf("constraint id was missing for constraint: %s with name %q", + vea.Report(errors.AssertionFailedf("constraint ID was missing for constraint: %s with name %q", constraint.Kind, name)) @@ -849,10 +850,10 @@ func (desc *wrapper) validateConstraintIDs(vea catalog.ValidationErrorAccumulato } } -func (desc *wrapper) validateColumns( - columnNames map[string]descpb.ColumnID, columnIDs map[descpb.ColumnID]*descpb.ColumnDescriptor, -) error { - for _, column := range desc.NonDropColumns() { +func (desc *wrapper) validateColumns() error { + columnIDs := make(map[descpb.ColumnID]*descpb.ColumnDescriptor, len(desc.Columns)) + columnNames := make(map[string]descpb.ColumnID, len(desc.Columns)) + for _, column := range desc.DeletableColumns() { if err := catalog.ValidateName(column.GetName(), "column"); err != nil { return err @@ -861,21 +862,10 @@ func (desc *wrapper) validateColumns( return errors.AssertionFailedf("invalid column ID %d", errors.Safe(column.GetID())) } - if _, columnNameExists := columnNames[column.GetName()]; columnNameExists { - for i := range desc.Columns { - if desc.Columns[i].Name == column.GetName() { - return pgerror.Newf(pgcode.DuplicateColumn, - "duplicate column name: %q", column.GetName()) - } - } - return pgerror.Newf(pgcode.DuplicateColumn, - "duplicate: column %q in the middle of being added, not yet public", column.GetName()) - } - if colinfo.IsSystemColumnName(column.GetName()) { - return pgerror.Newf(pgcode.DuplicateColumn, - "column name %q conflicts with a system column name", column.GetName()) + if column.GetID() >= desc.NextColumnID { + return errors.AssertionFailedf("column %q invalid ID (%d) >= next column ID (%d)", + column.GetName(), errors.Safe(column.GetID()), errors.Safe(desc.NextColumnID)) } - columnNames[column.GetName()] = column.GetID() if other, ok := columnIDs[column.GetID()]; ok { return errors.Newf("column %q duplicate ID of column %q: %d", @@ -883,11 +873,6 @@ func (desc *wrapper) validateColumns( } columnIDs[column.GetID()] = column.ColumnDesc() - if column.GetID() >= desc.NextColumnID { - return errors.AssertionFailedf("column %q invalid ID (%d) >= next column ID (%d)", - column.GetName(), errors.Safe(column.GetID()), errors.Safe(desc.NextColumnID)) - } - if column.IsComputed() { // Verify that the computed column expression is valid. expr, err := parser.ParseExpr(column.GetComputeExpr()) @@ -936,13 +921,32 @@ func (desc *wrapper) validateColumns( if column.HasOnUpdate() && column.IsGeneratedAsIdentity() { return errors.Newf("both generated identity and on update expression specified for column %q", column.GetName()) } + + // The following checks on names only apply to non-dropped columns. + if column.Dropped() { + continue + } + + if _, columnNameExists := columnNames[column.GetName()]; columnNameExists { + for i := range desc.Columns { + if desc.Columns[i].Name == column.GetName() { + return pgerror.Newf(pgcode.DuplicateColumn, + "duplicate column name: %q", column.GetName()) + } + } + return pgerror.Newf(pgcode.DuplicateColumn, + "duplicate: column %q in the middle of being added, not yet public", column.GetName()) + } + if colinfo.IsSystemColumnName(column.GetName()) { + return pgerror.Newf(pgcode.DuplicateColumn, + "column name %q conflicts with a system column name", column.GetName()) + } + columnNames[column.GetName()] = column.GetID() } return nil } -func (desc *wrapper) validateColumnFamilies( - columnIDs map[descpb.ColumnID]*descpb.ColumnDescriptor, -) error { +func (desc *wrapper) validateColumnFamilies(columnsByID map[descpb.ColumnID]catalog.Column) error { if len(desc.Families) < 1 { return errors.Newf("at least 1 column family must be specified") } @@ -990,16 +994,16 @@ func (desc *wrapper) validateColumnFamilies( } for i, colID := range family.ColumnIDs { - col, ok := columnIDs[colID] + col, ok := columnsByID[colID] if !ok { return errors.Newf("family %q contains unknown column \"%d\"", family.Name, colID) } - if col.Name != family.ColumnNames[i] { + if col.GetName() != family.ColumnNames[i] { return errors.Newf("family %q column %d should have name %q, but found name %q", - family.Name, colID, col.Name, family.ColumnNames[i]) + family.Name, colID, col.GetName(), family.ColumnNames[i]) } - if col.Virtual { - return errors.Newf("virtual computed column %q cannot be part of a family", col.Name) + if col.IsVirtual() { + return errors.Newf("virtual computed column %q cannot be part of a family", col.GetName()) } } @@ -1010,10 +1014,10 @@ func (desc *wrapper) validateColumnFamilies( colIDToFamilyID[colID] = family.ID } } - for colID, colDesc := range columnIDs { - if !colDesc.Virtual { + for colID, col := range columnsByID { + if !col.IsVirtual() { if _, ok := colIDToFamilyID[colID]; !ok { - return errors.Newf("column %q is not in any column family", colDesc.Name) + return errors.Newf("column %q is not in any column family", col.GetName()) } } } @@ -1024,12 +1028,12 @@ func (desc *wrapper) validateColumnFamilies( // Checks include validating the column IDs and verifying that check expressions // do not reference non-existent columns. func (desc *wrapper) validateCheckConstraints( - columnIDs map[descpb.ColumnID]*descpb.ColumnDescriptor, + columnsByID map[descpb.ColumnID]catalog.Column, ) error { for _, chk := range desc.AllActiveAndInactiveChecks() { // Verify that the check's column IDs are valid. for _, colID := range chk.ColumnIDs { - _, ok := columnIDs[colID] + _, ok := columnsByID[colID] if !ok { return errors.Newf("check constraint %q contains unknown column \"%d\"", chk.Name, colID) } @@ -1056,7 +1060,7 @@ func (desc *wrapper) validateCheckConstraints( // constraints are well formed. Checks include validating the column IDs and // column names. func (desc *wrapper) validateUniqueWithoutIndexConstraints( - columnIDs map[descpb.ColumnID]*descpb.ColumnDescriptor, + columnsByID map[descpb.ColumnID]catalog.Column, ) error { for _, c := range desc.AllActiveAndInactiveUniqueWithoutIndexConstraints() { if err := catalog.ValidateName(c.Name, "unique without index constraint"); err != nil { @@ -1074,7 +1078,7 @@ func (desc *wrapper) validateUniqueWithoutIndexConstraints( // Verify that the constraint's column IDs are valid and unique. var seen util.FastIntSet for _, colID := range c.ColumnIDs { - _, ok := columnIDs[colID] + _, ok := columnsByID[colID] if !ok { return errors.Newf( "unique without index constraint %q contains unknown column \"%d\"", c.Name, colID, @@ -1116,26 +1120,12 @@ func (desc *wrapper) validateUniqueWithoutIndexConstraints( // if indexes are unique (i.e. same set of columns, direction, and uniqueness) // as there are practical uses for them. func (desc *wrapper) validateTableIndexes( - columnNames map[string]descpb.ColumnID, vea catalog.ValidationErrorAccumulator, + columnsByID map[descpb.ColumnID]catalog.Column, vea catalog.ValidationErrorAccumulator, ) error { if len(desc.PrimaryIndex.KeyColumnIDs) == 0 { return ErrMissingPrimaryKey } - columnsByID := make(map[descpb.ColumnID]catalog.Column) - for _, col := range desc.DeletableColumns() { - columnsByID[col.GetID()] = col - } - - if !vea.IsActive(clusterversion.Start22_1) { - // Verify that the primary index columns are not virtual. - for _, pkID := range desc.PrimaryIndex.KeyColumnIDs { - if col := columnsByID[pkID]; col != nil && col.IsVirtual() { - return errors.Newf("primary index column %q cannot be virtual", col.GetName()) - } - } - } - indexNames := map[string]struct{}{} indexIDs := map[descpb.IndexID]string{} for _, idx := range desc.NonDropIndexes() { @@ -1198,18 +1188,20 @@ func (desc *wrapper) validateTableIndexes( } var validateIndexDup catalog.TableColSet - for i, name := range idx.IndexDesc().KeyColumnNames { - inIndexColID := idx.IndexDesc().KeyColumnIDs[i] - colID, ok := columnNames[name] - if !ok { - return errors.Newf("index %q contains unknown column %q", idx.GetName(), name) + for i, colID := range idx.IndexDesc().KeyColumnIDs { + inIndexColName := idx.IndexDesc().KeyColumnNames[i] + col, exists := columnsByID[colID] + if !exists { + return errors.Newf("index %q contains key column %q with unknown ID %d", idx.GetName(), inIndexColName, colID) + } + if col.GetName() != inIndexColName { + return errors.Newf("index %q key column ID %d should have name %q, but found name %q", + idx.GetName(), colID, col.ColName(), inIndexColName) } - if colID != inIndexColID { - return errors.Newf("index %q column %q should have ID %d, but found ID %d", - idx.GetName(), name, colID, inIndexColID) + if col.Dropped() && idx.GetEncodingType() != descpb.PrimaryIndexEncoding { + return errors.Newf("secondary index %q contains dropped key column %q", idx.GetName(), col.ColName()) } if validateIndexDup.Contains(colID) { - col, _ := desc.FindColumnWithID(colID) if col.IsExpressionIndexColumn() { return pgerror.Newf(pgcode.FeatureNotSupported, "index %q contains duplicate expression %q", @@ -1218,11 +1210,25 @@ func (desc *wrapper) validateTableIndexes( } return pgerror.Newf(pgcode.FeatureNotSupported, "index %q contains duplicate column %q", - idx.GetName(), name, + idx.GetName(), col.ColName(), ) } validateIndexDup.Add(colID) } + for _, colID := range idx.IndexDesc().KeySuffixColumnIDs { + col, exists := columnsByID[colID] + if !exists { + return errors.Newf("index %q key suffix column ID %d is invalid", + idx.GetName(), colID) + } + if idx.GetEncodingType() == descpb.PrimaryIndexEncoding { + return errors.Newf("primary-encoded index %q unexpectedly contains key suffix columns, for instance %q", + idx.GetName(), col.ColName()) + } + if col.Dropped() { + return errors.Newf("secondary index %q contains dropped key suffix column %q", idx.GetName(), col.ColName()) + } + } for i, colID := range idx.IndexDesc().StoreColumnIDs { inIndexColName := idx.IndexDesc().StoreColumnNames[i] col, exists := columnsByID[colID] @@ -1233,19 +1239,15 @@ func (desc *wrapper) validateTableIndexes( return errors.Newf("index %q stored column ID %d should have name %q, but found name %q", idx.GetName(), colID, col.ColName(), inIndexColName) } - } - for _, colID := range idx.IndexDesc().KeySuffixColumnIDs { - if _, exists := columnsByID[colID]; !exists { - return errors.Newf("index %q key suffix column ID %d is invalid", - idx.GetName(), colID) + if col.Dropped() && idx.GetEncodingType() != descpb.PrimaryIndexEncoding { + return errors.Newf("secondary index %q contains dropped stored column %q", idx.GetName(), col.ColName()) } } - if idx.IsSharded() { if err := desc.ensureShardedIndexNotComputed(idx.IndexDesc()); err != nil { return err } - if _, exists := columnNames[idx.GetSharded().Name]; !exists { + if col, _ := desc.FindColumnWithName(tree.Name(idx.GetSharded().Name)); col == nil { return errors.Newf("index %q refers to non-existent shard column %q", idx.GetName(), idx.GetSharded().Name) } @@ -1301,15 +1303,7 @@ func (desc *wrapper) validateTableIndexes( } } for _, colID := range idx.IndexDesc().KeySuffixColumnIDs { - if !vea.IsActive(clusterversion.Start22_1) { - if col := columnsByID[colID]; col != nil && col.IsVirtual() { - return errors.Newf("index %q cannot store virtual column %d", idx.GetName(), colID) - } - } - - if _, ok := columnsByID[colID]; !ok { - return errors.Newf("column %d does not exist in table %s", colID, desc.Name) - } + // At this point the ID -> column mapping is known to be valid. col := columnsByID[colID] if !col.IsVirtual() { continue diff --git a/pkg/sql/catalog/tabledesc/validate_test.go b/pkg/sql/catalog/tabledesc/validate_test.go index 0f0569112866..c63c7e5ce6d9 100644 --- a/pkg/sql/catalog/tabledesc/validate_test.go +++ b/pkg/sql/catalog/tabledesc/validate_test.go @@ -457,9 +457,9 @@ func TestValidateTableDesc(t *testing.T) { FormatVersion: descpb.InterleavedFormatVersion, Columns: []descpb.ColumnDescriptor{ {ID: 1, Name: "bar"}, - {ID: 1, Name: "bar"}, + {ID: 2, Name: "bar"}, }, - NextColumnID: 2, + NextColumnID: 3, }}, {`duplicate column name: "bar"`, descpb.TableDescriptor{ @@ -469,9 +469,9 @@ func TestValidateTableDesc(t *testing.T) { FormatVersion: descpb.InterleavedFormatVersion, Columns: []descpb.ColumnDescriptor{ {ID: 1, Name: "bar"}, - {ID: 1, Name: "bar"}, + {ID: 2, Name: "bar"}, }, - NextColumnID: 2, + NextColumnID: 3, }}, {`column "blah" duplicate ID of column "bar": 1`, descpb.TableDescriptor{ @@ -847,7 +847,7 @@ func TestValidateTableDesc(t *testing.T) { NextFamilyID: 1, NextIndexID: 2, }}, - {`index "bar" column "bar" should have ID 1, but found ID 2`, + {`index "bar" contains key column "bar" with unknown ID 2`, descpb.TableDescriptor{ ID: 2, ParentID: 1, @@ -859,7 +859,10 @@ func TestValidateTableDesc(t *testing.T) { Families: []descpb.ColumnFamilyDescriptor{ {ID: 0, Name: "primary", ColumnIDs: []descpb.ColumnID{1}, ColumnNames: []string{"bar"}}, }, - PrimaryIndex: descpb.IndexDescriptor{ID: 1, Name: "bar", KeyColumnIDs: []descpb.ColumnID{2}, + PrimaryIndex: descpb.IndexDescriptor{ + ID: 1, + Name: "bar", + KeyColumnIDs: []descpb.ColumnID{2}, KeyColumnNames: []string{"bar"}, KeyColumnDirections: []catpb.IndexColumn_Direction{catpb.IndexColumn_ASC}, }, @@ -867,7 +870,7 @@ func TestValidateTableDesc(t *testing.T) { NextFamilyID: 1, NextIndexID: 2, }}, - {`index "bar" contains unknown column "blah"`, + {`index "bar" key column ID 1 should have name "bar", but found name "blah"`, descpb.TableDescriptor{ ID: 2, ParentID: 1, @@ -879,7 +882,10 @@ func TestValidateTableDesc(t *testing.T) { Families: []descpb.ColumnFamilyDescriptor{ {ID: 0, Name: "primary", ColumnIDs: []descpb.ColumnID{1}, ColumnNames: []string{"bar"}}, }, - PrimaryIndex: descpb.IndexDescriptor{ID: 1, Name: "bar", KeyColumnIDs: []descpb.ColumnID{1}, + PrimaryIndex: descpb.IndexDescriptor{ + ID: 1, + Name: "bar", + KeyColumnIDs: []descpb.ColumnID{1}, KeyColumnNames: []string{"blah"}, KeyColumnDirections: []catpb.IndexColumn_Direction{catpb.IndexColumn_ASC}, }, @@ -1113,7 +1119,9 @@ func TestValidateTableDesc(t *testing.T) { }, }, PrimaryIndex: descpb.IndexDescriptor{ - ID: 1, Name: "primary", + ID: 1, + ConstraintID: 1, + Name: "primary", Unique: true, KeyColumnIDs: []descpb.ColumnID{1}, KeyColumnNames: []string{"bar"}, @@ -2049,151 +2057,6 @@ func TestValidateTableDesc(t *testing.T) { } } -func TestPrimaryKeyCannotBeVirtualBefore22_1(t *testing.T) { - computedExpr := "1 + 1" - testData := []struct { - err string - desc descpb.TableDescriptor - }{ - { - err: `primary index column "c3" cannot be virtual`, - desc: descpb.TableDescriptor{ - ID: 2, - ParentID: 1, - Name: "foo", - FormatVersion: descpb.InterleavedFormatVersion, - Columns: []descpb.ColumnDescriptor{ - {ID: 1, Name: "c1"}, - {ID: 2, Name: "c2"}, - {ID: 3, Name: "c3", ComputeExpr: &computedExpr, Virtual: true}, - }, - PrimaryIndex: descpb.IndexDescriptor{ - ID: 1, - Name: "primary", - Unique: true, - KeyColumnIDs: []descpb.ColumnID{1, 3}, - KeyColumnNames: []string{"c1", "c3"}, - KeyColumnDirections: []catpb.IndexColumn_Direction{catpb.IndexColumn_ASC, catpb.IndexColumn_ASC}, - Version: descpb.LatestIndexDescriptorVersion, - EncodingType: descpb.PrimaryIndexEncoding, - }, - Indexes: []descpb.IndexDescriptor{ - {ID: 2, Name: "sec", KeyColumnIDs: []descpb.ColumnID{2}, - KeyColumnNames: []string{"c2"}, - KeyColumnDirections: []catpb.IndexColumn_Direction{catpb.IndexColumn_ASC}, - KeySuffixColumnIDs: []descpb.ColumnID{1, 3}, - }, - }, - Families: []descpb.ColumnFamilyDescriptor{ - {ID: 0, Name: "primary", - ColumnIDs: []descpb.ColumnID{1, 2}, - ColumnNames: []string{"c1", "c2"}, - }, - }, - Mutations: []descpb.DescriptorMutation{}, - NextColumnID: 4, - NextFamilyID: 1, - NextIndexID: 5, - }, - }, - { - err: `index "sec" cannot store virtual column 3`, - desc: descpb.TableDescriptor{ - ID: 2, - ParentID: 1, - Name: "foo", - FormatVersion: descpb.InterleavedFormatVersion, - Columns: []descpb.ColumnDescriptor{ - {ID: 1, Name: "c1"}, - {ID: 2, Name: "c2"}, - {ID: 3, Name: "c3", ComputeExpr: &computedExpr, Virtual: true}, - }, - PrimaryIndex: descpb.IndexDescriptor{ - ID: 1, - Name: "primary", - Unique: true, - KeyColumnIDs: []descpb.ColumnID{1}, - KeyColumnNames: []string{"c1"}, - KeyColumnDirections: []catpb.IndexColumn_Direction{catpb.IndexColumn_ASC}, - Version: descpb.LatestIndexDescriptorVersion, - EncodingType: descpb.PrimaryIndexEncoding, - }, - Indexes: []descpb.IndexDescriptor{ - {ID: 2, Name: "sec", KeyColumnIDs: []descpb.ColumnID{2}, - KeyColumnNames: []string{"c2"}, - KeyColumnDirections: []catpb.IndexColumn_Direction{catpb.IndexColumn_ASC}, - KeySuffixColumnIDs: []descpb.ColumnID{1, 3}, - }, - }, - Families: []descpb.ColumnFamilyDescriptor{ - {ID: 0, Name: "primary", - ColumnIDs: []descpb.ColumnID{1, 2}, - ColumnNames: []string{"c1", "c2"}, - }, - }, - Mutations: []descpb.DescriptorMutation{ - { - Descriptor_: &descpb.DescriptorMutation_Index{ - Index: &descpb.IndexDescriptor{ - ID: 3, - Name: "new_primary_key", - Unique: true, - KeyColumnIDs: []descpb.ColumnID{1, 3}, - KeyColumnNames: []string{"c1", "c3"}, - KeyColumnDirections: []catpb.IndexColumn_Direction{catpb.IndexColumn_ASC, catpb.IndexColumn_ASC}, - Version: descpb.LatestIndexDescriptorVersion, - EncodingType: descpb.PrimaryIndexEncoding, - }, - }, - Direction: descpb.DescriptorMutation_ADD, - State: descpb.DescriptorMutation_DELETE_ONLY, - }, - { - Descriptor_: &descpb.DescriptorMutation_Index{ - Index: &descpb.IndexDescriptor{ - ID: 4, Name: "new_sec", KeyColumnIDs: []descpb.ColumnID{2}, - KeyColumnNames: []string{"c2"}, - KeyColumnDirections: []catpb.IndexColumn_Direction{catpb.IndexColumn_ASC}, - KeySuffixColumnIDs: []descpb.ColumnID{1, 3}, - }, - }, - Direction: descpb.DescriptorMutation_ADD, - State: descpb.DescriptorMutation_DELETE_ONLY, - }, - { - Descriptor_: &descpb.DescriptorMutation_PrimaryKeySwap{ - PrimaryKeySwap: &descpb.PrimaryKeySwap{ - OldPrimaryIndexId: 1, - NewPrimaryIndexId: 3, - NewIndexes: []descpb.IndexID{4}, - OldIndexes: []descpb.IndexID{2}, - }, - }, - Direction: descpb.DescriptorMutation_ADD, - State: descpb.DescriptorMutation_DELETE_ONLY, - }, - }, - NextColumnID: 4, - NextFamilyID: 1, - NextIndexID: 5, - }, - }, - } - for i, d := range testData { - t.Run(d.err, func(t *testing.T) { - d.desc.Privileges = catpb.NewBasePrivilegeDescriptor(username.RootUserName()) - desc := NewBuilder(&d.desc).BuildImmutableTable() - expectedErr := fmt.Sprintf("%s %q (%d): %s", desc.DescriptorType(), desc.GetName(), desc.GetID(), d.err) - err := validate.Self(clusterversion.ClusterVersion{Version: clusterversion.ByKey(clusterversion.V21_2)}, desc) - if err == nil { - t.Errorf("%d: expected \"%s\", but found success: %+v", i, expectedErr, d.desc) - } else if expectedErr != err.Error() { - t.Errorf("%d: expected \"%s\", but found \"%+v\"", i, expectedErr, err) - } - }) - } -} - func TestValidateCrossTableReferences(t *testing.T) { defer leaktest.AfterTest(t)() ctx := context.Background() @@ -2844,7 +2707,7 @@ func TestValidateConstraintID(t *testing.T) { err string desc descpb.TableDescriptor }{ - {`constraint id was missing for constraint: PRIMARY KEY with name \"primary\"`, + {`constraint ID was missing for constraint: PRIMARY KEY with name \"primary\"`, descpb.TableDescriptor{ ID: 2, ParentID: 1, @@ -2867,7 +2730,7 @@ func TestValidateConstraintID(t *testing.T) { privilege.List{}, username.RootUserName()), }}, - {`constraint id was missing for constraint: UNIQUE with name \"secondary\"`, + {`constraint ID was missing for constraint: UNIQUE with name \"secondary\"`, descpb.TableDescriptor{ ID: 2, ParentID: 1, @@ -2897,7 +2760,7 @@ func TestValidateConstraintID(t *testing.T) { privilege.List{}, username.RootUserName()), }}, - {`constraint id was missing for constraint: UNIQUE with name \"bad\"`, + {`constraint ID was missing for constraint: UNIQUE with name \"bad\"`, descpb.TableDescriptor{ ID: 2, ParentID: 1, @@ -2923,7 +2786,7 @@ func TestValidateConstraintID(t *testing.T) { privilege.List{}, username.RootUserName()), }}, - {`constraint id was missing for constraint: CHECK with name \"bad\"`, + {`constraint ID was missing for constraint: CHECK with name \"bad\"`, descpb.TableDescriptor{ ID: 2, ParentID: 1, diff --git a/pkg/sql/descriptor_mutation_test.go b/pkg/sql/descriptor_mutation_test.go index b5253c0cd519..66eddb93a5ec 100644 --- a/pkg/sql/descriptor_mutation_test.go +++ b/pkg/sql/descriptor_mutation_test.go @@ -1007,7 +1007,7 @@ CREATE TABLE t.test (a STRING PRIMARY KEY, b STRING, c STRING, INDEX foo (c)); mt.makeMutationsActive(ctx) // Add column mutation "b" mt.writeColumnMutation(ctx, "b", descpb.DescriptorMutation{Direction: descpb.DescriptorMutation_DROP}) - if _, err := sqlDB.Exec(`ALTER TABLE t.test ADD CONSTRAINT bar UNIQUE (b)`); !testutils.IsError(err, `index "bar" contains unknown column "b"`) { + if _, err := sqlDB.Exec(`ALTER TABLE t.test ADD CONSTRAINT bar UNIQUE (b)`); !testutils.IsError(err, `secondary index "bar" contains dropped key column "b"`) { t.Fatal(err) } // Make "b" live. diff --git a/pkg/sql/logictest/testdata/logic_test/alter_primary_key b/pkg/sql/logictest/testdata/logic_test/alter_primary_key index 0c42f5fc555e..96941e2f60ba 100644 --- a/pkg/sql/logictest/testdata/logic_test/alter_primary_key +++ b/pkg/sql/logictest/testdata/logic_test/alter_primary_key @@ -530,7 +530,6 @@ SHOW CREATE t ---- t CREATE TABLE public.t ( rowid INT8 NOT NULL, - rowid_1 INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), CONSTRAINT t_pkey PRIMARY KEY (rowid ASC) ) @@ -1150,10 +1149,9 @@ alter table t1 alter primary key using columns(id, id2); query TTT select index_name,column_name,direction from [show indexes from t1]; ---- -t1_pkey id ASC -t1_pkey id2 ASC -t1_pkey name N/A -t1_pkey rowid N/A +t1_pkey id ASC +t1_pkey id2 ASC +t1_pkey name N/A statement ok @@ -1163,10 +1161,9 @@ alter table t1 alter primary key using columns(id, id2); query TTT select index_name,column_name,direction from [show indexes from t1]; ---- -t1_pkey id ASC -t1_pkey id2 ASC -t1_pkey name N/A -t1_pkey rowid N/A +t1_pkey id ASC +t1_pkey id2 ASC +t1_pkey name N/A # Validate drop and recreate statement ok @@ -1175,10 +1172,9 @@ alter table t1 drop constraint t1_pkey, alter primary key using columns(id, id2) query TTT select index_name,column_name,direction from [show indexes from t1]; ---- -t1_pkey id ASC -t1_pkey id2 ASC -t1_pkey name N/A -t1_pkey rowid N/A +t1_pkey id ASC +t1_pkey id2 ASC +t1_pkey name N/A statement ok alter table t1 alter primary key using columns(id); @@ -1187,12 +1183,11 @@ alter table t1 alter primary key using columns(id); query TTT select index_name,column_name,direction from [show indexes from t1]; ---- -t1_pkey id ASC -t1_pkey id2 N/A -t1_pkey name N/A -t1_pkey rowid N/A -t1_id_id2_key id ASC -t1_id_id2_key id2 ASC +t1_pkey id ASC +t1_pkey id2 N/A +t1_pkey name N/A +t1_id_id2_key id ASC +t1_id_id2_key id2 ASC statement ok alter table t1 alter primary key using columns(id desc); @@ -1201,13 +1196,12 @@ alter table t1 alter primary key using columns(id desc); query TTT select index_name,column_name,direction from [show indexes from t1]; ---- -t1_pkey id DESC -t1_pkey id2 N/A -t1_pkey name N/A -t1_pkey rowid N/A -t1_id_key id ASC -t1_id_id2_key id ASC -t1_id_id2_key id2 ASC +t1_pkey id DESC +t1_pkey id2 N/A +t1_pkey name N/A +t1_id_key id ASC +t1_id_id2_key id ASC +t1_id_id2_key id2 ASC statement ok @@ -1216,13 +1210,12 @@ alter table t1 alter primary key using columns(id desc); query TTT select index_name,column_name,direction from [show indexes from t1]; ---- -t1_pkey id DESC -t1_pkey id2 N/A -t1_pkey name N/A -t1_pkey rowid N/A -t1_id_key id ASC -t1_id_id2_key id ASC -t1_id_id2_key id2 ASC +t1_pkey id DESC +t1_pkey id2 N/A +t1_pkey name N/A +t1_id_key id ASC +t1_id_id2_key id ASC +t1_id_id2_key id2 ASC statement ok alter table t1 alter primary key using columns(id desc); @@ -1230,13 +1223,12 @@ alter table t1 alter primary key using columns(id desc); query TTT select index_name,column_name,direction from [show indexes from t1]; ---- -t1_pkey id DESC -t1_pkey id2 N/A -t1_pkey name N/A -t1_pkey rowid N/A -t1_id_key id ASC -t1_id_id2_key id ASC -t1_id_id2_key id2 ASC +t1_pkey id DESC +t1_pkey id2 N/A +t1_pkey name N/A +t1_id_key id ASC +t1_id_id2_key id ASC +t1_id_id2_key id2 ASC statement ok alter table t1 alter primary key using columns(id) USING HASH WITH (bucket_count=10) @@ -1248,7 +1240,6 @@ t1_pkey crdb_internal_id_shard_10 ASC t1_pkey id ASC t1_pkey id2 N/A t1_pkey name N/A -t1_pkey rowid N/A t1_id_key1 id DESC t1_id_key1 crdb_internal_id_shard_10 ASC t1_id_key id ASC @@ -1715,3 +1706,39 @@ INSERT INTO t_multiple_cf VALUES (23, 24) statement ok ALTER TABLE t_multiple_cf ALTER PRIMARY KEY USING COLUMNS (j) + +subtest alter_primary_key_removes_rowid + +statement ok +CREATE TABLE t_rowid (k INT NOT NULL, v STRING) + +# Weird but legal: a reference is held to the hidden rowid column. +statement ok +CREATE TABLE t_child (id INT8 PRIMARY KEY, CONSTRAINT fk FOREIGN KEY (id) REFERENCES t_rowid (rowid)) + +# In this case, we expect the rowid column to NOT be dropped, +# furthermore it should be covered by a unique index. +statement ok +ALTER TABLE t_rowid ALTER PRIMARY KEY USING COLUMNS (k) + +query T +SELECT column_name FROM [SHOW COLUMNS FROM t_rowid] ORDER BY column_name; +---- +k +rowid +v + +# Recreate the table but without any references to rowid. +statement ok +DROP TABLE t_rowid CASCADE; +CREATE TABLE t_rowid (k INT NOT NULL, v STRING) + +# Now we expect the rowid column to be dropped. +statement ok +ALTER TABLE t_rowid ALTER PRIMARY KEY USING COLUMNS (k) + +query T +SELECT column_name FROM [SHOW COLUMNS FROM t_rowid] ORDER BY column_name; +---- +k +v diff --git a/pkg/sql/schemachanger/scbuild/internal/scbuildstmt/alter_table_add_column.go b/pkg/sql/schemachanger/scbuild/internal/scbuildstmt/alter_table_add_column.go index 482c7d168363..266ef796f228 100644 --- a/pkg/sql/schemachanger/scbuild/internal/scbuildstmt/alter_table_add_column.go +++ b/pkg/sql/schemachanger/scbuild/internal/scbuildstmt/alter_table_add_column.go @@ -347,26 +347,20 @@ func addColumn(b BuildCtx, spec addColumnSpec, n tree.NodeFormatter) (backing *s // Otherwise, create a new primary index target and swap it with the existing // primary index. - return createNewPrimaryIndex(b, spec.tbl, existing, func( - b BuildCtx, newIndex *scpb.PrimaryIndex, existingColumns []*scpb.IndexColumn, - ) (newColumns []*scpb.IndexColumn) { - for _, ec := range existingColumns { - cloned := protoutil.Clone(ec).(*scpb.IndexColumn) - cloned.IndexID = newIndex.IndexID - newColumns = append(newColumns, cloned) - b.Add(cloned) - } - ic := &scpb.IndexColumn{ - TableID: newIndex.TableID, - IndexID: newIndex.IndexID, - ColumnID: spec.col.ColumnID, - OrdinalInKind: getNextStoredIndexColumnOrdinal(allTargets, newIndex), - Kind: scpb.IndexColumn_STORED, - } - newColumns = append(newColumns, ic) - b.Add(ic) - return newColumns - }) + out := makePrimaryIndexSpec(b, existing) + inColumns := make([]indexColumnSpec, len(out.columns)+1) + for i, ic := range out.columns { + inColumns[i] = makeIndexColumnSpec(ic) + } + inColumns[len(out.columns)] = indexColumnSpec{ + columnID: spec.col.ColumnID, + kind: scpb.IndexColumn_STORED, + } + out.apply(b.Drop) + in, temp := makeSwapPrimaryIndexSpec(b, out, inColumns) + in.apply(b.Add) + temp.apply(b.AddTransient) + return in.idx } // handleAddColumnFreshlyAddedPrimaryIndex is used when adding a column to a @@ -428,103 +422,6 @@ func handleAddColumnFreshlyAddedPrimaryIndex( b.Add(tempIC) } -// newPrimaryIndexColumnFn is a callback which is supplied the old primary -// index and its columns and is responsible for constructing the set of -// columns for use in the new primary index. It is used by -// createNewPrimaryIndex. -type newPrimaryIndexColumnsFn = func( - b BuildCtx, - newIndex *scpb.PrimaryIndex, - existingColumns []*scpb.IndexColumn, -) (newColumns []*scpb.IndexColumn) - -// createNewPrimaryIndex creates a replacement primary index by dropping the -// existing primary index and adding a newly synthesized primary index. The -// makeColumnsFn is passed the existing columns and the new index and must -// synthesize the new IndexColumn elements to be added. -func createNewPrimaryIndex( - b BuildCtx, tbl *scpb.Table, existing *scpb.PrimaryIndex, makeColumnsFn newPrimaryIndexColumnsFn, -) *scpb.PrimaryIndex { - - // Drop all existing primary index elements. - existingName, existingPartitioning, - existingColumns := dropExistingPrimaryIndex(b, existing) - - // Create the new primary index element and its dependents. - replacement := protoutil.Clone(existing).(*scpb.PrimaryIndex) - replacement.IndexID = b.NextTableIndexID(tbl) - replacement.SourceIndexID = existing.IndexID - replacementColumns := makeColumnsFn(b, replacement, existingColumns) - replacement.TemporaryIndexID = replacement.IndexID + 1 - replacement.ConstraintID = b.NextTableConstraintID(tbl.TableID) - b.Add(replacement) - if existingName != nil { - updatedName := protoutil.Clone(existingName).(*scpb.IndexName) - updatedName.IndexID = replacement.IndexID - b.Add(updatedName) - } - if existingPartitioning != nil { - updatedPartitioning := protoutil.Clone(existingPartitioning).(*scpb.IndexPartitioning) - updatedPartitioning.IndexID = replacement.IndexID - b.Add(updatedPartitioning) - } - temp := &scpb.TemporaryIndex{ - Index: protoutil.Clone(replacement).(*scpb.PrimaryIndex).Index, - IsUsingSecondaryEncoding: false, - } - temp.TemporaryIndexID = 0 - temp.IndexID = b.NextTableIndexID(tbl) - temp.ConstraintID = b.NextTableConstraintID(tbl.TableID) - b.AddTransient(temp) - if existingPartitioning != nil { - updatedPartitioning := protoutil.Clone(existingPartitioning).(*scpb.IndexPartitioning) - updatedPartitioning.IndexID = temp.IndexID - b.Add(updatedPartitioning) - } - for _, ec := range replacementColumns { - cloned := protoutil.Clone(ec).(*scpb.IndexColumn) - cloned.IndexID = temp.IndexID - b.Add(cloned) - } - return replacement -} - -// dropExistingPrimaryIndex drops a primary index which existed before this -// schema change. -func dropExistingPrimaryIndex( - b BuildCtx, existing *scpb.PrimaryIndex, -) ( - existingName *scpb.IndexName, - existingPartitioning *scpb.IndexPartitioning, - existingColumns []*scpb.IndexColumn, -) { - b.Drop(existing) - publicTargets := b.QueryByID(existing.TableID).Filter(publicTargetFilter) - scpb.ForEachIndexName(publicTargets, func(_ scpb.Status, _ scpb.TargetStatus, name *scpb.IndexName) { - if name.IndexID == existing.IndexID { - existingName = name - } - }) - scpb.ForEachIndexPartitioning(publicTargets, func(_ scpb.Status, _ scpb.TargetStatus, part *scpb.IndexPartitioning) { - if part.IndexID == existing.IndexID { - existingPartitioning = part - } - }) - scpb.ForEachIndexColumn(publicTargets, func(_ scpb.Status, _ scpb.TargetStatus, e *scpb.IndexColumn) { - if e.IndexID == existing.IndexID { - existingColumns = append(existingColumns, e) - b.Drop(e) - } - }) - if existingPartitioning != nil { - b.Drop(existingPartitioning) - } - if existingName != nil { - b.Drop(existingName) - } - return existingName, existingPartitioning, existingColumns -} - func getNextStoredIndexColumnOrdinal(allTargets ElementResultSet, idx *scpb.PrimaryIndex) uint32 { max := -1 scpb.ForEachIndexColumn(allTargets, func( diff --git a/pkg/sql/schemachanger/scbuild/internal/scbuildstmt/alter_table_alter_primary_key.go b/pkg/sql/schemachanger/scbuild/internal/scbuildstmt/alter_table_alter_primary_key.go index ee83006b11d5..ebf9d01b884b 100644 --- a/pkg/sql/schemachanger/scbuild/internal/scbuildstmt/alter_table_alter_primary_key.go +++ b/pkg/sql/schemachanger/scbuild/internal/scbuildstmt/alter_table_alter_primary_key.go @@ -66,60 +66,114 @@ func alterTableAlterPrimaryKey( // should be returned, so, here we panic with an programming error. panic(errors.AssertionFailedf("programming error: new primary index has already existed.")) } - newPrimaryIndexElem = createNewPrimaryIndex(b, tbl, oldPrimaryIndexElem, func( - b BuildCtx, newPrimaryIndex *scpb.PrimaryIndex, _ []*scpb.IndexColumn, - ) (newColumns []*scpb.IndexColumn) { + + // Handle special case where the old primary key is the hidden rowid column. + // In this case, drop this column if it is not referenced anywhere. + rowidToDrop := getPrimaryIndexDefaultRowIDColumn(b, tbl.TableID, oldPrimaryIndexElem.IndexID) + if rowidToDrop != nil { + canBeDropped := true + walkDropColumnDependencies(b, rowidToDrop, func(e scpb.Element) { + switch e := e.(type) { + case *scpb.Column: + if e.TableID != rowidToDrop.TableID || e.ColumnID != rowidToDrop.ColumnID { + canBeDropped = false + } + case *scpb.ColumnDefaultExpression: + if e.TableID != rowidToDrop.TableID || e.ColumnID != rowidToDrop.ColumnID { + canBeDropped = false + } + case *scpb.ColumnOnUpdateExpression: + if e.TableID != rowidToDrop.TableID || e.ColumnID != rowidToDrop.ColumnID { + canBeDropped = false + } + case *scpb.UniqueWithoutIndexConstraint, *scpb.CheckConstraint, *scpb.ForeignKeyConstraint: + canBeDropped = false + case *scpb.View, *scpb.Sequence: + canBeDropped = false + case *scpb.SecondaryIndex: + // TODO(postamar): support dropping rowid in the presence of secondary + // indexes if the column is only present in key suffixes. + canBeDropped = false + } + }) + if !canBeDropped { + rowidToDrop = nil + } + } + + out := makePrimaryIndexSpec(b, oldPrimaryIndexElem) + inColumns := make([]indexColumnSpec, 0, len(out.columns)) + { allColumns := getSortedAllColumnIDsInTable(b, tbl.TableID) // Get all KEY columns from t.Columns allColumnsNameToIDMapping := getAllColumnsNameToIDMapping(b, tbl.TableID) allKeyColumnIDs := make(map[catid.ColumnID]bool) - for i, col := range t.Columns { - if colID, exist := allColumnsNameToIDMapping[string(col.Column)]; !exist { + for _, col := range t.Columns { + colID, exist := allColumnsNameToIDMapping[string(col.Column)] + if !exist { panic(fmt.Sprintf("table %v does not have a column named %v", tn.String(), col.Column)) - } else { - ic := &scpb.IndexColumn{ - TableID: tbl.TableID, - IndexID: newPrimaryIndex.IndexID, - ColumnID: colID, - OrdinalInKind: uint32(i), - Kind: scpb.IndexColumn_KEY, - Direction: indexColumnDirection(col.Direction), - } - b.Add(ic) - newColumns = append(newColumns, ic) - allKeyColumnIDs[colID] = true } + if rowidToDrop != nil && colID == rowidToDrop.ColumnID { + rowidToDrop = nil + } + inColumns = append(inColumns, indexColumnSpec{ + columnID: colID, + kind: scpb.IndexColumn_KEY, + direction: indexColumnDirection(col.Direction), + }) + allKeyColumnIDs[colID] = true } // What's left are STORED columns, excluding virtual columns and system columns - i := 0 for _, colID := range allColumns { if _, isKeyCol := allKeyColumnIDs[colID]; isKeyCol || mustRetrieveColumnTypeElem(b, tbl.TableID, colID).IsVirtual || - colinfo.IsColIDSystemColumn(colID) { + colinfo.IsColIDSystemColumn(colID) || + (rowidToDrop != nil && colID == rowidToDrop.ColumnID) { continue } - ic := &scpb.IndexColumn{ - TableID: tbl.TableID, - IndexID: newPrimaryIndex.IndexID, - ColumnID: colID, - OrdinalInKind: uint32(i), - Kind: scpb.IndexColumn_STORED, - } - b.Add(ic) - newColumns = append(newColumns, ic) - i++ + inColumns = append(inColumns, indexColumnSpec{ + columnID: colID, + kind: scpb.IndexColumn_STORED, + }) } - - return newColumns - }) - newPrimaryIndexElem.Sharding = makeShardedDescriptor(b, t) + } + out.apply(b.Drop) + sharding := makeShardedDescriptor(b, t) + if rowidToDrop == nil { + // We're NOT dropping the rowid column => do one primary index swap. + in, tempIn := makeSwapPrimaryIndexSpec(b, out, inColumns) + in.idx.Sharding = sharding + in.apply(b.Add) + tempIn.apply(b.AddTransient) + newPrimaryIndexElem = in.idx + } else { + // We ARE dropping the rowid column => swap indexes twice and drop column. + unionColumns := append(inColumns[:len(inColumns):len(inColumns)], indexColumnSpec{ + columnID: rowidToDrop.ColumnID, + kind: scpb.IndexColumn_STORED, + }) + // Swap once to the new PK but storing rowid. + union, tempUnion := makeSwapPrimaryIndexSpec(b, out, unionColumns) + union.idx.Sharding = protoutil.Clone(sharding).(*catpb.ShardedDescriptor) + union.apply(b.AddTransient) + tempUnion.apply(b.AddTransient) + // Swap again to the final primary index: same PK but NOT storing rowid. + in, tempIn := makeSwapPrimaryIndexSpec(b, union, inColumns) + in.idx.Sharding = sharding + in.apply(b.Add) + tempIn.apply(b.AddTransient) + newPrimaryIndexElem = in.idx + // Drop the rowid column + elts := b.QueryByID(rowidToDrop.TableID).Filter(hasColumnIDAttrFilter(rowidToDrop.ColumnID)) + dropColumn(b, tn, tbl, t, rowidToDrop, elts, tree.DropRestrict) + } // Construct and add elements for a unique secondary index created on // the old primary key columns. // This is a CRDB unique feature that exists in the legacy schema changer. - maybeAddUniqueIndexForOldPrimaryKey(b, tn, tbl, t, oldPrimaryIndexElem, newPrimaryIndexElem) + maybeAddUniqueIndexForOldPrimaryKey(b, tn, tbl, t, oldPrimaryIndexElem, newPrimaryIndexElem, rowidToDrop) } // checkForEarlyExit asserts several precondition for a @@ -270,7 +324,7 @@ func fallBackIfRequestToBeSharded(t *tree.AlterTableAlterPrimaryKey) { func fallBackIfSecondaryIndexExists(b BuildCtx, tableID catid.DescID) { _, _, sie := scpb.FindSecondaryIndex(b.QueryByID(tableID)) if sie != nil { - panic(scerrors.NotImplementedErrorf(nil, "ALTER PRIMARY KEY on a table with secondary index"+ + panic(scerrors.NotImplementedErrorf(nil, "ALTER PRIMARY KEY on a table with secondary index "+ "is not yet supported because they might need to be rewritten.")) } } @@ -468,9 +522,11 @@ func maybeAddUniqueIndexForOldPrimaryKey( tbl *scpb.Table, t *tree.AlterTableAlterPrimaryKey, oldPrimaryIndex, newPrimaryIndex *scpb.PrimaryIndex, + rowidToDrop *scpb.Column, ) { - if shouldCreateUniqueIndexOnOldPrimaryKeyColumns(b, tn, tbl, t, - oldPrimaryIndex.IndexID, newPrimaryIndex.IndexID) { + if shouldCreateUniqueIndexOnOldPrimaryKeyColumns( + b, tbl, oldPrimaryIndex.IndexID, newPrimaryIndex.IndexID, rowidToDrop, + ) { newUniqueSecondaryIndex, tempIndex := addNewUniqueSecondaryIndexAndTempIndex(b, tn, tbl, oldPrimaryIndex) addIndexColumnsForNewUniqueSecondaryIndexAndTempIndex(b, tn, tbl, t, oldPrimaryIndex.IndexID, newUniqueSecondaryIndex.IndexID, tempIndex.IndexID) @@ -605,11 +661,9 @@ func addIndexNameForNewUniqueSecondaryIndex(b BuildCtx, tbl *scpb.Table, indexID // * There is no existing secondary index on the old primary key columns. func shouldCreateUniqueIndexOnOldPrimaryKeyColumns( b BuildCtx, - tn *tree.TableName, tbl *scpb.Table, - t *tree.AlterTableAlterPrimaryKey, - oldPrimaryIndexID catid.IndexID, - newPrimaryIndexID catid.IndexID, + oldPrimaryIndexID, newPrimaryIndexID catid.IndexID, + rowidToDrop *scpb.Column, ) bool { // A function that retrieves all KEY columns of this index. // If excludeShardedCol, sharded column is excluded, if any. @@ -649,6 +703,11 @@ func shouldCreateUniqueIndexOnOldPrimaryKeyColumns( return true } + // If the primary key doesn't really change, don't create any unique indexes. + if keyColumnIDsAndDirsMatch(b, tbl.TableID, oldPrimaryIndexID, newPrimaryIndexID, true /* excludeShardedCol */) { + return false + } + // A function that checks whether there exists a secondary index // that is "identical" to the old primary index. // It is used to avoid creating duplicate secondary index during @@ -673,16 +732,27 @@ func shouldCreateUniqueIndexOnOldPrimaryKeyColumns( return found } - return !isPrimaryIndexDefaultRowID(b, tbl.TableID, oldPrimaryIndexID) && - !keyColumnIDsAndDirsMatch(b, tbl.TableID, oldPrimaryIndexID, newPrimaryIndexID, true /* excludeShardedCol */) && - !alreadyHasSecondaryIndexOnPKColumns(b, tbl.TableID, oldPrimaryIndexID) + // If there already exist suitable unique indexes, then don't create any. + if alreadyHasSecondaryIndexOnPKColumns(b, tbl.TableID, oldPrimaryIndexID) { + return false + } + + // If the old PK consists of the rowid column, and if we intend to drop it, + // then that implies that there are no references to it anywhere and we don't + // need to guarantee its uniqueness. + if rowidToDrop != nil { + return false + } + + // In all other cases, we need to create unique indexes just to be sure. + return true } -// isPrimaryIndexDefaultRowID checks whether the index is on the -// implicitly created, hidden column 'rowid'. -func isPrimaryIndexDefaultRowID( +// getPrimaryIndexDefaultRowIDColumn checks whether the primary key is on the +// implicitly created, hidden column 'rowid' and returns it if that's the case. +func getPrimaryIndexDefaultRowIDColumn( b BuildCtx, tableID catid.DescID, indexID catid.IndexID, -) (res bool) { +) (column *scpb.Column) { // Sanity check: input `indexID` should really be the index of // a primary index. var primaryIndex *scpb.PrimaryIndex @@ -700,27 +770,27 @@ func isPrimaryIndexDefaultRowID( // This primary index should have only one column. indexColumns := mustRetrieveKeyIndexColumns(b, tableID, indexID) if len(indexColumns) != 1 { - return false + return nil } columnID := indexColumns[0].ColumnID // That one column should be hidden. - column := mustRetrieveColumnElem(b, tableID, columnID) + column = mustRetrieveColumnElem(b, tableID, columnID) if !column.IsHidden { - return false + return nil } // That one column's name should be 'rowid' or prefixed by 'rowid'. columnName := mustRetrieveColumnNameElem(b, tableID, columnID) if !strings.HasPrefix(columnName.Name, "rowid") { - return false + return nil } // That column should be of type INT. columnType := mustRetrieveColumnTypeElem(b, tableID, columnID) if !columnType.Type.Equal(types.Int) { - return false + return nil } // That column should have default expression that is equal to "unique_rowid()". @@ -733,11 +803,11 @@ func isPrimaryIndexDefaultRowID( } }) if columnDefaultExpression == nil || columnDefaultExpression.Expr != "unique_rowid()" { - return false + return nil } // All checks are satisfied, return true! - return true + return column } // getAllColumnsNameToIDMapping constructs a name to ID mapping @@ -756,9 +826,7 @@ func getAllColumnsNameToIDMapping( // getSortedAllColumnIDsInTable returns sorted IDs of all columns in table. func getSortedAllColumnIDsInTable(b BuildCtx, tableID catid.DescID) (res []catid.ColumnID) { - scpb.ForEachColumn(b.QueryByID(tableID), func( - current scpb.Status, target scpb.TargetStatus, e *scpb.Column, - ) { + scpb.ForEachColumn(b.QueryByID(tableID), func(_ scpb.Status, _ scpb.TargetStatus, e *scpb.Column) { res = append(res, e.ColumnID) }) sort.Slice(res, func(i, j int) bool { diff --git a/pkg/sql/schemachanger/scbuild/internal/scbuildstmt/alter_table_drop_column.go b/pkg/sql/schemachanger/scbuild/internal/scbuildstmt/alter_table_drop_column.go index d3eb0cfabe3a..1fd1d3179114 100644 --- a/pkg/sql/schemachanger/scbuild/internal/scbuildstmt/alter_table_drop_column.go +++ b/pkg/sql/schemachanger/scbuild/internal/scbuildstmt/alter_table_drop_column.go @@ -21,11 +21,9 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/privilege" "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scerrors" "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scpb" - "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/screl" "github.com/cockroachdb/cockroach/pkg/sql/sem/catid" "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" "github.com/cockroachdb/cockroach/pkg/sql/sqlerrors" - "github.com/cockroachdb/cockroach/pkg/util/protoutil" "github.com/cockroachdb/errors" ) @@ -153,92 +151,188 @@ func dropColumn( behavior tree.DropBehavior, ) { _, _, cn := scpb.FindColumnName(colElts) - _, _, ct := scpb.FindColumnType(colElts) - checkColumnNotInPrimaryKey(b, col, cn) - b.Drop(col) - b.Drop(cn) - b.Drop(ct) - if _, _, cc := scpb.FindColumnComment(colElts); cc != nil { - b.Drop(cc) - } - handleDropColumnExpressions(b, colElts, behavior) - handleDropColumnIndexes(b, tn, col, behavior) - handleDropColumnComputedColumns(b, tn, cn, tbl, n, col, behavior) - handleDropColumnUniqueWithoutIndexConstraints(b, col, n) - handleDropColumnCheckConstraints(b, col, n) - handleDropColumnForeignKeyConstraintForwardReferences(b, col, n) - backrefs := undroppedBackrefs(b, col.TableID) - handleDropColumnViewBackReferences(b, backrefs, col, cn, behavior) - handleDropColumnForeignKeyConstraintBackReferences(b, cn, backrefs, col, n, behavior) - if !ct.IsVirtual { + var undroppedSeqBackrefsToCheck catalog.DescriptorIDSet + walkDropColumnDependencies(b, col, func(e scpb.Element) { + switch e := e.(type) { + case *scpb.Column: + if e.TableID == col.TableID && e.ColumnID == col.ColumnID { + b.Drop(e) + return + } + elts := b.QueryByID(e.TableID).Filter(hasColumnIDAttrFilter(e.ColumnID)) + if behavior != tree.DropCascade { + _, _, computedColName := scpb.FindColumnName(elts.Filter(publicTargetFilter)) + panic(sqlerrors.NewColumnReferencedByComputedColumnError(cn.Name, computedColName.Name)) + } + dropColumn(b, tn, tbl, n, e, elts, behavior) + case *scpb.PrimaryIndex: + tableElts := b.QueryByID(e.TableID).Filter(publicTargetFilter) + scpb.ForEachIndexColumn(tableElts, func(_ scpb.Status, _ scpb.TargetStatus, ic *scpb.IndexColumn) { + if ic.ColumnID == col.ColumnID && + e.IndexID == ic.IndexID && + ic.Kind == scpb.IndexColumn_KEY { + panic(sqlerrors.NewColumnReferencedByPrimaryKeyError(cn.Name)) + } + }) + case *scpb.SecondaryIndex: + indexElts := b.QueryByID(e.TableID).Filter(hasIndexIDAttrFilter(e.IndexID)) + _, _, indexName := scpb.FindIndexName(indexElts.Filter(publicTargetFilter)) + name := tree.TableIndexName{ + Table: *tn, + Index: tree.UnrestrictedName(indexName.Name), + } + dropSecondaryIndex(b, &name, behavior, e, indexElts) + case *scpb.UniqueWithoutIndexConstraint: + // TODO(ajwerner): Support dropping UNIQUE WITHOUT INDEX constraints. + panic(errors.Wrap(scerrors.NotImplementedError(n), + "dropping of UNIQUE WITHOUT INDEX constraints not supported")) + case *scpb.CheckConstraint: + // TODO(ajwerner): Support dropping CHECK constraints. + panic(errors.Wrap(scerrors.NotImplementedError(n), + "dropping of CHECK constraints not supported")) + case *scpb.ForeignKeyConstraint: + if e.TableID != col.TableID && behavior != tree.DropCascade { + panic(pgerror.Newf(pgcode.DependentObjectsStillExist, + "cannot drop column %s because other objects depend on it", cn.Name)) + } + // TODO(ajwerner): Support dropping FOREIGN KEY constraints. + panic(errors.Wrap(scerrors.NotImplementedError(n), + "dropping of FOREIGN KEY constraints not supported")) + case *scpb.View: + if behavior != tree.DropCascade { + _, _, ns := scpb.FindNamespace(b.QueryByID(col.TableID)) + _, _, nsDep := scpb.FindNamespace(b.QueryByID(e.ViewID)) + if nsDep.DatabaseID != ns.DatabaseID || nsDep.SchemaID != ns.SchemaID { + panic(errors.WithHintf(sqlerrors.NewDependentObjectErrorf( + "cannot drop column %q because view %q depends on it", + cn.Name, qualifiedName(b, e.ViewID)), + "you can drop %s instead.", nsDep.Name)) + } + panic(sqlerrors.NewDependentObjectErrorf( + "cannot drop column %q because view %q depends on it", + cn.Name, nsDep.Name)) + } + dropCascadeDescriptor(b, e.ViewID) + case *scpb.Sequence: + // Find all the sequences owned by this column and drop them either restrict + // or cascade. Then, we'll need to check whether these sequences have any + // other backreferences which have not yet been dropped. Note that we don't + // need to wait for the other commands in this statement; postgres fails on + // something like: + // + // create table t (i serial); + // alter table t add column j default nextval('t_i_seq'::regclass); + // alter table t drop column i, drop column j; + // 2BP01: cannot drop column i of table t because other objects depend on it + // + if behavior == tree.DropCascade { + dropCascadeDescriptor(b, e.SequenceID) + } else { + dropRestrictDescriptor(b, e.SequenceID) + undroppedSeqBackrefsToCheck.Add(e.SequenceID) + } + default: + b.Drop(e) + } + }) + // TODO(ajwerner): Track the undropped backrefs to populate a detail + // message like postgres does. For example: + // + // create table t (i serial); + // create table t2 (i int default nextval('t_i_seq'::regclass)); + // drop table t restrict; + // ERROR: cannot drop table t because other objects depend on it + // DETAIL: default value for column i of table t2 depends on sequence t_i_seq + // HINT: Use DROP ... CASCADE to drop the dependent objects too. + // + undroppedSeqBackrefsToCheck.ForEach(func(seqID descpb.ID) { + if udr := undroppedBackrefs(b, seqID); !udr.IsEmpty() { + panic(pgerror.Newf(pgcode.DependentObjectsStillExist, + "cannot drop column %s because other objects depend on it", cn.Name)) + } + }) + if _, _, ct := scpb.FindColumnType(colElts); !ct.IsVirtual { handleDropColumnPrimaryIndexes(b, tbl, n, col) } assertAllColumnElementsAreDropped(colElts) } -func checkColumnNotInPrimaryKey(b BuildCtx, col *scpb.Column, cn *scpb.ColumnName) { - publicTargets := b.QueryByID(col.TableID).Filter(publicTargetFilter) - _, _, pi := scpb.FindPrimaryIndex(publicTargets) - var ic *scpb.IndexColumn - scpb.ForEachIndexColumn(publicTargets, func( - _ scpb.Status, _ scpb.TargetStatus, e *scpb.IndexColumn, - ) { - if e.ColumnID == col.ColumnID && - e.IndexID == pi.IndexID && - e.Kind == scpb.IndexColumn_KEY { - ic = e +func walkDropColumnDependencies(b BuildCtx, col *scpb.Column, fn func(e scpb.Element)) { + var sequencesToDrop catalog.DescriptorIDSet + var indexesToDrop catid.IndexSet + var columnsToDrop catalog.TableColSet + tblElts := b.QueryByID(col.TableID).Filter(publicTargetFilter) + tblElts. + Filter(referencesColumnIDFilter(col.ColumnID)). + ForEachElementStatus(func(_ scpb.Status, _ scpb.TargetStatus, e scpb.Element) { + switch elt := e.(type) { + case *scpb.Column, *scpb.ColumnName, *scpb.ColumnComment: + fn(e) + case *scpb.ColumnDefaultExpression, *scpb.ColumnOnUpdateExpression: + fn(e) + case *scpb.UniqueWithoutIndexConstraint, *scpb.CheckConstraint: + fn(e) + case *scpb.ColumnType: + if elt.ColumnID == col.ColumnID { + fn(e) + } else { + columnsToDrop.Add(elt.ColumnID) + } + case *scpb.SequenceOwner: + fn(e) + sequencesToDrop.Add(elt.SequenceID) + case *scpb.SecondaryIndexPartial: + indexesToDrop.Add(elt.IndexID) + case *scpb.IndexColumn: + indexesToDrop.Add(elt.IndexID) + case *scpb.ForeignKeyConstraint: + if elt.TableID == col.TableID && + catalog.MakeTableColSet(elt.ColumnIDs...).Contains(col.ColumnID) { + fn(e) + } else if elt.ReferencedTableID == col.TableID && + catalog.MakeTableColSet(elt.ReferencedColumnIDs...).Contains(col.ColumnID) { + fn(e) + } + } + }) + tblElts.ForEachElementStatus(func(_ scpb.Status, _ scpb.TargetStatus, e scpb.Element) { + switch elt := e.(type) { + case *scpb.Column: + if columnsToDrop.Contains(elt.ColumnID) { + fn(e) + } + case *scpb.PrimaryIndex: + if indexesToDrop.Contains(elt.IndexID) { + fn(e) + } + case *scpb.SecondaryIndex: + if indexesToDrop.Contains(elt.IndexID) { + fn(e) + } } }) - if ic != nil { - panic(sqlerrors.NewColumnReferencedByPrimaryKeyError(cn.Name)) - } -} - -func handleDropColumnComputedColumns( - b BuildCtx, - tn *tree.TableName, - cn *scpb.ColumnName, - tbl *scpb.Table, - n tree.NodeFormatter, - col *scpb.Column, - behavior tree.DropBehavior, -) { - var toRemove catalog.TableColSet - allElts := b.QueryByID(col.TableID) - publicElts := allElts.Filter(publicTargetFilter) - scpb.ForEachColumnType(publicElts, func( - _ scpb.Status, _ scpb.TargetStatus, e *scpb.ColumnType, - ) { - // The below check is defensive given, at the time of writing, we already - // dropped the column type for the column in question. - if e.ColumnID == col.ColumnID || - // We only care about references in the computed expression. - e.ComputeExpr == nil { - return - } - if descpb.ColumnIDs.Contains(e.ComputeExpr.ReferencedColumnIDs, col.ColumnID) { - toRemove.Add(e.ColumnID) + sequencesToDrop.ForEach(func(id descpb.ID) { + _, target, seq := scpb.FindSequence(b.QueryByID(id)) + if target == scpb.ToPublic && seq != nil { + fn(seq) } }) - if !toRemove.Empty() && behavior != tree.DropCascade { - first, _ := toRemove.Next(0) - var computedColumnName *scpb.ColumnName - scpb.ForEachColumnName(publicElts, func( - _ scpb.Status, _ scpb.TargetStatus, e *scpb.ColumnName, - ) { - if e.ColumnID == first { - computedColumnName = e + backrefs := undroppedBackrefs(b, col.TableID) + backrefs.ForEachElementStatus(func(_ scpb.Status, target scpb.TargetStatus, e scpb.Element) { + switch elt := e.(type) { + case *scpb.View: + for _, ref := range elt.ForwardReferences { + if ref.ToID == col.TableID && + catalog.MakeTableColSet(ref.ColumnIDs...).Contains(col.ColumnID) { + fn(e) + } } - }) - panic(sqlerrors.NewColumnReferencedByComputedColumnError(cn.Name, computedColumnName.Name)) - } - toRemove.ForEach(func(computedColumnID descpb.ColumnID) { - elts := allElts.Filter(func(_ scpb.Status, _ scpb.TargetStatus, e scpb.Element) bool { - idI, _ := screl.Schema.GetAttribute(screl.ColumnID, e) - return idI != nil && idI.(catid.ColumnID) == computedColumnID - }) - _, _, computedCol := scpb.FindColumn(elts) - dropColumn(b, tn, tbl, n, computedCol, elts, behavior) + case *scpb.ForeignKeyConstraint: + if elt.ReferencedTableID == col.TableID && + catalog.MakeTableColSet(elt.ReferencedColumnIDs...).Contains(col.ColumnID) { + fn(e) + } + } }) } @@ -256,58 +350,48 @@ func handleDropColumnPrimaryIndexes( } existing, freshlyAdded := getPrimaryIndexes(b, tbl.TableID) if freshlyAdded != nil { - handleDropColumnFreshlyAddedPrimaryIndex(b, tbl, freshlyAdded, col) + handleDropColumnFreshlyAddedPrimaryIndex(b, freshlyAdded, col) } else { - handleDropColumnCreateNewPrimaryIndex(b, tbl, existing, col) + handleDropColumnCreateNewPrimaryIndex(b, existing, col) } } func handleDropColumnCreateNewPrimaryIndex( - b BuildCtx, tbl *scpb.Table, existing *scpb.PrimaryIndex, col *scpb.Column, + b BuildCtx, existing *scpb.PrimaryIndex, col *scpb.Column, ) *scpb.PrimaryIndex { - return createNewPrimaryIndex(b, tbl, existing, func( - b BuildCtx, newIndex *scpb.PrimaryIndex, existingColumns []*scpb.IndexColumn, - ) (newColumns []*scpb.IndexColumn) { - var ic *scpb.IndexColumn - for _, c := range existingColumns { - if c.ColumnID == col.ColumnID { - ic = c - break - } - } - if ic == nil { - panic(errors.AssertionFailedf("failed to find column")) - } - if ic.Kind != scpb.IndexColumn_STORED { - panic(errors.AssertionFailedf("can only drop columns which are stored in the primary index, this one is %v ", - ic.Kind)) - } - for _, ec := range existingColumns { - sameKind := ec.Kind == ic.Kind - if sameKind && ec.OrdinalInKind == ic.OrdinalInKind { - continue - } - cloned := protoutil.Clone(ec).(*scpb.IndexColumn) - if sameKind && ec.OrdinalInKind > ic.OrdinalInKind { - cloned.OrdinalInKind-- - } - cloned.IndexID = newIndex.IndexID - newColumns = append(newColumns, cloned) - b.Add(cloned) + out := makePrimaryIndexSpec(b, existing) + inColumns := make([]indexColumnSpec, 0, len(out.columns)-1) + var dropped *scpb.IndexColumn + for _, ic := range out.columns { + if ic.ColumnID == col.ColumnID { + dropped = ic + } else { + inColumns = append(inColumns, makeIndexColumnSpec(ic)) } - return newColumns - }) + } + if dropped == nil { + panic(errors.AssertionFailedf("failed to find column")) + } + if dropped.Kind != scpb.IndexColumn_STORED { + panic(errors.AssertionFailedf("can only drop columns which are stored in the primary index, this one is %v ", + dropped.Kind)) + } + in, temp := makeSwapPrimaryIndexSpec(b, out, inColumns) + out.apply(b.Drop) + in.apply(b.Add) + temp.apply(b.AddTransient) + return in.idx } func handleDropColumnFreshlyAddedPrimaryIndex( - b BuildCtx, tbl *scpb.Table, freshlyAdded *scpb.PrimaryIndex, col *scpb.Column, + b BuildCtx, freshlyAdded *scpb.PrimaryIndex, col *scpb.Column, ) { // We want to find the freshly added index and go ahead and remove this // column from the stored set. That means going through the other // index columns for this index and adjusting their ordinal appropriately. var storedColumns, storedTempColumns []*scpb.IndexColumn var tempIndex *scpb.TemporaryIndex - scpb.ForEachTemporaryIndex(b.QueryByID(tbl.TableID), func( + scpb.ForEachTemporaryIndex(b.QueryByID(freshlyAdded.TableID), func( _ scpb.Status, _ scpb.TargetStatus, e *scpb.TemporaryIndex, ) { if e.IndexID == freshlyAdded.TemporaryIndexID { @@ -317,9 +401,12 @@ func handleDropColumnFreshlyAddedPrimaryIndex( if tempIndex == nil { panic(errors.AssertionFailedf("failed to find temp index %d", freshlyAdded.TemporaryIndexID)) } - scpb.ForEachIndexColumn(b.QueryByID(tbl.TableID).Filter(publicTargetFilter), func( - _ scpb.Status, _ scpb.TargetStatus, e *scpb.IndexColumn, + scpb.ForEachIndexColumn(b.QueryByID(freshlyAdded.TableID), func( + _ scpb.Status, targetStatus scpb.TargetStatus, e *scpb.IndexColumn, ) { + if targetStatus == scpb.ToAbsent { + return + } if e.Kind != scpb.IndexColumn_STORED { return } @@ -344,7 +431,7 @@ func handleDropColumnFreshlyAddedPrimaryIndex( } } if n == -1 { - panic(errors.AssertionFailedf("failed to find column %d in index %d", col.ColumnID, freshlyAdded.TemporaryIndexID)) + return } b.Drop(storedColumns[n]) b.Drop(storedTempColumns[n]) @@ -356,261 +443,6 @@ func handleDropColumnFreshlyAddedPrimaryIndex( } } -func handleDropColumnUniqueWithoutIndexConstraints( - b BuildCtx, col *scpb.Column, n tree.NodeFormatter, -) { - publicTargets := b.QueryByID(col.TableID).Filter(publicTargetFilter) - var constraints []*scpb.UniqueWithoutIndexConstraint - scpb.ForEachUniqueWithoutIndexConstraint(publicTargets, func( - _ scpb.Status, _ scpb.TargetStatus, e *scpb.UniqueWithoutIndexConstraint, - ) { - if descpb.ColumnIDs(e.ColumnIDs).Contains(col.ColumnID) { - constraints = append(constraints, e) - } - }) - if len(constraints) == 0 { - return - } - // TODO(ajwerner): Support dropping UNIQUE WITHOUT INDEX constraints. - panic(errors.Wrap(scerrors.NotImplementedError(n), - "dropping of UNIQUE WITHOUT INDEX constraints not supported")) -} - -func handleDropColumnCheckConstraints(b BuildCtx, col *scpb.Column, n tree.NodeFormatter) { - publicTargets := b.QueryByID(col.TableID).Filter(publicTargetFilter) - var constraints []*scpb.CheckConstraint - scpb.ForEachCheckConstraint(publicTargets, func( - _ scpb.Status, _ scpb.TargetStatus, e *scpb.CheckConstraint, - ) { - if descpb.ColumnIDs.Contains(e.ReferencedColumnIDs, col.ColumnID) { - constraints = append(constraints, e) - } - }) - if len(constraints) == 0 { - return - } - // TODO(ajwerner): Support dropping CHECK constraints. - panic(errors.Wrap(scerrors.NotImplementedError(n), - "dropping of CHECK constraints not supported")) -} - -func handleDropColumnForeignKeyConstraintForwardReferences( - b BuildCtx, col *scpb.Column, n tree.NodeFormatter, -) { - publicTargets := b.QueryByID(col.TableID).Filter(publicTargetFilter) - var constraints []*scpb.ForeignKeyConstraint - scpb.ForEachForeignKeyConstraint(publicTargets, func( - _ scpb.Status, _ scpb.TargetStatus, e *scpb.ForeignKeyConstraint, - ) { - if descpb.ColumnIDs.Contains(e.ColumnIDs, col.ColumnID) { - constraints = append(constraints, e) - } - }) - if len(constraints) == 0 { - return - } - // Here we will drop a constraint with or without cascade for outbound - // constraints. - // TODO(ajwerner): Support dropping FOREIGN KEY constraints. - panic(errors.Wrap(scerrors.NotImplementedError(n), - "dropping of FOREIGN KEY constraints not supported")) -} - -func handleDropColumnForeignKeyConstraintBackReferences( - b BuildCtx, - cn *scpb.ColumnName, - backrefs ElementResultSet, - col *scpb.Column, - n tree.NodeFormatter, - behavior tree.DropBehavior, -) { - publicTargets := b.QueryByID(col.TableID).Filter(publicTargetFilter) - var constraints []*scpb.ForeignKeyConstraint - scpb.ForEachForeignKeyConstraint(publicTargets, func( - _ scpb.Status, _ scpb.TargetStatus, e *scpb.ForeignKeyConstraint, - ) { - if descpb.ColumnIDs.Contains(e.ReferencedColumnIDs, col.ColumnID) { - constraints = append(constraints, e) - } - }) - scpb.ForEachForeignKeyConstraint(backrefs, func( - _ scpb.Status, _ scpb.TargetStatus, e *scpb.ForeignKeyConstraint, - ) { - if descpb.ColumnIDs.Contains(e.ReferencedColumnIDs, col.ColumnID) { - constraints = append(constraints, e) - } - }) - if len(constraints) == 0 { - return - } - if behavior != tree.DropCascade { - panic(pgerror.Newf(pgcode.DependentObjectsStillExist, - "cannot drop column %s because other objects depend on it", cn.Name)) - } - // Here we will drop a constraint with or without cascade for outbound - // constraints. - // TODO(ajwerner): Support dropping FOREIGN KEY constraints. - panic(errors.Wrap(scerrors.NotImplementedError(n), - "dropping of FOREIGN KEY constraints not supported")) -} - -func handleDropColumnExpressions(b BuildCtx, colElts ElementResultSet, behavior tree.DropBehavior) { - publicTargets := colElts.Filter(publicTargetFilter) - if _, _, de := scpb.FindColumnDefaultExpression(publicTargets); de != nil { - b.Drop(de) - } - if _, _, ue := scpb.FindColumnOnUpdateExpression(publicTargets); ue != nil { - b.Drop(ue) - } - - // Find all the sequences owned by this column and drop them either restrict - // or cascade. Then, we'll need to check whether these sequences have any - // other backreferences which have not yet been dropped. Note that we don't - // need to wait for the other commands in this statement; postgres fails on - // something like: - // - // create table t (i serial); - // alter table t add column j default nextval('t_i_seq'::regclass); - // alter table t drop column i, drop column j; - // 2BP01: cannot drop column i of table t because other objects depend on it - // - var undroppedBackrefsToCheck catalog.DescriptorIDSet - scpb.ForEachSequenceOwner(colElts, func( - _ scpb.Status, _ scpb.TargetStatus, so *scpb.SequenceOwner, - ) { - if behavior == tree.DropCascade { - dropCascadeDescriptor(b, so.SequenceID) - } else { - dropRestrictDescriptor(b, so.SequenceID) - undroppedBackrefsToCheck.Add(so.SequenceID) - b.Drop(so) - } - }) - // TODO(ajwerner): Track the undropped backrefs to populate a detail - // message like postgres does. For example: - // - // create table t (i serial); - // create table t2 (i int default nextval('t_i_seq'::regclass)); - // drop table t restrict; - // ERROR: cannot drop table t because other objects depend on it - // DETAIL: default value for column i of table t2 depends on sequence t_i_seq - // HINT: Use DROP ... CASCADE to drop the dependent objects too. - // - var hasUndroppedBackrefs bool - undroppedBackrefsToCheck.ForEach(func(seqID descpb.ID) { - udr := undroppedBackrefs(b, seqID) - if !udr.IsEmpty() { - hasUndroppedBackrefs = true - } - }) - _, _, cn := scpb.FindColumnName(colElts) - if hasUndroppedBackrefs { - panic(pgerror.Newf(pgcode.DependentObjectsStillExist, - "cannot drop column %s because other objects depend on it", cn.Name)) - } -} - -func handleDropColumnViewBackReferences( - b BuildCtx, - backrefs ElementResultSet, - col *scpb.Column, - cn *scpb.ColumnName, - dropBehavior tree.DropBehavior, -) { - var views []*scpb.View - scpb.ForEachView(backrefs, func(_ scpb.Status, _ scpb.TargetStatus, e *scpb.View) { - for _, ref := range e.ForwardReferences { - if ref.ToID == col.TableID && - catalog.MakeTableColSet(ref.ColumnIDs...).Contains(col.ColumnID) { - views = append(views, e) - } - } - }) - if len(views) == 0 { - return - } - if dropBehavior == tree.DropCascade { - for _, v := range views { - dropCascadeDescriptor(b, v.ViewID) - } - return - } - depView := views[0] - _, _, ns := scpb.FindNamespace(b.QueryByID(col.TableID)) - _, _, nsDep := scpb.FindNamespace(b.QueryByID(depView.ViewID)) - if nsDep.DatabaseID != ns.DatabaseID || nsDep.SchemaID != ns.SchemaID { - panic(errors.WithHintf(sqlerrors.NewDependentObjectErrorf( - "cannot drop column %q because view %q depends on it", - cn.Name, qualifiedName(b, depView.ViewID)), - "you can drop %s instead.", nsDep.Name)) - } - panic(sqlerrors.NewDependentObjectErrorf( - "cannot drop column %q because view %q depends on it", - cn.Name, nsDep.Name)) -} - -func handleDropColumnIndexes( - b BuildCtx, tn *tree.TableName, col *scpb.Column, dropBehavior tree.DropBehavior, -) { - tableElts := b.QueryByID(col.TableID).Filter(publicTargetFilter) - var indexIDs catid.IndexSet - scpb.ForEachIndexColumn(tableElts, func( - _ scpb.Status, _ scpb.TargetStatus, e *scpb.IndexColumn, - ) { - if e.ColumnID == col.ColumnID { - indexIDs.Add(e.IndexID) - } - }) - scpb.ForEachSecondaryIndexPartial(tableElts, func( - current scpb.Status, target scpb.TargetStatus, e *scpb.SecondaryIndexPartial, - ) { - if descpb.ColumnIDs.Contains(e.ReferencedColumnIDs, col.ColumnID) { - indexIDs.Add(e.IndexID) - } - }) - var secondaryIndexIDs catid.IndexSet - var indexes []*scpb.SecondaryIndex - var indexNames []*scpb.IndexName - scpb.ForEachSecondaryIndex(tableElts, func( - _ scpb.Status, _ scpb.TargetStatus, e *scpb.SecondaryIndex, - ) { - if indexIDs.Contains(e.IndexID) { - secondaryIndexIDs.Add(e.IndexID) - indexes = append(indexes, e) - } - }) - scpb.ForEachIndexName(tableElts, func( - _ scpb.Status, _ scpb.TargetStatus, e *scpb.IndexName, - ) { - if secondaryIndexIDs.Contains(e.IndexID) { - indexNames = append(indexNames, e) - } - }) - if len(indexNames) != len(indexes) { - panic(errors.AssertionFailedf("indexes %v does not match indexNames %v", - indexes, indexNames)) - } - sort.Slice(indexes, func(i, j int) bool { - return indexes[i].IndexID < indexes[j].IndexID - }) - sort.Slice(indexNames, func(i, j int) bool { - return indexNames[i].IndexID < indexNames[j].IndexID - }) - for i, idx := range indexes { - name := tree.TableIndexName{ - Table: *tn, - Index: tree.UnrestrictedName(indexNames[i].Name), - } - indexElts := tableElts.Filter(func( - current scpb.Status, target scpb.TargetStatus, e scpb.Element, - ) bool { - idI, _ := screl.Schema.GetAttribute(screl.IndexID, e) - return idI != nil && idI.(catid.IndexID) == idx.IndexID - }) - dropSecondaryIndex(b, &name, dropBehavior, idx, indexElts) - } -} - func assertAllColumnElementsAreDropped(colElts ElementResultSet) { if stillPublic := colElts.Filter(publicTargetFilter); !stillPublic.IsEmpty() { var elements []scpb.Element diff --git a/pkg/sql/schemachanger/scbuild/internal/scbuildstmt/helpers.go b/pkg/sql/schemachanger/scbuild/internal/scbuildstmt/helpers.go index 7f898069537b..ac04c9e4db45 100644 --- a/pkg/sql/schemachanger/scbuild/internal/scbuildstmt/helpers.go +++ b/pkg/sql/schemachanger/scbuild/internal/scbuildstmt/helpers.go @@ -24,6 +24,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/screl" "github.com/cockroachdb/cockroach/pkg/sql/sem/catid" "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" + "github.com/cockroachdb/cockroach/pkg/util/protoutil" "github.com/cockroachdb/errors" ) @@ -325,6 +326,10 @@ func absentTargetFilter(_ scpb.Status, target scpb.TargetStatus, _ scpb.Element) return target == scpb.ToAbsent } +func notAbsentTargetFilter(_ scpb.Status, target scpb.TargetStatus, _ scpb.Element) bool { + return target != scpb.ToAbsent +} + func statusAbsentOrBackfillOnlyFilter( status scpb.Status, _ scpb.TargetStatus, _ scpb.Element, ) bool { @@ -335,6 +340,38 @@ func statusPublicFilter(status scpb.Status, _ scpb.TargetStatus, _ scpb.Element) return status == scpb.Status_PUBLIC } +func hasIndexIDAttrFilter( + indexID catid.IndexID, +) func(_ scpb.Status, _ scpb.TargetStatus, _ scpb.Element) bool { + return func(_ scpb.Status, _ scpb.TargetStatus, e scpb.Element) (included bool) { + idI, _ := screl.Schema.GetAttribute(screl.IndexID, e) + return idI != nil && idI.(catid.IndexID) == indexID + } +} + +func hasColumnIDAttrFilter( + columnID catid.ColumnID, +) func(_ scpb.Status, _ scpb.TargetStatus, _ scpb.Element) bool { + return func(_ scpb.Status, _ scpb.TargetStatus, e scpb.Element) (included bool) { + idI, _ := screl.Schema.GetAttribute(screl.ColumnID, e) + return idI != nil && idI.(catid.ColumnID) == columnID + } +} + +func referencesColumnIDFilter( + columnID catid.ColumnID, +) func(_ scpb.Status, _ scpb.TargetStatus, _ scpb.Element) bool { + return func(_ scpb.Status, _ scpb.TargetStatus, e scpb.Element) (included bool) { + _ = screl.WalkColumnIDs(e, func(id *catid.ColumnID) error { + if id != nil && *id == columnID { + included = true + } + return nil + }) + return included + } +} + // getPrimaryIndexes returns the primary indexes of the current table. // Note that it assumes that there are at most two primary indexes and at // least one. The existing primary index is the primary index which is @@ -370,3 +407,147 @@ func indexColumnDirection(d tree.Direction) catpb.IndexColumn_Direction { panic(errors.AssertionFailedf("unknown direction %s", d)) } } + +// primaryIndexSpec holds a primary index element and its children. +type primaryIndexSpec struct { + idx *scpb.PrimaryIndex + name *scpb.IndexName + partitioning *scpb.IndexPartitioning + columns []*scpb.IndexColumn +} + +// apply makes it possible to conveniently define build targets for all +// the elements in the primaryIndexSpec. +func (s primaryIndexSpec) apply(fn func(e scpb.Element)) { + fn(s.idx) + if s.name != nil { + fn(s.name) + } + if s.partitioning != nil { + fn(s.partitioning) + } + for _, ic := range s.columns { + fn(ic) + } +} + +// clone conveniently deep-copies all the elements in the primaryIndexSpec. +func (s primaryIndexSpec) clone() (c primaryIndexSpec) { + c.idx = protoutil.Clone(s.idx).(*scpb.PrimaryIndex) + if s.name != nil { + c.name = protoutil.Clone(s.name).(*scpb.IndexName) + } + if s.partitioning != nil { + c.partitioning = protoutil.Clone(s.partitioning).(*scpb.IndexPartitioning) + } + for _, ic := range s.columns { + c.columns = append(c.columns, protoutil.Clone(ic).(*scpb.IndexColumn)) + } + return c +} + +// makePrimaryIndexSpec constructs a primaryIndexSpec based on an existing +// scpb.PrimaryIndex element. +func makePrimaryIndexSpec(b BuildCtx, idx *scpb.PrimaryIndex) (s primaryIndexSpec) { + s.idx = idx + publicIdxTargets := b.QueryByID(idx.TableID).Filter(publicTargetFilter).Filter(hasIndexIDAttrFilter(idx.IndexID)) + _, _, s.name = scpb.FindIndexName(publicIdxTargets) + _, _, s.partitioning = scpb.FindIndexPartitioning(publicIdxTargets) + scpb.ForEachIndexColumn(publicIdxTargets, func(_ scpb.Status, _ scpb.TargetStatus, ic *scpb.IndexColumn) { + s.columns = append(s.columns, ic) + }) + return s +} + +// tempIndexSpec holds a temporary index element and its children. +type tempIndexSpec struct { + idx *scpb.TemporaryIndex + partitioning *scpb.IndexPartitioning + columns []*scpb.IndexColumn +} + +// apply makes it possible to conveniently define build targets for all +// the elements in the tempIndexSpec. +func (s tempIndexSpec) apply(fn func(e scpb.Element)) { + fn(s.idx) + if s.partitioning != nil { + fn(s.partitioning) + } + for _, ic := range s.columns { + fn(ic) + } +} + +// indexColumnSpec specifies how to construct a scpb.IndexColumn element. +type indexColumnSpec struct { + columnID catid.ColumnID + kind scpb.IndexColumn_Kind + direction catpb.IndexColumn_Direction +} + +func makeIndexColumnSpec(ic *scpb.IndexColumn) indexColumnSpec { + return indexColumnSpec{ + columnID: ic.ColumnID, + kind: ic.Kind, + direction: ic.Direction, + } +} + +// makeSwapPrimaryIndexSpec constructs a primaryIndexSpec and an accompanying +// tempIndexSpec to swap out an existing primary index with. +func makeSwapPrimaryIndexSpec( + b BuildCtx, out primaryIndexSpec, inColumns []indexColumnSpec, +) (in primaryIndexSpec, temp tempIndexSpec) { + var inID, tempID catid.IndexID + var inConstraintID, tempConstraintID catid.ConstraintID + { + _, _, tbl := scpb.FindTable(b.QueryByID(out.idx.TableID).Filter(notAbsentTargetFilter)) + inID = b.NextTableIndexID(tbl) + inConstraintID = b.NextTableConstraintID(tbl.TableID) + tempID = inID + 1 + tempConstraintID = inConstraintID + 1 + } + { + in = out.clone() + in.idx.IndexID = inID + in.idx.SourceIndexID = out.idx.IndexID + in.idx.TemporaryIndexID = tempID + in.idx.ConstraintID = inConstraintID + if in.name != nil { + in.name.IndexID = inID + } + if in.partitioning != nil { + in.partitioning.IndexID = inID + } + m := make(map[scpb.IndexColumn_Kind]uint32) + in.columns = in.columns[:0] + for _, cs := range inColumns { + ordinalInKind := m[cs.kind] + m[cs.kind] = ordinalInKind + 1 + in.columns = append(in.columns, &scpb.IndexColumn{ + TableID: in.idx.TableID, + IndexID: inID, + ColumnID: cs.columnID, + OrdinalInKind: ordinalInKind, + Kind: cs.kind, + Direction: cs.direction, + }) + } + } + { + s := in.clone() + temp.idx = &scpb.TemporaryIndex{Index: s.idx.Index} + temp.idx.IndexID = tempID + temp.idx.TemporaryIndexID = 0 + temp.idx.ConstraintID = tempConstraintID + if s.partitioning != nil { + temp.partitioning = s.partitioning + temp.partitioning.IndexID = tempID + } + for _, ic := range s.columns { + ic.IndexID = tempID + } + temp.columns = s.columns + } + return in, temp +} diff --git a/pkg/sql/schemachanger/scbuild/testdata/alter_table_add_column b/pkg/sql/schemachanger/scbuild/testdata/alter_table_add_column index 349915642395..aeee5d1d00bf 100644 --- a/pkg/sql/schemachanger/scbuild/testdata/alter_table_add_column +++ b/pkg/sql/schemachanger/scbuild/testdata/alter_table_add_column @@ -31,19 +31,19 @@ ALTER TABLE defaultdb.foo ADD COLUMN j INT NOT NULL DEFAULT 123 {columnId: 2, tableId: 104, type: {family: IntFamily, oid: 20, width: 64}} - [[ColumnDefaultExpression:{DescID: 104, ColumnID: 2}, PUBLIC], ABSENT] {columnId: 2, expr: '123:::INT8', tableId: 104} -- [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2}, PUBLIC], ABSENT] - {columnId: 1, indexId: 2, tableId: 104} -- [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2}, PUBLIC], ABSENT] - {columnId: 2, indexId: 2, kind: STORED, tableId: 104} - [[PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC], ABSENT] {constraintId: 2, indexId: 2, isUnique: true, sourceIndexId: 1, tableId: 104, temporaryIndexId: 3} - [[IndexName:{DescID: 104, Name: foo_pkey, IndexID: 2}, PUBLIC], ABSENT] {indexId: 2, name: foo_pkey, tableId: 104} +- [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2}, PUBLIC], ABSENT] + {columnId: 1, indexId: 2, tableId: 104} +- [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2}, PUBLIC], ABSENT] + {columnId: 2, indexId: 2, kind: STORED, tableId: 104} - [[TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], ABSENT] {constraintId: 3, indexId: 3, isUnique: true, sourceIndexId: 1, tableId: 104} -- [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3}, PUBLIC], ABSENT] +- [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3}, TRANSIENT_ABSENT], ABSENT] {columnId: 1, indexId: 3, tableId: 104} -- [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3}, PUBLIC], ABSENT] +- [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3}, TRANSIENT_ABSENT], ABSENT] {columnId: 2, indexId: 3, kind: STORED, tableId: 104} build @@ -64,19 +64,19 @@ ALTER TABLE defaultdb.foo ADD COLUMN k INT DEFAULT 456; {columnId: 2, isNullable: true, tableId: 104, type: {family: IntFamily, oid: 20, width: 64}} - [[ColumnDefaultExpression:{DescID: 104, ColumnID: 2}, PUBLIC], ABSENT] {columnId: 2, expr: '123:::INT8', tableId: 104} -- [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2}, PUBLIC], ABSENT] - {columnId: 1, indexId: 2, tableId: 104} -- [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2}, PUBLIC], ABSENT] - {columnId: 2, indexId: 2, kind: STORED, tableId: 104} - [[PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC], ABSENT] {constraintId: 2, indexId: 2, isUnique: true, sourceIndexId: 1, tableId: 104, temporaryIndexId: 3} - [[IndexName:{DescID: 104, Name: foo_pkey, IndexID: 2}, PUBLIC], ABSENT] {indexId: 2, name: foo_pkey, tableId: 104} +- [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2}, PUBLIC], ABSENT] + {columnId: 1, indexId: 2, tableId: 104} +- [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2}, PUBLIC], ABSENT] + {columnId: 2, indexId: 2, kind: STORED, tableId: 104} - [[TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], ABSENT] {constraintId: 3, indexId: 3, isUnique: true, sourceIndexId: 1, tableId: 104} -- [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3}, PUBLIC], ABSENT] +- [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3}, TRANSIENT_ABSENT], ABSENT] {columnId: 1, indexId: 3, tableId: 104} -- [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3}, PUBLIC], ABSENT] +- [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3}, TRANSIENT_ABSENT], ABSENT] {columnId: 2, indexId: 3, kind: STORED, tableId: 104} - [[Column:{DescID: 104, ColumnID: 3}, PUBLIC], ABSENT] {columnId: 3, pgAttributeNum: 3, tableId: 104} @@ -106,19 +106,19 @@ ALTER TABLE defaultdb.foo ADD COLUMN a INT AS (i+1) STORED {columnId: 2, name: a, tableId: 104} - [[ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2}, PUBLIC], ABSENT] {columnId: 2, computeExpr: {expr: 'i + 1:::INT8'}, isNullable: true, tableId: 104, type: {family: IntFamily, oid: 20, width: 64}} -- [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2}, PUBLIC], ABSENT] - {columnId: 1, indexId: 2, tableId: 104} -- [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2}, PUBLIC], ABSENT] - {columnId: 2, indexId: 2, kind: STORED, tableId: 104} - [[PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC], ABSENT] {constraintId: 2, indexId: 2, isUnique: true, sourceIndexId: 1, tableId: 104, temporaryIndexId: 3} - [[IndexName:{DescID: 104, Name: foo_pkey, IndexID: 2}, PUBLIC], ABSENT] {indexId: 2, name: foo_pkey, tableId: 104} +- [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2}, PUBLIC], ABSENT] + {columnId: 1, indexId: 2, tableId: 104} +- [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2}, PUBLIC], ABSENT] + {columnId: 2, indexId: 2, kind: STORED, tableId: 104} - [[TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], ABSENT] {constraintId: 3, indexId: 3, isUnique: true, sourceIndexId: 1, tableId: 104} -- [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3}, PUBLIC], ABSENT] +- [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3}, TRANSIENT_ABSENT], ABSENT] {columnId: 1, indexId: 3, tableId: 104} -- [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3}, PUBLIC], ABSENT] +- [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3}, TRANSIENT_ABSENT], ABSENT] {columnId: 2, indexId: 3, kind: STORED, tableId: 104} setup @@ -161,19 +161,19 @@ ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (j) {constraintId: 1, indexId: 1, isUnique: true, tableId: 106} - [[IndexName:{DescID: 106, Name: t_pkey, IndexID: 1}, ABSENT], PUBLIC] {indexId: 1, name: t_pkey, tableId: 106} -- [[IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2}, PUBLIC], ABSENT] - {columnId: 2, indexId: 2, tableId: 106} -- [[IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2}, PUBLIC], ABSENT] - {columnId: 1, indexId: 2, kind: STORED, tableId: 106} - [[PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC], ABSENT] {constraintId: 2, indexId: 2, isUnique: true, sourceIndexId: 1, tableId: 106, temporaryIndexId: 3} - [[IndexName:{DescID: 106, Name: t_pkey, IndexID: 2}, PUBLIC], ABSENT] {indexId: 2, name: t_pkey, tableId: 106} +- [[IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2}, PUBLIC], ABSENT] + {columnId: 2, indexId: 2, tableId: 106} +- [[IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2}, PUBLIC], ABSENT] + {columnId: 1, indexId: 2, kind: STORED, tableId: 106} - [[TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], ABSENT] {constraintId: 3, indexId: 3, isUnique: true, sourceIndexId: 1, tableId: 106} -- [[IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3}, PUBLIC], ABSENT] +- [[IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3}, TRANSIENT_ABSENT], ABSENT] {columnId: 2, indexId: 3, tableId: 106} -- [[IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3}, PUBLIC], ABSENT] +- [[IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3}, TRANSIENT_ABSENT], ABSENT] {columnId: 1, indexId: 3, kind: STORED, tableId: 106} - [[SecondaryIndex:{DescID: 106, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1}, PUBLIC], ABSENT] {constraintId: 4, indexId: 4, isUnique: true, sourceIndexId: 1, tableId: 106, temporaryIndexId: 5} diff --git a/pkg/sql/schemachanger/scbuild/testdata/alter_table_alter_primary_key b/pkg/sql/schemachanger/scbuild/testdata/alter_table_alter_primary_key new file mode 100644 index 000000000000..e037c30ec85a --- /dev/null +++ b/pkg/sql/schemachanger/scbuild/testdata/alter_table_alter_primary_key @@ -0,0 +1,88 @@ +setup +CREATE TABLE defaultdb.foo (i INT PRIMARY KEY, j INT NOT NULL); +CREATE TABLE defaultdb.bar (i INT NOT NULL); +---- + +build +ALTER TABLE defaultdb.foo ALTER PRIMARY KEY USING COLUMNS (j) +---- +- [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1}, ABSENT], PUBLIC] + {columnId: 1, indexId: 1, tableId: 104} +- [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1}, ABSENT], PUBLIC] + {columnId: 2, indexId: 1, kind: STORED, tableId: 104} +- [[PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1}, ABSENT], PUBLIC] + {constraintId: 1, indexId: 1, isUnique: true, tableId: 104} +- [[IndexName:{DescID: 104, Name: foo_pkey, IndexID: 1}, ABSENT], PUBLIC] + {indexId: 1, name: foo_pkey, tableId: 104} +- [[PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC], ABSENT] + {constraintId: 2, indexId: 2, isUnique: true, sourceIndexId: 1, tableId: 104, temporaryIndexId: 3} +- [[IndexName:{DescID: 104, Name: foo_pkey, IndexID: 2}, PUBLIC], ABSENT] + {indexId: 2, name: foo_pkey, tableId: 104} +- [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2}, PUBLIC], ABSENT] + {columnId: 2, indexId: 2, tableId: 104} +- [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2}, PUBLIC], ABSENT] + {columnId: 1, indexId: 2, kind: STORED, tableId: 104} +- [[TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], ABSENT] + {constraintId: 3, indexId: 3, isUnique: true, sourceIndexId: 1, tableId: 104} +- [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3}, TRANSIENT_ABSENT], ABSENT] + {columnId: 2, indexId: 3, tableId: 104} +- [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3}, TRANSIENT_ABSENT], ABSENT] + {columnId: 1, indexId: 3, kind: STORED, tableId: 104} +- [[SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1}, PUBLIC], ABSENT] + {constraintId: 4, indexId: 4, isUnique: true, sourceIndexId: 1, tableId: 104, temporaryIndexId: 5} +- [[TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 1}, TRANSIENT_ABSENT], ABSENT] + {constraintId: 5, indexId: 5, isUnique: true, isUsingSecondaryEncoding: true, sourceIndexId: 1, tableId: 104} +- [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4}, PUBLIC], ABSENT] + {columnId: 1, indexId: 4, tableId: 104} +- [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5}, PUBLIC], ABSENT] + {columnId: 1, indexId: 5, tableId: 104} +- [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 4}, PUBLIC], ABSENT] + {columnId: 2, indexId: 4, kind: KEY_SUFFIX, tableId: 104} +- [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 5}, PUBLIC], ABSENT] + {columnId: 2, indexId: 5, kind: KEY_SUFFIX, tableId: 104} +- [[IndexName:{DescID: 104, Name: foo_i_key, IndexID: 4}, PUBLIC], ABSENT] + {indexId: 4, name: foo_i_key, tableId: 104} + +build +ALTER TABLE defaultdb.bar ALTER PRIMARY KEY USING COLUMNS (i) +---- +- [[Column:{DescID: 105, ColumnID: 2}, ABSENT], PUBLIC] + {columnId: 2, isHidden: true, pgAttributeNum: 2, tableId: 105} +- [[ColumnName:{DescID: 105, Name: rowid, ColumnID: 2}, ABSENT], PUBLIC] + {columnId: 2, name: rowid, tableId: 105} +- [[ColumnType:{DescID: 105, ColumnFamilyID: 0, ColumnID: 2}, ABSENT], PUBLIC] + {columnId: 2, tableId: 105, type: {family: IntFamily, oid: 20, width: 64}} +- [[ColumnDefaultExpression:{DescID: 105, ColumnID: 2}, ABSENT], PUBLIC] + {columnId: 2, expr: unique_rowid(), tableId: 105} +- [[IndexColumn:{DescID: 105, ColumnID: 2, IndexID: 1}, ABSENT], PUBLIC] + {columnId: 2, indexId: 1, tableId: 105} +- [[IndexColumn:{DescID: 105, ColumnID: 1, IndexID: 1}, ABSENT], PUBLIC] + {columnId: 1, indexId: 1, kind: STORED, tableId: 105} +- [[PrimaryIndex:{DescID: 105, IndexID: 1, ConstraintID: 1}, ABSENT], PUBLIC] + {constraintId: 1, indexId: 1, isUnique: true, tableId: 105} +- [[IndexName:{DescID: 105, Name: bar_pkey, IndexID: 1}, ABSENT], PUBLIC] + {indexId: 1, name: bar_pkey, tableId: 105} +- [[PrimaryIndex:{DescID: 105, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], ABSENT] + {constraintId: 2, indexId: 2, isUnique: true, sourceIndexId: 1, tableId: 105, temporaryIndexId: 3} +- [[IndexName:{DescID: 105, Name: bar_pkey, IndexID: 2}, TRANSIENT_ABSENT], ABSENT] + {indexId: 2, name: bar_pkey, tableId: 105} +- [[IndexColumn:{DescID: 105, ColumnID: 1, IndexID: 2}, TRANSIENT_ABSENT], ABSENT] + {columnId: 1, indexId: 2, tableId: 105} +- [[IndexColumn:{DescID: 105, ColumnID: 2, IndexID: 2}, TRANSIENT_ABSENT], ABSENT] + {columnId: 2, indexId: 2, kind: STORED, tableId: 105} +- [[TemporaryIndex:{DescID: 105, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], ABSENT] + {constraintId: 3, indexId: 3, isUnique: true, sourceIndexId: 1, tableId: 105} +- [[IndexColumn:{DescID: 105, ColumnID: 1, IndexID: 3}, TRANSIENT_ABSENT], ABSENT] + {columnId: 1, indexId: 3, tableId: 105} +- [[IndexColumn:{DescID: 105, ColumnID: 2, IndexID: 3}, TRANSIENT_ABSENT], ABSENT] + {columnId: 2, indexId: 3, kind: STORED, tableId: 105} +- [[PrimaryIndex:{DescID: 105, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2}, PUBLIC], ABSENT] + {constraintId: 4, indexId: 4, isUnique: true, sourceIndexId: 2, tableId: 105, temporaryIndexId: 5} +- [[IndexName:{DescID: 105, Name: bar_pkey, IndexID: 4}, PUBLIC], ABSENT] + {indexId: 4, name: bar_pkey, tableId: 105} +- [[IndexColumn:{DescID: 105, ColumnID: 1, IndexID: 4}, PUBLIC], ABSENT] + {columnId: 1, indexId: 4, tableId: 105} +- [[TemporaryIndex:{DescID: 105, IndexID: 5, ConstraintID: 5, SourceIndexID: 2}, TRANSIENT_ABSENT], ABSENT] + {constraintId: 5, indexId: 5, isUnique: true, sourceIndexId: 2, tableId: 105} +- [[IndexColumn:{DescID: 105, ColumnID: 1, IndexID: 5}, TRANSIENT_ABSENT], ABSENT] + {columnId: 1, indexId: 5, tableId: 105} diff --git a/pkg/sql/schemachanger/scbuild/testdata/alter_table_drop_column b/pkg/sql/schemachanger/scbuild/testdata/alter_table_drop_column index cc607e45e772..b1546fbb792c 100644 --- a/pkg/sql/schemachanger/scbuild/testdata/alter_table_drop_column +++ b/pkg/sql/schemachanger/scbuild/testdata/alter_table_drop_column @@ -51,23 +51,23 @@ ALTER TABLE defaultdb.t DROP COLUMN j {indexId: 3, tableId: 104} - [[IndexName:{DescID: 104, Name: t_j_k_idx, IndexID: 3}, ABSENT], PUBLIC] {indexId: 3, name: t_j_k_idx, tableId: 104} +- [[PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 2, TemporaryIndexID: 5, SourceIndexID: 1}, PUBLIC], ABSENT] + {constraintId: 2, indexId: 4, isUnique: true, sourceIndexId: 1, tableId: 104, temporaryIndexId: 5} +- [[IndexName:{DescID: 104, Name: t_pkey, IndexID: 4}, PUBLIC], ABSENT] + {indexId: 4, name: t_pkey, tableId: 104} - [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4}, PUBLIC], ABSENT] {columnId: 1, indexId: 4, tableId: 104} - [[IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4}, PUBLIC], ABSENT] {columnId: 3, indexId: 4, kind: STORED, tableId: 104} - [[IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 4}, PUBLIC], ABSENT] {columnId: 4, indexId: 4, kind: STORED, ordinalInKind: 1, tableId: 104} -- [[PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 2, TemporaryIndexID: 5, SourceIndexID: 1}, PUBLIC], ABSENT] - {constraintId: 2, indexId: 4, isUnique: true, sourceIndexId: 1, tableId: 104, temporaryIndexId: 5} -- [[IndexName:{DescID: 104, Name: t_pkey, IndexID: 4}, PUBLIC], ABSENT] - {indexId: 4, name: t_pkey, tableId: 104} - [[TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], ABSENT] {constraintId: 3, indexId: 5, isUnique: true, sourceIndexId: 1, tableId: 104} -- [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5}, PUBLIC], ABSENT] +- [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5}, TRANSIENT_ABSENT], ABSENT] {columnId: 1, indexId: 5, tableId: 104} -- [[IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 5}, PUBLIC], ABSENT] +- [[IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 5}, TRANSIENT_ABSENT], ABSENT] {columnId: 3, indexId: 5, kind: STORED, tableId: 104} -- [[IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 5}, PUBLIC], ABSENT] +- [[IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 5}, TRANSIENT_ABSENT], ABSENT] {columnId: 4, indexId: 5, kind: STORED, ordinalInKind: 1, tableId: 104} build @@ -101,23 +101,23 @@ ALTER TABLE defaultdb.t DROP COLUMN k {indexId: 3, tableId: 104} - [[IndexName:{DescID: 104, Name: t_j_k_idx, IndexID: 3}, ABSENT], PUBLIC] {indexId: 3, name: t_j_k_idx, tableId: 104} +- [[PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 2, TemporaryIndexID: 5, SourceIndexID: 1}, PUBLIC], ABSENT] + {constraintId: 2, indexId: 4, isUnique: true, sourceIndexId: 1, tableId: 104, temporaryIndexId: 5} +- [[IndexName:{DescID: 104, Name: t_pkey, IndexID: 4}, PUBLIC], ABSENT] + {indexId: 4, name: t_pkey, tableId: 104} - [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4}, PUBLIC], ABSENT] {columnId: 1, indexId: 4, tableId: 104} - [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 4}, PUBLIC], ABSENT] {columnId: 2, indexId: 4, kind: STORED, tableId: 104} - [[IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 4}, PUBLIC], ABSENT] {columnId: 4, indexId: 4, kind: STORED, ordinalInKind: 1, tableId: 104} -- [[PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 2, TemporaryIndexID: 5, SourceIndexID: 1}, PUBLIC], ABSENT] - {constraintId: 2, indexId: 4, isUnique: true, sourceIndexId: 1, tableId: 104, temporaryIndexId: 5} -- [[IndexName:{DescID: 104, Name: t_pkey, IndexID: 4}, PUBLIC], ABSENT] - {indexId: 4, name: t_pkey, tableId: 104} - [[TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], ABSENT] {constraintId: 3, indexId: 5, isUnique: true, sourceIndexId: 1, tableId: 104} -- [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5}, PUBLIC], ABSENT] +- [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5}, TRANSIENT_ABSENT], ABSENT] {columnId: 1, indexId: 5, tableId: 104} -- [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 5}, PUBLIC], ABSENT] +- [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 5}, TRANSIENT_ABSENT], ABSENT] {columnId: 2, indexId: 5, kind: STORED, tableId: 104} -- [[IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 5}, PUBLIC], ABSENT] +- [[IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 5}, TRANSIENT_ABSENT], ABSENT] {columnId: 4, indexId: 5, kind: STORED, ordinalInKind: 1, tableId: 104} build @@ -157,21 +157,21 @@ ALTER TABLE defaultdb.t DROP COLUMN l {sequenceId: 105} - [[ObjectParent:{DescID: 105, ReferencedDescID: 101}, ABSENT], PUBLIC] {objectId: 105, parentSchemaId: 101} +- [[PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 2, TemporaryIndexID: 5, SourceIndexID: 1}, PUBLIC], ABSENT] + {constraintId: 2, indexId: 4, isUnique: true, sourceIndexId: 1, tableId: 104, temporaryIndexId: 5} +- [[IndexName:{DescID: 104, Name: t_pkey, IndexID: 4}, PUBLIC], ABSENT] + {indexId: 4, name: t_pkey, tableId: 104} - [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4}, PUBLIC], ABSENT] {columnId: 1, indexId: 4, tableId: 104} - [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 4}, PUBLIC], ABSENT] {columnId: 2, indexId: 4, kind: STORED, tableId: 104} - [[IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4}, PUBLIC], ABSENT] {columnId: 3, indexId: 4, kind: STORED, ordinalInKind: 1, tableId: 104} -- [[PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 2, TemporaryIndexID: 5, SourceIndexID: 1}, PUBLIC], ABSENT] - {constraintId: 2, indexId: 4, isUnique: true, sourceIndexId: 1, tableId: 104, temporaryIndexId: 5} -- [[IndexName:{DescID: 104, Name: t_pkey, IndexID: 4}, PUBLIC], ABSENT] - {indexId: 4, name: t_pkey, tableId: 104} - [[TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], ABSENT] {constraintId: 3, indexId: 5, isUnique: true, sourceIndexId: 1, tableId: 104} -- [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5}, PUBLIC], ABSENT] +- [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5}, TRANSIENT_ABSENT], ABSENT] {columnId: 1, indexId: 5, tableId: 104} -- [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 5}, PUBLIC], ABSENT] +- [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 5}, TRANSIENT_ABSENT], ABSENT] {columnId: 2, indexId: 5, kind: STORED, tableId: 104} -- [[IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 5}, PUBLIC], ABSENT] +- [[IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 5}, TRANSIENT_ABSENT], ABSENT] {columnId: 3, indexId: 5, kind: STORED, ordinalInKind: 1, tableId: 104} diff --git a/pkg/sql/schemachanger/scbuild/testdata/unimplemented_alter_table b/pkg/sql/schemachanger/scbuild/testdata/unimplemented_alter_table index ce6dc16a0c29..c67a2380064d 100644 --- a/pkg/sql/schemachanger/scbuild/testdata/unimplemented_alter_table +++ b/pkg/sql/schemachanger/scbuild/testdata/unimplemented_alter_table @@ -4,7 +4,7 @@ CREATE TABLE defaultdb.foo ( i INT8 PRIMARY KEY, -- j gets added by the test k INT8 CHECK (k > 10), - l INT8 UNIQUE, + l INT8 NOT NULL UNIQUE, m INT8 REFERENCES foo (l), n UUID, UNIQUE WITHOUT INDEX (n), @@ -103,3 +103,7 @@ ALTER TABLE defaultdb.foo PARTITION BY NOTHING unimplemented ALTER TABLE defaultdb.foo INJECT STATISTICS '[]' ---- + +unimplemented +ALTER TABLE defaultdb.foo ALTER PRIMARY KEY USING COLUMNS (l) +---- diff --git a/pkg/sql/schemachanger/scexec/executor_external_test.go b/pkg/sql/schemachanger/scexec/executor_external_test.go index b1745d30ff37..10d8475d5388 100644 --- a/pkg/sql/schemachanger/scexec/executor_external_test.go +++ b/pkg/sql/schemachanger/scexec/executor_external_test.go @@ -285,21 +285,10 @@ func TestSchemaChanger(t *testing.T) { targets := []scpb.Target{ scpb.MakeTarget( scpb.ToPublic, - &scpb.IndexColumn{ - TableID: fooTable.GetID(), - IndexID: 1, - ColumnID: 2, - OrdinalInKind: 0, - Kind: scpb.IndexColumn_STORED, - }, - metadata, - ), - scpb.MakeTarget( - scpb.ToPublic, - &scpb.ColumnName{ - TableID: fooTable.GetID(), - ColumnID: 2, - Name: "j", + &scpb.Column{ + TableID: fooTable.GetID(), + ColumnID: 2, + PgAttributeNum: 2, }, metadata, ), @@ -315,10 +304,21 @@ func TestSchemaChanger(t *testing.T) { ), scpb.MakeTarget( scpb.ToPublic, - &scpb.Column{ - TableID: fooTable.GetID(), - ColumnID: 2, - PgAttributeNum: 2, + &scpb.ColumnName{ + TableID: fooTable.GetID(), + ColumnID: 2, + Name: "j", + }, + metadata, + ), + scpb.MakeTarget( + scpb.ToPublic, + &scpb.IndexColumn{ + TableID: fooTable.GetID(), + IndexID: 1, + ColumnID: 2, + OrdinalInKind: 0, + Kind: scpb.IndexColumn_STORED, }, metadata, ), diff --git a/pkg/sql/schemachanger/scexec/scmutationexec/index.go b/pkg/sql/schemachanger/scexec/scmutationexec/index.go index 11d023f32f25..4167c53dd13f 100644 --- a/pkg/sql/schemachanger/scexec/scmutationexec/index.go +++ b/pkg/sql/schemachanger/scexec/scmutationexec/index.go @@ -424,12 +424,6 @@ func (m *visitor) RemoveColumnFromIndex(ctx context.Context, op scop.RemoveColum if err != nil { return err } - // As a special case, avoid removing any columns from dropped indexes. - // The index is going to be removed, so it doesn't matter if it references - // dropped columns. - if index.Dropped() { - return nil - } column, err := tbl.FindColumnWithID(op.ColumnID) if err != nil { return err diff --git a/pkg/sql/schemachanger/scpb/scpb.proto b/pkg/sql/schemachanger/scpb/scpb.proto index c2db7a4df5f2..50a369c6da7d 100644 --- a/pkg/sql/schemachanger/scpb/scpb.proto +++ b/pkg/sql/schemachanger/scpb/scpb.proto @@ -53,6 +53,12 @@ enum Status { // Intermediate states on the transient index dropping path TRANSIENT_DELETE_ONLY = 13; TRANSIENT_WRITE_ONLY = 14; + TRANSIENT_BACKFILL_ONLY = 16; + TRANSIENT_BACKFILLED = 17; + TRANSIENT_MERGE_ONLY = 18; + TRANSIENT_MERGED = 19; + TRANSIENT_VALIDATED = 20; + TRANSIENT_PUBLIC = 21; } // TargetMetadata refers to the metadata for individual elements, where diff --git a/pkg/sql/schemachanger/scpb/transient.go b/pkg/sql/schemachanger/scpb/transient.go index f47fda482a66..a5104266813d 100644 --- a/pkg/sql/schemachanger/scpb/transient.go +++ b/pkg/sql/schemachanger/scpb/transient.go @@ -19,7 +19,13 @@ func GetTransientEquivalent(s Status) (Status, bool) { } var transientEquivalent = map[Status]Status{ - Status_DELETE_ONLY: Status_TRANSIENT_DELETE_ONLY, - Status_WRITE_ONLY: Status_TRANSIENT_WRITE_ONLY, - Status_ABSENT: Status_TRANSIENT_ABSENT, + Status_DELETE_ONLY: Status_TRANSIENT_DELETE_ONLY, + Status_WRITE_ONLY: Status_TRANSIENT_WRITE_ONLY, + Status_ABSENT: Status_TRANSIENT_ABSENT, + Status_PUBLIC: Status_TRANSIENT_PUBLIC, + Status_BACKFILL_ONLY: Status_TRANSIENT_BACKFILL_ONLY, + Status_BACKFILLED: Status_TRANSIENT_BACKFILLED, + Status_MERGE_ONLY: Status_TRANSIENT_MERGE_ONLY, + Status_MERGED: Status_TRANSIENT_MERGED, + Status_VALIDATED: Status_TRANSIENT_VALIDATED, } diff --git a/pkg/sql/schemachanger/scplan/internal/opgen/opgen_index_column.go b/pkg/sql/schemachanger/scplan/internal/opgen/opgen_index_column.go index 0ae827350eaf..286ad6525726 100644 --- a/pkg/sql/schemachanger/scplan/internal/opgen/opgen_index_column.go +++ b/pkg/sql/schemachanger/scplan/internal/opgen/opgen_index_column.go @@ -30,6 +30,7 @@ func init() { } })), ), + toTransientAbsentLikePublic(), toAbsent( scpb.Status_PUBLIC, to(scpb.Status_ABSENT, diff --git a/pkg/sql/schemachanger/scplan/internal/opgen/opgen_index_name.go b/pkg/sql/schemachanger/scplan/internal/opgen/opgen_index_name.go index 01326f3c95af..fcb5496f50f5 100644 --- a/pkg/sql/schemachanger/scplan/internal/opgen/opgen_index_name.go +++ b/pkg/sql/schemachanger/scplan/internal/opgen/opgen_index_name.go @@ -31,6 +31,7 @@ func init() { }), ), ), + toTransientAbsentLikePublic(), toAbsent( scpb.Status_PUBLIC, to(scpb.Status_ABSENT, diff --git a/pkg/sql/schemachanger/scplan/internal/opgen/opgen_index_partitioning.go b/pkg/sql/schemachanger/scplan/internal/opgen/opgen_index_partitioning.go index bea597fbe76b..8b2439f5b228 100644 --- a/pkg/sql/schemachanger/scplan/internal/opgen/opgen_index_partitioning.go +++ b/pkg/sql/schemachanger/scplan/internal/opgen/opgen_index_partitioning.go @@ -38,6 +38,7 @@ func init() { }), ), ), + toTransientAbsentLikePublic(), toAbsent( scpb.Status_PUBLIC, to(scpb.Status_ABSENT), diff --git a/pkg/sql/schemachanger/scplan/internal/opgen/opgen_primary_index.go b/pkg/sql/schemachanger/scplan/internal/opgen/opgen_primary_index.go index 7cb9cd39cbf9..855d506c6d19 100644 --- a/pkg/sql/schemachanger/scplan/internal/opgen/opgen_primary_index.go +++ b/pkg/sql/schemachanger/scplan/internal/opgen/opgen_primary_index.go @@ -93,6 +93,7 @@ func init() { }), ), ), + toTransientAbsentLikePublic(), toAbsent( scpb.Status_PUBLIC, to(scpb.Status_VALIDATED, diff --git a/pkg/sql/schemachanger/scplan/internal/opgen/opgen_secondary_index_partial.go b/pkg/sql/schemachanger/scplan/internal/opgen/opgen_secondary_index_partial.go index 4435993cfae2..097d86deb3c1 100644 --- a/pkg/sql/schemachanger/scplan/internal/opgen/opgen_secondary_index_partial.go +++ b/pkg/sql/schemachanger/scplan/internal/opgen/opgen_secondary_index_partial.go @@ -38,6 +38,7 @@ func init() { }), ), ), + toTransientAbsentLikePublic(), toAbsent( scpb.Status_PUBLIC, to(scpb.Status_ABSENT, diff --git a/pkg/sql/schemachanger/scplan/internal/opgen/register.go b/pkg/sql/schemachanger/scplan/internal/opgen/register.go index 57785754d734..e86909da2b30 100644 --- a/pkg/sql/schemachanger/scplan/internal/opgen/register.go +++ b/pkg/sql/schemachanger/scplan/internal/opgen/register.go @@ -41,6 +41,10 @@ func toTransientAbsent(initalStatus scpb.Status, specs ...transitionSpec) target return asTargetSpec(scpb.Status_TRANSIENT_ABSENT, initalStatus, specs...) } +func toTransientAbsentLikePublic() targetSpec { + return asTargetSpec(scpb.Status_TRANSIENT_ABSENT, scpb.Status_ABSENT) +} + func asTargetSpec(to, from scpb.Status, specs ...transitionSpec) targetSpec { return targetSpec{from: from, to: to, transitionSpecs: specs} } @@ -53,22 +57,63 @@ func (r *registry) register(e scpb.Element, targetSpecs ...targetSpec) { panic(errors.NewAssertionErrorWithWrappedErrf(err, "element %T", e)) } } - - onErrPanic(expandTransientAbsentSpec(targetSpecs)) - targets, err := buildTargets(e, targetSpecs) + fullTargetSpecs, err := populateAndValidateSpecs(targetSpecs) + onErrPanic(err) + targets, err := buildTargets(e, fullTargetSpecs) onErrPanic(err) onErrPanic(validateTargets(targets)) r.targets = append(r.targets, targets...) } -// Expand the definition of the TRANSIENT_ABSENT targetSpec according to -// the transitions in the ABSENT targetSpec if they exist. -func expandTransientAbsentSpec(targetSpecs []targetSpec) error { - toAbsent, transient, err := findToAbsentAndTransient(targetSpecs) - if err != nil || transient == nil { - return err +func populateAndValidateSpecs(targetSpecs []targetSpec) ([]targetSpec, error) { + var absentSpec, publicSpec, transientSpec *targetSpec + for i := range targetSpecs { + s := &targetSpecs[i] + var p **targetSpec + switch s.to { + case scpb.Status_ABSENT: + p = &absentSpec + case scpb.Status_PUBLIC: + p = &publicSpec + case scpb.Status_TRANSIENT_ABSENT: + p = &transientSpec + default: + return nil, errors.Errorf("unsupported target %s", s.to) + } + if *p != nil { + return nil, errors.Errorf("duplicate %s spec", s.to) + } + if s.to != scpb.Status_ABSENT && s.from != scpb.Status_ABSENT { + return nil, errors.Errorf("expected %s spec to start in ABSENT, not %s", s.to, s.from) + } + *p = s + } + if absentSpec == nil { + return nil, errors.Errorf("ABSENT spec is missing but required") + } + if transientSpec != nil { + if publicSpec != nil && len(transientSpec.transitionSpecs) == 0 { + // Here we want the transient spec to be a copy of the public spec. + transientSpec.transitionSpecs = append(transientSpec.transitionSpecs, publicSpec.transitionSpecs...) + } + if err := populateTransientAbsent(absentSpec, transientSpec); err != nil { + return nil, err + } + } + specs := make([]targetSpec, 1, 3) + specs[0] = *absentSpec + if publicSpec != nil { + specs = append(specs, *publicSpec) + } + if transientSpec != nil { + specs = append(specs, *transientSpec) + } + for _, s := range specs { + if len(s.transitionSpecs) == 0 { + return nil, errors.Errorf("no transition specs found for %s spec", s.to) + } } - return populateTransientAbsent(toAbsent, transient) + return specs, nil } // populateTransientAbsent takes the targetSpecs to ABSENT and TRANSIENT_ABSENT @@ -78,14 +123,14 @@ func expandTransientAbsentSpec(targetSpecs []targetSpec) error { // with the status of the latter sequence containing the TRANSIENT_ prefix. // // Note that this function directly mutates the passed targetSpecs. -func populateTransientAbsent(toAbsent, transient *targetSpec) error { +func populateTransientAbsent(absentSpec, transientSpec *targetSpec) error { // Begin by finding the position in the ABSENT transition specs which match // the end of the existing TRANSIENT_ABSENT spec. - tts := transient.transitionSpecs - ats := toAbsent.transitionSpecs + ats := absentSpec.transitionSpecs + tts := transientSpec.transitionSpecs var startIdx int - if initial := tts[len(tts)-1].to; toAbsent.from != initial { + if initial := tts[len(tts)-1].to; absentSpec.from != initial { startIdx = findTransitionTo(ats, initial) + 1 if startIdx == 0 { return errors.AssertionFailedf( @@ -105,70 +150,33 @@ func populateTransientAbsent(toAbsent, transient *targetSpec) error { for i := startIdx; i < len(ats); i++ { next := ats[i] atsWithEquiv = append(atsWithEquiv, next) - - // NOTE: If the toAbsent transitions have any equiv definitions - // we'll fail to find them because we won't find a transient equivalent. - // For now, this is fine, but we may later need to decide to skip them or - // add them in some other way. - nextTo, ok := scpb.GetTransientEquivalent(next.to) - if !ok { - return errors.AssertionFailedf( - "failed to find transient equivalent for %v", next.to, - ) + if next.to == scpb.Status_UNKNOWN { + nextFrom, ok := scpb.GetTransientEquivalent(next.from) + if !ok { + return errors.AssertionFailedf( + "failed to find transient equivalent for 'from' %s", next.from, + ) + } + next.from = nextFrom + atsWithEquiv = append(atsWithEquiv, equiv(next.from)) + } else { + nextTo, ok := scpb.GetTransientEquivalent(next.to) + if !ok { + return errors.AssertionFailedf( + "failed to find transient equivalent for 'to' %s", next.to, + ) + } + next.to = nextTo + atsWithEquiv = append(atsWithEquiv, equiv(next.to)) } - next.to = nextTo tts = append(tts, next) - atsWithEquiv = append(atsWithEquiv, equiv(next.to)) } - transient.transitionSpecs = tts - toAbsent.transitionSpecs = atsWithEquiv + transientSpec.transitionSpecs = tts + absentSpec.transitionSpecs = atsWithEquiv return nil } -// findToAbsentAndTransient searches the slice of targetSpec for the two -// targets to ABSENT and TRANSIENT_ABSENT. An error is returned if either -// such target is defined more than once of if TRANSIENT_ABSENT is defined -// but ABSENT is not. If TRANSIENT_ABSENT is not defined, neither targetSpec -// will be returned; it is not an error for just ABSENT to be defined or -// for neither to be defined. -func findToAbsentAndTransient(specs []targetSpec) (toAbsent, transient *targetSpec, err error) { - findTargetSpec := func(to scpb.Status) (*targetSpec, error) { - i := findTargetSpecTo(specs, to) - if i == -1 { - return nil, nil - } - if also := findTargetSpecTo(specs[i+1:], to); also != -1 { - return nil, errors.Errorf("duplicate spec to %v", to) - } - return &specs[i], nil - } - if transient, err = findTargetSpec( - scpb.Status_TRANSIENT_ABSENT, - ); err != nil || transient == nil { - return nil, nil, err - } - if toAbsent, err = findTargetSpec(scpb.Status_ABSENT); err != nil { - return nil, nil, err - } - if toAbsent == nil { - return nil, nil, errors.AssertionFailedf( - "cannot have %v target without a %v target", - scpb.Status_TRANSIENT_ABSENT, scpb.Status_ABSENT, - ) - } - return toAbsent, transient, nil -} - -func findTargetSpecTo(haystack []targetSpec, needle scpb.Status) int { - for i, spec := range haystack { - if spec.to == needle { - return i - } - } - return -1 -} - func findTransitionTo(haystack []transitionSpec, needle scpb.Status) int { for i, transition := range haystack { if transition.from == needle { @@ -191,25 +199,29 @@ func buildTargets(e scpb.Element, targetSpecs []targetSpec) ([]target, error) { func validateTargets(targets []target) error { allStatuses := map[scpb.Status]bool{} - targetStatuses := make([]map[scpb.Status]bool, len(targets)) + absentStatuses := map[scpb.Status]bool{} + nonAbsentStatuses := map[scpb.Status]bool{} for i, tgt := range targets { - m := map[scpb.Status]bool{} + var m map[scpb.Status]bool + if i == 0 { + m = absentStatuses + } else { + m = nonAbsentStatuses + } for _, t := range tgt.transitions { m[t.from] = true allStatuses[t.from] = true m[t.to] = true allStatuses[t.to] = true } - targetStatuses[i] = m } - for i, tgt := range targets { - m := targetStatuses[i] - for s := range allStatuses { - if !m[s] { - return errors.Errorf("target %s: status %s is missing here but is featured in other targets", - tgt.status.String(), s.String()) - } + for s := range allStatuses { + if !absentStatuses[s] { + return errors.Errorf("status %s is featured in non-ABSENT targets but not in the ABSENT target", s) + } + if !nonAbsentStatuses[s] { + return errors.Errorf("status %s is featured in ABSENT target but not in any non-ABSENT targets", s) } } return nil diff --git a/pkg/sql/schemachanger/scplan/internal/rules/BUILD.bazel b/pkg/sql/schemachanger/scplan/internal/rules/BUILD.bazel index ba3c99c60b40..99eb03874764 100644 --- a/pkg/sql/schemachanger/scplan/internal/rules/BUILD.bazel +++ b/pkg/sql/schemachanger/scplan/internal/rules/BUILD.bazel @@ -4,12 +4,17 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "rules", srcs = [ - "dep_column.go", - "dep_drop.go", - "dep_index.go", - "dep_index_and_column.go", + "dep_add_column.go", + "dep_add_index.go", + "dep_add_index_and_column.go", + "dep_drop_column.go", + "dep_drop_index.go", + "dep_drop_index_and_column.go", + "dep_drop_object.go", + "dep_swap_index.go", "helpers.go", "op_drop.go", + "op_index_and_column.go", "registry.go", ], importpath = "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scplan/internal/rules", diff --git a/pkg/sql/schemachanger/scplan/internal/rules/dep_add_column.go b/pkg/sql/schemachanger/scplan/internal/rules/dep_add_column.go new file mode 100644 index 000000000000..a24cdc5f12a7 --- /dev/null +++ b/pkg/sql/schemachanger/scplan/internal/rules/dep_add_column.go @@ -0,0 +1,110 @@ +// Copyright 2022 The Cockroach Authors. +// +// Use of this software is governed by the Business Source License +// included in the file licenses/BSL.txt. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0, included in the file +// licenses/APL.txt. + +package rules + +import ( + "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/rel" + "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scpb" + "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scplan/internal/scgraph" + "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/screl" +) + +// These rules ensure that column-dependent elements, like a column's name, its +// DEFAULT expression, etc. appear once the column reaches a suitable state. +func init() { + + registerDepRule( + "column existence precedes column dependents", + scgraph.Precedence, + "column", "dependent", + func(from, to nodeVars) rel.Clauses { + return rel.Clauses{ + from.Type((*scpb.Column)(nil)), + to.typeFilter(isColumnDependent), + joinOnColumnID(from, to, "table-id", "col-id"), + statusesToPublicOrTransient(from, scpb.Status_DELETE_ONLY, to, scpb.Status_PUBLIC), + } + }, + ) + + registerDepRule( + "column dependents exist before column becomes public", + scgraph.Precedence, + "dependent", "column", + func(from, to nodeVars) rel.Clauses { + return rel.Clauses{ + from.typeFilter(isColumnDependent), + to.Type((*scpb.Column)(nil)), + joinOnColumnID(from, to, "table-id", "col-id"), + statusesToPublicOrTransient(from, scpb.Status_PUBLIC, to, scpb.Status_PUBLIC), + } + }, + ) +} + +// Special cases of the above. +func init() { + registerDepRule( + "column name and type set right after column existence", + scgraph.SameStagePrecedence, + "column", "column-name-or-type", + func(from, to nodeVars) rel.Clauses { + return rel.Clauses{ + from.Type((*scpb.Column)(nil)), + to.Type( + (*scpb.ColumnName)(nil), + (*scpb.ColumnType)(nil), + ), + statusesToPublicOrTransient(from, scpb.Status_DELETE_ONLY, to, scpb.Status_PUBLIC), + joinOnColumnID(from, to, "table-id", "col-id"), + } + }, + ) + + registerDepRule( + "DEFAULT or ON UPDATE existence precedes writes to column", + scgraph.Precedence, + "expr", "column", + func(from, to nodeVars) rel.Clauses { + return rel.Clauses{ + from.Type( + (*scpb.ColumnDefaultExpression)(nil), + (*scpb.ColumnOnUpdateExpression)(nil), + ), + to.Type((*scpb.Column)(nil)), + joinOnColumnID(from, to, "table-id", "col-id"), + statusesToPublicOrTransient(from, scpb.Status_PUBLIC, to, scpb.Status_WRITE_ONLY), + } + }, + ) +} + +// This rule ensures that columns depend on each other in increasing order. +func init() { + registerDepRule( + "ensure columns are in increasing order", + scgraph.SameStagePrecedence, + "later-column", "earlier-column", + func(from, to nodeVars) rel.Clauses { + status := rel.Var("status") + return rel.Clauses{ + from.Type((*scpb.Column)(nil)), + to.Type((*scpb.Column)(nil)), + joinOnDescID(from, to, "table-id"), + toPublicOrTransient(from, to), + status.In(scpb.Status_WRITE_ONLY, scpb.Status_PUBLIC), + status.Entities(screl.CurrentStatus, from.node, to.node), + filterElements("SmallerColumnIDFirst", from, to, func(from, to *scpb.Column) bool { + return from.ColumnID < to.ColumnID + }), + } + }) +} diff --git a/pkg/sql/schemachanger/scplan/internal/rules/dep_add_index.go b/pkg/sql/schemachanger/scplan/internal/rules/dep_add_index.go new file mode 100644 index 000000000000..93f651350831 --- /dev/null +++ b/pkg/sql/schemachanger/scplan/internal/rules/dep_add_index.go @@ -0,0 +1,159 @@ +// Copyright 2022 The Cockroach Authors. +// +// Use of this software is governed by the Business Source License +// included in the file licenses/BSL.txt. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0, included in the file +// licenses/APL.txt. + +package rules + +import ( + "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/rel" + "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scpb" + "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scplan/internal/scgraph" + "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/screl" +) + +// These rules ensure that index-dependent elements, like an index's name, its +// partitioning, etc. appear once the index reaches a suitable state. +func init() { + + registerDepRule( + "index existence precedes index dependents", + scgraph.Precedence, + "index", "dependent", + func(from, to nodeVars) rel.Clauses { + return rel.Clauses{ + from.Type( + (*scpb.PrimaryIndex)(nil), + (*scpb.SecondaryIndex)(nil), + ), + to.typeFilter(isIndexDependent), + joinOnIndexID(from, to, "table-id", "index-id"), + statusesToPublicOrTransient(from, scpb.Status_BACKFILL_ONLY, to, scpb.Status_PUBLIC), + } + }, + ) + + registerDepRule( + "temp index existence precedes index dependents", + scgraph.Precedence, + "index", "dependent", + func(from, to nodeVars) rel.Clauses { + return rel.Clauses{ + from.Type((*scpb.TemporaryIndex)(nil)), + to.typeFilter(isIndexDependent), + joinOnIndexID(from, to, "table-id", "index-id"), + statusesToPublicOrTransient(from, scpb.Status_DELETE_ONLY, to, scpb.Status_PUBLIC), + } + }, + ) + + registerDepRule( + "index dependents exist before index becomes public", + scgraph.Precedence, + "dependent", "index", + func(from, to nodeVars) rel.Clauses { + return rel.Clauses{ + from.typeFilter(isIndexDependent), + to.typeFilter(isIndex), + joinOnIndexID(from, to, "table-id", "index-id"), + statusesToPublicOrTransient(from, scpb.Status_PUBLIC, to, scpb.Status_PUBLIC), + } + }, + ) +} + +// Special cases of the above. +func init() { + + registerDepRule( + "index named right before index becomes public", + scgraph.SameStagePrecedence, + "index-name", "index", + func(from, to nodeVars) rel.Clauses { + return rel.Clauses{ + from.Type((*scpb.IndexName)(nil)), + to.Type( + (*scpb.PrimaryIndex)(nil), + (*scpb.SecondaryIndex)(nil), + ), + joinOnIndexID(from, to, "table-id", "index-id"), + statusesToPublicOrTransient(from, scpb.Status_PUBLIC, to, scpb.Status_PUBLIC), + } + }, + ) +} + +// This rule ensures that before an offline-backfilled index can begin +// backfilling, the corresponding temporary index exists in WRITE_ONLY. +func init() { + + registerDepRule( + "temp index is WRITE_ONLY before backfill", + scgraph.Precedence, + "temp", "index", + func(from, to nodeVars) rel.Clauses { + return rel.Clauses{ + from.Type((*scpb.TemporaryIndex)(nil)), + to.Type((*scpb.PrimaryIndex)(nil), (*scpb.SecondaryIndex)(nil)), + joinOnDescID(from, to, "table-id"), + joinOn( + from, screl.IndexID, + to, screl.TemporaryIndexID, + "temp-index-id", + ), + from.targetStatus(scpb.Transient), + to.targetStatus(scpb.ToPublic, scpb.Transient), + from.currentStatus(scpb.Status_WRITE_ONLY), + to.currentStatus(scpb.Status_BACKFILLED), + } + }, + ) +} + +// We want to say that all columns which are part of a secondary index need +// to be in a primary index which is validated +// To do that, we want to find a secondary index which has a source which +// is a primary index which is itself new. +func init() { + + registerDepRule( + "primary index with new columns should exist before secondary indexes", + scgraph.Precedence, + "primary-index", "secondary-index", + func(from, to nodeVars) rel.Clauses { + return rel.Clauses{ + from.Type((*scpb.PrimaryIndex)(nil)), + to.Type((*scpb.SecondaryIndex)(nil)), + joinOnDescID(from, to, "table-id"), + joinOn( + from, screl.IndexID, + to, screl.SourceIndexID, + "primary-index-id", + ), + statusesToPublicOrTransient(from, scpb.Status_PUBLIC, to, scpb.Status_BACKFILL_ONLY), + } + }) + + registerDepRule( + "primary index with new columns should exist before temp indexes", + scgraph.Precedence, + "primary-index", "temp-index", + func(from, to nodeVars) rel.Clauses { + return rel.Clauses{ + from.Type((*scpb.PrimaryIndex)(nil)), + to.Type((*scpb.TemporaryIndex)(nil)), + joinOnDescID(from, to, "table-id"), + joinOn( + from, screl.IndexID, + to, screl.SourceIndexID, + "primary-index-id", + ), + statusesToPublicOrTransient(from, scpb.Status_PUBLIC, to, scpb.Status_DELETE_ONLY), + } + }) +} diff --git a/pkg/sql/schemachanger/scplan/internal/rules/dep_add_index_and_column.go b/pkg/sql/schemachanger/scplan/internal/rules/dep_add_index_and_column.go new file mode 100644 index 000000000000..f6f12b15699b --- /dev/null +++ b/pkg/sql/schemachanger/scplan/internal/rules/dep_add_index_and_column.go @@ -0,0 +1,124 @@ +// Copyright 2022 The Cockroach Authors. +// +// Use of this software is governed by the Business Source License +// included in the file licenses/BSL.txt. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0, included in the file +// licenses/APL.txt. + +package rules + +import ( + "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/rel" + "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scpb" + "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scplan/internal/scgraph" +) + +// These rules ensure that columns and indexes containing these columns +// appear into existence in the correct order. +func init() { + + // We need to make sure that no columns are added to the index after it + // receives any data due to a backfill. + registerDepRule("index-column added to index before index is backfilled", + scgraph.Precedence, + "index-column", "index", + func(from, to nodeVars) rel.Clauses { + return rel.Clauses{ + from.Type((*scpb.IndexColumn)(nil)), + to.Type((*scpb.PrimaryIndex)(nil), (*scpb.SecondaryIndex)(nil)), + joinOnIndexID(from, to, "table-id", "index-id"), + statusesToPublicOrTransient(from, scpb.Status_PUBLIC, to, scpb.Status_BACKFILLED), + } + }) + + // We need to make sure that no columns are added to the temp index after it + // receives any writes. + registerDepRule("index-column added to index before temp index receives writes", + scgraph.Precedence, + "index-column", "index", + func(from, to nodeVars) rel.Clauses { + return rel.Clauses{ + from.Type((*scpb.IndexColumn)(nil)), + to.Type((*scpb.TemporaryIndex)(nil)), + joinOnIndexID(from, to, "table-id", "index-id"), + statusesTransient(from, scpb.Status_PUBLIC, to, scpb.Status_WRITE_ONLY), + } + }) + + registerDepRule( + "column existence precedes index existence", + scgraph.Precedence, + "column", "index", + func(from, to nodeVars) rel.Clauses { + ic := mkNodeVars("index-column") + relationID, columnID := rel.Var("table-id"), rel.Var("column-id") + return rel.Clauses{ + from.Type((*scpb.Column)(nil)), + to.Type((*scpb.PrimaryIndex)(nil), (*scpb.SecondaryIndex)(nil)), + joinOnColumnID(from, ic, relationID, columnID), + columnInIndex(ic, to, relationID, columnID, "index-id"), + statusesToPublicOrTransient(from, scpb.Status_DELETE_ONLY, to, scpb.Status_BACKFILL_ONLY), + } + }, + ) + + registerDepRule( + "column existence precedes temp index existence", + scgraph.Precedence, + "column", "index", + func(from, to nodeVars) rel.Clauses { + ic := mkNodeVars("index-column") + relationID, columnID := rel.Var("table-id"), rel.Var("column-id") + return rel.Clauses{ + from.Type((*scpb.Column)(nil)), + to.Type((*scpb.TemporaryIndex)(nil)), + joinOnColumnID(ic, from, relationID, columnID), + columnInIndex(ic, to, relationID, columnID, "index-id"), + statusesToPublicOrTransient(from, scpb.Status_DELETE_ONLY, to, scpb.Status_DELETE_ONLY), + } + }, + ) + + // We need to ensure that the temporary index has all the relevant writes + // to any columns it contains. We ensure elsewhere that any index which + // will later be merged with the temporary index is not backfilled until + // that temporary index is receiving writes. This rule ensures that those + // write operations contain data for all columns. + registerDepRule( + "column is WRITE_ONLY before temporary index is WRITE_ONLY", + scgraph.Precedence, + "column", "index", + func(from, to nodeVars) rel.Clauses { + ic := mkNodeVars("index-column") + relationID, columnID := rel.Var("table-id"), rel.Var("column-id") + return rel.Clauses{ + from.el.Type((*scpb.Column)(nil)), + to.el.Type((*scpb.TemporaryIndex)(nil)), + joinOnColumnID(ic, from, relationID, columnID), + columnInIndex(ic, to, relationID, columnID, "index-id"), + statusesToPublicOrTransient(from, scpb.Status_WRITE_ONLY, to, scpb.Status_WRITE_ONLY), + } + }, + ) + + registerDepRule( + "swapped primary index public before column", + scgraph.Precedence, + "index", "column", + func(from, to nodeVars) rel.Clauses { + ic := mkNodeVars("index-column") + relationID, columnID := rel.Var("table-id"), rel.Var("column-id") + return rel.Clauses{ + from.Type((*scpb.PrimaryIndex)(nil)), + to.Type((*scpb.Column)(nil)), + columnInSwappedInPrimaryIndex(ic, from, relationID, columnID, "index-id"), + joinOnColumnID(ic, to, relationID, columnID), + statusesToPublicOrTransient(from, scpb.Status_PUBLIC, to, scpb.Status_PUBLIC), + } + }, + ) + +} diff --git a/pkg/sql/schemachanger/scplan/internal/rules/dep_column.go b/pkg/sql/schemachanger/scplan/internal/rules/dep_column.go deleted file mode 100644 index 1dacaad58900..000000000000 --- a/pkg/sql/schemachanger/scplan/internal/rules/dep_column.go +++ /dev/null @@ -1,180 +0,0 @@ -// Copyright 2022 The Cockroach Authors. -// -// Use of this software is governed by the Business Source License -// included in the file licenses/BSL.txt. -// -// As of the Change Date specified in that file, in accordance with -// the Business Source License, use of this software will be governed -// by the Apache License, Version 2.0, included in the file -// licenses/APL.txt. - -package rules - -import ( - "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/rel" - "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scpb" - "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scplan/internal/scgraph" - "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/screl" -) - -// These rules ensure that column-dependent elements, like a column's name, its -// DEFAULT expression, etc. appear once the column reaches a suitable state. -// Vice-versa for column removal. -func init() { - registerDepRule( - "column name set right after column existence", - scgraph.SameStagePrecedence, - "column", "column-name", - func(from, to nodeVars) rel.Clauses { - return rel.Clauses{ - from.Type((*scpb.Column)(nil)), - to.Type((*scpb.ColumnName)(nil)), - statusesToPublic(from, scpb.Status_DELETE_ONLY, to, scpb.Status_PUBLIC), - joinOnColumnID(from, to, "table-id", "col-id"), - } - }, - ) - registerDepRule( - "column existence precedes column dependents", - scgraph.Precedence, - "column", "dependent", - func(from, to nodeVars) rel.Clauses { - return rel.Clauses{ - from.Type((*scpb.Column)(nil)), - to.Type( - (*scpb.ColumnName)(nil), - (*scpb.ColumnDefaultExpression)(nil), - (*scpb.ColumnOnUpdateExpression)(nil), - (*scpb.ColumnComment)(nil), - (*scpb.IndexColumn)(nil), - ), - joinOnColumnID(from, to, "table-id", "col-id"), - statusesToPublic(from, scpb.Status_DELETE_ONLY, to, scpb.Status_PUBLIC), - } - }, - ) - - registerDepRule( - "DEFAULT or ON UPDATE existence precedes writes to column", - scgraph.Precedence, - "expr", "column", - func(from, to nodeVars) rel.Clauses { - return rel.Clauses{ - from.Type( - (*scpb.ColumnDefaultExpression)(nil), - (*scpb.ColumnOnUpdateExpression)(nil), - ), - to.Type((*scpb.Column)(nil)), - joinOnColumnID(from, to, "table-id", "col-id"), - statusesToPublic(from, scpb.Status_PUBLIC, to, scpb.Status_WRITE_ONLY), - } - }, - ) - - // TODO(ajwerner): Understand this rule and why it needs to exist. - registerDepRule( - "column named before column type becomes public", - scgraph.Precedence, - "column-name", "column-type", - func(from, to nodeVars) rel.Clauses { - return rel.Clauses{ - from.Type((*scpb.ColumnName)(nil)), - to.Type((*scpb.ColumnType)(nil)), - joinOnColumnID(from, to, "table-id", "col-id"), - statusesToPublic(from, scpb.Status_PUBLIC, to, scpb.Status_PUBLIC), - } - }, - ) - - // The comment is all that is remaining column dependents now that the name - // and the DEFAULT and ON UPDATE expressions have already been dealt with. - registerDepRule( - "column comment exists before column becomes public", - scgraph.Precedence, - "column-comment", "column", - func(from, to nodeVars) rel.Clauses { - return rel.Clauses{ - from.Type((*scpb.ColumnComment)(nil)), - to.Type((*scpb.Column)(nil)), - joinOnColumnID(from, to, "table-id", "col-id"), - statusesToPublic(from, scpb.Status_PUBLIC, to, scpb.Status_PUBLIC), - } - }, - ) - - registerDepRule( - "column dependents removed after column no longer public", - scgraph.Precedence, - "column", "dependent", - func(from, to nodeVars) rel.Clauses { - return rel.Clauses{ - from.Type((*scpb.Column)(nil)), - to.Type( - (*scpb.ColumnType)(nil), - (*scpb.ColumnName)(nil), - (*scpb.ColumnComment)(nil), - ), - joinOnColumnID(from, to, "table-id", "col-id"), - statusesToAbsent(from, scpb.Status_WRITE_ONLY, to, scpb.Status_ABSENT), - } - }, - ) - - registerDepRule( - "column type dependents removed right before column type", - scgraph.SameStagePrecedence, - "dependent", "column-type", - func(from, to nodeVars) rel.Clauses { - return rel.Clauses{ - from.Type( - (*scpb.SequenceOwner)(nil), - (*scpb.ColumnDefaultExpression)(nil), - (*scpb.ColumnOnUpdateExpression)(nil), - ), - to.Type((*scpb.ColumnType)(nil)), - joinOnColumnID(from, to, "table-id", "col-id"), - statusesToAbsent(from, scpb.Status_ABSENT, to, scpb.Status_ABSENT), - } - }, - ) - - registerDepRule( - "dependents removed before column", - scgraph.Precedence, - "dependent", "column", - func(from, to nodeVars) rel.Clauses { - return rel.Clauses{ - from.Type( - (*scpb.ColumnName)(nil), - (*scpb.ColumnType)(nil), - (*scpb.ColumnComment)(nil), - ), - to.Type((*scpb.Column)(nil)), - joinOnColumnID(from, to, "table-id", "col-id"), - statusesToAbsent(from, scpb.Status_ABSENT, to, scpb.Status_ABSENT), - } - }, - ) -} - -// This rule ensures that columns depend on each other in increasing order. -func init() { - registerDepRule( - "ensure columns are in increasing order", - scgraph.SameStagePrecedence, - "later-column", "earlier-column", - func(from, to nodeVars) rel.Clauses { - status := rel.Var("status") - return rel.Clauses{ - from.Type((*scpb.Column)(nil)), - to.Type((*scpb.Column)(nil)), - joinOnDescID(from, to, "table-id"), - toPublic(from, to), - status.In(scpb.Status_WRITE_ONLY, scpb.Status_PUBLIC), - status.Entities(screl.CurrentStatus, from.node, to.node), - filterElements("SmallerColumnIDFirst", from, to, func(from, to *scpb.Column) bool { - return from.ColumnID < to.ColumnID - }), - } - }) -} diff --git a/pkg/sql/schemachanger/scplan/internal/rules/dep_drop_column.go b/pkg/sql/schemachanger/scplan/internal/rules/dep_drop_column.go new file mode 100644 index 000000000000..79d967f51ee8 --- /dev/null +++ b/pkg/sql/schemachanger/scplan/internal/rules/dep_drop_column.go @@ -0,0 +1,105 @@ +// Copyright 2022 The Cockroach Authors. +// +// Use of this software is governed by the Business Source License +// included in the file licenses/BSL.txt. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0, included in the file +// licenses/APL.txt. + +package rules + +import ( + "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/rel" + "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scpb" + "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scplan/internal/scgraph" +) + +// These rules ensure that column-dependent elements, like a column's name, its +// DEFAULT expression, etc. disappear once the column reaches a suitable state. +func init() { + + registerDepRuleForDrop( + "column no longer public before dependents", + scgraph.Precedence, + "column", "dependent", + scpb.Status_WRITE_ONLY, scpb.Status_ABSENT, + func(from, to nodeVars) rel.Clauses { + return rel.Clauses{ + from.Type((*scpb.Column)(nil)), + to.typeFilter(isColumnDependent), + joinOnColumnID(from, to, "table-id", "col-id"), + } + }, + ) + + registerDepRuleForDrop( + "dependents removed before column", + scgraph.Precedence, + "dependent", "column", + scpb.Status_ABSENT, scpb.Status_ABSENT, + func(from, to nodeVars) rel.Clauses { + return rel.Clauses{ + from.typeFilter(isColumnDependent), + to.Type((*scpb.Column)(nil)), + joinOnColumnID(from, to, "table-id", "col-id"), + } + }, + ) +} + +// Special cases of the above. +func init() { + + registerDepRule( + "column type dependents removed right before column type", + scgraph.SameStagePrecedence, + "dependent", "column-type", + func(from, to nodeVars) rel.Clauses { + return rel.Clauses{ + from.typeFilter(isColumnTypeDependent), + to.Type((*scpb.ColumnType)(nil)), + joinOnColumnID(from, to, "table-id", "col-id"), + statusesToAbsent(from, scpb.Status_ABSENT, to, scpb.Status_ABSENT), + } + }, + ) + + // Special cases for removal of column types, which hold references to other + // descriptors. + // + // When the whole table is dropped, we can (and in fact, should) remove these + // right away in-txn. However, when only the column is dropped but the table + // remains, we need to wait until the column is DELETE_ONLY, which happens + // post-commit because of the need to uphold the 2-version invariant. + // + // We distinguish the two cases using a flag in ColumnType which is set iff + // the parent relation is dropped. This is a dirty hack, ideally we should be + // able to express the _absence_ of a target element as a query clause. + // + // Note that DEFAULT and ON UPDATE expressions are column-dependent elements + // which also hold references to other descriptors. The rule prior to this one + // ensures that they transition to ABSENT before scpb.ColumnType does. + // + // TODO(postamar): express this rule in a saner way + registerDepRule( + "column type removed right before column when not dropping relation", + scgraph.SameStagePrecedence, + "column-type", "column", + func(from, to nodeVars) rel.Clauses { + return rel.Clauses{ + from.Type((*scpb.ColumnType)(nil)), + to.Type((*scpb.Column)(nil)), + joinOnColumnID(from, to, "table-id", "col-id"), + statusesToAbsent(from, scpb.Status_ABSENT, to, scpb.Status_ABSENT), + rel.Filter("relationIsNotBeingDropped", from.el)( + func(ct *scpb.ColumnType) bool { + return !ct.IsRelationBeingDropped + }, + ), + } + }, + ) + +} diff --git a/pkg/sql/schemachanger/scplan/internal/rules/dep_drop_index.go b/pkg/sql/schemachanger/scplan/internal/rules/dep_drop_index.go new file mode 100644 index 000000000000..ead68e167975 --- /dev/null +++ b/pkg/sql/schemachanger/scplan/internal/rules/dep_drop_index.go @@ -0,0 +1,112 @@ +// Copyright 2022 The Cockroach Authors. +// +// Use of this software is governed by the Business Source License +// included in the file licenses/BSL.txt. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0, included in the file +// licenses/APL.txt. + +package rules + +import ( + "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/rel" + "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scpb" + "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scplan/internal/scgraph" +) + +// These rules ensure that index-dependent elements, like an index's name, its +// partitioning, etc. disappear once the index reaches a suitable state. +func init() { + + registerDepRuleForDrop( + "index no longer public before dependents", + scgraph.Precedence, + "index", "dependent", + scpb.Status_VALIDATED, scpb.Status_ABSENT, + func(from, to nodeVars) rel.Clauses { + return rel.Clauses{ + from.typeFilter(isIndex), + to.typeFilter(isIndexDependent), + joinOnIndexID(from, to, "table-id", "index-id"), + } + }, + ) + registerDepRuleForDrop( + "dependents removed before index", + scgraph.Precedence, + "dependent", "index", + scpb.Status_ABSENT, scpb.Status_ABSENT, + func(from, to nodeVars) rel.Clauses { + return rel.Clauses{ + from.typeFilter(isIndexDependent), + to.typeFilter(isIndex), + joinOnIndexID(from, to, "table-id", "index-id"), + } + }, + ) +} + +// Special cases of the above. +func init() { + + // If we're going to be removing columns from an index, we know that + // it'll be because we're dropping the index. If we're dropping the + // index and not the descriptor, we need to make sure that we only + // do it once the index is definitely being dropped. The reason for + // this is roundabout: dropping a column from an index which is itself + // being dropped is treated as a no-op by the op rules. + // + // TODO(ajwerner): This rule really feels like it ought to be a + // same stage precedence sort of rule where we remove the columns from the + // index when we remove the index, but for some reason, that overconstrains + // the graph when dropping the table. Because of that, we allow the column + // to be removed from the index in DELETE_ONLY, and we no-op the removal. + registerDepRuleForDrop( + "remove columns from index right before removing index", + scgraph.Precedence, + "index", "index-column", + scpb.Status_DELETE_ONLY, scpb.Status_ABSENT, + func(from, to nodeVars) rel.Clauses { + return rel.Clauses{ + from.Type((*scpb.IndexColumn)(nil)), + to.typeFilter(isIndex), + joinOnIndexID(from, to, "table-id", "index-id"), + } + }, + ) + + // Special case for removal of partial predicates, which hold references to + // other descriptors. + // + // When the whole table is dropped, we can (and in fact, should) remove these + // right away in-txn. However, when only the index is dropped but the table + // remains, we need to wait until the index is DELETE_ONLY, which happens + // post-commit because of the need to uphold the 2-version invariant. + // + // We distinguish the two cases using a flag in SecondaryIndexPartial which is + // set iff the parent relation is dropped. This is a dirty hack, ideally we + // should be able to express the _absence_ of a target element as a query + // clause. + // + // TODO(postamar): express this rule in a saner way + registerDepRuleForDrop( + "partial predicate removed right before secondary index when not dropping relation", + scgraph.SameStagePrecedence, + "partial-predicate", "index", + scpb.Status_ABSENT, scpb.Status_ABSENT, + func(from, to nodeVars) rel.Clauses { + return rel.Clauses{ + from.Type((*scpb.SecondaryIndexPartial)(nil)), + to.Type((*scpb.SecondaryIndex)(nil)), + joinOnIndexID(from, to, "table-id", "index-id"), + rel.Filter("relationIsNotBeingDropped", from.el)( + func(ip *scpb.SecondaryIndexPartial) bool { + return !ip.IsRelationBeingDropped + }, + ), + } + }, + ) +} diff --git a/pkg/sql/schemachanger/scplan/internal/rules/dep_drop_index_and_column.go b/pkg/sql/schemachanger/scplan/internal/rules/dep_drop_index_and_column.go new file mode 100644 index 000000000000..17767c21f35a --- /dev/null +++ b/pkg/sql/schemachanger/scplan/internal/rules/dep_drop_index_and_column.go @@ -0,0 +1,75 @@ +// Copyright 2022 The Cockroach Authors. +// +// Use of this software is governed by the Business Source License +// included in the file licenses/BSL.txt. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0, included in the file +// licenses/APL.txt. + +package rules + +import ( + "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/rel" + "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scpb" + "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scplan/internal/scgraph" +) + +// These rules ensure that columns and indexes containing these columns +// disappear from existence in the correct order. +func init() { + + // Without this rule, we might have an index which exists and contains + // a column which does not exist. This would lead to panics inside the + // optimizer and an invalid table descriptor. + registerDepRuleForDrop("indexes containing column reach absent before column", + scgraph.Precedence, + "index", "column", + scpb.Status_ABSENT, scpb.Status_ABSENT, + func(from, to nodeVars) rel.Clauses { + ic, ct := mkNodeVars("index-column"), mkNodeVars("column-type") + relationID, columnID := rel.Var("table-id"), rel.Var("column-id") + return rel.Clauses{ + from.Type((*scpb.PrimaryIndex)(nil), (*scpb.SecondaryIndex)(nil)), + to.Type((*scpb.Column)(nil)), + ct.Type((*scpb.ColumnType)(nil)), + columnInIndex(ic, from, relationID, columnID, "index-id"), + joinOnColumnID(ic, to, relationID, columnID), + joinOnColumnID(ic, ct, relationID, columnID), + rel.Filter("relationIsNotBeingDropped", ct.el)( + func(ct *scpb.ColumnType) bool { + return !ct.IsRelationBeingDropped + }, + ), + } + }) + + registerDepRule("secondary indexes containing column as key reach write-only before column", + scgraph.Precedence, + "index", "column", + func(from, to nodeVars) rel.Clauses { + ic, ct := mkNodeVars("index-column"), mkNodeVars("column-type") + relationID, columnID := rel.Var("table-id"), rel.Var("column-id") + return rel.Clauses{ + from.Type((*scpb.SecondaryIndex)(nil)), + to.Type((*scpb.Column)(nil)), + columnInIndex(ic, from, relationID, columnID, "index-id"), + joinOnColumnID(ic, to, relationID, columnID), + statusesToAbsent(from, scpb.Status_VALIDATED, to, scpb.Status_WRITE_ONLY), + ct.Type((*scpb.ColumnType)(nil)), + joinOnColumnID(ic, ct, relationID, columnID), + rel.Filter("relationIsNotBeingDropped", ct.el)( + func(ct *scpb.ColumnType) bool { + return !ct.IsRelationBeingDropped + }, + ), + rel.Filter("isIndexKeyColumnKey", ic.el)( + func(ic *scpb.IndexColumn) bool { + return ic.Kind == scpb.IndexColumn_KEY + }, + ), + } + }) + +} diff --git a/pkg/sql/schemachanger/scplan/internal/rules/dep_drop.go b/pkg/sql/schemachanger/scplan/internal/rules/dep_drop_object.go similarity index 100% rename from pkg/sql/schemachanger/scplan/internal/rules/dep_drop.go rename to pkg/sql/schemachanger/scplan/internal/rules/dep_drop_object.go diff --git a/pkg/sql/schemachanger/scplan/internal/rules/dep_index.go b/pkg/sql/schemachanger/scplan/internal/rules/dep_index.go deleted file mode 100644 index 37bef778a08f..000000000000 --- a/pkg/sql/schemachanger/scplan/internal/rules/dep_index.go +++ /dev/null @@ -1,311 +0,0 @@ -// Copyright 2022 The Cockroach Authors. -// -// Use of this software is governed by the Business Source License -// included in the file licenses/BSL.txt. -// -// As of the Change Date specified in that file, in accordance with -// the Business Source License, use of this software will be governed -// by the Apache License, Version 2.0, included in the file -// licenses/APL.txt. - -package rules - -import ( - "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/rel" - "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scpb" - "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scplan/internal/scgraph" - "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/screl" -) - -// This rule ensures that a new primary index becomes public right after the -// old primary index starts getting removed, effectively swapping one for the -// other. This rule also applies when the schema change gets reverted. -func init() { - registerDepRule( - "primary index swap", - scgraph.SameStagePrecedence, - "old-index", "new-index", - func(from, to nodeVars) rel.Clauses { - return rel.Clauses{ - from.Type((*scpb.PrimaryIndex)(nil)), - to.Type((*scpb.PrimaryIndex)(nil)), - joinOnDescID(from, to, "table-id"), - from.targetStatus(scpb.ToAbsent), - to.targetStatus(scpb.ToPublic), - from.currentStatus(scpb.Status_VALIDATED), - to.currentStatus(scpb.Status_PUBLIC), - filterElements("primaryIndexesDependency", from, to, func(i1, i2 *scpb.PrimaryIndex) bool { - return i1.SourceIndexID == i2.IndexID || i1.IndexID == i2.SourceIndexID - }), - } - }, - ) -} - -// These rules ensure that index-dependent elements, like an index's name, its -// partitioning, etc. appear once the index reaches a suitable state. -// Vice-versa for index removal. -func init() { - registerDepRule( - "index existence precedes index name and comment", - scgraph.Precedence, - "index", "index-dependent", - func(from, to nodeVars) rel.Clauses { - return rel.Clauses{ - from.Type( - (*scpb.PrimaryIndex)(nil), - (*scpb.SecondaryIndex)(nil), - ), - to.Type( - (*scpb.IndexName)(nil), - (*scpb.IndexComment)(nil), - ), - joinOnIndexID(from, to, "table-id", "index-id"), - statusesToPublic(from, scpb.Status_BACKFILL_ONLY, to, scpb.Status_PUBLIC), - } - }) - - // This rule pairs with the rule which ensures that columns are added to - // the index before it receives writes. - registerDepRule( - "temp index exists before columns, partitioning, and partial", - scgraph.Precedence, - "temp-index", "index-partitioning", - func(from, to nodeVars) rel.Clauses { - return rel.Clauses{ - from.Type((*scpb.TemporaryIndex)(nil)), - to.Type( - (*scpb.IndexColumn)(nil), - (*scpb.IndexPartitioning)(nil), - (*scpb.SecondaryIndexPartial)(nil), - ), - joinOnIndexID(from, to, "table-id", "index-id"), - from.targetStatus(scpb.Transient), - to.targetStatus(scpb.ToPublic), - from.currentStatus(scpb.Status_DELETE_ONLY), - to.currentStatus(scpb.Status_PUBLIC), - } - }) - - // Once the index is public, its comment should be visible. - registerDepRule( - "comment existence precedes index becoming public", - scgraph.Precedence, - "child", "index", - func(from, to nodeVars) rel.Clauses { - return rel.Clauses{ - from.Type( - (*scpb.IndexComment)(nil), - ), - to.Type( - (*scpb.PrimaryIndex)(nil), - (*scpb.SecondaryIndex)(nil), - ), - joinOnIndexID(from, to, "table-id", "index-id"), - statusesToPublic(from, scpb.Status_PUBLIC, to, scpb.Status_PUBLIC), - } - }, - ) - registerDepRule( - "index named right before index becomes public", - scgraph.SameStagePrecedence, - "index-name", "index", - func(from, to nodeVars) rel.Clauses { - return rel.Clauses{ - from.Type((*scpb.IndexName)(nil)), - to.Type( - (*scpb.PrimaryIndex)(nil), - (*scpb.SecondaryIndex)(nil), - ), - statusesToPublic(from, scpb.Status_PUBLIC, to, scpb.Status_PUBLIC), - joinOnIndexID(from, to, "table-id", "index-id"), - } - }, - ) - - // If we're going to be removing columns from an index, we know that - // it'll be because we're dropping the index. If we're dropping the - // index and not the descriptor, we need to make sure that we only - // do it once the index is definitely being dropped. The reason for - // this is roundabout: dropping a column from an index which is itself - // being dropped is treated as a no-op by the execution layer. - // - // TODO(ajwerner): This pair of rules really feels like it ought to be a - // same stage precedence sort of rule where we remove the columns from the - // index when we remove the index, but for some reason, that overconstrains - // the graph when dropping the table. Because of that, we allow the column - // to be removed from the index in DELETE_ONLY, and we no-op the removal. - registerDepRule( - "secondary index columns removed before removing the index", - scgraph.Precedence, - "index-column", "index", - func(from, to nodeVars) rel.Clauses { - return rel.Clauses{ - from.Type((*scpb.IndexColumn)(nil)), - to.Type((*scpb.SecondaryIndex)(nil)), - joinOnIndexID(from, to, "table-id", "index-id"), - statusesToAbsent(from, scpb.Status_ABSENT, to, scpb.Status_ABSENT), - } - }, - ) - registerDepRule( - "secondary index in DELETE_ONLY before removing columns", - scgraph.Precedence, - "index", "index-column", - func(from, to nodeVars) rel.Clauses { - return rel.Clauses{ - from.Type((*scpb.SecondaryIndex)(nil)), - to.Type((*scpb.IndexColumn)(nil)), - joinOnIndexID(from, to, "table-id", "index-id"), - statusesToAbsent(from, scpb.Status_DELETE_ONLY, to, scpb.Status_ABSENT), - } - }, - ) - registerDepRule( - "temp index columns removed before removing the index", - scgraph.Precedence, - "index-column", "index", - func(from, to nodeVars) rel.Clauses { - return rel.Clauses{ - from.Type((*scpb.IndexColumn)(nil)), - to.Type((*scpb.TemporaryIndex)(nil)), - joinOnIndexID(from, to, "table-id", "index-id"), - statusesToAbsent(from, scpb.Status_ABSENT, to, scpb.Status_TRANSIENT_ABSENT), - } - }, - ) - registerDepRule( - "temp index in DELETE_ONLY before removing columns", - scgraph.Precedence, - "index", "index-column", - func(from, to nodeVars) rel.Clauses { - return rel.Clauses{ - from.Type((*scpb.TemporaryIndex)(nil)), - to.Type((*scpb.IndexColumn)(nil)), - joinOnIndexID(from, to, "table-id", "index-id"), - statusesToAbsent(from, scpb.Status_TRANSIENT_DELETE_ONLY, to, scpb.Status_ABSENT), - } - }, - ) - - // This rule is suspect. We absolutely cannot remove the partial predicate - // until the index is not longer being written to. I think the same goes - // for the columns. The partitioning is less clear. I think the name could - // go earlier. - registerDepRule( - "index no longer public before dependents removed", - scgraph.Precedence, - "index", "child", - func(from, to nodeVars) rel.Clauses { - return rel.Clauses{ - from.typeFilter(isIndex), - to.typeFilter(isIndexDependent), - joinOnIndexID(from, to, "table-id", "index-id"), - statusesToAbsent(from, scpb.Status_VALIDATED, to, scpb.Status_ABSENT), - } - }, - ) - - registerDepRule( - "dependents removed before index", - scgraph.Precedence, - "dependent", "index", - func(from, to nodeVars) rel.Clauses { - return rel.Clauses{ - from.typeFilter(isIndexDependent), - to.typeFilter(isIndex), - joinOnIndexID(from, to, "table-id", "index-id"), - statusesToAbsent(from, scpb.Status_ABSENT, to, scpb.Status_ABSENT), - } - }, - ) -} - -// These rules ensure that before an offline-backfilled index can begin -// backfilling, the corresponding temporary index exists in WRITE_ONLY. -func init() { - registerDepRule( - "temp index is WRITE_ONLY before backfill", - scgraph.Precedence, - "temp", "index", - func(from, to nodeVars) rel.Clauses { - return rel.Clauses{ - from.Type((*scpb.TemporaryIndex)(nil)), - to.Type((*scpb.PrimaryIndex)(nil), (*scpb.SecondaryIndex)(nil)), - joinOnDescID(from, to, "table-id"), - joinOn( - from, screl.IndexID, - to, screl.TemporaryIndexID, - "temp-index-id", - ), - from.targetStatus(scpb.Transient), - to.targetStatus(scpb.ToPublic), - from.currentStatus(scpb.Status_WRITE_ONLY), - to.currentStatus(scpb.Status_BACKFILLED), - } - }, - ) -} - -// We want to say that all columns which are part of a secondary index need -// to be in a primary index which is validated -// To do that, we want to find a secondary index which has a source which -// is a primary index which is itself new. Then we want to find -func init() { - registerDepRule( - "primary index with new columns should exist before secondary indexes", - scgraph.Precedence, - "primary-index", "second-index", - func(from, to nodeVars) rel.Clauses { - return rel.Clauses{ - from.Type((*scpb.PrimaryIndex)(nil)), - to.Type((*scpb.SecondaryIndex)(nil)), - joinOnDescID(from, to, "table-id"), - joinOn( - from, screl.IndexID, - to, screl.SourceIndexID, - "primary-index-id", - ), - statusesToPublic(from, scpb.Status_PUBLIC, to, scpb.Status_BACKFILL_ONLY), - } - }) - registerDepRule( - "primary index with new columns should exist before temp indexes", - scgraph.Precedence, - "primary-index", "second-index", - func(from, to nodeVars) rel.Clauses { - return rel.Clauses{ - from.Type((*scpb.PrimaryIndex)(nil)), - to.Type((*scpb.TemporaryIndex)(nil)), - joinOnDescID(from, to, "table-id"), - joinOn(from, screl.IndexID, to, screl.SourceIndexID, "primary-index-id"), - from.targetStatus(scpb.ToPublic), - to.targetStatus(scpb.Transient), - from.currentStatus(scpb.Status_PUBLIC), - to.currentStatus(scpb.Status_DELETE_ONLY), - } - }) -} - -// This is a pair of somewhat brute-force hack to ensure that we only create -// a single GC job for all the indexes of a table being dropped by a -// transaction. -func init() { - - registerDepRule("temp indexes reach absent at the same time as other indexes", - scgraph.SameStagePrecedence, - "index-a", "index-b", - func(from, to nodeVars) rel.Clauses { - return rel.Clauses{ - from.Type((*scpb.TemporaryIndex)(nil)), - to.Type((*scpb.PrimaryIndex)(nil), (*scpb.SecondaryIndex)(nil)), - joinOnDescID(from, to, "desc-id"), - from.targetStatus(scpb.Transient), - to.targetStatus(scpb.ToAbsent), - from.currentStatus(scpb.Status_TRANSIENT_ABSENT), - to.currentStatus(scpb.Status_ABSENT), - } - }) - // TODO(postamar): reimplement rule - // "indexes reach absent at the same time as other indexes" -} diff --git a/pkg/sql/schemachanger/scplan/internal/rules/dep_index_and_column.go b/pkg/sql/schemachanger/scplan/internal/rules/dep_index_and_column.go deleted file mode 100644 index 656c570f6825..000000000000 --- a/pkg/sql/schemachanger/scplan/internal/rules/dep_index_and_column.go +++ /dev/null @@ -1,274 +0,0 @@ -// Copyright 2022 The Cockroach Authors. -// -// Use of this software is governed by the Business Source License -// included in the file licenses/BSL.txt. -// -// As of the Change Date specified in that file, in accordance with -// the Business Source License, use of this software will be governed -// by the Apache License, Version 2.0, included in the file -// licenses/APL.txt. - -package rules - -import ( - "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/rel" - "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scpb" - "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scplan/internal/scgraph" -) - -// Special cases for removal of column types and index partial predicates, -// which hold references to other descriptors. -// -// When the whole table is dropped, we can (and in fact, should) remove these -// right away in-txn. However, when only the column (or the index) is -// dropped but the table remains, we need to wait until the column is -// DELETE_ONLY, which happens post-commit because of the need to uphold the -// 2-version invariant. -// -// We distinguish the two cases using a flag in ColumnType and -// SecondaryIndexPartial which is set iff the parent relation is dropped. This -// is a dirty hack, ideally we should be able to express the _absence_ of a -// target as a query clause. -// -// Note that DEFAULT and ON UPDATE expressions are column-dependent elements -// which also hold references to other descriptors. The rule prior to this one -// ensures that they transition to ABSENT before scpb.ColumnType does. -// -// TODO(postamar): express this rule in a saner way -func init() { - - registerDepRule( - "column type removed right before column when not dropping relation", - scgraph.SameStagePrecedence, - "column-type", "column", - func(from, to nodeVars) rel.Clauses { - return rel.Clauses{ - from.Type((*scpb.ColumnType)(nil)), - to.Type((*scpb.Column)(nil)), - joinOnColumnID(from, to, "table-id", "col-id"), - statusesToAbsent(from, scpb.Status_ABSENT, to, scpb.Status_ABSENT), - rel.Filter("RelationIsNotBeingDropped", from.el)( - func(ct *scpb.ColumnType) bool { - return !ct.IsRelationBeingDropped - }, - ), - } - }, - ) - - // Without this rule, we might have an index which exists and contains - // a column which does not exist. This would lead to panics inside the - // optimizer and an invalid table descriptor. - registerDepRule("indexes containing columns reach absent before column", - scgraph.Precedence, - "index", "column", - func(from, to nodeVars) rel.Clauses { - ic, ct := mkNodeVars("index-column"), mkNodeVars("column-type") - relationID, columnID := rel.Var("table-id"), rel.Var("column-id") - return rel.Clauses{ - from.Type((*scpb.PrimaryIndex)(nil), (*scpb.SecondaryIndex)(nil)), - to.Type((*scpb.Column)(nil)), - ct.Type((*scpb.ColumnType)(nil)), - columnInIndex(ic, from, relationID, columnID, "index-id"), - joinOnColumnID(ic, to, relationID, columnID), - joinOnColumnID(ic, ct, relationID, columnID), - statusesToAbsent(from, scpb.Status_ABSENT, to, scpb.Status_ABSENT), - rel.Filter("RelationIsNotBeingDropped", ct.el)( - func(ct *scpb.ColumnType) bool { - return !ct.IsRelationBeingDropped - }), - } - }) - - registerDepRule( - "partial predicate removed right before secondary index when not dropping relation", - scgraph.SameStagePrecedence, - "partial-predicate", "index", - func(from, to nodeVars) rel.Clauses { - return rel.Clauses{ - from.Type((*scpb.SecondaryIndexPartial)(nil)), - to.Type((*scpb.SecondaryIndex)(nil)), - joinOnIndexID(from, to, "table-id", "index-id"), - statusesToAbsent(from, scpb.Status_ABSENT, to, scpb.Status_ABSENT), - rel.Filter("RelationIsNotBeingDropped", from.el)( - func(ip *scpb.SecondaryIndexPartial) bool { - return !ip.IsRelationBeingDropped - }, - ), - } - }, - ) -} - -// These rules ensure that columns and indexes containing these columns -// appear into existence in the correct order. -func init() { - - registerDepRule( - "adding column depends on primary index", - scgraph.Precedence, - "index", "column", - func(from, to nodeVars) rel.Clauses { - ic := mkNodeVars("index-column") - relationID, columnID := rel.Var("table-id"), rel.Var("column-id") - return rel.Clauses{ - from.Type((*scpb.PrimaryIndex)(nil)), - to.Type((*scpb.Column)(nil)), - columnInPrimaryIndexSwap(ic, from, relationID, columnID, "index-id"), - joinOnColumnID(ic, to, relationID, columnID), - statusesToPublic(from, scpb.Status_PUBLIC, to, scpb.Status_PUBLIC), - } - }, - ) - - registerDepRule( - "primary index should be cleaned up before newly added column when reverting", - scgraph.Precedence, - "index", "column", - func(from, to nodeVars) rel.Clauses { - ic := mkNodeVars("index-column") - relationID, columnID := rel.Var("table-id"), rel.Var("column-id") - return rel.Clauses{ - from.Type((*scpb.PrimaryIndex)(nil)), - to.Type((*scpb.Column)(nil)), - columnInPrimaryIndexSwap(ic, from, relationID, columnID, "index-id"), - joinOnColumnID(ic, to, relationID, columnID), - statusesToAbsent(from, scpb.Status_WRITE_ONLY, to, scpb.Status_WRITE_ONLY), - } - }) - registerDepRule( - "column existence precedes index existence", - scgraph.Precedence, - "column", "index", - func(from, to nodeVars) rel.Clauses { - ic := mkNodeVars("index-column") - relationID, columnID := rel.Var("table-id"), rel.Var("column-id") - return rel.Clauses{ - from.Type((*scpb.Column)(nil)), - to.Type((*scpb.PrimaryIndex)(nil), (*scpb.SecondaryIndex)(nil)), - joinOnColumnID(from, ic, relationID, columnID), - columnInIndex(ic, to, relationID, columnID, "index-id"), - statusesToPublic(from, scpb.Status_DELETE_ONLY, to, scpb.Status_BACKFILL_ONLY), - } - }, - ) - - // We need to make sure that we don't add a temporary index to a table - // until the column has been added to the table. - registerDepRule( - "column existence precedes temporary index existence", - scgraph.Precedence, - "column", "temp-index", - func(from, to nodeVars) rel.Clauses { - ic := mkNodeVars("index-column") - relationID, columnID := rel.Var("table-id"), rel.Var("column-id") - return rel.Clauses{ - from.Type((*scpb.Column)(nil)), - to.Type((*scpb.TemporaryIndex)(nil)), - columnInIndex(ic, to, relationID, columnID, "temp-index-id"), - joinOnColumnID(ic, from, relationID, columnID), - from.targetStatus(scpb.ToPublic), - to.targetStatus(scpb.Transient), - from.currentStatus(scpb.Status_DELETE_ONLY), - to.currentStatus(scpb.Status_DELETE_ONLY), - } - }, - ) - - // We want to ensure that column names are not dropped until the column is - // no longer in use in any dropping indexes. - registerDepRule( - "column name and type to public after all index column to public", - scgraph.Precedence, - "column-name-or-type", "index-column", - func(from, to nodeVars) rel.Clauses { - return rel.Clauses{ - from.Type((*scpb.ColumnName)(nil), (*scpb.ColumnType)(nil)), - to.Type((*scpb.IndexColumn)(nil)), - joinOnColumnID(from, to, "table-id", "column-id"), - statusesToPublic(from, scpb.Status_PUBLIC, to, scpb.Status_PUBLIC), - } - }, - ) - - registerDepRule("index-column added to index after index exists", - scgraph.Precedence, - "index", "index-column", - func(from, to nodeVars) rel.Clauses { - return rel.Clauses{ - from.Type((*scpb.PrimaryIndex)(nil), (*scpb.SecondaryIndex)(nil)), - to.Type((*scpb.IndexColumn)(nil)), - joinOnIndexID(from, to, "table-id", "index-id"), - statusesToPublic(from, scpb.Status_BACKFILL_ONLY, to, scpb.Status_PUBLIC), - } - }) - // We need to make sure that no columns are added to the index after it - // receives any data due to a backfill. - registerDepRule("index-column added to index before index is backfilled", - scgraph.Precedence, - "index-column", "index", - func(from, to nodeVars) rel.Clauses { - return rel.Clauses{ - from.Type((*scpb.IndexColumn)(nil)), - to.Type((*scpb.PrimaryIndex)(nil), (*scpb.SecondaryIndex)(nil)), - joinOnIndexID(from, to, "table-id", "index-id"), - statusesToPublic(from, scpb.Status_PUBLIC, to, scpb.Status_BACKFILLED), - } - }) - registerDepRule("index-column added to index after temp index exists", - scgraph.Precedence, - "index", "index-column", - func(from, to nodeVars) rel.Clauses { - return rel.Clauses{ - from.Type((*scpb.TemporaryIndex)(nil)), - to.Type((*scpb.IndexColumn)(nil)), - joinOnIndexID(from, to, "table-id", "index-id"), - from.targetStatus(scpb.Transient), - to.targetStatus(scpb.ToPublic), - from.currentStatus(scpb.Status_DELETE_ONLY), - to.currentStatus(scpb.Status_PUBLIC), - } - }) - // We need to make sure that no columns are added to the temp index after it - // receives any writes. - registerDepRule("index-column added to index before temp index receives writes", - scgraph.Precedence, - "index-column", "index", - func(from, to nodeVars) rel.Clauses { - return rel.Clauses{ - from.Type((*scpb.IndexColumn)(nil)), - to.Type((*scpb.TemporaryIndex)(nil)), - joinOnIndexID(from, to, "table-id", "index-id"), - from.targetStatus(scpb.ToPublic), - to.targetStatus(scpb.Transient), - from.currentStatus(scpb.Status_PUBLIC), - to.currentStatus(scpb.Status_WRITE_ONLY), - } - }) - - // We need to ensure that the temporary index has all the relevant writes - // to any columns it contains. We ensure elsewhere that any index which - // will later be merged with the temporary index is not backfilled until - // that temporary index is receiving writes. This rule ensures that those - // write operations contain data for all columns. - registerDepRule( - "column is WRITE_ONLY before temporary index is WRITE_ONLY", - scgraph.Precedence, - "column", "index", - func(from, to nodeVars) rel.Clauses { - ic := mkNodeVars("index-column") - relationID, columnID := rel.Var("table-id"), rel.Var("column-id") - return rel.Clauses{ - from.el.Type((*scpb.Column)(nil)), - to.el.Type((*scpb.TemporaryIndex)(nil)), - joinOnColumnID(ic, from, relationID, columnID), - columnInIndex(ic, to, relationID, columnID, "index-id"), - from.targetStatus(scpb.ToPublic), - to.targetStatus(scpb.Transient), - from.currentStatus(scpb.Status_WRITE_ONLY), - to.currentStatus(scpb.Status_WRITE_ONLY), - } - }, - ) - -} diff --git a/pkg/sql/schemachanger/scplan/internal/rules/dep_swap_index.go b/pkg/sql/schemachanger/scplan/internal/rules/dep_swap_index.go new file mode 100644 index 000000000000..b55bd7266f1a --- /dev/null +++ b/pkg/sql/schemachanger/scplan/internal/rules/dep_swap_index.go @@ -0,0 +1,126 @@ +// Copyright 2022 The Cockroach Authors. +// +// Use of this software is governed by the Business Source License +// included in the file licenses/BSL.txt. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0, included in the file +// licenses/APL.txt. + +package rules + +import ( + "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/rel" + "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scpb" + "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scplan/internal/scgraph" + "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/screl" +) + +// This rule ensures that a new primary index becomes public right after the +// old primary index starts getting removed, effectively swapping one for the +// other. This rule also applies when the schema change gets reverted. +func init() { + + registerDepRule( + "primary index swap", + scgraph.SameStagePrecedence, + "old-index", "new-index", + func(from, to nodeVars) rel.Clauses { + return rel.Clauses{ + from.Type((*scpb.PrimaryIndex)(nil)), + to.Type((*scpb.PrimaryIndex)(nil)), + joinOnDescID(from, to, "table-id"), + joinOn( + from, screl.IndexID, + to, screl.SourceIndexID, + "old-index-id", + ), + from.targetStatus(scpb.ToAbsent), + from.currentStatus(scpb.Status_VALIDATED), + to.targetStatus(scpb.ToPublic, scpb.Transient), + to.currentStatus(scpb.Status_PUBLIC), + } + }, + ) + + registerDepRule( + "primary index swap", + scgraph.SameStagePrecedence, + "old-index", "new-index", + func(from, to nodeVars) rel.Clauses { + return rel.Clauses{ + from.Type((*scpb.PrimaryIndex)(nil)), + to.Type((*scpb.PrimaryIndex)(nil)), + joinOnDescID(from, to, "table-id"), + joinOn( + from, screl.IndexID, + to, screl.SourceIndexID, + "old-index-id", + ), + from.targetStatus(scpb.Transient), + from.currentStatus(scpb.Status_TRANSIENT_VALIDATED), + to.targetStatus(scpb.ToPublic, scpb.Transient), + to.currentStatus(scpb.Status_PUBLIC), + } + }, + ) + + registerDepRule( + "primary index swap", + scgraph.SameStagePrecedence, + "new-index", "old-index", + func(from, to nodeVars) rel.Clauses { + return rel.Clauses{ + from.Type((*scpb.PrimaryIndex)(nil)), + to.Type((*scpb.PrimaryIndex)(nil)), + joinOnDescID(from, to, "table-id"), + joinOn( + from, screl.SourceIndexID, + to, screl.IndexID, + "old-index-id", + ), + from.targetStatus(scpb.ToAbsent), + from.currentStatus(scpb.Status_VALIDATED), + to.targetStatus(scpb.ToPublic), + to.currentStatus(scpb.Status_PUBLIC), + } + }, + ) +} + +// This rule ensures that when a transient primary index is involved in the +// swap, the old index is gone before the new index is instated. +func init() { + + registerDepRule( + "old index absent before new index public when swapping with transient", + scgraph.Precedence, + "old-primary-index", "new-primary-index", + func(from, to nodeVars) rel.Clauses { + union := mkNodeVars("transient-primary-index") + relationID := rel.Var("table-id") + return rel.Clauses{ + from.Type((*scpb.PrimaryIndex)(nil)), + union.Type((*scpb.PrimaryIndex)(nil)), + to.Type((*scpb.PrimaryIndex)(nil)), + joinOnDescID(from, union, relationID), + joinOn( + from, screl.IndexID, + union, screl.SourceIndexID, + "old-index-id", + ), + joinOnDescID(union, to, relationID), + joinOn( + union, screl.IndexID, + to, screl.SourceIndexID, + "transient-index-id", + ), + from.targetStatus(scpb.ToAbsent), + from.currentStatus(scpb.Status_ABSENT), + to.targetStatus(scpb.ToPublic), + to.currentStatus(scpb.Status_PUBLIC), + } + }, + ) +} diff --git a/pkg/sql/schemachanger/scplan/internal/rules/helpers.go b/pkg/sql/schemachanger/scplan/internal/rules/helpers.go index a095750c171b..8ca12d7aea63 100644 --- a/pkg/sql/schemachanger/scplan/internal/rules/helpers.go +++ b/pkg/sql/schemachanger/scplan/internal/rules/helpers.go @@ -16,6 +16,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/catalog/descpb" "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/rel" "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scpb" + "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scplan/internal/scgraph" "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/screl" "github.com/cockroachdb/cockroach/pkg/sql/sem/catid" "github.com/cockroachdb/cockroach/pkg/util/iterutil" @@ -48,15 +49,15 @@ func filterElements(name string, a, b nodeVars, fn interface{}) rel.Clause { return rel.Filter(name, a.el, b.el)(fn) } -func toPublic(from, to nodeVars) rel.Clause { - return toPublicUntyped(from.target, to.target) +func toPublicOrTransient(from, to nodeVars) rel.Clause { + return toPublicOrTransientUntyped(from.target, to.target) } -func statusesToPublic( +func statusesToPublicOrTransient( from nodeVars, fromStatus scpb.Status, to nodeVars, toStatus scpb.Status, ) rel.Clause { return rel.And( - toPublic(from, to), + toPublicOrTransient(from, to), from.currentStatus(fromStatus), to.currentStatus(toStatus), ) @@ -76,6 +77,20 @@ func statusesToAbsent( ) } +func transient(from, to nodeVars) rel.Clause { + return transientUntyped(from.target, to.target) +} + +func statusesTransient( + from nodeVars, fromStatus scpb.Status, to nodeVars, toStatus scpb.Status, +) rel.Clause { + return rel.And( + transient(from, to), + from.currentStatus(fromStatus), + to.currentStatus(toStatus), + ) +} + func joinOnDescID(a, b nodeVars, descriptorIDVar rel.Var) rel.Clause { return joinOnDescIDUntyped(a.el, b.el, descriptorIDVar) } @@ -102,20 +117,20 @@ func columnInIndex( return columnInIndexUntyped(indexColumn.el, index.el, relationIDVar, columnIDVar, indexIDVar) } -func columnInPrimaryIndexSwap( +func columnInSwappedInPrimaryIndex( indexColumn, index nodeVars, relationIDVar, columnIDVar, indexIDVar rel.Var, ) rel.Clause { - return columnInPrimaryIndexSwapUntyped(indexColumn.el, index.el, relationIDVar, columnIDVar, indexIDVar) + return columnInSwappedInPrimaryIndexUntyped(indexColumn.el, index.el, relationIDVar, columnIDVar, indexIDVar) } var ( - toPublicUntyped = screl.Schema.Def2( - "toPublic", + toPublicOrTransientUntyped = screl.Schema.Def2( + "toPublicOrTransient", "target1", "target2", func(target1 rel.Var, target2 rel.Var) rel.Clauses { return rel.Clauses{ - target1.AttrEq(screl.TargetStatus, scpb.Status_PUBLIC), - target2.AttrEq(screl.TargetStatus, scpb.Status_PUBLIC), + target1.AttrIn(screl.TargetStatus, scpb.Status_PUBLIC, scpb.Status_TRANSIENT_ABSENT), + target2.AttrIn(screl.TargetStatus, scpb.Status_PUBLIC, scpb.Status_TRANSIENT_ABSENT), } }) @@ -129,6 +144,16 @@ var ( } }) + transientUntyped = screl.Schema.Def2( + "transient", + "target1", "target2", + func(target1 rel.Var, target2 rel.Var) rel.Clauses { + return rel.Clauses{ + target1.AttrEq(screl.TargetStatus, scpb.Status_TRANSIENT_ABSENT), + target2.AttrEq(screl.TargetStatus, scpb.Status_TRANSIENT_ABSENT), + } + }) + joinReferencedDescIDUntyped = screl.Schema.Def3( "joinReferencedDescID", "referrer", "referenced", "id", func( referrer, referenced, id rel.Var, @@ -191,7 +216,7 @@ var ( } }) - sourceIndexNotSetUntyped = screl.Schema.Def1("sourceIndexNotSet", "index", func( + sourceIndexIsSetUntyped = screl.Schema.Def1("sourceIndexIsSet", "index", func( index rel.Var, ) rel.Clauses { return rel.Clauses{ @@ -199,8 +224,8 @@ var ( } }) - columnInPrimaryIndexSwapUntyped = screl.Schema.Def5( - "columnInPrimaryIndexSwap", + columnInSwappedInPrimaryIndexUntyped = screl.Schema.Def5( + "columnInSwappedInPrimaryIndex", "index-column", "index", "table-id", "column-id", "index-id", func( indexColumn, index, tableID, columnID, indexID rel.Var, ) rel.Clauses { @@ -208,7 +233,7 @@ var ( columnInIndexUntyped( indexColumn, index, tableID, columnID, indexID, ), - sourceIndexNotSetUntyped(index), + sourceIndexIsSetUntyped(index), } }) ) @@ -359,3 +384,58 @@ func isIndexDependent(e scpb.Element) bool { } return false } + +// registerDepRuleForDrop is a convenience function which calls +// registerDepRule with the cross-product of (ToAbsent,Transient)^2 target +// states, which can't easily be composed. +func registerDepRuleForDrop( + ruleName scgraph.RuleName, + kind scgraph.DepEdgeKind, + from, to string, + fromStatus, toStatus scpb.Status, + fn func(from, to nodeVars) rel.Clauses, +) { + + transientFromStatus, okFrom := scpb.GetTransientEquivalent(fromStatus) + if !okFrom { + panic(errors.AssertionFailedf("Invalid 'from' status %s", fromStatus)) + } + transientToStatus, okTo := scpb.GetTransientEquivalent(toStatus) + if !okTo { + panic(errors.AssertionFailedf("Invalid 'from' status %s", toStatus)) + } + + registerDepRule(ruleName, kind, from, to, func(from, to nodeVars) rel.Clauses { + return append( + fn(from, to), + statusesToAbsent(from, fromStatus, to, toStatus), + ) + }) + + registerDepRule(ruleName, kind, from, to, func(from, to nodeVars) rel.Clauses { + return append( + fn(from, to), + statusesTransient(from, transientFromStatus, to, transientToStatus), + ) + }) + + registerDepRule(ruleName, kind, from, to, func(from, to nodeVars) rel.Clauses { + return append( + fn(from, to), + from.targetStatus(scpb.Transient), + from.currentStatus(transientFromStatus), + to.targetStatus(scpb.ToAbsent), + to.currentStatus(toStatus), + ) + }) + + registerDepRule(ruleName, kind, from, to, func(from, to nodeVars) rel.Clauses { + return append( + fn(from, to), + from.targetStatus(scpb.ToAbsent), + from.currentStatus(fromStatus), + to.targetStatus(scpb.Transient), + to.currentStatus(transientToStatus), + ) + }) +} diff --git a/pkg/sql/schemachanger/scplan/internal/rules/op_index_and_column.go b/pkg/sql/schemachanger/scplan/internal/rules/op_index_and_column.go new file mode 100644 index 000000000000..c436d15b447c --- /dev/null +++ b/pkg/sql/schemachanger/scplan/internal/rules/op_index_and_column.go @@ -0,0 +1,40 @@ +// Copyright 2022 The Cockroach Authors. +// +// Use of this software is governed by the Business Source License +// included in the file licenses/BSL.txt. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0, included in the file +// licenses/APL.txt. + +package rules + +import ( + "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/rel" + "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scpb" + "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/screl" +) + +// Skill all IndexColumn removal ops for indexes which are also being removed. +func init() { + + ic := mkNodeVars("index-column") + index := mkNodeVars("index") + relationID, indexID := rel.Var("relation-id"), rel.Var("index-id") + + registerOpRule( + "skip index-column removal ops on index removal", + ic.node, + screl.MustQuery( + ic.Type((*scpb.IndexColumn)(nil)), + index.typeFilter(isIndex), + joinOnIndexID(ic, index, relationID, indexID), + ic.joinTargetNode(), + ic.targetStatus(scpb.ToAbsent, scpb.Transient), + ic.currentStatus(scpb.Status_PUBLIC, scpb.Status_TRANSIENT_PUBLIC), + index.joinTarget(), + index.targetStatus(scpb.ToAbsent, scpb.Transient), + ), + ) +} diff --git a/pkg/sql/schemachanger/scplan/internal/rules/registry.go b/pkg/sql/schemachanger/scplan/internal/rules/registry.go index 7eb37bddc353..4010bb579366 100644 --- a/pkg/sql/schemachanger/scplan/internal/rules/registry.go +++ b/pkg/sql/schemachanger/scplan/internal/rules/registry.go @@ -164,8 +164,18 @@ func (v nodeVars) joinTarget() rel.Clause { return screl.JoinTarget(v.el, v.target) } -func (v nodeVars) targetStatus(status scpb.TargetStatus) rel.Clause { - return v.target.AttrEq(screl.TargetStatus, status.Status()) +func (v nodeVars) targetStatus(status ...scpb.TargetStatus) rel.Clause { + if len(status) == 0 { + panic(errors.AssertionFailedf("empty current status values")) + } + if len(status) == 1 { + return v.target.AttrEq(screl.TargetStatus, status[0].Status()) + } + in := make([]interface{}, len(status)) + for i, s := range status { + in[i] = s.Status() + } + return v.target.AttrIn(screl.TargetStatus, in...) } // Type delegates to the element var Type method. diff --git a/pkg/sql/schemachanger/scplan/internal/rules/testdata/deprules b/pkg/sql/schemachanger/scplan/internal/rules/testdata/deprules index df57627190ea..f0c27c27ca3f 100644 --- a/pkg/sql/schemachanger/scplan/internal/rules/testdata/deprules +++ b/pkg/sql/schemachanger/scplan/internal/rules/testdata/deprules @@ -6,9 +6,9 @@ columnInIndex(index-column, index, table-id, column-id, index-id): - $index-column[ColumnID] = $column-id - $index[IndexID] = $index-id - joinOnIndexID($index, $index-column, $table-id, $index-id) -columnInPrimaryIndexSwap(index-column, index, table-id, column-id, index-id): +columnInSwappedInPrimaryIndex(index-column, index, table-id, column-id, index-id): - columnInIndex($index-column, $index, $table-id, $column-id, $index-id) - - sourceIndexNotSet($index) + - sourceIndexIsSet($index) joinOnColumnID(a, b, desc-id, col-id): - joinOnDescID($a, $b, $desc-id) - $a[ColumnID] = $col-id @@ -35,14 +35,17 @@ joinTargetNode(element, target, node): - joinTarget($element, $target) - $node[Type] = '*screl.Node' - $node[Target] = $target -sourceIndexNotSet(index): +sourceIndexIsSet(index): - $index[SourceIndexID] != 0 toAbsent(target1, target2): - $target1[TargetStatus] = ABSENT - $target2[TargetStatus] = ABSENT -toPublic(target1, target2): - - $target1[TargetStatus] = PUBLIC - - $target2[TargetStatus] = PUBLIC +toPublicOrTransient(target1, target2): + - $target1[TargetStatus] IN [PUBLIC, TRANSIENT_ABSENT] + - $target2[TargetStatus] IN [PUBLIC, TRANSIENT_ABSENT] +transient(target1, target2): + - $target1[TargetStatus] = TRANSIENT_ABSENT + - $target2[TargetStatus] = TRANSIENT_ABSENT deprules ---- @@ -54,60 +57,33 @@ deprules - $expr[Type] IN ['*scpb.ColumnDefaultExpression', '*scpb.ColumnOnUpdateExpression'] - $column[Type] = '*scpb.Column' - joinOnColumnID($expr, $column, $table-id, $col-id) - - toPublic($expr-target, $column-target) + - toPublicOrTransient($expr-target, $column-target) - $expr-node[CurrentStatus] = PUBLIC - $column-node[CurrentStatus] = WRITE_ONLY - joinTargetNode($expr, $expr-target, $expr-node) - joinTargetNode($column, $column-target, $column-node) -- name: adding column depends on primary index - from: index-node - kind: Precedence - to: column-node - query: - - $index[Type] = '*scpb.PrimaryIndex' - - $column[Type] = '*scpb.Column' - - columnInPrimaryIndexSwap($index-column, $index, $table-id, $column-id, $index-id) - - joinOnColumnID($index-column, $column, $table-id, $column-id) - - toPublic($index-target, $column-target) - - $index-node[CurrentStatus] = PUBLIC - - $column-node[CurrentStatus] = PUBLIC - - joinTargetNode($index, $index-target, $index-node) - - joinTargetNode($column, $column-target, $column-node) -- name: column comment exists before column becomes public - from: column-comment-node +- name: column dependents exist before column becomes public + from: dependent-node kind: Precedence to: column-node query: - - $column-comment[Type] = '*scpb.ColumnComment' + - $dependent[Type] IN ['*scpb.ColumnName', '*scpb.ColumnType', '*scpb.ColumnDefaultExpression', '*scpb.ColumnOnUpdateExpression', '*scpb.SequenceOwner', '*scpb.ColumnComment', '*scpb.IndexColumn'] - $column[Type] = '*scpb.Column' - - joinOnColumnID($column-comment, $column, $table-id, $col-id) - - toPublic($column-comment-target, $column-target) - - $column-comment-node[CurrentStatus] = PUBLIC + - joinOnColumnID($dependent, $column, $table-id, $col-id) + - toPublicOrTransient($dependent-target, $column-target) + - $dependent-node[CurrentStatus] = PUBLIC - $column-node[CurrentStatus] = PUBLIC - - joinTargetNode($column-comment, $column-comment-target, $column-comment-node) - - joinTargetNode($column, $column-target, $column-node) -- name: column dependents removed after column no longer public - from: column-node - kind: Precedence - to: dependent-node - query: - - $column[Type] = '*scpb.Column' - - $dependent[Type] IN ['*scpb.ColumnType', '*scpb.ColumnName', '*scpb.ColumnComment'] - - joinOnColumnID($column, $dependent, $table-id, $col-id) - - toAbsent($column-target, $dependent-target) - - $column-node[CurrentStatus] = WRITE_ONLY - - $dependent-node[CurrentStatus] = ABSENT - - joinTargetNode($column, $column-target, $column-node) - joinTargetNode($dependent, $dependent-target, $dependent-node) + - joinTargetNode($column, $column-target, $column-node) - name: column existence precedes column dependents from: column-node kind: Precedence to: dependent-node query: - $column[Type] = '*scpb.Column' - - $dependent[Type] IN ['*scpb.ColumnName', '*scpb.ColumnDefaultExpression', '*scpb.ColumnOnUpdateExpression', '*scpb.ColumnComment', '*scpb.IndexColumn'] + - $dependent[Type] IN ['*scpb.ColumnName', '*scpb.ColumnType', '*scpb.ColumnDefaultExpression', '*scpb.ColumnOnUpdateExpression', '*scpb.SequenceOwner', '*scpb.ColumnComment', '*scpb.IndexColumn'] - joinOnColumnID($column, $dependent, $table-id, $col-id) - - toPublic($column-target, $dependent-target) + - toPublicOrTransient($column-target, $dependent-target) - $column-node[CurrentStatus] = DELETE_ONLY - $dependent-node[CurrentStatus] = PUBLIC - joinTargetNode($column, $column-target, $column-node) @@ -121,26 +97,25 @@ deprules - $index[Type] IN ['*scpb.PrimaryIndex', '*scpb.SecondaryIndex'] - joinOnColumnID($column, $index-column, $table-id, $column-id) - columnInIndex($index-column, $index, $table-id, $column-id, $index-id) - - toPublic($column-target, $index-target) + - toPublicOrTransient($column-target, $index-target) - $column-node[CurrentStatus] = DELETE_ONLY - $index-node[CurrentStatus] = BACKFILL_ONLY - joinTargetNode($column, $column-target, $column-node) - joinTargetNode($index, $index-target, $index-node) -- name: column existence precedes temporary index existence +- name: column existence precedes temp index existence from: column-node kind: Precedence - to: temp-index-node + to: index-node query: - $column[Type] = '*scpb.Column' - - $temp-index[Type] = '*scpb.TemporaryIndex' - - columnInIndex($index-column, $temp-index, $table-id, $column-id, $temp-index-id) + - $index[Type] = '*scpb.TemporaryIndex' - joinOnColumnID($index-column, $column, $table-id, $column-id) - - $column-target[TargetStatus] = PUBLIC - - $temp-index-target[TargetStatus] = TRANSIENT_ABSENT + - columnInIndex($index-column, $index, $table-id, $column-id, $index-id) + - toPublicOrTransient($column-target, $index-target) - $column-node[CurrentStatus] = DELETE_ONLY - - $temp-index-node[CurrentStatus] = DELETE_ONLY + - $index-node[CurrentStatus] = DELETE_ONLY - joinTargetNode($column, $column-target, $column-node) - - joinTargetNode($temp-index, $temp-index-target, $temp-index-node) + - joinTargetNode($index, $index-target, $index-node) - name: column is WRITE_ONLY before temporary index is WRITE_ONLY from: column-node kind: Precedence @@ -150,57 +125,84 @@ deprules - $index[Type] = '*scpb.TemporaryIndex' - joinOnColumnID($index-column, $column, $table-id, $column-id) - columnInIndex($index-column, $index, $table-id, $column-id, $index-id) - - $column-target[TargetStatus] = PUBLIC - - $index-target[TargetStatus] = TRANSIENT_ABSENT + - toPublicOrTransient($column-target, $index-target) - $column-node[CurrentStatus] = WRITE_ONLY - $index-node[CurrentStatus] = WRITE_ONLY - joinTargetNode($column, $column-target, $column-node) - joinTargetNode($index, $index-target, $index-node) -- name: column name and type to public after all index column to public - from: column-name-or-type-node - kind: Precedence - to: index-column-node +- name: column name and type set right after column existence + from: column-node + kind: SameStagePrecedence + to: column-name-or-type-node query: + - $column[Type] = '*scpb.Column' - $column-name-or-type[Type] IN ['*scpb.ColumnName', '*scpb.ColumnType'] - - $index-column[Type] = '*scpb.IndexColumn' - - joinOnColumnID($column-name-or-type, $index-column, $table-id, $column-id) - - toPublic($column-name-or-type-target, $index-column-target) + - toPublicOrTransient($column-target, $column-name-or-type-target) + - $column-node[CurrentStatus] = DELETE_ONLY - $column-name-or-type-node[CurrentStatus] = PUBLIC - - $index-column-node[CurrentStatus] = PUBLIC + - joinOnColumnID($column, $column-name-or-type, $table-id, $col-id) + - joinTargetNode($column, $column-target, $column-node) - joinTargetNode($column-name-or-type, $column-name-or-type-target, $column-name-or-type-node) - - joinTargetNode($index-column, $index-column-target, $index-column-node) -- name: column name set right after column existence +- name: column no longer public before dependents from: column-node - kind: SameStagePrecedence - to: column-name-node + kind: Precedence + to: dependent-node query: - $column[Type] = '*scpb.Column' - - $column-name[Type] = '*scpb.ColumnName' - - toPublic($column-target, $column-name-target) - - $column-node[CurrentStatus] = DELETE_ONLY - - $column-name-node[CurrentStatus] = PUBLIC - - joinOnColumnID($column, $column-name, $table-id, $col-id) + - $dependent[Type] IN ['*scpb.ColumnName', '*scpb.ColumnType', '*scpb.ColumnDefaultExpression', '*scpb.ColumnOnUpdateExpression', '*scpb.SequenceOwner', '*scpb.ColumnComment', '*scpb.IndexColumn'] + - joinOnColumnID($column, $dependent, $table-id, $col-id) + - $column-target[TargetStatus] = ABSENT + - $column-node[CurrentStatus] = WRITE_ONLY + - $dependent-target[TargetStatus] = TRANSIENT_ABSENT + - $dependent-node[CurrentStatus] = TRANSIENT_ABSENT - joinTargetNode($column, $column-target, $column-node) - - joinTargetNode($column-name, $column-name-target, $column-name-node) -- name: column named before column type becomes public - from: column-name-node + - joinTargetNode($dependent, $dependent-target, $dependent-node) +- name: column no longer public before dependents + from: column-node kind: Precedence - to: column-type-node + to: dependent-node query: - - $column-name[Type] = '*scpb.ColumnName' - - $column-type[Type] = '*scpb.ColumnType' - - joinOnColumnID($column-name, $column-type, $table-id, $col-id) - - toPublic($column-name-target, $column-type-target) - - $column-name-node[CurrentStatus] = PUBLIC - - $column-type-node[CurrentStatus] = PUBLIC - - joinTargetNode($column-name, $column-name-target, $column-name-node) - - joinTargetNode($column-type, $column-type-target, $column-type-node) + - $column[Type] = '*scpb.Column' + - $dependent[Type] IN ['*scpb.ColumnName', '*scpb.ColumnType', '*scpb.ColumnDefaultExpression', '*scpb.ColumnOnUpdateExpression', '*scpb.SequenceOwner', '*scpb.ColumnComment', '*scpb.IndexColumn'] + - joinOnColumnID($column, $dependent, $table-id, $col-id) + - $column-target[TargetStatus] = TRANSIENT_ABSENT + - $column-node[CurrentStatus] = TRANSIENT_WRITE_ONLY + - $dependent-target[TargetStatus] = ABSENT + - $dependent-node[CurrentStatus] = ABSENT + - joinTargetNode($column, $column-target, $column-node) + - joinTargetNode($dependent, $dependent-target, $dependent-node) +- name: column no longer public before dependents + from: column-node + kind: Precedence + to: dependent-node + query: + - $column[Type] = '*scpb.Column' + - $dependent[Type] IN ['*scpb.ColumnName', '*scpb.ColumnType', '*scpb.ColumnDefaultExpression', '*scpb.ColumnOnUpdateExpression', '*scpb.SequenceOwner', '*scpb.ColumnComment', '*scpb.IndexColumn'] + - joinOnColumnID($column, $dependent, $table-id, $col-id) + - transient($column-target, $dependent-target) + - $column-node[CurrentStatus] = TRANSIENT_WRITE_ONLY + - $dependent-node[CurrentStatus] = TRANSIENT_ABSENT + - joinTargetNode($column, $column-target, $column-node) + - joinTargetNode($dependent, $dependent-target, $dependent-node) +- name: column no longer public before dependents + from: column-node + kind: Precedence + to: dependent-node + query: + - $column[Type] = '*scpb.Column' + - $dependent[Type] IN ['*scpb.ColumnName', '*scpb.ColumnType', '*scpb.ColumnDefaultExpression', '*scpb.ColumnOnUpdateExpression', '*scpb.SequenceOwner', '*scpb.ColumnComment', '*scpb.IndexColumn'] + - joinOnColumnID($column, $dependent, $table-id, $col-id) + - toAbsent($column-target, $dependent-target) + - $column-node[CurrentStatus] = WRITE_ONLY + - $dependent-node[CurrentStatus] = ABSENT + - joinTargetNode($column, $column-target, $column-node) + - joinTargetNode($dependent, $dependent-target, $dependent-node) - name: column type dependents removed right before column type from: dependent-node kind: SameStagePrecedence to: column-type-node query: - - $dependent[Type] IN ['*scpb.SequenceOwner', '*scpb.ColumnDefaultExpression', '*scpb.ColumnOnUpdateExpression'] + - $dependent[Type] IN ['*scpb.ColumnDefaultExpression', '*scpb.ColumnOnUpdateExpression', '*scpb.SequenceOwner'] - $column-type[Type] = '*scpb.ColumnType' - joinOnColumnID($dependent, $column-type, $table-id, $col-id) - toAbsent($dependent-target, $column-type-target) @@ -219,35 +221,104 @@ deprules - toAbsent($column-type-target, $column-target) - $column-type-node[CurrentStatus] = ABSENT - $column-node[CurrentStatus] = ABSENT - - RelationIsNotBeingDropped(*scpb.ColumnType)($column-type) + - relationIsNotBeingDropped(*scpb.ColumnType)($column-type) - joinTargetNode($column-type, $column-type-target, $column-type-node) - joinTargetNode($column, $column-target, $column-node) -- name: comment existence precedes index becoming public - from: child-node +- name: dependents removed before column + from: dependent-node kind: Precedence - to: index-node + to: column-node query: - - $child[Type] = '*scpb.IndexComment' - - $index[Type] IN ['*scpb.PrimaryIndex', '*scpb.SecondaryIndex'] - - joinOnIndexID($child, $index, $table-id, $index-id) - - toPublic($child-target, $index-target) - - $child-node[CurrentStatus] = PUBLIC - - $index-node[CurrentStatus] = PUBLIC - - joinTargetNode($child, $child-target, $child-node) - - joinTargetNode($index, $index-target, $index-node) + - $dependent[Type] IN ['*scpb.ColumnName', '*scpb.ColumnType', '*scpb.ColumnDefaultExpression', '*scpb.ColumnOnUpdateExpression', '*scpb.SequenceOwner', '*scpb.ColumnComment', '*scpb.IndexColumn'] + - $column[Type] = '*scpb.Column' + - joinOnColumnID($dependent, $column, $table-id, $col-id) + - toAbsent($dependent-target, $column-target) + - $dependent-node[CurrentStatus] = ABSENT + - $column-node[CurrentStatus] = ABSENT + - joinTargetNode($dependent, $dependent-target, $dependent-node) + - joinTargetNode($column, $column-target, $column-node) - name: dependents removed before column from: dependent-node kind: Precedence to: column-node query: - - $dependent[Type] IN ['*scpb.ColumnName', '*scpb.ColumnType', '*scpb.ColumnComment'] + - $dependent[Type] IN ['*scpb.ColumnName', '*scpb.ColumnType', '*scpb.ColumnDefaultExpression', '*scpb.ColumnOnUpdateExpression', '*scpb.SequenceOwner', '*scpb.ColumnComment', '*scpb.IndexColumn'] - $column[Type] = '*scpb.Column' - joinOnColumnID($dependent, $column, $table-id, $col-id) - - toAbsent($dependent-target, $column-target) + - transient($dependent-target, $column-target) + - $dependent-node[CurrentStatus] = TRANSIENT_ABSENT + - $column-node[CurrentStatus] = TRANSIENT_ABSENT + - joinTargetNode($dependent, $dependent-target, $dependent-node) + - joinTargetNode($column, $column-target, $column-node) +- name: dependents removed before column + from: dependent-node + kind: Precedence + to: column-node + query: + - $dependent[Type] IN ['*scpb.ColumnName', '*scpb.ColumnType', '*scpb.ColumnDefaultExpression', '*scpb.ColumnOnUpdateExpression', '*scpb.SequenceOwner', '*scpb.ColumnComment', '*scpb.IndexColumn'] + - $column[Type] = '*scpb.Column' + - joinOnColumnID($dependent, $column, $table-id, $col-id) + - $dependent-target[TargetStatus] = ABSENT - $dependent-node[CurrentStatus] = ABSENT + - $column-target[TargetStatus] = TRANSIENT_ABSENT + - $column-node[CurrentStatus] = TRANSIENT_ABSENT + - joinTargetNode($dependent, $dependent-target, $dependent-node) + - joinTargetNode($column, $column-target, $column-node) +- name: dependents removed before column + from: dependent-node + kind: Precedence + to: column-node + query: + - $dependent[Type] IN ['*scpb.ColumnName', '*scpb.ColumnType', '*scpb.ColumnDefaultExpression', '*scpb.ColumnOnUpdateExpression', '*scpb.SequenceOwner', '*scpb.ColumnComment', '*scpb.IndexColumn'] + - $column[Type] = '*scpb.Column' + - joinOnColumnID($dependent, $column, $table-id, $col-id) + - $dependent-target[TargetStatus] = TRANSIENT_ABSENT + - $dependent-node[CurrentStatus] = TRANSIENT_ABSENT + - $column-target[TargetStatus] = ABSENT - $column-node[CurrentStatus] = ABSENT - joinTargetNode($dependent, $dependent-target, $dependent-node) - joinTargetNode($column, $column-target, $column-node) +- name: dependents removed before index + from: dependent-node + kind: Precedence + to: index-node + query: + - $dependent[Type] IN ['*scpb.IndexName', '*scpb.IndexPartitioning', '*scpb.SecondaryIndexPartial', '*scpb.IndexComment', '*scpb.IndexColumn'] + - $index[Type] IN ['*scpb.PrimaryIndex', '*scpb.SecondaryIndex', '*scpb.TemporaryIndex'] + - joinOnIndexID($dependent, $index, $table-id, $index-id) + - $dependent-target[TargetStatus] = ABSENT + - $dependent-node[CurrentStatus] = ABSENT + - $index-target[TargetStatus] = TRANSIENT_ABSENT + - $index-node[CurrentStatus] = TRANSIENT_ABSENT + - joinTargetNode($dependent, $dependent-target, $dependent-node) + - joinTargetNode($index, $index-target, $index-node) +- name: dependents removed before index + from: dependent-node + kind: Precedence + to: index-node + query: + - $dependent[Type] IN ['*scpb.IndexName', '*scpb.IndexPartitioning', '*scpb.SecondaryIndexPartial', '*scpb.IndexComment', '*scpb.IndexColumn'] + - $index[Type] IN ['*scpb.PrimaryIndex', '*scpb.SecondaryIndex', '*scpb.TemporaryIndex'] + - joinOnIndexID($dependent, $index, $table-id, $index-id) + - $dependent-target[TargetStatus] = TRANSIENT_ABSENT + - $dependent-node[CurrentStatus] = TRANSIENT_ABSENT + - $index-target[TargetStatus] = ABSENT + - $index-node[CurrentStatus] = ABSENT + - joinTargetNode($dependent, $dependent-target, $dependent-node) + - joinTargetNode($index, $index-target, $index-node) +- name: dependents removed before index + from: dependent-node + kind: Precedence + to: index-node + query: + - $dependent[Type] IN ['*scpb.IndexName', '*scpb.IndexPartitioning', '*scpb.SecondaryIndexPartial', '*scpb.IndexComment', '*scpb.IndexColumn'] + - $index[Type] IN ['*scpb.PrimaryIndex', '*scpb.SecondaryIndex', '*scpb.TemporaryIndex'] + - joinOnIndexID($dependent, $index, $table-id, $index-id) + - transient($dependent-target, $index-target) + - $dependent-node[CurrentStatus] = TRANSIENT_ABSENT + - $index-node[CurrentStatus] = TRANSIENT_ABSENT + - joinTargetNode($dependent, $dependent-target, $dependent-node) + - joinTargetNode($index, $index-target, $index-node) - name: dependents removed before index from: dependent-node kind: Precedence @@ -334,26 +405,39 @@ deprules - $later-column[Type] = '*scpb.Column' - $earlier-column[Type] = '*scpb.Column' - joinOnDescID($later-column, $earlier-column, $table-id) - - toPublic($later-column-target, $earlier-column-target) + - toPublicOrTransient($later-column-target, $earlier-column-target) - $status IN [WRITE_ONLY, PUBLIC] - $later-column-node[CurrentStatus] = $status - $earlier-column-node[CurrentStatus] = $status - SmallerColumnIDFirst(*scpb.Column, *scpb.Column)($later-column, $earlier-column) - joinTargetNode($later-column, $later-column-target, $later-column-node) - joinTargetNode($earlier-column, $earlier-column-target, $earlier-column-node) -- name: index existence precedes index name and comment +- name: index dependents exist before index becomes public + from: dependent-node + kind: Precedence + to: index-node + query: + - $dependent[Type] IN ['*scpb.IndexName', '*scpb.IndexPartitioning', '*scpb.SecondaryIndexPartial', '*scpb.IndexComment', '*scpb.IndexColumn'] + - $index[Type] IN ['*scpb.PrimaryIndex', '*scpb.SecondaryIndex', '*scpb.TemporaryIndex'] + - joinOnIndexID($dependent, $index, $table-id, $index-id) + - toPublicOrTransient($dependent-target, $index-target) + - $dependent-node[CurrentStatus] = PUBLIC + - $index-node[CurrentStatus] = PUBLIC + - joinTargetNode($dependent, $dependent-target, $dependent-node) + - joinTargetNode($index, $index-target, $index-node) +- name: index existence precedes index dependents from: index-node kind: Precedence - to: index-dependent-node + to: dependent-node query: - $index[Type] IN ['*scpb.PrimaryIndex', '*scpb.SecondaryIndex'] - - $index-dependent[Type] IN ['*scpb.IndexName', '*scpb.IndexComment'] - - joinOnIndexID($index, $index-dependent, $table-id, $index-id) - - toPublic($index-target, $index-dependent-target) + - $dependent[Type] IN ['*scpb.IndexName', '*scpb.IndexPartitioning', '*scpb.SecondaryIndexPartial', '*scpb.IndexComment', '*scpb.IndexColumn'] + - joinOnIndexID($index, $dependent, $table-id, $index-id) + - toPublicOrTransient($index-target, $dependent-target) - $index-node[CurrentStatus] = BACKFILL_ONLY - - $index-dependent-node[CurrentStatus] = PUBLIC + - $dependent-node[CurrentStatus] = PUBLIC - joinTargetNode($index, $index-target, $index-node) - - joinTargetNode($index-dependent, $index-dependent-target, $index-dependent-node) + - joinTargetNode($dependent, $dependent-target, $dependent-node) - name: index named right before index becomes public from: index-name-node kind: SameStagePrecedence @@ -361,52 +445,66 @@ deprules query: - $index-name[Type] = '*scpb.IndexName' - $index[Type] IN ['*scpb.PrimaryIndex', '*scpb.SecondaryIndex'] - - toPublic($index-name-target, $index-target) + - joinOnIndexID($index-name, $index, $table-id, $index-id) + - toPublicOrTransient($index-name-target, $index-target) - $index-name-node[CurrentStatus] = PUBLIC - $index-node[CurrentStatus] = PUBLIC - - joinOnIndexID($index-name, $index, $table-id, $index-id) - joinTargetNode($index-name, $index-name-target, $index-name-node) - joinTargetNode($index, $index-target, $index-node) -- name: index no longer public before dependents removed +- name: index no longer public before dependents from: index-node kind: Precedence - to: child-node + to: dependent-node query: - $index[Type] IN ['*scpb.PrimaryIndex', '*scpb.SecondaryIndex', '*scpb.TemporaryIndex'] - - $child[Type] IN ['*scpb.IndexName', '*scpb.IndexPartitioning', '*scpb.SecondaryIndexPartial', '*scpb.IndexComment', '*scpb.IndexColumn'] - - joinOnIndexID($index, $child, $table-id, $index-id) - - toAbsent($index-target, $child-target) + - $dependent[Type] IN ['*scpb.IndexName', '*scpb.IndexPartitioning', '*scpb.SecondaryIndexPartial', '*scpb.IndexComment', '*scpb.IndexColumn'] + - joinOnIndexID($index, $dependent, $table-id, $index-id) + - toAbsent($index-target, $dependent-target) - $index-node[CurrentStatus] = VALIDATED - - $child-node[CurrentStatus] = ABSENT + - $dependent-node[CurrentStatus] = ABSENT - joinTargetNode($index, $index-target, $index-node) - - joinTargetNode($child, $child-target, $child-node) -- name: index-column added to index after index exists + - joinTargetNode($dependent, $dependent-target, $dependent-node) +- name: index no longer public before dependents from: index-node kind: Precedence - to: index-column-node + to: dependent-node query: - - $index[Type] IN ['*scpb.PrimaryIndex', '*scpb.SecondaryIndex'] - - $index-column[Type] = '*scpb.IndexColumn' - - joinOnIndexID($index, $index-column, $table-id, $index-id) - - toPublic($index-target, $index-column-target) - - $index-node[CurrentStatus] = BACKFILL_ONLY - - $index-column-node[CurrentStatus] = PUBLIC + - $index[Type] IN ['*scpb.PrimaryIndex', '*scpb.SecondaryIndex', '*scpb.TemporaryIndex'] + - $dependent[Type] IN ['*scpb.IndexName', '*scpb.IndexPartitioning', '*scpb.SecondaryIndexPartial', '*scpb.IndexComment', '*scpb.IndexColumn'] + - joinOnIndexID($index, $dependent, $table-id, $index-id) + - $index-target[TargetStatus] = TRANSIENT_ABSENT + - $index-node[CurrentStatus] = TRANSIENT_VALIDATED + - $dependent-target[TargetStatus] = ABSENT + - $dependent-node[CurrentStatus] = ABSENT - joinTargetNode($index, $index-target, $index-node) - - joinTargetNode($index-column, $index-column-target, $index-column-node) -- name: index-column added to index after temp index exists + - joinTargetNode($dependent, $dependent-target, $dependent-node) +- name: index no longer public before dependents from: index-node kind: Precedence - to: index-column-node + to: dependent-node query: - - $index[Type] = '*scpb.TemporaryIndex' - - $index-column[Type] = '*scpb.IndexColumn' - - joinOnIndexID($index, $index-column, $table-id, $index-id) - - $index-target[TargetStatus] = TRANSIENT_ABSENT - - $index-column-target[TargetStatus] = PUBLIC - - $index-node[CurrentStatus] = DELETE_ONLY - - $index-column-node[CurrentStatus] = PUBLIC + - $index[Type] IN ['*scpb.PrimaryIndex', '*scpb.SecondaryIndex', '*scpb.TemporaryIndex'] + - $dependent[Type] IN ['*scpb.IndexName', '*scpb.IndexPartitioning', '*scpb.SecondaryIndexPartial', '*scpb.IndexComment', '*scpb.IndexColumn'] + - joinOnIndexID($index, $dependent, $table-id, $index-id) + - $index-target[TargetStatus] = ABSENT + - $index-node[CurrentStatus] = VALIDATED + - $dependent-target[TargetStatus] = TRANSIENT_ABSENT + - $dependent-node[CurrentStatus] = TRANSIENT_ABSENT - joinTargetNode($index, $index-target, $index-node) - - joinTargetNode($index-column, $index-column-target, $index-column-node) + - joinTargetNode($dependent, $dependent-target, $dependent-node) +- name: index no longer public before dependents + from: index-node + kind: Precedence + to: dependent-node + query: + - $index[Type] IN ['*scpb.PrimaryIndex', '*scpb.SecondaryIndex', '*scpb.TemporaryIndex'] + - $dependent[Type] IN ['*scpb.IndexName', '*scpb.IndexPartitioning', '*scpb.SecondaryIndexPartial', '*scpb.IndexComment', '*scpb.IndexColumn'] + - joinOnIndexID($index, $dependent, $table-id, $index-id) + - transient($index-target, $dependent-target) + - $index-node[CurrentStatus] = TRANSIENT_VALIDATED + - $dependent-node[CurrentStatus] = TRANSIENT_ABSENT + - joinTargetNode($index, $index-target, $index-node) + - joinTargetNode($dependent, $dependent-target, $dependent-node) - name: index-column added to index before index is backfilled from: index-column-node kind: Precedence @@ -415,7 +513,7 @@ deprules - $index-column[Type] = '*scpb.IndexColumn' - $index[Type] IN ['*scpb.PrimaryIndex', '*scpb.SecondaryIndex'] - joinOnIndexID($index-column, $index, $table-id, $index-id) - - toPublic($index-column-target, $index-target) + - toPublicOrTransient($index-column-target, $index-target) - $index-column-node[CurrentStatus] = PUBLIC - $index-node[CurrentStatus] = BACKFILLED - joinTargetNode($index-column, $index-column-target, $index-column-node) @@ -428,13 +526,12 @@ deprules - $index-column[Type] = '*scpb.IndexColumn' - $index[Type] = '*scpb.TemporaryIndex' - joinOnIndexID($index-column, $index, $table-id, $index-id) - - $index-column-target[TargetStatus] = PUBLIC - - $index-target[TargetStatus] = TRANSIENT_ABSENT + - transient($index-column-target, $index-target) - $index-column-node[CurrentStatus] = PUBLIC - $index-node[CurrentStatus] = WRITE_ONLY - joinTargetNode($index-column, $index-column-target, $index-column-node) - joinTargetNode($index, $index-target, $index-node) -- name: indexes containing columns reach absent before column +- name: indexes containing column reach absent before column from: index-node kind: Precedence to: column-node @@ -445,12 +542,115 @@ deprules - columnInIndex($index-column, $index, $table-id, $column-id, $index-id) - joinOnColumnID($index-column, $column, $table-id, $column-id) - joinOnColumnID($index-column, $column-type, $table-id, $column-id) + - relationIsNotBeingDropped(*scpb.ColumnType)($column-type) - toAbsent($index-target, $column-target) - $index-node[CurrentStatus] = ABSENT - $column-node[CurrentStatus] = ABSENT - - RelationIsNotBeingDropped(*scpb.ColumnType)($column-type) - joinTargetNode($index, $index-target, $index-node) - joinTargetNode($column, $column-target, $column-node) +- name: indexes containing column reach absent before column + from: index-node + kind: Precedence + to: column-node + query: + - $index[Type] IN ['*scpb.PrimaryIndex', '*scpb.SecondaryIndex'] + - $column[Type] = '*scpb.Column' + - $column-type[Type] = '*scpb.ColumnType' + - columnInIndex($index-column, $index, $table-id, $column-id, $index-id) + - joinOnColumnID($index-column, $column, $table-id, $column-id) + - joinOnColumnID($index-column, $column-type, $table-id, $column-id) + - relationIsNotBeingDropped(*scpb.ColumnType)($column-type) + - $index-target[TargetStatus] = ABSENT + - $index-node[CurrentStatus] = ABSENT + - $column-target[TargetStatus] = TRANSIENT_ABSENT + - $column-node[CurrentStatus] = TRANSIENT_ABSENT + - joinTargetNode($index, $index-target, $index-node) + - joinTargetNode($column, $column-target, $column-node) +- name: indexes containing column reach absent before column + from: index-node + kind: Precedence + to: column-node + query: + - $index[Type] IN ['*scpb.PrimaryIndex', '*scpb.SecondaryIndex'] + - $column[Type] = '*scpb.Column' + - $column-type[Type] = '*scpb.ColumnType' + - columnInIndex($index-column, $index, $table-id, $column-id, $index-id) + - joinOnColumnID($index-column, $column, $table-id, $column-id) + - joinOnColumnID($index-column, $column-type, $table-id, $column-id) + - relationIsNotBeingDropped(*scpb.ColumnType)($column-type) + - $index-target[TargetStatus] = TRANSIENT_ABSENT + - $index-node[CurrentStatus] = TRANSIENT_ABSENT + - $column-target[TargetStatus] = ABSENT + - $column-node[CurrentStatus] = ABSENT + - joinTargetNode($index, $index-target, $index-node) + - joinTargetNode($column, $column-target, $column-node) +- name: indexes containing column reach absent before column + from: index-node + kind: Precedence + to: column-node + query: + - $index[Type] IN ['*scpb.PrimaryIndex', '*scpb.SecondaryIndex'] + - $column[Type] = '*scpb.Column' + - $column-type[Type] = '*scpb.ColumnType' + - columnInIndex($index-column, $index, $table-id, $column-id, $index-id) + - joinOnColumnID($index-column, $column, $table-id, $column-id) + - joinOnColumnID($index-column, $column-type, $table-id, $column-id) + - relationIsNotBeingDropped(*scpb.ColumnType)($column-type) + - transient($index-target, $column-target) + - $index-node[CurrentStatus] = TRANSIENT_ABSENT + - $column-node[CurrentStatus] = TRANSIENT_ABSENT + - joinTargetNode($index, $index-target, $index-node) + - joinTargetNode($column, $column-target, $column-node) +- name: old index absent before new index public when swapping with transient + from: old-primary-index-node + kind: Precedence + to: new-primary-index-node + query: + - $old-primary-index[Type] = '*scpb.PrimaryIndex' + - $transient-primary-index[Type] = '*scpb.PrimaryIndex' + - $new-primary-index[Type] = '*scpb.PrimaryIndex' + - joinOnDescID($old-primary-index, $transient-primary-index, $table-id) + - $old-primary-index[IndexID] = $old-index-id + - $transient-primary-index[SourceIndexID] = $old-index-id + - joinOnDescID($transient-primary-index, $new-primary-index, $table-id) + - $transient-primary-index[IndexID] = $transient-index-id + - $new-primary-index[SourceIndexID] = $transient-index-id + - $old-primary-index-target[TargetStatus] = ABSENT + - $old-primary-index-node[CurrentStatus] = ABSENT + - $new-primary-index-target[TargetStatus] = PUBLIC + - $new-primary-index-node[CurrentStatus] = PUBLIC + - joinTargetNode($old-primary-index, $old-primary-index-target, $old-primary-index-node) + - joinTargetNode($new-primary-index, $new-primary-index-target, $new-primary-index-node) +- name: partial predicate removed right before secondary index when not dropping relation + from: partial-predicate-node + kind: SameStagePrecedence + to: index-node + query: + - $partial-predicate[Type] = '*scpb.SecondaryIndexPartial' + - $index[Type] = '*scpb.SecondaryIndex' + - joinOnIndexID($partial-predicate, $index, $table-id, $index-id) + - relationIsNotBeingDropped(*scpb.SecondaryIndexPartial)($partial-predicate) + - $partial-predicate-target[TargetStatus] = TRANSIENT_ABSENT + - $partial-predicate-node[CurrentStatus] = TRANSIENT_ABSENT + - $index-target[TargetStatus] = ABSENT + - $index-node[CurrentStatus] = ABSENT + - joinTargetNode($partial-predicate, $partial-predicate-target, $partial-predicate-node) + - joinTargetNode($index, $index-target, $index-node) +- name: partial predicate removed right before secondary index when not dropping relation + from: partial-predicate-node + kind: SameStagePrecedence + to: index-node + query: + - $partial-predicate[Type] = '*scpb.SecondaryIndexPartial' + - $index[Type] = '*scpb.SecondaryIndex' + - joinOnIndexID($partial-predicate, $index, $table-id, $index-id) + - relationIsNotBeingDropped(*scpb.SecondaryIndexPartial)($partial-predicate) + - $partial-predicate-target[TargetStatus] = ABSENT + - $partial-predicate-node[CurrentStatus] = ABSENT + - $index-target[TargetStatus] = TRANSIENT_ABSENT + - $index-node[CurrentStatus] = TRANSIENT_ABSENT + - joinTargetNode($partial-predicate, $partial-predicate-target, $partial-predicate-node) + - joinTargetNode($index, $index-target, $index-node) - name: partial predicate removed right before secondary index when not dropping relation from: partial-predicate-node kind: SameStagePrecedence @@ -459,26 +659,26 @@ deprules - $partial-predicate[Type] = '*scpb.SecondaryIndexPartial' - $index[Type] = '*scpb.SecondaryIndex' - joinOnIndexID($partial-predicate, $index, $table-id, $index-id) + - relationIsNotBeingDropped(*scpb.SecondaryIndexPartial)($partial-predicate) - toAbsent($partial-predicate-target, $index-target) - $partial-predicate-node[CurrentStatus] = ABSENT - $index-node[CurrentStatus] = ABSENT - - RelationIsNotBeingDropped(*scpb.SecondaryIndexPartial)($partial-predicate) - joinTargetNode($partial-predicate, $partial-predicate-target, $partial-predicate-node) - joinTargetNode($index, $index-target, $index-node) -- name: primary index should be cleaned up before newly added column when reverting - from: index-node - kind: Precedence - to: column-node +- name: partial predicate removed right before secondary index when not dropping relation + from: partial-predicate-node + kind: SameStagePrecedence + to: index-node query: - - $index[Type] = '*scpb.PrimaryIndex' - - $column[Type] = '*scpb.Column' - - columnInPrimaryIndexSwap($index-column, $index, $table-id, $column-id, $index-id) - - joinOnColumnID($index-column, $column, $table-id, $column-id) - - toAbsent($index-target, $column-target) - - $index-node[CurrentStatus] = WRITE_ONLY - - $column-node[CurrentStatus] = WRITE_ONLY + - $partial-predicate[Type] = '*scpb.SecondaryIndexPartial' + - $index[Type] = '*scpb.SecondaryIndex' + - joinOnIndexID($partial-predicate, $index, $table-id, $index-id) + - relationIsNotBeingDropped(*scpb.SecondaryIndexPartial)($partial-predicate) + - transient($partial-predicate-target, $index-target) + - $partial-predicate-node[CurrentStatus] = TRANSIENT_ABSENT + - $index-node[CurrentStatus] = TRANSIENT_ABSENT + - joinTargetNode($partial-predicate, $partial-predicate-target, $partial-predicate-node) - joinTargetNode($index, $index-target, $index-node) - - joinTargetNode($column, $column-target, $column-node) - name: primary index swap from: old-index-node kind: SameStagePrecedence @@ -487,110 +687,175 @@ deprules - $old-index[Type] = '*scpb.PrimaryIndex' - $new-index[Type] = '*scpb.PrimaryIndex' - joinOnDescID($old-index, $new-index, $table-id) + - $old-index[IndexID] = $old-index-id + - $new-index[SourceIndexID] = $old-index-id - $old-index-target[TargetStatus] = ABSENT - - $new-index-target[TargetStatus] = PUBLIC - $old-index-node[CurrentStatus] = VALIDATED + - $new-index-target[TargetStatus] IN [PUBLIC, TRANSIENT_ABSENT] + - $new-index-node[CurrentStatus] = PUBLIC + - joinTargetNode($old-index, $old-index-target, $old-index-node) + - joinTargetNode($new-index, $new-index-target, $new-index-node) +- name: primary index swap + from: old-index-node + kind: SameStagePrecedence + to: new-index-node + query: + - $old-index[Type] = '*scpb.PrimaryIndex' + - $new-index[Type] = '*scpb.PrimaryIndex' + - joinOnDescID($old-index, $new-index, $table-id) + - $old-index[IndexID] = $old-index-id + - $new-index[SourceIndexID] = $old-index-id + - $old-index-target[TargetStatus] = TRANSIENT_ABSENT + - $old-index-node[CurrentStatus] = TRANSIENT_VALIDATED + - $new-index-target[TargetStatus] IN [PUBLIC, TRANSIENT_ABSENT] - $new-index-node[CurrentStatus] = PUBLIC - - primaryIndexesDependency(*scpb.PrimaryIndex, *scpb.PrimaryIndex)($old-index, $new-index) - joinTargetNode($old-index, $old-index-target, $old-index-node) - joinTargetNode($new-index, $new-index-target, $new-index-node) +- name: primary index swap + from: new-index-node + kind: SameStagePrecedence + to: old-index-node + query: + - $new-index[Type] = '*scpb.PrimaryIndex' + - $old-index[Type] = '*scpb.PrimaryIndex' + - joinOnDescID($new-index, $old-index, $table-id) + - $new-index[SourceIndexID] = $old-index-id + - $old-index[IndexID] = $old-index-id + - $new-index-target[TargetStatus] = ABSENT + - $new-index-node[CurrentStatus] = VALIDATED + - $old-index-target[TargetStatus] = PUBLIC + - $old-index-node[CurrentStatus] = PUBLIC + - joinTargetNode($new-index, $new-index-target, $new-index-node) + - joinTargetNode($old-index, $old-index-target, $old-index-node) - name: primary index with new columns should exist before secondary indexes from: primary-index-node kind: Precedence - to: second-index-node + to: secondary-index-node query: - $primary-index[Type] = '*scpb.PrimaryIndex' - - $second-index[Type] = '*scpb.SecondaryIndex' - - joinOnDescID($primary-index, $second-index, $table-id) + - $secondary-index[Type] = '*scpb.SecondaryIndex' + - joinOnDescID($primary-index, $secondary-index, $table-id) - $primary-index[IndexID] = $primary-index-id - - $second-index[SourceIndexID] = $primary-index-id - - toPublic($primary-index-target, $second-index-target) + - $secondary-index[SourceIndexID] = $primary-index-id + - toPublicOrTransient($primary-index-target, $secondary-index-target) - $primary-index-node[CurrentStatus] = PUBLIC - - $second-index-node[CurrentStatus] = BACKFILL_ONLY + - $secondary-index-node[CurrentStatus] = BACKFILL_ONLY - joinTargetNode($primary-index, $primary-index-target, $primary-index-node) - - joinTargetNode($second-index, $second-index-target, $second-index-node) + - joinTargetNode($secondary-index, $secondary-index-target, $secondary-index-node) - name: primary index with new columns should exist before temp indexes from: primary-index-node kind: Precedence - to: second-index-node + to: temp-index-node query: - $primary-index[Type] = '*scpb.PrimaryIndex' - - $second-index[Type] = '*scpb.TemporaryIndex' - - joinOnDescID($primary-index, $second-index, $table-id) + - $temp-index[Type] = '*scpb.TemporaryIndex' + - joinOnDescID($primary-index, $temp-index, $table-id) - $primary-index[IndexID] = $primary-index-id - - $second-index[SourceIndexID] = $primary-index-id - - $primary-index-target[TargetStatus] = PUBLIC - - $second-index-target[TargetStatus] = TRANSIENT_ABSENT + - $temp-index[SourceIndexID] = $primary-index-id + - toPublicOrTransient($primary-index-target, $temp-index-target) - $primary-index-node[CurrentStatus] = PUBLIC - - $second-index-node[CurrentStatus] = DELETE_ONLY + - $temp-index-node[CurrentStatus] = DELETE_ONLY - joinTargetNode($primary-index, $primary-index-target, $primary-index-node) - - joinTargetNode($second-index, $second-index-target, $second-index-node) -- name: secondary index columns removed before removing the index - from: index-column-node + - joinTargetNode($temp-index, $temp-index-target, $temp-index-node) +- name: remove columns from index right before removing index + from: index-node kind: Precedence - to: index-node + to: index-column-node query: - - $index-column[Type] = '*scpb.IndexColumn' - - $index[Type] = '*scpb.SecondaryIndex' - - joinOnIndexID($index-column, $index, $table-id, $index-id) - - toAbsent($index-column-target, $index-target) + - $index[Type] = '*scpb.IndexColumn' + - $index-column[Type] IN ['*scpb.PrimaryIndex', '*scpb.SecondaryIndex', '*scpb.TemporaryIndex'] + - joinOnIndexID($index, $index-column, $table-id, $index-id) + - toAbsent($index-target, $index-column-target) + - $index-node[CurrentStatus] = DELETE_ONLY - $index-column-node[CurrentStatus] = ABSENT - - $index-node[CurrentStatus] = ABSENT + - joinTargetNode($index, $index-target, $index-node) - joinTargetNode($index-column, $index-column-target, $index-column-node) +- name: remove columns from index right before removing index + from: index-node + kind: Precedence + to: index-column-node + query: + - $index[Type] = '*scpb.IndexColumn' + - $index-column[Type] IN ['*scpb.PrimaryIndex', '*scpb.SecondaryIndex', '*scpb.TemporaryIndex'] + - joinOnIndexID($index, $index-column, $table-id, $index-id) + - transient($index-target, $index-column-target) + - $index-node[CurrentStatus] = TRANSIENT_DELETE_ONLY + - $index-column-node[CurrentStatus] = TRANSIENT_ABSENT - joinTargetNode($index, $index-target, $index-node) -- name: secondary index in DELETE_ONLY before removing columns + - joinTargetNode($index-column, $index-column-target, $index-column-node) +- name: remove columns from index right before removing index from: index-node kind: Precedence to: index-column-node query: - - $index[Type] = '*scpb.SecondaryIndex' - - $index-column[Type] = '*scpb.IndexColumn' + - $index[Type] = '*scpb.IndexColumn' + - $index-column[Type] IN ['*scpb.PrimaryIndex', '*scpb.SecondaryIndex', '*scpb.TemporaryIndex'] - joinOnIndexID($index, $index-column, $table-id, $index-id) - - toAbsent($index-target, $index-column-target) - - $index-node[CurrentStatus] = DELETE_ONLY + - $index-target[TargetStatus] = TRANSIENT_ABSENT + - $index-node[CurrentStatus] = TRANSIENT_DELETE_ONLY + - $index-column-target[TargetStatus] = ABSENT - $index-column-node[CurrentStatus] = ABSENT - joinTargetNode($index, $index-target, $index-node) - joinTargetNode($index-column, $index-column-target, $index-column-node) -- name: temp index columns removed before removing the index - from: index-column-node +- name: remove columns from index right before removing index + from: index-node kind: Precedence - to: index-node + to: index-column-node query: - - $index-column[Type] = '*scpb.IndexColumn' - - $index[Type] = '*scpb.TemporaryIndex' - - joinOnIndexID($index-column, $index, $table-id, $index-id) - - toAbsent($index-column-target, $index-target) - - $index-column-node[CurrentStatus] = ABSENT - - $index-node[CurrentStatus] = TRANSIENT_ABSENT + - $index[Type] = '*scpb.IndexColumn' + - $index-column[Type] IN ['*scpb.PrimaryIndex', '*scpb.SecondaryIndex', '*scpb.TemporaryIndex'] + - joinOnIndexID($index, $index-column, $table-id, $index-id) + - $index-target[TargetStatus] = ABSENT + - $index-node[CurrentStatus] = DELETE_ONLY + - $index-column-target[TargetStatus] = TRANSIENT_ABSENT + - $index-column-node[CurrentStatus] = TRANSIENT_ABSENT + - joinTargetNode($index, $index-target, $index-node) - joinTargetNode($index-column, $index-column-target, $index-column-node) +- name: secondary indexes containing column as key reach write-only before column + from: index-node + kind: Precedence + to: column-node + query: + - $index[Type] = '*scpb.SecondaryIndex' + - $column[Type] = '*scpb.Column' + - columnInIndex($index-column, $index, $table-id, $column-id, $index-id) + - joinOnColumnID($index-column, $column, $table-id, $column-id) + - toAbsent($index-target, $column-target) + - $index-node[CurrentStatus] = VALIDATED + - $column-node[CurrentStatus] = WRITE_ONLY + - $column-type[Type] = '*scpb.ColumnType' + - joinOnColumnID($index-column, $column-type, $table-id, $column-id) + - relationIsNotBeingDropped(*scpb.ColumnType)($column-type) + - isIndexKeyColumnKey(*scpb.IndexColumn)($index-column) - joinTargetNode($index, $index-target, $index-node) -- name: temp index exists before columns, partitioning, and partial - from: temp-index-node + - joinTargetNode($column, $column-target, $column-node) +- name: swapped primary index public before column + from: index-node kind: Precedence - to: index-partitioning-node + to: column-node query: - - $temp-index[Type] = '*scpb.TemporaryIndex' - - $index-partitioning[Type] IN ['*scpb.IndexColumn', '*scpb.IndexPartitioning', '*scpb.SecondaryIndexPartial'] - - joinOnIndexID($temp-index, $index-partitioning, $table-id, $index-id) - - $temp-index-target[TargetStatus] = TRANSIENT_ABSENT - - $index-partitioning-target[TargetStatus] = PUBLIC - - $temp-index-node[CurrentStatus] = DELETE_ONLY - - $index-partitioning-node[CurrentStatus] = PUBLIC - - joinTargetNode($temp-index, $temp-index-target, $temp-index-node) - - joinTargetNode($index-partitioning, $index-partitioning-target, $index-partitioning-node) -- name: temp index in DELETE_ONLY before removing columns + - $index[Type] = '*scpb.PrimaryIndex' + - $column[Type] = '*scpb.Column' + - columnInSwappedInPrimaryIndex($index-column, $index, $table-id, $column-id, $index-id) + - joinOnColumnID($index-column, $column, $table-id, $column-id) + - toPublicOrTransient($index-target, $column-target) + - $index-node[CurrentStatus] = PUBLIC + - $column-node[CurrentStatus] = PUBLIC + - joinTargetNode($index, $index-target, $index-node) + - joinTargetNode($column, $column-target, $column-node) +- name: temp index existence precedes index dependents from: index-node kind: Precedence - to: index-column-node + to: dependent-node query: - $index[Type] = '*scpb.TemporaryIndex' - - $index-column[Type] = '*scpb.IndexColumn' - - joinOnIndexID($index, $index-column, $table-id, $index-id) - - toAbsent($index-target, $index-column-target) - - $index-node[CurrentStatus] = TRANSIENT_DELETE_ONLY - - $index-column-node[CurrentStatus] = ABSENT + - $dependent[Type] IN ['*scpb.IndexName', '*scpb.IndexPartitioning', '*scpb.SecondaryIndexPartial', '*scpb.IndexComment', '*scpb.IndexColumn'] + - joinOnIndexID($index, $dependent, $table-id, $index-id) + - toPublicOrTransient($index-target, $dependent-target) + - $index-node[CurrentStatus] = DELETE_ONLY + - $dependent-node[CurrentStatus] = PUBLIC - joinTargetNode($index, $index-target, $index-node) - - joinTargetNode($index-column, $index-column-target, $index-column-node) + - joinTargetNode($dependent, $dependent-target, $dependent-node) - name: temp index is WRITE_ONLY before backfill from: temp-node kind: Precedence @@ -602,22 +867,8 @@ deprules - $temp[IndexID] = $temp-index-id - $index[TemporaryIndexID] = $temp-index-id - $temp-target[TargetStatus] = TRANSIENT_ABSENT - - $index-target[TargetStatus] = PUBLIC + - $index-target[TargetStatus] IN [PUBLIC, TRANSIENT_ABSENT] - $temp-node[CurrentStatus] = WRITE_ONLY - $index-node[CurrentStatus] = BACKFILLED - joinTargetNode($temp, $temp-target, $temp-node) - joinTargetNode($index, $index-target, $index-node) -- name: temp indexes reach absent at the same time as other indexes - from: index-a-node - kind: SameStagePrecedence - to: index-b-node - query: - - $index-a[Type] = '*scpb.TemporaryIndex' - - $index-b[Type] IN ['*scpb.PrimaryIndex', '*scpb.SecondaryIndex'] - - joinOnDescID($index-a, $index-b, $desc-id) - - $index-a-target[TargetStatus] = TRANSIENT_ABSENT - - $index-b-target[TargetStatus] = ABSENT - - $index-a-node[CurrentStatus] = TRANSIENT_ABSENT - - $index-b-node[CurrentStatus] = ABSENT - - joinTargetNode($index-a, $index-a-target, $index-a-node) - - joinTargetNode($index-b, $index-b-target, $index-b-node) diff --git a/pkg/sql/schemachanger/scplan/internal/rules/testdata/oprules b/pkg/sql/schemachanger/scplan/internal/rules/testdata/oprules index 5dedd93249b7..8d8ed491f3fd 100644 --- a/pkg/sql/schemachanger/scplan/internal/rules/testdata/oprules +++ b/pkg/sql/schemachanger/scplan/internal/rules/testdata/oprules @@ -6,9 +6,9 @@ columnInIndex(index-column, index, table-id, column-id, index-id): - $index-column[ColumnID] = $column-id - $index[IndexID] = $index-id - joinOnIndexID($index, $index-column, $table-id, $index-id) -columnInPrimaryIndexSwap(index-column, index, table-id, column-id, index-id): +columnInSwappedInPrimaryIndex(index-column, index, table-id, column-id, index-id): - columnInIndex($index-column, $index, $table-id, $column-id, $index-id) - - sourceIndexNotSet($index) + - sourceIndexIsSet($index) joinOnColumnID(a, b, desc-id, col-id): - joinOnDescID($a, $b, $desc-id) - $a[ColumnID] = $col-id @@ -35,14 +35,17 @@ joinTargetNode(element, target, node): - joinTarget($element, $target) - $node[Type] = '*screl.Node' - $node[Target] = $target -sourceIndexNotSet(index): +sourceIndexIsSet(index): - $index[SourceIndexID] != 0 toAbsent(target1, target2): - $target1[TargetStatus] = ABSENT - $target2[TargetStatus] = ABSENT -toPublic(target1, target2): - - $target1[TargetStatus] = PUBLIC - - $target2[TargetStatus] = PUBLIC +toPublicOrTransient(target1, target2): + - $target1[TargetStatus] IN [PUBLIC, TRANSIENT_ABSENT] + - $target2[TargetStatus] IN [PUBLIC, TRANSIENT_ABSENT] +transient(target1, target2): + - $target1[TargetStatus] = TRANSIENT_ABSENT + - $target2[TargetStatus] = TRANSIENT_ABSENT oprules ---- @@ -129,6 +132,17 @@ oprules - $relation-target[TargetStatus] = ABSENT - joinTargetNode($index, $index-target, $index-node) - $index-target[TargetStatus] = ABSENT +- name: skip index-column removal ops on index removal + from: index-column-node + query: + - $index-column[Type] = '*scpb.IndexColumn' + - $index[Type] IN ['*scpb.PrimaryIndex', '*scpb.SecondaryIndex', '*scpb.TemporaryIndex'] + - joinOnIndexID($index-column, $index, $relation-id, $index-id) + - joinTargetNode($index-column, $index-column-target, $index-column-node) + - $index-column-target[TargetStatus] IN [ABSENT, TRANSIENT_ABSENT] + - $index-column-node[CurrentStatus] IN [PUBLIC, TRANSIENT_PUBLIC] + - joinTarget($index, $index-target) + - $index-target[TargetStatus] IN [ABSENT, TRANSIENT_ABSENT] - name: skip table comment removal ops on descriptor drop from: dep-node query: diff --git a/pkg/sql/schemachanger/scplan/internal/scgraph/depedgekind_string.go b/pkg/sql/schemachanger/scplan/internal/scgraph/depedgekind_string.go index cbf92d30f4a2..a768c9bd1415 100644 --- a/pkg/sql/schemachanger/scplan/internal/scgraph/depedgekind_string.go +++ b/pkg/sql/schemachanger/scplan/internal/scgraph/depedgekind_string.go @@ -10,11 +10,12 @@ func _() { var x [1]struct{} _ = x[Precedence-1] _ = x[SameStagePrecedence-2] + _ = x[PreviousStagePrecedence-3] } -const _DepEdgeKind_name = "PrecedenceSameStagePrecedence" +const _DepEdgeKind_name = "PrecedenceSameStagePrecedencePreviousStagePrecedence" -var _DepEdgeKind_index = [...]uint8{0, 10, 29} +var _DepEdgeKind_index = [...]uint8{0, 10, 29, 52} func (i DepEdgeKind) String() string { i -= 1 diff --git a/pkg/sql/schemachanger/scplan/internal/scgraph/edge.go b/pkg/sql/schemachanger/scplan/internal/scgraph/edge.go index 132af20d015e..646b93480b40 100644 --- a/pkg/sql/schemachanger/scplan/internal/scgraph/edge.go +++ b/pkg/sql/schemachanger/scplan/internal/scgraph/edge.go @@ -97,6 +97,11 @@ const ( // SameStagePrecedence indicates that the source (from) of the edge must // be reached before the destination (to), and _must_ do so in the same stage. SameStagePrecedence + + // PreviousStagePrecedence indicates that the source (from) of the edge must + // be reached before the destination (to), and _must_ do so in a previous + // stage. + PreviousStagePrecedence ) // DepEdge represents a dependency between two nodes. A dependency @@ -156,7 +161,8 @@ func (de *DepEdge) Rules() []Rule { return de.rules } // Kind returns the kind of the DepEdge. Note that it returns the strongest // kind implied by a rule; if one rule which created this edge is Precedence, -// and another is SameStagePrecedence, this will return SameStagePrecedence. +// and another is SameStagePrecedence or PreviousStagePrecedence, then it +// returns the latter. func (de *DepEdge) Kind() DepEdgeKind { return de.kind } // String returns a string representation of this edge diff --git a/pkg/sql/schemachanger/scplan/internal/scgraph/graph.go b/pkg/sql/schemachanger/scplan/internal/scgraph/graph.go index 9380f6399f87..611c347e1b38 100644 --- a/pkg/sql/schemachanger/scplan/internal/scgraph/graph.go +++ b/pkg/sql/schemachanger/scplan/internal/scgraph/graph.go @@ -267,8 +267,12 @@ func (g *Graph) AddDepEdge( return err } if got := g.depEdgesFrom.get(de); got != nil { - if got.kind == Precedence && kind == SameStagePrecedence { - got.kind = SameStagePrecedence + if got.kind != kind && kind != Precedence { + if got.kind != Precedence { + return errors.AssertionFailedf("inconsistent dep edge kinds: %s rule %q conflicts with %s", + rule.Kind, rule.Name, got) + } + got.kind = kind } got.rules = append(got.rules, rule) return diff --git a/pkg/sql/schemachanger/scplan/internal/scgraphviz/graphviz.go b/pkg/sql/schemachanger/scplan/internal/scgraphviz/graphviz.go index a6daf3833431..f4212bb49f99 100644 --- a/pkg/sql/schemachanger/scplan/internal/scgraphviz/graphviz.go +++ b/pkg/sql/schemachanger/scplan/internal/scgraphviz/graphviz.go @@ -227,7 +227,10 @@ func drawDeps(cs scpb.CurrentState, g *scgraph.Graph) (*dot.Graph, error) { case *scgraph.DepEdge: ge.Attr("color", "red") ge.Attr("label", e.RuleNames()) - if e.Kind() == scgraph.SameStagePrecedence { + switch e.Kind() { + case scgraph.PreviousStagePrecedence: + ge.Attr("arrowhead", "inv") + case scgraph.SameStagePrecedence: ge.Attr("arrowhead", "diamond") } } diff --git a/pkg/sql/schemachanger/scplan/internal/scstage/build.go b/pkg/sql/schemachanger/scplan/internal/scstage/build.go index 83934907f19a..d0dcfadee63e 100644 --- a/pkg/sql/schemachanger/scplan/internal/scstage/build.go +++ b/pkg/sql/schemachanger/scplan/internal/scstage/build.go @@ -13,6 +13,7 @@ package scstage import ( "fmt" "sort" + "strings" "github.com/cockroachdb/cockroach/pkg/jobs/jobspb" "github.com/cockroachdb/cockroach/pkg/sql/catalog" @@ -136,7 +137,13 @@ func buildStages(bc buildContext) (stages []Stage) { if bs.phase == scop.LatestPhase { // This should never happen, we should always be able to make forward // progress because we haven't reached the terminal state yet. - panic(errors.AssertionFailedf("unable to make progress")) + var str strings.Builder + for _, t := range sb.current { + str.WriteString(" - ") + str.WriteString(screl.NodeString(t.n)) + str.WriteString("\n") + } + panic(errors.WithDetailf(errors.AssertionFailedf("unable to make progress"), "terminal state:\n%s", str.String())) } bs.phase++ sb = bc.makeStageBuilder(bs) @@ -379,6 +386,10 @@ func (sb *stageBuilder) isUnmetInboundDep(de *scgraph.DepEdge) bool { _, fromIsFulfilled := sb.bs.fulfilled[de.From()] _, fromIsCandidate := sb.fulfilling[de.From()] switch de.Kind() { + case scgraph.PreviousStagePrecedence: + // True iff the source node has not been fulfilled in an earlier stage. + return !fromIsFulfilled + case scgraph.Precedence: // True iff the source node has not been fulfilled in an earlier stage // and also iff it's not (yet?) scheduled to be fulfilled in this stage. diff --git a/pkg/sql/schemachanger/scplan/internal/scstage/stage.go b/pkg/sql/schemachanger/scplan/internal/scstage/stage.go index 9bd610aebbf8..20da540c2cf2 100644 --- a/pkg/sql/schemachanger/scplan/internal/scstage/stage.go +++ b/pkg/sql/schemachanger/scplan/internal/scstage/stage.go @@ -158,9 +158,16 @@ func validateStageSubgraph(ts scpb.TargetState, stage Stage, g *scgraph.Graph) e } } + type beforeOrDuring int + const ( + _ beforeOrDuring = iota + before + during + ) + // Build the initial set of fulfilled nodes by traversing the graph // recursively and backwards. - fulfilled := map[*screl.Node]bool{} + fulfilled := map[*screl.Node]beforeOrDuring{} current := make([]*screl.Node, len(ts.Targets)) for i, status := range stage.Before { t := &ts.Targets[i] @@ -182,7 +189,7 @@ func validateStageSubgraph(ts scpb.TargetState, stage Stage, g *scgraph.Graph) e if _, found := fulfilled[n]; found { return } - fulfilled[n] = true + fulfilled[n] = before for _, e := range edgesTo[n] { dfs(e.From()) } @@ -215,7 +222,9 @@ func validateStageSubgraph(ts scpb.TargetState, stage Stage, g *scgraph.Graph) e // Prevent making progress on this target if there are unmet dependencies. var hasUnmetDeps bool if err := g.ForEachDepEdgeTo(oe.To(), func(de *scgraph.DepEdge) error { - hasUnmetDeps = hasUnmetDeps || !fulfilled[de.From()] + if _, isFulfilled := fulfilled[de.From()]; !isFulfilled { + hasUnmetDeps = true + } return nil }); err != nil { return err @@ -233,8 +242,27 @@ func validateStageSubgraph(ts scpb.TargetState, stage Stage, g *scgraph.Graph) e } current[i] = oe.To() - fulfilled[oe.To()] = true + fulfilled[oe.To()] = during hasProgressed = true + + // Check same-stage or previous-stage constraints. + if err := g.ForEachDepEdgeTo(oe.To(), func(de *scgraph.DepEdge) error { + switch fulfilled[de.From()] { + case before: + if de.Kind() == scgraph.SameStagePrecedence { + return errors.Errorf("%s not reached in same stage as %s, violates rule in %s", + de.From(), oe.To(), de.RuleNames()) + } + case during: + if de.Kind() == scgraph.PreviousStagePrecedence { + return errors.Errorf("%s reached in same stage as %s, violates rule in %s", + de.From(), oe.To(), de.RuleNames()) + } + } + return nil + }); err != nil { + return err + } } } // When we stop making progress we expect to have reached the After state. diff --git a/pkg/sql/schemachanger/scplan/plan.go b/pkg/sql/schemachanger/scplan/plan.go index 7ee467877332..4f4436677f62 100644 --- a/pkg/sql/schemachanger/scplan/plan.go +++ b/pkg/sql/schemachanger/scplan/plan.go @@ -73,24 +73,29 @@ func (p Plan) StagesForCurrentPhase() []scstage.Stage { } // MakePlan generates a Plan for a particular phase of a schema change, given -// the initial state for a set of targets. -// Returns an error when planning fails. It is up to the caller to wrap this -// error as an assertion failure and with useful debug information details. +// the initial state for a set of targets. Returns an error when planning fails. func MakePlan(initial scpb.CurrentState, params Params) (p Plan, err error) { p = Plan{ CurrentState: initial, Params: params, } + err = makePlan(&p) + if err != nil { + err = p.DecorateErrorWithPlanDetails(err) + } + return p, err +} + +func makePlan(p *Plan) (err error) { defer func() { if r := recover(); r != nil { rAsErr, ok := r.(error) if !ok { rAsErr = errors.Errorf("panic during MakePlan: %v", r) } - err = p.DecorateErrorWithPlanDetails(rAsErr) + err = rAsErr } }() - { start := timeutil.Now() p.Graph = buildGraph(p.CurrentState) @@ -101,7 +106,7 @@ func MakePlan(initial scpb.CurrentState, params Params) (p Plan, err error) { { start := timeutil.Now() p.Stages = scstage.BuildStages( - initial, params.ExecutionPhase, p.Graph, params.SchemaChangerJobIDSupplier, + p.CurrentState, p.Params.ExecutionPhase, p.Graph, p.Params.SchemaChangerJobIDSupplier, ) if log.V(2) { log.Infof(context.TODO(), "stage generation took %v", timeutil.Since(start)) @@ -109,12 +114,12 @@ func MakePlan(initial scpb.CurrentState, params Params) (p Plan, err error) { } if n := len(p.Stages); n > 0 && p.Stages[n-1].Phase > scop.PreCommitPhase { // Only get the job ID if it's actually been assigned already. - p.JobID = params.SchemaChangerJobIDSupplier() + p.JobID = p.Params.SchemaChangerJobIDSupplier() } if err := scstage.ValidateStages(p.TargetState, p.Stages, p.Graph); err != nil { panic(errors.Wrapf(err, "invalid execution plan")) } - return p, nil + return nil } func buildGraph(cs scpb.CurrentState) *scgraph.Graph { diff --git a/pkg/sql/schemachanger/scplan/plan_explain.go b/pkg/sql/schemachanger/scplan/plan_explain.go index ce587df7275a..0deda38e5282 100644 --- a/pkg/sql/schemachanger/scplan/plan_explain.go +++ b/pkg/sql/schemachanger/scplan/plan_explain.go @@ -34,45 +34,36 @@ func (p Plan) DecorateErrorWithPlanDetails(err error) (retErr error) { if err == nil { return nil } + if len(p.Stages) > 0 { + err = addDetail(err, "EXPLAIN plan", "", p.ExplainVerbose) + err = addDetail(err, "EXPLAIN graphviz URL", "stages graphviz: ", p.StagesURL) + } + if p.Graph != nil { + err = addDetail(err, "dependencies graphviz URL", "dependencies graphviz: ", p.DependenciesURL) + } + return errors.WithAssertionFailure(err) +} + +func addDetail( + undecoratedError error, errWrapStr, detailFmtStr string, genDetail func() (string, error), +) (err error) { + err = undecoratedError defer func() { if r := recover(); r != nil { rAsErr, ok := r.(error) if !ok { - rAsErr = errors.Errorf("panic during scplan.DecorateErrorWithPlanDetails: %v", r) + rAsErr = errors.Errorf("%v", r) } - retErr = errors.CombineErrors(err, rAsErr) + rAsErr = errors.Wrapf(rAsErr, "panic when generating plan error detail %s", errWrapStr) + err = errors.CombineErrors(err, rAsErr) } }() - - if len(p.Stages) > 0 { - explain, explainErr := p.ExplainVerbose() - if explainErr != nil { - explainErr = errors.Wrapf(explainErr, "error when generating EXPLAIN plan") - err = errors.CombineErrors(err, explainErr) - } else { - err = errors.WithDetailf(err, "%s", explain) - } - - stagesURL, stagesErr := p.StagesURL() - if stagesErr != nil { - stagesErr = errors.Wrapf(stagesErr, "error when generating EXPLAIN graphviz URL") - err = errors.CombineErrors(err, stagesErr) - } else { - err = errors.WithDetailf(err, "stages graphviz: %s", stagesURL) - } - } - - if p.Graph != nil { - dependenciesURL, dependenciesErr := p.DependenciesURL() - if dependenciesErr != nil { - dependenciesErr = errors.Wrapf(dependenciesErr, "error when generating dependencies graphviz URL") - err = errors.CombineErrors(err, dependenciesErr) - } else { - err = errors.WithDetailf(err, "dependencies graphviz: %s", dependenciesURL) - } + detail, detailErr := genDetail() + if detailErr == nil { + return errors.WithDetailf(err, detailFmtStr+"%s", detail) } - - return errors.WithAssertionFailure(err) + detailErr = errors.Wrapf(detailErr, "error when generating plan error detail %s", errWrapStr) + return errors.CombineErrors(err, detailErr) } // DependenciesURL returns a URL to render the dependency graph in the Plan. diff --git a/pkg/sql/schemachanger/scplan/testdata/alter_table_add_column b/pkg/sql/schemachanger/scplan/testdata/alter_table_add_column index 0a45b50baa9b..719beadaddeb 100644 --- a/pkg/sql/schemachanger/scplan/testdata/alter_table_add_column +++ b/pkg/sql/schemachanger/scplan/testdata/alter_table_add_column @@ -140,12 +140,12 @@ StatementPhase stage 1 of 1 with 11 MutationType ops [[ColumnName:{DescID: 104, Name: j, ColumnID: 2}, PUBLIC], ABSENT] -> PUBLIC [[ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2}, PUBLIC], ABSENT] -> PUBLIC [[ColumnDefaultExpression:{DescID: 104, ColumnID: 2}, PUBLIC], ABSENT] -> PUBLIC + [[PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC], ABSENT] -> BACKFILL_ONLY [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2}, PUBLIC], ABSENT] -> PUBLIC [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2}, PUBLIC], ABSENT] -> PUBLIC - [[PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC], ABSENT] -> BACKFILL_ONLY [[TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], ABSENT] -> DELETE_ONLY - [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3}, PUBLIC], ABSENT] -> PUBLIC - [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3}, PUBLIC], ABSENT] -> PUBLIC + [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3}, TRANSIENT_ABSENT], ABSENT] -> PUBLIC + [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3}, TRANSIENT_ABSENT], ABSENT] -> PUBLIC ops: *scop.MakeAddedColumnDeleteOnly Column: @@ -195,6 +195,15 @@ StatementPhase stage 1 of 1 with 11 MutationType ops SourceIndexID: 1 TableID: 104 TemporaryIndexID: 3 + *scop.AddColumnToIndex + ColumnID: 1 + IndexID: 2 + TableID: 104 + *scop.AddColumnToIndex + ColumnID: 2 + IndexID: 2 + Kind: 2 + TableID: 104 *scop.MakeAddedTempIndexDeleteOnly Index: ConstraintID: 3 @@ -211,15 +220,6 @@ StatementPhase stage 1 of 1 with 11 MutationType ops IndexID: 3 Kind: 2 TableID: 104 - *scop.AddColumnToIndex - ColumnID: 1 - IndexID: 2 - TableID: 104 - *scop.AddColumnToIndex - ColumnID: 2 - IndexID: 2 - Kind: 2 - TableID: 104 PreCommitPhase stage 1 of 1 with 2 MutationType ops transitions: ops: @@ -309,7 +309,7 @@ PostCommitPhase stage 7 of 7 with 1 ValidationType op *scop.ValidateUniqueIndex IndexID: 2 TableID: 104 -PostCommitNonRevertiblePhase stage 1 of 3 with 10 MutationType ops +PostCommitNonRevertiblePhase stage 1 of 3 with 9 MutationType ops transitions: [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1}, ABSENT], PUBLIC] -> ABSENT [[PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1}, ABSENT], PUBLIC] -> WRITE_ONLY @@ -318,6 +318,8 @@ PostCommitNonRevertiblePhase stage 1 of 3 with 10 MutationType ops [[PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC], VALIDATED] -> PUBLIC [[IndexName:{DescID: 104, Name: foo_pkey, IndexID: 2}, PUBLIC], ABSENT] -> PUBLIC [[TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], WRITE_ONLY] -> TRANSIENT_DELETE_ONLY + [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3}, TRANSIENT_ABSENT], PUBLIC] -> TRANSIENT_ABSENT + [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3}, TRANSIENT_ABSENT], PUBLIC] -> TRANSIENT_ABSENT ops: *scop.MakeDroppedPrimaryIndexDeleteAndWriteOnly IndexID: 1 @@ -333,10 +335,6 @@ PostCommitNonRevertiblePhase stage 1 of 3 with 10 MutationType ops *scop.MakeDroppedIndexDeleteOnly IndexID: 3 TableID: 104 - *scop.RemoveColumnFromIndex - ColumnID: 1 - IndexID: 1 - TableID: 104 *scop.MakeAddedPrimaryIndexPublic EventBase: Authorization: @@ -368,29 +366,29 @@ PostCommitNonRevertiblePhase stage 1 of 3 with 10 MutationType ops *scop.UpdateSchemaChangerJob IsNonCancelable: true JobID: 1 -PostCommitNonRevertiblePhase stage 2 of 3 with 3 MutationType ops +PostCommitNonRevertiblePhase stage 2 of 3 with 5 MutationType ops transitions: [[PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1}, ABSENT], WRITE_ONLY] -> DELETE_ONLY + [[TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], TRANSIENT_DELETE_ONLY] -> TRANSIENT_ABSENT ops: *scop.MakeDroppedIndexDeleteOnly IndexID: 1 TableID: 104 + *scop.CreateGcJobForIndex + IndexID: 3 + TableID: 104 + *scop.MakeIndexAbsent + IndexID: 3 + TableID: 104 *scop.SetJobStateOnDescriptor DescriptorID: 104 *scop.UpdateSchemaChangerJob IsNonCancelable: true JobID: 1 -PostCommitNonRevertiblePhase stage 3 of 3 with 6 MutationType ops +PostCommitNonRevertiblePhase stage 3 of 3 with 4 MutationType ops transitions: [[PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1}, ABSENT], DELETE_ONLY] -> ABSENT - [[TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], TRANSIENT_DELETE_ONLY] -> TRANSIENT_ABSENT ops: - *scop.CreateGcJobForIndex - IndexID: 3 - TableID: 104 - *scop.MakeIndexAbsent - IndexID: 3 - TableID: 104 *scop.CreateGcJobForIndex IndexID: 1 StatementForDropJob: @@ -425,12 +423,12 @@ StatementPhase stage 1 of 1 with 18 MutationType ops [[ColumnName:{DescID: 104, Name: j, ColumnID: 2}, PUBLIC], ABSENT] -> PUBLIC [[ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2}, PUBLIC], ABSENT] -> PUBLIC [[ColumnDefaultExpression:{DescID: 104, ColumnID: 2}, PUBLIC], ABSENT] -> PUBLIC + [[PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC], ABSENT] -> BACKFILL_ONLY [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2}, PUBLIC], ABSENT] -> PUBLIC [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2}, PUBLIC], ABSENT] -> PUBLIC - [[PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC], ABSENT] -> BACKFILL_ONLY [[TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], ABSENT] -> DELETE_ONLY - [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3}, PUBLIC], ABSENT] -> PUBLIC - [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3}, PUBLIC], ABSENT] -> PUBLIC + [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3}, TRANSIENT_ABSENT], ABSENT] -> PUBLIC + [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3}, TRANSIENT_ABSENT], ABSENT] -> PUBLIC [[Column:{DescID: 104, ColumnID: 3}, PUBLIC], ABSENT] -> DELETE_ONLY [[ColumnName:{DescID: 104, Name: k, ColumnID: 3}, PUBLIC], ABSENT] -> PUBLIC [[ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 3}, PUBLIC], ABSENT] -> PUBLIC @@ -527,6 +525,15 @@ StatementPhase stage 1 of 1 with 18 MutationType ops SourceIndexID: 1 TableID: 104 TemporaryIndexID: 3 + *scop.AddColumnToIndex + ColumnID: 1 + IndexID: 2 + TableID: 104 + *scop.AddColumnToIndex + ColumnID: 2 + IndexID: 2 + Kind: 2 + TableID: 104 *scop.MakeAddedTempIndexDeleteOnly Index: ConstraintID: 3 @@ -555,15 +562,6 @@ StatementPhase stage 1 of 1 with 18 MutationType ops Kind: 2 Ordinal: 1 TableID: 104 - *scop.AddColumnToIndex - ColumnID: 1 - IndexID: 2 - TableID: 104 - *scop.AddColumnToIndex - ColumnID: 2 - IndexID: 2 - Kind: 2 - TableID: 104 PreCommitPhase stage 1 of 1 with 2 MutationType ops transitions: ops: @@ -661,7 +659,7 @@ PostCommitPhase stage 7 of 7 with 1 ValidationType op *scop.ValidateUniqueIndex IndexID: 2 TableID: 104 -PostCommitNonRevertiblePhase stage 1 of 3 with 12 MutationType ops +PostCommitNonRevertiblePhase stage 1 of 3 with 11 MutationType ops transitions: [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1}, ABSENT], PUBLIC] -> ABSENT [[PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1}, ABSENT], PUBLIC] -> WRITE_ONLY @@ -670,6 +668,8 @@ PostCommitNonRevertiblePhase stage 1 of 3 with 12 MutationType ops [[PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC], VALIDATED] -> PUBLIC [[IndexName:{DescID: 104, Name: foo_pkey, IndexID: 2}, PUBLIC], ABSENT] -> PUBLIC [[TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], WRITE_ONLY] -> TRANSIENT_DELETE_ONLY + [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3}, TRANSIENT_ABSENT], PUBLIC] -> TRANSIENT_ABSENT + [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3}, TRANSIENT_ABSENT], PUBLIC] -> TRANSIENT_ABSENT [[Column:{DescID: 104, ColumnID: 3}, PUBLIC], WRITE_ONLY] -> PUBLIC ops: *scop.MakeDroppedPrimaryIndexDeleteAndWriteOnly @@ -686,10 +686,6 @@ PostCommitNonRevertiblePhase stage 1 of 3 with 12 MutationType ops *scop.MakeDroppedIndexDeleteOnly IndexID: 3 TableID: 104 - *scop.RemoveColumnFromIndex - ColumnID: 1 - IndexID: 1 - TableID: 104 *scop.MakeAddedPrimaryIndexPublic EventBase: Authorization: @@ -733,29 +729,29 @@ PostCommitNonRevertiblePhase stage 1 of 3 with 12 MutationType ops *scop.UpdateSchemaChangerJob IsNonCancelable: true JobID: 1 -PostCommitNonRevertiblePhase stage 2 of 3 with 3 MutationType ops +PostCommitNonRevertiblePhase stage 2 of 3 with 5 MutationType ops transitions: [[PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1}, ABSENT], WRITE_ONLY] -> DELETE_ONLY + [[TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], TRANSIENT_DELETE_ONLY] -> TRANSIENT_ABSENT ops: *scop.MakeDroppedIndexDeleteOnly IndexID: 1 TableID: 104 + *scop.CreateGcJobForIndex + IndexID: 3 + TableID: 104 + *scop.MakeIndexAbsent + IndexID: 3 + TableID: 104 *scop.SetJobStateOnDescriptor DescriptorID: 104 *scop.UpdateSchemaChangerJob IsNonCancelable: true JobID: 1 -PostCommitNonRevertiblePhase stage 3 of 3 with 6 MutationType ops +PostCommitNonRevertiblePhase stage 3 of 3 with 4 MutationType ops transitions: [[PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1}, ABSENT], DELETE_ONLY] -> ABSENT - [[TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], TRANSIENT_DELETE_ONLY] -> TRANSIENT_ABSENT ops: - *scop.CreateGcJobForIndex - IndexID: 3 - TableID: 104 - *scop.MakeIndexAbsent - IndexID: 3 - TableID: 104 *scop.CreateGcJobForIndex IndexID: 1 StatementForDropJob: @@ -787,12 +783,12 @@ StatementPhase stage 1 of 1 with 10 MutationType ops [[Column:{DescID: 104, ColumnID: 2}, PUBLIC], ABSENT] -> DELETE_ONLY [[ColumnName:{DescID: 104, Name: a, ColumnID: 2}, PUBLIC], ABSENT] -> PUBLIC [[ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2}, PUBLIC], ABSENT] -> PUBLIC + [[PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC], ABSENT] -> BACKFILL_ONLY [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2}, PUBLIC], ABSENT] -> PUBLIC [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2}, PUBLIC], ABSENT] -> PUBLIC - [[PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC], ABSENT] -> BACKFILL_ONLY [[TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], ABSENT] -> DELETE_ONLY - [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3}, PUBLIC], ABSENT] -> PUBLIC - [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3}, PUBLIC], ABSENT] -> PUBLIC + [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3}, TRANSIENT_ABSENT], ABSENT] -> PUBLIC + [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3}, TRANSIENT_ABSENT], ABSENT] -> PUBLIC ops: *scop.MakeAddedColumnDeleteOnly Column: @@ -839,6 +835,15 @@ StatementPhase stage 1 of 1 with 10 MutationType ops SourceIndexID: 1 TableID: 104 TemporaryIndexID: 3 + *scop.AddColumnToIndex + ColumnID: 1 + IndexID: 2 + TableID: 104 + *scop.AddColumnToIndex + ColumnID: 2 + IndexID: 2 + Kind: 2 + TableID: 104 *scop.MakeAddedTempIndexDeleteOnly Index: ConstraintID: 3 @@ -855,15 +860,6 @@ StatementPhase stage 1 of 1 with 10 MutationType ops IndexID: 3 Kind: 2 TableID: 104 - *scop.AddColumnToIndex - ColumnID: 1 - IndexID: 2 - TableID: 104 - *scop.AddColumnToIndex - ColumnID: 2 - IndexID: 2 - Kind: 2 - TableID: 104 PreCommitPhase stage 1 of 1 with 2 MutationType ops transitions: ops: @@ -953,7 +949,7 @@ PostCommitPhase stage 7 of 7 with 1 ValidationType op *scop.ValidateUniqueIndex IndexID: 2 TableID: 104 -PostCommitNonRevertiblePhase stage 1 of 3 with 10 MutationType ops +PostCommitNonRevertiblePhase stage 1 of 3 with 9 MutationType ops transitions: [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1}, ABSENT], PUBLIC] -> ABSENT [[PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1}, ABSENT], PUBLIC] -> WRITE_ONLY @@ -962,6 +958,8 @@ PostCommitNonRevertiblePhase stage 1 of 3 with 10 MutationType ops [[PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC], VALIDATED] -> PUBLIC [[IndexName:{DescID: 104, Name: foo_pkey, IndexID: 2}, PUBLIC], ABSENT] -> PUBLIC [[TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], WRITE_ONLY] -> TRANSIENT_DELETE_ONLY + [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3}, TRANSIENT_ABSENT], PUBLIC] -> TRANSIENT_ABSENT + [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3}, TRANSIENT_ABSENT], PUBLIC] -> TRANSIENT_ABSENT ops: *scop.MakeDroppedPrimaryIndexDeleteAndWriteOnly IndexID: 1 @@ -977,10 +975,6 @@ PostCommitNonRevertiblePhase stage 1 of 3 with 10 MutationType ops *scop.MakeDroppedIndexDeleteOnly IndexID: 3 TableID: 104 - *scop.RemoveColumnFromIndex - ColumnID: 1 - IndexID: 1 - TableID: 104 *scop.MakeAddedPrimaryIndexPublic EventBase: Authorization: @@ -1012,29 +1006,29 @@ PostCommitNonRevertiblePhase stage 1 of 3 with 10 MutationType ops *scop.UpdateSchemaChangerJob IsNonCancelable: true JobID: 1 -PostCommitNonRevertiblePhase stage 2 of 3 with 3 MutationType ops +PostCommitNonRevertiblePhase stage 2 of 3 with 5 MutationType ops transitions: [[PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1}, ABSENT], WRITE_ONLY] -> DELETE_ONLY + [[TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], TRANSIENT_DELETE_ONLY] -> TRANSIENT_ABSENT ops: *scop.MakeDroppedIndexDeleteOnly IndexID: 1 TableID: 104 + *scop.CreateGcJobForIndex + IndexID: 3 + TableID: 104 + *scop.MakeIndexAbsent + IndexID: 3 + TableID: 104 *scop.SetJobStateOnDescriptor DescriptorID: 104 *scop.UpdateSchemaChangerJob IsNonCancelable: true JobID: 1 -PostCommitNonRevertiblePhase stage 3 of 3 with 6 MutationType ops +PostCommitNonRevertiblePhase stage 3 of 3 with 4 MutationType ops transitions: [[PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1}, ABSENT], DELETE_ONLY] -> ABSENT - [[TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], TRANSIENT_DELETE_ONLY] -> TRANSIENT_ABSENT ops: - *scop.CreateGcJobForIndex - IndexID: 3 - TableID: 104 - *scop.MakeIndexAbsent - IndexID: 3 - TableID: 104 *scop.CreateGcJobForIndex IndexID: 1 StatementForDropJob: @@ -1251,12 +1245,12 @@ ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (j) ---- StatementPhase stage 1 of 1 with 12 MutationType ops transitions: + [[PrimaryIndex:{DescID: 108, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC], ABSENT] -> BACKFILL_ONLY [[IndexColumn:{DescID: 108, ColumnID: 2, IndexID: 2}, PUBLIC], ABSENT] -> PUBLIC [[IndexColumn:{DescID: 108, ColumnID: 1, IndexID: 2}, PUBLIC], ABSENT] -> PUBLIC - [[PrimaryIndex:{DescID: 108, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC], ABSENT] -> BACKFILL_ONLY [[TemporaryIndex:{DescID: 108, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], ABSENT] -> DELETE_ONLY - [[IndexColumn:{DescID: 108, ColumnID: 2, IndexID: 3}, PUBLIC], ABSENT] -> PUBLIC - [[IndexColumn:{DescID: 108, ColumnID: 1, IndexID: 3}, PUBLIC], ABSENT] -> PUBLIC + [[IndexColumn:{DescID: 108, ColumnID: 2, IndexID: 3}, TRANSIENT_ABSENT], ABSENT] -> PUBLIC + [[IndexColumn:{DescID: 108, ColumnID: 1, IndexID: 3}, TRANSIENT_ABSENT], ABSENT] -> PUBLIC [[SecondaryIndex:{DescID: 108, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1}, PUBLIC], ABSENT] -> BACKFILL_ONLY [[TemporaryIndex:{DescID: 108, IndexID: 5, ConstraintID: 5, SourceIndexID: 1}, TRANSIENT_ABSENT], ABSENT] -> DELETE_ONLY [[IndexColumn:{DescID: 108, ColumnID: 1, IndexID: 4}, PUBLIC], ABSENT] -> PUBLIC @@ -1272,6 +1266,15 @@ StatementPhase stage 1 of 1 with 12 MutationType ops SourceIndexID: 1 TableID: 108 TemporaryIndexID: 3 + *scop.AddColumnToIndex + ColumnID: 2 + IndexID: 2 + TableID: 108 + *scop.AddColumnToIndex + ColumnID: 1 + IndexID: 2 + Kind: 2 + TableID: 108 *scop.MakeAddedTempIndexDeleteOnly Index: ConstraintID: 3 @@ -1323,15 +1326,6 @@ StatementPhase stage 1 of 1 with 12 MutationType ops IndexID: 5 Kind: 1 TableID: 108 - *scop.AddColumnToIndex - ColumnID: 2 - IndexID: 2 - TableID: 108 - *scop.AddColumnToIndex - ColumnID: 1 - IndexID: 2 - Kind: 2 - TableID: 108 PreCommitPhase stage 1 of 1 with 2 MutationType ops transitions: ops: @@ -1447,7 +1441,7 @@ PostCommitPhase stage 7 of 7 with 2 ValidationType ops *scop.ValidateUniqueIndex IndexID: 4 TableID: 108 -PostCommitNonRevertiblePhase stage 1 of 3 with 12 MutationType ops +PostCommitNonRevertiblePhase stage 1 of 3 with 10 MutationType ops transitions: [[IndexColumn:{DescID: 108, ColumnID: 1, IndexID: 1}, ABSENT], PUBLIC] -> ABSENT [[IndexColumn:{DescID: 108, ColumnID: 2, IndexID: 1}, ABSENT], PUBLIC] -> ABSENT @@ -1456,6 +1450,8 @@ PostCommitNonRevertiblePhase stage 1 of 3 with 12 MutationType ops [[PrimaryIndex:{DescID: 108, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC], VALIDATED] -> PUBLIC [[IndexName:{DescID: 108, Name: t_pkey, IndexID: 2}, PUBLIC], ABSENT] -> PUBLIC [[TemporaryIndex:{DescID: 108, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], WRITE_ONLY] -> TRANSIENT_DELETE_ONLY + [[IndexColumn:{DescID: 108, ColumnID: 2, IndexID: 3}, TRANSIENT_ABSENT], PUBLIC] -> TRANSIENT_ABSENT + [[IndexColumn:{DescID: 108, ColumnID: 1, IndexID: 3}, TRANSIENT_ABSENT], PUBLIC] -> TRANSIENT_ABSENT [[SecondaryIndex:{DescID: 108, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1}, PUBLIC], VALIDATED] -> PUBLIC [[TemporaryIndex:{DescID: 108, IndexID: 5, ConstraintID: 5, SourceIndexID: 1}, TRANSIENT_ABSENT], WRITE_ONLY] -> TRANSIENT_DELETE_ONLY [[IndexName:{DescID: 108, Name: t_i_key, IndexID: 4}, PUBLIC], ABSENT] -> PUBLIC @@ -1481,15 +1477,6 @@ PostCommitNonRevertiblePhase stage 1 of 3 with 12 MutationType ops IndexID: 4 Name: t_i_key TableID: 108 - *scop.RemoveColumnFromIndex - ColumnID: 1 - IndexID: 1 - TableID: 108 - *scop.RemoveColumnFromIndex - ColumnID: 2 - IndexID: 1 - Kind: 2 - TableID: 108 *scop.MakeAddedPrimaryIndexPublic EventBase: Authorization: @@ -1509,24 +1496,15 @@ PostCommitNonRevertiblePhase stage 1 of 3 with 12 MutationType ops *scop.UpdateSchemaChangerJob IsNonCancelable: true JobID: 1 -PostCommitNonRevertiblePhase stage 2 of 3 with 3 MutationType ops +PostCommitNonRevertiblePhase stage 2 of 3 with 7 MutationType ops transitions: [[PrimaryIndex:{DescID: 108, IndexID: 1, ConstraintID: 1}, ABSENT], WRITE_ONLY] -> DELETE_ONLY + [[TemporaryIndex:{DescID: 108, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], TRANSIENT_DELETE_ONLY] -> TRANSIENT_ABSENT + [[TemporaryIndex:{DescID: 108, IndexID: 5, ConstraintID: 5, SourceIndexID: 1}, TRANSIENT_ABSENT], TRANSIENT_DELETE_ONLY] -> TRANSIENT_ABSENT ops: *scop.MakeDroppedIndexDeleteOnly IndexID: 1 TableID: 108 - *scop.SetJobStateOnDescriptor - DescriptorID: 108 - *scop.UpdateSchemaChangerJob - IsNonCancelable: true - JobID: 1 -PostCommitNonRevertiblePhase stage 3 of 3 with 8 MutationType ops - transitions: - [[PrimaryIndex:{DescID: 108, IndexID: 1, ConstraintID: 1}, ABSENT], DELETE_ONLY] -> ABSENT - [[TemporaryIndex:{DescID: 108, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], TRANSIENT_DELETE_ONLY] -> TRANSIENT_ABSENT - [[TemporaryIndex:{DescID: 108, IndexID: 5, ConstraintID: 5, SourceIndexID: 1}, TRANSIENT_ABSENT], TRANSIENT_DELETE_ONLY] -> TRANSIENT_ABSENT - ops: *scop.CreateGcJobForIndex IndexID: 3 TableID: 108 @@ -1539,6 +1517,15 @@ PostCommitNonRevertiblePhase stage 3 of 3 with 8 MutationType ops *scop.MakeIndexAbsent IndexID: 5 TableID: 108 + *scop.SetJobStateOnDescriptor + DescriptorID: 108 + *scop.UpdateSchemaChangerJob + IsNonCancelable: true + JobID: 1 +PostCommitNonRevertiblePhase stage 3 of 3 with 4 MutationType ops + transitions: + [[PrimaryIndex:{DescID: 108, IndexID: 1, ConstraintID: 1}, ABSENT], DELETE_ONLY] -> ABSENT + ops: *scop.CreateGcJobForIndex IndexID: 1 StatementForDropJob: @@ -1561,3 +1548,641 @@ PostCommitNonRevertiblePhase stage 3 of 3 with 8 MutationType ops *scop.UpdateSchemaChangerJob IsNonCancelable: true JobID: 1 + +setup +CREATE TABLE defaultdb.baz (i INT PRIMARY KEY); +---- + +ops +ALTER TABLE defaultdb.baz ADD g INT UNIQUE DEFAULT 1 +---- +StatementPhase stage 1 of 1 with 11 MutationType ops + transitions: + [[Column:{DescID: 109, ColumnID: 2}, PUBLIC], ABSENT] -> DELETE_ONLY + [[ColumnName:{DescID: 109, Name: g, ColumnID: 2}, PUBLIC], ABSENT] -> PUBLIC + [[ColumnType:{DescID: 109, ColumnFamilyID: 0, ColumnID: 2}, PUBLIC], ABSENT] -> PUBLIC + [[ColumnDefaultExpression:{DescID: 109, ColumnID: 2}, PUBLIC], ABSENT] -> PUBLIC + [[PrimaryIndex:{DescID: 109, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC], ABSENT] -> BACKFILL_ONLY + [[IndexColumn:{DescID: 109, ColumnID: 1, IndexID: 2}, PUBLIC], ABSENT] -> PUBLIC + [[IndexColumn:{DescID: 109, ColumnID: 2, IndexID: 2}, PUBLIC], ABSENT] -> PUBLIC + [[TemporaryIndex:{DescID: 109, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], ABSENT] -> DELETE_ONLY + [[IndexColumn:{DescID: 109, ColumnID: 1, IndexID: 3}, TRANSIENT_ABSENT], ABSENT] -> PUBLIC + [[IndexColumn:{DescID: 109, ColumnID: 2, IndexID: 3}, TRANSIENT_ABSENT], ABSENT] -> PUBLIC + ops: + *scop.MakeAddedColumnDeleteOnly + Column: + ColumnID: 2 + PgAttributeNum: 2 + TableID: 109 + *scop.LogEvent + Element: + Column: + columnId: 2 + pgAttributeNum: 2 + tableId: 109 + EventBase: + Authorization: + UserName: root + Statement: ALTER TABLE ‹defaultdb›.public.‹baz› ADD COLUMN ‹g› INT8 UNIQUE DEFAULT + ‹1› + StatementTag: ALTER TABLE + TargetMetadata: + SourceElementID: 1 + SubWorkID: 1 + TargetStatus: 2 + *scop.SetColumnName + ColumnID: 2 + Name: g + TableID: 109 + *scop.SetAddedColumnType + ColumnType: + ColumnID: 2 + IsNullable: true + TableID: 109 + TypeT: + Type: + family: IntFamily + oid: 20 + width: 64 + *scop.AddColumnDefaultExpression + Default: + ColumnID: 2 + Expression: + Expr: 1:::INT8 + TableID: 109 + *scop.MakeAddedIndexBackfilling + Index: + ConstraintID: 2 + IndexID: 2 + IsUnique: true + SourceIndexID: 1 + TableID: 109 + TemporaryIndexID: 3 + *scop.AddColumnToIndex + ColumnID: 1 + IndexID: 2 + TableID: 109 + *scop.AddColumnToIndex + ColumnID: 2 + IndexID: 2 + Kind: 2 + TableID: 109 + *scop.MakeAddedTempIndexDeleteOnly + Index: + ConstraintID: 3 + IndexID: 3 + IsUnique: true + SourceIndexID: 1 + TableID: 109 + *scop.AddColumnToIndex + ColumnID: 1 + IndexID: 3 + TableID: 109 + *scop.AddColumnToIndex + ColumnID: 2 + IndexID: 3 + Kind: 2 + TableID: 109 +PreCommitPhase stage 1 of 1 with 2 MutationType ops + transitions: + ops: + *scop.SetJobStateOnDescriptor + DescriptorID: 109 + Initialize: true + *scop.CreateSchemaChangerJob + Authorization: + UserName: root + DescriptorIDs: + - 109 + JobID: 1 + RunningStatus: PostCommitPhase stage 1 of 15 with 2 MutationType ops pending + Statements: + - statement: ALTER TABLE defaultdb.baz ADD COLUMN g INT8 UNIQUE DEFAULT 1 + redactedstatement: ALTER TABLE ‹defaultdb›.public.‹baz› ADD COLUMN ‹g› INT8 UNIQUE + DEFAULT ‹1› + statementtag: ALTER TABLE +PostCommitPhase stage 1 of 15 with 4 MutationType ops + transitions: + [[Column:{DescID: 109, ColumnID: 2}, PUBLIC], DELETE_ONLY] -> WRITE_ONLY + [[TemporaryIndex:{DescID: 109, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], DELETE_ONLY] -> WRITE_ONLY + ops: + *scop.MakeAddedColumnDeleteAndWriteOnly + ColumnID: 2 + TableID: 109 + *scop.MakeAddedIndexDeleteAndWriteOnly + IndexID: 3 + TableID: 109 + *scop.SetJobStateOnDescriptor + DescriptorID: 109 + *scop.UpdateSchemaChangerJob + JobID: 1 +PostCommitPhase stage 2 of 15 with 1 BackfillType op + transitions: + [[PrimaryIndex:{DescID: 109, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC], BACKFILL_ONLY] -> BACKFILLED + ops: + *scop.BackfillIndex + IndexID: 2 + SourceIndexID: 1 + TableID: 109 +PostCommitPhase stage 3 of 15 with 3 MutationType ops + transitions: + [[PrimaryIndex:{DescID: 109, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC], BACKFILLED] -> DELETE_ONLY + ops: + *scop.MakeBackfillingIndexDeleteOnly + IndexID: 2 + TableID: 109 + *scop.SetJobStateOnDescriptor + DescriptorID: 109 + *scop.UpdateSchemaChangerJob + JobID: 1 +PostCommitPhase stage 4 of 15 with 3 MutationType ops + transitions: + [[PrimaryIndex:{DescID: 109, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC], DELETE_ONLY] -> MERGE_ONLY + ops: + *scop.MakeBackfilledIndexMerging + IndexID: 2 + TableID: 109 + *scop.SetJobStateOnDescriptor + DescriptorID: 109 + *scop.UpdateSchemaChangerJob + JobID: 1 +PostCommitPhase stage 5 of 15 with 1 BackfillType op + transitions: + [[PrimaryIndex:{DescID: 109, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC], MERGE_ONLY] -> MERGED + ops: + *scop.MergeIndex + BackfilledIndexID: 2 + TableID: 109 + TemporaryIndexID: 3 +PostCommitPhase stage 6 of 15 with 3 MutationType ops + transitions: + [[PrimaryIndex:{DescID: 109, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC], MERGED] -> WRITE_ONLY + ops: + *scop.MakeMergedIndexWriteOnly + IndexID: 2 + TableID: 109 + *scop.SetJobStateOnDescriptor + DescriptorID: 109 + *scop.UpdateSchemaChangerJob + JobID: 1 +PostCommitPhase stage 7 of 15 with 1 ValidationType op + transitions: + [[PrimaryIndex:{DescID: 109, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC], WRITE_ONLY] -> VALIDATED + ops: + *scop.ValidateUniqueIndex + IndexID: 2 + TableID: 109 +PostCommitPhase stage 8 of 15 with 14 MutationType ops + transitions: + [[PrimaryIndex:{DescID: 109, IndexID: 1, ConstraintID: 1}, ABSENT], PUBLIC] -> VALIDATED + [[IndexName:{DescID: 109, Name: baz_pkey, IndexID: 1}, ABSENT], PUBLIC] -> ABSENT + [[Column:{DescID: 109, ColumnID: 2}, PUBLIC], WRITE_ONLY] -> PUBLIC + [[PrimaryIndex:{DescID: 109, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC], VALIDATED] -> PUBLIC + [[IndexName:{DescID: 109, Name: baz_pkey, IndexID: 2}, PUBLIC], ABSENT] -> PUBLIC + [[IndexColumn:{DescID: 109, ColumnID: 2, IndexID: 4}, PUBLIC], ABSENT] -> PUBLIC + [[IndexColumn:{DescID: 109, ColumnID: 1, IndexID: 4}, PUBLIC], ABSENT] -> PUBLIC + [[SecondaryIndex:{DescID: 109, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2}, PUBLIC], ABSENT] -> BACKFILL_ONLY + [[IndexColumn:{DescID: 109, ColumnID: 2, IndexID: 5}, PUBLIC], ABSENT] -> PUBLIC + [[IndexColumn:{DescID: 109, ColumnID: 1, IndexID: 5}, PUBLIC], ABSENT] -> PUBLIC + [[TemporaryIndex:{DescID: 109, IndexID: 5, ConstraintID: 4, SourceIndexID: 2}, TRANSIENT_ABSENT], ABSENT] -> DELETE_ONLY + ops: + *scop.MakeDroppedPrimaryIndexDeleteAndWriteOnly + IndexID: 1 + TableID: 109 + *scop.SetIndexName + IndexID: 1 + Name: crdb_internal_index_1_name_placeholder + TableID: 109 + *scop.SetIndexName + IndexID: 2 + Name: baz_pkey + TableID: 109 + *scop.MakeAddedPrimaryIndexPublic + EventBase: + Authorization: + UserName: root + Statement: ALTER TABLE ‹defaultdb›.public.‹baz› ADD COLUMN ‹g› INT8 UNIQUE DEFAULT + ‹1› + StatementTag: ALTER TABLE + TargetMetadata: + SourceElementID: 1 + SubWorkID: 1 + IndexID: 2 + TableID: 109 + *scop.MakeAddedIndexBackfilling + Index: + ConstraintID: 4 + IndexID: 4 + IsUnique: true + SourceIndexID: 2 + TableID: 109 + TemporaryIndexID: 5 + IsSecondaryIndex: true + *scop.MakeAddedTempIndexDeleteOnly + Index: + ConstraintID: 4 + IndexID: 5 + IsUnique: true + SourceIndexID: 2 + TableID: 109 + IsSecondaryIndex: true + *scop.AddColumnToIndex + ColumnID: 2 + IndexID: 4 + TableID: 109 + *scop.AddColumnToIndex + ColumnID: 1 + IndexID: 4 + Kind: 1 + TableID: 109 + *scop.AddColumnToIndex + ColumnID: 2 + IndexID: 5 + TableID: 109 + *scop.AddColumnToIndex + ColumnID: 1 + IndexID: 5 + Kind: 1 + TableID: 109 + *scop.MakeColumnPublic + ColumnID: 2 + EventBase: + Authorization: + UserName: root + Statement: ALTER TABLE ‹defaultdb›.public.‹baz› ADD COLUMN ‹g› INT8 UNIQUE DEFAULT + ‹1› + StatementTag: ALTER TABLE + TargetMetadata: + SourceElementID: 1 + SubWorkID: 1 + TableID: 109 + *scop.RefreshStats + TableID: 109 + *scop.SetJobStateOnDescriptor + DescriptorID: 109 + *scop.UpdateSchemaChangerJob + JobID: 1 +PostCommitPhase stage 9 of 15 with 3 MutationType ops + transitions: + [[TemporaryIndex:{DescID: 109, IndexID: 5, ConstraintID: 4, SourceIndexID: 2}, TRANSIENT_ABSENT], DELETE_ONLY] -> WRITE_ONLY + ops: + *scop.MakeAddedIndexDeleteAndWriteOnly + IndexID: 5 + TableID: 109 + *scop.SetJobStateOnDescriptor + DescriptorID: 109 + *scop.UpdateSchemaChangerJob + JobID: 1 +PostCommitPhase stage 10 of 15 with 1 BackfillType op + transitions: + [[SecondaryIndex:{DescID: 109, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2}, PUBLIC], BACKFILL_ONLY] -> BACKFILLED + ops: + *scop.BackfillIndex + IndexID: 4 + SourceIndexID: 2 + TableID: 109 +PostCommitPhase stage 11 of 15 with 3 MutationType ops + transitions: + [[SecondaryIndex:{DescID: 109, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2}, PUBLIC], BACKFILLED] -> DELETE_ONLY + ops: + *scop.MakeBackfillingIndexDeleteOnly + IndexID: 4 + TableID: 109 + *scop.SetJobStateOnDescriptor + DescriptorID: 109 + *scop.UpdateSchemaChangerJob + JobID: 1 +PostCommitPhase stage 12 of 15 with 3 MutationType ops + transitions: + [[SecondaryIndex:{DescID: 109, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2}, PUBLIC], DELETE_ONLY] -> MERGE_ONLY + ops: + *scop.MakeBackfilledIndexMerging + IndexID: 4 + TableID: 109 + *scop.SetJobStateOnDescriptor + DescriptorID: 109 + *scop.UpdateSchemaChangerJob + JobID: 1 +PostCommitPhase stage 13 of 15 with 1 BackfillType op + transitions: + [[SecondaryIndex:{DescID: 109, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2}, PUBLIC], MERGE_ONLY] -> MERGED + ops: + *scop.MergeIndex + BackfilledIndexID: 4 + TableID: 109 + TemporaryIndexID: 5 +PostCommitPhase stage 14 of 15 with 3 MutationType ops + transitions: + [[SecondaryIndex:{DescID: 109, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2}, PUBLIC], MERGED] -> WRITE_ONLY + ops: + *scop.MakeMergedIndexWriteOnly + IndexID: 4 + TableID: 109 + *scop.SetJobStateOnDescriptor + DescriptorID: 109 + *scop.UpdateSchemaChangerJob + JobID: 1 +PostCommitPhase stage 15 of 15 with 1 ValidationType op + transitions: + [[SecondaryIndex:{DescID: 109, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2}, PUBLIC], WRITE_ONLY] -> VALIDATED + ops: + *scop.ValidateUniqueIndex + IndexID: 4 + TableID: 109 +PostCommitNonRevertiblePhase stage 1 of 2 with 7 MutationType ops + transitions: + [[IndexColumn:{DescID: 109, ColumnID: 1, IndexID: 1}, ABSENT], PUBLIC] -> ABSENT + [[PrimaryIndex:{DescID: 109, IndexID: 1, ConstraintID: 1}, ABSENT], VALIDATED] -> DELETE_ONLY + [[TemporaryIndex:{DescID: 109, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], WRITE_ONLY] -> TRANSIENT_DELETE_ONLY + [[IndexColumn:{DescID: 109, ColumnID: 1, IndexID: 3}, TRANSIENT_ABSENT], PUBLIC] -> TRANSIENT_ABSENT + [[IndexColumn:{DescID: 109, ColumnID: 2, IndexID: 3}, TRANSIENT_ABSENT], PUBLIC] -> TRANSIENT_ABSENT + [[SecondaryIndex:{DescID: 109, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2}, PUBLIC], VALIDATED] -> PUBLIC + [[IndexName:{DescID: 109, Name: baz_g_key, IndexID: 4}, PUBLIC], ABSENT] -> PUBLIC + [[TemporaryIndex:{DescID: 109, IndexID: 5, ConstraintID: 4, SourceIndexID: 2}, TRANSIENT_ABSENT], WRITE_ONLY] -> TRANSIENT_DELETE_ONLY + ops: + *scop.MakeDroppedIndexDeleteOnly + IndexID: 3 + TableID: 109 + *scop.SetIndexName + IndexID: 4 + Name: baz_g_key + TableID: 109 + *scop.MakeDroppedIndexDeleteOnly + IndexID: 5 + TableID: 109 + *scop.MakeDroppedIndexDeleteOnly + IndexID: 1 + TableID: 109 + *scop.MakeAddedSecondaryIndexPublic + IndexID: 4 + TableID: 109 + *scop.SetJobStateOnDescriptor + DescriptorID: 109 + *scop.UpdateSchemaChangerJob + IsNonCancelable: true + JobID: 1 +PostCommitNonRevertiblePhase stage 2 of 2 with 8 MutationType ops + transitions: + [[PrimaryIndex:{DescID: 109, IndexID: 1, ConstraintID: 1}, ABSENT], DELETE_ONLY] -> ABSENT + [[TemporaryIndex:{DescID: 109, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], TRANSIENT_DELETE_ONLY] -> TRANSIENT_ABSENT + [[TemporaryIndex:{DescID: 109, IndexID: 5, ConstraintID: 4, SourceIndexID: 2}, TRANSIENT_ABSENT], TRANSIENT_DELETE_ONLY] -> TRANSIENT_ABSENT + ops: + *scop.CreateGcJobForIndex + IndexID: 1 + StatementForDropJob: + Statement: ALTER TABLE defaultdb.public.baz ADD COLUMN g INT8 UNIQUE DEFAULT 1 + TableID: 109 + *scop.MakeIndexAbsent + EventBase: + Authorization: + UserName: root + Statement: ALTER TABLE ‹defaultdb›.public.‹baz› ADD COLUMN ‹g› INT8 UNIQUE DEFAULT + ‹1› + StatementTag: ALTER TABLE + TargetMetadata: + SourceElementID: 1 + SubWorkID: 1 + IndexID: 1 + TableID: 109 + *scop.CreateGcJobForIndex + IndexID: 3 + TableID: 109 + *scop.MakeIndexAbsent + IndexID: 3 + TableID: 109 + *scop.CreateGcJobForIndex + IndexID: 5 + TableID: 109 + *scop.MakeIndexAbsent + IndexID: 5 + TableID: 109 + *scop.RemoveJobStateFromDescriptor + DescriptorID: 109 + JobID: 1 + *scop.UpdateSchemaChangerJob + IsNonCancelable: true + JobID: 1 + +deps +ALTER TABLE defaultdb.baz ADD g INT UNIQUE DEFAULT 1 +---- +- from: [Column:{DescID: 109, ColumnID: 2}, DELETE_ONLY] + to: [ColumnDefaultExpression:{DescID: 109, ColumnID: 2}, PUBLIC] + kind: Precedence + rule: column existence precedes column dependents +- from: [Column:{DescID: 109, ColumnID: 2}, DELETE_ONLY] + to: [ColumnName:{DescID: 109, Name: g, ColumnID: 2}, PUBLIC] + kind: SameStagePrecedence + rules: [column existence precedes column dependents; column name and type set right after column existence] +- from: [Column:{DescID: 109, ColumnID: 2}, DELETE_ONLY] + to: [ColumnType:{DescID: 109, ColumnFamilyID: 0, ColumnID: 2}, PUBLIC] + kind: SameStagePrecedence + rules: [column existence precedes column dependents; column name and type set right after column existence] +- from: [Column:{DescID: 109, ColumnID: 2}, DELETE_ONLY] + to: [IndexColumn:{DescID: 109, ColumnID: 2, IndexID: 2}, PUBLIC] + kind: Precedence + rule: column existence precedes column dependents +- from: [Column:{DescID: 109, ColumnID: 2}, DELETE_ONLY] + to: [IndexColumn:{DescID: 109, ColumnID: 2, IndexID: 3}, PUBLIC] + kind: Precedence + rule: column existence precedes column dependents +- from: [Column:{DescID: 109, ColumnID: 2}, DELETE_ONLY] + to: [IndexColumn:{DescID: 109, ColumnID: 2, IndexID: 4}, PUBLIC] + kind: Precedence + rule: column existence precedes column dependents +- from: [Column:{DescID: 109, ColumnID: 2}, DELETE_ONLY] + to: [IndexColumn:{DescID: 109, ColumnID: 2, IndexID: 5}, PUBLIC] + kind: Precedence + rule: column existence precedes column dependents +- from: [Column:{DescID: 109, ColumnID: 2}, DELETE_ONLY] + to: [PrimaryIndex:{DescID: 109, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, BACKFILL_ONLY] + kind: Precedence + rule: column existence precedes index existence +- from: [Column:{DescID: 109, ColumnID: 2}, DELETE_ONLY] + to: [SecondaryIndex:{DescID: 109, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2}, BACKFILL_ONLY] + kind: Precedence + rule: column existence precedes index existence +- from: [Column:{DescID: 109, ColumnID: 2}, DELETE_ONLY] + to: [TemporaryIndex:{DescID: 109, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, DELETE_ONLY] + kind: Precedence + rule: column existence precedes temp index existence +- from: [Column:{DescID: 109, ColumnID: 2}, DELETE_ONLY] + to: [TemporaryIndex:{DescID: 109, IndexID: 5, ConstraintID: 4, SourceIndexID: 2}, DELETE_ONLY] + kind: Precedence + rule: column existence precedes temp index existence +- from: [Column:{DescID: 109, ColumnID: 2}, WRITE_ONLY] + to: [TemporaryIndex:{DescID: 109, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, WRITE_ONLY] + kind: Precedence + rule: column is WRITE_ONLY before temporary index is WRITE_ONLY +- from: [Column:{DescID: 109, ColumnID: 2}, WRITE_ONLY] + to: [TemporaryIndex:{DescID: 109, IndexID: 5, ConstraintID: 4, SourceIndexID: 2}, WRITE_ONLY] + kind: Precedence + rule: column is WRITE_ONLY before temporary index is WRITE_ONLY +- from: [ColumnDefaultExpression:{DescID: 109, ColumnID: 2}, PUBLIC] + to: [Column:{DescID: 109, ColumnID: 2}, PUBLIC] + kind: Precedence + rule: column dependents exist before column becomes public +- from: [ColumnDefaultExpression:{DescID: 109, ColumnID: 2}, PUBLIC] + to: [Column:{DescID: 109, ColumnID: 2}, WRITE_ONLY] + kind: Precedence + rule: DEFAULT or ON UPDATE existence precedes writes to column +- from: [ColumnName:{DescID: 109, Name: g, ColumnID: 2}, PUBLIC] + to: [Column:{DescID: 109, ColumnID: 2}, PUBLIC] + kind: Precedence + rule: column dependents exist before column becomes public +- from: [ColumnType:{DescID: 109, ColumnFamilyID: 0, ColumnID: 2}, PUBLIC] + to: [Column:{DescID: 109, ColumnID: 2}, PUBLIC] + kind: Precedence + rule: column dependents exist before column becomes public +- from: [IndexColumn:{DescID: 109, ColumnID: 1, IndexID: 1}, ABSENT] + to: [PrimaryIndex:{DescID: 109, IndexID: 1, ConstraintID: 1}, ABSENT] + kind: Precedence + rule: dependents removed before index +- from: [IndexColumn:{DescID: 109, ColumnID: 1, IndexID: 2}, PUBLIC] + to: [PrimaryIndex:{DescID: 109, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, BACKFILLED] + kind: Precedence + rule: index-column added to index before index is backfilled +- from: [IndexColumn:{DescID: 109, ColumnID: 1, IndexID: 2}, PUBLIC] + to: [PrimaryIndex:{DescID: 109, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC] + kind: Precedence + rule: index dependents exist before index becomes public +- from: [IndexColumn:{DescID: 109, ColumnID: 1, IndexID: 3}, PUBLIC] + to: [TemporaryIndex:{DescID: 109, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, WRITE_ONLY] + kind: Precedence + rule: index-column added to index before temp index receives writes +- from: [IndexColumn:{DescID: 109, ColumnID: 1, IndexID: 3}, TRANSIENT_ABSENT] + to: [TemporaryIndex:{DescID: 109, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT] + kind: Precedence + rule: dependents removed before index +- from: [IndexColumn:{DescID: 109, ColumnID: 1, IndexID: 4}, PUBLIC] + to: [SecondaryIndex:{DescID: 109, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2}, BACKFILLED] + kind: Precedence + rule: index-column added to index before index is backfilled +- from: [IndexColumn:{DescID: 109, ColumnID: 1, IndexID: 4}, PUBLIC] + to: [SecondaryIndex:{DescID: 109, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2}, PUBLIC] + kind: Precedence + rule: index dependents exist before index becomes public +- from: [IndexColumn:{DescID: 109, ColumnID: 2, IndexID: 2}, PUBLIC] + to: [Column:{DescID: 109, ColumnID: 2}, PUBLIC] + kind: Precedence + rule: column dependents exist before column becomes public +- from: [IndexColumn:{DescID: 109, ColumnID: 2, IndexID: 2}, PUBLIC] + to: [PrimaryIndex:{DescID: 109, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, BACKFILLED] + kind: Precedence + rule: index-column added to index before index is backfilled +- from: [IndexColumn:{DescID: 109, ColumnID: 2, IndexID: 2}, PUBLIC] + to: [PrimaryIndex:{DescID: 109, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC] + kind: Precedence + rule: index dependents exist before index becomes public +- from: [IndexColumn:{DescID: 109, ColumnID: 2, IndexID: 3}, PUBLIC] + to: [Column:{DescID: 109, ColumnID: 2}, PUBLIC] + kind: Precedence + rule: column dependents exist before column becomes public +- from: [IndexColumn:{DescID: 109, ColumnID: 2, IndexID: 3}, PUBLIC] + to: [TemporaryIndex:{DescID: 109, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, WRITE_ONLY] + kind: Precedence + rule: index-column added to index before temp index receives writes +- from: [IndexColumn:{DescID: 109, ColumnID: 2, IndexID: 3}, TRANSIENT_ABSENT] + to: [TemporaryIndex:{DescID: 109, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT] + kind: Precedence + rule: dependents removed before index +- from: [IndexColumn:{DescID: 109, ColumnID: 2, IndexID: 4}, PUBLIC] + to: [Column:{DescID: 109, ColumnID: 2}, PUBLIC] + kind: Precedence + rule: column dependents exist before column becomes public +- from: [IndexColumn:{DescID: 109, ColumnID: 2, IndexID: 4}, PUBLIC] + to: [SecondaryIndex:{DescID: 109, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2}, BACKFILLED] + kind: Precedence + rule: index-column added to index before index is backfilled +- from: [IndexColumn:{DescID: 109, ColumnID: 2, IndexID: 4}, PUBLIC] + to: [SecondaryIndex:{DescID: 109, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2}, PUBLIC] + kind: Precedence + rule: index dependents exist before index becomes public +- from: [IndexColumn:{DescID: 109, ColumnID: 2, IndexID: 5}, PUBLIC] + to: [Column:{DescID: 109, ColumnID: 2}, PUBLIC] + kind: Precedence + rule: column dependents exist before column becomes public +- from: [IndexName:{DescID: 109, Name: baz_g_key, IndexID: 4}, PUBLIC] + to: [SecondaryIndex:{DescID: 109, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2}, PUBLIC] + kind: SameStagePrecedence + rules: [index dependents exist before index becomes public; index named right before index becomes public] +- from: [IndexName:{DescID: 109, Name: baz_pkey, IndexID: 1}, ABSENT] + to: [PrimaryIndex:{DescID: 109, IndexID: 1, ConstraintID: 1}, ABSENT] + kind: Precedence + rule: dependents removed before index +- from: [IndexName:{DescID: 109, Name: baz_pkey, IndexID: 2}, PUBLIC] + to: [PrimaryIndex:{DescID: 109, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC] + kind: SameStagePrecedence + rules: [index dependents exist before index becomes public; index named right before index becomes public] +- from: [PrimaryIndex:{DescID: 109, IndexID: 1, ConstraintID: 1}, VALIDATED] + to: [IndexColumn:{DescID: 109, ColumnID: 1, IndexID: 1}, ABSENT] + kind: Precedence + rule: index no longer public before dependents +- from: [PrimaryIndex:{DescID: 109, IndexID: 1, ConstraintID: 1}, VALIDATED] + to: [IndexName:{DescID: 109, Name: baz_pkey, IndexID: 1}, ABSENT] + kind: Precedence + rule: index no longer public before dependents +- from: [PrimaryIndex:{DescID: 109, IndexID: 1, ConstraintID: 1}, VALIDATED] + to: [PrimaryIndex:{DescID: 109, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC] + kind: SameStagePrecedence + rule: primary index swap +- from: [PrimaryIndex:{DescID: 109, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, BACKFILL_ONLY] + to: [IndexColumn:{DescID: 109, ColumnID: 1, IndexID: 2}, PUBLIC] + kind: Precedence + rule: index existence precedes index dependents +- from: [PrimaryIndex:{DescID: 109, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, BACKFILL_ONLY] + to: [IndexColumn:{DescID: 109, ColumnID: 2, IndexID: 2}, PUBLIC] + kind: Precedence + rule: index existence precedes index dependents +- from: [PrimaryIndex:{DescID: 109, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, BACKFILL_ONLY] + to: [IndexName:{DescID: 109, Name: baz_pkey, IndexID: 2}, PUBLIC] + kind: Precedence + rule: index existence precedes index dependents +- from: [PrimaryIndex:{DescID: 109, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC] + to: [Column:{DescID: 109, ColumnID: 2}, PUBLIC] + kind: Precedence + rule: swapped primary index public before column +- from: [PrimaryIndex:{DescID: 109, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC] + to: [SecondaryIndex:{DescID: 109, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2}, BACKFILL_ONLY] + kind: Precedence + rule: primary index with new columns should exist before secondary indexes +- from: [PrimaryIndex:{DescID: 109, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC] + to: [TemporaryIndex:{DescID: 109, IndexID: 5, ConstraintID: 4, SourceIndexID: 2}, DELETE_ONLY] + kind: Precedence + rule: primary index with new columns should exist before temp indexes +- from: [SecondaryIndex:{DescID: 109, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2}, BACKFILL_ONLY] + to: [IndexColumn:{DescID: 109, ColumnID: 1, IndexID: 4}, PUBLIC] + kind: Precedence + rule: index existence precedes index dependents +- from: [SecondaryIndex:{DescID: 109, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2}, BACKFILL_ONLY] + to: [IndexColumn:{DescID: 109, ColumnID: 2, IndexID: 4}, PUBLIC] + kind: Precedence + rule: index existence precedes index dependents +- from: [SecondaryIndex:{DescID: 109, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2}, BACKFILL_ONLY] + to: [IndexName:{DescID: 109, Name: baz_g_key, IndexID: 4}, PUBLIC] + kind: Precedence + rule: index existence precedes index dependents +- from: [TemporaryIndex:{DescID: 109, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, DELETE_ONLY] + to: [IndexColumn:{DescID: 109, ColumnID: 1, IndexID: 3}, PUBLIC] + kind: Precedence + rule: temp index existence precedes index dependents +- from: [TemporaryIndex:{DescID: 109, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, DELETE_ONLY] + to: [IndexColumn:{DescID: 109, ColumnID: 2, IndexID: 3}, PUBLIC] + kind: Precedence + rule: temp index existence precedes index dependents +- from: [TemporaryIndex:{DescID: 109, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, WRITE_ONLY] + to: [PrimaryIndex:{DescID: 109, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, BACKFILLED] + kind: Precedence + rule: temp index is WRITE_ONLY before backfill +- from: [TemporaryIndex:{DescID: 109, IndexID: 5, ConstraintID: 4, SourceIndexID: 2}, DELETE_ONLY] + to: [IndexColumn:{DescID: 109, ColumnID: 1, IndexID: 5}, PUBLIC] + kind: Precedence + rule: temp index existence precedes index dependents +- from: [TemporaryIndex:{DescID: 109, IndexID: 5, ConstraintID: 4, SourceIndexID: 2}, DELETE_ONLY] + to: [IndexColumn:{DescID: 109, ColumnID: 2, IndexID: 5}, PUBLIC] + kind: Precedence + rule: temp index existence precedes index dependents +- from: [TemporaryIndex:{DescID: 109, IndexID: 5, ConstraintID: 4, SourceIndexID: 2}, WRITE_ONLY] + to: [SecondaryIndex:{DescID: 109, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2}, BACKFILLED] + kind: Precedence + rule: temp index is WRITE_ONLY before backfill diff --git a/pkg/sql/schemachanger/scplan/testdata/alter_table_alter_primary_key b/pkg/sql/schemachanger/scplan/testdata/alter_table_alter_primary_key new file mode 100644 index 000000000000..06c1ab8ee30d --- /dev/null +++ b/pkg/sql/schemachanger/scplan/testdata/alter_table_alter_primary_key @@ -0,0 +1,755 @@ +setup +CREATE TABLE t (k INT NOT NULL, v STRING); +---- + +ops +ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (k); +---- +StatementPhase stage 1 of 1 with 14 MutationType ops + transitions: + [[Column:{DescID: 104, ColumnID: 3}, ABSENT], PUBLIC] -> WRITE_ONLY + [[ColumnName:{DescID: 104, Name: rowid, ColumnID: 3}, ABSENT], PUBLIC] -> ABSENT + [[PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], ABSENT] -> BACKFILL_ONLY + [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2}, TRANSIENT_ABSENT], ABSENT] -> PUBLIC + [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2}, TRANSIENT_ABSENT], ABSENT] -> PUBLIC + [[IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2}, TRANSIENT_ABSENT], ABSENT] -> PUBLIC + [[TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], ABSENT] -> DELETE_ONLY + [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3}, TRANSIENT_ABSENT], ABSENT] -> PUBLIC + [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3}, TRANSIENT_ABSENT], ABSENT] -> PUBLIC + [[IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3}, TRANSIENT_ABSENT], ABSENT] -> PUBLIC + [[PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2}, PUBLIC], ABSENT] -> BACKFILL_ONLY + [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4}, PUBLIC], ABSENT] -> PUBLIC + [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 4}, PUBLIC], ABSENT] -> PUBLIC + ops: + *scop.MakeDroppedColumnDeleteAndWriteOnly + ColumnID: 3 + TableID: 104 + *scop.LogEvent + Element: + Column: + columnId: 3 + isHidden: true + pgAttributeNum: 3 + tableId: 104 + EventBase: + Authorization: + UserName: root + Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹k›) + StatementTag: ALTER TABLE + TargetMetadata: + SourceElementID: 1 + SubWorkID: 1 + TargetStatus: 1 + *scop.SetColumnName + ColumnID: 3 + Name: crdb_internal_column_3_name_placeholder + TableID: 104 + *scop.MakeAddedIndexBackfilling + Index: + ConstraintID: 2 + IndexID: 2 + IsUnique: true + SourceIndexID: 1 + TableID: 104 + TemporaryIndexID: 3 + *scop.AddColumnToIndex + ColumnID: 1 + IndexID: 2 + TableID: 104 + *scop.AddColumnToIndex + ColumnID: 2 + IndexID: 2 + Kind: 2 + TableID: 104 + *scop.AddColumnToIndex + ColumnID: 3 + IndexID: 2 + Kind: 2 + Ordinal: 1 + TableID: 104 + *scop.MakeAddedTempIndexDeleteOnly + Index: + ConstraintID: 3 + IndexID: 3 + IsUnique: true + SourceIndexID: 1 + TableID: 104 + *scop.AddColumnToIndex + ColumnID: 1 + IndexID: 3 + TableID: 104 + *scop.AddColumnToIndex + ColumnID: 2 + IndexID: 3 + Kind: 2 + TableID: 104 + *scop.AddColumnToIndex + ColumnID: 3 + IndexID: 3 + Kind: 2 + Ordinal: 1 + TableID: 104 + *scop.MakeAddedIndexBackfilling + Index: + ConstraintID: 4 + IndexID: 4 + IsUnique: true + SourceIndexID: 2 + TableID: 104 + TemporaryIndexID: 5 + *scop.AddColumnToIndex + ColumnID: 1 + IndexID: 4 + TableID: 104 + *scop.AddColumnToIndex + ColumnID: 2 + IndexID: 4 + Kind: 2 + TableID: 104 +PreCommitPhase stage 1 of 1 with 2 MutationType ops + transitions: + ops: + *scop.SetJobStateOnDescriptor + DescriptorID: 104 + Initialize: true + *scop.CreateSchemaChangerJob + Authorization: + UserName: root + DescriptorIDs: + - 104 + JobID: 1 + RunningStatus: PostCommitPhase stage 1 of 15 with 1 MutationType op pending + Statements: + - statement: ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (k) + redactedstatement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS + (‹k›) + statementtag: ALTER TABLE +PostCommitPhase stage 1 of 15 with 3 MutationType ops + transitions: + [[TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], DELETE_ONLY] -> WRITE_ONLY + ops: + *scop.MakeAddedIndexDeleteAndWriteOnly + IndexID: 3 + TableID: 104 + *scop.SetJobStateOnDescriptor + DescriptorID: 104 + *scop.UpdateSchemaChangerJob + JobID: 1 +PostCommitPhase stage 2 of 15 with 1 BackfillType op + transitions: + [[PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], BACKFILL_ONLY] -> BACKFILLED + ops: + *scop.BackfillIndex + IndexID: 2 + SourceIndexID: 1 + TableID: 104 +PostCommitPhase stage 3 of 15 with 3 MutationType ops + transitions: + [[PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], BACKFILLED] -> DELETE_ONLY + ops: + *scop.MakeBackfillingIndexDeleteOnly + IndexID: 2 + TableID: 104 + *scop.SetJobStateOnDescriptor + DescriptorID: 104 + *scop.UpdateSchemaChangerJob + JobID: 1 +PostCommitPhase stage 4 of 15 with 3 MutationType ops + transitions: + [[PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], DELETE_ONLY] -> MERGE_ONLY + ops: + *scop.MakeBackfilledIndexMerging + IndexID: 2 + TableID: 104 + *scop.SetJobStateOnDescriptor + DescriptorID: 104 + *scop.UpdateSchemaChangerJob + JobID: 1 +PostCommitPhase stage 5 of 15 with 1 BackfillType op + transitions: + [[PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], MERGE_ONLY] -> MERGED + ops: + *scop.MergeIndex + BackfilledIndexID: 2 + TableID: 104 + TemporaryIndexID: 3 +PostCommitPhase stage 6 of 15 with 3 MutationType ops + transitions: + [[PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], MERGED] -> WRITE_ONLY + ops: + *scop.MakeMergedIndexWriteOnly + IndexID: 2 + TableID: 104 + *scop.SetJobStateOnDescriptor + DescriptorID: 104 + *scop.UpdateSchemaChangerJob + JobID: 1 +PostCommitPhase stage 7 of 15 with 1 ValidationType op + transitions: + [[PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], WRITE_ONLY] -> VALIDATED + ops: + *scop.ValidateUniqueIndex + IndexID: 2 + TableID: 104 +PostCommitPhase stage 8 of 15 with 9 MutationType ops + transitions: + [[PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1}, ABSENT], PUBLIC] -> VALIDATED + [[IndexName:{DescID: 104, Name: t_pkey, IndexID: 1}, ABSENT], PUBLIC] -> ABSENT + [[PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], VALIDATED] -> PUBLIC + [[IndexName:{DescID: 104, Name: t_pkey, IndexID: 2}, TRANSIENT_ABSENT], ABSENT] -> PUBLIC + [[TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2}, TRANSIENT_ABSENT], ABSENT] -> DELETE_ONLY + [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5}, TRANSIENT_ABSENT], ABSENT] -> PUBLIC + [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 5}, TRANSIENT_ABSENT], ABSENT] -> PUBLIC + ops: + *scop.MakeDroppedPrimaryIndexDeleteAndWriteOnly + IndexID: 1 + TableID: 104 + *scop.SetIndexName + IndexID: 1 + Name: crdb_internal_index_1_name_placeholder + TableID: 104 + *scop.SetIndexName + IndexID: 2 + Name: t_pkey + TableID: 104 + *scop.MakeAddedPrimaryIndexPublic + EventBase: + Authorization: + UserName: root + Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹k›) + StatementTag: ALTER TABLE + TargetMetadata: + SourceElementID: 1 + SubWorkID: 1 + IndexID: 2 + TableID: 104 + *scop.MakeAddedTempIndexDeleteOnly + Index: + ConstraintID: 5 + IndexID: 5 + IsUnique: true + SourceIndexID: 2 + TableID: 104 + *scop.AddColumnToIndex + ColumnID: 1 + IndexID: 5 + TableID: 104 + *scop.AddColumnToIndex + ColumnID: 2 + IndexID: 5 + Kind: 2 + TableID: 104 + *scop.SetJobStateOnDescriptor + DescriptorID: 104 + *scop.UpdateSchemaChangerJob + JobID: 1 +PostCommitPhase stage 9 of 15 with 3 MutationType ops + transitions: + [[TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2}, TRANSIENT_ABSENT], DELETE_ONLY] -> WRITE_ONLY + ops: + *scop.MakeAddedIndexDeleteAndWriteOnly + IndexID: 5 + TableID: 104 + *scop.SetJobStateOnDescriptor + DescriptorID: 104 + *scop.UpdateSchemaChangerJob + JobID: 1 +PostCommitPhase stage 10 of 15 with 1 BackfillType op + transitions: + [[PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2}, PUBLIC], BACKFILL_ONLY] -> BACKFILLED + ops: + *scop.BackfillIndex + IndexID: 4 + SourceIndexID: 2 + TableID: 104 +PostCommitPhase stage 11 of 15 with 3 MutationType ops + transitions: + [[PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2}, PUBLIC], BACKFILLED] -> DELETE_ONLY + ops: + *scop.MakeBackfillingIndexDeleteOnly + IndexID: 4 + TableID: 104 + *scop.SetJobStateOnDescriptor + DescriptorID: 104 + *scop.UpdateSchemaChangerJob + JobID: 1 +PostCommitPhase stage 12 of 15 with 3 MutationType ops + transitions: + [[PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2}, PUBLIC], DELETE_ONLY] -> MERGE_ONLY + ops: + *scop.MakeBackfilledIndexMerging + IndexID: 4 + TableID: 104 + *scop.SetJobStateOnDescriptor + DescriptorID: 104 + *scop.UpdateSchemaChangerJob + JobID: 1 +PostCommitPhase stage 13 of 15 with 1 BackfillType op + transitions: + [[PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2}, PUBLIC], MERGE_ONLY] -> MERGED + ops: + *scop.MergeIndex + BackfilledIndexID: 4 + TableID: 104 + TemporaryIndexID: 5 +PostCommitPhase stage 14 of 15 with 3 MutationType ops + transitions: + [[PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2}, PUBLIC], MERGED] -> WRITE_ONLY + ops: + *scop.MakeMergedIndexWriteOnly + IndexID: 4 + TableID: 104 + *scop.SetJobStateOnDescriptor + DescriptorID: 104 + *scop.UpdateSchemaChangerJob + JobID: 1 +PostCommitPhase stage 15 of 15 with 1 ValidationType op + transitions: + [[PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2}, PUBLIC], WRITE_ONLY] -> VALIDATED + ops: + *scop.ValidateUniqueIndex + IndexID: 4 + TableID: 104 +PostCommitNonRevertiblePhase stage 1 of 4 with 6 MutationType ops + transitions: + [[Column:{DescID: 104, ColumnID: 3}, ABSENT], WRITE_ONLY] -> DELETE_ONLY + [[IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 1}, ABSENT], PUBLIC] -> ABSENT + [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1}, ABSENT], PUBLIC] -> ABSENT + [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1}, ABSENT], PUBLIC] -> ABSENT + [[PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1}, ABSENT], VALIDATED] -> DELETE_ONLY + [[TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], WRITE_ONLY] -> TRANSIENT_DELETE_ONLY + [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3}, TRANSIENT_ABSENT], PUBLIC] -> TRANSIENT_ABSENT + [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3}, TRANSIENT_ABSENT], PUBLIC] -> TRANSIENT_ABSENT + [[IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3}, TRANSIENT_ABSENT], PUBLIC] -> TRANSIENT_ABSENT + [[TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2}, TRANSIENT_ABSENT], WRITE_ONLY] -> TRANSIENT_DELETE_ONLY + [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5}, TRANSIENT_ABSENT], PUBLIC] -> TRANSIENT_ABSENT + [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 5}, TRANSIENT_ABSENT], PUBLIC] -> TRANSIENT_ABSENT + ops: + *scop.MakeDroppedColumnDeleteOnly + ColumnID: 3 + TableID: 104 + *scop.MakeDroppedIndexDeleteOnly + IndexID: 3 + TableID: 104 + *scop.MakeDroppedIndexDeleteOnly + IndexID: 5 + TableID: 104 + *scop.MakeDroppedIndexDeleteOnly + IndexID: 1 + TableID: 104 + *scop.SetJobStateOnDescriptor + DescriptorID: 104 + *scop.UpdateSchemaChangerJob + IsNonCancelable: true + JobID: 1 +PostCommitNonRevertiblePhase stage 2 of 4 with 12 MutationType ops + transitions: + [[PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1}, ABSENT], DELETE_ONLY] -> ABSENT + [[PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], PUBLIC] -> TRANSIENT_WRITE_ONLY + [[IndexName:{DescID: 104, Name: t_pkey, IndexID: 2}, TRANSIENT_ABSENT], PUBLIC] -> TRANSIENT_ABSENT + [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2}, TRANSIENT_ABSENT], PUBLIC] -> TRANSIENT_ABSENT + [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2}, TRANSIENT_ABSENT], PUBLIC] -> TRANSIENT_ABSENT + [[IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2}, TRANSIENT_ABSENT], PUBLIC] -> TRANSIENT_ABSENT + [[TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], TRANSIENT_DELETE_ONLY] -> TRANSIENT_ABSENT + [[PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2}, PUBLIC], VALIDATED] -> PUBLIC + [[IndexName:{DescID: 104, Name: t_pkey, IndexID: 4}, PUBLIC], ABSENT] -> PUBLIC + [[TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2}, TRANSIENT_ABSENT], TRANSIENT_DELETE_ONLY] -> TRANSIENT_ABSENT + ops: + *scop.CreateGcJobForIndex + IndexID: 1 + StatementForDropJob: + Statement: ALTER TABLE defaultdb.public.t ALTER PRIMARY KEY USING COLUMNS (k) + TableID: 104 + *scop.MakeIndexAbsent + EventBase: + Authorization: + UserName: root + Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹k›) + StatementTag: ALTER TABLE + TargetMetadata: + SourceElementID: 1 + SubWorkID: 1 + IndexID: 1 + TableID: 104 + *scop.MakeDroppedPrimaryIndexDeleteAndWriteOnly + IndexID: 2 + TableID: 104 + *scop.SetIndexName + IndexID: 2 + Name: crdb_internal_index_2_name_placeholder + TableID: 104 + *scop.CreateGcJobForIndex + IndexID: 3 + TableID: 104 + *scop.MakeIndexAbsent + IndexID: 3 + TableID: 104 + *scop.SetIndexName + IndexID: 4 + Name: t_pkey + TableID: 104 + *scop.CreateGcJobForIndex + IndexID: 5 + TableID: 104 + *scop.MakeIndexAbsent + IndexID: 5 + TableID: 104 + *scop.MakeAddedPrimaryIndexPublic + EventBase: + Authorization: + UserName: root + Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹k›) + StatementTag: ALTER TABLE + TargetMetadata: + SourceElementID: 1 + SubWorkID: 1 + IndexID: 4 + TableID: 104 + *scop.SetJobStateOnDescriptor + DescriptorID: 104 + *scop.UpdateSchemaChangerJob + IsNonCancelable: true + JobID: 1 +PostCommitNonRevertiblePhase stage 3 of 4 with 3 MutationType ops + transitions: + [[PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], TRANSIENT_WRITE_ONLY] -> TRANSIENT_DELETE_ONLY + ops: + *scop.MakeDroppedIndexDeleteOnly + IndexID: 2 + TableID: 104 + *scop.SetJobStateOnDescriptor + DescriptorID: 104 + *scop.UpdateSchemaChangerJob + IsNonCancelable: true + JobID: 1 +PostCommitNonRevertiblePhase stage 4 of 4 with 6 MutationType ops + transitions: + [[Column:{DescID: 104, ColumnID: 3}, ABSENT], DELETE_ONLY] -> ABSENT + [[ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 3}, ABSENT], PUBLIC] -> ABSENT + [[ColumnDefaultExpression:{DescID: 104, ColumnID: 3}, ABSENT], PUBLIC] -> ABSENT + [[PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], TRANSIENT_DELETE_ONLY] -> TRANSIENT_ABSENT + ops: + *scop.CreateGcJobForIndex + IndexID: 2 + StatementForDropJob: + Statement: ALTER TABLE defaultdb.public.t ALTER PRIMARY KEY USING COLUMNS (k) + TableID: 104 + *scop.MakeIndexAbsent + EventBase: + Authorization: + UserName: root + Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹k›) + StatementTag: ALTER TABLE + TargetMetadata: + SourceElementID: 1 + SubWorkID: 1 + IndexID: 2 + TableID: 104 + *scop.RemoveColumnDefaultExpression + ColumnID: 3 + TableID: 104 + *scop.MakeColumnAbsent + ColumnID: 3 + EventBase: + Authorization: + UserName: root + Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹k›) + StatementTag: ALTER TABLE + TargetMetadata: + SourceElementID: 1 + SubWorkID: 1 + TableID: 104 + *scop.RemoveJobStateFromDescriptor + DescriptorID: 104 + JobID: 1 + *scop.UpdateSchemaChangerJob + IsNonCancelable: true + JobID: 1 + +deps +ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (k); +---- +- from: [Column:{DescID: 104, ColumnID: 3}, WRITE_ONLY] + to: [ColumnDefaultExpression:{DescID: 104, ColumnID: 3}, ABSENT] + kind: Precedence + rule: column no longer public before dependents +- from: [Column:{DescID: 104, ColumnID: 3}, WRITE_ONLY] + to: [ColumnName:{DescID: 104, Name: rowid, ColumnID: 3}, ABSENT] + kind: Precedence + rule: column no longer public before dependents +- from: [Column:{DescID: 104, ColumnID: 3}, WRITE_ONLY] + to: [ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 3}, ABSENT] + kind: Precedence + rule: column no longer public before dependents +- from: [Column:{DescID: 104, ColumnID: 3}, WRITE_ONLY] + to: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 1}, ABSENT] + kind: Precedence + rule: column no longer public before dependents +- from: [Column:{DescID: 104, ColumnID: 3}, WRITE_ONLY] + to: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2}, TRANSIENT_ABSENT] + kind: Precedence + rule: column no longer public before dependents +- from: [Column:{DescID: 104, ColumnID: 3}, WRITE_ONLY] + to: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3}, TRANSIENT_ABSENT] + kind: Precedence + rule: column no longer public before dependents +- from: [ColumnDefaultExpression:{DescID: 104, ColumnID: 3}, ABSENT] + to: [Column:{DescID: 104, ColumnID: 3}, ABSENT] + kind: Precedence + rule: dependents removed before column +- from: [ColumnDefaultExpression:{DescID: 104, ColumnID: 3}, ABSENT] + to: [ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 3}, ABSENT] + kind: SameStagePrecedence + rule: column type dependents removed right before column type +- from: [ColumnName:{DescID: 104, Name: rowid, ColumnID: 3}, ABSENT] + to: [Column:{DescID: 104, ColumnID: 3}, ABSENT] + kind: Precedence + rule: dependents removed before column +- from: [ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 3}, ABSENT] + to: [Column:{DescID: 104, ColumnID: 3}, ABSENT] + kind: SameStagePrecedence + rules: [dependents removed before column; column type removed right before column when not dropping relation] +- from: [IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1}, ABSENT] + to: [PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1}, ABSENT] + kind: Precedence + rule: dependents removed before index +- from: [IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2}, PUBLIC] + to: [PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, BACKFILLED] + kind: Precedence + rule: index-column added to index before index is backfilled +- from: [IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2}, PUBLIC] + to: [PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC] + kind: Precedence + rule: index dependents exist before index becomes public +- from: [IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2}, TRANSIENT_ABSENT] + to: [PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT] + kind: Precedence + rule: dependents removed before index +- from: [IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3}, PUBLIC] + to: [TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, WRITE_ONLY] + kind: Precedence + rule: index-column added to index before temp index receives writes +- from: [IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3}, TRANSIENT_ABSENT] + to: [TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT] + kind: Precedence + rule: dependents removed before index +- from: [IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4}, PUBLIC] + to: [PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2}, BACKFILLED] + kind: Precedence + rule: index-column added to index before index is backfilled +- from: [IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4}, PUBLIC] + to: [PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2}, PUBLIC] + kind: Precedence + rule: index dependents exist before index becomes public +- from: [IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5}, PUBLIC] + to: [TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2}, WRITE_ONLY] + kind: Precedence + rule: index-column added to index before temp index receives writes +- from: [IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5}, TRANSIENT_ABSENT] + to: [TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2}, TRANSIENT_ABSENT] + kind: Precedence + rule: dependents removed before index +- from: [IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1}, ABSENT] + to: [PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1}, ABSENT] + kind: Precedence + rule: dependents removed before index +- from: [IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2}, PUBLIC] + to: [PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, BACKFILLED] + kind: Precedence + rule: index-column added to index before index is backfilled +- from: [IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2}, PUBLIC] + to: [PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC] + kind: Precedence + rule: index dependents exist before index becomes public +- from: [IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2}, TRANSIENT_ABSENT] + to: [PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT] + kind: Precedence + rule: dependents removed before index +- from: [IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3}, PUBLIC] + to: [TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, WRITE_ONLY] + kind: Precedence + rule: index-column added to index before temp index receives writes +- from: [IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3}, TRANSIENT_ABSENT] + to: [TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT] + kind: Precedence + rule: dependents removed before index +- from: [IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 4}, PUBLIC] + to: [PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2}, BACKFILLED] + kind: Precedence + rule: index-column added to index before index is backfilled +- from: [IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 4}, PUBLIC] + to: [PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2}, PUBLIC] + kind: Precedence + rule: index dependents exist before index becomes public +- from: [IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 5}, PUBLIC] + to: [TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2}, WRITE_ONLY] + kind: Precedence + rule: index-column added to index before temp index receives writes +- from: [IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 5}, TRANSIENT_ABSENT] + to: [TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2}, TRANSIENT_ABSENT] + kind: Precedence + rule: dependents removed before index +- from: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 1}, ABSENT] + to: [Column:{DescID: 104, ColumnID: 3}, ABSENT] + kind: Precedence + rule: dependents removed before column +- from: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 1}, ABSENT] + to: [PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1}, ABSENT] + kind: Precedence + rule: dependents removed before index +- from: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2}, PUBLIC] + to: [PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, BACKFILLED] + kind: Precedence + rule: index-column added to index before index is backfilled +- from: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2}, PUBLIC] + to: [PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC] + kind: Precedence + rule: index dependents exist before index becomes public +- from: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2}, TRANSIENT_ABSENT] + to: [Column:{DescID: 104, ColumnID: 3}, ABSENT] + kind: Precedence + rule: dependents removed before column +- from: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2}, TRANSIENT_ABSENT] + to: [PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT] + kind: Precedence + rule: dependents removed before index +- from: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3}, PUBLIC] + to: [TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, WRITE_ONLY] + kind: Precedence + rule: index-column added to index before temp index receives writes +- from: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3}, TRANSIENT_ABSENT] + to: [Column:{DescID: 104, ColumnID: 3}, ABSENT] + kind: Precedence + rule: dependents removed before column +- from: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3}, TRANSIENT_ABSENT] + to: [TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT] + kind: Precedence + rule: dependents removed before index +- from: [IndexName:{DescID: 104, Name: t_pkey, IndexID: 1}, ABSENT] + to: [PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1}, ABSENT] + kind: Precedence + rule: dependents removed before index +- from: [IndexName:{DescID: 104, Name: t_pkey, IndexID: 2}, PUBLIC] + to: [PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC] + kind: SameStagePrecedence + rules: [index dependents exist before index becomes public; index named right before index becomes public] +- from: [IndexName:{DescID: 104, Name: t_pkey, IndexID: 2}, TRANSIENT_ABSENT] + to: [PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT] + kind: Precedence + rule: dependents removed before index +- from: [IndexName:{DescID: 104, Name: t_pkey, IndexID: 4}, PUBLIC] + to: [PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2}, PUBLIC] + kind: SameStagePrecedence + rules: [index dependents exist before index becomes public; index named right before index becomes public] +- from: [PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1}, ABSENT] + to: [Column:{DescID: 104, ColumnID: 3}, ABSENT] + kind: Precedence + rule: indexes containing column reach absent before column +- from: [PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1}, ABSENT] + to: [PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2}, PUBLIC] + kind: Precedence + rule: old index absent before new index public when swapping with transient +- from: [PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1}, VALIDATED] + to: [IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1}, ABSENT] + kind: Precedence + rule: index no longer public before dependents +- from: [PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1}, VALIDATED] + to: [IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1}, ABSENT] + kind: Precedence + rule: index no longer public before dependents +- from: [PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1}, VALIDATED] + to: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 1}, ABSENT] + kind: Precedence + rule: index no longer public before dependents +- from: [PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1}, VALIDATED] + to: [IndexName:{DescID: 104, Name: t_pkey, IndexID: 1}, ABSENT] + kind: Precedence + rule: index no longer public before dependents +- from: [PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1}, VALIDATED] + to: [PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC] + kind: SameStagePrecedence + rule: primary index swap +- from: [PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, BACKFILL_ONLY] + to: [IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2}, PUBLIC] + kind: Precedence + rule: index existence precedes index dependents +- from: [PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, BACKFILL_ONLY] + to: [IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2}, PUBLIC] + kind: Precedence + rule: index existence precedes index dependents +- from: [PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, BACKFILL_ONLY] + to: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2}, PUBLIC] + kind: Precedence + rule: index existence precedes index dependents +- from: [PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, BACKFILL_ONLY] + to: [IndexName:{DescID: 104, Name: t_pkey, IndexID: 2}, PUBLIC] + kind: Precedence + rule: index existence precedes index dependents +- from: [PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC] + to: [TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2}, DELETE_ONLY] + kind: Precedence + rule: primary index with new columns should exist before temp indexes +- from: [PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT] + to: [Column:{DescID: 104, ColumnID: 3}, ABSENT] + kind: Precedence + rule: indexes containing column reach absent before column +- from: [PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, TRANSIENT_VALIDATED] + to: [IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2}, TRANSIENT_ABSENT] + kind: Precedence + rule: index no longer public before dependents +- from: [PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, TRANSIENT_VALIDATED] + to: [IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2}, TRANSIENT_ABSENT] + kind: Precedence + rule: index no longer public before dependents +- from: [PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, TRANSIENT_VALIDATED] + to: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2}, TRANSIENT_ABSENT] + kind: Precedence + rule: index no longer public before dependents +- from: [PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, TRANSIENT_VALIDATED] + to: [IndexName:{DescID: 104, Name: t_pkey, IndexID: 2}, TRANSIENT_ABSENT] + kind: Precedence + rule: index no longer public before dependents +- from: [PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, TRANSIENT_VALIDATED] + to: [PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2}, PUBLIC] + kind: SameStagePrecedence + rule: primary index swap +- from: [PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2}, BACKFILL_ONLY] + to: [IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4}, PUBLIC] + kind: Precedence + rule: index existence precedes index dependents +- from: [PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2}, BACKFILL_ONLY] + to: [IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 4}, PUBLIC] + kind: Precedence + rule: index existence precedes index dependents +- from: [PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2}, BACKFILL_ONLY] + to: [IndexName:{DescID: 104, Name: t_pkey, IndexID: 4}, PUBLIC] + kind: Precedence + rule: index existence precedes index dependents +- from: [TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, DELETE_ONLY] + to: [IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3}, PUBLIC] + kind: Precedence + rule: temp index existence precedes index dependents +- from: [TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, DELETE_ONLY] + to: [IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3}, PUBLIC] + kind: Precedence + rule: temp index existence precedes index dependents +- from: [TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, DELETE_ONLY] + to: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3}, PUBLIC] + kind: Precedence + rule: temp index existence precedes index dependents +- from: [TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1}, WRITE_ONLY] + to: [PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, BACKFILLED] + kind: Precedence + rule: temp index is WRITE_ONLY before backfill +- from: [TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2}, DELETE_ONLY] + to: [IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5}, PUBLIC] + kind: Precedence + rule: temp index existence precedes index dependents +- from: [TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2}, DELETE_ONLY] + to: [IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 5}, PUBLIC] + kind: Precedence + rule: temp index existence precedes index dependents +- from: [TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2}, WRITE_ONLY] + to: [PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2}, BACKFILLED] + kind: Precedence + rule: temp index is WRITE_ONLY before backfill diff --git a/pkg/sql/schemachanger/scplan/testdata/alter_table_drop_column b/pkg/sql/schemachanger/scplan/testdata/alter_table_drop_column index a7f23c561f68..0ba5b08e4e33 100644 --- a/pkg/sql/schemachanger/scplan/testdata/alter_table_drop_column +++ b/pkg/sql/schemachanger/scplan/testdata/alter_table_drop_column @@ -26,12 +26,12 @@ StatementPhase stage 1 of 1 with 12 MutationType ops [[Column:{DescID: 108, ColumnID: 3}, ABSENT], PUBLIC] -> WRITE_ONLY [[Column:{DescID: 108, ColumnID: 4294967295}, ABSENT], PUBLIC] -> WRITE_ONLY [[Column:{DescID: 108, ColumnID: 4294967294}, ABSENT], PUBLIC] -> WRITE_ONLY + [[PrimaryIndex:{DescID: 107, IndexID: 3, ConstraintID: 3, TemporaryIndexID: 4, SourceIndexID: 1}, PUBLIC], ABSENT] -> BACKFILL_ONLY [[IndexColumn:{DescID: 107, ColumnID: 1, IndexID: 3}, PUBLIC], ABSENT] -> PUBLIC [[IndexColumn:{DescID: 107, ColumnID: 3, IndexID: 3}, PUBLIC], ABSENT] -> PUBLIC - [[PrimaryIndex:{DescID: 107, IndexID: 3, ConstraintID: 3, TemporaryIndexID: 4, SourceIndexID: 1}, PUBLIC], ABSENT] -> BACKFILL_ONLY [[TemporaryIndex:{DescID: 107, IndexID: 4, ConstraintID: 4, SourceIndexID: 1}, TRANSIENT_ABSENT], ABSENT] -> DELETE_ONLY - [[IndexColumn:{DescID: 107, ColumnID: 1, IndexID: 4}, PUBLIC], ABSENT] -> PUBLIC - [[IndexColumn:{DescID: 107, ColumnID: 3, IndexID: 4}, PUBLIC], ABSENT] -> PUBLIC + [[IndexColumn:{DescID: 107, ColumnID: 1, IndexID: 4}, TRANSIENT_ABSENT], ABSENT] -> PUBLIC + [[IndexColumn:{DescID: 107, ColumnID: 3, IndexID: 4}, TRANSIENT_ABSENT], ABSENT] -> PUBLIC ops: *scop.MakeDroppedColumnDeleteAndWriteOnly ColumnID: 2 @@ -73,6 +73,15 @@ StatementPhase stage 1 of 1 with 12 MutationType ops SourceIndexID: 1 TableID: 107 TemporaryIndexID: 4 + *scop.AddColumnToIndex + ColumnID: 1 + IndexID: 3 + TableID: 107 + *scop.AddColumnToIndex + ColumnID: 3 + IndexID: 3 + Kind: 2 + TableID: 107 *scop.MakeAddedTempIndexDeleteOnly Index: ConstraintID: 4 @@ -89,15 +98,6 @@ StatementPhase stage 1 of 1 with 12 MutationType ops IndexID: 4 Kind: 2 TableID: 107 - *scop.AddColumnToIndex - ColumnID: 1 - IndexID: 3 - TableID: 107 - *scop.AddColumnToIndex - ColumnID: 3 - IndexID: 3 - Kind: 2 - TableID: 107 PreCommitPhase stage 1 of 1 with 5 MutationType ops transitions: ops: @@ -218,7 +218,7 @@ PostCommitPhase stage 7 of 7 with 1 ValidationType op *scop.ValidateUniqueIndex IndexID: 3 TableID: 107 -PostCommitNonRevertiblePhase stage 1 of 3 with 25 MutationType ops +PostCommitNonRevertiblePhase stage 1 of 3 with 19 MutationType ops transitions: [[Column:{DescID: 107, ColumnID: 2}, ABSENT], WRITE_ONLY] -> DELETE_ONLY [[IndexColumn:{DescID: 107, ColumnID: 1, IndexID: 1}, ABSENT], PUBLIC] -> ABSENT @@ -254,6 +254,8 @@ PostCommitNonRevertiblePhase stage 1 of 3 with 25 MutationType ops [[PrimaryIndex:{DescID: 107, IndexID: 3, ConstraintID: 3, TemporaryIndexID: 4, SourceIndexID: 1}, PUBLIC], VALIDATED] -> PUBLIC [[IndexName:{DescID: 107, Name: foo_pkey, IndexID: 3}, PUBLIC], ABSENT] -> PUBLIC [[TemporaryIndex:{DescID: 107, IndexID: 4, ConstraintID: 4, SourceIndexID: 1}, TRANSIENT_ABSENT], WRITE_ONLY] -> TRANSIENT_DELETE_ONLY + [[IndexColumn:{DescID: 107, ColumnID: 1, IndexID: 4}, TRANSIENT_ABSENT], PUBLIC] -> TRANSIENT_ABSENT + [[IndexColumn:{DescID: 107, ColumnID: 3, IndexID: 4}, TRANSIENT_ABSENT], PUBLIC] -> TRANSIENT_ABSENT ops: *scop.MakeDroppedColumnDeleteOnly ColumnID: 2 @@ -292,21 +294,6 @@ PostCommitNonRevertiblePhase stage 1 of 3 with 25 MutationType ops *scop.MakeDroppedIndexDeleteOnly IndexID: 4 TableID: 107 - *scop.RemoveColumnFromIndex - ColumnID: 1 - IndexID: 1 - TableID: 107 - *scop.RemoveColumnFromIndex - ColumnID: 2 - IndexID: 1 - Kind: 2 - TableID: 107 - *scop.RemoveColumnFromIndex - ColumnID: 3 - IndexID: 1 - Kind: 2 - Ordinal: 1 - TableID: 107 *scop.MakeDroppedIndexDeleteOnly IndexID: 2 TableID: 107 @@ -327,20 +314,6 @@ PostCommitNonRevertiblePhase stage 1 of 3 with 25 MutationType ops SubWorkID: 1 IndexID: 3 TableID: 107 - *scop.RemoveColumnFromIndex - ColumnID: 3 - IndexID: 2 - TableID: 107 - *scop.RemoveColumnFromIndex - ColumnID: 1 - IndexID: 2 - Kind: 1 - TableID: 107 - *scop.RemoveColumnFromIndex - ColumnID: 2 - IndexID: 2 - Kind: 2 - TableID: 107 *scop.SetJobStateOnDescriptor DescriptorID: 104 *scop.SetJobStateOnDescriptor @@ -352,19 +325,45 @@ PostCommitNonRevertiblePhase stage 1 of 3 with 25 MutationType ops *scop.UpdateSchemaChangerJob IsNonCancelable: true JobID: 1 -PostCommitNonRevertiblePhase stage 2 of 3 with 12 MutationType ops +PostCommitNonRevertiblePhase stage 2 of 3 with 17 MutationType ops transitions: [[PrimaryIndex:{DescID: 107, IndexID: 1, ConstraintID: 2}, ABSENT], WRITE_ONLY] -> DELETE_ONLY + [[SecondaryIndex:{DescID: 107, IndexID: 2, ConstraintID: 1}, ABSENT], DELETE_ONLY] -> ABSENT [[View:{DescID: 108}, ABSENT], DROPPED] -> ABSENT [[Column:{DescID: 108, ColumnID: 1}, ABSENT], DELETE_ONLY] -> ABSENT [[Column:{DescID: 108, ColumnID: 2}, ABSENT], DELETE_ONLY] -> ABSENT [[Column:{DescID: 108, ColumnID: 3}, ABSENT], DELETE_ONLY] -> ABSENT [[Column:{DescID: 108, ColumnID: 4294967295}, ABSENT], DELETE_ONLY] -> ABSENT [[Column:{DescID: 108, ColumnID: 4294967294}, ABSENT], DELETE_ONLY] -> ABSENT + [[TemporaryIndex:{DescID: 107, IndexID: 4, ConstraintID: 4, SourceIndexID: 1}, TRANSIENT_ABSENT], TRANSIENT_DELETE_ONLY] -> TRANSIENT_ABSENT ops: *scop.MakeDroppedIndexDeleteOnly IndexID: 1 TableID: 107 + *scop.LogEvent + Element: + SecondaryIndex: + constraintId: 1 + indexId: 2 + isUnique: true + tableId: 107 + EventBase: + Authorization: + UserName: root + Statement: ALTER TABLE ‹defaultdb›.public.‹foo› DROP COLUMN ‹v1› CASCADE + StatementTag: ALTER TABLE + TargetMetadata: + SourceElementID: 1 + SubWorkID: 1 + TargetStatus: 1 + *scop.CreateGcJobForIndex + IndexID: 2 + StatementForDropJob: + Statement: ALTER TABLE defaultdb.public.foo DROP COLUMN v1 CASCADE + TableID: 107 + *scop.MakeIndexAbsent + IndexID: 2 + TableID: 107 *scop.LogEvent Element: View: @@ -445,6 +444,12 @@ PostCommitNonRevertiblePhase stage 2 of 3 with 12 MutationType ops SourceElementID: 1 SubWorkID: 1 TableID: 108 + *scop.CreateGcJobForIndex + IndexID: 4 + TableID: 107 + *scop.MakeIndexAbsent + IndexID: 4 + TableID: 107 *scop.SetJobStateOnDescriptor DescriptorID: 104 *scop.SetJobStateOnDescriptor @@ -456,20 +461,12 @@ PostCommitNonRevertiblePhase stage 2 of 3 with 12 MutationType ops - 108 IsNonCancelable: true JobID: 1 -PostCommitNonRevertiblePhase stage 3 of 3 with 14 MutationType ops +PostCommitNonRevertiblePhase stage 3 of 3 with 9 MutationType ops transitions: [[Column:{DescID: 107, ColumnID: 2}, ABSENT], DELETE_ONLY] -> ABSENT [[ColumnType:{DescID: 107, ColumnFamilyID: 0, ColumnID: 2}, ABSENT], PUBLIC] -> ABSENT [[PrimaryIndex:{DescID: 107, IndexID: 1, ConstraintID: 2}, ABSENT], DELETE_ONLY] -> ABSENT - [[SecondaryIndex:{DescID: 107, IndexID: 2, ConstraintID: 1}, ABSENT], DELETE_ONLY] -> ABSENT - [[TemporaryIndex:{DescID: 107, IndexID: 4, ConstraintID: 4, SourceIndexID: 1}, TRANSIENT_ABSENT], TRANSIENT_DELETE_ONLY] -> TRANSIENT_ABSENT ops: - *scop.CreateGcJobForIndex - IndexID: 4 - TableID: 107 - *scop.MakeIndexAbsent - IndexID: 4 - TableID: 107 *scop.CreateGcJobForIndex IndexID: 1 StatementForDropJob: @@ -486,30 +483,6 @@ PostCommitNonRevertiblePhase stage 3 of 3 with 14 MutationType ops SubWorkID: 1 IndexID: 1 TableID: 107 - *scop.LogEvent - Element: - SecondaryIndex: - constraintId: 1 - indexId: 2 - isUnique: true - tableId: 107 - EventBase: - Authorization: - UserName: root - Statement: ALTER TABLE ‹defaultdb›.public.‹foo› DROP COLUMN ‹v1› CASCADE - StatementTag: ALTER TABLE - TargetMetadata: - SourceElementID: 1 - SubWorkID: 1 - TargetStatus: 1 - *scop.CreateGcJobForIndex - IndexID: 2 - StatementForDropJob: - Statement: ALTER TABLE defaultdb.public.foo DROP COLUMN v1 CASCADE - TableID: 107 - *scop.MakeIndexAbsent - IndexID: 2 - TableID: 107 *scop.RemoveDroppedColumnType ColumnID: 2 TableID: 107 @@ -548,51 +521,59 @@ ALTER TABLE defaultdb.foo DROP COLUMN v1 CASCADE; - from: [Column:{DescID: 107, ColumnID: 2}, WRITE_ONLY] to: [ColumnName:{DescID: 107, Name: v1, ColumnID: 2}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 107, ColumnID: 2}, WRITE_ONLY] to: [ColumnType:{DescID: 107, ColumnFamilyID: 0, ColumnID: 2}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents +- from: [Column:{DescID: 107, ColumnID: 2}, WRITE_ONLY] + to: [IndexColumn:{DescID: 107, ColumnID: 2, IndexID: 1}, ABSENT] + kind: Precedence + rule: column no longer public before dependents +- from: [Column:{DescID: 107, ColumnID: 2}, WRITE_ONLY] + to: [IndexColumn:{DescID: 107, ColumnID: 2, IndexID: 2}, ABSENT] + kind: Precedence + rule: column no longer public before dependents - from: [Column:{DescID: 108, ColumnID: 1}, WRITE_ONLY] to: [ColumnName:{DescID: 108, Name: k, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 108, ColumnID: 1}, WRITE_ONLY] to: [ColumnType:{DescID: 108, ColumnFamilyID: 0, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 108, ColumnID: 2}, WRITE_ONLY] to: [ColumnName:{DescID: 108, Name: v1, ColumnID: 2}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 108, ColumnID: 2}, WRITE_ONLY] to: [ColumnType:{DescID: 108, ColumnFamilyID: 0, ColumnID: 2}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 108, ColumnID: 3}, WRITE_ONLY] to: [ColumnName:{DescID: 108, Name: v2, ColumnID: 3}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 108, ColumnID: 3}, WRITE_ONLY] to: [ColumnType:{DescID: 108, ColumnFamilyID: 0, ColumnID: 3}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 108, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnName:{DescID: 108, Name: tableoid, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 108, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnType:{DescID: 108, ColumnFamilyID: 0, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 108, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnName:{DescID: 108, Name: crdb_internal_mvcc_timestamp, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 108, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnType:{DescID: 108, ColumnFamilyID: 0, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [ColumnName:{DescID: 107, Name: v1, ColumnID: 2}, ABSENT] to: [Column:{DescID: 107, ColumnID: 2}, ABSENT] kind: Precedence @@ -648,23 +629,39 @@ ALTER TABLE defaultdb.foo DROP COLUMN v1 CASCADE; - from: [IndexColumn:{DescID: 107, ColumnID: 1, IndexID: 2}, ABSENT] to: [SecondaryIndex:{DescID: 107, IndexID: 2, ConstraintID: 1}, ABSENT] kind: Precedence - rules: [secondary index columns removed before removing the index; dependents removed before index] + rule: dependents removed before index - from: [IndexColumn:{DescID: 107, ColumnID: 1, IndexID: 3}, PUBLIC] to: [PrimaryIndex:{DescID: 107, IndexID: 3, ConstraintID: 3, TemporaryIndexID: 4, SourceIndexID: 1}, BACKFILLED] kind: Precedence rule: index-column added to index before index is backfilled +- from: [IndexColumn:{DescID: 107, ColumnID: 1, IndexID: 3}, PUBLIC] + to: [PrimaryIndex:{DescID: 107, IndexID: 3, ConstraintID: 3, TemporaryIndexID: 4, SourceIndexID: 1}, PUBLIC] + kind: Precedence + rule: index dependents exist before index becomes public - from: [IndexColumn:{DescID: 107, ColumnID: 1, IndexID: 4}, PUBLIC] to: [TemporaryIndex:{DescID: 107, IndexID: 4, ConstraintID: 4, SourceIndexID: 1}, WRITE_ONLY] kind: Precedence rule: index-column added to index before temp index receives writes +- from: [IndexColumn:{DescID: 107, ColumnID: 1, IndexID: 4}, TRANSIENT_ABSENT] + to: [TemporaryIndex:{DescID: 107, IndexID: 4, ConstraintID: 4, SourceIndexID: 1}, TRANSIENT_ABSENT] + kind: Precedence + rule: dependents removed before index +- from: [IndexColumn:{DescID: 107, ColumnID: 2, IndexID: 1}, ABSENT] + to: [Column:{DescID: 107, ColumnID: 2}, ABSENT] + kind: Precedence + rule: dependents removed before column - from: [IndexColumn:{DescID: 107, ColumnID: 2, IndexID: 1}, ABSENT] to: [PrimaryIndex:{DescID: 107, IndexID: 1, ConstraintID: 2}, ABSENT] kind: Precedence rule: dependents removed before index +- from: [IndexColumn:{DescID: 107, ColumnID: 2, IndexID: 2}, ABSENT] + to: [Column:{DescID: 107, ColumnID: 2}, ABSENT] + kind: Precedence + rule: dependents removed before column - from: [IndexColumn:{DescID: 107, ColumnID: 2, IndexID: 2}, ABSENT] to: [SecondaryIndex:{DescID: 107, IndexID: 2, ConstraintID: 1}, ABSENT] kind: Precedence - rules: [secondary index columns removed before removing the index; dependents removed before index] + rule: dependents removed before index - from: [IndexColumn:{DescID: 107, ColumnID: 3, IndexID: 1}, ABSENT] to: [PrimaryIndex:{DescID: 107, IndexID: 1, ConstraintID: 2}, ABSENT] kind: Precedence @@ -672,15 +669,23 @@ ALTER TABLE defaultdb.foo DROP COLUMN v1 CASCADE; - from: [IndexColumn:{DescID: 107, ColumnID: 3, IndexID: 2}, ABSENT] to: [SecondaryIndex:{DescID: 107, IndexID: 2, ConstraintID: 1}, ABSENT] kind: Precedence - rules: [secondary index columns removed before removing the index; dependents removed before index] + rule: dependents removed before index - from: [IndexColumn:{DescID: 107, ColumnID: 3, IndexID: 3}, PUBLIC] to: [PrimaryIndex:{DescID: 107, IndexID: 3, ConstraintID: 3, TemporaryIndexID: 4, SourceIndexID: 1}, BACKFILLED] kind: Precedence rule: index-column added to index before index is backfilled +- from: [IndexColumn:{DescID: 107, ColumnID: 3, IndexID: 3}, PUBLIC] + to: [PrimaryIndex:{DescID: 107, IndexID: 3, ConstraintID: 3, TemporaryIndexID: 4, SourceIndexID: 1}, PUBLIC] + kind: Precedence + rule: index dependents exist before index becomes public - from: [IndexColumn:{DescID: 107, ColumnID: 3, IndexID: 4}, PUBLIC] to: [TemporaryIndex:{DescID: 107, IndexID: 4, ConstraintID: 4, SourceIndexID: 1}, WRITE_ONLY] kind: Precedence rule: index-column added to index before temp index receives writes +- from: [IndexColumn:{DescID: 107, ColumnID: 3, IndexID: 4}, TRANSIENT_ABSENT] + to: [TemporaryIndex:{DescID: 107, IndexID: 4, ConstraintID: 4, SourceIndexID: 1}, TRANSIENT_ABSENT] + kind: Precedence + rule: dependents removed before index - from: [IndexName:{DescID: 107, Name: foo_pkey, IndexID: 1}, ABSENT] to: [PrimaryIndex:{DescID: 107, IndexID: 1, ConstraintID: 2}, ABSENT] kind: Precedence @@ -688,7 +693,7 @@ ALTER TABLE defaultdb.foo DROP COLUMN v1 CASCADE; - from: [IndexName:{DescID: 107, Name: foo_pkey, IndexID: 3}, PUBLIC] to: [PrimaryIndex:{DescID: 107, IndexID: 3, ConstraintID: 3, TemporaryIndexID: 4, SourceIndexID: 1}, PUBLIC] kind: SameStagePrecedence - rule: index named right before index becomes public + rules: [index dependents exist before index becomes public; index named right before index becomes public] - from: [IndexName:{DescID: 107, Name: foo_v2_key, IndexID: 2}, ABSENT] to: [SecondaryIndex:{DescID: 107, IndexID: 2, ConstraintID: 1}, ABSENT] kind: Precedence @@ -696,23 +701,23 @@ ALTER TABLE defaultdb.foo DROP COLUMN v1 CASCADE; - from: [PrimaryIndex:{DescID: 107, IndexID: 1, ConstraintID: 2}, ABSENT] to: [Column:{DescID: 107, ColumnID: 2}, ABSENT] kind: Precedence - rule: indexes containing columns reach absent before column + rule: indexes containing column reach absent before column - from: [PrimaryIndex:{DescID: 107, IndexID: 1, ConstraintID: 2}, VALIDATED] to: [IndexColumn:{DescID: 107, ColumnID: 1, IndexID: 1}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [PrimaryIndex:{DescID: 107, IndexID: 1, ConstraintID: 2}, VALIDATED] to: [IndexColumn:{DescID: 107, ColumnID: 2, IndexID: 1}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [PrimaryIndex:{DescID: 107, IndexID: 1, ConstraintID: 2}, VALIDATED] to: [IndexColumn:{DescID: 107, ColumnID: 3, IndexID: 1}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [PrimaryIndex:{DescID: 107, IndexID: 1, ConstraintID: 2}, VALIDATED] to: [IndexName:{DescID: 107, Name: foo_pkey, IndexID: 1}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [PrimaryIndex:{DescID: 107, IndexID: 1, ConstraintID: 2}, VALIDATED] to: [PrimaryIndex:{DescID: 107, IndexID: 3, ConstraintID: 3, TemporaryIndexID: 4, SourceIndexID: 1}, PUBLIC] kind: SameStagePrecedence @@ -720,63 +725,43 @@ ALTER TABLE defaultdb.foo DROP COLUMN v1 CASCADE; - from: [PrimaryIndex:{DescID: 107, IndexID: 3, ConstraintID: 3, TemporaryIndexID: 4, SourceIndexID: 1}, BACKFILL_ONLY] to: [IndexColumn:{DescID: 107, ColumnID: 1, IndexID: 3}, PUBLIC] kind: Precedence - rule: index-column added to index after index exists + rule: index existence precedes index dependents - from: [PrimaryIndex:{DescID: 107, IndexID: 3, ConstraintID: 3, TemporaryIndexID: 4, SourceIndexID: 1}, BACKFILL_ONLY] to: [IndexColumn:{DescID: 107, ColumnID: 3, IndexID: 3}, PUBLIC] kind: Precedence - rule: index-column added to index after index exists + rule: index existence precedes index dependents - from: [PrimaryIndex:{DescID: 107, IndexID: 3, ConstraintID: 3, TemporaryIndexID: 4, SourceIndexID: 1}, BACKFILL_ONLY] to: [IndexName:{DescID: 107, Name: foo_pkey, IndexID: 3}, PUBLIC] kind: Precedence - rule: index existence precedes index name and comment + rule: index existence precedes index dependents - from: [SecondaryIndex:{DescID: 107, IndexID: 2, ConstraintID: 1}, ABSENT] to: [Column:{DescID: 107, ColumnID: 2}, ABSENT] kind: Precedence - rule: indexes containing columns reach absent before column -- from: [SecondaryIndex:{DescID: 107, IndexID: 2, ConstraintID: 1}, DELETE_ONLY] - to: [IndexColumn:{DescID: 107, ColumnID: 1, IndexID: 2}, ABSENT] - kind: Precedence - rule: secondary index in DELETE_ONLY before removing columns -- from: [SecondaryIndex:{DescID: 107, IndexID: 2, ConstraintID: 1}, DELETE_ONLY] - to: [IndexColumn:{DescID: 107, ColumnID: 2, IndexID: 2}, ABSENT] - kind: Precedence - rule: secondary index in DELETE_ONLY before removing columns -- from: [SecondaryIndex:{DescID: 107, IndexID: 2, ConstraintID: 1}, DELETE_ONLY] - to: [IndexColumn:{DescID: 107, ColumnID: 3, IndexID: 2}, ABSENT] - kind: Precedence - rule: secondary index in DELETE_ONLY before removing columns + rule: indexes containing column reach absent before column - from: [SecondaryIndex:{DescID: 107, IndexID: 2, ConstraintID: 1}, VALIDATED] to: [IndexColumn:{DescID: 107, ColumnID: 1, IndexID: 2}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [SecondaryIndex:{DescID: 107, IndexID: 2, ConstraintID: 1}, VALIDATED] to: [IndexColumn:{DescID: 107, ColumnID: 2, IndexID: 2}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [SecondaryIndex:{DescID: 107, IndexID: 2, ConstraintID: 1}, VALIDATED] to: [IndexColumn:{DescID: 107, ColumnID: 3, IndexID: 2}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [SecondaryIndex:{DescID: 107, IndexID: 2, ConstraintID: 1}, VALIDATED] to: [IndexName:{DescID: 107, Name: foo_v2_key, IndexID: 2}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [TemporaryIndex:{DescID: 107, IndexID: 4, ConstraintID: 4, SourceIndexID: 1}, DELETE_ONLY] to: [IndexColumn:{DescID: 107, ColumnID: 1, IndexID: 4}, PUBLIC] kind: Precedence - rules: [temp index exists before columns, partitioning, and partial; index-column added to index after temp index exists] + rule: temp index existence precedes index dependents - from: [TemporaryIndex:{DescID: 107, IndexID: 4, ConstraintID: 4, SourceIndexID: 1}, DELETE_ONLY] to: [IndexColumn:{DescID: 107, ColumnID: 3, IndexID: 4}, PUBLIC] kind: Precedence - rules: [temp index exists before columns, partitioning, and partial; index-column added to index after temp index exists] -- from: [TemporaryIndex:{DescID: 107, IndexID: 4, ConstraintID: 4, SourceIndexID: 1}, TRANSIENT_ABSENT] - to: [PrimaryIndex:{DescID: 107, IndexID: 1, ConstraintID: 2}, ABSENT] - kind: SameStagePrecedence - rule: temp indexes reach absent at the same time as other indexes -- from: [TemporaryIndex:{DescID: 107, IndexID: 4, ConstraintID: 4, SourceIndexID: 1}, TRANSIENT_ABSENT] - to: [SecondaryIndex:{DescID: 107, IndexID: 2, ConstraintID: 1}, ABSENT] - kind: SameStagePrecedence - rule: temp indexes reach absent at the same time as other indexes + rule: temp index existence precedes index dependents - from: [TemporaryIndex:{DescID: 107, IndexID: 4, ConstraintID: 4, SourceIndexID: 1}, WRITE_ONLY] to: [PrimaryIndex:{DescID: 107, IndexID: 3, ConstraintID: 3, TemporaryIndexID: 4, SourceIndexID: 1}, BACKFILLED] kind: Precedence @@ -877,35 +862,13 @@ StatementPhase stage 1 of 1 with 12 MutationType ops [[Column:{DescID: 108, ColumnID: 3}, ABSENT], PUBLIC] -> WRITE_ONLY [[Column:{DescID: 108, ColumnID: 4294967295}, ABSENT], PUBLIC] -> WRITE_ONLY [[Column:{DescID: 108, ColumnID: 4294967294}, ABSENT], PUBLIC] -> WRITE_ONLY + [[PrimaryIndex:{DescID: 107, IndexID: 3, ConstraintID: 3, TemporaryIndexID: 4, SourceIndexID: 1}, PUBLIC], ABSENT] -> BACKFILL_ONLY [[IndexColumn:{DescID: 107, ColumnID: 1, IndexID: 3}, PUBLIC], ABSENT] -> PUBLIC [[IndexColumn:{DescID: 107, ColumnID: 2, IndexID: 3}, PUBLIC], ABSENT] -> PUBLIC - [[PrimaryIndex:{DescID: 107, IndexID: 3, ConstraintID: 3, TemporaryIndexID: 4, SourceIndexID: 1}, PUBLIC], ABSENT] -> BACKFILL_ONLY [[TemporaryIndex:{DescID: 107, IndexID: 4, ConstraintID: 4, SourceIndexID: 1}, TRANSIENT_ABSENT], ABSENT] -> DELETE_ONLY - [[IndexColumn:{DescID: 107, ColumnID: 1, IndexID: 4}, PUBLIC], ABSENT] -> PUBLIC - [[IndexColumn:{DescID: 107, ColumnID: 2, IndexID: 4}, PUBLIC], ABSENT] -> PUBLIC + [[IndexColumn:{DescID: 107, ColumnID: 1, IndexID: 4}, TRANSIENT_ABSENT], ABSENT] -> PUBLIC + [[IndexColumn:{DescID: 107, ColumnID: 2, IndexID: 4}, TRANSIENT_ABSENT], ABSENT] -> PUBLIC ops: - *scop.MakeDroppedColumnDeleteAndWriteOnly - ColumnID: 3 - TableID: 107 - *scop.LogEvent - Element: - Column: - columnId: 3 - pgAttributeNum: 3 - tableId: 107 - EventBase: - Authorization: - UserName: root - Statement: ALTER TABLE ‹defaultdb›.public.‹foo› DROP COLUMN ‹v2› CASCADE - StatementTag: ALTER TABLE - TargetMetadata: - SourceElementID: 1 - SubWorkID: 1 - TargetStatus: 1 - *scop.SetColumnName - ColumnID: 3 - Name: crdb_internal_column_3_name_placeholder - TableID: 107 *scop.MakeDroppedNonPrimaryIndexDeleteAndWriteOnly IndexID: 2 TableID: 107 @@ -924,6 +887,15 @@ StatementPhase stage 1 of 1 with 12 MutationType ops SourceIndexID: 1 TableID: 107 TemporaryIndexID: 4 + *scop.AddColumnToIndex + ColumnID: 1 + IndexID: 3 + TableID: 107 + *scop.AddColumnToIndex + ColumnID: 2 + IndexID: 3 + Kind: 2 + TableID: 107 *scop.MakeAddedTempIndexDeleteOnly Index: ConstraintID: 4 @@ -940,14 +912,27 @@ StatementPhase stage 1 of 1 with 12 MutationType ops IndexID: 4 Kind: 2 TableID: 107 - *scop.AddColumnToIndex - ColumnID: 1 - IndexID: 3 + *scop.MakeDroppedColumnDeleteAndWriteOnly + ColumnID: 3 TableID: 107 - *scop.AddColumnToIndex - ColumnID: 2 - IndexID: 3 - Kind: 2 + *scop.LogEvent + Element: + Column: + columnId: 3 + pgAttributeNum: 3 + tableId: 107 + EventBase: + Authorization: + UserName: root + Statement: ALTER TABLE ‹defaultdb›.public.‹foo› DROP COLUMN ‹v2› CASCADE + StatementTag: ALTER TABLE + TargetMetadata: + SourceElementID: 1 + SubWorkID: 1 + TargetStatus: 1 + *scop.SetColumnName + ColumnID: 3 + Name: crdb_internal_column_3_name_placeholder TableID: 107 PreCommitPhase stage 1 of 1 with 6 MutationType ops transitions: @@ -1081,7 +1066,7 @@ PostCommitPhase stage 7 of 7 with 1 ValidationType op *scop.ValidateUniqueIndex IndexID: 3 TableID: 107 -PostCommitNonRevertiblePhase stage 1 of 3 with 26 MutationType ops +PostCommitNonRevertiblePhase stage 1 of 3 with 20 MutationType ops transitions: [[Column:{DescID: 107, ColumnID: 3}, ABSENT], WRITE_ONLY] -> DELETE_ONLY [[IndexColumn:{DescID: 107, ColumnID: 1, IndexID: 1}, ABSENT], PUBLIC] -> ABSENT @@ -1117,6 +1102,8 @@ PostCommitNonRevertiblePhase stage 1 of 3 with 26 MutationType ops [[PrimaryIndex:{DescID: 107, IndexID: 3, ConstraintID: 3, TemporaryIndexID: 4, SourceIndexID: 1}, PUBLIC], VALIDATED] -> PUBLIC [[IndexName:{DescID: 107, Name: foo_pkey, IndexID: 3}, PUBLIC], ABSENT] -> PUBLIC [[TemporaryIndex:{DescID: 107, IndexID: 4, ConstraintID: 4, SourceIndexID: 1}, TRANSIENT_ABSENT], WRITE_ONLY] -> TRANSIENT_DELETE_ONLY + [[IndexColumn:{DescID: 107, ColumnID: 1, IndexID: 4}, TRANSIENT_ABSENT], PUBLIC] -> TRANSIENT_ABSENT + [[IndexColumn:{DescID: 107, ColumnID: 2, IndexID: 4}, TRANSIENT_ABSENT], PUBLIC] -> TRANSIENT_ABSENT ops: *scop.MakeDroppedColumnDeleteOnly ColumnID: 3 @@ -1155,21 +1142,6 @@ PostCommitNonRevertiblePhase stage 1 of 3 with 26 MutationType ops *scop.MakeDroppedIndexDeleteOnly IndexID: 4 TableID: 107 - *scop.RemoveColumnFromIndex - ColumnID: 1 - IndexID: 1 - TableID: 107 - *scop.RemoveColumnFromIndex - ColumnID: 2 - IndexID: 1 - Kind: 2 - TableID: 107 - *scop.RemoveColumnFromIndex - ColumnID: 3 - IndexID: 1 - Kind: 2 - Ordinal: 1 - TableID: 107 *scop.MakeDroppedIndexDeleteOnly IndexID: 2 TableID: 107 @@ -1190,20 +1162,6 @@ PostCommitNonRevertiblePhase stage 1 of 3 with 26 MutationType ops SubWorkID: 1 IndexID: 3 TableID: 107 - *scop.RemoveColumnFromIndex - ColumnID: 3 - IndexID: 2 - TableID: 107 - *scop.RemoveColumnFromIndex - ColumnID: 1 - IndexID: 2 - Kind: 1 - TableID: 107 - *scop.RemoveColumnFromIndex - ColumnID: 2 - IndexID: 2 - Kind: 2 - TableID: 107 *scop.SetJobStateOnDescriptor DescriptorID: 104 *scop.SetJobStateOnDescriptor @@ -1217,19 +1175,45 @@ PostCommitNonRevertiblePhase stage 1 of 3 with 26 MutationType ops *scop.UpdateSchemaChangerJob IsNonCancelable: true JobID: 1 -PostCommitNonRevertiblePhase stage 2 of 3 with 13 MutationType ops +PostCommitNonRevertiblePhase stage 2 of 3 with 18 MutationType ops transitions: [[PrimaryIndex:{DescID: 107, IndexID: 1, ConstraintID: 2}, ABSENT], WRITE_ONLY] -> DELETE_ONLY + [[SecondaryIndex:{DescID: 107, IndexID: 2, ConstraintID: 1}, ABSENT], DELETE_ONLY] -> ABSENT [[View:{DescID: 108}, ABSENT], DROPPED] -> ABSENT [[Column:{DescID: 108, ColumnID: 1}, ABSENT], DELETE_ONLY] -> ABSENT [[Column:{DescID: 108, ColumnID: 2}, ABSENT], DELETE_ONLY] -> ABSENT [[Column:{DescID: 108, ColumnID: 3}, ABSENT], DELETE_ONLY] -> ABSENT [[Column:{DescID: 108, ColumnID: 4294967295}, ABSENT], DELETE_ONLY] -> ABSENT [[Column:{DescID: 108, ColumnID: 4294967294}, ABSENT], DELETE_ONLY] -> ABSENT + [[TemporaryIndex:{DescID: 107, IndexID: 4, ConstraintID: 4, SourceIndexID: 1}, TRANSIENT_ABSENT], TRANSIENT_DELETE_ONLY] -> TRANSIENT_ABSENT ops: *scop.MakeDroppedIndexDeleteOnly IndexID: 1 TableID: 107 + *scop.LogEvent + Element: + SecondaryIndex: + constraintId: 1 + indexId: 2 + isUnique: true + tableId: 107 + EventBase: + Authorization: + UserName: root + Statement: ALTER TABLE ‹defaultdb›.public.‹foo› DROP COLUMN ‹v2› CASCADE + StatementTag: ALTER TABLE + TargetMetadata: + SourceElementID: 1 + SubWorkID: 1 + TargetStatus: 1 + *scop.CreateGcJobForIndex + IndexID: 2 + StatementForDropJob: + Statement: ALTER TABLE defaultdb.public.foo DROP COLUMN v2 CASCADE + TableID: 107 + *scop.MakeIndexAbsent + IndexID: 2 + TableID: 107 *scop.LogEvent Element: View: @@ -1310,6 +1294,12 @@ PostCommitNonRevertiblePhase stage 2 of 3 with 13 MutationType ops SourceElementID: 1 SubWorkID: 1 TableID: 108 + *scop.CreateGcJobForIndex + IndexID: 4 + TableID: 107 + *scop.MakeIndexAbsent + IndexID: 4 + TableID: 107 *scop.SetJobStateOnDescriptor DescriptorID: 104 *scop.SetJobStateOnDescriptor @@ -1323,21 +1313,13 @@ PostCommitNonRevertiblePhase stage 2 of 3 with 13 MutationType ops - 108 IsNonCancelable: true JobID: 1 -PostCommitNonRevertiblePhase stage 3 of 3 with 15 MutationType ops +PostCommitNonRevertiblePhase stage 3 of 3 with 10 MutationType ops transitions: [[Column:{DescID: 107, ColumnID: 3}, ABSENT], DELETE_ONLY] -> ABSENT [[ColumnType:{DescID: 107, ColumnFamilyID: 0, ColumnID: 3}, ABSENT], PUBLIC] -> ABSENT [[ColumnDefaultExpression:{DescID: 107, ColumnID: 3}, ABSENT], PUBLIC] -> ABSENT [[PrimaryIndex:{DescID: 107, IndexID: 1, ConstraintID: 2}, ABSENT], DELETE_ONLY] -> ABSENT - [[SecondaryIndex:{DescID: 107, IndexID: 2, ConstraintID: 1}, ABSENT], DELETE_ONLY] -> ABSENT - [[TemporaryIndex:{DescID: 107, IndexID: 4, ConstraintID: 4, SourceIndexID: 1}, TRANSIENT_ABSENT], TRANSIENT_DELETE_ONLY] -> TRANSIENT_ABSENT ops: - *scop.CreateGcJobForIndex - IndexID: 4 - TableID: 107 - *scop.MakeIndexAbsent - IndexID: 4 - TableID: 107 *scop.CreateGcJobForIndex IndexID: 1 StatementForDropJob: @@ -1354,30 +1336,6 @@ PostCommitNonRevertiblePhase stage 3 of 3 with 15 MutationType ops SubWorkID: 1 IndexID: 1 TableID: 107 - *scop.LogEvent - Element: - SecondaryIndex: - constraintId: 1 - indexId: 2 - isUnique: true - tableId: 107 - EventBase: - Authorization: - UserName: root - Statement: ALTER TABLE ‹defaultdb›.public.‹foo› DROP COLUMN ‹v2› CASCADE - StatementTag: ALTER TABLE - TargetMetadata: - SourceElementID: 1 - SubWorkID: 1 - TargetStatus: 1 - *scop.CreateGcJobForIndex - IndexID: 2 - StatementForDropJob: - Statement: ALTER TABLE defaultdb.public.foo DROP COLUMN v2 CASCADE - TableID: 107 - *scop.MakeIndexAbsent - IndexID: 2 - TableID: 107 *scop.RemoveColumnDefaultExpression ColumnID: 3 TableID: 107 @@ -1416,54 +1374,70 @@ PostCommitNonRevertiblePhase stage 3 of 3 with 15 MutationType ops deps ALTER TABLE defaultdb.foo DROP COLUMN v2 CASCADE; ---- +- from: [Column:{DescID: 107, ColumnID: 3}, WRITE_ONLY] + to: [ColumnDefaultExpression:{DescID: 107, ColumnID: 3}, ABSENT] + kind: Precedence + rule: column no longer public before dependents - from: [Column:{DescID: 107, ColumnID: 3}, WRITE_ONLY] to: [ColumnName:{DescID: 107, Name: v2, ColumnID: 3}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 107, ColumnID: 3}, WRITE_ONLY] to: [ColumnType:{DescID: 107, ColumnFamilyID: 0, ColumnID: 3}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents +- from: [Column:{DescID: 107, ColumnID: 3}, WRITE_ONLY] + to: [IndexColumn:{DescID: 107, ColumnID: 3, IndexID: 1}, ABSENT] + kind: Precedence + rule: column no longer public before dependents +- from: [Column:{DescID: 107, ColumnID: 3}, WRITE_ONLY] + to: [IndexColumn:{DescID: 107, ColumnID: 3, IndexID: 2}, ABSENT] + kind: Precedence + rule: column no longer public before dependents - from: [Column:{DescID: 108, ColumnID: 1}, WRITE_ONLY] to: [ColumnName:{DescID: 108, Name: k, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 108, ColumnID: 1}, WRITE_ONLY] to: [ColumnType:{DescID: 108, ColumnFamilyID: 0, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 108, ColumnID: 2}, WRITE_ONLY] to: [ColumnName:{DescID: 108, Name: v1, ColumnID: 2}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 108, ColumnID: 2}, WRITE_ONLY] to: [ColumnType:{DescID: 108, ColumnFamilyID: 0, ColumnID: 2}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 108, ColumnID: 3}, WRITE_ONLY] to: [ColumnName:{DescID: 108, Name: v2, ColumnID: 3}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 108, ColumnID: 3}, WRITE_ONLY] to: [ColumnType:{DescID: 108, ColumnFamilyID: 0, ColumnID: 3}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 108, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnName:{DescID: 108, Name: tableoid, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 108, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnType:{DescID: 108, ColumnFamilyID: 0, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 108, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnName:{DescID: 108, Name: crdb_internal_mvcc_timestamp, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 108, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnType:{DescID: 108, ColumnFamilyID: 0, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents +- from: [ColumnDefaultExpression:{DescID: 107, ColumnID: 3}, ABSENT] + to: [Column:{DescID: 107, ColumnID: 3}, ABSENT] + kind: Precedence + rule: dependents removed before column - from: [ColumnDefaultExpression:{DescID: 107, ColumnID: 3}, ABSENT] to: [ColumnType:{DescID: 107, ColumnFamilyID: 0, ColumnID: 3}, ABSENT] kind: SameStagePrecedence @@ -1523,15 +1497,23 @@ ALTER TABLE defaultdb.foo DROP COLUMN v2 CASCADE; - from: [IndexColumn:{DescID: 107, ColumnID: 1, IndexID: 2}, ABSENT] to: [SecondaryIndex:{DescID: 107, IndexID: 2, ConstraintID: 1}, ABSENT] kind: Precedence - rules: [secondary index columns removed before removing the index; dependents removed before index] + rule: dependents removed before index - from: [IndexColumn:{DescID: 107, ColumnID: 1, IndexID: 3}, PUBLIC] to: [PrimaryIndex:{DescID: 107, IndexID: 3, ConstraintID: 3, TemporaryIndexID: 4, SourceIndexID: 1}, BACKFILLED] kind: Precedence rule: index-column added to index before index is backfilled +- from: [IndexColumn:{DescID: 107, ColumnID: 1, IndexID: 3}, PUBLIC] + to: [PrimaryIndex:{DescID: 107, IndexID: 3, ConstraintID: 3, TemporaryIndexID: 4, SourceIndexID: 1}, PUBLIC] + kind: Precedence + rule: index dependents exist before index becomes public - from: [IndexColumn:{DescID: 107, ColumnID: 1, IndexID: 4}, PUBLIC] to: [TemporaryIndex:{DescID: 107, IndexID: 4, ConstraintID: 4, SourceIndexID: 1}, WRITE_ONLY] kind: Precedence rule: index-column added to index before temp index receives writes +- from: [IndexColumn:{DescID: 107, ColumnID: 1, IndexID: 4}, TRANSIENT_ABSENT] + to: [TemporaryIndex:{DescID: 107, IndexID: 4, ConstraintID: 4, SourceIndexID: 1}, TRANSIENT_ABSENT] + kind: Precedence + rule: dependents removed before index - from: [IndexColumn:{DescID: 107, ColumnID: 2, IndexID: 1}, ABSENT] to: [PrimaryIndex:{DescID: 107, IndexID: 1, ConstraintID: 2}, ABSENT] kind: Precedence @@ -1539,23 +1521,39 @@ ALTER TABLE defaultdb.foo DROP COLUMN v2 CASCADE; - from: [IndexColumn:{DescID: 107, ColumnID: 2, IndexID: 2}, ABSENT] to: [SecondaryIndex:{DescID: 107, IndexID: 2, ConstraintID: 1}, ABSENT] kind: Precedence - rules: [secondary index columns removed before removing the index; dependents removed before index] + rule: dependents removed before index - from: [IndexColumn:{DescID: 107, ColumnID: 2, IndexID: 3}, PUBLIC] to: [PrimaryIndex:{DescID: 107, IndexID: 3, ConstraintID: 3, TemporaryIndexID: 4, SourceIndexID: 1}, BACKFILLED] kind: Precedence rule: index-column added to index before index is backfilled +- from: [IndexColumn:{DescID: 107, ColumnID: 2, IndexID: 3}, PUBLIC] + to: [PrimaryIndex:{DescID: 107, IndexID: 3, ConstraintID: 3, TemporaryIndexID: 4, SourceIndexID: 1}, PUBLIC] + kind: Precedence + rule: index dependents exist before index becomes public - from: [IndexColumn:{DescID: 107, ColumnID: 2, IndexID: 4}, PUBLIC] to: [TemporaryIndex:{DescID: 107, IndexID: 4, ConstraintID: 4, SourceIndexID: 1}, WRITE_ONLY] kind: Precedence rule: index-column added to index before temp index receives writes +- from: [IndexColumn:{DescID: 107, ColumnID: 2, IndexID: 4}, TRANSIENT_ABSENT] + to: [TemporaryIndex:{DescID: 107, IndexID: 4, ConstraintID: 4, SourceIndexID: 1}, TRANSIENT_ABSENT] + kind: Precedence + rule: dependents removed before index +- from: [IndexColumn:{DescID: 107, ColumnID: 3, IndexID: 1}, ABSENT] + to: [Column:{DescID: 107, ColumnID: 3}, ABSENT] + kind: Precedence + rule: dependents removed before column - from: [IndexColumn:{DescID: 107, ColumnID: 3, IndexID: 1}, ABSENT] to: [PrimaryIndex:{DescID: 107, IndexID: 1, ConstraintID: 2}, ABSENT] kind: Precedence rule: dependents removed before index +- from: [IndexColumn:{DescID: 107, ColumnID: 3, IndexID: 2}, ABSENT] + to: [Column:{DescID: 107, ColumnID: 3}, ABSENT] + kind: Precedence + rule: dependents removed before column - from: [IndexColumn:{DescID: 107, ColumnID: 3, IndexID: 2}, ABSENT] to: [SecondaryIndex:{DescID: 107, IndexID: 2, ConstraintID: 1}, ABSENT] kind: Precedence - rules: [secondary index columns removed before removing the index; dependents removed before index] + rule: dependents removed before index - from: [IndexName:{DescID: 107, Name: foo_pkey, IndexID: 1}, ABSENT] to: [PrimaryIndex:{DescID: 107, IndexID: 1, ConstraintID: 2}, ABSENT] kind: Precedence @@ -1563,7 +1561,7 @@ ALTER TABLE defaultdb.foo DROP COLUMN v2 CASCADE; - from: [IndexName:{DescID: 107, Name: foo_pkey, IndexID: 3}, PUBLIC] to: [PrimaryIndex:{DescID: 107, IndexID: 3, ConstraintID: 3, TemporaryIndexID: 4, SourceIndexID: 1}, PUBLIC] kind: SameStagePrecedence - rule: index named right before index becomes public + rules: [index dependents exist before index becomes public; index named right before index becomes public] - from: [IndexName:{DescID: 107, Name: foo_v2_key, IndexID: 2}, ABSENT] to: [SecondaryIndex:{DescID: 107, IndexID: 2, ConstraintID: 1}, ABSENT] kind: Precedence @@ -1571,23 +1569,23 @@ ALTER TABLE defaultdb.foo DROP COLUMN v2 CASCADE; - from: [PrimaryIndex:{DescID: 107, IndexID: 1, ConstraintID: 2}, ABSENT] to: [Column:{DescID: 107, ColumnID: 3}, ABSENT] kind: Precedence - rule: indexes containing columns reach absent before column + rule: indexes containing column reach absent before column - from: [PrimaryIndex:{DescID: 107, IndexID: 1, ConstraintID: 2}, VALIDATED] to: [IndexColumn:{DescID: 107, ColumnID: 1, IndexID: 1}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [PrimaryIndex:{DescID: 107, IndexID: 1, ConstraintID: 2}, VALIDATED] to: [IndexColumn:{DescID: 107, ColumnID: 2, IndexID: 1}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [PrimaryIndex:{DescID: 107, IndexID: 1, ConstraintID: 2}, VALIDATED] to: [IndexColumn:{DescID: 107, ColumnID: 3, IndexID: 1}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [PrimaryIndex:{DescID: 107, IndexID: 1, ConstraintID: 2}, VALIDATED] to: [IndexName:{DescID: 107, Name: foo_pkey, IndexID: 1}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [PrimaryIndex:{DescID: 107, IndexID: 1, ConstraintID: 2}, VALIDATED] to: [PrimaryIndex:{DescID: 107, IndexID: 3, ConstraintID: 3, TemporaryIndexID: 4, SourceIndexID: 1}, PUBLIC] kind: SameStagePrecedence @@ -1595,63 +1593,47 @@ ALTER TABLE defaultdb.foo DROP COLUMN v2 CASCADE; - from: [PrimaryIndex:{DescID: 107, IndexID: 3, ConstraintID: 3, TemporaryIndexID: 4, SourceIndexID: 1}, BACKFILL_ONLY] to: [IndexColumn:{DescID: 107, ColumnID: 1, IndexID: 3}, PUBLIC] kind: Precedence - rule: index-column added to index after index exists + rule: index existence precedes index dependents - from: [PrimaryIndex:{DescID: 107, IndexID: 3, ConstraintID: 3, TemporaryIndexID: 4, SourceIndexID: 1}, BACKFILL_ONLY] to: [IndexColumn:{DescID: 107, ColumnID: 2, IndexID: 3}, PUBLIC] kind: Precedence - rule: index-column added to index after index exists + rule: index existence precedes index dependents - from: [PrimaryIndex:{DescID: 107, IndexID: 3, ConstraintID: 3, TemporaryIndexID: 4, SourceIndexID: 1}, BACKFILL_ONLY] to: [IndexName:{DescID: 107, Name: foo_pkey, IndexID: 3}, PUBLIC] kind: Precedence - rule: index existence precedes index name and comment + rule: index existence precedes index dependents - from: [SecondaryIndex:{DescID: 107, IndexID: 2, ConstraintID: 1}, ABSENT] to: [Column:{DescID: 107, ColumnID: 3}, ABSENT] kind: Precedence - rule: indexes containing columns reach absent before column -- from: [SecondaryIndex:{DescID: 107, IndexID: 2, ConstraintID: 1}, DELETE_ONLY] - to: [IndexColumn:{DescID: 107, ColumnID: 1, IndexID: 2}, ABSENT] - kind: Precedence - rule: secondary index in DELETE_ONLY before removing columns -- from: [SecondaryIndex:{DescID: 107, IndexID: 2, ConstraintID: 1}, DELETE_ONLY] - to: [IndexColumn:{DescID: 107, ColumnID: 2, IndexID: 2}, ABSENT] - kind: Precedence - rule: secondary index in DELETE_ONLY before removing columns -- from: [SecondaryIndex:{DescID: 107, IndexID: 2, ConstraintID: 1}, DELETE_ONLY] - to: [IndexColumn:{DescID: 107, ColumnID: 3, IndexID: 2}, ABSENT] + rule: indexes containing column reach absent before column +- from: [SecondaryIndex:{DescID: 107, IndexID: 2, ConstraintID: 1}, VALIDATED] + to: [Column:{DescID: 107, ColumnID: 3}, WRITE_ONLY] kind: Precedence - rule: secondary index in DELETE_ONLY before removing columns + rule: secondary indexes containing column as key reach write-only before column - from: [SecondaryIndex:{DescID: 107, IndexID: 2, ConstraintID: 1}, VALIDATED] to: [IndexColumn:{DescID: 107, ColumnID: 1, IndexID: 2}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [SecondaryIndex:{DescID: 107, IndexID: 2, ConstraintID: 1}, VALIDATED] to: [IndexColumn:{DescID: 107, ColumnID: 2, IndexID: 2}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [SecondaryIndex:{DescID: 107, IndexID: 2, ConstraintID: 1}, VALIDATED] to: [IndexColumn:{DescID: 107, ColumnID: 3, IndexID: 2}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [SecondaryIndex:{DescID: 107, IndexID: 2, ConstraintID: 1}, VALIDATED] to: [IndexName:{DescID: 107, Name: foo_v2_key, IndexID: 2}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [TemporaryIndex:{DescID: 107, IndexID: 4, ConstraintID: 4, SourceIndexID: 1}, DELETE_ONLY] to: [IndexColumn:{DescID: 107, ColumnID: 1, IndexID: 4}, PUBLIC] kind: Precedence - rules: [temp index exists before columns, partitioning, and partial; index-column added to index after temp index exists] + rule: temp index existence precedes index dependents - from: [TemporaryIndex:{DescID: 107, IndexID: 4, ConstraintID: 4, SourceIndexID: 1}, DELETE_ONLY] to: [IndexColumn:{DescID: 107, ColumnID: 2, IndexID: 4}, PUBLIC] kind: Precedence - rules: [temp index exists before columns, partitioning, and partial; index-column added to index after temp index exists] -- from: [TemporaryIndex:{DescID: 107, IndexID: 4, ConstraintID: 4, SourceIndexID: 1}, TRANSIENT_ABSENT] - to: [PrimaryIndex:{DescID: 107, IndexID: 1, ConstraintID: 2}, ABSENT] - kind: SameStagePrecedence - rule: temp indexes reach absent at the same time as other indexes -- from: [TemporaryIndex:{DescID: 107, IndexID: 4, ConstraintID: 4, SourceIndexID: 1}, TRANSIENT_ABSENT] - to: [SecondaryIndex:{DescID: 107, IndexID: 2, ConstraintID: 1}, ABSENT] - kind: SameStagePrecedence - rule: temp indexes reach absent at the same time as other indexes + rule: temp index existence precedes index dependents - from: [TemporaryIndex:{DescID: 107, IndexID: 4, ConstraintID: 4, SourceIndexID: 1}, WRITE_ONLY] to: [PrimaryIndex:{DescID: 107, IndexID: 3, ConstraintID: 3, TemporaryIndexID: 4, SourceIndexID: 1}, BACKFILLED] kind: Precedence diff --git a/pkg/sql/schemachanger/scplan/testdata/create_index b/pkg/sql/schemachanger/scplan/testdata/create_index index 41dc6a29b337..fccb19b04d9e 100644 --- a/pkg/sql/schemachanger/scplan/testdata/create_index +++ b/pkg/sql/schemachanger/scplan/testdata/create_index @@ -187,58 +187,58 @@ CREATE INDEX id1 ON defaultdb.t1 (id, name) STORING (money) to: [SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1}, BACKFILLED] kind: Precedence rule: index-column added to index before index is backfilled -- from: [IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3}, PUBLIC] - to: [TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 0, SourceIndexID: 1}, WRITE_ONLY] +- from: [IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2}, PUBLIC] + to: [SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC] kind: Precedence - rule: index-column added to index before temp index receives writes + rule: index dependents exist before index becomes public - from: [IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2}, PUBLIC] to: [SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1}, BACKFILLED] kind: Precedence rule: index-column added to index before index is backfilled -- from: [IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3}, PUBLIC] - to: [TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 0, SourceIndexID: 1}, WRITE_ONLY] +- from: [IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2}, PUBLIC] + to: [SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC] kind: Precedence - rule: index-column added to index before temp index receives writes + rule: index dependents exist before index becomes public - from: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2}, PUBLIC] to: [SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1}, BACKFILLED] kind: Precedence rule: index-column added to index before index is backfilled -- from: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3}, PUBLIC] - to: [TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 0, SourceIndexID: 1}, WRITE_ONLY] +- from: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2}, PUBLIC] + to: [SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC] kind: Precedence - rule: index-column added to index before temp index receives writes + rule: index dependents exist before index becomes public - from: [IndexName:{DescID: 104, Name: id1, IndexID: 2}, PUBLIC] to: [SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC] kind: SameStagePrecedence - rule: index named right before index becomes public + rules: [index dependents exist before index becomes public; index named right before index becomes public] - from: [SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1}, BACKFILL_ONLY] to: [IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2}, PUBLIC] kind: Precedence - rule: index-column added to index after index exists + rule: index existence precedes index dependents - from: [SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1}, BACKFILL_ONLY] to: [IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2}, PUBLIC] kind: Precedence - rule: index-column added to index after index exists + rule: index existence precedes index dependents - from: [SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1}, BACKFILL_ONLY] to: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2}, PUBLIC] kind: Precedence - rule: index-column added to index after index exists + rule: index existence precedes index dependents - from: [SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1}, BACKFILL_ONLY] to: [IndexName:{DescID: 104, Name: id1, IndexID: 2}, PUBLIC] kind: Precedence - rule: index existence precedes index name and comment + rule: index existence precedes index dependents - from: [TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 0, SourceIndexID: 1}, DELETE_ONLY] to: [IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3}, PUBLIC] kind: Precedence - rules: [temp index exists before columns, partitioning, and partial; index-column added to index after temp index exists] + rule: temp index existence precedes index dependents - from: [TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 0, SourceIndexID: 1}, DELETE_ONLY] to: [IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3}, PUBLIC] kind: Precedence - rules: [temp index exists before columns, partitioning, and partial; index-column added to index after temp index exists] + rule: temp index existence precedes index dependents - from: [TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 0, SourceIndexID: 1}, DELETE_ONLY] to: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3}, PUBLIC] kind: Precedence - rules: [temp index exists before columns, partitioning, and partial; index-column added to index after temp index exists] + rule: temp index existence precedes index dependents - from: [TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 0, SourceIndexID: 1}, WRITE_ONLY] to: [SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1}, BACKFILLED] kind: Precedence @@ -434,58 +434,58 @@ CREATE INDEX id1 ON defaultdb.t1 (id, name) STORING (money) to: [SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1}, BACKFILLED] kind: Precedence rule: index-column added to index before index is backfilled -- from: [IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3}, PUBLIC] - to: [TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 0, SourceIndexID: 1}, WRITE_ONLY] +- from: [IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2}, PUBLIC] + to: [SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC] kind: Precedence - rule: index-column added to index before temp index receives writes + rule: index dependents exist before index becomes public - from: [IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2}, PUBLIC] to: [SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1}, BACKFILLED] kind: Precedence rule: index-column added to index before index is backfilled -- from: [IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3}, PUBLIC] - to: [TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 0, SourceIndexID: 1}, WRITE_ONLY] +- from: [IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2}, PUBLIC] + to: [SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC] kind: Precedence - rule: index-column added to index before temp index receives writes + rule: index dependents exist before index becomes public - from: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2}, PUBLIC] to: [SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1}, BACKFILLED] kind: Precedence rule: index-column added to index before index is backfilled -- from: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3}, PUBLIC] - to: [TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 0, SourceIndexID: 1}, WRITE_ONLY] +- from: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2}, PUBLIC] + to: [SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC] kind: Precedence - rule: index-column added to index before temp index receives writes + rule: index dependents exist before index becomes public - from: [IndexName:{DescID: 104, Name: id1, IndexID: 2}, PUBLIC] to: [SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC] kind: SameStagePrecedence - rule: index named right before index becomes public + rules: [index dependents exist before index becomes public; index named right before index becomes public] - from: [SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1}, BACKFILL_ONLY] to: [IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2}, PUBLIC] kind: Precedence - rule: index-column added to index after index exists + rule: index existence precedes index dependents - from: [SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1}, BACKFILL_ONLY] to: [IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2}, PUBLIC] kind: Precedence - rule: index-column added to index after index exists + rule: index existence precedes index dependents - from: [SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1}, BACKFILL_ONLY] to: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2}, PUBLIC] kind: Precedence - rule: index-column added to index after index exists + rule: index existence precedes index dependents - from: [SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1}, BACKFILL_ONLY] to: [IndexName:{DescID: 104, Name: id1, IndexID: 2}, PUBLIC] kind: Precedence - rule: index existence precedes index name and comment + rule: index existence precedes index dependents - from: [TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 0, SourceIndexID: 1}, DELETE_ONLY] to: [IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3}, PUBLIC] kind: Precedence - rules: [temp index exists before columns, partitioning, and partial; index-column added to index after temp index exists] + rule: temp index existence precedes index dependents - from: [TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 0, SourceIndexID: 1}, DELETE_ONLY] to: [IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3}, PUBLIC] kind: Precedence - rules: [temp index exists before columns, partitioning, and partial; index-column added to index after temp index exists] + rule: temp index existence precedes index dependents - from: [TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 0, SourceIndexID: 1}, DELETE_ONLY] to: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3}, PUBLIC] kind: Precedence - rules: [temp index exists before columns, partitioning, and partial; index-column added to index after temp index exists] + rule: temp index existence precedes index dependents - from: [TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 0, SourceIndexID: 1}, WRITE_ONLY] to: [SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1}, BACKFILLED] kind: Precedence diff --git a/pkg/sql/schemachanger/scplan/testdata/drop_database b/pkg/sql/schemachanger/scplan/testdata/drop_database index b0f5fcaad881..df01e4e73800 100644 --- a/pkg/sql/schemachanger/scplan/testdata/drop_database +++ b/pkg/sql/schemachanger/scplan/testdata/drop_database @@ -1338,247 +1338,287 @@ DROP DATABASE db1 CASCADE - from: [Column:{DescID: 109, ColumnID: 1}, WRITE_ONLY] to: [ColumnName:{DescID: 109, Name: id, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 109, ColumnID: 1}, WRITE_ONLY] to: [ColumnType:{DescID: 109, ColumnFamilyID: 0, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents +- from: [Column:{DescID: 109, ColumnID: 1}, WRITE_ONLY] + to: [IndexColumn:{DescID: 109, ColumnID: 1, IndexID: 1}, ABSENT] + kind: Precedence + rule: column no longer public before dependents - from: [Column:{DescID: 109, ColumnID: 2}, WRITE_ONLY] to: [ColumnName:{DescID: 109, Name: name, ColumnID: 2}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 109, ColumnID: 2}, WRITE_ONLY] to: [ColumnType:{DescID: 109, ColumnFamilyID: 0, ColumnID: 2}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents +- from: [Column:{DescID: 109, ColumnID: 2}, WRITE_ONLY] + to: [IndexColumn:{DescID: 109, ColumnID: 2, IndexID: 1}, ABSENT] + kind: Precedence + rule: column no longer public before dependents +- from: [Column:{DescID: 109, ColumnID: 3}, WRITE_ONLY] + to: [ColumnDefaultExpression:{DescID: 109, ColumnID: 3}, ABSENT] + kind: Precedence + rule: column no longer public before dependents - from: [Column:{DescID: 109, ColumnID: 3}, WRITE_ONLY] to: [ColumnName:{DescID: 109, Name: val, ColumnID: 3}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 109, ColumnID: 3}, WRITE_ONLY] to: [ColumnType:{DescID: 109, ColumnFamilyID: 0, ColumnID: 3}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents +- from: [Column:{DescID: 109, ColumnID: 3}, WRITE_ONLY] + to: [IndexColumn:{DescID: 109, ColumnID: 3, IndexID: 1}, ABSENT] + kind: Precedence + rule: column no longer public before dependents - from: [Column:{DescID: 109, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnName:{DescID: 109, Name: tableoid, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 109, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnType:{DescID: 109, ColumnFamilyID: 0, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 109, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnName:{DescID: 109, Name: crdb_internal_mvcc_timestamp, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 109, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnType:{DescID: 109, ColumnFamilyID: 0, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 110, ColumnID: 1}, WRITE_ONLY] to: [ColumnName:{DescID: 110, Name: id, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 110, ColumnID: 1}, WRITE_ONLY] to: [ColumnType:{DescID: 110, ColumnFamilyID: 0, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents +- from: [Column:{DescID: 110, ColumnID: 1}, WRITE_ONLY] + to: [IndexColumn:{DescID: 110, ColumnID: 1, IndexID: 1}, ABSENT] + kind: Precedence + rule: column no longer public before dependents - from: [Column:{DescID: 110, ColumnID: 2}, WRITE_ONLY] to: [ColumnName:{DescID: 110, Name: name, ColumnID: 2}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 110, ColumnID: 2}, WRITE_ONLY] to: [ColumnType:{DescID: 110, ColumnFamilyID: 0, ColumnID: 2}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents +- from: [Column:{DescID: 110, ColumnID: 2}, WRITE_ONLY] + to: [IndexColumn:{DescID: 110, ColumnID: 2, IndexID: 1}, ABSENT] + kind: Precedence + rule: column no longer public before dependents +- from: [Column:{DescID: 110, ColumnID: 3}, WRITE_ONLY] + to: [ColumnDefaultExpression:{DescID: 110, ColumnID: 3}, ABSENT] + kind: Precedence + rule: column no longer public before dependents - from: [Column:{DescID: 110, ColumnID: 3}, WRITE_ONLY] to: [ColumnName:{DescID: 110, Name: val, ColumnID: 3}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 110, ColumnID: 3}, WRITE_ONLY] to: [ColumnType:{DescID: 110, ColumnFamilyID: 0, ColumnID: 3}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents +- from: [Column:{DescID: 110, ColumnID: 3}, WRITE_ONLY] + to: [IndexColumn:{DescID: 110, ColumnID: 3, IndexID: 1}, ABSENT] + kind: Precedence + rule: column no longer public before dependents - from: [Column:{DescID: 110, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnName:{DescID: 110, Name: tableoid, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 110, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnType:{DescID: 110, ColumnFamilyID: 0, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 110, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnName:{DescID: 110, Name: crdb_internal_mvcc_timestamp, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 110, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnType:{DescID: 110, ColumnFamilyID: 0, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 111, ColumnID: 1}, WRITE_ONLY] to: [ColumnName:{DescID: 111, Name: name, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 111, ColumnID: 1}, WRITE_ONLY] to: [ColumnType:{DescID: 111, ColumnFamilyID: 0, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 111, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnName:{DescID: 111, Name: tableoid, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 111, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnType:{DescID: 111, ColumnFamilyID: 0, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 111, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnName:{DescID: 111, Name: crdb_internal_mvcc_timestamp, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 111, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnType:{DescID: 111, ColumnFamilyID: 0, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 112, ColumnID: 1}, WRITE_ONLY] to: [ColumnName:{DescID: 112, Name: n1, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 112, ColumnID: 1}, WRITE_ONLY] to: [ColumnType:{DescID: 112, ColumnFamilyID: 0, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 112, ColumnID: 2}, WRITE_ONLY] to: [ColumnName:{DescID: 112, Name: n2, ColumnID: 2}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 112, ColumnID: 2}, WRITE_ONLY] to: [ColumnType:{DescID: 112, ColumnFamilyID: 0, ColumnID: 2}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 112, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnName:{DescID: 112, Name: tableoid, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 112, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnType:{DescID: 112, ColumnFamilyID: 0, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 112, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnName:{DescID: 112, Name: crdb_internal_mvcc_timestamp, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 112, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnType:{DescID: 112, ColumnFamilyID: 0, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 113, ColumnID: 1}, WRITE_ONLY] to: [ColumnName:{DescID: 113, Name: name, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 113, ColumnID: 1}, WRITE_ONLY] to: [ColumnType:{DescID: 113, ColumnFamilyID: 0, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 113, ColumnID: 2}, WRITE_ONLY] to: [ColumnName:{DescID: 113, Name: n1, ColumnID: 2}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 113, ColumnID: 2}, WRITE_ONLY] to: [ColumnType:{DescID: 113, ColumnFamilyID: 0, ColumnID: 2}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 113, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnName:{DescID: 113, Name: tableoid, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 113, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnType:{DescID: 113, ColumnFamilyID: 0, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 113, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnName:{DescID: 113, Name: crdb_internal_mvcc_timestamp, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 113, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnType:{DescID: 113, ColumnFamilyID: 0, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 114, ColumnID: 1}, WRITE_ONLY] to: [ColumnName:{DescID: 114, Name: n2, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 114, ColumnID: 1}, WRITE_ONLY] to: [ColumnType:{DescID: 114, ColumnFamilyID: 0, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 114, ColumnID: 2}, WRITE_ONLY] to: [ColumnName:{DescID: 114, Name: n1, ColumnID: 2}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 114, ColumnID: 2}, WRITE_ONLY] to: [ColumnType:{DescID: 114, ColumnFamilyID: 0, ColumnID: 2}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 114, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnName:{DescID: 114, Name: tableoid, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 114, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnType:{DescID: 114, ColumnFamilyID: 0, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 114, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnName:{DescID: 114, Name: crdb_internal_mvcc_timestamp, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 114, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnType:{DescID: 114, ColumnFamilyID: 0, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 117, ColumnID: 1}, WRITE_ONLY] to: [ColumnName:{DescID: 117, Name: k, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 117, ColumnID: 1}, WRITE_ONLY] to: [ColumnType:{DescID: 117, ColumnFamilyID: 0, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 117, ColumnID: 2}, WRITE_ONLY] to: [ColumnName:{DescID: 117, Name: n2, ColumnID: 2}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 117, ColumnID: 2}, WRITE_ONLY] to: [ColumnType:{DescID: 117, ColumnFamilyID: 0, ColumnID: 2}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 117, ColumnID: 3}, WRITE_ONLY] to: [ColumnName:{DescID: 117, Name: n1, ColumnID: 3}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 117, ColumnID: 3}, WRITE_ONLY] to: [ColumnType:{DescID: 117, ColumnFamilyID: 0, ColumnID: 3}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 117, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnName:{DescID: 117, Name: tableoid, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 117, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnType:{DescID: 117, ColumnFamilyID: 0, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 117, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnName:{DescID: 117, Name: crdb_internal_mvcc_timestamp, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 117, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnType:{DescID: 117, ColumnFamilyID: 0, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents +- from: [ColumnDefaultExpression:{DescID: 109, ColumnID: 3}, ABSENT] + to: [Column:{DescID: 109, ColumnID: 3}, ABSENT] + kind: Precedence + rule: dependents removed before column - from: [ColumnDefaultExpression:{DescID: 109, ColumnID: 3}, ABSENT] to: [ColumnType:{DescID: 109, ColumnFamilyID: 0, ColumnID: 3}, ABSENT] kind: SameStagePrecedence rule: column type dependents removed right before column type +- from: [ColumnDefaultExpression:{DescID: 110, ColumnID: 3}, ABSENT] + to: [Column:{DescID: 110, ColumnID: 3}, ABSENT] + kind: Precedence + rule: dependents removed before column - from: [ColumnDefaultExpression:{DescID: 110, ColumnID: 3}, ABSENT] to: [ColumnType:{DescID: 110, ColumnFamilyID: 0, ColumnID: 3}, ABSENT] kind: SameStagePrecedence @@ -1939,26 +1979,50 @@ DROP DATABASE db1 CASCADE to: [UserPrivileges:{DescID: 115, Name: root}, ABSENT] kind: SameStagePrecedence rule: descriptor drop right before dependent element removal +- from: [IndexColumn:{DescID: 109, ColumnID: 1, IndexID: 1}, ABSENT] + to: [Column:{DescID: 109, ColumnID: 1}, ABSENT] + kind: Precedence + rule: dependents removed before column - from: [IndexColumn:{DescID: 109, ColumnID: 1, IndexID: 1}, ABSENT] to: [PrimaryIndex:{DescID: 109, IndexID: 1, ConstraintID: 1}, ABSENT] kind: Precedence rule: dependents removed before index +- from: [IndexColumn:{DescID: 109, ColumnID: 2, IndexID: 1}, ABSENT] + to: [Column:{DescID: 109, ColumnID: 2}, ABSENT] + kind: Precedence + rule: dependents removed before column - from: [IndexColumn:{DescID: 109, ColumnID: 2, IndexID: 1}, ABSENT] to: [PrimaryIndex:{DescID: 109, IndexID: 1, ConstraintID: 1}, ABSENT] kind: Precedence rule: dependents removed before index +- from: [IndexColumn:{DescID: 109, ColumnID: 3, IndexID: 1}, ABSENT] + to: [Column:{DescID: 109, ColumnID: 3}, ABSENT] + kind: Precedence + rule: dependents removed before column - from: [IndexColumn:{DescID: 109, ColumnID: 3, IndexID: 1}, ABSENT] to: [PrimaryIndex:{DescID: 109, IndexID: 1, ConstraintID: 1}, ABSENT] kind: Precedence rule: dependents removed before index +- from: [IndexColumn:{DescID: 110, ColumnID: 1, IndexID: 1}, ABSENT] + to: [Column:{DescID: 110, ColumnID: 1}, ABSENT] + kind: Precedence + rule: dependents removed before column - from: [IndexColumn:{DescID: 110, ColumnID: 1, IndexID: 1}, ABSENT] to: [PrimaryIndex:{DescID: 110, IndexID: 1, ConstraintID: 1}, ABSENT] kind: Precedence rule: dependents removed before index +- from: [IndexColumn:{DescID: 110, ColumnID: 2, IndexID: 1}, ABSENT] + to: [Column:{DescID: 110, ColumnID: 2}, ABSENT] + kind: Precedence + rule: dependents removed before column - from: [IndexColumn:{DescID: 110, ColumnID: 2, IndexID: 1}, ABSENT] to: [PrimaryIndex:{DescID: 110, IndexID: 1, ConstraintID: 1}, ABSENT] kind: Precedence rule: dependents removed before index +- from: [IndexColumn:{DescID: 110, ColumnID: 3, IndexID: 1}, ABSENT] + to: [Column:{DescID: 110, ColumnID: 3}, ABSENT] + kind: Precedence + rule: dependents removed before column - from: [IndexColumn:{DescID: 110, ColumnID: 3, IndexID: 1}, ABSENT] to: [PrimaryIndex:{DescID: 110, IndexID: 1, ConstraintID: 1}, ABSENT] kind: Precedence @@ -1974,35 +2038,35 @@ DROP DATABASE db1 CASCADE - from: [PrimaryIndex:{DescID: 109, IndexID: 1, ConstraintID: 1}, VALIDATED] to: [IndexColumn:{DescID: 109, ColumnID: 1, IndexID: 1}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [PrimaryIndex:{DescID: 109, IndexID: 1, ConstraintID: 1}, VALIDATED] to: [IndexColumn:{DescID: 109, ColumnID: 2, IndexID: 1}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [PrimaryIndex:{DescID: 109, IndexID: 1, ConstraintID: 1}, VALIDATED] to: [IndexColumn:{DescID: 109, ColumnID: 3, IndexID: 1}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [PrimaryIndex:{DescID: 109, IndexID: 1, ConstraintID: 1}, VALIDATED] to: [IndexName:{DescID: 109, Name: t1_pkey, IndexID: 1}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [PrimaryIndex:{DescID: 110, IndexID: 1, ConstraintID: 1}, VALIDATED] to: [IndexColumn:{DescID: 110, ColumnID: 1, IndexID: 1}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [PrimaryIndex:{DescID: 110, IndexID: 1, ConstraintID: 1}, VALIDATED] to: [IndexColumn:{DescID: 110, ColumnID: 2, IndexID: 1}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [PrimaryIndex:{DescID: 110, IndexID: 1, ConstraintID: 1}, VALIDATED] to: [IndexColumn:{DescID: 110, ColumnID: 3, IndexID: 1}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [PrimaryIndex:{DescID: 110, IndexID: 1, ConstraintID: 1}, VALIDATED] to: [IndexName:{DescID: 110, Name: t1_pkey, IndexID: 1}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [Schema:{DescID: 105}, DROPPED] to: [Namespace:{DescID: 105, Name: public, ReferencedDescID: 104}, ABSENT] kind: SameStagePrecedence diff --git a/pkg/sql/schemachanger/scplan/testdata/drop_index b/pkg/sql/schemachanger/scplan/testdata/drop_index index 5e7ed7bebfc6..76ec4d19e4cc 100644 --- a/pkg/sql/schemachanger/scplan/testdata/drop_index +++ b/pkg/sql/schemachanger/scplan/testdata/drop_index @@ -40,12 +40,12 @@ PreCommitPhase stage 1 of 1 with 2 MutationType ops - 104 JobID: 1 NonCancelable: true - RunningStatus: PostCommitNonRevertiblePhase stage 1 of 2 with 3 MutationType ops pending + RunningStatus: PostCommitNonRevertiblePhase stage 1 of 2 with 1 MutationType op pending Statements: - statement: DROP INDEX idx1 CASCADE redactedstatement: DROP INDEX ‹defaultdb›.public.‹t1›@‹idx1› CASCADE statementtag: DROP INDEX -PostCommitNonRevertiblePhase stage 1 of 2 with 5 MutationType ops +PostCommitNonRevertiblePhase stage 1 of 2 with 3 MutationType ops transitions: [[IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2}, ABSENT], PUBLIC] -> ABSENT [[IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2}, ABSENT], PUBLIC] -> ABSENT @@ -54,15 +54,6 @@ PostCommitNonRevertiblePhase stage 1 of 2 with 5 MutationType ops *scop.MakeDroppedIndexDeleteOnly IndexID: 2 TableID: 104 - *scop.RemoveColumnFromIndex - ColumnID: 1 - IndexID: 2 - TableID: 104 - *scop.RemoveColumnFromIndex - ColumnID: 3 - IndexID: 2 - Kind: 1 - TableID: 104 *scop.SetJobStateOnDescriptor DescriptorID: 104 *scop.UpdateSchemaChangerJob @@ -108,35 +99,27 @@ DROP INDEX idx1 CASCADE - from: [IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2}, ABSENT] to: [SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0}, ABSENT] kind: Precedence - rules: [secondary index columns removed before removing the index; dependents removed before index] + rule: dependents removed before index - from: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2}, ABSENT] to: [SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0}, ABSENT] kind: Precedence - rules: [secondary index columns removed before removing the index; dependents removed before index] + rule: dependents removed before index - from: [IndexName:{DescID: 104, Name: idx1, IndexID: 2}, ABSENT] to: [SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0}, ABSENT] kind: Precedence rule: dependents removed before index -- from: [SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0}, DELETE_ONLY] - to: [IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2}, ABSENT] - kind: Precedence - rule: secondary index in DELETE_ONLY before removing columns -- from: [SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0}, DELETE_ONLY] - to: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2}, ABSENT] - kind: Precedence - rule: secondary index in DELETE_ONLY before removing columns - from: [SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0}, VALIDATED] to: [IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0}, VALIDATED] to: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0}, VALIDATED] to: [IndexName:{DescID: 104, Name: idx1, IndexID: 2}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents ops DROP INDEX idx2 CASCADE @@ -148,6 +131,13 @@ StatementPhase stage 1 of 1 with 5 MutationType ops [[SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 0}, ABSENT], PUBLIC] -> VALIDATED [[IndexName:{DescID: 104, Name: idx2, IndexID: 4}, ABSENT], PUBLIC] -> ABSENT ops: + *scop.MakeDroppedNonPrimaryIndexDeleteAndWriteOnly + IndexID: 4 + TableID: 104 + *scop.SetIndexName + IndexID: 4 + Name: crdb_internal_index_4_name_placeholder + TableID: 104 *scop.MakeDroppedColumnDeleteAndWriteOnly ColumnID: 4 TableID: 104 @@ -171,13 +161,6 @@ StatementPhase stage 1 of 1 with 5 MutationType ops ColumnID: 4 Name: crdb_internal_column_4_name_placeholder TableID: 104 - *scop.MakeDroppedNonPrimaryIndexDeleteAndWriteOnly - IndexID: 4 - TableID: 104 - *scop.SetIndexName - IndexID: 4 - Name: crdb_internal_index_4_name_placeholder - TableID: 104 PreCommitPhase stage 1 of 1 with 2 MutationType ops transitions: ops: @@ -191,12 +174,12 @@ PreCommitPhase stage 1 of 1 with 2 MutationType ops - 104 JobID: 1 NonCancelable: true - RunningStatus: PostCommitNonRevertiblePhase stage 1 of 2 with 4 MutationType ops pending + RunningStatus: PostCommitNonRevertiblePhase stage 1 of 2 with 2 MutationType ops pending Statements: - statement: DROP INDEX idx2 CASCADE redactedstatement: DROP INDEX ‹defaultdb›.public.‹t1›@‹idx2› CASCADE statementtag: DROP INDEX -PostCommitNonRevertiblePhase stage 1 of 2 with 6 MutationType ops +PostCommitNonRevertiblePhase stage 1 of 2 with 4 MutationType ops transitions: [[Column:{DescID: 104, ColumnID: 4}, ABSENT], WRITE_ONLY] -> DELETE_ONLY [[IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 4}, ABSENT], PUBLIC] -> ABSENT @@ -209,15 +192,6 @@ PostCommitNonRevertiblePhase stage 1 of 2 with 6 MutationType ops *scop.MakeDroppedIndexDeleteOnly IndexID: 4 TableID: 104 - *scop.RemoveColumnFromIndex - ColumnID: 4 - IndexID: 4 - TableID: 104 - *scop.RemoveColumnFromIndex - ColumnID: 3 - IndexID: 4 - Kind: 1 - TableID: 104 *scop.SetJobStateOnDescriptor DescriptorID: 104 *scop.UpdateSchemaChangerJob @@ -280,11 +254,15 @@ DROP INDEX idx2 CASCADE - from: [Column:{DescID: 104, ColumnID: 4}, WRITE_ONLY] to: [ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 104, ColumnID: 4}, WRITE_ONLY] to: [ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 4}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents +- from: [Column:{DescID: 104, ColumnID: 4}, WRITE_ONLY] + to: [IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 4}, ABSENT] + kind: Precedence + rule: column no longer public before dependents - from: [ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4}, ABSENT] to: [Column:{DescID: 104, ColumnID: 4}, ABSENT] kind: Precedence @@ -296,11 +274,15 @@ DROP INDEX idx2 CASCADE - from: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4}, ABSENT] to: [SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 0}, ABSENT] kind: Precedence - rules: [secondary index columns removed before removing the index; dependents removed before index] + rule: dependents removed before index +- from: [IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 4}, ABSENT] + to: [Column:{DescID: 104, ColumnID: 4}, ABSENT] + kind: Precedence + rule: dependents removed before column - from: [IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 4}, ABSENT] to: [SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 0}, ABSENT] kind: Precedence - rules: [secondary index columns removed before removing the index; dependents removed before index] + rule: dependents removed before index - from: [IndexName:{DescID: 104, Name: idx2, IndexID: 4}, ABSENT] to: [SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 0}, ABSENT] kind: Precedence @@ -308,31 +290,27 @@ DROP INDEX idx2 CASCADE - from: [SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 0}, ABSENT] to: [Column:{DescID: 104, ColumnID: 4}, ABSENT] kind: Precedence - rule: indexes containing columns reach absent before column -- from: [SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 0}, DELETE_ONLY] - to: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4}, ABSENT] - kind: Precedence - rule: secondary index in DELETE_ONLY before removing columns -- from: [SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 0}, DELETE_ONLY] - to: [IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 4}, ABSENT] + rule: indexes containing column reach absent before column +- from: [SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 0}, VALIDATED] + to: [Column:{DescID: 104, ColumnID: 4}, WRITE_ONLY] kind: Precedence - rule: secondary index in DELETE_ONLY before removing columns + rule: secondary indexes containing column as key reach write-only before column - from: [SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 0}, VALIDATED] to: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 0}, VALIDATED] to: [IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 4}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 0}, VALIDATED] to: [IndexName:{DescID: 104, Name: idx2, IndexID: 4}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 0}, VALIDATED] to: [SecondaryIndexPartial:{DescID: 104, IndexID: 4}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [SecondaryIndexPartial:{DescID: 104, IndexID: 4}, ABSENT] to: [SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 0}, ABSENT] kind: SameStagePrecedence @@ -348,6 +326,13 @@ StatementPhase stage 1 of 1 with 5 MutationType ops [[SecondaryIndex:{DescID: 104, IndexID: 6, ConstraintID: 0}, ABSENT], PUBLIC] -> VALIDATED [[IndexName:{DescID: 104, Name: idx3, IndexID: 6}, ABSENT], PUBLIC] -> ABSENT ops: + *scop.MakeDroppedNonPrimaryIndexDeleteAndWriteOnly + IndexID: 6 + TableID: 104 + *scop.SetIndexName + IndexID: 6 + Name: crdb_internal_index_6_name_placeholder + TableID: 104 *scop.MakeDroppedColumnDeleteAndWriteOnly ColumnID: 5 TableID: 104 @@ -371,13 +356,6 @@ StatementPhase stage 1 of 1 with 5 MutationType ops ColumnID: 5 Name: crdb_internal_column_5_name_placeholder TableID: 104 - *scop.MakeDroppedNonPrimaryIndexDeleteAndWriteOnly - IndexID: 6 - TableID: 104 - *scop.SetIndexName - IndexID: 6 - Name: crdb_internal_index_6_name_placeholder - TableID: 104 PreCommitPhase stage 1 of 1 with 2 MutationType ops transitions: ops: @@ -391,12 +369,12 @@ PreCommitPhase stage 1 of 1 with 2 MutationType ops - 104 JobID: 1 NonCancelable: true - RunningStatus: PostCommitNonRevertiblePhase stage 1 of 2 with 7 MutationType ops pending + RunningStatus: PostCommitNonRevertiblePhase stage 1 of 2 with 4 MutationType ops pending Statements: - statement: DROP INDEX idx3 CASCADE redactedstatement: DROP INDEX ‹defaultdb›.public.‹t1›@‹idx3› CASCADE statementtag: DROP INDEX -PostCommitNonRevertiblePhase stage 1 of 2 with 9 MutationType ops +PostCommitNonRevertiblePhase stage 1 of 2 with 6 MutationType ops transitions: [[Column:{DescID: 104, ColumnID: 5}, ABSENT], WRITE_ONLY] -> DELETE_ONLY [[IndexColumn:{DescID: 104, ColumnID: 5, IndexID: 6}, ABSENT], PUBLIC] -> ABSENT @@ -417,20 +395,6 @@ PostCommitNonRevertiblePhase stage 1 of 2 with 9 MutationType ops *scop.MakeDroppedIndexDeleteOnly IndexID: 6 TableID: 104 - *scop.RemoveColumnFromIndex - ColumnID: 5 - IndexID: 6 - TableID: 104 - *scop.RemoveColumnFromIndex - ColumnID: 1 - IndexID: 6 - Ordinal: 1 - TableID: 104 - *scop.RemoveColumnFromIndex - ColumnID: 3 - IndexID: 6 - Kind: 1 - TableID: 104 *scop.SetJobStateOnDescriptor DescriptorID: 104 *scop.UpdateSchemaChangerJob @@ -495,11 +459,15 @@ DROP INDEX idx3 CASCADE - from: [Column:{DescID: 104, ColumnID: 5}, WRITE_ONLY] to: [ColumnName:{DescID: 104, Name: crdb_internal_i_shard_16, ColumnID: 5}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 104, ColumnID: 5}, WRITE_ONLY] to: [ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 5}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents +- from: [Column:{DescID: 104, ColumnID: 5}, WRITE_ONLY] + to: [IndexColumn:{DescID: 104, ColumnID: 5, IndexID: 6}, ABSENT] + kind: Precedence + rule: column no longer public before dependents - from: [ColumnName:{DescID: 104, Name: crdb_internal_i_shard_16, ColumnID: 5}, ABSENT] to: [Column:{DescID: 104, ColumnID: 5}, ABSENT] kind: Precedence @@ -511,15 +479,19 @@ DROP INDEX idx3 CASCADE - from: [IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 6}, ABSENT] to: [SecondaryIndex:{DescID: 104, IndexID: 6, ConstraintID: 0}, ABSENT] kind: Precedence - rules: [secondary index columns removed before removing the index; dependents removed before index] + rule: dependents removed before index - from: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 6}, ABSENT] to: [SecondaryIndex:{DescID: 104, IndexID: 6, ConstraintID: 0}, ABSENT] kind: Precedence - rules: [secondary index columns removed before removing the index; dependents removed before index] + rule: dependents removed before index +- from: [IndexColumn:{DescID: 104, ColumnID: 5, IndexID: 6}, ABSENT] + to: [Column:{DescID: 104, ColumnID: 5}, ABSENT] + kind: Precedence + rule: dependents removed before column - from: [IndexColumn:{DescID: 104, ColumnID: 5, IndexID: 6}, ABSENT] to: [SecondaryIndex:{DescID: 104, IndexID: 6, ConstraintID: 0}, ABSENT] kind: Precedence - rules: [secondary index columns removed before removing the index; dependents removed before index] + rule: dependents removed before index - from: [IndexName:{DescID: 104, Name: idx3, IndexID: 6}, ABSENT] to: [SecondaryIndex:{DescID: 104, IndexID: 6, ConstraintID: 0}, ABSENT] kind: Precedence @@ -527,35 +499,27 @@ DROP INDEX idx3 CASCADE - from: [SecondaryIndex:{DescID: 104, IndexID: 6, ConstraintID: 0}, ABSENT] to: [Column:{DescID: 104, ColumnID: 5}, ABSENT] kind: Precedence - rule: indexes containing columns reach absent before column -- from: [SecondaryIndex:{DescID: 104, IndexID: 6, ConstraintID: 0}, DELETE_ONLY] - to: [IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 6}, ABSENT] - kind: Precedence - rule: secondary index in DELETE_ONLY before removing columns -- from: [SecondaryIndex:{DescID: 104, IndexID: 6, ConstraintID: 0}, DELETE_ONLY] - to: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 6}, ABSENT] - kind: Precedence - rule: secondary index in DELETE_ONLY before removing columns -- from: [SecondaryIndex:{DescID: 104, IndexID: 6, ConstraintID: 0}, DELETE_ONLY] - to: [IndexColumn:{DescID: 104, ColumnID: 5, IndexID: 6}, ABSENT] + rule: indexes containing column reach absent before column +- from: [SecondaryIndex:{DescID: 104, IndexID: 6, ConstraintID: 0}, VALIDATED] + to: [Column:{DescID: 104, ColumnID: 5}, WRITE_ONLY] kind: Precedence - rule: secondary index in DELETE_ONLY before removing columns + rule: secondary indexes containing column as key reach write-only before column - from: [SecondaryIndex:{DescID: 104, IndexID: 6, ConstraintID: 0}, VALIDATED] to: [IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 6}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [SecondaryIndex:{DescID: 104, IndexID: 6, ConstraintID: 0}, VALIDATED] to: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 6}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [SecondaryIndex:{DescID: 104, IndexID: 6, ConstraintID: 0}, VALIDATED] to: [IndexColumn:{DescID: 104, ColumnID: 5, IndexID: 6}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [SecondaryIndex:{DescID: 104, IndexID: 6, ConstraintID: 0}, VALIDATED] to: [IndexName:{DescID: 104, Name: idx3, IndexID: 6}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents ops DROP INDEX idx4 CASCADE @@ -596,12 +560,12 @@ PreCommitPhase stage 1 of 1 with 3 MutationType ops - 105 JobID: 1 NonCancelable: true - RunningStatus: PostCommitNonRevertiblePhase stage 1 of 2 with 7 MutationType ops pending + RunningStatus: PostCommitNonRevertiblePhase stage 1 of 2 with 5 MutationType ops pending Statements: - statement: DROP INDEX idx4 CASCADE redactedstatement: DROP INDEX ‹defaultdb›.public.‹t1›@‹idx4› CASCADE statementtag: DROP INDEX -PostCommitNonRevertiblePhase stage 1 of 2 with 10 MutationType ops +PostCommitNonRevertiblePhase stage 1 of 2 with 8 MutationType ops transitions: [[IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 8}, ABSENT], PUBLIC] -> ABSENT [[IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 8}, ABSENT], PUBLIC] -> ABSENT @@ -639,15 +603,6 @@ PostCommitNonRevertiblePhase stage 1 of 2 with 10 MutationType ops DescriptorID: 105 Name: v SchemaID: 101 - *scop.RemoveColumnFromIndex - ColumnID: 2 - IndexID: 8 - TableID: 104 - *scop.RemoveColumnFromIndex - ColumnID: 3 - IndexID: 8 - Kind: 1 - TableID: 104 *scop.SetJobStateOnDescriptor DescriptorID: 104 *scop.SetJobStateOnDescriptor @@ -759,27 +714,27 @@ DROP INDEX idx4 CASCADE - from: [Column:{DescID: 105, ColumnID: 1}, WRITE_ONLY] to: [ColumnName:{DescID: 105, Name: count, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 105, ColumnID: 1}, WRITE_ONLY] to: [ColumnType:{DescID: 105, ColumnFamilyID: 0, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 105, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnName:{DescID: 105, Name: tableoid, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 105, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnType:{DescID: 105, ColumnFamilyID: 0, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 105, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnName:{DescID: 105, Name: crdb_internal_mvcc_timestamp, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 105, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnType:{DescID: 105, ColumnFamilyID: 0, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [ColumnName:{DescID: 105, Name: count, ColumnID: 1}, ABSENT] to: [Column:{DescID: 105, ColumnID: 1}, ABSENT] kind: Precedence @@ -807,35 +762,27 @@ DROP INDEX idx4 CASCADE - from: [IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 8}, ABSENT] to: [SecondaryIndex:{DescID: 104, IndexID: 8, ConstraintID: 3}, ABSENT] kind: Precedence - rules: [secondary index columns removed before removing the index; dependents removed before index] + rule: dependents removed before index - from: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 8}, ABSENT] to: [SecondaryIndex:{DescID: 104, IndexID: 8, ConstraintID: 3}, ABSENT] kind: Precedence - rules: [secondary index columns removed before removing the index; dependents removed before index] + rule: dependents removed before index - from: [IndexName:{DescID: 104, Name: idx4, IndexID: 8}, ABSENT] to: [SecondaryIndex:{DescID: 104, IndexID: 8, ConstraintID: 3}, ABSENT] kind: Precedence rule: dependents removed before index -- from: [SecondaryIndex:{DescID: 104, IndexID: 8, ConstraintID: 3}, DELETE_ONLY] - to: [IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 8}, ABSENT] - kind: Precedence - rule: secondary index in DELETE_ONLY before removing columns -- from: [SecondaryIndex:{DescID: 104, IndexID: 8, ConstraintID: 3}, DELETE_ONLY] - to: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 8}, ABSENT] - kind: Precedence - rule: secondary index in DELETE_ONLY before removing columns - from: [SecondaryIndex:{DescID: 104, IndexID: 8, ConstraintID: 3}, VALIDATED] to: [IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 8}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [SecondaryIndex:{DescID: 104, IndexID: 8, ConstraintID: 3}, VALIDATED] to: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 8}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [SecondaryIndex:{DescID: 104, IndexID: 8, ConstraintID: 3}, VALIDATED] to: [IndexName:{DescID: 104, Name: idx4, IndexID: 8}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [View:{DescID: 105}, ABSENT] to: [Column:{DescID: 105, ColumnID: 1}, ABSENT] kind: SameStagePrecedence diff --git a/pkg/sql/schemachanger/scplan/testdata/drop_schema b/pkg/sql/schemachanger/scplan/testdata/drop_schema index 98e18c40dbb2..afa31b2c2c72 100644 --- a/pkg/sql/schemachanger/scplan/testdata/drop_schema +++ b/pkg/sql/schemachanger/scplan/testdata/drop_schema @@ -42,203 +42,223 @@ DROP SCHEMA defaultdb.SC1 CASCADE - from: [Column:{DescID: 106, ColumnID: 1}, WRITE_ONLY] to: [ColumnName:{DescID: 106, Name: id, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 106, ColumnID: 1}, WRITE_ONLY] to: [ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents +- from: [Column:{DescID: 106, ColumnID: 1}, WRITE_ONLY] + to: [IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 1}, ABSENT] + kind: Precedence + rule: column no longer public before dependents - from: [Column:{DescID: 106, ColumnID: 2}, WRITE_ONLY] to: [ColumnName:{DescID: 106, Name: name, ColumnID: 2}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 106, ColumnID: 2}, WRITE_ONLY] to: [ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 2}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents +- from: [Column:{DescID: 106, ColumnID: 2}, WRITE_ONLY] + to: [IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 1}, ABSENT] + kind: Precedence + rule: column no longer public before dependents +- from: [Column:{DescID: 106, ColumnID: 3}, WRITE_ONLY] + to: [ColumnDefaultExpression:{DescID: 106, ColumnID: 3}, ABSENT] + kind: Precedence + rule: column no longer public before dependents - from: [Column:{DescID: 106, ColumnID: 3}, WRITE_ONLY] to: [ColumnName:{DescID: 106, Name: val, ColumnID: 3}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 106, ColumnID: 3}, WRITE_ONLY] to: [ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 3}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents +- from: [Column:{DescID: 106, ColumnID: 3}, WRITE_ONLY] + to: [IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 1}, ABSENT] + kind: Precedence + rule: column no longer public before dependents - from: [Column:{DescID: 106, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnName:{DescID: 106, Name: tableoid, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 106, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 106, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnName:{DescID: 106, Name: crdb_internal_mvcc_timestamp, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 106, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 107, ColumnID: 1}, WRITE_ONLY] to: [ColumnName:{DescID: 107, Name: name, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 107, ColumnID: 1}, WRITE_ONLY] to: [ColumnType:{DescID: 107, ColumnFamilyID: 0, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 107, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnName:{DescID: 107, Name: tableoid, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 107, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnType:{DescID: 107, ColumnFamilyID: 0, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 107, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnName:{DescID: 107, Name: crdb_internal_mvcc_timestamp, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 107, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnType:{DescID: 107, ColumnFamilyID: 0, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 108, ColumnID: 1}, WRITE_ONLY] to: [ColumnName:{DescID: 108, Name: n1, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 108, ColumnID: 1}, WRITE_ONLY] to: [ColumnType:{DescID: 108, ColumnFamilyID: 0, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 108, ColumnID: 2}, WRITE_ONLY] to: [ColumnName:{DescID: 108, Name: n2, ColumnID: 2}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 108, ColumnID: 2}, WRITE_ONLY] to: [ColumnType:{DescID: 108, ColumnFamilyID: 0, ColumnID: 2}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 108, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnName:{DescID: 108, Name: tableoid, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 108, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnType:{DescID: 108, ColumnFamilyID: 0, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 108, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnName:{DescID: 108, Name: crdb_internal_mvcc_timestamp, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 108, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnType:{DescID: 108, ColumnFamilyID: 0, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 109, ColumnID: 1}, WRITE_ONLY] to: [ColumnName:{DescID: 109, Name: name, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 109, ColumnID: 1}, WRITE_ONLY] to: [ColumnType:{DescID: 109, ColumnFamilyID: 0, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 109, ColumnID: 2}, WRITE_ONLY] to: [ColumnName:{DescID: 109, Name: n1, ColumnID: 2}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 109, ColumnID: 2}, WRITE_ONLY] to: [ColumnType:{DescID: 109, ColumnFamilyID: 0, ColumnID: 2}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 109, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnName:{DescID: 109, Name: tableoid, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 109, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnType:{DescID: 109, ColumnFamilyID: 0, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 109, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnName:{DescID: 109, Name: crdb_internal_mvcc_timestamp, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 109, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnType:{DescID: 109, ColumnFamilyID: 0, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 110, ColumnID: 1}, WRITE_ONLY] to: [ColumnName:{DescID: 110, Name: n2, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 110, ColumnID: 1}, WRITE_ONLY] to: [ColumnType:{DescID: 110, ColumnFamilyID: 0, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 110, ColumnID: 2}, WRITE_ONLY] to: [ColumnName:{DescID: 110, Name: n1, ColumnID: 2}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 110, ColumnID: 2}, WRITE_ONLY] to: [ColumnType:{DescID: 110, ColumnFamilyID: 0, ColumnID: 2}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 110, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnName:{DescID: 110, Name: tableoid, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 110, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnType:{DescID: 110, ColumnFamilyID: 0, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 110, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnName:{DescID: 110, Name: crdb_internal_mvcc_timestamp, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 110, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnType:{DescID: 110, ColumnFamilyID: 0, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 113, ColumnID: 1}, WRITE_ONLY] to: [ColumnName:{DescID: 113, Name: k, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 113, ColumnID: 1}, WRITE_ONLY] to: [ColumnType:{DescID: 113, ColumnFamilyID: 0, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 113, ColumnID: 2}, WRITE_ONLY] to: [ColumnName:{DescID: 113, Name: n2, ColumnID: 2}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 113, ColumnID: 2}, WRITE_ONLY] to: [ColumnType:{DescID: 113, ColumnFamilyID: 0, ColumnID: 2}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 113, ColumnID: 3}, WRITE_ONLY] to: [ColumnName:{DescID: 113, Name: n1, ColumnID: 3}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 113, ColumnID: 3}, WRITE_ONLY] to: [ColumnType:{DescID: 113, ColumnFamilyID: 0, ColumnID: 3}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 113, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnName:{DescID: 113, Name: tableoid, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 113, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnType:{DescID: 113, ColumnFamilyID: 0, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 113, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnName:{DescID: 113, Name: crdb_internal_mvcc_timestamp, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 113, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnType:{DescID: 113, ColumnFamilyID: 0, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents +- from: [ColumnDefaultExpression:{DescID: 106, ColumnID: 3}, ABSENT] + to: [Column:{DescID: 106, ColumnID: 3}, ABSENT] + kind: Precedence + rule: dependents removed before column - from: [ColumnDefaultExpression:{DescID: 106, ColumnID: 3}, ABSENT] to: [ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 3}, ABSENT] kind: SameStagePrecedence @@ -471,14 +491,26 @@ DROP SCHEMA defaultdb.SC1 CASCADE to: [UserPrivileges:{DescID: 111, Name: root}, ABSENT] kind: SameStagePrecedence rule: descriptor drop right before dependent element removal +- from: [IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 1}, ABSENT] + to: [Column:{DescID: 106, ColumnID: 1}, ABSENT] + kind: Precedence + rule: dependents removed before column - from: [IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 1}, ABSENT] to: [PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1}, ABSENT] kind: Precedence rule: dependents removed before index +- from: [IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 1}, ABSENT] + to: [Column:{DescID: 106, ColumnID: 2}, ABSENT] + kind: Precedence + rule: dependents removed before column - from: [IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 1}, ABSENT] to: [PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1}, ABSENT] kind: Precedence rule: dependents removed before index +- from: [IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 1}, ABSENT] + to: [Column:{DescID: 106, ColumnID: 3}, ABSENT] + kind: Precedence + rule: dependents removed before column - from: [IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 1}, ABSENT] to: [PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1}, ABSENT] kind: Precedence @@ -490,19 +522,19 @@ DROP SCHEMA defaultdb.SC1 CASCADE - from: [PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1}, VALIDATED] to: [IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 1}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1}, VALIDATED] to: [IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 1}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1}, VALIDATED] to: [IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 1}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1}, VALIDATED] to: [IndexName:{DescID: 106, Name: t1_pkey, IndexID: 1}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [Schema:{DescID: 104}, DROPPED] to: [Namespace:{DescID: 104, Name: sc1, ReferencedDescID: 100}, ABSENT] kind: SameStagePrecedence diff --git a/pkg/sql/schemachanger/scplan/testdata/drop_table b/pkg/sql/schemachanger/scplan/testdata/drop_table index ac529b561dcd..25fc1d81e5c1 100644 --- a/pkg/sql/schemachanger/scplan/testdata/drop_table +++ b/pkg/sql/schemachanger/scplan/testdata/drop_table @@ -183,24 +183,6 @@ PostCommitNonRevertiblePhase stage 1 of 2 with 32 MutationType ops [[ColumnName:{DescID: 111, Name: tableoid, ColumnID: 4294967294}, ABSENT], PUBLIC] -> ABSENT [[ColumnType:{DescID: 111, ColumnFamilyID: 0, ColumnID: 4294967294}, ABSENT], PUBLIC] -> ABSENT ops: - *scop.MarkDescriptorAsDropped - DescID: 111 - *scop.RemoveViewBackReferencesInRelations - BackReferencedViewID: 111 - RelationIDs: - - 109 - *scop.RemoveAllTableComments - TableID: 111 - *scop.MarkDescriptorAsDropped - DescID: 110 - *scop.RemoveAllTableComments - TableID: 110 - *scop.DrainDescriptorName - Namespace: - DatabaseID: 100 - DescriptorID: 111 - Name: v1 - SchemaID: 101 *scop.MarkDescriptorAsDropped DescID: 109 *scop.RemoveAllTableComments @@ -208,12 +190,6 @@ PostCommitNonRevertiblePhase stage 1 of 2 with 32 MutationType ops *scop.RemoveColumnDefaultExpression ColumnID: 1 TableID: 109 - *scop.RemoveSequenceOwner - ColumnID: 2 - OwnedSequenceID: 110 - TableID: 109 - *scop.RemoveOwnerBackReferenceInSequence - SequenceID: 110 *scop.RemoveDroppedColumnType ColumnID: 3 TableID: 109 @@ -252,6 +228,30 @@ PostCommitNonRevertiblePhase stage 1 of 2 with 32 MutationType ops *scop.RemoveForeignKeyConstraint ConstraintID: 3 TableID: 109 + *scop.MarkDescriptorAsDropped + DescID: 110 + *scop.RemoveAllTableComments + TableID: 110 + *scop.MarkDescriptorAsDropped + DescID: 111 + *scop.RemoveViewBackReferencesInRelations + BackReferencedViewID: 111 + RelationIDs: + - 109 + *scop.RemoveAllTableComments + TableID: 111 + *scop.DrainDescriptorName + Namespace: + DatabaseID: 100 + DescriptorID: 109 + Name: shipments + SchemaID: 101 + *scop.RemoveSequenceOwner + ColumnID: 2 + OwnedSequenceID: 110 + TableID: 109 + *scop.RemoveOwnerBackReferenceInSequence + SequenceID: 110 *scop.DrainDescriptorName Namespace: DatabaseID: 100 @@ -261,8 +261,8 @@ PostCommitNonRevertiblePhase stage 1 of 2 with 32 MutationType ops *scop.DrainDescriptorName Namespace: DatabaseID: 100 - DescriptorID: 109 - Name: shipments + DescriptorID: 111 + Name: v1 SchemaID: 101 *scop.SetJobStateOnDescriptor DescriptorID: 104 @@ -513,103 +513,155 @@ DROP TABLE defaultdb.shipments CASCADE; - from: [Column:{DescID: 109, ColumnID: 1}, WRITE_ONLY] to: [ColumnComment:{DescID: 109, ColumnID: 1, Comment: tracking_number is a must}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents +- from: [Column:{DescID: 109, ColumnID: 1}, WRITE_ONLY] + to: [ColumnDefaultExpression:{DescID: 109, ColumnID: 1}, ABSENT] + kind: Precedence + rule: column no longer public before dependents - from: [Column:{DescID: 109, ColumnID: 1}, WRITE_ONLY] to: [ColumnName:{DescID: 109, Name: tracking_number, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 109, ColumnID: 1}, WRITE_ONLY] to: [ColumnType:{DescID: 109, ColumnFamilyID: 0, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents +- from: [Column:{DescID: 109, ColumnID: 1}, WRITE_ONLY] + to: [IndexColumn:{DescID: 109, ColumnID: 1, IndexID: 1}, ABSENT] + kind: Precedence + rule: column no longer public before dependents +- from: [Column:{DescID: 109, ColumnID: 1}, WRITE_ONLY] + to: [IndexColumn:{DescID: 109, ColumnID: 1, IndexID: 2}, ABSENT] + kind: Precedence + rule: column no longer public before dependents - from: [Column:{DescID: 109, ColumnID: 2}, WRITE_ONLY] to: [ColumnName:{DescID: 109, Name: carrier, ColumnID: 2}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 109, ColumnID: 2}, WRITE_ONLY] to: [ColumnType:{DescID: 109, ColumnFamilyID: 0, ColumnID: 2}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents +- from: [Column:{DescID: 109, ColumnID: 2}, WRITE_ONLY] + to: [IndexColumn:{DescID: 109, ColumnID: 2, IndexID: 1}, ABSENT] + kind: Precedence + rule: column no longer public before dependents +- from: [Column:{DescID: 109, ColumnID: 2}, WRITE_ONLY] + to: [SequenceOwner:{DescID: 109, ColumnID: 2, ReferencedDescID: 110}, ABSENT] + kind: Precedence + rule: column no longer public before dependents - from: [Column:{DescID: 109, ColumnID: 3}, WRITE_ONLY] to: [ColumnName:{DescID: 109, Name: status, ColumnID: 3}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 109, ColumnID: 3}, WRITE_ONLY] to: [ColumnType:{DescID: 109, ColumnFamilyID: 0, ColumnID: 3}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents +- from: [Column:{DescID: 109, ColumnID: 3}, WRITE_ONLY] + to: [IndexColumn:{DescID: 109, ColumnID: 3, IndexID: 1}, ABSENT] + kind: Precedence + rule: column no longer public before dependents +- from: [Column:{DescID: 109, ColumnID: 3}, WRITE_ONLY] + to: [IndexColumn:{DescID: 109, ColumnID: 3, IndexID: 2}, ABSENT] + kind: Precedence + rule: column no longer public before dependents - from: [Column:{DescID: 109, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnName:{DescID: 109, Name: tableoid, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 109, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnType:{DescID: 109, ColumnFamilyID: 0, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 109, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnName:{DescID: 109, Name: crdb_internal_mvcc_timestamp, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 109, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnType:{DescID: 109, ColumnFamilyID: 0, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 109, ColumnID: 4}, WRITE_ONLY] to: [ColumnName:{DescID: 109, Name: customer_id, ColumnID: 4}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 109, ColumnID: 4}, WRITE_ONLY] to: [ColumnType:{DescID: 109, ColumnFamilyID: 0, ColumnID: 4}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents +- from: [Column:{DescID: 109, ColumnID: 4}, WRITE_ONLY] + to: [IndexColumn:{DescID: 109, ColumnID: 4, IndexID: 1}, ABSENT] + kind: Precedence + rule: column no longer public before dependents +- from: [Column:{DescID: 109, ColumnID: 4}, WRITE_ONLY] + to: [IndexColumn:{DescID: 109, ColumnID: 4, IndexID: 2}, ABSENT] + kind: Precedence + rule: column no longer public before dependents +- from: [Column:{DescID: 109, ColumnID: 5}, WRITE_ONLY] + to: [ColumnDefaultExpression:{DescID: 109, ColumnID: 5}, ABSENT] + kind: Precedence + rule: column no longer public before dependents - from: [Column:{DescID: 109, ColumnID: 5}, WRITE_ONLY] to: [ColumnName:{DescID: 109, Name: randcol, ColumnID: 5}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 109, ColumnID: 5}, WRITE_ONLY] to: [ColumnType:{DescID: 109, ColumnFamilyID: 0, ColumnID: 5}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents +- from: [Column:{DescID: 109, ColumnID: 5}, WRITE_ONLY] + to: [IndexColumn:{DescID: 109, ColumnID: 5, IndexID: 1}, ABSENT] + kind: Precedence + rule: column no longer public before dependents - from: [Column:{DescID: 111, ColumnID: 1}, WRITE_ONLY] to: [ColumnName:{DescID: 111, Name: customer_id, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 111, ColumnID: 1}, WRITE_ONLY] to: [ColumnType:{DescID: 111, ColumnFamilyID: 0, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 111, ColumnID: 2}, WRITE_ONLY] to: [ColumnName:{DescID: 111, Name: carrier, ColumnID: 2}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 111, ColumnID: 2}, WRITE_ONLY] to: [ColumnType:{DescID: 111, ColumnFamilyID: 0, ColumnID: 2}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 111, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnName:{DescID: 111, Name: tableoid, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 111, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnType:{DescID: 111, ColumnFamilyID: 0, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 111, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnName:{DescID: 111, Name: crdb_internal_mvcc_timestamp, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 111, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnType:{DescID: 111, ColumnFamilyID: 0, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [ColumnComment:{DescID: 109, ColumnID: 1, Comment: tracking_number is a must}, ABSENT] to: [Column:{DescID: 109, ColumnID: 1}, ABSENT] kind: Precedence rule: dependents removed before column +- from: [ColumnDefaultExpression:{DescID: 109, ColumnID: 1}, ABSENT] + to: [Column:{DescID: 109, ColumnID: 1}, ABSENT] + kind: Precedence + rule: dependents removed before column - from: [ColumnDefaultExpression:{DescID: 109, ColumnID: 1}, ABSENT] to: [ColumnType:{DescID: 109, ColumnFamilyID: 0, ColumnID: 1}, ABSENT] kind: SameStagePrecedence rule: column type dependents removed right before column type +- from: [ColumnDefaultExpression:{DescID: 109, ColumnID: 5}, ABSENT] + to: [Column:{DescID: 109, ColumnID: 5}, ABSENT] + kind: Precedence + rule: dependents removed before column - from: [ColumnDefaultExpression:{DescID: 109, ColumnID: 5}, ABSENT] to: [ColumnType:{DescID: 109, ColumnFamilyID: 0, ColumnID: 5}, ABSENT] kind: SameStagePrecedence @@ -702,34 +754,66 @@ DROP TABLE defaultdb.shipments CASCADE; to: [Column:{DescID: 111, ColumnID: 4294967295}, ABSENT] kind: Precedence rule: dependents removed before column +- from: [IndexColumn:{DescID: 109, ColumnID: 1, IndexID: 1}, ABSENT] + to: [Column:{DescID: 109, ColumnID: 1}, ABSENT] + kind: Precedence + rule: dependents removed before column - from: [IndexColumn:{DescID: 109, ColumnID: 1, IndexID: 1}, ABSENT] to: [PrimaryIndex:{DescID: 109, IndexID: 1, ConstraintID: 1}, ABSENT] kind: Precedence rule: dependents removed before index +- from: [IndexColumn:{DescID: 109, ColumnID: 1, IndexID: 2}, ABSENT] + to: [Column:{DescID: 109, ColumnID: 1}, ABSENT] + kind: Precedence + rule: dependents removed before column - from: [IndexColumn:{DescID: 109, ColumnID: 1, IndexID: 2}, ABSENT] to: [SecondaryIndex:{DescID: 109, IndexID: 2, ConstraintID: 0}, ABSENT] kind: Precedence - rules: [secondary index columns removed before removing the index; dependents removed before index] + rule: dependents removed before index +- from: [IndexColumn:{DescID: 109, ColumnID: 2, IndexID: 1}, ABSENT] + to: [Column:{DescID: 109, ColumnID: 2}, ABSENT] + kind: Precedence + rule: dependents removed before column - from: [IndexColumn:{DescID: 109, ColumnID: 2, IndexID: 1}, ABSENT] to: [PrimaryIndex:{DescID: 109, IndexID: 1, ConstraintID: 1}, ABSENT] kind: Precedence rule: dependents removed before index +- from: [IndexColumn:{DescID: 109, ColumnID: 3, IndexID: 1}, ABSENT] + to: [Column:{DescID: 109, ColumnID: 3}, ABSENT] + kind: Precedence + rule: dependents removed before column - from: [IndexColumn:{DescID: 109, ColumnID: 3, IndexID: 1}, ABSENT] to: [PrimaryIndex:{DescID: 109, IndexID: 1, ConstraintID: 1}, ABSENT] kind: Precedence rule: dependents removed before index +- from: [IndexColumn:{DescID: 109, ColumnID: 3, IndexID: 2}, ABSENT] + to: [Column:{DescID: 109, ColumnID: 3}, ABSENT] + kind: Precedence + rule: dependents removed before column - from: [IndexColumn:{DescID: 109, ColumnID: 3, IndexID: 2}, ABSENT] to: [SecondaryIndex:{DescID: 109, IndexID: 2, ConstraintID: 0}, ABSENT] kind: Precedence - rules: [secondary index columns removed before removing the index; dependents removed before index] + rule: dependents removed before index +- from: [IndexColumn:{DescID: 109, ColumnID: 4, IndexID: 1}, ABSENT] + to: [Column:{DescID: 109, ColumnID: 4}, ABSENT] + kind: Precedence + rule: dependents removed before column - from: [IndexColumn:{DescID: 109, ColumnID: 4, IndexID: 1}, ABSENT] to: [PrimaryIndex:{DescID: 109, IndexID: 1, ConstraintID: 1}, ABSENT] kind: Precedence rule: dependents removed before index +- from: [IndexColumn:{DescID: 109, ColumnID: 4, IndexID: 2}, ABSENT] + to: [Column:{DescID: 109, ColumnID: 4}, ABSENT] + kind: Precedence + rule: dependents removed before column - from: [IndexColumn:{DescID: 109, ColumnID: 4, IndexID: 2}, ABSENT] to: [SecondaryIndex:{DescID: 109, IndexID: 2, ConstraintID: 0}, ABSENT] kind: Precedence - rules: [secondary index columns removed before removing the index; dependents removed before index] + rule: dependents removed before index +- from: [IndexColumn:{DescID: 109, ColumnID: 5, IndexID: 1}, ABSENT] + to: [Column:{DescID: 109, ColumnID: 5}, ABSENT] + kind: Precedence + rule: dependents removed before column - from: [IndexColumn:{DescID: 109, ColumnID: 5, IndexID: 1}, ABSENT] to: [PrimaryIndex:{DescID: 109, IndexID: 1, ConstraintID: 1}, ABSENT] kind: Precedence @@ -749,63 +833,51 @@ DROP TABLE defaultdb.shipments CASCADE; - from: [PrimaryIndex:{DescID: 109, IndexID: 1, ConstraintID: 1}, VALIDATED] to: [IndexColumn:{DescID: 109, ColumnID: 1, IndexID: 1}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [PrimaryIndex:{DescID: 109, IndexID: 1, ConstraintID: 1}, VALIDATED] to: [IndexColumn:{DescID: 109, ColumnID: 2, IndexID: 1}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [PrimaryIndex:{DescID: 109, IndexID: 1, ConstraintID: 1}, VALIDATED] to: [IndexColumn:{DescID: 109, ColumnID: 3, IndexID: 1}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [PrimaryIndex:{DescID: 109, IndexID: 1, ConstraintID: 1}, VALIDATED] to: [IndexColumn:{DescID: 109, ColumnID: 4, IndexID: 1}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [PrimaryIndex:{DescID: 109, IndexID: 1, ConstraintID: 1}, VALIDATED] to: [IndexColumn:{DescID: 109, ColumnID: 5, IndexID: 1}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [PrimaryIndex:{DescID: 109, IndexID: 1, ConstraintID: 1}, VALIDATED] to: [IndexComment:{DescID: 109, IndexID: 1, Comment: pkey is good}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [PrimaryIndex:{DescID: 109, IndexID: 1, ConstraintID: 1}, VALIDATED] to: [IndexName:{DescID: 109, Name: shipments_pkey, IndexID: 1}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed -- from: [SecondaryIndex:{DescID: 109, IndexID: 2, ConstraintID: 0}, DELETE_ONLY] - to: [IndexColumn:{DescID: 109, ColumnID: 1, IndexID: 2}, ABSENT] - kind: Precedence - rule: secondary index in DELETE_ONLY before removing columns -- from: [SecondaryIndex:{DescID: 109, IndexID: 2, ConstraintID: 0}, DELETE_ONLY] - to: [IndexColumn:{DescID: 109, ColumnID: 3, IndexID: 2}, ABSENT] - kind: Precedence - rule: secondary index in DELETE_ONLY before removing columns -- from: [SecondaryIndex:{DescID: 109, IndexID: 2, ConstraintID: 0}, DELETE_ONLY] - to: [IndexColumn:{DescID: 109, ColumnID: 4, IndexID: 2}, ABSENT] - kind: Precedence - rule: secondary index in DELETE_ONLY before removing columns + rule: index no longer public before dependents - from: [SecondaryIndex:{DescID: 109, IndexID: 2, ConstraintID: 0}, VALIDATED] to: [IndexColumn:{DescID: 109, ColumnID: 1, IndexID: 2}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [SecondaryIndex:{DescID: 109, IndexID: 2, ConstraintID: 0}, VALIDATED] to: [IndexColumn:{DescID: 109, ColumnID: 3, IndexID: 2}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [SecondaryIndex:{DescID: 109, IndexID: 2, ConstraintID: 0}, VALIDATED] to: [IndexColumn:{DescID: 109, ColumnID: 4, IndexID: 2}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [SecondaryIndex:{DescID: 109, IndexID: 2, ConstraintID: 0}, VALIDATED] to: [IndexName:{DescID: 109, Name: partialidx, IndexID: 2}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [SecondaryIndex:{DescID: 109, IndexID: 2, ConstraintID: 0}, VALIDATED] to: [SecondaryIndexPartial:{DescID: 109, IndexID: 2}, ABSENT] kind: Precedence - rule: index no longer public before dependents removed + rule: index no longer public before dependents - from: [SecondaryIndexPartial:{DescID: 109, IndexID: 2}, ABSENT] to: [SecondaryIndex:{DescID: 109, IndexID: 2, ConstraintID: 0}, ABSENT] kind: Precedence @@ -834,6 +906,10 @@ DROP TABLE defaultdb.shipments CASCADE; to: [UserPrivileges:{DescID: 110, Name: root}, ABSENT] kind: SameStagePrecedence rule: descriptor drop right before dependent element removal +- from: [SequenceOwner:{DescID: 109, ColumnID: 2, ReferencedDescID: 110}, ABSENT] + to: [Column:{DescID: 109, ColumnID: 2}, ABSENT] + kind: Precedence + rule: dependents removed before column - from: [SequenceOwner:{DescID: 109, ColumnID: 2, ReferencedDescID: 110}, ABSENT] to: [ColumnType:{DescID: 109, ColumnFamilyID: 0, ColumnID: 2}, ABSENT] kind: SameStagePrecedence diff --git a/pkg/sql/schemachanger/scplan/testdata/drop_view b/pkg/sql/schemachanger/scplan/testdata/drop_view index 7a7124b25e83..97afffea117a 100644 --- a/pkg/sql/schemachanger/scplan/testdata/drop_view +++ b/pkg/sql/schemachanger/scplan/testdata/drop_view @@ -154,27 +154,27 @@ DROP VIEW defaultdb.v1 - from: [Column:{DescID: 105, ColumnID: 1}, WRITE_ONLY] to: [ColumnName:{DescID: 105, Name: name, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 105, ColumnID: 1}, WRITE_ONLY] to: [ColumnType:{DescID: 105, ColumnFamilyID: 0, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 105, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnName:{DescID: 105, Name: tableoid, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 105, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnType:{DescID: 105, ColumnFamilyID: 0, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 105, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnName:{DescID: 105, Name: crdb_internal_mvcc_timestamp, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 105, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnType:{DescID: 105, ColumnFamilyID: 0, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [ColumnName:{DescID: 105, Name: crdb_internal_mvcc_timestamp, ColumnID: 4294967295}, ABSENT] to: [Column:{DescID: 105, ColumnID: 4294967295}, ABSENT] kind: Precedence @@ -942,163 +942,163 @@ DROP VIEW defaultdb.v1 CASCADE - from: [Column:{DescID: 105, ColumnID: 1}, WRITE_ONLY] to: [ColumnName:{DescID: 105, Name: name, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 105, ColumnID: 1}, WRITE_ONLY] to: [ColumnType:{DescID: 105, ColumnFamilyID: 0, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 105, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnName:{DescID: 105, Name: tableoid, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 105, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnType:{DescID: 105, ColumnFamilyID: 0, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 105, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnName:{DescID: 105, Name: crdb_internal_mvcc_timestamp, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 105, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnType:{DescID: 105, ColumnFamilyID: 0, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 106, ColumnID: 1}, WRITE_ONLY] to: [ColumnName:{DescID: 106, Name: n1, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 106, ColumnID: 1}, WRITE_ONLY] to: [ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 106, ColumnID: 2}, WRITE_ONLY] to: [ColumnName:{DescID: 106, Name: n2, ColumnID: 2}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 106, ColumnID: 2}, WRITE_ONLY] to: [ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 2}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 106, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnName:{DescID: 106, Name: tableoid, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 106, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 106, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnName:{DescID: 106, Name: crdb_internal_mvcc_timestamp, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 106, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 107, ColumnID: 1}, WRITE_ONLY] to: [ColumnName:{DescID: 107, Name: name, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 107, ColumnID: 1}, WRITE_ONLY] to: [ColumnType:{DescID: 107, ColumnFamilyID: 0, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 107, ColumnID: 2}, WRITE_ONLY] to: [ColumnName:{DescID: 107, Name: n1, ColumnID: 2}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 107, ColumnID: 2}, WRITE_ONLY] to: [ColumnType:{DescID: 107, ColumnFamilyID: 0, ColumnID: 2}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 107, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnName:{DescID: 107, Name: tableoid, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 107, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnType:{DescID: 107, ColumnFamilyID: 0, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 107, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnName:{DescID: 107, Name: crdb_internal_mvcc_timestamp, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 107, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnType:{DescID: 107, ColumnFamilyID: 0, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 108, ColumnID: 1}, WRITE_ONLY] to: [ColumnName:{DescID: 108, Name: n2, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 108, ColumnID: 1}, WRITE_ONLY] to: [ColumnType:{DescID: 108, ColumnFamilyID: 0, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 108, ColumnID: 2}, WRITE_ONLY] to: [ColumnName:{DescID: 108, Name: n1, ColumnID: 2}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 108, ColumnID: 2}, WRITE_ONLY] to: [ColumnType:{DescID: 108, ColumnFamilyID: 0, ColumnID: 2}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 108, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnName:{DescID: 108, Name: tableoid, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 108, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnType:{DescID: 108, ColumnFamilyID: 0, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 108, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnName:{DescID: 108, Name: crdb_internal_mvcc_timestamp, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 108, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnType:{DescID: 108, ColumnFamilyID: 0, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 111, ColumnID: 1}, WRITE_ONLY] to: [ColumnName:{DescID: 111, Name: k, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 111, ColumnID: 1}, WRITE_ONLY] to: [ColumnType:{DescID: 111, ColumnFamilyID: 0, ColumnID: 1}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 111, ColumnID: 2}, WRITE_ONLY] to: [ColumnName:{DescID: 111, Name: n2, ColumnID: 2}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 111, ColumnID: 2}, WRITE_ONLY] to: [ColumnType:{DescID: 111, ColumnFamilyID: 0, ColumnID: 2}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 111, ColumnID: 3}, WRITE_ONLY] to: [ColumnName:{DescID: 111, Name: n1, ColumnID: 3}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 111, ColumnID: 3}, WRITE_ONLY] to: [ColumnType:{DescID: 111, ColumnFamilyID: 0, ColumnID: 3}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 111, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnName:{DescID: 111, Name: tableoid, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 111, ColumnID: 4294967294}, WRITE_ONLY] to: [ColumnType:{DescID: 111, ColumnFamilyID: 0, ColumnID: 4294967294}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 111, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnName:{DescID: 111, Name: crdb_internal_mvcc_timestamp, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [Column:{DescID: 111, ColumnID: 4294967295}, WRITE_ONLY] to: [ColumnType:{DescID: 111, ColumnFamilyID: 0, ColumnID: 4294967295}, ABSENT] kind: Precedence - rule: column dependents removed after column no longer public + rule: column no longer public before dependents - from: [ColumnName:{DescID: 105, Name: crdb_internal_mvcc_timestamp, ColumnID: 4294967295}, ABSENT] to: [Column:{DescID: 105, ColumnID: 4294967295}, ABSENT] kind: Precedence diff --git a/pkg/sql/schemachanger/screl/walk.go b/pkg/sql/schemachanger/screl/walk.go index fca627767d33..43754e4ac8c5 100644 --- a/pkg/sql/schemachanger/screl/walk.go +++ b/pkg/sql/schemachanger/screl/walk.go @@ -42,6 +42,13 @@ func WalkExpressions(e scpb.Element, f func(t *catpb.Expression) error) error { }) } +// WalkColumnIDs calls f for every catid.ColumnID field in e. +func WalkColumnIDs(e scpb.Element, f func(id *catid.ColumnID) error) error { + return walk(reflect.TypeOf((*catid.ColumnID)(nil)), e, func(i interface{}) error { + return f(i.(*catid.ColumnID)) + }) +} + // walk will use reflection to find all values which are either scalars // types or pointers types and pass them to f as pointers. The // expectation is that the input is a pointer to some structure so that diff --git a/pkg/sql/schemachanger/testdata/end_to_end/add_column b/pkg/sql/schemachanger/testdata/end_to_end/add_column index a752a391828a..3560c9024fbe 100644 --- a/pkg/sql/schemachanger/testdata/end_to_end/add_column +++ b/pkg/sql/schemachanger/testdata/end_to_end/add_column @@ -278,7 +278,7 @@ begin transaction #9 validate forward indexes [2] in table #106 commit transaction #9 begin transaction #10 -## PostCommitNonRevertiblePhase stage 1 of 3 with 10 MutationType ops +## PostCommitNonRevertiblePhase stage 1 of 3 with 9 MutationType ops upsert descriptor #106 ... oid: 20 @@ -404,11 +404,11 @@ upsert descriptor #106 - version: "6" + version: "7" adding table for stats refresh: 106 -update progress of schema change job #1: "PostCommitNonRevertiblePhase stage 2 of 3 with 1 MutationType op pending" +update progress of schema change job #1: "PostCommitNonRevertiblePhase stage 2 of 3 with 3 MutationType ops pending" set schema change job #1 to non-cancellable commit transaction #10 begin transaction #11 -## PostCommitNonRevertiblePhase stage 2 of 3 with 3 MutationType ops +## PostCommitNonRevertiblePhase stage 2 of 3 with 5 MutationType ops upsert descriptor #106 ... formatVersion: 3 @@ -418,6 +418,36 @@ upsert descriptor #106 + modificationTime: {} mutations: - direction: DROP + index: + - constraintId: 3 + - createdExplicitly: true + - encodingType: 1 + - foreignKey: {} + - geoConfig: {} + - id: 3 + - interleave: {} + - keyColumnDirections: + - - ASC + - keyColumnIds: + - - 1 + - keyColumnNames: + - - i + - name: crdb_internal_index_3_name_placeholder + - partitioning: {} + - sharded: {} + - storeColumnIds: + - - 2 + - storeColumnNames: + - - j + - unique: true + - useDeletePreservingEncoding: true + - version: 4 + - mutationId: 1 + - state: DELETE_ONLY + - - direction: DROP + - index: + constraintId: 1 + createdAtNanos: "1640995200000000000" ... version: 4 mutationId: 1 @@ -430,10 +460,13 @@ upsert descriptor #106 unexposedParentSchemaId: 105 - version: "7" + version: "8" -update progress of schema change job #1: "PostCommitNonRevertiblePhase stage 3 of 3 with 4 MutationType ops pending" +create job #2 (non-cancelable: true): "GC for " + descriptor IDs: [106] +update progress of schema change job #1: "PostCommitNonRevertiblePhase stage 3 of 3 with 2 MutationType ops pending" commit transaction #11 +notified job registry to adopt jobs: [2] begin transaction #12 -## PostCommitNonRevertiblePhase stage 3 of 3 with 6 MutationType ops +## PostCommitNonRevertiblePhase stage 3 of 3 with 4 MutationType ops upsert descriptor #106 ... createAsOfTime: @@ -461,33 +494,6 @@ upsert descriptor #106 - mutations: - - direction: DROP - index: - - constraintId: 3 - - createdExplicitly: true - - encodingType: 1 - - foreignKey: {} - - geoConfig: {} - - id: 3 - - interleave: {} - - keyColumnDirections: - - - ASC - - keyColumnIds: - - - 1 - - keyColumnNames: - - - i - - name: crdb_internal_index_3_name_placeholder - - partitioning: {} - - sharded: {} - - storeColumnIds: - - - 2 - - storeColumnNames: - - - j - - unique: true - - useDeletePreservingEncoding: true - - version: 4 - - mutationId: 1 - - state: DELETE_ONLY - - - direction: DROP - - index: - constraintId: 1 - createdAtNanos: "1640995200000000000" - encodingType: 1 @@ -518,9 +524,9 @@ upsert descriptor #106 - version: "8" + version: "9" write *eventpb.FinishSchemaChange to event log for descriptor 106 -create job #2 (non-cancelable: true): "GC for ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL DEFAULT 42" +create job #3 (non-cancelable: true): "GC for ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL DEFAULT 42" descriptor IDs: [106] update progress of schema change job #1: "all stages completed" commit transaction #12 -notified job registry to adopt jobs: [2] +notified job registry to adopt jobs: [3] # end PostCommitPhase diff --git a/pkg/sql/schemachanger/testdata/end_to_end/add_column_default_seq b/pkg/sql/schemachanger/testdata/end_to_end/add_column_default_seq index be65dce56d8f..d4e231990169 100644 --- a/pkg/sql/schemachanger/testdata/end_to_end/add_column_default_seq +++ b/pkg/sql/schemachanger/testdata/end_to_end/add_column_default_seq @@ -379,7 +379,7 @@ begin transaction #9 validate forward indexes [2] in table #106 commit transaction #9 begin transaction #10 -## PostCommitNonRevertiblePhase stage 1 of 3 with 11 MutationType ops +## PostCommitNonRevertiblePhase stage 1 of 3 with 10 MutationType ops upsert descriptor #106 ... oid: 20 @@ -529,11 +529,11 @@ upsert descriptor #107 - version: "6" + version: "7" adding table for stats refresh: 106 -update progress of schema change job #1: "PostCommitNonRevertiblePhase stage 2 of 3 with 1 MutationType op pending" +update progress of schema change job #1: "PostCommitNonRevertiblePhase stage 2 of 3 with 3 MutationType ops pending" set schema change job #1 to non-cancellable commit transaction #10 begin transaction #11 -## PostCommitNonRevertiblePhase stage 2 of 3 with 4 MutationType ops +## PostCommitNonRevertiblePhase stage 2 of 3 with 6 MutationType ops upsert descriptor #106 ... formatVersion: 3 @@ -543,6 +543,36 @@ upsert descriptor #106 + modificationTime: {} mutations: - direction: DROP + index: + - constraintId: 3 + - createdExplicitly: true + - encodingType: 1 + - foreignKey: {} + - geoConfig: {} + - id: 3 + - interleave: {} + - keyColumnDirections: + - - ASC + - keyColumnIds: + - - 1 + - keyColumnNames: + - - i + - name: crdb_internal_index_3_name_placeholder + - partitioning: {} + - sharded: {} + - storeColumnIds: + - - 2 + - storeColumnNames: + - - l + - unique: true + - useDeletePreservingEncoding: true + - version: 4 + - mutationId: 1 + - state: DELETE_ONLY + - - direction: DROP + - index: + constraintId: 1 + createdAtNanos: "1640995200000000000" ... version: 4 mutationId: 1 @@ -569,10 +599,13 @@ upsert descriptor #107 unexposedParentSchemaId: 105 - version: "7" + version: "8" -update progress of schema change job #1: "PostCommitNonRevertiblePhase stage 3 of 3 with 4 MutationType ops pending" +create job #2 (non-cancelable: true): "GC for " + descriptor IDs: [106] +update progress of schema change job #1: "PostCommitNonRevertiblePhase stage 3 of 3 with 2 MutationType ops pending" commit transaction #11 +notified job registry to adopt jobs: [2] begin transaction #12 -## PostCommitNonRevertiblePhase stage 3 of 3 with 7 MutationType ops +## PostCommitNonRevertiblePhase stage 3 of 3 with 5 MutationType ops upsert descriptor #106 ... createAsOfTime: @@ -600,33 +633,6 @@ upsert descriptor #106 - mutations: - - direction: DROP - index: - - constraintId: 3 - - createdExplicitly: true - - encodingType: 1 - - foreignKey: {} - - geoConfig: {} - - id: 3 - - interleave: {} - - keyColumnDirections: - - - ASC - - keyColumnIds: - - - 1 - - keyColumnNames: - - - i - - name: crdb_internal_index_3_name_placeholder - - partitioning: {} - - sharded: {} - - storeColumnIds: - - - 2 - - storeColumnNames: - - - l - - unique: true - - useDeletePreservingEncoding: true - - version: 4 - - mutationId: 1 - - state: DELETE_ONLY - - - direction: DROP - - index: - constraintId: 1 - createdAtNanos: "1640995200000000000" - encodingType: 1 @@ -680,9 +686,9 @@ upsert descriptor #107 - version: "8" + version: "9" write *eventpb.FinishSchemaChange to event log for descriptor 106 -create job #2 (non-cancelable: true): "GC for ALTER TABLE db.public.tbl ADD COLUMN l INT8 NOT NULL DEFAULT nextval('db.public.sq1')" +create job #3 (non-cancelable: true): "GC for ALTER TABLE db.public.tbl ADD COLUMN l INT8 NOT NULL DEFAULT nextval('db.public.sq1')" descriptor IDs: [106] update progress of schema change job #1: "all stages completed" commit transaction #12 -notified job registry to adopt jobs: [2] +notified job registry to adopt jobs: [3] # end PostCommitPhase diff --git a/pkg/sql/schemachanger/testdata/end_to_end/alter_table_alter_primary_key_drop_rowid b/pkg/sql/schemachanger/testdata/end_to_end/alter_table_alter_primary_key_drop_rowid new file mode 100644 index 000000000000..5587ba5336fe --- /dev/null +++ b/pkg/sql/schemachanger/testdata/end_to_end/alter_table_alter_primary_key_drop_rowid @@ -0,0 +1,893 @@ +setup +CREATE TABLE t (a INT NOT NULL) +---- +... ++object {100 101 t} -> 104 + +test +ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a) +---- +begin transaction #1 +# begin StatementPhase +checking for feature: ALTER TABLE +increment telemetry for sql.schema.alter_table +## StatementPhase stage 1 of 1 with 11 MutationType ops +upsert descriptor #104 + ... + oid: 20 + width: 64 + - - defaultExpr: unique_rowid() + - hidden: true + - id: 2 + - name: rowid + - type: + - family: IntFamily + - oid: 20 + - width: 64 + createAsOfTime: + wallTime: "1640995200000000000" + ... + columnNames: + - a + - - rowid + + - crdb_internal_column_2_name_placeholder + defaultColumnId: 1 + name: primary + formatVersion: 3 + id: 104 + - modificationTime: + - wallTime: "1640995200000000000" + + modificationTime: {} + + mutations: + + - column: + + defaultExpr: unique_rowid() + + hidden: true + + id: 2 + + name: crdb_internal_column_2_name_placeholder + + type: + + family: IntFamily + + oid: 20 + + width: 64 + + direction: DROP + + mutationId: 1 + + state: DELETE_AND_WRITE_ONLY + + - direction: ADD + + index: + + constraintId: 2 + + createdExplicitly: true + + encodingType: 1 + + foreignKey: {} + + geoConfig: {} + + id: 2 + + interleave: {} + + keyColumnDirections: + + - ASC + + keyColumnIds: + + - 1 + + keyColumnNames: + + - a + + name: crdb_internal_index_2_name_placeholder + + partitioning: {} + + sharded: {} + + storeColumnIds: + + - 2 + + storeColumnNames: + + - crdb_internal_column_2_name_placeholder + + unique: true + + version: 4 + + mutationId: 1 + + state: BACKFILLING + + - direction: ADD + + index: + + constraintId: 3 + + createdExplicitly: true + + encodingType: 1 + + foreignKey: {} + + geoConfig: {} + + id: 3 + + interleave: {} + + keyColumnDirections: + + - ASC + + keyColumnIds: + + - 1 + + keyColumnNames: + + - a + + name: crdb_internal_index_3_name_placeholder + + partitioning: {} + + sharded: {} + + storeColumnIds: + + - 2 + + storeColumnNames: + + - crdb_internal_column_2_name_placeholder + + unique: true + + useDeletePreservingEncoding: true + + version: 4 + + mutationId: 1 + + state: DELETE_ONLY + + - direction: ADD + + index: + + constraintId: 4 + + createdExplicitly: true + + encodingType: 1 + + foreignKey: {} + + geoConfig: {} + + id: 4 + + interleave: {} + + keyColumnDirections: + + - ASC + + keyColumnIds: + + - 1 + + keyColumnNames: + + - a + + name: crdb_internal_index_4_name_placeholder + + partitioning: {} + + sharded: {} + + storeColumnNames: [] + + unique: true + + version: 4 + + mutationId: 1 + + state: BACKFILLING + name: t + nextColumnId: 3 + - nextConstraintId: 2 + + nextConstraintId: 5 + nextFamilyId: 1 + - nextIndexId: 2 + + nextIndexId: 5 + nextMutationId: 1 + parentId: 100 + ... + - 2 + keyColumnNames: + - - rowid + + - crdb_internal_column_2_name_placeholder + name: t_pkey + partitioning: {} + ... + time: {} + unexposedParentSchemaId: 101 + - version: "1" + + version: "2" +write *eventpb.AlterTable to event log for descriptor #104: ALTER TABLE ‹defaultdb›.‹public›.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) +# end StatementPhase +# begin PreCommitPhase +## PreCommitPhase stage 1 of 1 with 2 MutationType ops +upsert descriptor #104 + ... + createAsOfTime: + wallTime: "1640995200000000000" + + declarativeSchemaChangerState: + + authorization: + + userName: root + + currentStatuses: + + jobId: "1" + + relevantStatements: + + - statement: + + redactedStatement: ALTER TABLE ‹defaultdb›.‹public›.‹t› ALTER PRIMARY KEY + + USING COLUMNS (‹a›) + + statement: ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a) + + statementTag: ALTER TABLE + + revertible: true + + targetRanks: + + targets: + families: + - columnIds: + ... + formatVersion: 3 + id: 104 + - modificationTime: {} + + modificationTime: + + wallTime: "1640995200000000001" + mutations: + - column: + ... +create job #1 (non-cancelable: false): "ALTER TABLE defaultdb.public.t ALTER PRIMARY KEY USING COLUMNS (a)" + descriptor IDs: [104] +# end PreCommitPhase +commit transaction #1 +notified job registry to adopt jobs: [1] +# begin PostCommitPhase +begin transaction #2 +commit transaction #2 +begin transaction #3 +## PostCommitPhase stage 1 of 15 with 3 MutationType ops +upsert descriptor #104 + ... + formatVersion: 3 + id: 104 + - modificationTime: + - wallTime: "1640995200000000001" + + modificationTime: {} + mutations: + - column: + ... + version: 4 + mutationId: 1 + - state: DELETE_ONLY + + state: DELETE_AND_WRITE_ONLY + - direction: ADD + index: + ... + time: {} + unexposedParentSchemaId: 101 + - version: "2" + + version: "3" +update progress of schema change job #1: "PostCommitPhase stage 2 of 15 with 1 BackfillType op pending" +commit transaction #3 +begin transaction #4 +## PostCommitPhase stage 2 of 15 with 1 BackfillType op +backfill indexes [2] from index #1 in table #104 +commit transaction #4 +begin transaction #5 +## PostCommitPhase stage 3 of 15 with 3 MutationType ops +upsert descriptor #104 + ... + formatVersion: 3 + id: 104 + - modificationTime: + - wallTime: "1640995200000000003" + + modificationTime: {} + mutations: + - column: + ... + version: 4 + mutationId: 1 + - state: BACKFILLING + + state: DELETE_ONLY + - direction: ADD + index: + ... + time: {} + unexposedParentSchemaId: 101 + - version: "3" + + version: "4" +update progress of schema change job #1: "PostCommitPhase stage 4 of 15 with 1 MutationType op pending" +commit transaction #5 +begin transaction #6 +## PostCommitPhase stage 4 of 15 with 3 MutationType ops +upsert descriptor #104 + ... + formatVersion: 3 + id: 104 + - modificationTime: + - wallTime: "1640995200000000005" + + modificationTime: {} + mutations: + - column: + ... + version: 4 + mutationId: 1 + - state: DELETE_ONLY + + state: MERGING + - direction: ADD + index: + ... + time: {} + unexposedParentSchemaId: 101 + - version: "4" + + version: "5" +update progress of schema change job #1: "PostCommitPhase stage 5 of 15 with 1 BackfillType op pending" +commit transaction #6 +begin transaction #7 +## PostCommitPhase stage 5 of 15 with 1 BackfillType op +merge temporary indexes [3] into backfilled indexes [2] in table #104 +commit transaction #7 +begin transaction #8 +## PostCommitPhase stage 6 of 15 with 3 MutationType ops +upsert descriptor #104 + ... + formatVersion: 3 + id: 104 + - modificationTime: + - wallTime: "1640995200000000006" + + modificationTime: {} + mutations: + - column: + ... + version: 4 + mutationId: 1 + - state: MERGING + + state: DELETE_AND_WRITE_ONLY + - direction: ADD + index: + ... + time: {} + unexposedParentSchemaId: 101 + - version: "5" + + version: "6" +update progress of schema change job #1: "PostCommitPhase stage 7 of 15 with 1 ValidationType op pending" +commit transaction #8 +begin transaction #9 +## PostCommitPhase stage 7 of 15 with 1 ValidationType op +validate forward indexes [2] in table #104 +commit transaction #9 +begin transaction #10 +## PostCommitPhase stage 8 of 15 with 8 MutationType ops +upsert descriptor #104 + ... + formatVersion: 3 + id: 104 + - modificationTime: + - wallTime: "1640995200000000008" + + modificationTime: {} + mutations: + - column: + ... + - direction: ADD + index: + - constraintId: 2 + + constraintId: 3 + createdExplicitly: true + encodingType: 1 + foreignKey: {} + geoConfig: {} + - id: 2 + + id: 3 + interleave: {} + keyColumnDirections: + ... + keyColumnNames: + - a + - name: crdb_internal_index_2_name_placeholder + + name: crdb_internal_index_3_name_placeholder + partitioning: {} + sharded: {} + ... + - crdb_internal_column_2_name_placeholder + unique: true + + useDeletePreservingEncoding: true + version: 4 + mutationId: 1 + ... + - direction: ADD + index: + - constraintId: 3 + + constraintId: 4 + createdExplicitly: true + encodingType: 1 + foreignKey: {} + geoConfig: {} + - id: 3 + + id: 4 + interleave: {} + keyColumnDirections: + ... + keyColumnNames: + - a + - name: crdb_internal_index_3_name_placeholder + + name: crdb_internal_index_4_name_placeholder + partitioning: {} + sharded: {} + - storeColumnIds: + + storeColumnNames: [] + + unique: true + + version: 4 + + mutationId: 1 + + state: BACKFILLING + + - direction: DROP + + index: + + constraintId: 1 + + createdAtNanos: "1640995200000000000" + + encodingType: 1 + + foreignKey: {} + + geoConfig: {} + + id: 1 + + interleave: {} + + keyColumnDirections: + + - ASC + + keyColumnIds: + - 2 + - storeColumnNames: + + keyColumnNames: + - crdb_internal_column_2_name_placeholder + + name: crdb_internal_index_1_name_placeholder + + partitioning: {} + + sharded: {} + + storeColumnIds: + + - 1 + + storeColumnNames: + + - a + unique: true + - useDeletePreservingEncoding: true + version: 4 + mutationId: 1 + ... + - direction: ADD + index: + - constraintId: 4 + + constraintId: 5 + createdExplicitly: true + encodingType: 1 + foreignKey: {} + geoConfig: {} + - id: 4 + + id: 5 + interleave: {} + keyColumnDirections: + ... + keyColumnNames: + - a + - name: crdb_internal_index_4_name_placeholder + + name: crdb_internal_index_5_name_placeholder + partitioning: {} + sharded: {} + storeColumnNames: [] + unique: true + + useDeletePreservingEncoding: true + version: 4 + mutationId: 1 + - state: BACKFILLING + + state: DELETE_ONLY + name: t + nextColumnId: 3 + - nextConstraintId: 5 + + nextConstraintId: 6 + nextFamilyId: 1 + - nextIndexId: 5 + + nextIndexId: 6 + nextMutationId: 1 + parentId: 100 + primaryIndex: + - constraintId: 1 + - createdAtNanos: "1640995200000000000" + + constraintId: 2 + + createdExplicitly: true + encodingType: 1 + foreignKey: {} + geoConfig: {} + - id: 1 + + id: 2 + interleave: {} + keyColumnDirections: + - ASC + keyColumnIds: + - - 2 + + - 1 + keyColumnNames: + - - crdb_internal_column_2_name_placeholder + + - a + name: t_pkey + partitioning: {} + sharded: {} + storeColumnIds: + - - 1 + + - 2 + storeColumnNames: + - - a + + - crdb_internal_column_2_name_placeholder + unique: true + version: 4 + ... + time: {} + unexposedParentSchemaId: 101 + - version: "6" + + version: "7" +update progress of schema change job #1: "PostCommitPhase stage 9 of 15 with 1 MutationType op pending" +commit transaction #10 +begin transaction #11 +## PostCommitPhase stage 9 of 15 with 3 MutationType ops +upsert descriptor #104 + ... + formatVersion: 3 + id: 104 + - modificationTime: + - wallTime: "1640995200000000010" + + modificationTime: {} + mutations: + - column: + ... + version: 4 + mutationId: 1 + - state: DELETE_ONLY + + state: DELETE_AND_WRITE_ONLY + name: t + nextColumnId: 3 + ... + time: {} + unexposedParentSchemaId: 101 + - version: "7" + + version: "8" +update progress of schema change job #1: "PostCommitPhase stage 10 of 15 with 1 BackfillType op pending" +commit transaction #11 +begin transaction #12 +## PostCommitPhase stage 10 of 15 with 1 BackfillType op +backfill indexes [4] from index #2 in table #104 +commit transaction #12 +begin transaction #13 +## PostCommitPhase stage 11 of 15 with 3 MutationType ops +upsert descriptor #104 + ... + formatVersion: 3 + id: 104 + - modificationTime: + - wallTime: "1640995200000000011" + + modificationTime: {} + mutations: + - column: + ... + version: 4 + mutationId: 1 + - state: BACKFILLING + + state: DELETE_ONLY + - direction: DROP + index: + ... + time: {} + unexposedParentSchemaId: 101 + - version: "8" + + version: "9" +update progress of schema change job #1: "PostCommitPhase stage 12 of 15 with 1 MutationType op pending" +commit transaction #13 +begin transaction #14 +## PostCommitPhase stage 12 of 15 with 3 MutationType ops +upsert descriptor #104 + ... + formatVersion: 3 + id: 104 + - modificationTime: + - wallTime: "1640995200000000013" + + modificationTime: {} + mutations: + - column: + ... + version: 4 + mutationId: 1 + - state: DELETE_ONLY + + state: MERGING + - direction: DROP + index: + ... + time: {} + unexposedParentSchemaId: 101 + - version: "9" + + version: "10" +update progress of schema change job #1: "PostCommitPhase stage 13 of 15 with 1 BackfillType op pending" +commit transaction #14 +begin transaction #15 +## PostCommitPhase stage 13 of 15 with 1 BackfillType op +merge temporary indexes [5] into backfilled indexes [4] in table #104 +commit transaction #15 +begin transaction #16 +## PostCommitPhase stage 14 of 15 with 3 MutationType ops +upsert descriptor #104 + ... + formatVersion: 3 + id: 104 + - modificationTime: + - wallTime: "1640995200000000014" + + modificationTime: {} + mutations: + - column: + ... + version: 4 + mutationId: 1 + - state: MERGING + + state: DELETE_AND_WRITE_ONLY + - direction: DROP + index: + ... + time: {} + unexposedParentSchemaId: 101 + - version: "10" + + version: "11" +update progress of schema change job #1: "PostCommitPhase stage 15 of 15 with 1 ValidationType op pending" +commit transaction #16 +begin transaction #17 +## PostCommitPhase stage 15 of 15 with 1 ValidationType op +validate forward indexes [4] in table #104 +commit transaction #17 +begin transaction #18 +## PostCommitNonRevertiblePhase stage 1 of 4 with 6 MutationType ops +upsert descriptor #104 + ... + statement: ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a) + statementTag: ALTER TABLE + - revertible: true + targetRanks: + targets: + ... + formatVersion: 3 + id: 104 + - modificationTime: + - wallTime: "1640995200000000016" + + modificationTime: {} + mutations: + - column: + ... + direction: DROP + mutationId: 1 + - state: DELETE_AND_WRITE_ONLY + - - direction: ADD + + state: DELETE_ONLY + + - direction: DROP + index: + constraintId: 3 + ... + version: 4 + mutationId: 1 + - state: DELETE_AND_WRITE_ONLY + + state: DELETE_ONLY + - direction: ADD + index: + ... + version: 4 + mutationId: 1 + - state: DELETE_AND_WRITE_ONLY + - - direction: ADD + + state: DELETE_ONLY + + - direction: DROP + index: + constraintId: 5 + ... + version: 4 + mutationId: 1 + - state: DELETE_AND_WRITE_ONLY + + state: DELETE_ONLY + name: t + nextColumnId: 3 + ... + time: {} + unexposedParentSchemaId: 101 + - version: "11" + + version: "12" +update progress of schema change job #1: "PostCommitNonRevertiblePhase stage 2 of 4 with 10 MutationType ops pending" +set schema change job #1 to non-cancellable +commit transaction #18 +begin transaction #19 +## PostCommitNonRevertiblePhase stage 2 of 4 with 12 MutationType ops +upsert descriptor #104 + ... + formatVersion: 3 + id: 104 + - modificationTime: + - wallTime: "1640995200000000018" + + modificationTime: {} + mutations: + - column: + ... + - direction: DROP + index: + - constraintId: 3 + + constraintId: 2 + createdExplicitly: true + encodingType: 1 + foreignKey: {} + geoConfig: {} + - id: 3 + + id: 2 + interleave: {} + keyColumnDirections: + ... + keyColumnNames: + - a + - name: crdb_internal_index_3_name_placeholder + + name: crdb_internal_index_2_name_placeholder + partitioning: {} + sharded: {} + ... + - crdb_internal_column_2_name_placeholder + unique: true + - useDeletePreservingEncoding: true + version: 4 + mutationId: 1 + - state: DELETE_ONLY + - - direction: ADD + - index: + - constraintId: 4 + - createdExplicitly: true + - encodingType: 1 + - foreignKey: {} + - geoConfig: {} + - id: 4 + - interleave: {} + - keyColumnDirections: + - - ASC + - keyColumnIds: + - - 1 + - keyColumnNames: + - - a + - name: crdb_internal_index_4_name_placeholder + - partitioning: {} + - sharded: {} + - storeColumnNames: [] + - unique: true + - version: 4 + - mutationId: 1 + state: DELETE_AND_WRITE_ONLY + - - direction: DROP + - index: + - constraintId: 1 + - createdAtNanos: "1640995200000000000" + - encodingType: 1 + - foreignKey: {} + - geoConfig: {} + - id: 1 + - interleave: {} + - keyColumnDirections: + - - ASC + - keyColumnIds: + - - 2 + - keyColumnNames: + - - crdb_internal_column_2_name_placeholder + - name: crdb_internal_index_1_name_placeholder + - partitioning: {} + - sharded: {} + - storeColumnIds: + - - 1 + - storeColumnNames: + - - a + - unique: true + - version: 4 + - mutationId: 1 + - state: DELETE_ONLY + - - direction: DROP + - index: + - constraintId: 5 + - createdExplicitly: true + - encodingType: 1 + - foreignKey: {} + - geoConfig: {} + - id: 5 + - interleave: {} + - keyColumnDirections: + - - ASC + - keyColumnIds: + - - 1 + - keyColumnNames: + - - a + - name: crdb_internal_index_5_name_placeholder + - partitioning: {} + - sharded: {} + - storeColumnNames: [] + - unique: true + - useDeletePreservingEncoding: true + - version: 4 + - mutationId: 1 + - state: DELETE_ONLY + name: t + nextColumnId: 3 + ... + parentId: 100 + primaryIndex: + - constraintId: 2 + + constraintId: 4 + createdExplicitly: true + encodingType: 1 + foreignKey: {} + geoConfig: {} + - id: 2 + + id: 4 + interleave: {} + keyColumnDirections: + ... + partitioning: {} + sharded: {} + - storeColumnIds: + - - 2 + - storeColumnNames: + - - crdb_internal_column_2_name_placeholder + + storeColumnNames: [] + unique: true + version: 4 + ... + time: {} + unexposedParentSchemaId: 101 + - version: "12" + + version: "13" +create job #2 (non-cancelable: true): "GC for ALTER TABLE defaultdb.public.t ALTER PRIMARY KEY USING COLUMNS (a)" + descriptor IDs: [104] +update progress of schema change job #1: "PostCommitNonRevertiblePhase stage 3 of 4 with 1 MutationType op pending" +commit transaction #19 +notified job registry to adopt jobs: [2] +begin transaction #20 +## PostCommitNonRevertiblePhase stage 3 of 4 with 3 MutationType ops +upsert descriptor #104 + ... + formatVersion: 3 + id: 104 + - modificationTime: + - wallTime: "1640995200000000019" + + modificationTime: {} + mutations: + - column: + ... + version: 4 + mutationId: 1 + - state: DELETE_AND_WRITE_ONLY + + state: DELETE_ONLY + name: t + nextColumnId: 3 + ... + time: {} + unexposedParentSchemaId: 101 + - version: "13" + + version: "14" +update progress of schema change job #1: "PostCommitNonRevertiblePhase stage 4 of 4 with 4 MutationType ops pending" +commit transaction #20 +begin transaction #21 +## PostCommitNonRevertiblePhase stage 4 of 4 with 6 MutationType ops +upsert descriptor #104 + ... + createAsOfTime: + wallTime: "1640995200000000000" + - declarativeSchemaChangerState: + - authorization: + - userName: root + - currentStatuses: + - jobId: "1" + - relevantStatements: + - - statement: + - redactedStatement: ALTER TABLE ‹defaultdb›.‹public›.‹t› ALTER PRIMARY KEY + - USING COLUMNS (‹a›) + - statement: ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a) + - statementTag: ALTER TABLE + - targetRanks: + - targets: + families: + - columnIds: + - 1 + - - 2 + columnNames: + - a + - - crdb_internal_column_2_name_placeholder + defaultColumnId: 1 + name: primary + formatVersion: 3 + id: 104 + - modificationTime: + - wallTime: "1640995200000000020" + - mutations: + - - column: + - defaultExpr: unique_rowid() + - hidden: true + - id: 2 + - name: crdb_internal_column_2_name_placeholder + - type: + - family: IntFamily + - oid: 20 + - width: 64 + - direction: DROP + - mutationId: 1 + - state: DELETE_ONLY + - - direction: DROP + - index: + - constraintId: 2 + - createdExplicitly: true + - encodingType: 1 + - foreignKey: {} + - geoConfig: {} + - id: 2 + - interleave: {} + - keyColumnDirections: + - - ASC + - keyColumnIds: + - - 1 + - keyColumnNames: + - - a + - name: crdb_internal_index_2_name_placeholder + - partitioning: {} + - sharded: {} + - storeColumnIds: + - - 2 + - storeColumnNames: + - - crdb_internal_column_2_name_placeholder + - unique: true + - version: 4 + - mutationId: 1 + - state: DELETE_ONLY + + modificationTime: {} + + mutations: [] + name: t + nextColumnId: 3 + ... + time: {} + unexposedParentSchemaId: 101 + - version: "14" + + version: "15" +write *eventpb.FinishSchemaChange to event log for descriptor 104 +create job #3 (non-cancelable: true): "GC for ALTER TABLE defaultdb.public.t ALTER PRIMARY KEY USING COLUMNS (a)" + descriptor IDs: [104] +update progress of schema change job #1: "all stages completed" +commit transaction #21 +notified job registry to adopt jobs: [3] +# end PostCommitPhase diff --git a/pkg/sql/schemachanger/testdata/end_to_end/alter_table_alter_primary_key_vanilla b/pkg/sql/schemachanger/testdata/end_to_end/alter_table_alter_primary_key_vanilla index d4a99c7beaf4..2feb9c47d9f6 100644 --- a/pkg/sql/schemachanger/testdata/end_to_end/alter_table_alter_primary_key_vanilla +++ b/pkg/sql/schemachanger/testdata/end_to_end/alter_table_alter_primary_key_vanilla @@ -319,7 +319,7 @@ validate forward indexes [2] in table #104 validate forward indexes [4] in table #104 commit transaction #9 begin transaction #10 -## PostCommitNonRevertiblePhase stage 1 of 3 with 12 MutationType ops +## PostCommitNonRevertiblePhase stage 1 of 3 with 10 MutationType ops upsert descriptor #104 ... statement: ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (j) @@ -486,11 +486,11 @@ upsert descriptor #104 unexposedParentSchemaId: 101 - version: "6" + version: "7" -update progress of schema change job #1: "PostCommitNonRevertiblePhase stage 2 of 3 with 1 MutationType op pending" +update progress of schema change job #1: "PostCommitNonRevertiblePhase stage 2 of 3 with 5 MutationType ops pending" set schema change job #1 to non-cancellable commit transaction #10 begin transaction #11 -## PostCommitNonRevertiblePhase stage 2 of 3 with 3 MutationType ops +## PostCommitNonRevertiblePhase stage 2 of 3 with 7 MutationType ops upsert descriptor #104 ... unique: true @@ -500,49 +500,7 @@ upsert descriptor #104 + modificationTime: {} mutations: - direction: DROP - ... - version: 4 - mutationId: 1 - - state: DELETE_AND_WRITE_ONLY - + state: DELETE_ONLY - name: t - nextColumnId: 3 - ... - time: {} - unexposedParentSchemaId: 101 - - version: "7" - + version: "8" -update progress of schema change job #1: "PostCommitNonRevertiblePhase stage 3 of 3 with 6 MutationType ops pending" -commit transaction #11 -begin transaction #12 -## PostCommitNonRevertiblePhase stage 3 of 3 with 8 MutationType ops -upsert descriptor #104 - ... - createAsOfTime: - wallTime: "1640995200000000000" - - declarativeSchemaChangerState: - - authorization: - - userName: root - - currentStatuses: - - jobId: "1" - - relevantStatements: - - - statement: - - redactedStatement: ALTER TABLE ‹defaultdb›.‹public›.‹t› ALTER PRIMARY KEY - - USING COLUMNS (‹j›) - - statement: ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (j) - - statementTag: ALTER TABLE - - targetRanks: - - targets: - families: - - columnIds: - ... - unique: true - version: 4 - - modificationTime: - - wallTime: "1640995200000000011" - - mutations: - - - direction: DROP - - index: + index: - constraintId: 3 - createdExplicitly: true - encodingType: 1 @@ -594,6 +552,54 @@ upsert descriptor #104 - mutationId: 1 - state: DELETE_ONLY - - direction: DROP + - index: + constraintId: 1 + createdAtNanos: "1640995200000000000" + ... + version: 4 + mutationId: 1 + - state: DELETE_AND_WRITE_ONLY + + state: DELETE_ONLY + name: t + nextColumnId: 3 + ... + time: {} + unexposedParentSchemaId: 101 + - version: "7" + + version: "8" +create job #2 (non-cancelable: true): "GC for " + descriptor IDs: [104] +update progress of schema change job #1: "PostCommitNonRevertiblePhase stage 3 of 3 with 2 MutationType ops pending" +commit transaction #11 +notified job registry to adopt jobs: [2] +begin transaction #12 +## PostCommitNonRevertiblePhase stage 3 of 3 with 4 MutationType ops +upsert descriptor #104 + ... + createAsOfTime: + wallTime: "1640995200000000000" + - declarativeSchemaChangerState: + - authorization: + - userName: root + - currentStatuses: + - jobId: "1" + - relevantStatements: + - - statement: + - redactedStatement: ALTER TABLE ‹defaultdb›.‹public›.‹t› ALTER PRIMARY KEY + - USING COLUMNS (‹j›) + - statement: ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (j) + - statementTag: ALTER TABLE + - targetRanks: + - targets: + families: + - columnIds: + ... + unique: true + version: 4 + - modificationTime: + - wallTime: "1640995200000000011" + - mutations: + - - direction: DROP - index: - constraintId: 1 - createdAtNanos: "1640995200000000000" @@ -629,9 +635,9 @@ upsert descriptor #104 - version: "8" + version: "9" write *eventpb.FinishSchemaChange to event log for descriptor 104 -create job #2 (non-cancelable: true): "GC for ALTER TABLE defaultdb.public.t ALTER PRIMARY KEY USING COLUMNS (j)" +create job #3 (non-cancelable: true): "GC for ALTER TABLE defaultdb.public.t ALTER PRIMARY KEY USING COLUMNS (j)" descriptor IDs: [104] update progress of schema change job #1: "all stages completed" commit transaction #12 -notified job registry to adopt jobs: [2] +notified job registry to adopt jobs: [3] # end PostCommitPhase diff --git a/pkg/sql/schemachanger/testdata/end_to_end/drop_column_basic b/pkg/sql/schemachanger/testdata/end_to_end/drop_column_basic index 34aa7d70e50b..b4b830814426 100644 --- a/pkg/sql/schemachanger/testdata/end_to_end/drop_column_basic +++ b/pkg/sql/schemachanger/testdata/end_to_end/drop_column_basic @@ -271,7 +271,7 @@ begin transaction #9 validate forward indexes [2] in table #104 commit transaction #9 begin transaction #10 -## PostCommitNonRevertiblePhase stage 1 of 3 with 10 MutationType ops +## PostCommitNonRevertiblePhase stage 1 of 3 with 8 MutationType ops upsert descriptor #104 ... statement: ALTER TABLE t DROP COLUMN j @@ -378,11 +378,11 @@ upsert descriptor #104 unexposedParentSchemaId: 101 - version: "6" + version: "7" -update progress of schema change job #1: "PostCommitNonRevertiblePhase stage 2 of 3 with 1 MutationType op pending" +update progress of schema change job #1: "PostCommitNonRevertiblePhase stage 2 of 3 with 3 MutationType ops pending" set schema change job #1 to non-cancellable commit transaction #10 begin transaction #11 -## PostCommitNonRevertiblePhase stage 2 of 3 with 3 MutationType ops +## PostCommitNonRevertiblePhase stage 2 of 3 with 5 MutationType ops upsert descriptor #104 ... formatVersion: 3 @@ -392,6 +392,35 @@ upsert descriptor #104 + modificationTime: {} mutations: - column: + ... + - direction: DROP + index: + - constraintId: 3 + - createdExplicitly: true + - encodingType: 1 + - foreignKey: {} + - geoConfig: {} + - id: 3 + - interleave: {} + - keyColumnDirections: + - - ASC + - keyColumnIds: + - - 1 + - keyColumnNames: + - - i + - name: crdb_internal_index_3_name_placeholder + - partitioning: {} + - sharded: {} + - storeColumnNames: [] + - unique: true + - useDeletePreservingEncoding: true + - version: 4 + - mutationId: 1 + - state: DELETE_ONLY + - - direction: DROP + - index: + constraintId: 1 + createdAtNanos: "1640995200000000000" ... version: 4 mutationId: 1 @@ -404,10 +433,13 @@ upsert descriptor #104 unexposedParentSchemaId: 101 - version: "7" + version: "8" -update progress of schema change job #1: "PostCommitNonRevertiblePhase stage 3 of 3 with 5 MutationType ops pending" +create job #2 (non-cancelable: true): "GC for " + descriptor IDs: [104] +update progress of schema change job #1: "PostCommitNonRevertiblePhase stage 3 of 3 with 3 MutationType ops pending" commit transaction #11 +notified job registry to adopt jobs: [2] begin transaction #12 -## PostCommitNonRevertiblePhase stage 3 of 3 with 7 MutationType ops +## PostCommitNonRevertiblePhase stage 3 of 3 with 5 MutationType ops upsert descriptor #104 ... createAsOfTime: @@ -451,30 +483,6 @@ upsert descriptor #104 - state: DELETE_ONLY - - direction: DROP - index: - - constraintId: 3 - - createdExplicitly: true - - encodingType: 1 - - foreignKey: {} - - geoConfig: {} - - id: 3 - - interleave: {} - - keyColumnDirections: - - - ASC - - keyColumnIds: - - - 1 - - keyColumnNames: - - - i - - name: crdb_internal_index_3_name_placeholder - - partitioning: {} - - sharded: {} - - storeColumnNames: [] - - unique: true - - useDeletePreservingEncoding: true - - version: 4 - - mutationId: 1 - - state: DELETE_ONLY - - - direction: DROP - - index: - constraintId: 1 - createdAtNanos: "1640995200000000000" - encodingType: 1 @@ -509,9 +517,9 @@ upsert descriptor #104 - version: "8" + version: "9" write *eventpb.FinishSchemaChange to event log for descriptor 104 -create job #2 (non-cancelable: true): "GC for ALTER TABLE defaultdb.public.t DROP COLUMN j" +create job #3 (non-cancelable: true): "GC for ALTER TABLE defaultdb.public.t DROP COLUMN j" descriptor IDs: [104] update progress of schema change job #1: "all stages completed" commit transaction #12 -notified job registry to adopt jobs: [2] +notified job registry to adopt jobs: [3] # end PostCommitPhase diff --git a/pkg/sql/schemachanger/testdata/end_to_end/drop_column_computed_index b/pkg/sql/schemachanger/testdata/end_to_end/drop_column_computed_index index 253d47fd8f3c..2c98d12fe148 100644 --- a/pkg/sql/schemachanger/testdata/end_to_end/drop_column_computed_index +++ b/pkg/sql/schemachanger/testdata/end_to_end/drop_column_computed_index @@ -79,20 +79,6 @@ upsert descriptor #104 + direction: DROP + mutationId: 1 + state: DELETE_AND_WRITE_ONLY - + - column: - + computeExpr: crdb_internal_column_2_name_placeholder + 1:::INT8 - + id: 3 - + inaccessible: true - + name: crdb_internal_column_3_name_placeholder - + nullable: true - + type: - + family: IntFamily - + oid: 20 - + width: 64 - + virtual: true - + direction: DROP - + mutationId: 1 - + state: DELETE_AND_WRITE_ONLY + - direction: DROP + index: + createdAtNanos: "1640995200000000000" @@ -161,6 +147,20 @@ upsert descriptor #104 + version: 4 + mutationId: 1 + state: DELETE_ONLY + + - column: + + computeExpr: crdb_internal_column_2_name_placeholder + 1:::INT8 + + id: 3 + + inaccessible: true + + name: crdb_internal_column_3_name_placeholder + + nullable: true + + type: + + family: IntFamily + + oid: 20 + + width: 64 + + virtual: true + + direction: DROP + + mutationId: 1 + + state: DELETE_AND_WRITE_ONLY name: t nextColumnId: 4 - nextConstraintId: 2 @@ -238,8 +238,8 @@ upsert descriptor #104 mutationId: 1 - state: DELETE_ONLY + state: DELETE_AND_WRITE_ONLY - name: t - nextColumnId: 4 + - column: + computeExpr: crdb_internal_column_2_name_placeholder + 1:::INT8 ... time: {} unexposedParentSchemaId: 101 @@ -335,7 +335,7 @@ begin transaction #9 validate forward indexes [3] in table #104 commit transaction #9 begin transaction #10 -## PostCommitNonRevertiblePhase stage 1 of 3 with 14 MutationType ops +## PostCommitNonRevertiblePhase stage 1 of 3 with 10 MutationType ops upsert descriptor #104 ... statement: ALTER TABLE t DROP COLUMN j CASCADE @@ -355,13 +355,6 @@ upsert descriptor #104 direction: DROP mutationId: 1 - state: DELETE_AND_WRITE_ONLY - + state: DELETE_ONLY - - column: - computeExpr: crdb_internal_column_2_name_placeholder + 1:::INT8 - ... - direction: DROP - mutationId: 1 - - state: DELETE_AND_WRITE_ONLY + state: DELETE_ONLY - direction: DROP index: @@ -374,59 +367,68 @@ upsert descriptor #104 + - direction: DROP index: - constraintId: 2 - + constraintId: 3 - createdExplicitly: true - encodingType: 1 - foreignKey: {} - geoConfig: {} + - createdExplicitly: true + - encodingType: 1 + - foreignKey: {} + - geoConfig: {} - id: 3 - + id: 4 - interleave: {} - keyColumnDirections: - ... - keyColumnNames: - - i + - interleave: {} + - keyColumnDirections: + - - ASC + - keyColumnIds: + - - 1 + - keyColumnNames: + - - i - name: crdb_internal_index_3_name_placeholder - + name: crdb_internal_index_4_name_placeholder - partitioning: {} - sharded: {} - storeColumnNames: [] - unique: true - + useDeletePreservingEncoding: true + - partitioning: {} + - sharded: {} + - storeColumnNames: [] + - unique: true + - version: 4 + - mutationId: 1 + - state: DELETE_AND_WRITE_ONLY + - - direction: ADD + - index: + constraintId: 3 + createdExplicitly: true + ... version: 4 mutationId: 1 - state: DELETE_AND_WRITE_ONLY - - - direction: ADD + + state: DELETE_ONLY + - column: + computeExpr: crdb_internal_column_2_name_placeholder + 1:::INT8 + ... + direction: DROP + mutationId: 1 + state: DELETE_ONLY + - direction: DROP - index: - - constraintId: 3 - - createdExplicitly: true + + index: + constraintId: 1 + createdAtNanos: "1640995200000000000" - encodingType: 1 - foreignKey: {} - geoConfig: {} - - id: 4 + + encodingType: 1 + + foreignKey: {} + + geoConfig: {} + id: 1 - interleave: {} - keyColumnDirections: - ... - keyColumnNames: - - i - - name: crdb_internal_index_4_name_placeholder + + interleave: {} + + keyColumnDirections: + + - ASC + + keyColumnIds: + + - 1 + + keyColumnNames: + + - i + name: crdb_internal_index_1_name_placeholder - partitioning: {} - sharded: {} - - storeColumnNames: [] + + partitioning: {} + + sharded: {} + storeColumnIds: + - 2 + storeColumnNames: + - crdb_internal_column_2_name_placeholder - unique: true - - useDeletePreservingEncoding: true - version: 4 - mutationId: 1 + + unique: true + + version: 4 + + mutationId: 1 + state: DELETE_AND_WRITE_ONLY + name: t ... parentId: 100 primaryIndex: @@ -456,11 +458,11 @@ upsert descriptor #104 unexposedParentSchemaId: 101 - version: "6" + version: "7" -update progress of schema change job #1: "PostCommitNonRevertiblePhase stage 2 of 3 with 1 MutationType op pending" +update progress of schema change job #1: "PostCommitNonRevertiblePhase stage 2 of 3 with 7 MutationType ops pending" set schema change job #1 to non-cancellable commit transaction #10 begin transaction #11 -## PostCommitNonRevertiblePhase stage 2 of 3 with 3 MutationType ops +## PostCommitNonRevertiblePhase stage 2 of 3 with 9 MutationType ops upsert descriptor #104 ... id: 104 @@ -470,6 +472,70 @@ upsert descriptor #104 + modificationTime: {} mutations: - column: + ... + - direction: DROP + index: + - createdAtNanos: "1640995200000000000" + - foreignKey: {} + - geoConfig: {} + - id: 2 + - interleave: {} + - keyColumnDirections: + - - ASC + - keyColumnIds: + - - 3 + - keyColumnNames: + - - crdb_internal_column_3_name_placeholder + - keySuffixColumnIds: + - - 1 + - name: crdb_internal_index_2_name_placeholder + - partitioning: {} + - sharded: {} + - version: 3 + - mutationId: 1 + - state: DELETE_ONLY + - - direction: DROP + - index: + - constraintId: 3 + - createdExplicitly: true + - encodingType: 1 + - foreignKey: {} + - geoConfig: {} + - id: 4 + - interleave: {} + - keyColumnDirections: + - - ASC + - keyColumnIds: + - - 1 + - keyColumnNames: + - - i + - name: crdb_internal_index_4_name_placeholder + - partitioning: {} + - sharded: {} + - storeColumnNames: [] + - unique: true + - useDeletePreservingEncoding: true + - version: 4 + - mutationId: 1 + - state: DELETE_ONLY + - - column: + - computeExpr: crdb_internal_column_2_name_placeholder + 1:::INT8 + - id: 3 + - inaccessible: true + - name: crdb_internal_column_3_name_placeholder + - nullable: true + - type: + - family: IntFamily + - oid: 20 + - width: 64 + - virtual: true + - direction: DROP + - mutationId: 1 + - state: DELETE_ONLY + - - direction: DROP + - index: + constraintId: 1 + createdAtNanos: "1640995200000000000" ... version: 4 mutationId: 1 @@ -482,10 +548,14 @@ upsert descriptor #104 unexposedParentSchemaId: 101 - version: "7" + version: "8" -update progress of schema change job #1: "PostCommitNonRevertiblePhase stage 3 of 3 with 9 MutationType ops pending" +write *eventpb.DropIndex to event log for descriptor #104: ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COLUMN ‹j› CASCADE +create job #2 (non-cancelable: true): "GC for ALTER TABLE defaultdb.public.t DROP COLUMN j CASCADE" + descriptor IDs: [104] +update progress of schema change job #1: "PostCommitNonRevertiblePhase stage 3 of 3 with 3 MutationType ops pending" commit transaction #11 +notified job registry to adopt jobs: [2] begin transaction #12 -## PostCommitNonRevertiblePhase stage 3 of 3 with 11 MutationType ops +## PostCommitNonRevertiblePhase stage 3 of 3 with 5 MutationType ops upsert descriptor #104 ... createAsOfTime: @@ -528,65 +598,6 @@ upsert descriptor #104 - direction: DROP - mutationId: 1 - state: DELETE_ONLY - - - column: - - computeExpr: crdb_internal_column_2_name_placeholder + 1:::INT8 - - id: 3 - - inaccessible: true - - name: crdb_internal_column_3_name_placeholder - - nullable: true - - type: - - family: IntFamily - - oid: 20 - - width: 64 - - virtual: true - - direction: DROP - - mutationId: 1 - - state: DELETE_ONLY - - - direction: DROP - - index: - - createdAtNanos: "1640995200000000000" - - foreignKey: {} - - geoConfig: {} - - id: 2 - - interleave: {} - - keyColumnDirections: - - - ASC - - keyColumnIds: - - - 3 - - keyColumnNames: - - - crdb_internal_column_3_name_placeholder - - keySuffixColumnIds: - - - 1 - - name: crdb_internal_index_2_name_placeholder - - partitioning: {} - - sharded: {} - - version: 3 - - mutationId: 1 - - state: DELETE_ONLY - - - direction: DROP - - index: - - constraintId: 3 - - createdExplicitly: true - - encodingType: 1 - - foreignKey: {} - - geoConfig: {} - - id: 4 - - interleave: {} - - keyColumnDirections: - - - ASC - - keyColumnIds: - - - 1 - - keyColumnNames: - - - i - - name: crdb_internal_index_4_name_placeholder - - partitioning: {} - - sharded: {} - - storeColumnNames: [] - - unique: true - - useDeletePreservingEncoding: true - - version: 4 - - mutationId: 1 - - state: DELETE_ONLY - - direction: DROP - index: - constraintId: 1 @@ -622,10 +633,10 @@ upsert descriptor #104 unexposedParentSchemaId: 101 - version: "8" + version: "9" -write *eventpb.DropIndex to event log for descriptor #104: ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COLUMN ‹j› CASCADE -create job #2 (non-cancelable: true): "GC for ALTER TABLE defaultdb.public.t DROP COLUMN j CASCADE" +write *eventpb.FinishSchemaChange to event log for descriptor 104 +create job #3 (non-cancelable: true): "GC for ALTER TABLE defaultdb.public.t DROP COLUMN j CASCADE" descriptor IDs: [104] update progress of schema change job #1: "all stages completed" commit transaction #12 -notified job registry to adopt jobs: [2] +notified job registry to adopt jobs: [3] # end PostCommitPhase diff --git a/pkg/sql/schemachanger/testdata/end_to_end/drop_column_create_index_separate_statements b/pkg/sql/schemachanger/testdata/end_to_end/drop_column_create_index_separate_statements index 961ecbdbb9d5..b5607cf1f15f 100644 --- a/pkg/sql/schemachanger/testdata/end_to_end/drop_column_create_index_separate_statements +++ b/pkg/sql/schemachanger/testdata/end_to_end/drop_column_create_index_separate_statements @@ -88,20 +88,6 @@ upsert descriptor #104 + direction: DROP + mutationId: 1 + state: DELETE_AND_WRITE_ONLY - + - column: - + computeExpr: crdb_internal_column_2_name_placeholder + 1:::INT8 - + id: 4 - + inaccessible: true - + name: crdb_internal_column_4_name_placeholder - + nullable: true - + type: - + family: IntFamily - + oid: 20 - + width: 64 - + virtual: true - + direction: DROP - + mutationId: 1 - + state: DELETE_AND_WRITE_ONLY + - direction: DROP + index: + createdAtNanos: "1640995200000000000" @@ -179,6 +165,20 @@ upsert descriptor #104 + version: 4 + mutationId: 1 + state: DELETE_ONLY + + - column: + + computeExpr: crdb_internal_column_2_name_placeholder + 1:::INT8 + + id: 4 + + inaccessible: true + + name: crdb_internal_column_4_name_placeholder + + nullable: true + + type: + + family: IntFamily + + oid: 20 + + width: 64 + + virtual: true + + direction: DROP + + mutationId: 1 + + state: DELETE_AND_WRITE_ONLY name: t nextColumnId: 5 - nextConstraintId: 2 @@ -262,8 +262,8 @@ upsert descriptor #104 mutationId: 1 - state: DELETE_ONLY + state: DELETE_AND_WRITE_ONLY - name: t - nextColumnId: 5 + - column: + computeExpr: crdb_internal_column_2_name_placeholder + 1:::INT8 ... time: {} unexposedParentSchemaId: 101 @@ -397,6 +397,20 @@ upsert descriptor #104 mutationId: 1 state: DELETE_AND_WRITE_ONLY - - direction: ADD + + - column: + + computeExpr: crdb_internal_column_2_name_placeholder + 1:::INT8 + + id: 4 + + inaccessible: true + + name: crdb_internal_column_4_name_placeholder + + nullable: true + + type: + + family: IntFamily + + oid: 20 + + width: 64 + + virtual: true + + direction: DROP + + mutationId: 1 + + state: DELETE_AND_WRITE_ONLY + - direction: DROP index: - constraintId: 3 @@ -428,6 +442,18 @@ upsert descriptor #104 version: 4 mutationId: 1 state: DELETE_AND_WRITE_ONLY + - - column: + - computeExpr: crdb_internal_column_2_name_placeholder + 1:::INT8 + - id: 4 + - inaccessible: true + - name: crdb_internal_column_4_name_placeholder + - nullable: true + - type: + - family: IntFamily + - oid: 20 + - width: 64 + - virtual: true + - direction: DROP + - direction: ADD + index: + constraintId: 4 @@ -450,7 +476,8 @@ upsert descriptor #104 + storeColumnNames: [] + unique: true + version: 4 - + mutationId: 1 + mutationId: 1 + - state: DELETE_AND_WRITE_ONLY + state: BACKFILLING + - direction: ADD + index: @@ -627,7 +654,7 @@ begin transaction #17 validate forward indexes [5] in table #104 commit transaction #17 begin transaction #18 -## PostCommitNonRevertiblePhase stage 1 of 2 with 16 MutationType ops +## PostCommitNonRevertiblePhase stage 1 of 2 with 10 MutationType ops upsert descriptor #104 ... statementTag: CREATE INDEX @@ -669,13 +696,6 @@ upsert descriptor #104 direction: DROP mutationId: 1 - state: DELETE_AND_WRITE_ONLY - + state: DELETE_ONLY - - column: - computeExpr: crdb_internal_column_2_name_placeholder + 1:::INT8 - ... - direction: DROP - mutationId: 1 - - state: DELETE_AND_WRITE_ONLY + state: DELETE_ONLY - direction: DROP index: @@ -692,6 +712,13 @@ upsert descriptor #104 version: 4 mutationId: 1 - state: DELETE_AND_WRITE_ONLY + + state: DELETE_ONLY + - column: + computeExpr: crdb_internal_column_2_name_placeholder + 1:::INT8 + ... + direction: DROP + mutationId: 1 + - state: DELETE_AND_WRITE_ONLY + state: DELETE_ONLY - direction: DROP index: @@ -798,20 +825,6 @@ upsert descriptor #104 - direction: DROP - mutationId: 1 - state: DELETE_ONLY - - - column: - - computeExpr: crdb_internal_column_2_name_placeholder + 1:::INT8 - - id: 4 - - inaccessible: true - - name: crdb_internal_column_4_name_placeholder - - nullable: true - - type: - - family: IntFamily - - oid: 20 - - width: 64 - - virtual: true - - direction: DROP - - mutationId: 1 - - state: DELETE_ONLY - - direction: DROP - index: - createdAtNanos: "1640995200000000000" @@ -863,6 +876,20 @@ upsert descriptor #104 - version: 4 - mutationId: 1 - state: DELETE_ONLY + - - column: + - computeExpr: crdb_internal_column_2_name_placeholder + 1:::INT8 + - id: 4 + - inaccessible: true + - name: crdb_internal_column_4_name_placeholder + - nullable: true + - type: + - family: IntFamily + - oid: 20 + - width: 64 + - virtual: true + - direction: DROP + - mutationId: 1 + - state: DELETE_ONLY - - direction: DROP - index: - constraintId: 1 diff --git a/pkg/sql/schemachanger/testdata/end_to_end/drop_column_unique_index b/pkg/sql/schemachanger/testdata/end_to_end/drop_column_unique_index index 4402ad4685ca..0a828bf0e46b 100644 --- a/pkg/sql/schemachanger/testdata/end_to_end/drop_column_unique_index +++ b/pkg/sql/schemachanger/testdata/end_to_end/drop_column_unique_index @@ -287,7 +287,7 @@ begin transaction #9 validate forward indexes [4] in table #106 commit transaction #9 begin transaction #10 -## PostCommitNonRevertiblePhase stage 1 of 3 with 12 MutationType ops +## PostCommitNonRevertiblePhase stage 1 of 3 with 8 MutationType ops upsert descriptor #106 ... statement: ALTER TABLE t.test DROP COLUMN pi @@ -398,11 +398,11 @@ upsert descriptor #106 unexposedParentSchemaId: 105 - version: "16" + version: "17" -update progress of schema change job #1: "PostCommitNonRevertiblePhase stage 2 of 3 with 1 MutationType op pending" +update progress of schema change job #1: "PostCommitNonRevertiblePhase stage 2 of 3 with 3 MutationType ops pending" set schema change job #1 to non-cancellable commit transaction #10 begin transaction #11 -## PostCommitNonRevertiblePhase stage 2 of 3 with 3 MutationType ops +## PostCommitNonRevertiblePhase stage 2 of 3 with 5 MutationType ops upsert descriptor #106 ... unique: true @@ -412,6 +412,40 @@ upsert descriptor #106 + modificationTime: {} mutations: - column: + ... + - direction: DROP + index: + - constraintId: 6 + - createdExplicitly: true + - encodingType: 1 + - foreignKey: {} + - geoConfig: {} + - id: 5 + - interleave: {} + - keyColumnDirections: + - - ASC + - keyColumnIds: + - - 1 + - keyColumnNames: + - - k + - name: crdb_internal_index_5_name_placeholder + - partitioning: {} + - sharded: {} + - storeColumnIds: + - - 2 + - - 4 + - storeColumnNames: + - - v + - - x + - unique: true + - useDeletePreservingEncoding: true + - version: 4 + - mutationId: 3 + - state: DELETE_ONLY + - - direction: DROP + - index: + constraintId: 1 + createdAtNanos: "1640995200000000000" ... version: 4 mutationId: 3 @@ -424,10 +458,13 @@ upsert descriptor #106 unexposedParentSchemaId: 105 - version: "17" + version: "18" -update progress of schema change job #1: "PostCommitNonRevertiblePhase stage 3 of 3 with 6 MutationType ops pending" +create job #2 (non-cancelable: true): "GC for " + descriptor IDs: [106] +update progress of schema change job #1: "PostCommitNonRevertiblePhase stage 3 of 3 with 4 MutationType ops pending" commit transaction #11 +notified job registry to adopt jobs: [2] begin transaction #12 -## PostCommitNonRevertiblePhase stage 3 of 3 with 8 MutationType ops +## PostCommitNonRevertiblePhase stage 3 of 3 with 6 MutationType ops upsert descriptor #106 ... createAsOfTime: @@ -475,35 +512,6 @@ upsert descriptor #106 - state: DELETE_ONLY - - direction: DROP - index: - - constraintId: 6 - - createdExplicitly: true - - encodingType: 1 - - foreignKey: {} - - geoConfig: {} - - id: 5 - - interleave: {} - - keyColumnDirections: - - - ASC - - keyColumnIds: - - - 1 - - keyColumnNames: - - - k - - name: crdb_internal_index_5_name_placeholder - - partitioning: {} - - sharded: {} - - storeColumnIds: - - - 2 - - - 4 - - storeColumnNames: - - - v - - - x - - unique: true - - useDeletePreservingEncoding: true - - version: 4 - - mutationId: 3 - - state: DELETE_ONLY - - - direction: DROP - - index: - constraintId: 1 - createdAtNanos: "1640995200000000000" - encodingType: 1 @@ -542,9 +550,9 @@ upsert descriptor #106 - version: "18" + version: "19" write *eventpb.FinishSchemaChange to event log for descriptor 106 -create job #2 (non-cancelable: true): "GC for ALTER TABLE t.public.test DROP COLUMN pi" +create job #3 (non-cancelable: true): "GC for ALTER TABLE t.public.test DROP COLUMN pi" descriptor IDs: [106] update progress of schema change job #1: "all stages completed" commit transaction #12 -notified job registry to adopt jobs: [2] +notified job registry to adopt jobs: [3] # end PostCommitPhase diff --git a/pkg/sql/schemachanger/testdata/end_to_end/drop_column_with_index b/pkg/sql/schemachanger/testdata/end_to_end/drop_column_with_index index a7030d7f0fd2..2ab29ed0eff1 100644 --- a/pkg/sql/schemachanger/testdata/end_to_end/drop_column_with_index +++ b/pkg/sql/schemachanger/testdata/end_to_end/drop_column_with_index @@ -58,17 +58,6 @@ upsert descriptor #104 + indexes: [] + modificationTime: {} + mutations: - + - column: - + id: 2 - + name: crdb_internal_column_2_name_placeholder - + nullable: true - + type: - + family: IntFamily - + oid: 20 - + width: 64 - + direction: DROP - + mutationId: 1 - + state: DELETE_AND_WRITE_ONLY + - direction: DROP + index: + createdAtNanos: "1640995200000000000" @@ -137,6 +126,17 @@ upsert descriptor #104 + version: 4 + mutationId: 1 + state: DELETE_ONLY + + - column: + + id: 2 + + name: crdb_internal_column_2_name_placeholder + + nullable: true + + type: + + family: IntFamily + + oid: 20 + + width: 64 + + direction: DROP + + mutationId: 1 + + state: DELETE_AND_WRITE_ONLY name: t nextColumnId: 3 - nextConstraintId: 2 @@ -158,7 +158,6 @@ upsert descriptor #104 unexposedParentSchemaId: 101 - version: "1" + version: "2" -write *eventpb.AlterTable to event log for descriptor #104: ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COLUMN ‹j› # end StatementPhase # begin PreCommitPhase ## PreCommitPhase stage 1 of 1 with 2 MutationType ops @@ -188,7 +187,7 @@ upsert descriptor #104 + modificationTime: + wallTime: "1640995200000000001" mutations: - - column: + - direction: DROP ... create job #1 (non-cancelable: false): "ALTER TABLE defaultdb.public.t DROP COLUMN j" descriptor IDs: [104] @@ -208,14 +207,14 @@ upsert descriptor #104 - wallTime: "1640995200000000001" + modificationTime: {} mutations: - - column: + - direction: DROP ... version: 4 mutationId: 1 - state: DELETE_ONLY + state: DELETE_AND_WRITE_ONLY - name: t - nextColumnId: 3 + - column: + id: 2 ... time: {} unexposedParentSchemaId: 101 @@ -237,7 +236,7 @@ upsert descriptor #104 - wallTime: "1640995200000000003" + modificationTime: {} mutations: - - column: + - direction: DROP ... version: 4 mutationId: 1 @@ -262,7 +261,7 @@ upsert descriptor #104 - wallTime: "1640995200000000005" + modificationTime: {} mutations: - - column: + - direction: DROP ... version: 4 mutationId: 1 @@ -291,7 +290,7 @@ upsert descriptor #104 - wallTime: "1640995200000000006" + modificationTime: {} mutations: - - column: + - direction: DROP ... version: 4 mutationId: 1 @@ -311,7 +310,7 @@ begin transaction #9 validate forward indexes [3] in table #104 commit transaction #9 begin transaction #10 -## PostCommitNonRevertiblePhase stage 1 of 3 with 13 MutationType ops +## PostCommitNonRevertiblePhase stage 1 of 3 with 9 MutationType ops upsert descriptor #104 ... statement: ALTER TABLE t DROP COLUMN j @@ -326,14 +325,7 @@ upsert descriptor #104 - wallTime: "1640995200000000008" + modificationTime: {} mutations: - - column: - ... - direction: DROP - mutationId: 1 - - state: DELETE_AND_WRITE_ONLY - + state: DELETE_ONLY - direction: DROP - index: ... version: 3 mutationId: 1 @@ -367,6 +359,17 @@ upsert descriptor #104 - state: DELETE_AND_WRITE_ONLY - - direction: ADD + state: DELETE_ONLY + + - column: + + id: 2 + + name: crdb_internal_column_2_name_placeholder + + nullable: true + + type: + + family: IntFamily + + oid: 20 + + width: 64 + + direction: DROP + + mutationId: 1 + + state: DELETE_ONLY + - direction: DROP index: - constraintId: 3 @@ -396,6 +399,20 @@ upsert descriptor #104 - useDeletePreservingEncoding: true version: 4 mutationId: 1 + state: DELETE_AND_WRITE_ONLY + - - column: + - id: 2 + - name: crdb_internal_column_2_name_placeholder + - nullable: true + - type: + - family: IntFamily + - oid: 20 + - width: 64 + - direction: DROP + - mutationId: 1 + - state: DELETE_AND_WRITE_ONLY + name: t + nextColumnId: 3 ... parentId: 100 primaryIndex: @@ -425,11 +442,11 @@ upsert descriptor #104 unexposedParentSchemaId: 101 - version: "6" + version: "7" -update progress of schema change job #1: "PostCommitNonRevertiblePhase stage 2 of 3 with 1 MutationType op pending" +update progress of schema change job #1: "PostCommitNonRevertiblePhase stage 2 of 3 with 6 MutationType ops pending" set schema change job #1 to non-cancellable commit transaction #10 begin transaction #11 -## PostCommitNonRevertiblePhase stage 2 of 3 with 3 MutationType ops +## PostCommitNonRevertiblePhase stage 2 of 3 with 8 MutationType ops upsert descriptor #104 ... id: 104 @@ -438,7 +455,53 @@ upsert descriptor #104 - wallTime: "1640995200000000010" + modificationTime: {} mutations: + - - direction: DROP + - index: + - createdAtNanos: "1640995200000000000" + - foreignKey: {} + - geoConfig: {} + - id: 2 + - interleave: {} + - keyColumnDirections: + - - ASC + - keyColumnIds: + - - 2 + - keyColumnNames: + - - crdb_internal_column_2_name_placeholder + - keySuffixColumnIds: + - - 1 + - name: crdb_internal_index_2_name_placeholder + - partitioning: {} + - sharded: {} + - version: 3 + - mutationId: 1 + - state: DELETE_ONLY + - - direction: DROP + - index: + - constraintId: 3 + - createdExplicitly: true + - encodingType: 1 + - foreignKey: {} + - geoConfig: {} + - id: 4 + - interleave: {} + - keyColumnDirections: + - - ASC + - keyColumnIds: + - - 1 + - keyColumnNames: + - - i + - name: crdb_internal_index_4_name_placeholder + - partitioning: {} + - sharded: {} + - storeColumnNames: [] + - unique: true + - useDeletePreservingEncoding: true + - version: 4 + - mutationId: 1 + - state: DELETE_ONLY - column: + id: 2 ... version: 4 mutationId: 1 @@ -451,10 +514,14 @@ upsert descriptor #104 unexposedParentSchemaId: 101 - version: "7" + version: "8" -update progress of schema change job #1: "PostCommitNonRevertiblePhase stage 3 of 3 with 8 MutationType ops pending" +write *eventpb.DropIndex to event log for descriptor #104: ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COLUMN ‹j› +create job #2 (non-cancelable: true): "GC for ALTER TABLE defaultdb.public.t DROP COLUMN j" + descriptor IDs: [104] +update progress of schema change job #1: "PostCommitNonRevertiblePhase stage 3 of 3 with 3 MutationType ops pending" commit transaction #11 +notified job registry to adopt jobs: [2] begin transaction #12 -## PostCommitNonRevertiblePhase stage 3 of 3 with 10 MutationType ops +## PostCommitNonRevertiblePhase stage 3 of 3 with 5 MutationType ops upsert descriptor #104 ... createAsOfTime: @@ -499,51 +566,6 @@ upsert descriptor #104 - state: DELETE_ONLY - - direction: DROP - index: - - createdAtNanos: "1640995200000000000" - - foreignKey: {} - - geoConfig: {} - - id: 2 - - interleave: {} - - keyColumnDirections: - - - ASC - - keyColumnIds: - - - 2 - - keyColumnNames: - - - crdb_internal_column_2_name_placeholder - - keySuffixColumnIds: - - - 1 - - name: crdb_internal_index_2_name_placeholder - - partitioning: {} - - sharded: {} - - version: 3 - - mutationId: 1 - - state: DELETE_ONLY - - - direction: DROP - - index: - - constraintId: 3 - - createdExplicitly: true - - encodingType: 1 - - foreignKey: {} - - geoConfig: {} - - id: 4 - - interleave: {} - - keyColumnDirections: - - - ASC - - keyColumnIds: - - - 1 - - keyColumnNames: - - - i - - name: crdb_internal_index_4_name_placeholder - - partitioning: {} - - sharded: {} - - storeColumnNames: [] - - unique: true - - useDeletePreservingEncoding: true - - version: 4 - - mutationId: 1 - - state: DELETE_ONLY - - - direction: DROP - - index: - constraintId: 1 - createdAtNanos: "1640995200000000000" - encodingType: 1 @@ -577,10 +599,10 @@ upsert descriptor #104 unexposedParentSchemaId: 101 - version: "8" + version: "9" -write *eventpb.DropIndex to event log for descriptor #104: ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COLUMN ‹j› -create job #2 (non-cancelable: true): "GC for ALTER TABLE defaultdb.public.t DROP COLUMN j" +write *eventpb.FinishSchemaChange to event log for descriptor 104 +create job #3 (non-cancelable: true): "GC for ALTER TABLE defaultdb.public.t DROP COLUMN j" descriptor IDs: [104] update progress of schema change job #1: "all stages completed" commit transaction #12 -notified job registry to adopt jobs: [2] +notified job registry to adopt jobs: [3] # end PostCommitPhase diff --git a/pkg/sql/schemachanger/testdata/end_to_end/drop_index_hash_sharded_index b/pkg/sql/schemachanger/testdata/end_to_end/drop_index_hash_sharded_index index 513e5dd31e29..82e26b19d631 100644 --- a/pkg/sql/schemachanger/testdata/end_to_end/drop_index_hash_sharded_index +++ b/pkg/sql/schemachanger/testdata/end_to_end/drop_index_hash_sharded_index @@ -67,19 +67,6 @@ upsert descriptor #104 + indexes: [] + modificationTime: {} + mutations: - + - column: - + computeExpr: mod(fnv32(crdb_internal.datums_to_bytes(j)), 16:::INT8) - + hidden: true - + id: 3 - + name: crdb_internal_column_3_name_placeholder - + type: - + family: IntFamily - + oid: 20 - + width: 64 - + virtual: true - + direction: DROP - + mutationId: 2 - + state: DELETE_AND_WRITE_ONLY + - direction: DROP + index: + createdAtNanos: "1640995200000000000" @@ -115,6 +102,19 @@ upsert descriptor #104 + shardBuckets: 16 + version: 3 + mutationId: 2 + + state: DELETE_AND_WRITE_ONLY + + - column: + + computeExpr: mod(fnv32(crdb_internal.datums_to_bytes(j)), 16:::INT8) + + hidden: true + + id: 3 + + name: crdb_internal_column_3_name_placeholder + + type: + + family: IntFamily + + oid: 20 + + width: 64 + + virtual: true + + direction: DROP + + mutationId: 2 + state: DELETE_AND_WRITE_ONLY name: t nextColumnId: 4 @@ -123,7 +123,6 @@ upsert descriptor #104 unexposedParentSchemaId: 101 - version: "8" + version: "9" -write *eventpb.AlterTable to event log for descriptor #104: DROP INDEX ‹defaultdb›.‹public›.‹t›@‹idx› CASCADE # end StatementPhase # begin PreCommitPhase ## PreCommitPhase stage 1 of 1 with 2 MutationType ops @@ -152,7 +151,7 @@ upsert descriptor #104 + modificationTime: + wallTime: "1640995200000000001" mutations: - - column: + - direction: DROP ... create job #1 (non-cancelable: true): "DROP INDEX defaultdb.public.t@idx CASCADE" descriptor IDs: [104] @@ -163,7 +162,7 @@ notified job registry to adopt jobs: [1] begin transaction #2 commit transaction #2 begin transaction #3 -## PostCommitNonRevertiblePhase stage 1 of 2 with 9 MutationType ops +## PostCommitNonRevertiblePhase stage 1 of 2 with 6 MutationType ops upsert descriptor #104 table: - checks: @@ -185,16 +184,16 @@ upsert descriptor #104 - wallTime: "1640995200000000001" + modificationTime: {} mutations: - - column: + - direction: DROP ... - direction: DROP + version: 3 mutationId: 2 - state: DELETE_AND_WRITE_ONLY + state: DELETE_ONLY - - direction: DROP - index: + - column: + computeExpr: mod(fnv32(crdb_internal.datums_to_bytes(j)), 16:::INT8) ... - version: 3 + direction: DROP mutationId: 2 - state: DELETE_AND_WRITE_ONLY + state: DELETE_ONLY @@ -233,19 +232,6 @@ upsert descriptor #104 - modificationTime: - wallTime: "1640995200000000003" - mutations: - - - column: - - computeExpr: mod(fnv32(crdb_internal.datums_to_bytes(j)), 16:::INT8) - - hidden: true - - id: 3 - - name: crdb_internal_column_3_name_placeholder - - type: - - family: IntFamily - - oid: 20 - - width: 64 - - virtual: true - - direction: DROP - - mutationId: 2 - - state: DELETE_ONLY - - direction: DROP - index: - createdAtNanos: "1640995200000000000" @@ -276,6 +262,19 @@ upsert descriptor #104 - version: 3 - mutationId: 2 - state: DELETE_ONLY + - - column: + - computeExpr: mod(fnv32(crdb_internal.datums_to_bytes(j)), 16:::INT8) + - hidden: true + - id: 3 + - name: crdb_internal_column_3_name_placeholder + - type: + - family: IntFamily + - oid: 20 + - width: 64 + - virtual: true + - direction: DROP + - mutationId: 2 + - state: DELETE_ONLY + modificationTime: {} + mutations: [] name: t diff --git a/pkg/sql/schemachanger/testdata/end_to_end/drop_index_partial_expression_index b/pkg/sql/schemachanger/testdata/end_to_end/drop_index_partial_expression_index index ee3ac7695a28..c9861f34895d 100644 --- a/pkg/sql/schemachanger/testdata/end_to_end/drop_index_partial_expression_index +++ b/pkg/sql/schemachanger/testdata/end_to_end/drop_index_partial_expression_index @@ -56,19 +56,6 @@ upsert descriptor #104 + indexes: [] + modificationTime: {} + mutations: - + - column: - + computeExpr: lower(j) - + id: 3 - + inaccessible: true - + name: crdb_internal_column_3_name_placeholder - + nullable: true - + type: - + family: StringFamily - + oid: 25 - + virtual: true - + direction: DROP - + mutationId: 2 - + state: DELETE_AND_WRITE_ONLY + - direction: DROP + index: + createdAtNanos: "1640995200000000000" @@ -91,6 +78,19 @@ upsert descriptor #104 + sharded: {} + version: 3 + mutationId: 2 + + state: DELETE_AND_WRITE_ONLY + + - column: + + computeExpr: lower(j) + + id: 3 + + inaccessible: true + + name: crdb_internal_column_3_name_placeholder + + nullable: true + + type: + + family: StringFamily + + oid: 25 + + virtual: true + + direction: DROP + + mutationId: 2 + state: DELETE_AND_WRITE_ONLY name: t nextColumnId: 4 @@ -99,7 +99,6 @@ upsert descriptor #104 unexposedParentSchemaId: 101 - version: "7" + version: "8" -write *eventpb.AlterTable to event log for descriptor #104: DROP INDEX ‹defaultdb›.‹public›.‹t›@‹idx› CASCADE # end StatementPhase # begin PreCommitPhase ## PreCommitPhase stage 1 of 1 with 2 MutationType ops @@ -128,7 +127,7 @@ upsert descriptor #104 + modificationTime: + wallTime: "1640995200000000001" mutations: - - column: + - direction: DROP ... create job #1 (non-cancelable: true): "DROP INDEX defaultdb.public.t@idx CASCADE" descriptor IDs: [104] @@ -139,7 +138,7 @@ notified job registry to adopt jobs: [1] begin transaction #2 commit transaction #2 begin transaction #3 -## PostCommitNonRevertiblePhase stage 1 of 2 with 6 MutationType ops +## PostCommitNonRevertiblePhase stage 1 of 2 with 4 MutationType ops upsert descriptor #104 ... id: 104 @@ -148,16 +147,16 @@ upsert descriptor #104 - wallTime: "1640995200000000001" + modificationTime: {} mutations: - - column: + - direction: DROP ... - direction: DROP + version: 3 mutationId: 2 - state: DELETE_AND_WRITE_ONLY + state: DELETE_ONLY - - direction: DROP - index: + - column: + computeExpr: lower(j) ... - version: 3 + direction: DROP mutationId: 2 - state: DELETE_AND_WRITE_ONLY + state: DELETE_ONLY @@ -196,19 +195,6 @@ upsert descriptor #104 - modificationTime: - wallTime: "1640995200000000003" - mutations: - - - column: - - computeExpr: lower(j) - - id: 3 - - inaccessible: true - - name: crdb_internal_column_3_name_placeholder - - nullable: true - - type: - - family: StringFamily - - oid: 25 - - virtual: true - - direction: DROP - - mutationId: 2 - - state: DELETE_ONLY - - direction: DROP - index: - createdAtNanos: "1640995200000000000" @@ -232,6 +218,19 @@ upsert descriptor #104 - version: 3 - mutationId: 2 - state: DELETE_ONLY + - - column: + - computeExpr: lower(j) + - id: 3 + - inaccessible: true + - name: crdb_internal_column_3_name_placeholder + - nullable: true + - type: + - family: StringFamily + - oid: 25 + - virtual: true + - direction: DROP + - mutationId: 2 + - state: DELETE_ONLY + modificationTime: {} + mutations: [] name: t diff --git a/pkg/sql/schemachanger/testdata/end_to_end/drop_index_vanilla_index b/pkg/sql/schemachanger/testdata/end_to_end/drop_index_vanilla_index index 62bb79782a6a..ea53c50f3ee0 100644 --- a/pkg/sql/schemachanger/testdata/end_to_end/drop_index_vanilla_index +++ b/pkg/sql/schemachanger/testdata/end_to_end/drop_index_vanilla_index @@ -109,7 +109,7 @@ notified job registry to adopt jobs: [1] begin transaction #2 commit transaction #2 begin transaction #3 -## PostCommitNonRevertiblePhase stage 1 of 2 with 5 MutationType ops +## PostCommitNonRevertiblePhase stage 1 of 2 with 3 MutationType ops upsert descriptor #104 ... id: 104 diff --git a/pkg/sql/schemachanger/testdata/end_to_end/drop_multiple_columns_separate_statements b/pkg/sql/schemachanger/testdata/end_to_end/drop_multiple_columns_separate_statements index 7d604e9f9659..4f75c7622a08 100644 --- a/pkg/sql/schemachanger/testdata/end_to_end/drop_multiple_columns_separate_statements +++ b/pkg/sql/schemachanger/testdata/end_to_end/drop_multiple_columns_separate_statements @@ -88,20 +88,6 @@ upsert descriptor #104 + direction: DROP + mutationId: 1 + state: DELETE_AND_WRITE_ONLY - + - column: - + computeExpr: crdb_internal_column_2_name_placeholder + 1:::INT8 - + id: 4 - + inaccessible: true - + name: crdb_internal_column_4_name_placeholder - + nullable: true - + type: - + family: IntFamily - + oid: 20 - + width: 64 - + virtual: true - + direction: DROP - + mutationId: 1 - + state: DELETE_AND_WRITE_ONLY + - direction: DROP + index: + createdAtNanos: "1640995200000000000" @@ -179,6 +165,20 @@ upsert descriptor #104 + version: 4 + mutationId: 1 + state: DELETE_ONLY + + - column: + + computeExpr: crdb_internal_column_2_name_placeholder + 1:::INT8 + + id: 4 + + inaccessible: true + + name: crdb_internal_column_4_name_placeholder + + nullable: true + + type: + + family: IntFamily + + oid: 20 + + width: 64 + + virtual: true + + direction: DROP + + mutationId: 1 + + state: DELETE_AND_WRITE_ONLY name: t nextColumnId: 5 - nextConstraintId: 2 @@ -257,7 +257,7 @@ upsert descriptor #104 useDeletePreservingEncoding: true ... mutationId: 1 - state: DELETE_ONLY + state: DELETE_AND_WRITE_ONLY + - column: + defaultExpr: 32:::INT8 + id: 3 @@ -334,7 +334,7 @@ upsert descriptor #104 - state: DELETE_ONLY + state: DELETE_AND_WRITE_ONLY - column: - defaultExpr: 32:::INT8 + computeExpr: crdb_internal_column_2_name_placeholder + 1:::INT8 ... time: {} unexposedParentSchemaId: 101 @@ -430,7 +430,7 @@ begin transaction #9 validate forward indexes [3] in table #104 commit transaction #9 begin transaction #10 -## PostCommitNonRevertiblePhase stage 1 of 3 with 19 MutationType ops +## PostCommitNonRevertiblePhase stage 1 of 3 with 12 MutationType ops upsert descriptor #104 ... statementTag: ALTER TABLE @@ -450,13 +450,6 @@ upsert descriptor #104 direction: DROP mutationId: 1 - state: DELETE_AND_WRITE_ONLY - + state: DELETE_ONLY - - column: - computeExpr: crdb_internal_column_2_name_placeholder + 1:::INT8 - ... - direction: DROP - mutationId: 1 - - state: DELETE_AND_WRITE_ONLY + state: DELETE_ONLY - direction: DROP index: @@ -469,94 +462,80 @@ upsert descriptor #104 + - direction: DROP index: - constraintId: 2 - + constraintId: 3 - createdExplicitly: true - encodingType: 1 - foreignKey: {} - geoConfig: {} + - createdExplicitly: true + - encodingType: 1 + - foreignKey: {} + - geoConfig: {} - id: 3 - + id: 4 - interleave: {} - keyColumnDirections: - ... - keyColumnNames: - - i + - interleave: {} + - keyColumnDirections: + - - ASC + - keyColumnIds: + - - 1 + - keyColumnNames: + - - i - name: crdb_internal_index_3_name_placeholder - + name: crdb_internal_index_4_name_placeholder - partitioning: {} - sharded: {} + - partitioning: {} + - sharded: {} - storeColumnIds: - - 3 - storeColumnNames: - - crdb_internal_column_3_name_placeholder - + storeColumnIds: [] - + storeColumnNames: [] - unique: true - + useDeletePreservingEncoding: true + - unique: true + - version: 4 + - mutationId: 1 + - state: DELETE_AND_WRITE_ONLY + - - direction: ADD + - index: + constraintId: 3 + createdExplicitly: true + ... version: 4 mutationId: 1 - state: DELETE_AND_WRITE_ONLY - - - direction: ADD + state: DELETE_ONLY - + - column: - + defaultExpr: 32:::INT8 - + id: 3 - + name: crdb_internal_column_3_name_placeholder - + nullable: true - + onUpdateExpr: 42:::INT8 - + type: - + family: IntFamily - + oid: 20 - + width: 64 - + direction: DROP - + mutationId: 1 + - column: + computeExpr: crdb_internal_column_2_name_placeholder + 1:::INT8 + ... + direction: DROP + mutationId: 1 + - state: DELETE_AND_WRITE_ONLY + + state: DELETE_ONLY + - column: + defaultExpr: 32:::INT8 + ... + direction: DROP + mutationId: 1 + state: DELETE_ONLY + - direction: DROP - index: - - constraintId: 3 - - createdExplicitly: true + + index: + constraintId: 1 + createdAtNanos: "1640995200000000000" - encodingType: 1 - foreignKey: {} - geoConfig: {} - - id: 4 + + encodingType: 1 + + foreignKey: {} + + geoConfig: {} + id: 1 - interleave: {} - keyColumnDirections: - ... - keyColumnNames: - - i - - name: crdb_internal_index_4_name_placeholder + + interleave: {} + + keyColumnDirections: + + - ASC + + keyColumnIds: + + - 1 + + keyColumnNames: + + - i + name: crdb_internal_index_1_name_placeholder - partitioning: {} - sharded: {} - storeColumnIds: + + partitioning: {} + + sharded: {} + + storeColumnIds: + - 2 - - 3 - storeColumnNames: + + - 3 + + storeColumnNames: + - crdb_internal_column_2_name_placeholder - - crdb_internal_column_3_name_placeholder - unique: true - - useDeletePreservingEncoding: true - version: 4 - mutationId: 1 + + - crdb_internal_column_3_name_placeholder + + unique: true + + version: 4 + + mutationId: 1 state: DELETE_AND_WRITE_ONLY - - - column: - - defaultExpr: 32:::INT8 - - id: 3 - - name: crdb_internal_column_3_name_placeholder - - nullable: true - - onUpdateExpr: 42:::INT8 - - type: - - family: IntFamily - - oid: 20 - - width: 64 - - direction: DROP - - mutationId: 1 - - state: DELETE_AND_WRITE_ONLY name: t - nextColumnId: 5 ... parentId: 100 primaryIndex: @@ -589,11 +568,11 @@ upsert descriptor #104 unexposedParentSchemaId: 101 - version: "6" + version: "7" -update progress of schema change job #1: "PostCommitNonRevertiblePhase stage 2 of 3 with 1 MutationType op pending" +update progress of schema change job #1: "PostCommitNonRevertiblePhase stage 2 of 3 with 7 MutationType ops pending" set schema change job #1 to non-cancellable commit transaction #10 begin transaction #11 -## PostCommitNonRevertiblePhase stage 2 of 3 with 3 MutationType ops +## PostCommitNonRevertiblePhase stage 2 of 3 with 9 MutationType ops upsert descriptor #104 ... id: 104 @@ -603,6 +582,77 @@ upsert descriptor #104 + modificationTime: {} mutations: - column: + ... + mutationId: 1 + state: DELETE_ONLY + - - direction: DROP + - index: + - createdAtNanos: "1640995200000000000" + - foreignKey: {} + - geoConfig: {} + - id: 2 + - interleave: {} + - keyColumnDirections: + - - ASC + - - ASC + - keyColumnIds: + - - 4 + - - 3 + - keyColumnNames: + - - crdb_internal_column_4_name_placeholder + - - crdb_internal_column_3_name_placeholder + - keySuffixColumnIds: + - - 1 + - name: crdb_internal_index_2_name_placeholder + - partitioning: {} + - sharded: {} + - version: 3 + - mutationId: 1 + - state: DELETE_ONLY + - - direction: DROP + - index: + - constraintId: 3 + - createdExplicitly: true + - encodingType: 1 + - foreignKey: {} + - geoConfig: {} + - id: 4 + - interleave: {} + - keyColumnDirections: + - - ASC + - keyColumnIds: + - - 1 + - keyColumnNames: + - - i + - name: crdb_internal_index_4_name_placeholder + - partitioning: {} + - sharded: {} + - storeColumnIds: + - - 3 + - storeColumnNames: + - - crdb_internal_column_3_name_placeholder + - unique: true + - useDeletePreservingEncoding: true + - version: 4 + - mutationId: 1 + - state: DELETE_ONLY + - column: + - computeExpr: crdb_internal_column_2_name_placeholder + 1:::INT8 + - id: 4 + - inaccessible: true + - name: crdb_internal_column_4_name_placeholder + - nullable: true + - type: + - family: IntFamily + - oid: 20 + - width: 64 + - virtual: true + - direction: DROP + - mutationId: 1 + - state: DELETE_ONLY + - - column: + defaultExpr: 32:::INT8 + id: 3 ... version: 4 mutationId: 1 @@ -615,10 +665,14 @@ upsert descriptor #104 unexposedParentSchemaId: 101 - version: "7" + version: "8" -update progress of schema change job #1: "PostCommitNonRevertiblePhase stage 3 of 3 with 12 MutationType ops pending" +write *eventpb.DropIndex to event log for descriptor #104: ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COLUMN ‹j› CASCADE +create job #2 (non-cancelable: true): "GC for ALTER TABLE defaultdb.public.t DROP COLUMN j CASCADE" + descriptor IDs: [104] +update progress of schema change job #1: "PostCommitNonRevertiblePhase stage 3 of 3 with 6 MutationType ops pending" commit transaction #11 +notified job registry to adopt jobs: [2] begin transaction #12 -## PostCommitNonRevertiblePhase stage 3 of 3 with 14 MutationType ops +## PostCommitNonRevertiblePhase stage 3 of 3 with 8 MutationType ops upsert descriptor #104 ... createAsOfTime: @@ -668,69 +722,6 @@ upsert descriptor #104 - mutationId: 1 - state: DELETE_ONLY - - column: - - computeExpr: crdb_internal_column_2_name_placeholder + 1:::INT8 - - id: 4 - - inaccessible: true - - name: crdb_internal_column_4_name_placeholder - - nullable: true - - type: - - family: IntFamily - - oid: 20 - - width: 64 - - virtual: true - - direction: DROP - - mutationId: 1 - - state: DELETE_ONLY - - - direction: DROP - - index: - - createdAtNanos: "1640995200000000000" - - foreignKey: {} - - geoConfig: {} - - id: 2 - - interleave: {} - - keyColumnDirections: - - - ASC - - - ASC - - keyColumnIds: - - - 4 - - - 3 - - keyColumnNames: - - - crdb_internal_column_4_name_placeholder - - - crdb_internal_column_3_name_placeholder - - keySuffixColumnIds: - - - 1 - - name: crdb_internal_index_2_name_placeholder - - partitioning: {} - - sharded: {} - - version: 3 - - mutationId: 1 - - state: DELETE_ONLY - - - direction: DROP - - index: - - constraintId: 3 - - createdExplicitly: true - - encodingType: 1 - - foreignKey: {} - - geoConfig: {} - - id: 4 - - interleave: {} - - keyColumnDirections: - - - ASC - - keyColumnIds: - - - 1 - - keyColumnNames: - - - i - - name: crdb_internal_index_4_name_placeholder - - partitioning: {} - - sharded: {} - - storeColumnIds: [] - - storeColumnNames: [] - - unique: true - - useDeletePreservingEncoding: true - - version: 4 - - mutationId: 1 - - state: DELETE_ONLY - - - column: - defaultExpr: 32:::INT8 - id: 3 - name: crdb_internal_column_3_name_placeholder @@ -780,11 +771,10 @@ upsert descriptor #104 unexposedParentSchemaId: 101 - version: "8" + version: "9" -write *eventpb.DropIndex to event log for descriptor #104: ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COLUMN ‹j› CASCADE write *eventpb.FinishSchemaChange to event log for descriptor 104 -create job #2 (non-cancelable: true): "GC for ALTER TABLE defaultdb.public.t DROP COLUMN j CASCADE" +create job #3 (non-cancelable: true): "GC for ALTER TABLE defaultdb.public.t DROP COLUMN j CASCADE" descriptor IDs: [104] update progress of schema change job #1: "all stages completed" commit transaction #12 -notified job registry to adopt jobs: [2] +notified job registry to adopt jobs: [3] # end PostCommitPhase diff --git a/pkg/sql/schemachanger/testdata/explain/add_column b/pkg/sql/schemachanger/testdata/explain/add_column index e69eac686cf2..6333498041d6 100644 --- a/pkg/sql/schemachanger/testdata/explain/add_column +++ b/pkg/sql/schemachanger/testdata/explain/add_column @@ -9,18 +9,18 @@ EXPLAIN (ddl) ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL DEFAULT 42; Schema change plan for ALTER TABLE ‹db›.‹public›.‹tbl› ADD COLUMN ‹j› INT8 NOT NULL DEFAULT ‹42›; ├── StatementPhase │ └── Stage 1 of 1 in StatementPhase - │ ├── 9 elements transitioning toward PUBLIC + │ ├── 7 elements transitioning toward PUBLIC │ │ ├── ABSENT → DELETE_ONLY Column:{DescID: 106, ColumnID: 2} │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 106, Name: j, ColumnID: 2} │ │ ├── ABSENT → PUBLIC ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 2} │ │ ├── ABSENT → PUBLIC ColumnDefaultExpression:{DescID: 106, ColumnID: 2} - │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} - │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} │ │ ├── ABSENT → BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ └── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ ├── 3 elements transitioning toward TRANSIENT_ABSENT + │ │ ├── ABSENT → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} │ │ └── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} - │ ├── 1 element transitioning toward TRANSIENT_ABSENT - │ │ └── ABSENT → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ └── 11 Mutation operations │ ├── MakeAddedColumnDeleteOnly {"Column":{"ColumnID":2,"PgAttributeNum":2,"TableID":106}} │ ├── LogEvent {"TargetStatus":2} @@ -28,11 +28,11 @@ Schema change plan for ALTER TABLE ‹db›.‹public›.‹tbl› ADD COLUMN │ ├── SetAddedColumnType {"ColumnType":{"ColumnID":2,"TableID":106}} │ ├── AddColumnDefaultExpression {"Default":{"ColumnID":2,"TableID":106}} │ ├── MakeAddedIndexBackfilling {"Index":{"ConstraintID":2,"IndexID":2,"IsUnique":true,"SourceIndexID":1,"TableID":106,"TemporaryIndexID":3}} + │ ├── AddColumnToIndex {"ColumnID":1,"IndexID":2,"TableID":106} + │ ├── AddColumnToIndex {"ColumnID":2,"IndexID":2,"Kind":2,"TableID":106} │ ├── MakeAddedTempIndexDeleteOnly {"Index":{"ConstraintID":3,"IndexID":3,"IsUnique":true,"SourceIndexID":1,"TableID":106}} │ ├── AddColumnToIndex {"ColumnID":1,"IndexID":3,"TableID":106} - │ ├── AddColumnToIndex {"ColumnID":2,"IndexID":3,"Kind":2,"TableID":106} - │ ├── AddColumnToIndex {"ColumnID":1,"IndexID":2,"TableID":106} - │ └── AddColumnToIndex {"ColumnID":2,"IndexID":2,"Kind":2,"TableID":106} + │ └── AddColumnToIndex {"ColumnID":2,"IndexID":3,"Kind":2,"TableID":106} ├── PreCommitPhase │ └── Stage 1 of 1 in PreCommitPhase │ └── 2 Mutation operations @@ -95,14 +95,15 @@ Schema change plan for ALTER TABLE ‹db›.‹public›.‹tbl› ADD COLUMN │ │ ├── WRITE_ONLY → PUBLIC Column:{DescID: 106, ColumnID: 2} │ │ ├── VALIDATED → PUBLIC PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} - │ ├── 1 element transitioning toward TRANSIENT_ABSENT - │ │ └── WRITE_ONLY → TRANSIENT_DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} - │ └── 10 Mutation operations + │ ├── 3 elements transitioning toward TRANSIENT_ABSENT + │ │ ├── WRITE_ONLY → TRANSIENT_DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → TRANSIENT_ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ └── PUBLIC → TRANSIENT_ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ └── 9 Mutation operations │ ├── MakeDroppedPrimaryIndexDeleteAndWriteOnly {"IndexID":1,"TableID":106} │ ├── SetIndexName {"IndexID":1,"Name":"crdb_internal_in...","TableID":106} │ ├── SetIndexName {"IndexID":2,"Name":"tbl_pkey","TableID":106} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":1,"TableID":106} │ ├── MakeAddedPrimaryIndexPublic {"IndexID":2,"TableID":106} │ ├── MakeColumnPublic {"ColumnID":2,"TableID":106} │ ├── RefreshStats {"TableID":106} @@ -110,19 +111,19 @@ Schema change plan for ALTER TABLE ‹db›.‹public›.‹tbl› ADD COLUMN │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} ├── Stage 2 of 3 in PostCommitNonRevertiblePhase │ ├── 1 element transitioning toward ABSENT - │ │ └── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} - │ └── 3 Mutation operations + │ │ └── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} + │ ├── 1 element transitioning toward TRANSIENT_ABSENT + │ │ └── TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ └── 5 Mutation operations │ ├── MakeDroppedIndexDeleteOnly {"IndexID":1,"TableID":106} + │ ├── CreateGcJobForIndex {"IndexID":3,"TableID":106} + │ ├── MakeIndexAbsent {"IndexID":3,"TableID":106} │ ├── SetJobStateOnDescriptor {"DescriptorID":106} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} └── Stage 3 of 3 in PostCommitNonRevertiblePhase ├── 1 element transitioning toward ABSENT - │ └── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} - ├── 1 element transitioning toward TRANSIENT_ABSENT - │ └── TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} - └── 6 Mutation operations - ├── CreateGcJobForIndex {"IndexID":3,"TableID":106} - ├── MakeIndexAbsent {"IndexID":3,"TableID":106} + │ └── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} + └── 4 Mutation operations ├── CreateGcJobForIndex {"IndexID":1,"TableID":106} ├── MakeIndexAbsent {"IndexID":1,"TableID":106} ├── RemoveJobStateFromDescriptor {"DescriptorID":106} diff --git a/pkg/sql/schemachanger/testdata/explain/add_column.rollback_1_of_7 b/pkg/sql/schemachanger/testdata/explain/add_column.rollback_1_of_7 index c3fec6edf94e..9fcc38ef9c95 100644 --- a/pkg/sql/schemachanger/testdata/explain/add_column.rollback_1_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/add_column.rollback_1_of_7 @@ -15,18 +15,14 @@ Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD CO │ ├── PUBLIC → ABSENT ColumnName:{DescID: 106, Name: j, ColumnID: 2} │ ├── PUBLIC → ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 2} │ ├── PUBLIC → ABSENT ColumnDefaultExpression:{DescID: 106, ColumnID: 2} + │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} - │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ ├── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} │ └── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} - └── 13 Mutation operations + └── 9 Mutation operations ├── SetColumnName {"ColumnID":2,"Name":"crdb_internal_co...","TableID":106} - ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":106} - ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"Kind":2,"TableID":106} - ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":106} - ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"Kind":2,"TableID":106} ├── CreateGcJobForIndex {"IndexID":2,"TableID":106} ├── MakeIndexAbsent {"IndexID":2,"TableID":106} ├── CreateGcJobForIndex {"IndexID":3,"TableID":106} diff --git a/pkg/sql/schemachanger/testdata/explain/add_column.rollback_2_of_7 b/pkg/sql/schemachanger/testdata/explain/add_column.rollback_2_of_7 index 1b96a09f1e5d..8c47ebd7e963 100644 --- a/pkg/sql/schemachanger/testdata/explain/add_column.rollback_2_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/add_column.rollback_2_of_7 @@ -13,20 +13,16 @@ Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD CO │ ├── 8 elements transitioning toward ABSENT │ │ ├── WRITE_ONLY → DELETE_ONLY Column:{DescID: 106, ColumnID: 2} │ │ ├── PUBLIC → ABSENT ColumnName:{DescID: 106, Name: j, ColumnID: 2} + │ │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} - │ │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} - │ └── 11 Mutation operations + │ └── 7 Mutation operations │ ├── MakeDroppedColumnDeleteOnly {"ColumnID":2,"TableID":106} │ ├── SetColumnName {"ColumnID":2,"Name":"crdb_internal_co...","TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"Kind":2,"TableID":106} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"Kind":2,"TableID":106} │ ├── CreateGcJobForIndex {"IndexID":2,"TableID":106} │ ├── MakeIndexAbsent {"IndexID":2,"TableID":106} │ ├── SetJobStateOnDescriptor {"DescriptorID":106} diff --git a/pkg/sql/schemachanger/testdata/explain/add_column.rollback_3_of_7 b/pkg/sql/schemachanger/testdata/explain/add_column.rollback_3_of_7 index f1306d39d4ab..0a19568d539a 100644 --- a/pkg/sql/schemachanger/testdata/explain/add_column.rollback_3_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/add_column.rollback_3_of_7 @@ -13,20 +13,16 @@ Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD CO │ ├── 8 elements transitioning toward ABSENT │ │ ├── WRITE_ONLY → DELETE_ONLY Column:{DescID: 106, ColumnID: 2} │ │ ├── PUBLIC → ABSENT ColumnName:{DescID: 106, Name: j, ColumnID: 2} + │ │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} - │ │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} - │ └── 11 Mutation operations + │ └── 7 Mutation operations │ ├── MakeDroppedColumnDeleteOnly {"ColumnID":2,"TableID":106} │ ├── SetColumnName {"ColumnID":2,"Name":"crdb_internal_co...","TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"Kind":2,"TableID":106} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"Kind":2,"TableID":106} │ ├── CreateGcJobForIndex {"IndexID":2,"TableID":106} │ ├── MakeIndexAbsent {"IndexID":2,"TableID":106} │ ├── SetJobStateOnDescriptor {"DescriptorID":106} diff --git a/pkg/sql/schemachanger/testdata/explain/add_column.rollback_4_of_7 b/pkg/sql/schemachanger/testdata/explain/add_column.rollback_4_of_7 index 814fa7ca2946..989f2e55c190 100644 --- a/pkg/sql/schemachanger/testdata/explain/add_column.rollback_4_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/add_column.rollback_4_of_7 @@ -13,22 +13,18 @@ Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD CO │ ├── 8 elements transitioning toward ABSENT │ │ ├── WRITE_ONLY → DELETE_ONLY Column:{DescID: 106, ColumnID: 2} │ │ ├── PUBLIC → ABSENT ColumnName:{DescID: 106, Name: j, ColumnID: 2} + │ │ ├── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} - │ │ ├── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} - │ └── 11 Mutation operations + │ └── 7 Mutation operations │ ├── MakeDroppedColumnDeleteOnly {"ColumnID":2,"TableID":106} │ ├── SetColumnName {"ColumnID":2,"Name":"crdb_internal_co...","TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"Kind":2,"TableID":106} + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":106} │ ├── CreateGcJobForIndex {"IndexID":2,"TableID":106} │ ├── MakeIndexAbsent {"IndexID":2,"TableID":106} - │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"Kind":2,"TableID":106} │ ├── SetJobStateOnDescriptor {"DescriptorID":106} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} └── Stage 2 of 2 in PostCommitNonRevertiblePhase diff --git a/pkg/sql/schemachanger/testdata/explain/add_column.rollback_5_of_7 b/pkg/sql/schemachanger/testdata/explain/add_column.rollback_5_of_7 index e054875aec4b..dcda26a91ca0 100644 --- a/pkg/sql/schemachanger/testdata/explain/add_column.rollback_5_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/add_column.rollback_5_of_7 @@ -13,20 +13,16 @@ Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD CO │ ├── 8 elements transitioning toward ABSENT │ │ ├── WRITE_ONLY → DELETE_ONLY Column:{DescID: 106, ColumnID: 2} │ │ ├── PUBLIC → ABSENT ColumnName:{DescID: 106, Name: j, ColumnID: 2} + │ │ ├── MERGE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} - │ │ ├── MERGE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} - │ └── 10 Mutation operations + │ └── 6 Mutation operations │ ├── MakeDroppedColumnDeleteOnly {"ColumnID":2,"TableID":106} │ ├── SetColumnName {"ColumnID":2,"Name":"crdb_internal_co...","TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"Kind":2,"TableID":106} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"Kind":2,"TableID":106} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":2,"TableID":106} │ ├── SetJobStateOnDescriptor {"DescriptorID":106} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} diff --git a/pkg/sql/schemachanger/testdata/explain/add_column.rollback_6_of_7 b/pkg/sql/schemachanger/testdata/explain/add_column.rollback_6_of_7 index b2e47d8cc948..9ef86308f945 100644 --- a/pkg/sql/schemachanger/testdata/explain/add_column.rollback_6_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/add_column.rollback_6_of_7 @@ -13,20 +13,16 @@ Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD CO │ ├── 8 elements transitioning toward ABSENT │ │ ├── WRITE_ONLY → DELETE_ONLY Column:{DescID: 106, ColumnID: 2} │ │ ├── PUBLIC → ABSENT ColumnName:{DescID: 106, Name: j, ColumnID: 2} + │ │ ├── MERGE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} - │ │ ├── MERGE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} - │ └── 10 Mutation operations + │ └── 6 Mutation operations │ ├── MakeDroppedColumnDeleteOnly {"ColumnID":2,"TableID":106} │ ├── SetColumnName {"ColumnID":2,"Name":"crdb_internal_co...","TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"Kind":2,"TableID":106} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"Kind":2,"TableID":106} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":2,"TableID":106} │ ├── SetJobStateOnDescriptor {"DescriptorID":106} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} diff --git a/pkg/sql/schemachanger/testdata/explain/add_column.rollback_7_of_7 b/pkg/sql/schemachanger/testdata/explain/add_column.rollback_7_of_7 index 0c2919764119..7001fc6562c3 100644 --- a/pkg/sql/schemachanger/testdata/explain/add_column.rollback_7_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/add_column.rollback_7_of_7 @@ -13,21 +13,17 @@ Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD CO │ ├── 8 elements transitioning toward ABSENT │ │ ├── WRITE_ONLY → DELETE_ONLY Column:{DescID: 106, ColumnID: 2} │ │ ├── PUBLIC → ABSENT ColumnName:{DescID: 106, Name: j, ColumnID: 2} + │ │ ├── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} - │ │ ├── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} - │ └── 10 Mutation operations + │ └── 6 Mutation operations │ ├── MakeDroppedColumnDeleteOnly {"ColumnID":2,"TableID":106} │ ├── SetColumnName {"ColumnID":2,"Name":"crdb_internal_co...","TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"Kind":2,"TableID":106} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":2,"TableID":106} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"Kind":2,"TableID":106} │ ├── SetJobStateOnDescriptor {"DescriptorID":106} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} └── Stage 2 of 2 in PostCommitNonRevertiblePhase diff --git a/pkg/sql/schemachanger/testdata/explain/add_column_default_seq b/pkg/sql/schemachanger/testdata/explain/add_column_default_seq index 5642c440508f..c142761d30ce 100644 --- a/pkg/sql/schemachanger/testdata/explain/add_column_default_seq +++ b/pkg/sql/schemachanger/testdata/explain/add_column_default_seq @@ -9,18 +9,18 @@ EXPLAIN (ddl) ALTER TABLE db.public.tbl ADD COLUMN l INT NOT NULL DEFAULT nextva Schema change plan for ALTER TABLE ‹db›.‹public›.‹tbl› ADD COLUMN ‹l› INT8 NOT NULL DEFAULT nextval(‹'db.public.sq1'›); ├── StatementPhase │ └── Stage 1 of 1 in StatementPhase - │ ├── 9 elements transitioning toward PUBLIC + │ ├── 7 elements transitioning toward PUBLIC │ │ ├── ABSENT → DELETE_ONLY Column:{DescID: 106, ColumnID: 2} │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 106, Name: l, ColumnID: 2} │ │ ├── ABSENT → PUBLIC ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 2} │ │ ├── ABSENT → PUBLIC ColumnDefaultExpression:{DescID: 106, ColumnID: 2} - │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} - │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} │ │ ├── ABSENT → BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ └── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ ├── 3 elements transitioning toward TRANSIENT_ABSENT + │ │ ├── ABSENT → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} │ │ └── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} - │ ├── 1 element transitioning toward TRANSIENT_ABSENT - │ │ └── ABSENT → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ └── 12 Mutation operations │ ├── MakeAddedColumnDeleteOnly {"Column":{"ColumnID":2,"PgAttributeNum":2,"TableID":106}} │ ├── LogEvent {"TargetStatus":2} @@ -29,11 +29,11 @@ Schema change plan for ALTER TABLE ‹db›.‹public›.‹tbl› ADD COLUMN │ ├── AddColumnDefaultExpression {"Default":{"ColumnID":2,"TableID":106}} │ ├── UpdateBackReferencesInSequences {"BackReferencedColumnID":2,"BackReferencedTableID":106} │ ├── MakeAddedIndexBackfilling {"Index":{"ConstraintID":2,"IndexID":2,"IsUnique":true,"SourceIndexID":1,"TableID":106,"TemporaryIndexID":3}} + │ ├── AddColumnToIndex {"ColumnID":1,"IndexID":2,"TableID":106} + │ ├── AddColumnToIndex {"ColumnID":2,"IndexID":2,"Kind":2,"TableID":106} │ ├── MakeAddedTempIndexDeleteOnly {"Index":{"ConstraintID":3,"IndexID":3,"IsUnique":true,"SourceIndexID":1,"TableID":106}} │ ├── AddColumnToIndex {"ColumnID":1,"IndexID":3,"TableID":106} - │ ├── AddColumnToIndex {"ColumnID":2,"IndexID":3,"Kind":2,"TableID":106} - │ ├── AddColumnToIndex {"ColumnID":1,"IndexID":2,"TableID":106} - │ └── AddColumnToIndex {"ColumnID":2,"IndexID":2,"Kind":2,"TableID":106} + │ └── AddColumnToIndex {"ColumnID":2,"IndexID":3,"Kind":2,"TableID":106} ├── PreCommitPhase │ └── Stage 1 of 1 in PreCommitPhase │ └── 3 Mutation operations @@ -101,14 +101,15 @@ Schema change plan for ALTER TABLE ‹db›.‹public›.‹tbl› ADD COLUMN │ │ ├── WRITE_ONLY → PUBLIC Column:{DescID: 106, ColumnID: 2} │ │ ├── VALIDATED → PUBLIC PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} - │ ├── 1 element transitioning toward TRANSIENT_ABSENT - │ │ └── WRITE_ONLY → TRANSIENT_DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} - │ └── 11 Mutation operations + │ ├── 3 elements transitioning toward TRANSIENT_ABSENT + │ │ ├── WRITE_ONLY → TRANSIENT_DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → TRANSIENT_ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ └── PUBLIC → TRANSIENT_ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ └── 10 Mutation operations │ ├── MakeDroppedPrimaryIndexDeleteAndWriteOnly {"IndexID":1,"TableID":106} │ ├── SetIndexName {"IndexID":1,"Name":"crdb_internal_in...","TableID":106} │ ├── SetIndexName {"IndexID":2,"Name":"tbl_pkey","TableID":106} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":1,"TableID":106} │ ├── MakeAddedPrimaryIndexPublic {"IndexID":2,"TableID":106} │ ├── MakeColumnPublic {"ColumnID":2,"TableID":106} │ ├── RefreshStats {"TableID":106} @@ -117,20 +118,20 @@ Schema change plan for ALTER TABLE ‹db›.‹public›.‹tbl› ADD COLUMN │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} ├── Stage 2 of 3 in PostCommitNonRevertiblePhase │ ├── 1 element transitioning toward ABSENT - │ │ └── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} - │ └── 4 Mutation operations + │ │ └── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} + │ ├── 1 element transitioning toward TRANSIENT_ABSENT + │ │ └── TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ └── 6 Mutation operations │ ├── MakeDroppedIndexDeleteOnly {"IndexID":1,"TableID":106} + │ ├── CreateGcJobForIndex {"IndexID":3,"TableID":106} + │ ├── MakeIndexAbsent {"IndexID":3,"TableID":106} │ ├── SetJobStateOnDescriptor {"DescriptorID":106} │ ├── SetJobStateOnDescriptor {"DescriptorID":107} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} └── Stage 3 of 3 in PostCommitNonRevertiblePhase ├── 1 element transitioning toward ABSENT - │ └── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} - ├── 1 element transitioning toward TRANSIENT_ABSENT - │ └── TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} - └── 7 Mutation operations - ├── CreateGcJobForIndex {"IndexID":3,"TableID":106} - ├── MakeIndexAbsent {"IndexID":3,"TableID":106} + │ └── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} + └── 5 Mutation operations ├── CreateGcJobForIndex {"IndexID":1,"TableID":106} ├── MakeIndexAbsent {"IndexID":1,"TableID":106} ├── RemoveJobStateFromDescriptor {"DescriptorID":106} diff --git a/pkg/sql/schemachanger/testdata/explain/add_column_default_seq.rollback_1_of_7 b/pkg/sql/schemachanger/testdata/explain/add_column_default_seq.rollback_1_of_7 index bcc4a7f5bd7a..956b45abd38b 100644 --- a/pkg/sql/schemachanger/testdata/explain/add_column_default_seq.rollback_1_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/add_column_default_seq.rollback_1_of_7 @@ -15,18 +15,14 @@ Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD CO │ ├── PUBLIC → ABSENT ColumnName:{DescID: 106, Name: l, ColumnID: 2} │ ├── PUBLIC → ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 2} │ ├── PUBLIC → ABSENT ColumnDefaultExpression:{DescID: 106, ColumnID: 2} + │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} - │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ ├── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} │ └── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} - └── 15 Mutation operations + └── 11 Mutation operations ├── SetColumnName {"ColumnID":2,"Name":"crdb_internal_co...","TableID":106} - ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":106} - ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"Kind":2,"TableID":106} - ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":106} - ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"Kind":2,"TableID":106} ├── CreateGcJobForIndex {"IndexID":2,"TableID":106} ├── MakeIndexAbsent {"IndexID":2,"TableID":106} ├── CreateGcJobForIndex {"IndexID":3,"TableID":106} diff --git a/pkg/sql/schemachanger/testdata/explain/add_column_default_seq.rollback_2_of_7 b/pkg/sql/schemachanger/testdata/explain/add_column_default_seq.rollback_2_of_7 index ec041187e77f..7f7ebf49ab23 100644 --- a/pkg/sql/schemachanger/testdata/explain/add_column_default_seq.rollback_2_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/add_column_default_seq.rollback_2_of_7 @@ -13,20 +13,16 @@ Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD CO │ ├── 8 elements transitioning toward ABSENT │ │ ├── WRITE_ONLY → DELETE_ONLY Column:{DescID: 106, ColumnID: 2} │ │ ├── PUBLIC → ABSENT ColumnName:{DescID: 106, Name: l, ColumnID: 2} + │ │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} - │ │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} - │ └── 12 Mutation operations + │ └── 8 Mutation operations │ ├── MakeDroppedColumnDeleteOnly {"ColumnID":2,"TableID":106} │ ├── SetColumnName {"ColumnID":2,"Name":"crdb_internal_co...","TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"Kind":2,"TableID":106} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"Kind":2,"TableID":106} │ ├── CreateGcJobForIndex {"IndexID":2,"TableID":106} │ ├── MakeIndexAbsent {"IndexID":2,"TableID":106} │ ├── SetJobStateOnDescriptor {"DescriptorID":106} diff --git a/pkg/sql/schemachanger/testdata/explain/add_column_default_seq.rollback_3_of_7 b/pkg/sql/schemachanger/testdata/explain/add_column_default_seq.rollback_3_of_7 index 30fb9f81ad9d..b5cde4b28f7f 100644 --- a/pkg/sql/schemachanger/testdata/explain/add_column_default_seq.rollback_3_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/add_column_default_seq.rollback_3_of_7 @@ -13,20 +13,16 @@ Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD CO │ ├── 8 elements transitioning toward ABSENT │ │ ├── WRITE_ONLY → DELETE_ONLY Column:{DescID: 106, ColumnID: 2} │ │ ├── PUBLIC → ABSENT ColumnName:{DescID: 106, Name: l, ColumnID: 2} + │ │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} - │ │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} - │ └── 12 Mutation operations + │ └── 8 Mutation operations │ ├── MakeDroppedColumnDeleteOnly {"ColumnID":2,"TableID":106} │ ├── SetColumnName {"ColumnID":2,"Name":"crdb_internal_co...","TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"Kind":2,"TableID":106} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"Kind":2,"TableID":106} │ ├── CreateGcJobForIndex {"IndexID":2,"TableID":106} │ ├── MakeIndexAbsent {"IndexID":2,"TableID":106} │ ├── SetJobStateOnDescriptor {"DescriptorID":106} diff --git a/pkg/sql/schemachanger/testdata/explain/add_column_default_seq.rollback_4_of_7 b/pkg/sql/schemachanger/testdata/explain/add_column_default_seq.rollback_4_of_7 index 263e3a89a30f..446b4004875f 100644 --- a/pkg/sql/schemachanger/testdata/explain/add_column_default_seq.rollback_4_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/add_column_default_seq.rollback_4_of_7 @@ -13,22 +13,18 @@ Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD CO │ ├── 8 elements transitioning toward ABSENT │ │ ├── WRITE_ONLY → DELETE_ONLY Column:{DescID: 106, ColumnID: 2} │ │ ├── PUBLIC → ABSENT ColumnName:{DescID: 106, Name: l, ColumnID: 2} + │ │ ├── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} - │ │ ├── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} - │ └── 12 Mutation operations + │ └── 8 Mutation operations │ ├── MakeDroppedColumnDeleteOnly {"ColumnID":2,"TableID":106} │ ├── SetColumnName {"ColumnID":2,"Name":"crdb_internal_co...","TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"Kind":2,"TableID":106} + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":106} │ ├── CreateGcJobForIndex {"IndexID":2,"TableID":106} │ ├── MakeIndexAbsent {"IndexID":2,"TableID":106} - │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"Kind":2,"TableID":106} │ ├── SetJobStateOnDescriptor {"DescriptorID":106} │ ├── SetJobStateOnDescriptor {"DescriptorID":107} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} diff --git a/pkg/sql/schemachanger/testdata/explain/add_column_default_seq.rollback_5_of_7 b/pkg/sql/schemachanger/testdata/explain/add_column_default_seq.rollback_5_of_7 index a86f78fb9256..ee85ad0b8e76 100644 --- a/pkg/sql/schemachanger/testdata/explain/add_column_default_seq.rollback_5_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/add_column_default_seq.rollback_5_of_7 @@ -13,20 +13,16 @@ Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD CO │ ├── 8 elements transitioning toward ABSENT │ │ ├── WRITE_ONLY → DELETE_ONLY Column:{DescID: 106, ColumnID: 2} │ │ ├── PUBLIC → ABSENT ColumnName:{DescID: 106, Name: l, ColumnID: 2} + │ │ ├── MERGE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} - │ │ ├── MERGE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} - │ └── 11 Mutation operations + │ └── 7 Mutation operations │ ├── MakeDroppedColumnDeleteOnly {"ColumnID":2,"TableID":106} │ ├── SetColumnName {"ColumnID":2,"Name":"crdb_internal_co...","TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"Kind":2,"TableID":106} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"Kind":2,"TableID":106} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":2,"TableID":106} │ ├── SetJobStateOnDescriptor {"DescriptorID":106} │ ├── SetJobStateOnDescriptor {"DescriptorID":107} diff --git a/pkg/sql/schemachanger/testdata/explain/add_column_default_seq.rollback_6_of_7 b/pkg/sql/schemachanger/testdata/explain/add_column_default_seq.rollback_6_of_7 index d57463cd80b3..f164087de2ea 100644 --- a/pkg/sql/schemachanger/testdata/explain/add_column_default_seq.rollback_6_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/add_column_default_seq.rollback_6_of_7 @@ -13,20 +13,16 @@ Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD CO │ ├── 8 elements transitioning toward ABSENT │ │ ├── WRITE_ONLY → DELETE_ONLY Column:{DescID: 106, ColumnID: 2} │ │ ├── PUBLIC → ABSENT ColumnName:{DescID: 106, Name: l, ColumnID: 2} + │ │ ├── MERGE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} - │ │ ├── MERGE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} - │ └── 11 Mutation operations + │ └── 7 Mutation operations │ ├── MakeDroppedColumnDeleteOnly {"ColumnID":2,"TableID":106} │ ├── SetColumnName {"ColumnID":2,"Name":"crdb_internal_co...","TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"Kind":2,"TableID":106} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"Kind":2,"TableID":106} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":2,"TableID":106} │ ├── SetJobStateOnDescriptor {"DescriptorID":106} │ ├── SetJobStateOnDescriptor {"DescriptorID":107} diff --git a/pkg/sql/schemachanger/testdata/explain/add_column_default_seq.rollback_7_of_7 b/pkg/sql/schemachanger/testdata/explain/add_column_default_seq.rollback_7_of_7 index 1373c73cb9cc..9c8bc0b98e97 100644 --- a/pkg/sql/schemachanger/testdata/explain/add_column_default_seq.rollback_7_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/add_column_default_seq.rollback_7_of_7 @@ -13,21 +13,17 @@ Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD CO │ ├── 8 elements transitioning toward ABSENT │ │ ├── WRITE_ONLY → DELETE_ONLY Column:{DescID: 106, ColumnID: 2} │ │ ├── PUBLIC → ABSENT ColumnName:{DescID: 106, Name: l, ColumnID: 2} + │ │ ├── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} - │ │ ├── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} - │ └── 11 Mutation operations + │ └── 7 Mutation operations │ ├── MakeDroppedColumnDeleteOnly {"ColumnID":2,"TableID":106} │ ├── SetColumnName {"ColumnID":2,"Name":"crdb_internal_co...","TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"Kind":2,"TableID":106} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":2,"TableID":106} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"Kind":2,"TableID":106} │ ├── SetJobStateOnDescriptor {"DescriptorID":106} │ ├── SetJobStateOnDescriptor {"DescriptorID":107} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} diff --git a/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid new file mode 100644 index 000000000000..be4e49446701 --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid @@ -0,0 +1,211 @@ +/* setup */ +CREATE TABLE t (a INT NOT NULL); + +/* test */ +EXPLAIN (ddl) ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a); +---- +Schema change plan for ALTER TABLE ‹defaultdb›.‹public›.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›); + ├── StatementPhase + │ └── Stage 1 of 1 in StatementPhase + │ ├── 2 elements transitioning toward ABSENT + │ │ ├── PUBLIC → WRITE_ONLY Column:{DescID: 104, ColumnID: 2} + │ │ └── PUBLIC → ABSENT ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ ├── 2 elements transitioning toward PUBLIC + │ │ ├── ABSENT → BACKFILL_ONLY PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ └── ABSENT → PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ ├── 6 elements transitioning toward TRANSIENT_ABSENT + │ │ ├── ABSENT → BACKFILL_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ ├── ABSENT → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ └── ABSENT → PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ └── 11 Mutation operations + │ ├── MakeDroppedColumnDeleteAndWriteOnly {"ColumnID":2,"TableID":104} + │ ├── LogEvent {"TargetStatus":1} + │ ├── SetColumnName {"ColumnID":2,"Name":"crdb_internal_co...","TableID":104} + │ ├── MakeAddedIndexBackfilling {"Index":{"ConstraintID":2,"IndexID":2,"IsUnique":true,"SourceIndexID":1,"TableID":104,"TemporaryIndexID":3}} + │ ├── AddColumnToIndex {"ColumnID":1,"IndexID":2,"TableID":104} + │ ├── AddColumnToIndex {"ColumnID":2,"IndexID":2,"Kind":2,"TableID":104} + │ ├── MakeAddedTempIndexDeleteOnly {"Index":{"ConstraintID":3,"IndexID":3,"IsUnique":true,"SourceIndexID":1,"TableID":104}} + │ ├── AddColumnToIndex {"ColumnID":1,"IndexID":3,"TableID":104} + │ ├── AddColumnToIndex {"ColumnID":2,"IndexID":3,"Kind":2,"TableID":104} + │ ├── MakeAddedIndexBackfilling {"Index":{"ConstraintID":4,"IndexID":4,"IsUnique":true,"SourceIndexID":2,"TableID":104,"TemporaryIndexID":5}} + │ └── AddColumnToIndex {"ColumnID":1,"IndexID":4,"TableID":104} + ├── PreCommitPhase + │ └── Stage 1 of 1 in PreCommitPhase + │ └── 2 Mutation operations + │ ├── SetJobStateOnDescriptor {"DescriptorID":104,"Initialize":true} + │ └── CreateSchemaChangerJob {"RunningStatus":"PostCommitPhase ..."} + ├── PostCommitPhase + │ ├── Stage 1 of 15 in PostCommitPhase + │ │ ├── 1 element transitioning toward TRANSIENT_ABSENT + │ │ │ └── DELETE_ONLY → WRITE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ └── 3 Mutation operations + │ │ ├── MakeAddedIndexDeleteAndWriteOnly {"IndexID":3,"TableID":104} + │ │ ├── SetJobStateOnDescriptor {"DescriptorID":104} + │ │ └── UpdateSchemaChangerJob {"RunningStatus":"PostCommitPhase ..."} + │ ├── Stage 2 of 15 in PostCommitPhase + │ │ ├── 1 element transitioning toward TRANSIENT_ABSENT + │ │ │ └── BACKFILL_ONLY → BACKFILLED PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ └── 1 Backfill operation + │ │ └── BackfillIndex {"IndexID":2,"SourceIndexID":1,"TableID":104} + │ ├── Stage 3 of 15 in PostCommitPhase + │ │ ├── 1 element transitioning toward TRANSIENT_ABSENT + │ │ │ └── BACKFILLED → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ └── 3 Mutation operations + │ │ ├── MakeBackfillingIndexDeleteOnly {"IndexID":2,"TableID":104} + │ │ ├── SetJobStateOnDescriptor {"DescriptorID":104} + │ │ └── UpdateSchemaChangerJob {"RunningStatus":"PostCommitPhase ..."} + │ ├── Stage 4 of 15 in PostCommitPhase + │ │ ├── 1 element transitioning toward TRANSIENT_ABSENT + │ │ │ └── DELETE_ONLY → MERGE_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ └── 3 Mutation operations + │ │ ├── MakeBackfilledIndexMerging {"IndexID":2,"TableID":104} + │ │ ├── SetJobStateOnDescriptor {"DescriptorID":104} + │ │ └── UpdateSchemaChangerJob {"RunningStatus":"PostCommitPhase ..."} + │ ├── Stage 5 of 15 in PostCommitPhase + │ │ ├── 1 element transitioning toward TRANSIENT_ABSENT + │ │ │ └── MERGE_ONLY → MERGED PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ └── 1 Backfill operation + │ │ └── MergeIndex {"BackfilledIndexID":2,"TableID":104,"TemporaryIndexID":3} + │ ├── Stage 6 of 15 in PostCommitPhase + │ │ ├── 1 element transitioning toward TRANSIENT_ABSENT + │ │ │ └── MERGED → WRITE_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ └── 3 Mutation operations + │ │ ├── MakeMergedIndexWriteOnly {"IndexID":2,"TableID":104} + │ │ ├── SetJobStateOnDescriptor {"DescriptorID":104} + │ │ └── UpdateSchemaChangerJob {"RunningStatus":"PostCommitPhase ..."} + │ ├── Stage 7 of 15 in PostCommitPhase + │ │ ├── 1 element transitioning toward TRANSIENT_ABSENT + │ │ │ └── WRITE_ONLY → VALIDATED PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ └── 1 Validation operation + │ │ └── ValidateUniqueIndex {"IndexID":2,"TableID":104} + │ ├── Stage 8 of 15 in PostCommitPhase + │ │ ├── 2 elements transitioning toward ABSENT + │ │ │ ├── PUBLIC → VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ │ └── PUBLIC → ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} + │ │ ├── 4 elements transitioning toward TRANSIENT_ABSENT + │ │ │ ├── VALIDATED → PUBLIC PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ ├── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ │ ├── ABSENT → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2} + │ │ │ └── ABSENT → PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} + │ │ └── 8 Mutation operations + │ │ ├── MakeDroppedPrimaryIndexDeleteAndWriteOnly {"IndexID":1,"TableID":104} + │ │ ├── SetIndexName {"IndexID":1,"Name":"crdb_internal_in...","TableID":104} + │ │ ├── SetIndexName {"IndexID":2,"Name":"t_pkey","TableID":104} + │ │ ├── MakeAddedPrimaryIndexPublic {"IndexID":2,"TableID":104} + │ │ ├── MakeAddedTempIndexDeleteOnly {"Index":{"ConstraintID":5,"IndexID":5,"IsUnique":true,"SourceIndexID":2,"TableID":104}} + │ │ ├── AddColumnToIndex {"ColumnID":1,"IndexID":5,"TableID":104} + │ │ ├── SetJobStateOnDescriptor {"DescriptorID":104} + │ │ └── UpdateSchemaChangerJob {"RunningStatus":"PostCommitPhase ..."} + │ ├── Stage 9 of 15 in PostCommitPhase + │ │ ├── 1 element transitioning toward TRANSIENT_ABSENT + │ │ │ └── DELETE_ONLY → WRITE_ONLY TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2} + │ │ └── 3 Mutation operations + │ │ ├── MakeAddedIndexDeleteAndWriteOnly {"IndexID":5,"TableID":104} + │ │ ├── SetJobStateOnDescriptor {"DescriptorID":104} + │ │ └── UpdateSchemaChangerJob {"RunningStatus":"PostCommitPhase ..."} + │ ├── Stage 10 of 15 in PostCommitPhase + │ │ ├── 1 element transitioning toward PUBLIC + │ │ │ └── BACKFILL_ONLY → BACKFILLED PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ └── 1 Backfill operation + │ │ └── BackfillIndex {"IndexID":4,"SourceIndexID":2,"TableID":104} + │ ├── Stage 11 of 15 in PostCommitPhase + │ │ ├── 1 element transitioning toward PUBLIC + │ │ │ └── BACKFILLED → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ └── 3 Mutation operations + │ │ ├── MakeBackfillingIndexDeleteOnly {"IndexID":4,"TableID":104} + │ │ ├── SetJobStateOnDescriptor {"DescriptorID":104} + │ │ └── UpdateSchemaChangerJob {"RunningStatus":"PostCommitPhase ..."} + │ ├── Stage 12 of 15 in PostCommitPhase + │ │ ├── 1 element transitioning toward PUBLIC + │ │ │ └── DELETE_ONLY → MERGE_ONLY PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ └── 3 Mutation operations + │ │ ├── MakeBackfilledIndexMerging {"IndexID":4,"TableID":104} + │ │ ├── SetJobStateOnDescriptor {"DescriptorID":104} + │ │ └── UpdateSchemaChangerJob {"RunningStatus":"PostCommitPhase ..."} + │ ├── Stage 13 of 15 in PostCommitPhase + │ │ ├── 1 element transitioning toward PUBLIC + │ │ │ └── MERGE_ONLY → MERGED PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ └── 1 Backfill operation + │ │ └── MergeIndex {"BackfilledIndexID":4,"TableID":104,"TemporaryIndexID":5} + │ ├── Stage 14 of 15 in PostCommitPhase + │ │ ├── 1 element transitioning toward PUBLIC + │ │ │ └── MERGED → WRITE_ONLY PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ └── 3 Mutation operations + │ │ ├── MakeMergedIndexWriteOnly {"IndexID":4,"TableID":104} + │ │ ├── SetJobStateOnDescriptor {"DescriptorID":104} + │ │ └── UpdateSchemaChangerJob {"RunningStatus":"PostCommitPhase ..."} + │ └── Stage 15 of 15 in PostCommitPhase + │ ├── 1 element transitioning toward PUBLIC + │ │ └── WRITE_ONLY → VALIDATED PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ └── 1 Validation operation + │ └── ValidateUniqueIndex {"IndexID":4,"TableID":104} + └── PostCommitNonRevertiblePhase + ├── Stage 1 of 4 in PostCommitNonRevertiblePhase + │ ├── 4 elements transitioning toward ABSENT + │ │ ├── WRITE_ONLY → DELETE_ONLY Column:{DescID: 104, ColumnID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1} + │ │ └── VALIDATED → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ ├── 5 elements transitioning toward TRANSIENT_ABSENT + │ │ ├── WRITE_ONLY → TRANSIENT_DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → TRANSIENT_ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ ├── PUBLIC → TRANSIENT_ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ ├── WRITE_ONLY → TRANSIENT_DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2} + │ │ └── PUBLIC → TRANSIENT_ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} + │ └── 6 Mutation operations + │ ├── MakeDroppedColumnDeleteOnly {"ColumnID":2,"TableID":104} + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":5,"TableID":104} + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":1,"TableID":104} + │ ├── SetJobStateOnDescriptor {"DescriptorID":104} + │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} + ├── Stage 2 of 4 in PostCommitNonRevertiblePhase + │ ├── 1 element transitioning toward ABSENT + │ │ └── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ ├── 2 elements transitioning toward PUBLIC + │ │ ├── VALIDATED → PUBLIC PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 4} + │ ├── 6 elements transitioning toward TRANSIENT_ABSENT + │ │ ├── PUBLIC → TRANSIENT_WRITE_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → TRANSIENT_ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ ├── PUBLIC → TRANSIENT_ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ ├── PUBLIC → TRANSIENT_ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ ├── TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ └── TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2} + │ └── 12 Mutation operations + │ ├── CreateGcJobForIndex {"IndexID":1,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":1,"TableID":104} + │ ├── MakeDroppedPrimaryIndexDeleteAndWriteOnly {"IndexID":2,"TableID":104} + │ ├── SetIndexName {"IndexID":2,"Name":"crdb_internal_in...","TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":3,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":3,"TableID":104} + │ ├── SetIndexName {"IndexID":4,"Name":"t_pkey","TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":5,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":5,"TableID":104} + │ ├── MakeAddedPrimaryIndexPublic {"IndexID":4,"TableID":104} + │ ├── SetJobStateOnDescriptor {"DescriptorID":104} + │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} + ├── Stage 3 of 4 in PostCommitNonRevertiblePhase + │ ├── 1 element transitioning toward TRANSIENT_ABSENT + │ │ └── TRANSIENT_WRITE_ONLY → TRANSIENT_DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ └── 3 Mutation operations + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":2,"TableID":104} + │ ├── SetJobStateOnDescriptor {"DescriptorID":104} + │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} + └── Stage 4 of 4 in PostCommitNonRevertiblePhase + ├── 3 elements transitioning toward ABSENT + │ ├── DELETE_ONLY → ABSENT Column:{DescID: 104, ColumnID: 2} + │ ├── PUBLIC → ABSENT ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ └── PUBLIC → ABSENT ColumnDefaultExpression:{DescID: 104, ColumnID: 2} + ├── 1 element transitioning toward TRANSIENT_ABSENT + │ └── TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + └── 6 Mutation operations + ├── CreateGcJobForIndex {"IndexID":2,"TableID":104} + ├── MakeIndexAbsent {"IndexID":2,"TableID":104} + ├── RemoveColumnDefaultExpression {"ColumnID":2,"TableID":104} + ├── MakeColumnAbsent {"ColumnID":2,"TableID":104} + ├── RemoveJobStateFromDescriptor {"DescriptorID":104} + └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"all stages compl..."} diff --git a/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_10_of_15 b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_10_of_15 new file mode 100644 index 000000000000..c46321d34ef6 --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_10_of_15 @@ -0,0 +1,62 @@ +/* setup */ +CREATE TABLE t (a INT NOT NULL); + +/* test */ +ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a); +EXPLAIN (ddl) rollback at post-commit stage 10 of 15; +---- +Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›); + └── PostCommitNonRevertiblePhase + ├── Stage 1 of 3 in PostCommitNonRevertiblePhase + │ ├── 11 elements transitioning toward ABSENT + │ │ ├── PUBLIC → WRITE_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2} + │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} + │ ├── 4 elements transitioning toward PUBLIC + │ │ ├── WRITE_ONLY → PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ │ ├── VALIDATED → PUBLIC PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} + │ └── 13 Mutation operations + │ ├── SetColumnName {"ColumnID":2,"Name":"rowid","TableID":104} + │ ├── SetIndexName {"IndexID":1,"Name":"t_pkey","TableID":104} + │ ├── MakeDroppedPrimaryIndexDeleteAndWriteOnly {"IndexID":2,"TableID":104} + │ ├── SetIndexName {"IndexID":2,"Name":"crdb_internal_in...","TableID":104} + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":5,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} + │ ├── MakeAddedPrimaryIndexPublic {"IndexID":1,"TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":4,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":4,"TableID":104} + │ ├── SetJobStateOnDescriptor {"DescriptorID":104} + │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} + ├── Stage 2 of 3 in PostCommitNonRevertiblePhase + │ ├── 3 elements transitioning toward ABSENT + │ │ ├── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ └── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2} + │ └── 7 Mutation operations + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":2,"TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":3,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":3,"TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":5,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":5,"TableID":104} + │ ├── SetJobStateOnDescriptor {"DescriptorID":104} + │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} + └── Stage 3 of 3 in PostCommitNonRevertiblePhase + ├── 1 element transitioning toward ABSENT + │ └── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + └── 4 Mutation operations + ├── CreateGcJobForIndex {"IndexID":2,"TableID":104} + ├── MakeIndexAbsent {"IndexID":2,"TableID":104} + ├── RemoveJobStateFromDescriptor {"DescriptorID":104} + └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"all stages compl..."} diff --git a/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_11_of_15 b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_11_of_15 new file mode 100644 index 000000000000..7adcc9b13c16 --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_11_of_15 @@ -0,0 +1,62 @@ +/* setup */ +CREATE TABLE t (a INT NOT NULL); + +/* test */ +ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a); +EXPLAIN (ddl) rollback at post-commit stage 11 of 15; +---- +Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›); + └── PostCommitNonRevertiblePhase + ├── Stage 1 of 3 in PostCommitNonRevertiblePhase + │ ├── 11 elements transitioning toward ABSENT + │ │ ├── PUBLIC → WRITE_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2} + │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} + │ ├── 4 elements transitioning toward PUBLIC + │ │ ├── WRITE_ONLY → PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ │ ├── VALIDATED → PUBLIC PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} + │ └── 13 Mutation operations + │ ├── SetColumnName {"ColumnID":2,"Name":"rowid","TableID":104} + │ ├── SetIndexName {"IndexID":1,"Name":"t_pkey","TableID":104} + │ ├── MakeDroppedPrimaryIndexDeleteAndWriteOnly {"IndexID":2,"TableID":104} + │ ├── SetIndexName {"IndexID":2,"Name":"crdb_internal_in...","TableID":104} + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":5,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} + │ ├── MakeAddedPrimaryIndexPublic {"IndexID":1,"TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":4,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":4,"TableID":104} + │ ├── SetJobStateOnDescriptor {"DescriptorID":104} + │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} + ├── Stage 2 of 3 in PostCommitNonRevertiblePhase + │ ├── 3 elements transitioning toward ABSENT + │ │ ├── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ └── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2} + │ └── 7 Mutation operations + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":2,"TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":3,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":3,"TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":5,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":5,"TableID":104} + │ ├── SetJobStateOnDescriptor {"DescriptorID":104} + │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} + └── Stage 3 of 3 in PostCommitNonRevertiblePhase + ├── 1 element transitioning toward ABSENT + │ └── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + └── 4 Mutation operations + ├── CreateGcJobForIndex {"IndexID":2,"TableID":104} + ├── MakeIndexAbsent {"IndexID":2,"TableID":104} + ├── RemoveJobStateFromDescriptor {"DescriptorID":104} + └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"all stages compl..."} diff --git a/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_12_of_15 b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_12_of_15 new file mode 100644 index 000000000000..aa8ef1e3a521 --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_12_of_15 @@ -0,0 +1,62 @@ +/* setup */ +CREATE TABLE t (a INT NOT NULL); + +/* test */ +ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a); +EXPLAIN (ddl) rollback at post-commit stage 12 of 15; +---- +Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›); + └── PostCommitNonRevertiblePhase + ├── Stage 1 of 3 in PostCommitNonRevertiblePhase + │ ├── 11 elements transitioning toward ABSENT + │ │ ├── PUBLIC → WRITE_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ ├── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2} + │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} + │ ├── 4 elements transitioning toward PUBLIC + │ │ ├── WRITE_ONLY → PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ │ ├── VALIDATED → PUBLIC PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} + │ └── 13 Mutation operations + │ ├── SetColumnName {"ColumnID":2,"Name":"rowid","TableID":104} + │ ├── SetIndexName {"IndexID":1,"Name":"t_pkey","TableID":104} + │ ├── MakeDroppedPrimaryIndexDeleteAndWriteOnly {"IndexID":2,"TableID":104} + │ ├── SetIndexName {"IndexID":2,"Name":"crdb_internal_in...","TableID":104} + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":5,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} + │ ├── MakeAddedPrimaryIndexPublic {"IndexID":1,"TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":4,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":4,"TableID":104} + │ ├── SetJobStateOnDescriptor {"DescriptorID":104} + │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} + ├── Stage 2 of 3 in PostCommitNonRevertiblePhase + │ ├── 3 elements transitioning toward ABSENT + │ │ ├── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ └── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2} + │ └── 7 Mutation operations + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":2,"TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":3,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":3,"TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":5,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":5,"TableID":104} + │ ├── SetJobStateOnDescriptor {"DescriptorID":104} + │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} + └── Stage 3 of 3 in PostCommitNonRevertiblePhase + ├── 1 element transitioning toward ABSENT + │ └── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + └── 4 Mutation operations + ├── CreateGcJobForIndex {"IndexID":2,"TableID":104} + ├── MakeIndexAbsent {"IndexID":2,"TableID":104} + ├── RemoveJobStateFromDescriptor {"DescriptorID":104} + └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"all stages compl..."} diff --git a/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_13_of_15 b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_13_of_15 new file mode 100644 index 000000000000..61b554a7bd61 --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_13_of_15 @@ -0,0 +1,64 @@ +/* setup */ +CREATE TABLE t (a INT NOT NULL); + +/* test */ +ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a); +EXPLAIN (ddl) rollback at post-commit stage 13 of 15; +---- +Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›); + └── PostCommitNonRevertiblePhase + ├── Stage 1 of 3 in PostCommitNonRevertiblePhase + │ ├── 11 elements transitioning toward ABSENT + │ │ ├── PUBLIC → WRITE_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ ├── MERGE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2} + │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} + │ ├── 4 elements transitioning toward PUBLIC + │ │ ├── WRITE_ONLY → PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ │ ├── VALIDATED → PUBLIC PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} + │ └── 12 Mutation operations + │ ├── SetColumnName {"ColumnID":2,"Name":"rowid","TableID":104} + │ ├── SetIndexName {"IndexID":1,"Name":"t_pkey","TableID":104} + │ ├── MakeDroppedPrimaryIndexDeleteAndWriteOnly {"IndexID":2,"TableID":104} + │ ├── SetIndexName {"IndexID":2,"Name":"crdb_internal_in...","TableID":104} + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":5,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} + │ ├── MakeAddedPrimaryIndexPublic {"IndexID":1,"TableID":104} + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} + │ ├── SetJobStateOnDescriptor {"DescriptorID":104} + │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} + ├── Stage 2 of 3 in PostCommitNonRevertiblePhase + │ ├── 4 elements transitioning toward ABSENT + │ │ ├── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ └── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2} + │ └── 9 Mutation operations + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":2,"TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":3,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":3,"TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":4,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":4,"TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":5,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":5,"TableID":104} + │ ├── SetJobStateOnDescriptor {"DescriptorID":104} + │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} + └── Stage 3 of 3 in PostCommitNonRevertiblePhase + ├── 1 element transitioning toward ABSENT + │ └── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + └── 4 Mutation operations + ├── CreateGcJobForIndex {"IndexID":2,"TableID":104} + ├── MakeIndexAbsent {"IndexID":2,"TableID":104} + ├── RemoveJobStateFromDescriptor {"DescriptorID":104} + └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"all stages compl..."} diff --git a/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_14_of_15 b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_14_of_15 new file mode 100644 index 000000000000..b5c5a97284fd --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_14_of_15 @@ -0,0 +1,64 @@ +/* setup */ +CREATE TABLE t (a INT NOT NULL); + +/* test */ +ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a); +EXPLAIN (ddl) rollback at post-commit stage 14 of 15; +---- +Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›); + └── PostCommitNonRevertiblePhase + ├── Stage 1 of 3 in PostCommitNonRevertiblePhase + │ ├── 11 elements transitioning toward ABSENT + │ │ ├── PUBLIC → WRITE_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ ├── MERGE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2} + │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} + │ ├── 4 elements transitioning toward PUBLIC + │ │ ├── WRITE_ONLY → PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ │ ├── VALIDATED → PUBLIC PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} + │ └── 12 Mutation operations + │ ├── SetColumnName {"ColumnID":2,"Name":"rowid","TableID":104} + │ ├── SetIndexName {"IndexID":1,"Name":"t_pkey","TableID":104} + │ ├── MakeDroppedPrimaryIndexDeleteAndWriteOnly {"IndexID":2,"TableID":104} + │ ├── SetIndexName {"IndexID":2,"Name":"crdb_internal_in...","TableID":104} + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":5,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} + │ ├── MakeAddedPrimaryIndexPublic {"IndexID":1,"TableID":104} + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} + │ ├── SetJobStateOnDescriptor {"DescriptorID":104} + │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} + ├── Stage 2 of 3 in PostCommitNonRevertiblePhase + │ ├── 4 elements transitioning toward ABSENT + │ │ ├── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ └── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2} + │ └── 9 Mutation operations + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":2,"TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":3,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":3,"TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":4,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":4,"TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":5,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":5,"TableID":104} + │ ├── SetJobStateOnDescriptor {"DescriptorID":104} + │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} + └── Stage 3 of 3 in PostCommitNonRevertiblePhase + ├── 1 element transitioning toward ABSENT + │ └── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + └── 4 Mutation operations + ├── CreateGcJobForIndex {"IndexID":2,"TableID":104} + ├── MakeIndexAbsent {"IndexID":2,"TableID":104} + ├── RemoveJobStateFromDescriptor {"DescriptorID":104} + └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"all stages compl..."} diff --git a/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_15_of_15 b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_15_of_15 new file mode 100644 index 000000000000..3cbc8eac266d --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_15_of_15 @@ -0,0 +1,64 @@ +/* setup */ +CREATE TABLE t (a INT NOT NULL); + +/* test */ +ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a); +EXPLAIN (ddl) rollback at post-commit stage 15 of 15; +---- +Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›); + └── PostCommitNonRevertiblePhase + ├── Stage 1 of 3 in PostCommitNonRevertiblePhase + │ ├── 11 elements transitioning toward ABSENT + │ │ ├── PUBLIC → WRITE_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ ├── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2} + │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} + │ ├── 4 elements transitioning toward PUBLIC + │ │ ├── WRITE_ONLY → PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ │ ├── VALIDATED → PUBLIC PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} + │ └── 12 Mutation operations + │ ├── SetColumnName {"ColumnID":2,"Name":"rowid","TableID":104} + │ ├── SetIndexName {"IndexID":1,"Name":"t_pkey","TableID":104} + │ ├── MakeDroppedPrimaryIndexDeleteAndWriteOnly {"IndexID":2,"TableID":104} + │ ├── SetIndexName {"IndexID":2,"Name":"crdb_internal_in...","TableID":104} + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":5,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} + │ ├── MakeAddedPrimaryIndexPublic {"IndexID":1,"TableID":104} + │ ├── SetJobStateOnDescriptor {"DescriptorID":104} + │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} + ├── Stage 2 of 3 in PostCommitNonRevertiblePhase + │ ├── 4 elements transitioning toward ABSENT + │ │ ├── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ └── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2} + │ └── 9 Mutation operations + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":2,"TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":3,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":3,"TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":4,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":4,"TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":5,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":5,"TableID":104} + │ ├── SetJobStateOnDescriptor {"DescriptorID":104} + │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} + └── Stage 3 of 3 in PostCommitNonRevertiblePhase + ├── 1 element transitioning toward ABSENT + │ └── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + └── 4 Mutation operations + ├── CreateGcJobForIndex {"IndexID":2,"TableID":104} + ├── MakeIndexAbsent {"IndexID":2,"TableID":104} + ├── RemoveJobStateFromDescriptor {"DescriptorID":104} + └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"all stages compl..."} diff --git a/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_1_of_15 b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_1_of_15 new file mode 100644 index 000000000000..278d404a265d --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_1_of_15 @@ -0,0 +1,34 @@ +/* setup */ +CREATE TABLE t (a INT NOT NULL); + +/* test */ +ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a); +EXPLAIN (ddl) rollback at post-commit stage 1 of 15; +---- +Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›); + └── PostCommitNonRevertiblePhase + └── Stage 1 of 1 in PostCommitNonRevertiblePhase + ├── 8 elements transitioning toward ABSENT + │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ ├── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + ├── 2 elements transitioning toward PUBLIC + │ ├── WRITE_ONLY → PUBLIC Column:{DescID: 104, ColumnID: 2} + │ └── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + └── 11 Mutation operations + ├── SetColumnName {"ColumnID":2,"Name":"rowid","TableID":104} + ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + ├── RefreshStats {"TableID":104} + ├── CreateGcJobForIndex {"IndexID":2,"TableID":104} + ├── MakeIndexAbsent {"IndexID":2,"TableID":104} + ├── CreateGcJobForIndex {"IndexID":3,"TableID":104} + ├── MakeIndexAbsent {"IndexID":3,"TableID":104} + ├── CreateGcJobForIndex {"IndexID":4,"TableID":104} + ├── MakeIndexAbsent {"IndexID":4,"TableID":104} + ├── RemoveJobStateFromDescriptor {"DescriptorID":104} + └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"all stages compl..."} diff --git a/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_2_of_15 b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_2_of_15 new file mode 100644 index 000000000000..9615729cabde --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_2_of_15 @@ -0,0 +1,41 @@ +/* setup */ +CREATE TABLE t (a INT NOT NULL); + +/* test */ +ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a); +EXPLAIN (ddl) rollback at post-commit stage 2 of 15; +---- +Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›); + └── PostCommitNonRevertiblePhase + ├── Stage 1 of 2 in PostCommitNonRevertiblePhase + │ ├── 8 elements transitioning toward ABSENT + │ │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ ├── 2 elements transitioning toward PUBLIC + │ │ ├── WRITE_ONLY → PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ └── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ └── 10 Mutation operations + │ ├── SetColumnName {"ColumnID":2,"Name":"rowid","TableID":104} + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":2,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":2,"TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":4,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":4,"TableID":104} + │ ├── SetJobStateOnDescriptor {"DescriptorID":104} + │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} + └── Stage 2 of 2 in PostCommitNonRevertiblePhase + ├── 1 element transitioning toward ABSENT + │ └── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + └── 4 Mutation operations + ├── CreateGcJobForIndex {"IndexID":3,"TableID":104} + ├── MakeIndexAbsent {"IndexID":3,"TableID":104} + ├── RemoveJobStateFromDescriptor {"DescriptorID":104} + └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"all stages compl..."} diff --git a/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_3_of_15 b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_3_of_15 new file mode 100644 index 000000000000..8d1339a76f05 --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_3_of_15 @@ -0,0 +1,41 @@ +/* setup */ +CREATE TABLE t (a INT NOT NULL); + +/* test */ +ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a); +EXPLAIN (ddl) rollback at post-commit stage 3 of 15; +---- +Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›); + └── PostCommitNonRevertiblePhase + ├── Stage 1 of 2 in PostCommitNonRevertiblePhase + │ ├── 8 elements transitioning toward ABSENT + │ │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ ├── 2 elements transitioning toward PUBLIC + │ │ ├── WRITE_ONLY → PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ └── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ └── 10 Mutation operations + │ ├── SetColumnName {"ColumnID":2,"Name":"rowid","TableID":104} + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":2,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":2,"TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":4,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":4,"TableID":104} + │ ├── SetJobStateOnDescriptor {"DescriptorID":104} + │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} + └── Stage 2 of 2 in PostCommitNonRevertiblePhase + ├── 1 element transitioning toward ABSENT + │ └── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + └── 4 Mutation operations + ├── CreateGcJobForIndex {"IndexID":3,"TableID":104} + ├── MakeIndexAbsent {"IndexID":3,"TableID":104} + ├── RemoveJobStateFromDescriptor {"DescriptorID":104} + └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"all stages compl..."} diff --git a/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_4_of_15 b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_4_of_15 new file mode 100644 index 000000000000..6a9198a9f45c --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_4_of_15 @@ -0,0 +1,41 @@ +/* setup */ +CREATE TABLE t (a INT NOT NULL); + +/* test */ +ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a); +EXPLAIN (ddl) rollback at post-commit stage 4 of 15; +---- +Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›); + └── PostCommitNonRevertiblePhase + ├── Stage 1 of 2 in PostCommitNonRevertiblePhase + │ ├── 8 elements transitioning toward ABSENT + │ │ ├── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ ├── 2 elements transitioning toward PUBLIC + │ │ ├── WRITE_ONLY → PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ └── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ └── 10 Mutation operations + │ ├── SetColumnName {"ColumnID":2,"Name":"rowid","TableID":104} + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":2,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":2,"TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":4,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":4,"TableID":104} + │ ├── SetJobStateOnDescriptor {"DescriptorID":104} + │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} + └── Stage 2 of 2 in PostCommitNonRevertiblePhase + ├── 1 element transitioning toward ABSENT + │ └── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + └── 4 Mutation operations + ├── CreateGcJobForIndex {"IndexID":3,"TableID":104} + ├── MakeIndexAbsent {"IndexID":3,"TableID":104} + ├── RemoveJobStateFromDescriptor {"DescriptorID":104} + └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"all stages compl..."} diff --git a/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_5_of_15 b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_5_of_15 new file mode 100644 index 000000000000..12c92622463c --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_5_of_15 @@ -0,0 +1,43 @@ +/* setup */ +CREATE TABLE t (a INT NOT NULL); + +/* test */ +ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a); +EXPLAIN (ddl) rollback at post-commit stage 5 of 15; +---- +Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›); + └── PostCommitNonRevertiblePhase + ├── Stage 1 of 2 in PostCommitNonRevertiblePhase + │ ├── 8 elements transitioning toward ABSENT + │ │ ├── MERGE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ ├── 2 elements transitioning toward PUBLIC + │ │ ├── WRITE_ONLY → PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ └── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ └── 9 Mutation operations + │ ├── SetColumnName {"ColumnID":2,"Name":"rowid","TableID":104} + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":2,"TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":4,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":4,"TableID":104} + │ ├── SetJobStateOnDescriptor {"DescriptorID":104} + │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} + └── Stage 2 of 2 in PostCommitNonRevertiblePhase + ├── 2 elements transitioning toward ABSENT + │ ├── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ └── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + └── 6 Mutation operations + ├── CreateGcJobForIndex {"IndexID":2,"TableID":104} + ├── MakeIndexAbsent {"IndexID":2,"TableID":104} + ├── CreateGcJobForIndex {"IndexID":3,"TableID":104} + ├── MakeIndexAbsent {"IndexID":3,"TableID":104} + ├── RemoveJobStateFromDescriptor {"DescriptorID":104} + └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"all stages compl..."} diff --git a/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_6_of_15 b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_6_of_15 new file mode 100644 index 000000000000..61cc5bb17586 --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_6_of_15 @@ -0,0 +1,43 @@ +/* setup */ +CREATE TABLE t (a INT NOT NULL); + +/* test */ +ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a); +EXPLAIN (ddl) rollback at post-commit stage 6 of 15; +---- +Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›); + └── PostCommitNonRevertiblePhase + ├── Stage 1 of 2 in PostCommitNonRevertiblePhase + │ ├── 8 elements transitioning toward ABSENT + │ │ ├── MERGE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ ├── 2 elements transitioning toward PUBLIC + │ │ ├── WRITE_ONLY → PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ └── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ └── 9 Mutation operations + │ ├── SetColumnName {"ColumnID":2,"Name":"rowid","TableID":104} + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":2,"TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":4,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":4,"TableID":104} + │ ├── SetJobStateOnDescriptor {"DescriptorID":104} + │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} + └── Stage 2 of 2 in PostCommitNonRevertiblePhase + ├── 2 elements transitioning toward ABSENT + │ ├── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ └── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + └── 6 Mutation operations + ├── CreateGcJobForIndex {"IndexID":2,"TableID":104} + ├── MakeIndexAbsent {"IndexID":2,"TableID":104} + ├── CreateGcJobForIndex {"IndexID":3,"TableID":104} + ├── MakeIndexAbsent {"IndexID":3,"TableID":104} + ├── RemoveJobStateFromDescriptor {"DescriptorID":104} + └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"all stages compl..."} diff --git a/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_7_of_15 b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_7_of_15 new file mode 100644 index 000000000000..9530cc6ebb4a --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_7_of_15 @@ -0,0 +1,43 @@ +/* setup */ +CREATE TABLE t (a INT NOT NULL); + +/* test */ +ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a); +EXPLAIN (ddl) rollback at post-commit stage 7 of 15; +---- +Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›); + └── PostCommitNonRevertiblePhase + ├── Stage 1 of 2 in PostCommitNonRevertiblePhase + │ ├── 8 elements transitioning toward ABSENT + │ │ ├── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ ├── 2 elements transitioning toward PUBLIC + │ │ ├── WRITE_ONLY → PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ └── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ └── 9 Mutation operations + │ ├── SetColumnName {"ColumnID":2,"Name":"rowid","TableID":104} + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":2,"TableID":104} + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":4,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":4,"TableID":104} + │ ├── SetJobStateOnDescriptor {"DescriptorID":104} + │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} + └── Stage 2 of 2 in PostCommitNonRevertiblePhase + ├── 2 elements transitioning toward ABSENT + │ ├── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ └── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + └── 6 Mutation operations + ├── CreateGcJobForIndex {"IndexID":2,"TableID":104} + ├── MakeIndexAbsent {"IndexID":2,"TableID":104} + ├── CreateGcJobForIndex {"IndexID":3,"TableID":104} + ├── MakeIndexAbsent {"IndexID":3,"TableID":104} + ├── RemoveJobStateFromDescriptor {"DescriptorID":104} + └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"all stages compl..."} diff --git a/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_8_of_15 b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_8_of_15 new file mode 100644 index 000000000000..c88c0d45f98b --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_8_of_15 @@ -0,0 +1,43 @@ +/* setup */ +CREATE TABLE t (a INT NOT NULL); + +/* test */ +ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a); +EXPLAIN (ddl) rollback at post-commit stage 8 of 15; +---- +Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›); + └── PostCommitNonRevertiblePhase + ├── Stage 1 of 2 in PostCommitNonRevertiblePhase + │ ├── 8 elements transitioning toward ABSENT + │ │ ├── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ ├── 2 elements transitioning toward PUBLIC + │ │ ├── WRITE_ONLY → PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ └── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ └── 9 Mutation operations + │ ├── SetColumnName {"ColumnID":2,"Name":"rowid","TableID":104} + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":2,"TableID":104} + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":4,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":4,"TableID":104} + │ ├── SetJobStateOnDescriptor {"DescriptorID":104} + │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} + └── Stage 2 of 2 in PostCommitNonRevertiblePhase + ├── 2 elements transitioning toward ABSENT + │ ├── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ └── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + └── 6 Mutation operations + ├── CreateGcJobForIndex {"IndexID":2,"TableID":104} + ├── MakeIndexAbsent {"IndexID":2,"TableID":104} + ├── CreateGcJobForIndex {"IndexID":3,"TableID":104} + ├── MakeIndexAbsent {"IndexID":3,"TableID":104} + ├── RemoveJobStateFromDescriptor {"DescriptorID":104} + └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"all stages compl..."} diff --git a/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_9_of_15 b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_9_of_15 new file mode 100644 index 000000000000..eb5df4ea76fd --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_9_of_15 @@ -0,0 +1,60 @@ +/* setup */ +CREATE TABLE t (a INT NOT NULL); + +/* test */ +ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a); +EXPLAIN (ddl) rollback at post-commit stage 9 of 15; +---- +Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›); + └── PostCommitNonRevertiblePhase + ├── Stage 1 of 3 in PostCommitNonRevertiblePhase + │ ├── 11 elements transitioning toward ABSENT + │ │ ├── PUBLIC → WRITE_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ ├── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2} + │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} + │ ├── 4 elements transitioning toward PUBLIC + │ │ ├── WRITE_ONLY → PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ │ ├── VALIDATED → PUBLIC PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} + │ └── 14 Mutation operations + │ ├── SetColumnName {"ColumnID":2,"Name":"rowid","TableID":104} + │ ├── SetIndexName {"IndexID":1,"Name":"t_pkey","TableID":104} + │ ├── MakeDroppedPrimaryIndexDeleteAndWriteOnly {"IndexID":2,"TableID":104} + │ ├── SetIndexName {"IndexID":2,"Name":"crdb_internal_in...","TableID":104} + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} + │ ├── MakeAddedPrimaryIndexPublic {"IndexID":1,"TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":4,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":4,"TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":5,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":5,"TableID":104} + │ ├── SetJobStateOnDescriptor {"DescriptorID":104} + │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} + ├── Stage 2 of 3 in PostCommitNonRevertiblePhase + │ ├── 2 elements transitioning toward ABSENT + │ │ ├── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ └── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ └── 5 Mutation operations + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":2,"TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":3,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":3,"TableID":104} + │ ├── SetJobStateOnDescriptor {"DescriptorID":104} + │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} + └── Stage 3 of 3 in PostCommitNonRevertiblePhase + ├── 1 element transitioning toward ABSENT + │ └── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + └── 4 Mutation operations + ├── CreateGcJobForIndex {"IndexID":2,"TableID":104} + ├── MakeIndexAbsent {"IndexID":2,"TableID":104} + ├── RemoveJobStateFromDescriptor {"DescriptorID":104} + └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"all stages compl..."} diff --git a/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_vanilla b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_vanilla index 311f27474488..b3cd5c6552b4 100644 --- a/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_vanilla +++ b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_vanilla @@ -7,22 +7,24 @@ EXPLAIN (ddl) ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (j); Schema change plan for ALTER TABLE ‹defaultdb›.‹public›.‹t› ALTER PRIMARY KEY USING COLUMNS (‹j›); ├── StatementPhase │ └── Stage 1 of 1 in StatementPhase - │ ├── 10 elements transitioning toward PUBLIC + │ ├── 8 elements transitioning toward PUBLIC + │ │ ├── ABSENT → BACKFILL_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} - │ │ ├── ABSENT → BACKFILL_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} - │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ ├── ABSENT → BACKFILL_ONLY SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1} │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 4} │ │ └── ABSENT → PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 5} - │ ├── 2 elements transitioning toward TRANSIENT_ABSENT + │ ├── 4 elements transitioning toward TRANSIENT_ABSENT │ │ ├── ABSENT → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ └── ABSENT → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 1} │ └── 12 Mutation operations │ ├── MakeAddedIndexBackfilling {"Index":{"ConstraintID":2,"IndexID":2,"IsUnique":true,"SourceIndexID":1,"TableID":104,"TemporaryIndexID":3}} + │ ├── AddColumnToIndex {"ColumnID":2,"IndexID":2,"TableID":104} + │ ├── AddColumnToIndex {"ColumnID":1,"IndexID":2,"Kind":2,"TableID":104} │ ├── MakeAddedTempIndexDeleteOnly {"Index":{"ConstraintID":3,"IndexID":3,"IsUnique":true,"SourceIndexID":1,"TableID":104}} │ ├── AddColumnToIndex {"ColumnID":2,"IndexID":3,"TableID":104} │ ├── AddColumnToIndex {"ColumnID":1,"IndexID":3,"Kind":2,"TableID":104} @@ -31,9 +33,7 @@ Schema change plan for ALTER TABLE ‹defaultdb›.‹public›.‹t› ALTER PR │ ├── AddColumnToIndex {"ColumnID":1,"IndexID":4,"TableID":104} │ ├── AddColumnToIndex {"ColumnID":1,"IndexID":5,"TableID":104} │ ├── AddColumnToIndex {"ColumnID":2,"IndexID":4,"Kind":1,"TableID":104} - │ ├── AddColumnToIndex {"ColumnID":2,"IndexID":5,"Kind":1,"TableID":104} - │ ├── AddColumnToIndex {"ColumnID":2,"IndexID":2,"TableID":104} - │ └── AddColumnToIndex {"ColumnID":1,"IndexID":2,"Kind":2,"TableID":104} + │ └── AddColumnToIndex {"ColumnID":2,"IndexID":5,"Kind":1,"TableID":104} ├── PreCommitPhase │ └── Stage 1 of 1 in PreCommitPhase │ └── 2 Mutation operations @@ -109,40 +109,40 @@ Schema change plan for ALTER TABLE ‹defaultdb›.‹public›.‹t› ALTER PR │ │ ├── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} │ │ ├── VALIDATED → PUBLIC SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_i_key, IndexID: 4} - │ ├── 2 elements transitioning toward TRANSIENT_ABSENT + │ ├── 4 elements transitioning toward TRANSIENT_ABSENT │ │ ├── WRITE_ONLY → TRANSIENT_DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → TRANSIENT_ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ ├── PUBLIC → TRANSIENT_ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ └── WRITE_ONLY → TRANSIENT_DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 1} - │ └── 12 Mutation operations + │ └── 10 Mutation operations │ ├── MakeDroppedPrimaryIndexDeleteAndWriteOnly {"IndexID":1,"TableID":104} │ ├── SetIndexName {"IndexID":1,"Name":"crdb_internal_in...","TableID":104} │ ├── SetIndexName {"IndexID":2,"Name":"t_pkey","TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":5,"TableID":104} │ ├── SetIndexName {"IndexID":4,"Name":"t_i_key","TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":1,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":1,"Kind":2,"TableID":104} │ ├── MakeAddedPrimaryIndexPublic {"IndexID":2,"TableID":104} │ ├── MakeAddedSecondaryIndexPublic {"IndexID":4,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} ├── Stage 2 of 3 in PostCommitNonRevertiblePhase │ ├── 1 element transitioning toward ABSENT - │ │ └── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ └── 3 Mutation operations + │ │ └── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ ├── 2 elements transitioning toward TRANSIENT_ABSENT + │ │ ├── TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ └── TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 1} + │ └── 7 Mutation operations │ ├── MakeDroppedIndexDeleteOnly {"IndexID":1,"TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":3,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":3,"TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":5,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":5,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} └── Stage 3 of 3 in PostCommitNonRevertiblePhase ├── 1 element transitioning toward ABSENT - │ └── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - ├── 2 elements transitioning toward TRANSIENT_ABSENT - │ ├── TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} - │ └── TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 1} - └── 8 Mutation operations - ├── CreateGcJobForIndex {"IndexID":3,"TableID":104} - ├── MakeIndexAbsent {"IndexID":3,"TableID":104} - ├── CreateGcJobForIndex {"IndexID":5,"TableID":104} - ├── MakeIndexAbsent {"IndexID":5,"TableID":104} + │ └── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + └── 4 Mutation operations ├── CreateGcJobForIndex {"IndexID":1,"TableID":104} ├── MakeIndexAbsent {"IndexID":1,"TableID":104} ├── RemoveJobStateFromDescriptor {"DescriptorID":104} diff --git a/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_vanilla.rollback_1_of_7 b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_vanilla.rollback_1_of_7 index 5474c3ddc60f..0050550107ac 100644 --- a/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_vanilla.rollback_1_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_vanilla.rollback_1_of_7 @@ -9,9 +9,9 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› A └── PostCommitNonRevertiblePhase └── Stage 1 of 1 in PostCommitNonRevertiblePhase ├── 12 elements transitioning toward ABSENT + │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} - │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ ├── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} @@ -21,15 +21,7 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› A │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 4} │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 5} - └── 19 Mutation operations - ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"TableID":104} - ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"Kind":2,"TableID":104} - ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"TableID":104} - ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"Kind":2,"TableID":104} - ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} - ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":5,"TableID":104} - ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":4,"Kind":1,"TableID":104} - ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":5,"Kind":1,"TableID":104} + └── 11 Mutation operations ├── CreateGcJobForIndex {"IndexID":2,"TableID":104} ├── MakeIndexAbsent {"IndexID":2,"TableID":104} ├── CreateGcJobForIndex {"IndexID":3,"TableID":104} diff --git a/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_vanilla.rollback_2_of_7 b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_vanilla.rollback_2_of_7 index 3907dbb33395..08741c5e1573 100644 --- a/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_vanilla.rollback_2_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_vanilla.rollback_2_of_7 @@ -9,9 +9,9 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› A └── PostCommitNonRevertiblePhase ├── Stage 1 of 2 in PostCommitNonRevertiblePhase │ ├── 12 elements transitioning toward ABSENT + │ │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} - │ │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} @@ -21,17 +21,9 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› A │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 4} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 5} - │ └── 17 Mutation operations - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"Kind":2,"TableID":104} + │ └── 9 Mutation operations │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"Kind":2,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":5,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":5,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":4,"Kind":1,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":5,"Kind":1,"TableID":104} │ ├── CreateGcJobForIndex {"IndexID":2,"TableID":104} │ ├── MakeIndexAbsent {"IndexID":2,"TableID":104} │ ├── LogEvent {"TargetStatus":1} diff --git a/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_vanilla.rollback_3_of_7 b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_vanilla.rollback_3_of_7 index a8830f455bb4..a477b89983cb 100644 --- a/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_vanilla.rollback_3_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_vanilla.rollback_3_of_7 @@ -9,9 +9,9 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› A └── PostCommitNonRevertiblePhase ├── Stage 1 of 2 in PostCommitNonRevertiblePhase │ ├── 12 elements transitioning toward ABSENT + │ │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} - │ │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} @@ -21,17 +21,9 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› A │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 4} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 5} - │ └── 17 Mutation operations - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"Kind":2,"TableID":104} + │ └── 9 Mutation operations │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"Kind":2,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":5,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":5,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":4,"Kind":1,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":5,"Kind":1,"TableID":104} │ ├── CreateGcJobForIndex {"IndexID":2,"TableID":104} │ ├── MakeIndexAbsent {"IndexID":2,"TableID":104} │ ├── LogEvent {"TargetStatus":1} diff --git a/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_vanilla.rollback_4_of_7 b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_vanilla.rollback_4_of_7 index bf3f6376dad3..3e97d46c591b 100644 --- a/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_vanilla.rollback_4_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_vanilla.rollback_4_of_7 @@ -9,9 +9,9 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› A └── PostCommitNonRevertiblePhase ├── Stage 1 of 2 in PostCommitNonRevertiblePhase │ ├── 12 elements transitioning toward ABSENT + │ │ ├── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} - │ │ ├── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} @@ -21,19 +21,11 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› A │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 4} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 5} - │ └── 17 Mutation operations - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"Kind":2,"TableID":104} - │ ├── CreateGcJobForIndex {"IndexID":2,"TableID":104} - │ ├── MakeIndexAbsent {"IndexID":2,"TableID":104} + │ └── 9 Mutation operations │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"Kind":2,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":5,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":5,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":4,"Kind":1,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":5,"Kind":1,"TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":2,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":2,"TableID":104} │ ├── LogEvent {"TargetStatus":1} │ ├── CreateGcJobForIndex {"IndexID":4,"TableID":104} │ ├── MakeIndexAbsent {"IndexID":4,"TableID":104} diff --git a/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_vanilla.rollback_5_of_7 b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_vanilla.rollback_5_of_7 index bc2605f0ae45..d7d214061585 100644 --- a/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_vanilla.rollback_5_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_vanilla.rollback_5_of_7 @@ -9,9 +9,9 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› A └── PostCommitNonRevertiblePhase ├── Stage 1 of 2 in PostCommitNonRevertiblePhase │ ├── 12 elements transitioning toward ABSENT + │ │ ├── MERGE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} - │ │ ├── MERGE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} @@ -21,19 +21,11 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› A │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 4} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 5} - │ └── 14 Mutation operations - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"Kind":2,"TableID":104} + │ └── 6 Mutation operations │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"Kind":2,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":5,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":5,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":5,"Kind":1,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":2,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":4,"Kind":1,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} └── Stage 2 of 2 in PostCommitNonRevertiblePhase diff --git a/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_vanilla.rollback_6_of_7 b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_vanilla.rollback_6_of_7 index 25de2db00b87..a0612068f966 100644 --- a/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_vanilla.rollback_6_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_vanilla.rollback_6_of_7 @@ -9,9 +9,9 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› A └── PostCommitNonRevertiblePhase ├── Stage 1 of 2 in PostCommitNonRevertiblePhase │ ├── 12 elements transitioning toward ABSENT + │ │ ├── MERGE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} - │ │ ├── MERGE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} @@ -21,19 +21,11 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› A │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 4} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 5} - │ └── 14 Mutation operations - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"Kind":2,"TableID":104} + │ └── 6 Mutation operations │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"Kind":2,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":5,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":5,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":5,"Kind":1,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":2,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":4,"Kind":1,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} └── Stage 2 of 2 in PostCommitNonRevertiblePhase diff --git a/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_vanilla.rollback_7_of_7 b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_vanilla.rollback_7_of_7 index 21589c50473d..0bbf403f591c 100644 --- a/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_vanilla.rollback_7_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_vanilla.rollback_7_of_7 @@ -9,9 +9,9 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› A └── PostCommitNonRevertiblePhase ├── Stage 1 of 2 in PostCommitNonRevertiblePhase │ ├── 12 elements transitioning toward ABSENT + │ │ ├── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} - │ │ ├── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} @@ -21,19 +21,11 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› A │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 4} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 5} - │ └── 14 Mutation operations - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"Kind":2,"TableID":104} + │ └── 6 Mutation operations │ ├── MakeDroppedIndexDeleteOnly {"IndexID":2,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"Kind":2,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":5,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":5,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":4,"Kind":1,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":5,"Kind":1,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} └── Stage 2 of 2 in PostCommitNonRevertiblePhase diff --git a/pkg/sql/schemachanger/testdata/explain/create_index.rollback_1_of_7 b/pkg/sql/schemachanger/testdata/explain/create_index.rollback_1_of_7 index 965cdd95f67e..475b000a707a 100644 --- a/pkg/sql/schemachanger/testdata/explain/create_index.rollback_1_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/create_index.rollback_1_of_7 @@ -16,11 +16,7 @@ Schema change plan for rolling back CREATE INDEX ‹idx1› ON ‹defaultdb›.p │ ├── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 0, SourceIndexID: 1} │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} │ └── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} - └── 11 Mutation operations - ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"TableID":106} - ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"Kind":1,"TableID":106} - ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"TableID":106} - ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"Kind":1,"TableID":106} + └── 7 Mutation operations ├── LogEvent {"TargetStatus":1} ├── CreateGcJobForIndex {"IndexID":2,"TableID":106} ├── MakeIndexAbsent {"IndexID":2,"TableID":106} diff --git a/pkg/sql/schemachanger/testdata/explain/create_index.rollback_2_of_7 b/pkg/sql/schemachanger/testdata/explain/create_index.rollback_2_of_7 index ca0ce448ea7c..061f15d2e6b3 100644 --- a/pkg/sql/schemachanger/testdata/explain/create_index.rollback_2_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/create_index.rollback_2_of_7 @@ -16,12 +16,8 @@ Schema change plan for rolling back CREATE INDEX ‹idx1› ON ‹defaultdb›.p │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 0, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} - │ └── 10 Mutation operations + │ └── 6 Mutation operations │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"Kind":1,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"Kind":1,"TableID":106} │ ├── LogEvent {"TargetStatus":1} │ ├── CreateGcJobForIndex {"IndexID":2,"TableID":106} │ ├── MakeIndexAbsent {"IndexID":2,"TableID":106} diff --git a/pkg/sql/schemachanger/testdata/explain/create_index.rollback_3_of_7 b/pkg/sql/schemachanger/testdata/explain/create_index.rollback_3_of_7 index f622fd30ad8d..518ff1d8e3a6 100644 --- a/pkg/sql/schemachanger/testdata/explain/create_index.rollback_3_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/create_index.rollback_3_of_7 @@ -16,12 +16,8 @@ Schema change plan for rolling back CREATE INDEX ‹idx1› ON ‹defaultdb›.p │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 0, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} - │ └── 10 Mutation operations + │ └── 6 Mutation operations │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"Kind":1,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"Kind":1,"TableID":106} │ ├── LogEvent {"TargetStatus":1} │ ├── CreateGcJobForIndex {"IndexID":2,"TableID":106} │ ├── MakeIndexAbsent {"IndexID":2,"TableID":106} diff --git a/pkg/sql/schemachanger/testdata/explain/create_index.rollback_4_of_7 b/pkg/sql/schemachanger/testdata/explain/create_index.rollback_4_of_7 index c954da978c74..4e86e70c0732 100644 --- a/pkg/sql/schemachanger/testdata/explain/create_index.rollback_4_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/create_index.rollback_4_of_7 @@ -16,15 +16,11 @@ Schema change plan for rolling back CREATE INDEX ‹idx1› ON ‹defaultdb›.p │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 0, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} - │ └── 10 Mutation operations - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"Kind":1,"TableID":106} + │ └── 6 Mutation operations │ ├── LogEvent {"TargetStatus":1} │ ├── CreateGcJobForIndex {"IndexID":2,"TableID":106} │ ├── MakeIndexAbsent {"IndexID":2,"TableID":106} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"Kind":1,"TableID":106} │ ├── SetJobStateOnDescriptor {"DescriptorID":106} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} └── Stage 2 of 2 in PostCommitNonRevertiblePhase diff --git a/pkg/sql/schemachanger/testdata/explain/create_index.rollback_5_of_7 b/pkg/sql/schemachanger/testdata/explain/create_index.rollback_5_of_7 index a265ab61810a..0e190f923859 100644 --- a/pkg/sql/schemachanger/testdata/explain/create_index.rollback_5_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/create_index.rollback_5_of_7 @@ -16,13 +16,9 @@ Schema change plan for rolling back CREATE INDEX ‹idx1› ON ‹defaultdb›.p │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 0, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} - │ └── 8 Mutation operations + │ └── 4 Mutation operations │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"Kind":1,"TableID":106} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":2,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"Kind":1,"TableID":106} │ ├── SetJobStateOnDescriptor {"DescriptorID":106} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} └── Stage 2 of 2 in PostCommitNonRevertiblePhase diff --git a/pkg/sql/schemachanger/testdata/explain/create_index.rollback_6_of_7 b/pkg/sql/schemachanger/testdata/explain/create_index.rollback_6_of_7 index 604ce83c2443..bec7a0c33b67 100644 --- a/pkg/sql/schemachanger/testdata/explain/create_index.rollback_6_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/create_index.rollback_6_of_7 @@ -16,13 +16,9 @@ Schema change plan for rolling back CREATE INDEX ‹idx1› ON ‹defaultdb›.p │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 0, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} - │ └── 8 Mutation operations + │ └── 4 Mutation operations │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"Kind":1,"TableID":106} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":2,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"Kind":1,"TableID":106} │ ├── SetJobStateOnDescriptor {"DescriptorID":106} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} └── Stage 2 of 2 in PostCommitNonRevertiblePhase diff --git a/pkg/sql/schemachanger/testdata/explain/create_index.rollback_7_of_7 b/pkg/sql/schemachanger/testdata/explain/create_index.rollback_7_of_7 index fe2c4441b96d..94cfaec315ae 100644 --- a/pkg/sql/schemachanger/testdata/explain/create_index.rollback_7_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/create_index.rollback_7_of_7 @@ -16,13 +16,9 @@ Schema change plan for rolling back CREATE INDEX ‹idx1› ON ‹defaultdb›.p │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 0, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} - │ └── 8 Mutation operations + │ └── 4 Mutation operations │ ├── MakeDroppedIndexDeleteOnly {"IndexID":2,"TableID":106} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"Kind":1,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"Kind":1,"TableID":106} │ ├── SetJobStateOnDescriptor {"DescriptorID":106} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} └── Stage 2 of 2 in PostCommitNonRevertiblePhase diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_basic b/pkg/sql/schemachanger/testdata/explain/drop_column_basic index bad337414333..9191bf7214ce 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_basic +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_basic @@ -10,20 +10,20 @@ Schema change plan for ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COL │ ├── 2 elements transitioning toward ABSENT │ │ ├── PUBLIC → WRITE_ONLY Column:{DescID: 104, ColumnID: 2} │ │ └── PUBLIC → ABSENT ColumnName:{DescID: 104, Name: j, ColumnID: 2} - │ ├── 3 elements transitioning toward PUBLIC - │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ ├── 2 elements transitioning toward PUBLIC │ │ ├── ABSENT → BACKFILL_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ └── ABSENT → PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ ├── 2 elements transitioning toward TRANSIENT_ABSENT + │ │ ├── ABSENT → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ └── ABSENT → PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ ├── 1 element transitioning toward TRANSIENT_ABSENT - │ │ └── ABSENT → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ └── 7 Mutation operations │ ├── MakeDroppedColumnDeleteAndWriteOnly {"ColumnID":2,"TableID":104} │ ├── LogEvent {"TargetStatus":1} │ ├── SetColumnName {"ColumnID":2,"Name":"crdb_internal_co...","TableID":104} │ ├── MakeAddedIndexBackfilling {"Index":{"ConstraintID":2,"IndexID":2,"IsUnique":true,"SourceIndexID":1,"TableID":104,"TemporaryIndexID":3}} + │ ├── AddColumnToIndex {"ColumnID":1,"IndexID":2,"TableID":104} │ ├── MakeAddedTempIndexDeleteOnly {"Index":{"ConstraintID":3,"IndexID":3,"IsUnique":true,"SourceIndexID":1,"TableID":104}} - │ ├── AddColumnToIndex {"ColumnID":1,"IndexID":3,"TableID":104} - │ └── AddColumnToIndex {"ColumnID":1,"IndexID":2,"TableID":104} + │ └── AddColumnToIndex {"ColumnID":1,"IndexID":3,"TableID":104} ├── PreCommitPhase │ └── Stage 1 of 1 in PreCommitPhase │ └── 2 Mutation operations @@ -84,36 +84,35 @@ Schema change plan for ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COL │ ├── 2 elements transitioning toward PUBLIC │ │ ├── VALIDATED → PUBLIC PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} - │ ├── 1 element transitioning toward TRANSIENT_ABSENT - │ │ └── WRITE_ONLY → TRANSIENT_DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} - │ └── 10 Mutation operations + │ ├── 2 elements transitioning toward TRANSIENT_ABSENT + │ │ ├── WRITE_ONLY → TRANSIENT_DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ └── PUBLIC → TRANSIENT_ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ └── 8 Mutation operations │ ├── MakeDroppedColumnDeleteOnly {"ColumnID":2,"TableID":104} │ ├── MakeDroppedPrimaryIndexDeleteAndWriteOnly {"IndexID":1,"TableID":104} │ ├── SetIndexName {"IndexID":1,"Name":"crdb_internal_in...","TableID":104} │ ├── SetIndexName {"IndexID":2,"Name":"t_pkey","TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":1,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":1,"Kind":2,"TableID":104} │ ├── MakeAddedPrimaryIndexPublic {"IndexID":2,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} ├── Stage 2 of 3 in PostCommitNonRevertiblePhase │ ├── 1 element transitioning toward ABSENT - │ │ └── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ └── 3 Mutation operations + │ │ └── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ ├── 1 element transitioning toward TRANSIENT_ABSENT + │ │ └── TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ └── 5 Mutation operations │ ├── MakeDroppedIndexDeleteOnly {"IndexID":1,"TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":3,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":3,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} └── Stage 3 of 3 in PostCommitNonRevertiblePhase ├── 3 elements transitioning toward ABSENT - │ ├── DELETE_ONLY → ABSENT Column:{DescID: 104, ColumnID: 2} - │ ├── PUBLIC → ABSENT ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} - │ └── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - ├── 1 element transitioning toward TRANSIENT_ABSENT - │ └── TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} - └── 7 Mutation operations - ├── CreateGcJobForIndex {"IndexID":3,"TableID":104} - ├── MakeIndexAbsent {"IndexID":3,"TableID":104} + │ ├── DELETE_ONLY → ABSENT Column:{DescID: 104, ColumnID: 2} + │ ├── PUBLIC → ABSENT ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ └── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + └── 5 Mutation operations ├── CreateGcJobForIndex {"IndexID":1,"TableID":104} ├── MakeIndexAbsent {"IndexID":1,"TableID":104} ├── MakeColumnAbsent {"ColumnID":2,"TableID":104} diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_basic.rollback_1_of_7 b/pkg/sql/schemachanger/testdata/explain/drop_column_basic.rollback_1_of_7 index da5ee2a9debf..3a3643d03245 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_basic.rollback_1_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_basic.rollback_1_of_7 @@ -9,19 +9,17 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D └── PostCommitNonRevertiblePhase └── Stage 1 of 1 in PostCommitNonRevertiblePhase ├── 4 elements transitioning toward ABSENT - │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ ├── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} ├── 2 elements transitioning toward PUBLIC │ ├── WRITE_ONLY → PUBLIC Column:{DescID: 104, ColumnID: 2} │ └── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} - └── 11 Mutation operations + └── 9 Mutation operations + ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} ├── MakeColumnPublic {"ColumnID":2,"TableID":104} ├── RefreshStats {"TableID":104} - ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} - ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":104} - ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} ├── CreateGcJobForIndex {"IndexID":2,"TableID":104} ├── MakeIndexAbsent {"IndexID":2,"TableID":104} ├── CreateGcJobForIndex {"IndexID":3,"TableID":104} diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_basic.rollback_2_of_7 b/pkg/sql/schemachanger/testdata/explain/drop_column_basic.rollback_2_of_7 index 90ebd364f505..b186f8147827 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_basic.rollback_2_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_basic.rollback_2_of_7 @@ -9,20 +9,18 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D └── PostCommitNonRevertiblePhase ├── Stage 1 of 2 in PostCommitNonRevertiblePhase │ ├── 4 elements transitioning toward ABSENT - │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ ├── 2 elements transitioning toward PUBLIC │ │ ├── WRITE_ONLY → PUBLIC Column:{DescID: 104, ColumnID: 2} │ │ └── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} - │ └── 10 Mutation operations - │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} - │ ├── RefreshStats {"TableID":104} + │ └── 8 Mutation operations │ ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} │ ├── CreateGcJobForIndex {"IndexID":2,"TableID":104} │ ├── MakeIndexAbsent {"IndexID":2,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_basic.rollback_3_of_7 b/pkg/sql/schemachanger/testdata/explain/drop_column_basic.rollback_3_of_7 index bfe619f70c67..3564215441a9 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_basic.rollback_3_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_basic.rollback_3_of_7 @@ -9,20 +9,18 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D └── PostCommitNonRevertiblePhase ├── Stage 1 of 2 in PostCommitNonRevertiblePhase │ ├── 4 elements transitioning toward ABSENT - │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ ├── 2 elements transitioning toward PUBLIC │ │ ├── WRITE_ONLY → PUBLIC Column:{DescID: 104, ColumnID: 2} │ │ └── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} - │ └── 10 Mutation operations - │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} - │ ├── RefreshStats {"TableID":104} + │ └── 8 Mutation operations │ ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} │ ├── CreateGcJobForIndex {"IndexID":2,"TableID":104} │ ├── MakeIndexAbsent {"IndexID":2,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_basic.rollback_4_of_7 b/pkg/sql/schemachanger/testdata/explain/drop_column_basic.rollback_4_of_7 index 068542cd9689..fada25d32582 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_basic.rollback_4_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_basic.rollback_4_of_7 @@ -9,22 +9,20 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D └── PostCommitNonRevertiblePhase ├── Stage 1 of 2 in PostCommitNonRevertiblePhase │ ├── 4 elements transitioning toward ABSENT - │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ ├── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ ├── 2 elements transitioning toward PUBLIC │ │ ├── WRITE_ONLY → PUBLIC Column:{DescID: 104, ColumnID: 2} │ │ └── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} - │ └── 10 Mutation operations + │ └── 8 Mutation operations + │ ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} │ ├── RefreshStats {"TableID":104} - │ ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":104} │ ├── CreateGcJobForIndex {"IndexID":2,"TableID":104} │ ├── MakeIndexAbsent {"IndexID":2,"TableID":104} - │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} └── Stage 2 of 2 in PostCommitNonRevertiblePhase diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_basic.rollback_5_of_7 b/pkg/sql/schemachanger/testdata/explain/drop_column_basic.rollback_5_of_7 index 3d6280970382..2b3854b6a7b4 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_basic.rollback_5_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_basic.rollback_5_of_7 @@ -9,20 +9,18 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D └── PostCommitNonRevertiblePhase ├── Stage 1 of 2 in PostCommitNonRevertiblePhase │ ├── 4 elements transitioning toward ABSENT - │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ ├── MERGE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ ├── 2 elements transitioning toward PUBLIC │ │ ├── WRITE_ONLY → PUBLIC Column:{DescID: 104, ColumnID: 2} │ │ └── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} - │ └── 9 Mutation operations - │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} - │ ├── RefreshStats {"TableID":104} + │ └── 7 Mutation operations │ ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":2,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_basic.rollback_6_of_7 b/pkg/sql/schemachanger/testdata/explain/drop_column_basic.rollback_6_of_7 index d52954b36b7f..800a1818fd39 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_basic.rollback_6_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_basic.rollback_6_of_7 @@ -9,20 +9,18 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D └── PostCommitNonRevertiblePhase ├── Stage 1 of 2 in PostCommitNonRevertiblePhase │ ├── 4 elements transitioning toward ABSENT - │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ ├── MERGE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ ├── 2 elements transitioning toward PUBLIC │ │ ├── WRITE_ONLY → PUBLIC Column:{DescID: 104, ColumnID: 2} │ │ └── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} - │ └── 9 Mutation operations - │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} - │ ├── RefreshStats {"TableID":104} + │ └── 7 Mutation operations │ ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":2,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_basic.rollback_7_of_7 b/pkg/sql/schemachanger/testdata/explain/drop_column_basic.rollback_7_of_7 index 22b07f7e1b39..ed3dd8a6cc16 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_basic.rollback_7_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_basic.rollback_7_of_7 @@ -9,21 +9,19 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D └── PostCommitNonRevertiblePhase ├── Stage 1 of 2 in PostCommitNonRevertiblePhase │ ├── 4 elements transitioning toward ABSENT - │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ ├── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ ├── 2 elements transitioning toward PUBLIC │ │ ├── WRITE_ONLY → PUBLIC Column:{DescID: 104, ColumnID: 2} │ │ └── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} - │ └── 9 Mutation operations - │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} - │ ├── RefreshStats {"TableID":104} + │ └── 7 Mutation operations │ ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":2,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} └── Stage 2 of 2 in PostCommitNonRevertiblePhase diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_computed_index b/pkg/sql/schemachanger/testdata/explain/drop_column_computed_index index 9ef81388a2b0..4bf1f0a25b51 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_computed_index +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_computed_index @@ -14,25 +14,25 @@ Schema change plan for ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COL │ │ ├── PUBLIC → ABSENT ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 3} │ │ ├── PUBLIC → VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ └── PUBLIC → ABSENT IndexName:{DescID: 104, Name: t_expr_idx, IndexID: 2} - │ ├── 3 elements transitioning toward PUBLIC - │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ ├── 2 elements transitioning toward PUBLIC │ │ ├── ABSENT → BACKFILL_ONLY PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} + │ │ └── ABSENT → PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ ├── 2 elements transitioning toward TRANSIENT_ABSENT + │ │ ├── ABSENT → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ │ └── ABSENT → PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ ├── 1 element transitioning toward TRANSIENT_ABSENT - │ │ └── ABSENT → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ └── 12 Mutation operations │ ├── MakeDroppedColumnDeleteAndWriteOnly {"ColumnID":2,"TableID":104} │ ├── LogEvent {"TargetStatus":1} │ ├── SetColumnName {"ColumnID":2,"Name":"crdb_internal_co...","TableID":104} - │ ├── MakeDroppedColumnDeleteAndWriteOnly {"ColumnID":3,"TableID":104} - │ ├── LogEvent {"TargetStatus":1} - │ ├── SetColumnName {"ColumnID":3,"Name":"crdb_internal_co...","TableID":104} │ ├── MakeDroppedNonPrimaryIndexDeleteAndWriteOnly {"IndexID":2,"TableID":104} │ ├── SetIndexName {"IndexID":2,"Name":"crdb_internal_in...","TableID":104} │ ├── MakeAddedIndexBackfilling {"Index":{"ConstraintID":2,"IndexID":3,"IsUnique":true,"SourceIndexID":1,"TableID":104,"TemporaryIndexID":4}} + │ ├── AddColumnToIndex {"ColumnID":1,"IndexID":3,"TableID":104} │ ├── MakeAddedTempIndexDeleteOnly {"Index":{"ConstraintID":3,"IndexID":4,"IsUnique":true,"SourceIndexID":1,"TableID":104}} │ ├── AddColumnToIndex {"ColumnID":1,"IndexID":4,"TableID":104} - │ └── AddColumnToIndex {"ColumnID":1,"IndexID":3,"TableID":104} + │ ├── MakeDroppedColumnDeleteAndWriteOnly {"ColumnID":3,"TableID":104} + │ ├── LogEvent {"TargetStatus":1} + │ └── SetColumnName {"ColumnID":3,"Name":"crdb_internal_co...","TableID":104} ├── PreCommitPhase │ └── Stage 1 of 1 in PreCommitPhase │ └── 2 Mutation operations @@ -97,49 +97,46 @@ Schema change plan for ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COL │ ├── 2 elements transitioning toward PUBLIC │ │ ├── VALIDATED → PUBLIC PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} - │ ├── 1 element transitioning toward TRANSIENT_ABSENT - │ │ └── WRITE_ONLY → TRANSIENT_DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} - │ └── 14 Mutation operations + │ ├── 2 elements transitioning toward TRANSIENT_ABSENT + │ │ ├── WRITE_ONLY → TRANSIENT_DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} + │ │ └── PUBLIC → TRANSIENT_ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ └── 10 Mutation operations │ ├── MakeDroppedColumnDeleteOnly {"ColumnID":2,"TableID":104} │ ├── MakeDroppedColumnDeleteOnly {"ColumnID":3,"TableID":104} │ ├── MakeDroppedPrimaryIndexDeleteAndWriteOnly {"IndexID":1,"TableID":104} │ ├── SetIndexName {"IndexID":1,"Name":"crdb_internal_in...","TableID":104} │ ├── SetIndexName {"IndexID":3,"Name":"t_pkey","TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":1,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":1,"Kind":2,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":2,"TableID":104} │ ├── MakeAddedPrimaryIndexPublic {"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"Kind":1,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} ├── Stage 2 of 3 in PostCommitNonRevertiblePhase - │ ├── 1 element transitioning toward ABSENT - │ │ └── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ └── 3 Mutation operations + │ ├── 4 elements transitioning toward ABSENT + │ │ ├── DELETE_ONLY → ABSENT Column:{DescID: 104, ColumnID: 3} + │ │ ├── PUBLIC → ABSENT ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 3} + │ │ ├── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ └── DELETE_ONLY → ABSENT SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ ├── 1 element transitioning toward TRANSIENT_ABSENT + │ │ └── TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} + │ └── 9 Mutation operations │ ├── MakeDroppedIndexDeleteOnly {"IndexID":1,"TableID":104} + │ ├── LogEvent {"TargetStatus":1} + │ ├── CreateGcJobForIndex {"IndexID":2,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":2,"TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":4,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":4,"TableID":104} + │ ├── MakeColumnAbsent {"ColumnID":3,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} └── Stage 3 of 3 in PostCommitNonRevertiblePhase - ├── 6 elements transitioning toward ABSENT - │ ├── DELETE_ONLY → ABSENT Column:{DescID: 104, ColumnID: 2} - │ ├── PUBLIC → ABSENT ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} - │ ├── DELETE_ONLY → ABSENT Column:{DescID: 104, ColumnID: 3} - │ ├── PUBLIC → ABSENT ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 3} - │ ├── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ └── DELETE_ONLY → ABSENT SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - ├── 1 element transitioning toward TRANSIENT_ABSENT - │ └── TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} - └── 11 Mutation operations - ├── CreateGcJobForIndex {"IndexID":4,"TableID":104} - ├── MakeIndexAbsent {"IndexID":4,"TableID":104} + ├── 3 elements transitioning toward ABSENT + │ ├── DELETE_ONLY → ABSENT Column:{DescID: 104, ColumnID: 2} + │ ├── PUBLIC → ABSENT ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ └── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + └── 5 Mutation operations ├── CreateGcJobForIndex {"IndexID":1,"TableID":104} ├── MakeIndexAbsent {"IndexID":1,"TableID":104} - ├── LogEvent {"TargetStatus":1} - ├── CreateGcJobForIndex {"IndexID":2,"TableID":104} - ├── MakeIndexAbsent {"IndexID":2,"TableID":104} ├── MakeColumnAbsent {"ColumnID":2,"TableID":104} - ├── MakeColumnAbsent {"ColumnID":3,"TableID":104} ├── RemoveJobStateFromDescriptor {"DescriptorID":104} └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"all stages compl..."} diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_computed_index.rollback_1_of_7 b/pkg/sql/schemachanger/testdata/explain/drop_column_computed_index.rollback_1_of_7 index 45bbacee1aeb..61a89e25d4db 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_computed_index.rollback_1_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_computed_index.rollback_1_of_7 @@ -9,8 +9,8 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D └── PostCommitNonRevertiblePhase └── Stage 1 of 1 in PostCommitNonRevertiblePhase ├── 4 elements transitioning toward ABSENT - │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} + │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ ├── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} ├── 6 elements transitioning toward PUBLIC @@ -20,16 +20,14 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 3} │ ├── VALIDATED → PUBLIC SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_expr_idx, IndexID: 2} - └── 16 Mutation operations + └── 14 Mutation operations + ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} + ├── SetColumnName {"ColumnID":3,"Name":"crdb_internal_id...","TableID":104} + ├── SetIndexName {"IndexID":2,"Name":"t_expr_idx","TableID":104} ├── MakeColumnPublic {"ColumnID":2,"TableID":104} ├── RefreshStats {"TableID":104} - ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} ├── MakeColumnPublic {"ColumnID":3,"TableID":104} ├── RefreshStats {"TableID":104} - ├── SetColumnName {"ColumnID":3,"Name":"crdb_internal_id...","TableID":104} - ├── SetIndexName {"IndexID":2,"Name":"t_expr_idx","TableID":104} - ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} - ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} ├── MakeAddedSecondaryIndexPublic {"IndexID":2,"TableID":104} ├── CreateGcJobForIndex {"IndexID":3,"TableID":104} ├── MakeIndexAbsent {"IndexID":3,"TableID":104} diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_computed_index.rollback_2_of_7 b/pkg/sql/schemachanger/testdata/explain/drop_column_computed_index.rollback_2_of_7 index 48f41d426bcf..fade3c656f29 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_computed_index.rollback_2_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_computed_index.rollback_2_of_7 @@ -9,8 +9,8 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D └── PostCommitNonRevertiblePhase ├── Stage 1 of 2 in PostCommitNonRevertiblePhase │ ├── 4 elements transitioning toward ABSENT - │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} │ ├── 6 elements transitioning toward PUBLIC @@ -20,17 +20,15 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 3} │ │ ├── VALIDATED → PUBLIC SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_expr_idx, IndexID: 2} - │ └── 15 Mutation operations - │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} - │ ├── RefreshStats {"TableID":104} + │ └── 13 Mutation operations │ ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} - │ ├── MakeColumnPublic {"ColumnID":3,"TableID":104} - │ ├── RefreshStats {"TableID":104} │ ├── SetColumnName {"ColumnID":3,"Name":"crdb_internal_id...","TableID":104} │ ├── SetIndexName {"IndexID":2,"Name":"t_expr_idx","TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":3,"TableID":104} + │ ├── RefreshStats {"TableID":104} │ ├── MakeAddedSecondaryIndexPublic {"IndexID":2,"TableID":104} │ ├── CreateGcJobForIndex {"IndexID":3,"TableID":104} │ ├── MakeIndexAbsent {"IndexID":3,"TableID":104} diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_computed_index.rollback_3_of_7 b/pkg/sql/schemachanger/testdata/explain/drop_column_computed_index.rollback_3_of_7 index 1dc9c837af89..98789b6951b4 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_computed_index.rollback_3_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_computed_index.rollback_3_of_7 @@ -9,8 +9,8 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D └── PostCommitNonRevertiblePhase ├── Stage 1 of 2 in PostCommitNonRevertiblePhase │ ├── 4 elements transitioning toward ABSENT - │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} │ ├── 6 elements transitioning toward PUBLIC @@ -20,17 +20,15 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 3} │ │ ├── VALIDATED → PUBLIC SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_expr_idx, IndexID: 2} - │ └── 15 Mutation operations - │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} - │ ├── RefreshStats {"TableID":104} + │ └── 13 Mutation operations │ ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} - │ ├── MakeColumnPublic {"ColumnID":3,"TableID":104} - │ ├── RefreshStats {"TableID":104} │ ├── SetColumnName {"ColumnID":3,"Name":"crdb_internal_id...","TableID":104} │ ├── SetIndexName {"IndexID":2,"Name":"t_expr_idx","TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":3,"TableID":104} + │ ├── RefreshStats {"TableID":104} │ ├── MakeAddedSecondaryIndexPublic {"IndexID":2,"TableID":104} │ ├── CreateGcJobForIndex {"IndexID":3,"TableID":104} │ ├── MakeIndexAbsent {"IndexID":3,"TableID":104} diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_computed_index.rollback_4_of_7 b/pkg/sql/schemachanger/testdata/explain/drop_column_computed_index.rollback_4_of_7 index e11207de8a6c..a2c90d2aa915 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_computed_index.rollback_4_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_computed_index.rollback_4_of_7 @@ -9,8 +9,8 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D └── PostCommitNonRevertiblePhase ├── Stage 1 of 2 in PostCommitNonRevertiblePhase │ ├── 4 elements transitioning toward ABSENT - │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ ├── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} │ ├── 6 elements transitioning toward PUBLIC @@ -20,20 +20,18 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 3} │ │ ├── VALIDATED → PUBLIC SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_expr_idx, IndexID: 2} - │ └── 15 Mutation operations + │ └── 13 Mutation operations + │ ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} + │ ├── SetColumnName {"ColumnID":3,"Name":"crdb_internal_id...","TableID":104} + │ ├── SetIndexName {"IndexID":2,"Name":"t_expr_idx","TableID":104} + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} │ ├── RefreshStats {"TableID":104} - │ ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} │ ├── MakeColumnPublic {"ColumnID":3,"TableID":104} │ ├── RefreshStats {"TableID":104} - │ ├── SetColumnName {"ColumnID":3,"Name":"crdb_internal_id...","TableID":104} - │ ├── SetIndexName {"IndexID":2,"Name":"t_expr_idx","TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} + │ ├── MakeAddedSecondaryIndexPublic {"IndexID":2,"TableID":104} │ ├── CreateGcJobForIndex {"IndexID":3,"TableID":104} │ ├── MakeIndexAbsent {"IndexID":3,"TableID":104} - │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} - │ ├── MakeAddedSecondaryIndexPublic {"IndexID":2,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} └── Stage 2 of 2 in PostCommitNonRevertiblePhase diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_computed_index.rollback_5_of_7 b/pkg/sql/schemachanger/testdata/explain/drop_column_computed_index.rollback_5_of_7 index 55a46c2c2e6f..40b4ecd7191a 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_computed_index.rollback_5_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_computed_index.rollback_5_of_7 @@ -9,8 +9,8 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D └── PostCommitNonRevertiblePhase ├── Stage 1 of 2 in PostCommitNonRevertiblePhase │ ├── 4 elements transitioning toward ABSENT - │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ ├── MERGE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} │ ├── 6 elements transitioning toward PUBLIC @@ -20,17 +20,15 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 3} │ │ ├── VALIDATED → PUBLIC SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_expr_idx, IndexID: 2} - │ └── 14 Mutation operations - │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} - │ ├── RefreshStats {"TableID":104} + │ └── 12 Mutation operations │ ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} - │ ├── MakeColumnPublic {"ColumnID":3,"TableID":104} - │ ├── RefreshStats {"TableID":104} │ ├── SetColumnName {"ColumnID":3,"Name":"crdb_internal_id...","TableID":104} │ ├── SetIndexName {"IndexID":2,"Name":"t_expr_idx","TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":3,"TableID":104} + │ ├── RefreshStats {"TableID":104} │ ├── MakeAddedSecondaryIndexPublic {"IndexID":2,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_computed_index.rollback_6_of_7 b/pkg/sql/schemachanger/testdata/explain/drop_column_computed_index.rollback_6_of_7 index ed4e943318a7..4c9fd672dead 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_computed_index.rollback_6_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_computed_index.rollback_6_of_7 @@ -9,8 +9,8 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D └── PostCommitNonRevertiblePhase ├── Stage 1 of 2 in PostCommitNonRevertiblePhase │ ├── 4 elements transitioning toward ABSENT - │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ ├── MERGE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} │ ├── 6 elements transitioning toward PUBLIC @@ -20,17 +20,15 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 3} │ │ ├── VALIDATED → PUBLIC SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_expr_idx, IndexID: 2} - │ └── 14 Mutation operations - │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} - │ ├── RefreshStats {"TableID":104} + │ └── 12 Mutation operations │ ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} - │ ├── MakeColumnPublic {"ColumnID":3,"TableID":104} - │ ├── RefreshStats {"TableID":104} │ ├── SetColumnName {"ColumnID":3,"Name":"crdb_internal_id...","TableID":104} │ ├── SetIndexName {"IndexID":2,"Name":"t_expr_idx","TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":3,"TableID":104} + │ ├── RefreshStats {"TableID":104} │ ├── MakeAddedSecondaryIndexPublic {"IndexID":2,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_computed_index.rollback_7_of_7 b/pkg/sql/schemachanger/testdata/explain/drop_column_computed_index.rollback_7_of_7 index 9c99dccb097c..1291f5f8b041 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_computed_index.rollback_7_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_computed_index.rollback_7_of_7 @@ -9,8 +9,8 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D └── PostCommitNonRevertiblePhase ├── Stage 1 of 2 in PostCommitNonRevertiblePhase │ ├── 4 elements transitioning toward ABSENT - │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ ├── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} │ ├── 6 elements transitioning toward PUBLIC @@ -20,18 +20,16 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 3} │ │ ├── VALIDATED → PUBLIC SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_expr_idx, IndexID: 2} - │ └── 14 Mutation operations - │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} - │ ├── RefreshStats {"TableID":104} + │ └── 12 Mutation operations │ ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} - │ ├── MakeColumnPublic {"ColumnID":3,"TableID":104} - │ ├── RefreshStats {"TableID":104} │ ├── SetColumnName {"ColumnID":3,"Name":"crdb_internal_id...","TableID":104} │ ├── SetIndexName {"IndexID":2,"Name":"t_expr_idx","TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":3,"TableID":104} + │ ├── RefreshStats {"TableID":104} │ ├── MakeAddedSecondaryIndexPublic {"IndexID":2,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_10_of_15 b/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_10_of_15 index 0fc7a4733838..e0aeec5611b8 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_10_of_15 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_10_of_15 @@ -32,14 +32,8 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} - │ └── 27 Mutation operations - │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} - │ ├── RefreshStats {"TableID":104} - │ ├── MakeColumnPublic {"ColumnID":4,"TableID":104} - │ ├── RefreshStats {"TableID":104} + │ └── 19 Mutation operations │ ├── SetIndexName {"IndexID":1,"Name":"t_pkey","TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":4,"Kind":2,"TableID":104} │ ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} │ ├── SetColumnName {"ColumnID":4,"Name":"crdb_internal_id...","TableID":104} │ ├── SetIndexName {"IndexID":2,"Name":"t_expr_k_idx","TableID":104} @@ -47,14 +41,12 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D │ ├── SetIndexName {"IndexID":3,"Name":"crdb_internal_in...","TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":6,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":6,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":6,"Kind":1,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":4,"TableID":104} + │ ├── RefreshStats {"TableID":104} │ ├── MakeAddedPrimaryIndexPublic {"IndexID":1,"TableID":104} │ ├── MakeAddedSecondaryIndexPublic {"IndexID":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":3,"Kind":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":5,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":5,"Kind":1,"TableID":104} │ ├── LogEvent {"TargetStatus":1} │ ├── CreateGcJobForIndex {"IndexID":5,"TableID":104} │ ├── MakeIndexAbsent {"IndexID":5,"TableID":104} diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_11_of_15 b/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_11_of_15 index 14583480b01e..6c67fafa30ca 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_11_of_15 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_11_of_15 @@ -32,14 +32,8 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} - │ └── 27 Mutation operations - │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} - │ ├── RefreshStats {"TableID":104} - │ ├── MakeColumnPublic {"ColumnID":4,"TableID":104} - │ ├── RefreshStats {"TableID":104} + │ └── 19 Mutation operations │ ├── SetIndexName {"IndexID":1,"Name":"t_pkey","TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":4,"Kind":2,"TableID":104} │ ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} │ ├── SetColumnName {"ColumnID":4,"Name":"crdb_internal_id...","TableID":104} │ ├── SetIndexName {"IndexID":2,"Name":"t_expr_k_idx","TableID":104} @@ -47,14 +41,12 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D │ ├── SetIndexName {"IndexID":3,"Name":"crdb_internal_in...","TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":6,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":6,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":6,"Kind":1,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":4,"TableID":104} + │ ├── RefreshStats {"TableID":104} │ ├── MakeAddedPrimaryIndexPublic {"IndexID":1,"TableID":104} │ ├── MakeAddedSecondaryIndexPublic {"IndexID":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":3,"Kind":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":5,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":5,"Kind":1,"TableID":104} │ ├── LogEvent {"TargetStatus":1} │ ├── CreateGcJobForIndex {"IndexID":5,"TableID":104} │ ├── MakeIndexAbsent {"IndexID":5,"TableID":104} diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_12_of_15 b/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_12_of_15 index 5a187aa35de0..10abeb6c1d4d 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_12_of_15 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_12_of_15 @@ -32,32 +32,24 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} - │ └── 27 Mutation operations - │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} - │ ├── RefreshStats {"TableID":104} - │ ├── MakeColumnPublic {"ColumnID":4,"TableID":104} - │ ├── RefreshStats {"TableID":104} + │ └── 19 Mutation operations │ ├── SetIndexName {"IndexID":1,"Name":"t_pkey","TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":4,"Kind":2,"TableID":104} │ ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} │ ├── SetColumnName {"ColumnID":4,"Name":"crdb_internal_id...","TableID":104} │ ├── SetIndexName {"IndexID":2,"Name":"t_expr_k_idx","TableID":104} │ ├── MakeDroppedPrimaryIndexDeleteAndWriteOnly {"IndexID":3,"TableID":104} │ ├── SetIndexName {"IndexID":3,"Name":"crdb_internal_in...","TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":5,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":5,"Kind":1,"TableID":104} │ ├── LogEvent {"TargetStatus":1} │ ├── CreateGcJobForIndex {"IndexID":5,"TableID":104} │ ├── MakeIndexAbsent {"IndexID":5,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":6,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":6,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":6,"Kind":1,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":4,"TableID":104} + │ ├── RefreshStats {"TableID":104} │ ├── MakeAddedPrimaryIndexPublic {"IndexID":1,"TableID":104} │ ├── MakeAddedSecondaryIndexPublic {"IndexID":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":3,"Kind":2,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} ├── Stage 2 of 3 in PostCommitNonRevertiblePhase diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_13_of_15 b/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_13_of_15 index 5e1d58d22296..f4f834b277dd 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_13_of_15 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_13_of_15 @@ -32,14 +32,8 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} - │ └── 25 Mutation operations - │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} - │ ├── RefreshStats {"TableID":104} - │ ├── MakeColumnPublic {"ColumnID":4,"TableID":104} - │ ├── RefreshStats {"TableID":104} + │ └── 17 Mutation operations │ ├── SetIndexName {"IndexID":1,"Name":"t_pkey","TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":4,"Kind":2,"TableID":104} │ ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} │ ├── SetColumnName {"ColumnID":4,"Name":"crdb_internal_id...","TableID":104} │ ├── SetIndexName {"IndexID":2,"Name":"t_expr_k_idx","TableID":104} @@ -47,15 +41,13 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D │ ├── SetIndexName {"IndexID":3,"Name":"crdb_internal_in...","TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":6,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":6,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":6,"Kind":1,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":4,"TableID":104} + │ ├── RefreshStats {"TableID":104} │ ├── MakeAddedPrimaryIndexPublic {"IndexID":1,"TableID":104} │ ├── MakeAddedSecondaryIndexPublic {"IndexID":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":3,"Kind":2,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":5,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":5,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":5,"Kind":1,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} ├── Stage 2 of 3 in PostCommitNonRevertiblePhase diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_14_of_15 b/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_14_of_15 index c92cd656f219..a059869c7d00 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_14_of_15 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_14_of_15 @@ -32,14 +32,8 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} - │ └── 25 Mutation operations - │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} - │ ├── RefreshStats {"TableID":104} - │ ├── MakeColumnPublic {"ColumnID":4,"TableID":104} - │ ├── RefreshStats {"TableID":104} + │ └── 17 Mutation operations │ ├── SetIndexName {"IndexID":1,"Name":"t_pkey","TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":4,"Kind":2,"TableID":104} │ ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} │ ├── SetColumnName {"ColumnID":4,"Name":"crdb_internal_id...","TableID":104} │ ├── SetIndexName {"IndexID":2,"Name":"t_expr_k_idx","TableID":104} @@ -47,15 +41,13 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D │ ├── SetIndexName {"IndexID":3,"Name":"crdb_internal_in...","TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":6,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":6,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":6,"Kind":1,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":4,"TableID":104} + │ ├── RefreshStats {"TableID":104} │ ├── MakeAddedPrimaryIndexPublic {"IndexID":1,"TableID":104} │ ├── MakeAddedSecondaryIndexPublic {"IndexID":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":3,"Kind":2,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":5,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":5,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":5,"Kind":1,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} ├── Stage 2 of 3 in PostCommitNonRevertiblePhase diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_15_of_15 b/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_15_of_15 index fe0efa3274e7..1c7e9e571e6a 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_15_of_15 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_15_of_15 @@ -32,14 +32,8 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} - │ └── 25 Mutation operations - │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} - │ ├── RefreshStats {"TableID":104} - │ ├── MakeColumnPublic {"ColumnID":4,"TableID":104} - │ ├── RefreshStats {"TableID":104} + │ └── 17 Mutation operations │ ├── SetIndexName {"IndexID":1,"Name":"t_pkey","TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":4,"Kind":2,"TableID":104} │ ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} │ ├── SetColumnName {"ColumnID":4,"Name":"crdb_internal_id...","TableID":104} │ ├── SetIndexName {"IndexID":2,"Name":"t_expr_k_idx","TableID":104} @@ -48,14 +42,12 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":5,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":6,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":6,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":6,"Kind":1,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":4,"TableID":104} + │ ├── RefreshStats {"TableID":104} │ ├── MakeAddedPrimaryIndexPublic {"IndexID":1,"TableID":104} │ ├── MakeAddedSecondaryIndexPublic {"IndexID":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":3,"Kind":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":5,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":5,"Kind":1,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} ├── Stage 2 of 3 in PostCommitNonRevertiblePhase diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_1_of_15 b/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_1_of_15 index a4fe6f4320ad..4038e58ef625 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_1_of_15 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_1_of_15 @@ -23,20 +23,16 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} - └── 18 Mutation operations - ├── MakeColumnPublic {"ColumnID":2,"TableID":104} - ├── RefreshStats {"TableID":104} - ├── MakeColumnPublic {"ColumnID":4,"TableID":104} - ├── RefreshStats {"TableID":104} - ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} - ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":3,"Kind":2,"TableID":104} - ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} - ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":4,"Kind":2,"TableID":104} + └── 14 Mutation operations ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} ├── SetColumnName {"ColumnID":4,"Name":"crdb_internal_id...","TableID":104} ├── SetIndexName {"IndexID":2,"Name":"t_expr_k_idx","TableID":104} ├── CreateGcJobForIndex {"IndexID":4,"TableID":104} ├── MakeIndexAbsent {"IndexID":4,"TableID":104} + ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + ├── RefreshStats {"TableID":104} + ├── MakeColumnPublic {"ColumnID":4,"TableID":104} + ├── RefreshStats {"TableID":104} ├── MakeAddedSecondaryIndexPublic {"IndexID":2,"TableID":104} ├── CreateGcJobForIndex {"IndexID":3,"TableID":104} ├── MakeIndexAbsent {"IndexID":3,"TableID":104} diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_2_of_15 b/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_2_of_15 index 597fb7a85fcb..c1df9924429a 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_2_of_15 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_2_of_15 @@ -23,19 +23,15 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} - │ └── 17 Mutation operations - │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} - │ ├── RefreshStats {"TableID":104} - │ ├── MakeColumnPublic {"ColumnID":4,"TableID":104} - │ ├── RefreshStats {"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":3,"Kind":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":4,"Kind":2,"TableID":104} + │ └── 13 Mutation operations │ ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} │ ├── SetColumnName {"ColumnID":4,"Name":"crdb_internal_id...","TableID":104} │ ├── SetIndexName {"IndexID":2,"Name":"t_expr_k_idx","TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":4,"TableID":104} + │ ├── RefreshStats {"TableID":104} │ ├── MakeAddedSecondaryIndexPublic {"IndexID":2,"TableID":104} │ ├── CreateGcJobForIndex {"IndexID":3,"TableID":104} │ ├── MakeIndexAbsent {"IndexID":3,"TableID":104} diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_3_of_15 b/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_3_of_15 index f93b66c30db3..90fa2bdcdd3b 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_3_of_15 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_3_of_15 @@ -23,19 +23,15 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} - │ └── 17 Mutation operations - │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} - │ ├── RefreshStats {"TableID":104} - │ ├── MakeColumnPublic {"ColumnID":4,"TableID":104} - │ ├── RefreshStats {"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":3,"Kind":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":4,"Kind":2,"TableID":104} + │ └── 13 Mutation operations │ ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} │ ├── SetColumnName {"ColumnID":4,"Name":"crdb_internal_id...","TableID":104} │ ├── SetIndexName {"IndexID":2,"Name":"t_expr_k_idx","TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":4,"TableID":104} + │ ├── RefreshStats {"TableID":104} │ ├── MakeAddedSecondaryIndexPublic {"IndexID":2,"TableID":104} │ ├── CreateGcJobForIndex {"IndexID":3,"TableID":104} │ ├── MakeIndexAbsent {"IndexID":3,"TableID":104} diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_4_of_15 b/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_4_of_15 index 16711094d3e9..37823b8973cd 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_4_of_15 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_4_of_15 @@ -23,21 +23,17 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} - │ └── 17 Mutation operations - │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} - │ ├── RefreshStats {"TableID":104} - │ ├── MakeColumnPublic {"ColumnID":4,"TableID":104} - │ ├── RefreshStats {"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":3,"Kind":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":4,"Kind":2,"TableID":104} + │ └── 13 Mutation operations │ ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} │ ├── SetColumnName {"ColumnID":4,"Name":"crdb_internal_id...","TableID":104} │ ├── SetIndexName {"IndexID":2,"Name":"t_expr_k_idx","TableID":104} │ ├── CreateGcJobForIndex {"IndexID":3,"TableID":104} │ ├── MakeIndexAbsent {"IndexID":3,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":4,"TableID":104} + │ ├── RefreshStats {"TableID":104} │ ├── MakeAddedSecondaryIndexPublic {"IndexID":2,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_5_of_15 b/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_5_of_15 index f9aba90c3bc5..cff6470d1586 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_5_of_15 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_5_of_15 @@ -23,19 +23,15 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} - │ └── 16 Mutation operations - │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} - │ ├── RefreshStats {"TableID":104} - │ ├── MakeColumnPublic {"ColumnID":4,"TableID":104} - │ ├── RefreshStats {"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":3,"Kind":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":4,"Kind":2,"TableID":104} + │ └── 12 Mutation operations │ ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} │ ├── SetColumnName {"ColumnID":4,"Name":"crdb_internal_id...","TableID":104} │ ├── SetIndexName {"IndexID":2,"Name":"t_expr_k_idx","TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":4,"TableID":104} + │ ├── RefreshStats {"TableID":104} │ ├── MakeAddedSecondaryIndexPublic {"IndexID":2,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_6_of_15 b/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_6_of_15 index 28cfa4f93a3e..6d8b0b607f80 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_6_of_15 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_6_of_15 @@ -23,19 +23,15 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} - │ └── 16 Mutation operations - │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} - │ ├── RefreshStats {"TableID":104} - │ ├── MakeColumnPublic {"ColumnID":4,"TableID":104} - │ ├── RefreshStats {"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":3,"Kind":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":4,"Kind":2,"TableID":104} + │ └── 12 Mutation operations │ ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} │ ├── SetColumnName {"ColumnID":4,"Name":"crdb_internal_id...","TableID":104} │ ├── SetIndexName {"IndexID":2,"Name":"t_expr_k_idx","TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":4,"TableID":104} + │ ├── RefreshStats {"TableID":104} │ ├── MakeAddedSecondaryIndexPublic {"IndexID":2,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_7_of_15 b/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_7_of_15 index f28d6e70d861..343c3970c961 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_7_of_15 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_7_of_15 @@ -23,20 +23,16 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} - │ └── 16 Mutation operations - │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} - │ ├── RefreshStats {"TableID":104} - │ ├── MakeColumnPublic {"ColumnID":4,"TableID":104} - │ ├── RefreshStats {"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":3,"Kind":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":4,"Kind":2,"TableID":104} + │ └── 12 Mutation operations │ ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} │ ├── SetColumnName {"ColumnID":4,"Name":"crdb_internal_id...","TableID":104} │ ├── SetIndexName {"IndexID":2,"Name":"t_expr_k_idx","TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":4,"TableID":104} + │ ├── RefreshStats {"TableID":104} │ ├── MakeAddedSecondaryIndexPublic {"IndexID":2,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_8_of_15 b/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_8_of_15 index ed0e00c1f70e..2333970b0678 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_8_of_15 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_8_of_15 @@ -23,20 +23,16 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} - │ └── 16 Mutation operations - │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} - │ ├── RefreshStats {"TableID":104} - │ ├── MakeColumnPublic {"ColumnID":4,"TableID":104} - │ ├── RefreshStats {"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":3,"Kind":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":4,"Kind":2,"TableID":104} + │ └── 12 Mutation operations │ ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} │ ├── SetColumnName {"ColumnID":4,"Name":"crdb_internal_id...","TableID":104} │ ├── SetIndexName {"IndexID":2,"Name":"t_expr_k_idx","TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":4,"TableID":104} + │ ├── RefreshStats {"TableID":104} │ ├── MakeAddedSecondaryIndexPublic {"IndexID":2,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_9_of_15 b/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_9_of_15 index 4dd22c13aa5c..723c3cea9b08 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_9_of_15 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.rollback_9_of_15 @@ -32,28 +32,20 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} - │ └── 28 Mutation operations - │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} - │ ├── RefreshStats {"TableID":104} - │ ├── MakeColumnPublic {"ColumnID":4,"TableID":104} - │ ├── RefreshStats {"TableID":104} + │ └── 20 Mutation operations │ ├── SetIndexName {"IndexID":1,"Name":"t_pkey","TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":4,"Kind":2,"TableID":104} │ ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} │ ├── SetColumnName {"ColumnID":4,"Name":"crdb_internal_id...","TableID":104} │ ├── SetIndexName {"IndexID":2,"Name":"t_expr_k_idx","TableID":104} │ ├── MakeDroppedPrimaryIndexDeleteAndWriteOnly {"IndexID":3,"TableID":104} │ ├── SetIndexName {"IndexID":3,"Name":"crdb_internal_in...","TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":6,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":6,"Kind":1,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":4,"TableID":104} + │ ├── RefreshStats {"TableID":104} │ ├── MakeAddedPrimaryIndexPublic {"IndexID":1,"TableID":104} │ ├── MakeAddedSecondaryIndexPublic {"IndexID":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":3,"Kind":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":5,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":5,"Kind":1,"TableID":104} │ ├── LogEvent {"TargetStatus":1} │ ├── CreateGcJobForIndex {"IndexID":5,"TableID":104} │ ├── MakeIndexAbsent {"IndexID":5,"TableID":104} diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.statement_1_of_2 b/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.statement_1_of_2 index 227b953c664f..4ca6238a76a2 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.statement_1_of_2 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.statement_1_of_2 @@ -14,29 +14,29 @@ Schema change plan for ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COL │ │ ├── PUBLIC → ABSENT ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} │ │ ├── PUBLIC → VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ └── PUBLIC → ABSENT IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} - │ ├── 5 elements transitioning toward PUBLIC - │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} + │ ├── 3 elements transitioning toward PUBLIC │ │ ├── ABSENT → BACKFILL_ONLY PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} + │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ └── ABSENT → PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} + │ ├── 3 elements transitioning toward TRANSIENT_ABSENT + │ │ ├── ABSENT → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} │ │ └── ABSENT → PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4} - │ ├── 1 element transitioning toward TRANSIENT_ABSENT - │ │ └── ABSENT → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ └── 14 Mutation operations │ ├── MakeDroppedColumnDeleteAndWriteOnly {"ColumnID":2,"TableID":104} │ ├── LogEvent {"TargetStatus":1} │ ├── SetColumnName {"ColumnID":2,"Name":"crdb_internal_co...","TableID":104} - │ ├── MakeDroppedColumnDeleteAndWriteOnly {"ColumnID":4,"TableID":104} - │ ├── LogEvent {"TargetStatus":1} - │ ├── SetColumnName {"ColumnID":4,"Name":"crdb_internal_co...","TableID":104} │ ├── MakeDroppedNonPrimaryIndexDeleteAndWriteOnly {"IndexID":2,"TableID":104} │ ├── SetIndexName {"IndexID":2,"Name":"crdb_internal_in...","TableID":104} │ ├── MakeAddedIndexBackfilling {"Index":{"ConstraintID":2,"IndexID":3,"IsUnique":true,"SourceIndexID":1,"TableID":104,"TemporaryIndexID":4}} + │ ├── AddColumnToIndex {"ColumnID":1,"IndexID":3,"TableID":104} + │ ├── AddColumnToIndex {"ColumnID":3,"IndexID":3,"Kind":2,"TableID":104} │ ├── MakeAddedTempIndexDeleteOnly {"Index":{"ConstraintID":3,"IndexID":4,"IsUnique":true,"SourceIndexID":1,"TableID":104}} │ ├── AddColumnToIndex {"ColumnID":1,"IndexID":4,"TableID":104} │ ├── AddColumnToIndex {"ColumnID":3,"IndexID":4,"Kind":2,"TableID":104} - │ ├── AddColumnToIndex {"ColumnID":1,"IndexID":3,"TableID":104} - │ └── AddColumnToIndex {"ColumnID":3,"IndexID":3,"Kind":2,"TableID":104} + │ ├── MakeDroppedColumnDeleteAndWriteOnly {"ColumnID":4,"TableID":104} + │ ├── LogEvent {"TargetStatus":1} + │ └── SetColumnName {"ColumnID":4,"Name":"crdb_internal_co...","TableID":104} ├── PreCommitPhase │ └── Stage 1 of 1 in PreCommitPhase │ └── 2 Mutation operations @@ -103,51 +103,47 @@ Schema change plan for ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COL │ ├── 2 elements transitioning toward PUBLIC │ │ ├── VALIDATED → PUBLIC PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} - │ ├── 1 element transitioning toward TRANSIENT_ABSENT - │ │ └── WRITE_ONLY → TRANSIENT_DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} - │ └── 16 Mutation operations + │ ├── 3 elements transitioning toward TRANSIENT_ABSENT + │ │ ├── WRITE_ONLY → TRANSIENT_DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → TRANSIENT_ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ └── PUBLIC → TRANSIENT_ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4} + │ └── 10 Mutation operations │ ├── MakeDroppedColumnDeleteOnly {"ColumnID":2,"TableID":104} │ ├── MakeDroppedColumnDeleteOnly {"ColumnID":4,"TableID":104} │ ├── MakeDroppedPrimaryIndexDeleteAndWriteOnly {"IndexID":1,"TableID":104} │ ├── SetIndexName {"IndexID":1,"Name":"crdb_internal_in...","TableID":104} │ ├── SetIndexName {"IndexID":3,"Name":"t_pkey","TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":1,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":1,"Kind":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":1,"Kind":2,"Ordinal":1,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":2,"TableID":104} │ ├── MakeAddedPrimaryIndexPublic {"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":4,"IndexID":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":2,"Ordinal":1,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"Kind":1,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} ├── Stage 2 of 3 in PostCommitNonRevertiblePhase - │ ├── 1 element transitioning toward ABSENT - │ │ └── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ └── 3 Mutation operations + │ ├── 4 elements transitioning toward ABSENT + │ │ ├── DELETE_ONLY → ABSENT Column:{DescID: 104, ColumnID: 4} + │ │ ├── PUBLIC → ABSENT ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 4} + │ │ ├── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ └── DELETE_ONLY → ABSENT SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ ├── 1 element transitioning toward TRANSIENT_ABSENT + │ │ └── TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} + │ └── 9 Mutation operations │ ├── MakeDroppedIndexDeleteOnly {"IndexID":1,"TableID":104} + │ ├── LogEvent {"TargetStatus":1} + │ ├── CreateGcJobForIndex {"IndexID":2,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":2,"TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":4,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":4,"TableID":104} + │ ├── MakeColumnAbsent {"ColumnID":4,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} └── Stage 3 of 3 in PostCommitNonRevertiblePhase - ├── 6 elements transitioning toward ABSENT - │ ├── DELETE_ONLY → ABSENT Column:{DescID: 104, ColumnID: 2} - │ ├── PUBLIC → ABSENT ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} - │ ├── DELETE_ONLY → ABSENT Column:{DescID: 104, ColumnID: 4} - │ ├── PUBLIC → ABSENT ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 4} - │ ├── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ └── DELETE_ONLY → ABSENT SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - ├── 1 element transitioning toward TRANSIENT_ABSENT - │ └── TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} - └── 11 Mutation operations - ├── CreateGcJobForIndex {"IndexID":4,"TableID":104} - ├── MakeIndexAbsent {"IndexID":4,"TableID":104} + ├── 3 elements transitioning toward ABSENT + │ ├── DELETE_ONLY → ABSENT Column:{DescID: 104, ColumnID: 2} + │ ├── PUBLIC → ABSENT ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ └── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + └── 5 Mutation operations ├── CreateGcJobForIndex {"IndexID":1,"TableID":104} ├── MakeIndexAbsent {"IndexID":1,"TableID":104} - ├── LogEvent {"TargetStatus":1} - ├── CreateGcJobForIndex {"IndexID":2,"TableID":104} - ├── MakeIndexAbsent {"IndexID":2,"TableID":104} ├── MakeColumnAbsent {"ColumnID":2,"TableID":104} - ├── MakeColumnAbsent {"ColumnID":4,"TableID":104} ├── RemoveJobStateFromDescriptor {"DescriptorID":104} └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"all stages compl..."} diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.statement_2_of_2 b/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.statement_2_of_2 index cdfb6a119abb..a317fdec2cdb 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.statement_2_of_2 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_create_index_separate_statements.statement_2_of_2 @@ -141,24 +141,20 @@ Schema change plan for ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COL │ ├── 2 elements transitioning toward PUBLIC │ │ ├── VALIDATED → PUBLIC SecondaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 4, TemporaryIndexID: 6, SourceIndexID: 3} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: idx, IndexID: 5} - │ ├── 2 elements transitioning toward TRANSIENT_ABSENT + │ ├── 4 elements transitioning toward TRANSIENT_ABSENT + │ │ ├── PUBLIC → TRANSIENT_ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ ├── PUBLIC → TRANSIENT_ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4} │ │ ├── WRITE_ONLY → TRANSIENT_DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ │ └── WRITE_ONLY → TRANSIENT_DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 6, ConstraintID: 4, SourceIndexID: 3} - │ └── 16 Mutation operations + │ └── 10 Mutation operations │ ├── MakeDroppedColumnDeleteOnly {"ColumnID":2,"TableID":104} │ ├── MakeDroppedColumnDeleteOnly {"ColumnID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":1,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":1,"Kind":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":1,"Kind":2,"Ordinal":1,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} │ ├── SetIndexName {"IndexID":5,"Name":"idx","TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":6,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":1,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":2,"TableID":104} │ ├── MakeAddedSecondaryIndexPublic {"IndexID":5,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":4,"IndexID":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":2,"Ordinal":1,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"Kind":1,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} └── Stage 2 of 2 in PostCommitNonRevertiblePhase @@ -173,15 +169,15 @@ Schema change plan for ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COL │ ├── TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ └── TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT TemporaryIndex:{DescID: 104, IndexID: 6, ConstraintID: 4, SourceIndexID: 3} └── 13 Mutation operations - ├── CreateGcJobForIndex {"IndexID":4,"TableID":104} - ├── MakeIndexAbsent {"IndexID":4,"TableID":104} - ├── CreateGcJobForIndex {"IndexID":6,"TableID":104} - ├── MakeIndexAbsent {"IndexID":6,"TableID":104} ├── CreateGcJobForIndex {"IndexID":1,"TableID":104} ├── MakeIndexAbsent {"IndexID":1,"TableID":104} ├── LogEvent {"TargetStatus":1} ├── CreateGcJobForIndex {"IndexID":2,"TableID":104} ├── MakeIndexAbsent {"IndexID":2,"TableID":104} + ├── CreateGcJobForIndex {"IndexID":4,"TableID":104} + ├── MakeIndexAbsent {"IndexID":4,"TableID":104} + ├── CreateGcJobForIndex {"IndexID":6,"TableID":104} + ├── MakeIndexAbsent {"IndexID":6,"TableID":104} ├── MakeColumnAbsent {"ColumnID":2,"TableID":104} ├── MakeColumnAbsent {"ColumnID":4,"TableID":104} ├── RemoveJobStateFromDescriptor {"DescriptorID":104} diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_unique_index b/pkg/sql/schemachanger/testdata/explain/drop_column_unique_index index b4b6cb36fe5c..af2234fa4ee0 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_unique_index +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_unique_index @@ -13,28 +13,28 @@ Schema change plan for ALTER TABLE ‹t›.‹public›.‹test› DROP COLUMN │ ├── 2 elements transitioning toward ABSENT │ │ ├── PUBLIC → WRITE_ONLY Column:{DescID: 106, ColumnID: 3} │ │ └── PUBLIC → ABSENT ColumnName:{DescID: 106, Name: pi, ColumnID: 3} - │ ├── 7 elements transitioning toward PUBLIC + │ ├── 4 elements transitioning toward PUBLIC + │ │ ├── ABSENT → BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 4, ConstraintID: 5, TemporaryIndexID: 5, SourceIndexID: 1} │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 4} │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 4} - │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 4} - │ │ ├── ABSENT → BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 4, ConstraintID: 5, TemporaryIndexID: 5, SourceIndexID: 1} + │ │ └── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 4} + │ ├── 4 elements transitioning toward TRANSIENT_ABSENT + │ │ ├── ABSENT → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 5, ConstraintID: 6, SourceIndexID: 1} │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 5} │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 5} │ │ └── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 5} - │ ├── 1 element transitioning toward TRANSIENT_ABSENT - │ │ └── ABSENT → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 5, ConstraintID: 6, SourceIndexID: 1} │ └── 11 Mutation operations │ ├── MakeDroppedColumnDeleteAndWriteOnly {"ColumnID":3,"TableID":106} │ ├── LogEvent {"TargetStatus":1} │ ├── SetColumnName {"ColumnID":3,"Name":"crdb_internal_co...","TableID":106} │ ├── MakeAddedIndexBackfilling {"Index":{"ConstraintID":5,"IndexID":4,"IsUnique":true,"SourceIndexID":1,"TableID":106,"TemporaryIndexID":5}} + │ ├── AddColumnToIndex {"ColumnID":1,"IndexID":4,"TableID":106} + │ ├── AddColumnToIndex {"ColumnID":2,"IndexID":4,"Kind":2,"TableID":106} + │ ├── AddColumnToIndex {"ColumnID":4,"IndexID":4,"Kind":2,"Ordinal":1,"TableID":106} │ ├── MakeAddedTempIndexDeleteOnly {"Index":{"ConstraintID":6,"IndexID":5,"IsUnique":true,"SourceIndexID":1,"TableID":106}} │ ├── AddColumnToIndex {"ColumnID":1,"IndexID":5,"TableID":106} │ ├── AddColumnToIndex {"ColumnID":2,"IndexID":5,"Kind":2,"TableID":106} - │ ├── AddColumnToIndex {"ColumnID":4,"IndexID":5,"Kind":2,"Ordinal":1,"TableID":106} - │ ├── AddColumnToIndex {"ColumnID":1,"IndexID":4,"TableID":106} - │ ├── AddColumnToIndex {"ColumnID":2,"IndexID":4,"Kind":2,"TableID":106} - │ └── AddColumnToIndex {"ColumnID":4,"IndexID":4,"Kind":2,"Ordinal":1,"TableID":106} + │ └── AddColumnToIndex {"ColumnID":4,"IndexID":5,"Kind":2,"Ordinal":1,"TableID":106} ├── PreCommitPhase │ └── Stage 1 of 1 in PreCommitPhase │ └── 2 Mutation operations @@ -97,39 +97,38 @@ Schema change plan for ALTER TABLE ‹t›.‹public›.‹test› DROP COLUMN │ ├── 2 elements transitioning toward PUBLIC │ │ ├── VALIDATED → PUBLIC PrimaryIndex:{DescID: 106, IndexID: 4, ConstraintID: 5, TemporaryIndexID: 5, SourceIndexID: 1} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 106, Name: test_pkey, IndexID: 4} - │ ├── 1 element transitioning toward TRANSIENT_ABSENT - │ │ └── WRITE_ONLY → TRANSIENT_DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 5, ConstraintID: 6, SourceIndexID: 1} - │ └── 12 Mutation operations + │ ├── 4 elements transitioning toward TRANSIENT_ABSENT + │ │ ├── WRITE_ONLY → TRANSIENT_DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 5, ConstraintID: 6, SourceIndexID: 1} + │ │ ├── PUBLIC → TRANSIENT_ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 5} + │ │ ├── PUBLIC → TRANSIENT_ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 5} + │ │ └── PUBLIC → TRANSIENT_ABSENT IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 5} + │ └── 8 Mutation operations │ ├── MakeDroppedColumnDeleteOnly {"ColumnID":3,"TableID":106} │ ├── MakeDroppedPrimaryIndexDeleteAndWriteOnly {"IndexID":1,"TableID":106} │ ├── SetIndexName {"IndexID":1,"Name":"crdb_internal_in...","TableID":106} │ ├── SetIndexName {"IndexID":4,"Name":"test_pkey","TableID":106} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":5,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":1,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":1,"Kind":2,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":1,"Kind":2,"Ordinal":1,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":4,"IndexID":1,"Kind":2,"Ordinal":2,"TableID":106} │ ├── MakeAddedPrimaryIndexPublic {"IndexID":4,"TableID":106} │ ├── SetJobStateOnDescriptor {"DescriptorID":106} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} ├── Stage 2 of 3 in PostCommitNonRevertiblePhase │ ├── 1 element transitioning toward ABSENT - │ │ └── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} - │ └── 3 Mutation operations + │ │ └── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} + │ ├── 1 element transitioning toward TRANSIENT_ABSENT + │ │ └── TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT TemporaryIndex:{DescID: 106, IndexID: 5, ConstraintID: 6, SourceIndexID: 1} + │ └── 5 Mutation operations │ ├── MakeDroppedIndexDeleteOnly {"IndexID":1,"TableID":106} + │ ├── CreateGcJobForIndex {"IndexID":5,"TableID":106} + │ ├── MakeIndexAbsent {"IndexID":5,"TableID":106} │ ├── SetJobStateOnDescriptor {"DescriptorID":106} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} └── Stage 3 of 3 in PostCommitNonRevertiblePhase ├── 4 elements transitioning toward ABSENT - │ ├── DELETE_ONLY → ABSENT Column:{DescID: 106, ColumnID: 3} - │ ├── PUBLIC → ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 3} - │ ├── PUBLIC → ABSENT ColumnDefaultExpression:{DescID: 106, ColumnID: 3} - │ └── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} - ├── 1 element transitioning toward TRANSIENT_ABSENT - │ └── TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT TemporaryIndex:{DescID: 106, IndexID: 5, ConstraintID: 6, SourceIndexID: 1} - └── 8 Mutation operations - ├── CreateGcJobForIndex {"IndexID":5,"TableID":106} - ├── MakeIndexAbsent {"IndexID":5,"TableID":106} + │ ├── DELETE_ONLY → ABSENT Column:{DescID: 106, ColumnID: 3} + │ ├── PUBLIC → ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 3} + │ ├── PUBLIC → ABSENT ColumnDefaultExpression:{DescID: 106, ColumnID: 3} + │ └── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} + └── 6 Mutation operations ├── CreateGcJobForIndex {"IndexID":1,"TableID":106} ├── MakeIndexAbsent {"IndexID":1,"TableID":106} ├── RemoveColumnDefaultExpression {"ColumnID":3,"TableID":106} diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_unique_index.rollback_1_of_7 b/pkg/sql/schemachanger/testdata/explain/drop_column_unique_index.rollback_1_of_7 index 029de049d6f6..5073ab3745c0 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_unique_index.rollback_1_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_unique_index.rollback_1_of_7 @@ -12,10 +12,10 @@ Schema change plan for rolling back ALTER TABLE ‹t›.public.‹test› DROP C └── PostCommitNonRevertiblePhase └── Stage 1 of 1 in PostCommitNonRevertiblePhase ├── 8 elements transitioning toward ABSENT + │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 4, ConstraintID: 5, TemporaryIndexID: 5, SourceIndexID: 1} │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 4} │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 4} │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 4} - │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 4, ConstraintID: 5, TemporaryIndexID: 5, SourceIndexID: 1} │ ├── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 106, IndexID: 5, ConstraintID: 6, SourceIndexID: 1} │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 5} │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 5} @@ -23,16 +23,10 @@ Schema change plan for rolling back ALTER TABLE ‹t›.public.‹test› DROP C ├── 2 elements transitioning toward PUBLIC │ ├── WRITE_ONLY → PUBLIC Column:{DescID: 106, ColumnID: 3} │ └── ABSENT → PUBLIC ColumnName:{DescID: 106, Name: pi, ColumnID: 3} - └── 15 Mutation operations + └── 9 Mutation operations + ├── SetColumnName {"ColumnID":3,"Name":"pi","TableID":106} ├── MakeColumnPublic {"ColumnID":3,"TableID":106} ├── RefreshStats {"TableID":106} - ├── SetColumnName {"ColumnID":3,"Name":"pi","TableID":106} - ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":106} - ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":4,"Kind":2,"TableID":106} - ├── RemoveColumnFromIndex {"ColumnID":4,"IndexID":4,"Kind":2,"Ordinal":1,"TableID":106} - ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":5,"TableID":106} - ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":5,"Kind":2,"TableID":106} - ├── RemoveColumnFromIndex {"ColumnID":4,"IndexID":5,"Kind":2,"Ordinal":1,"TableID":106} ├── CreateGcJobForIndex {"IndexID":4,"TableID":106} ├── MakeIndexAbsent {"IndexID":4,"TableID":106} ├── CreateGcJobForIndex {"IndexID":5,"TableID":106} diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_unique_index.rollback_2_of_7 b/pkg/sql/schemachanger/testdata/explain/drop_column_unique_index.rollback_2_of_7 index d71bb36162c5..f100c22ccaf9 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_unique_index.rollback_2_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_unique_index.rollback_2_of_7 @@ -12,10 +12,10 @@ Schema change plan for rolling back ALTER TABLE ‹t›.public.‹test› DROP C └── PostCommitNonRevertiblePhase ├── Stage 1 of 2 in PostCommitNonRevertiblePhase │ ├── 8 elements transitioning toward ABSENT + │ │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 4, ConstraintID: 5, TemporaryIndexID: 5, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 4} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 4} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 4} - │ │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 4, ConstraintID: 5, TemporaryIndexID: 5, SourceIndexID: 1} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 5, ConstraintID: 6, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 5} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 5} @@ -23,17 +23,11 @@ Schema change plan for rolling back ALTER TABLE ‹t›.public.‹test› DROP C │ ├── 2 elements transitioning toward PUBLIC │ │ ├── WRITE_ONLY → PUBLIC Column:{DescID: 106, ColumnID: 3} │ │ └── ABSENT → PUBLIC ColumnName:{DescID: 106, Name: pi, ColumnID: 3} - │ └── 14 Mutation operations - │ ├── MakeColumnPublic {"ColumnID":3,"TableID":106} - │ ├── RefreshStats {"TableID":106} + │ └── 8 Mutation operations │ ├── SetColumnName {"ColumnID":3,"Name":"pi","TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":4,"Kind":2,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":4,"IndexID":4,"Kind":2,"Ordinal":1,"TableID":106} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":5,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":5,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":5,"Kind":2,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":4,"IndexID":5,"Kind":2,"Ordinal":1,"TableID":106} + │ ├── MakeColumnPublic {"ColumnID":3,"TableID":106} + │ ├── RefreshStats {"TableID":106} │ ├── CreateGcJobForIndex {"IndexID":4,"TableID":106} │ ├── MakeIndexAbsent {"IndexID":4,"TableID":106} │ ├── SetJobStateOnDescriptor {"DescriptorID":106} diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_unique_index.rollback_3_of_7 b/pkg/sql/schemachanger/testdata/explain/drop_column_unique_index.rollback_3_of_7 index ac54177268bf..c487400caa27 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_unique_index.rollback_3_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_unique_index.rollback_3_of_7 @@ -12,10 +12,10 @@ Schema change plan for rolling back ALTER TABLE ‹t›.public.‹test› DROP C └── PostCommitNonRevertiblePhase ├── Stage 1 of 2 in PostCommitNonRevertiblePhase │ ├── 8 elements transitioning toward ABSENT + │ │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 4, ConstraintID: 5, TemporaryIndexID: 5, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 4} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 4} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 4} - │ │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 4, ConstraintID: 5, TemporaryIndexID: 5, SourceIndexID: 1} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 5, ConstraintID: 6, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 5} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 5} @@ -23,17 +23,11 @@ Schema change plan for rolling back ALTER TABLE ‹t›.public.‹test› DROP C │ ├── 2 elements transitioning toward PUBLIC │ │ ├── WRITE_ONLY → PUBLIC Column:{DescID: 106, ColumnID: 3} │ │ └── ABSENT → PUBLIC ColumnName:{DescID: 106, Name: pi, ColumnID: 3} - │ └── 14 Mutation operations - │ ├── MakeColumnPublic {"ColumnID":3,"TableID":106} - │ ├── RefreshStats {"TableID":106} + │ └── 8 Mutation operations │ ├── SetColumnName {"ColumnID":3,"Name":"pi","TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":4,"Kind":2,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":4,"IndexID":4,"Kind":2,"Ordinal":1,"TableID":106} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":5,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":5,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":5,"Kind":2,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":4,"IndexID":5,"Kind":2,"Ordinal":1,"TableID":106} + │ ├── MakeColumnPublic {"ColumnID":3,"TableID":106} + │ ├── RefreshStats {"TableID":106} │ ├── CreateGcJobForIndex {"IndexID":4,"TableID":106} │ ├── MakeIndexAbsent {"IndexID":4,"TableID":106} │ ├── SetJobStateOnDescriptor {"DescriptorID":106} diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_unique_index.rollback_4_of_7 b/pkg/sql/schemachanger/testdata/explain/drop_column_unique_index.rollback_4_of_7 index 72ff4e592e43..75174dec9c2f 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_unique_index.rollback_4_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_unique_index.rollback_4_of_7 @@ -12,10 +12,10 @@ Schema change plan for rolling back ALTER TABLE ‹t›.public.‹test› DROP C └── PostCommitNonRevertiblePhase ├── Stage 1 of 2 in PostCommitNonRevertiblePhase │ ├── 8 elements transitioning toward ABSENT + │ │ ├── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 4, ConstraintID: 5, TemporaryIndexID: 5, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 4} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 4} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 4} - │ │ ├── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 4, ConstraintID: 5, TemporaryIndexID: 5, SourceIndexID: 1} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 5, ConstraintID: 6, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 5} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 5} @@ -23,19 +23,13 @@ Schema change plan for rolling back ALTER TABLE ‹t›.public.‹test› DROP C │ ├── 2 elements transitioning toward PUBLIC │ │ ├── WRITE_ONLY → PUBLIC Column:{DescID: 106, ColumnID: 3} │ │ └── ABSENT → PUBLIC ColumnName:{DescID: 106, Name: pi, ColumnID: 3} - │ └── 14 Mutation operations + │ └── 8 Mutation operations + │ ├── SetColumnName {"ColumnID":3,"Name":"pi","TableID":106} + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":5,"TableID":106} │ ├── MakeColumnPublic {"ColumnID":3,"TableID":106} │ ├── RefreshStats {"TableID":106} - │ ├── SetColumnName {"ColumnID":3,"Name":"pi","TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":4,"Kind":2,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":4,"IndexID":4,"Kind":2,"Ordinal":1,"TableID":106} │ ├── CreateGcJobForIndex {"IndexID":4,"TableID":106} │ ├── MakeIndexAbsent {"IndexID":4,"TableID":106} - │ ├── MakeDroppedIndexDeleteOnly {"IndexID":5,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":5,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":5,"Kind":2,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":4,"IndexID":5,"Kind":2,"Ordinal":1,"TableID":106} │ ├── SetJobStateOnDescriptor {"DescriptorID":106} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} └── Stage 2 of 2 in PostCommitNonRevertiblePhase diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_unique_index.rollback_5_of_7 b/pkg/sql/schemachanger/testdata/explain/drop_column_unique_index.rollback_5_of_7 index d7b4eb01d8a3..63581e07274e 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_unique_index.rollback_5_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_unique_index.rollback_5_of_7 @@ -12,10 +12,10 @@ Schema change plan for rolling back ALTER TABLE ‹t›.public.‹test› DROP C └── PostCommitNonRevertiblePhase ├── Stage 1 of 2 in PostCommitNonRevertiblePhase │ ├── 8 elements transitioning toward ABSENT + │ │ ├── MERGE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 4, ConstraintID: 5, TemporaryIndexID: 5, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 4} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 4} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 4} - │ │ ├── MERGE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 4, ConstraintID: 5, TemporaryIndexID: 5, SourceIndexID: 1} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 5, ConstraintID: 6, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 5} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 5} @@ -23,17 +23,11 @@ Schema change plan for rolling back ALTER TABLE ‹t›.public.‹test› DROP C │ ├── 2 elements transitioning toward PUBLIC │ │ ├── WRITE_ONLY → PUBLIC Column:{DescID: 106, ColumnID: 3} │ │ └── ABSENT → PUBLIC ColumnName:{DescID: 106, Name: pi, ColumnID: 3} - │ └── 13 Mutation operations - │ ├── MakeColumnPublic {"ColumnID":3,"TableID":106} - │ ├── RefreshStats {"TableID":106} + │ └── 7 Mutation operations │ ├── SetColumnName {"ColumnID":3,"Name":"pi","TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":4,"Kind":2,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":4,"IndexID":4,"Kind":2,"Ordinal":1,"TableID":106} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":5,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":5,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":5,"Kind":2,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":4,"IndexID":5,"Kind":2,"Ordinal":1,"TableID":106} + │ ├── MakeColumnPublic {"ColumnID":3,"TableID":106} + │ ├── RefreshStats {"TableID":106} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":106} │ ├── SetJobStateOnDescriptor {"DescriptorID":106} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_unique_index.rollback_6_of_7 b/pkg/sql/schemachanger/testdata/explain/drop_column_unique_index.rollback_6_of_7 index de08a8a58d7c..3aaed05a4262 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_unique_index.rollback_6_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_unique_index.rollback_6_of_7 @@ -12,10 +12,10 @@ Schema change plan for rolling back ALTER TABLE ‹t›.public.‹test› DROP C └── PostCommitNonRevertiblePhase ├── Stage 1 of 2 in PostCommitNonRevertiblePhase │ ├── 8 elements transitioning toward ABSENT + │ │ ├── MERGE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 4, ConstraintID: 5, TemporaryIndexID: 5, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 4} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 4} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 4} - │ │ ├── MERGE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 4, ConstraintID: 5, TemporaryIndexID: 5, SourceIndexID: 1} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 5, ConstraintID: 6, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 5} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 5} @@ -23,17 +23,11 @@ Schema change plan for rolling back ALTER TABLE ‹t›.public.‹test› DROP C │ ├── 2 elements transitioning toward PUBLIC │ │ ├── WRITE_ONLY → PUBLIC Column:{DescID: 106, ColumnID: 3} │ │ └── ABSENT → PUBLIC ColumnName:{DescID: 106, Name: pi, ColumnID: 3} - │ └── 13 Mutation operations - │ ├── MakeColumnPublic {"ColumnID":3,"TableID":106} - │ ├── RefreshStats {"TableID":106} + │ └── 7 Mutation operations │ ├── SetColumnName {"ColumnID":3,"Name":"pi","TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":4,"Kind":2,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":4,"IndexID":4,"Kind":2,"Ordinal":1,"TableID":106} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":5,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":5,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":5,"Kind":2,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":4,"IndexID":5,"Kind":2,"Ordinal":1,"TableID":106} + │ ├── MakeColumnPublic {"ColumnID":3,"TableID":106} + │ ├── RefreshStats {"TableID":106} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":106} │ ├── SetJobStateOnDescriptor {"DescriptorID":106} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_unique_index.rollback_7_of_7 b/pkg/sql/schemachanger/testdata/explain/drop_column_unique_index.rollback_7_of_7 index e225a147bac7..b7b4d3a04cb7 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_unique_index.rollback_7_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_unique_index.rollback_7_of_7 @@ -12,10 +12,10 @@ Schema change plan for rolling back ALTER TABLE ‹t›.public.‹test› DROP C └── PostCommitNonRevertiblePhase ├── Stage 1 of 2 in PostCommitNonRevertiblePhase │ ├── 8 elements transitioning toward ABSENT + │ │ ├── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 4, ConstraintID: 5, TemporaryIndexID: 5, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 4} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 4} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 4} - │ │ ├── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 4, ConstraintID: 5, TemporaryIndexID: 5, SourceIndexID: 1} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 5, ConstraintID: 6, SourceIndexID: 1} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 5} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 5} @@ -23,18 +23,12 @@ Schema change plan for rolling back ALTER TABLE ‹t›.public.‹test› DROP C │ ├── 2 elements transitioning toward PUBLIC │ │ ├── WRITE_ONLY → PUBLIC Column:{DescID: 106, ColumnID: 3} │ │ └── ABSENT → PUBLIC ColumnName:{DescID: 106, Name: pi, ColumnID: 3} - │ └── 13 Mutation operations - │ ├── MakeColumnPublic {"ColumnID":3,"TableID":106} - │ ├── RefreshStats {"TableID":106} + │ └── 7 Mutation operations │ ├── SetColumnName {"ColumnID":3,"Name":"pi","TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":4,"Kind":2,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":4,"IndexID":4,"Kind":2,"Ordinal":1,"TableID":106} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":106} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":5,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":5,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":5,"Kind":2,"TableID":106} - │ ├── RemoveColumnFromIndex {"ColumnID":4,"IndexID":5,"Kind":2,"Ordinal":1,"TableID":106} + │ ├── MakeColumnPublic {"ColumnID":3,"TableID":106} + │ ├── RefreshStats {"TableID":106} │ ├── SetJobStateOnDescriptor {"DescriptorID":106} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} └── Stage 2 of 2 in PostCommitNonRevertiblePhase diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_with_index b/pkg/sql/schemachanger/testdata/explain/drop_column_with_index index 1d69ef396c39..2d2feca31f96 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_with_index +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_with_index @@ -12,22 +12,22 @@ Schema change plan for ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COL │ │ ├── PUBLIC → ABSENT ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ ├── PUBLIC → VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ └── PUBLIC → ABSENT IndexName:{DescID: 104, Name: t_j_idx, IndexID: 2} - │ ├── 3 elements transitioning toward PUBLIC - │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ ├── 2 elements transitioning toward PUBLIC │ │ ├── ABSENT → BACKFILL_ONLY PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} + │ │ └── ABSENT → PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ ├── 2 elements transitioning toward TRANSIENT_ABSENT + │ │ ├── ABSENT → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ │ └── ABSENT → PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ ├── 1 element transitioning toward TRANSIENT_ABSENT - │ │ └── ABSENT → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ └── 9 Mutation operations - │ ├── MakeDroppedColumnDeleteAndWriteOnly {"ColumnID":2,"TableID":104} - │ ├── LogEvent {"TargetStatus":1} - │ ├── SetColumnName {"ColumnID":2,"Name":"crdb_internal_co...","TableID":104} │ ├── MakeDroppedNonPrimaryIndexDeleteAndWriteOnly {"IndexID":2,"TableID":104} │ ├── SetIndexName {"IndexID":2,"Name":"crdb_internal_in...","TableID":104} │ ├── MakeAddedIndexBackfilling {"Index":{"ConstraintID":2,"IndexID":3,"IsUnique":true,"SourceIndexID":1,"TableID":104,"TemporaryIndexID":4}} + │ ├── AddColumnToIndex {"ColumnID":1,"IndexID":3,"TableID":104} │ ├── MakeAddedTempIndexDeleteOnly {"Index":{"ConstraintID":3,"IndexID":4,"IsUnique":true,"SourceIndexID":1,"TableID":104}} │ ├── AddColumnToIndex {"ColumnID":1,"IndexID":4,"TableID":104} - │ └── AddColumnToIndex {"ColumnID":1,"IndexID":3,"TableID":104} + │ ├── MakeDroppedColumnDeleteAndWriteOnly {"ColumnID":2,"TableID":104} + │ ├── LogEvent {"TargetStatus":1} + │ └── SetColumnName {"ColumnID":2,"Name":"crdb_internal_co...","TableID":104} ├── PreCommitPhase │ └── Stage 1 of 1 in PreCommitPhase │ └── 2 Mutation operations @@ -91,45 +91,42 @@ Schema change plan for ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COL │ ├── 2 elements transitioning toward PUBLIC │ │ ├── VALIDATED → PUBLIC PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} - │ ├── 1 element transitioning toward TRANSIENT_ABSENT - │ │ └── WRITE_ONLY → TRANSIENT_DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} - │ └── 13 Mutation operations + │ ├── 2 elements transitioning toward TRANSIENT_ABSENT + │ │ ├── WRITE_ONLY → TRANSIENT_DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} + │ │ └── PUBLIC → TRANSIENT_ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ └── 9 Mutation operations │ ├── MakeDroppedColumnDeleteOnly {"ColumnID":2,"TableID":104} │ ├── MakeDroppedPrimaryIndexDeleteAndWriteOnly {"IndexID":1,"TableID":104} │ ├── SetIndexName {"IndexID":1,"Name":"crdb_internal_in...","TableID":104} │ ├── SetIndexName {"IndexID":3,"Name":"t_pkey","TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":1,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":1,"Kind":2,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":2,"TableID":104} │ ├── MakeAddedPrimaryIndexPublic {"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"Kind":1,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} ├── Stage 2 of 3 in PostCommitNonRevertiblePhase - │ ├── 1 element transitioning toward ABSENT - │ │ └── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ └── 3 Mutation operations + │ ├── 2 elements transitioning toward ABSENT + │ │ ├── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ └── DELETE_ONLY → ABSENT SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ ├── 1 element transitioning toward TRANSIENT_ABSENT + │ │ └── TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} + │ └── 8 Mutation operations │ ├── MakeDroppedIndexDeleteOnly {"IndexID":1,"TableID":104} + │ ├── LogEvent {"TargetStatus":1} + │ ├── CreateGcJobForIndex {"IndexID":2,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":2,"TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":4,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":4,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} └── Stage 3 of 3 in PostCommitNonRevertiblePhase - ├── 4 elements transitioning toward ABSENT - │ ├── DELETE_ONLY → ABSENT Column:{DescID: 104, ColumnID: 2} - │ ├── PUBLIC → ABSENT ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} - │ ├── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ └── DELETE_ONLY → ABSENT SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - ├── 1 element transitioning toward TRANSIENT_ABSENT - │ └── TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} - └── 10 Mutation operations - ├── CreateGcJobForIndex {"IndexID":4,"TableID":104} - ├── MakeIndexAbsent {"IndexID":4,"TableID":104} + ├── 3 elements transitioning toward ABSENT + │ ├── DELETE_ONLY → ABSENT Column:{DescID: 104, ColumnID: 2} + │ ├── PUBLIC → ABSENT ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ └── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + └── 5 Mutation operations ├── CreateGcJobForIndex {"IndexID":1,"TableID":104} ├── MakeIndexAbsent {"IndexID":1,"TableID":104} - ├── LogEvent {"TargetStatus":1} - ├── CreateGcJobForIndex {"IndexID":2,"TableID":104} - ├── MakeIndexAbsent {"IndexID":2,"TableID":104} ├── MakeColumnAbsent {"ColumnID":2,"TableID":104} ├── RemoveJobStateFromDescriptor {"DescriptorID":104} └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"all stages compl..."} diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_with_index.rollback_1_of_7 b/pkg/sql/schemachanger/testdata/explain/drop_column_with_index.rollback_1_of_7 index ec8b53f0ff7f..3aa981462041 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_with_index.rollback_1_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_with_index.rollback_1_of_7 @@ -9,8 +9,8 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D └── PostCommitNonRevertiblePhase └── Stage 1 of 1 in PostCommitNonRevertiblePhase ├── 4 elements transitioning toward ABSENT - │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} + │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ ├── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} ├── 4 elements transitioning toward PUBLIC @@ -18,13 +18,11 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ ├── VALIDATED → PUBLIC SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_j_idx, IndexID: 2} - └── 13 Mutation operations - ├── MakeColumnPublic {"ColumnID":2,"TableID":104} - ├── RefreshStats {"TableID":104} + └── 11 Mutation operations ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} ├── SetIndexName {"IndexID":2,"Name":"t_j_idx","TableID":104} - ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} - ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} + ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + ├── RefreshStats {"TableID":104} ├── MakeAddedSecondaryIndexPublic {"IndexID":2,"TableID":104} ├── CreateGcJobForIndex {"IndexID":3,"TableID":104} ├── MakeIndexAbsent {"IndexID":3,"TableID":104} diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_with_index.rollback_2_of_7 b/pkg/sql/schemachanger/testdata/explain/drop_column_with_index.rollback_2_of_7 index 49dbaef0568b..7e58176c74de 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_with_index.rollback_2_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_with_index.rollback_2_of_7 @@ -9,8 +9,8 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D └── PostCommitNonRevertiblePhase ├── Stage 1 of 2 in PostCommitNonRevertiblePhase │ ├── 4 elements transitioning toward ABSENT - │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} │ ├── 4 elements transitioning toward PUBLIC @@ -18,14 +18,12 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ ├── VALIDATED → PUBLIC SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_j_idx, IndexID: 2} - │ └── 12 Mutation operations - │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} - │ ├── RefreshStats {"TableID":104} + │ └── 10 Mutation operations │ ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} │ ├── SetIndexName {"IndexID":2,"Name":"t_j_idx","TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} │ ├── MakeAddedSecondaryIndexPublic {"IndexID":2,"TableID":104} │ ├── CreateGcJobForIndex {"IndexID":3,"TableID":104} │ ├── MakeIndexAbsent {"IndexID":3,"TableID":104} diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_with_index.rollback_3_of_7 b/pkg/sql/schemachanger/testdata/explain/drop_column_with_index.rollback_3_of_7 index 1573cef460a6..c913887eba9a 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_with_index.rollback_3_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_with_index.rollback_3_of_7 @@ -9,8 +9,8 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D └── PostCommitNonRevertiblePhase ├── Stage 1 of 2 in PostCommitNonRevertiblePhase │ ├── 4 elements transitioning toward ABSENT - │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} │ ├── 4 elements transitioning toward PUBLIC @@ -18,14 +18,12 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ ├── VALIDATED → PUBLIC SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_j_idx, IndexID: 2} - │ └── 12 Mutation operations - │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} - │ ├── RefreshStats {"TableID":104} + │ └── 10 Mutation operations │ ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} │ ├── SetIndexName {"IndexID":2,"Name":"t_j_idx","TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} │ ├── MakeAddedSecondaryIndexPublic {"IndexID":2,"TableID":104} │ ├── CreateGcJobForIndex {"IndexID":3,"TableID":104} │ ├── MakeIndexAbsent {"IndexID":3,"TableID":104} diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_with_index.rollback_4_of_7 b/pkg/sql/schemachanger/testdata/explain/drop_column_with_index.rollback_4_of_7 index e8cdbfaf431b..5fb9f426ba75 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_with_index.rollback_4_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_with_index.rollback_4_of_7 @@ -9,8 +9,8 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D └── PostCommitNonRevertiblePhase ├── Stage 1 of 2 in PostCommitNonRevertiblePhase │ ├── 4 elements transitioning toward ABSENT - │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ ├── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} │ ├── 4 elements transitioning toward PUBLIC @@ -18,17 +18,15 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ ├── VALIDATED → PUBLIC SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_j_idx, IndexID: 2} - │ └── 12 Mutation operations - │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} - │ ├── RefreshStats {"TableID":104} + │ └── 10 Mutation operations │ ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} │ ├── SetIndexName {"IndexID":2,"Name":"t_j_idx","TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} - │ ├── CreateGcJobForIndex {"IndexID":3,"TableID":104} - │ ├── MakeIndexAbsent {"IndexID":3,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} │ ├── MakeAddedSecondaryIndexPublic {"IndexID":2,"TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":3,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":3,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} └── Stage 2 of 2 in PostCommitNonRevertiblePhase diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_with_index.rollback_5_of_7 b/pkg/sql/schemachanger/testdata/explain/drop_column_with_index.rollback_5_of_7 index b513e35716d9..9a34edeb342a 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_with_index.rollback_5_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_with_index.rollback_5_of_7 @@ -9,8 +9,8 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D └── PostCommitNonRevertiblePhase ├── Stage 1 of 2 in PostCommitNonRevertiblePhase │ ├── 4 elements transitioning toward ABSENT - │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ ├── MERGE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} │ ├── 4 elements transitioning toward PUBLIC @@ -18,14 +18,12 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ ├── VALIDATED → PUBLIC SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_j_idx, IndexID: 2} - │ └── 11 Mutation operations - │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} - │ ├── RefreshStats {"TableID":104} + │ └── 9 Mutation operations │ ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} │ ├── SetIndexName {"IndexID":2,"Name":"t_j_idx","TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} │ ├── MakeAddedSecondaryIndexPublic {"IndexID":2,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_with_index.rollback_6_of_7 b/pkg/sql/schemachanger/testdata/explain/drop_column_with_index.rollback_6_of_7 index 14c70bde144e..f9fef0bf8338 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_with_index.rollback_6_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_with_index.rollback_6_of_7 @@ -9,8 +9,8 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D └── PostCommitNonRevertiblePhase ├── Stage 1 of 2 in PostCommitNonRevertiblePhase │ ├── 4 elements transitioning toward ABSENT - │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ ├── MERGE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} │ ├── 4 elements transitioning toward PUBLIC @@ -18,14 +18,12 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ ├── VALIDATED → PUBLIC SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_j_idx, IndexID: 2} - │ └── 11 Mutation operations - │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} - │ ├── RefreshStats {"TableID":104} + │ └── 9 Mutation operations │ ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} │ ├── SetIndexName {"IndexID":2,"Name":"t_j_idx","TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} │ ├── MakeAddedSecondaryIndexPublic {"IndexID":2,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} diff --git a/pkg/sql/schemachanger/testdata/explain/drop_column_with_index.rollback_7_of_7 b/pkg/sql/schemachanger/testdata/explain/drop_column_with_index.rollback_7_of_7 index 7b64160d0bd0..1817b9bdffe3 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_column_with_index.rollback_7_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/drop_column_with_index.rollback_7_of_7 @@ -9,8 +9,8 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D └── PostCommitNonRevertiblePhase ├── Stage 1 of 2 in PostCommitNonRevertiblePhase │ ├── 4 elements transitioning toward ABSENT - │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ ├── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} │ ├── 4 elements transitioning toward PUBLIC @@ -18,15 +18,13 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ ├── VALIDATED → PUBLIC SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_j_idx, IndexID: 2} - │ └── 11 Mutation operations - │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} - │ ├── RefreshStats {"TableID":104} + │ └── 9 Mutation operations │ ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} │ ├── SetIndexName {"IndexID":2,"Name":"t_j_idx","TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} │ ├── MakeAddedSecondaryIndexPublic {"IndexID":2,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} diff --git a/pkg/sql/schemachanger/testdata/explain/drop_index_hash_sharded_index b/pkg/sql/schemachanger/testdata/explain/drop_index_hash_sharded_index index 102225f23ae5..55e12c246fd8 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_index_hash_sharded_index +++ b/pkg/sql/schemachanger/testdata/explain/drop_index_hash_sharded_index @@ -14,11 +14,11 @@ Schema change plan for DROP INDEX ‹defaultdb›.‹public›.‹t›@‹idx› │ │ ├── PUBLIC → VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ └── PUBLIC → ABSENT IndexName:{DescID: 104, Name: idx, IndexID: 2} │ └── 5 Mutation operations + │ ├── MakeDroppedNonPrimaryIndexDeleteAndWriteOnly {"IndexID":2,"TableID":104} + │ ├── SetIndexName {"IndexID":2,"Name":"crdb_internal_in...","TableID":104} │ ├── MakeDroppedColumnDeleteAndWriteOnly {"ColumnID":3,"TableID":104} │ ├── LogEvent {"TargetStatus":1} - │ ├── SetColumnName {"ColumnID":3,"Name":"crdb_internal_co...","TableID":104} - │ ├── MakeDroppedNonPrimaryIndexDeleteAndWriteOnly {"IndexID":2,"TableID":104} - │ └── SetIndexName {"IndexID":2,"Name":"crdb_internal_in...","TableID":104} + │ └── SetColumnName {"ColumnID":3,"Name":"crdb_internal_co...","TableID":104} ├── PreCommitPhase │ └── Stage 1 of 1 in PreCommitPhase │ └── 2 Mutation operations @@ -34,14 +34,11 @@ Schema change plan for DROP INDEX ‹defaultdb›.‹public›.‹t›@‹idx› │ │ ├── VALIDATED → DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ ├── PUBLIC → ABSENT CheckConstraint:{DescID: 104, ConstraintID: 2} │ │ └── PUBLIC → ABSENT ConstraintName:{DescID: 104, Name: check_crdb_internal_j_shard_16, ConstraintID: 2} - │ └── 9 Mutation operations + │ └── 6 Mutation operations │ ├── MakeDroppedColumnDeleteOnly {"ColumnID":3,"TableID":104} │ ├── RemoveCheckConstraint {"ConstraintID":2,"TableID":104} │ ├── NotImplemented {"ElementType":"scpb.ConstraintN..."} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"Ordinal":1,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"Kind":1,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} └── Stage 2 of 2 in PostCommitNonRevertiblePhase diff --git a/pkg/sql/schemachanger/testdata/explain/drop_index_partial_expression_index b/pkg/sql/schemachanger/testdata/explain/drop_index_partial_expression_index index 2027f7193169..24d270085a1c 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_index_partial_expression_index +++ b/pkg/sql/schemachanger/testdata/explain/drop_index_partial_expression_index @@ -14,11 +14,11 @@ Schema change plan for DROP INDEX ‹defaultdb›.‹public›.‹t›@‹idx› │ │ ├── PUBLIC → VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ └── PUBLIC → ABSENT IndexName:{DescID: 104, Name: idx, IndexID: 2} │ └── 5 Mutation operations + │ ├── MakeDroppedNonPrimaryIndexDeleteAndWriteOnly {"IndexID":2,"TableID":104} + │ ├── SetIndexName {"IndexID":2,"Name":"crdb_internal_in...","TableID":104} │ ├── MakeDroppedColumnDeleteAndWriteOnly {"ColumnID":3,"TableID":104} │ ├── LogEvent {"TargetStatus":1} - │ ├── SetColumnName {"ColumnID":3,"Name":"crdb_internal_co...","TableID":104} - │ ├── MakeDroppedNonPrimaryIndexDeleteAndWriteOnly {"IndexID":2,"TableID":104} - │ └── SetIndexName {"IndexID":2,"Name":"crdb_internal_in...","TableID":104} + │ └── SetColumnName {"ColumnID":3,"Name":"crdb_internal_co...","TableID":104} ├── PreCommitPhase │ └── Stage 1 of 1 in PreCommitPhase │ └── 2 Mutation operations @@ -31,11 +31,9 @@ Schema change plan for DROP INDEX ‹defaultdb›.‹public›.‹t›@‹idx› │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ └── VALIDATED → DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ └── 6 Mutation operations + │ └── 4 Mutation operations │ ├── MakeDroppedColumnDeleteOnly {"ColumnID":3,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"Kind":1,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} └── Stage 2 of 2 in PostCommitNonRevertiblePhase diff --git a/pkg/sql/schemachanger/testdata/explain/drop_index_vanilla_index b/pkg/sql/schemachanger/testdata/explain/drop_index_vanilla_index index 666df2c74309..b7da08ae6ea6 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_index_vanilla_index +++ b/pkg/sql/schemachanger/testdata/explain/drop_index_vanilla_index @@ -25,10 +25,8 @@ Schema change plan for DROP INDEX ‹defaultdb›.‹public›.‹t›@‹idx› │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ └── VALIDATED → DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ └── 5 Mutation operations + │ └── 3 Mutation operations │ ├── MakeDroppedIndexDeleteOnly {"IndexID":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"Kind":1,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} └── Stage 2 of 2 in PostCommitNonRevertiblePhase diff --git a/pkg/sql/schemachanger/testdata/explain/drop_multiple_columns_separate_statements.rollback_1_of_7 b/pkg/sql/schemachanger/testdata/explain/drop_multiple_columns_separate_statements.rollback_1_of_7 index 82f469d08bcf..fdcdae2e5819 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_multiple_columns_separate_statements.rollback_1_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/drop_multiple_columns_separate_statements.rollback_1_of_7 @@ -23,23 +23,21 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} - └── 19 Mutation operations + └── 17 Mutation operations ├── SetColumnName {"ColumnID":3,"Name":"k","TableID":104} - ├── MakeColumnPublic {"ColumnID":2,"TableID":104} - ├── RefreshStats {"TableID":104} - ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} - ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} ├── SetColumnName {"ColumnID":4,"Name":"crdb_internal_id...","TableID":104} ├── SetIndexName {"IndexID":2,"Name":"t_expr_k_idx","TableID":104} ├── CreateGcJobForIndex {"IndexID":4,"TableID":104} ├── MakeIndexAbsent {"IndexID":4,"TableID":104} - ├── MakeColumnPublic {"ColumnID":3,"TableID":104} - ├── RefreshStats {"TableID":104} - ├── MakeColumnPublic {"ColumnID":4,"TableID":104} + ├── MakeColumnPublic {"ColumnID":2,"TableID":104} ├── RefreshStats {"TableID":104} ├── MakeAddedSecondaryIndexPublic {"IndexID":2,"TableID":104} ├── CreateGcJobForIndex {"IndexID":3,"TableID":104} ├── MakeIndexAbsent {"IndexID":3,"TableID":104} + ├── MakeColumnPublic {"ColumnID":3,"TableID":104} + ├── RefreshStats {"TableID":104} + ├── MakeColumnPublic {"ColumnID":4,"TableID":104} + ├── RefreshStats {"TableID":104} ├── RemoveJobStateFromDescriptor {"DescriptorID":104} └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"all stages compl..."} diff --git a/pkg/sql/schemachanger/testdata/explain/drop_multiple_columns_separate_statements.rollback_2_of_7 b/pkg/sql/schemachanger/testdata/explain/drop_multiple_columns_separate_statements.rollback_2_of_7 index 5f82fff0a54d..b8d5dad53ea5 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_multiple_columns_separate_statements.rollback_2_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/drop_multiple_columns_separate_statements.rollback_2_of_7 @@ -23,23 +23,21 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} - │ └── 18 Mutation operations + │ └── 16 Mutation operations │ ├── SetColumnName {"ColumnID":3,"Name":"k","TableID":104} - │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} - │ ├── RefreshStats {"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} │ ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} │ ├── SetColumnName {"ColumnID":4,"Name":"crdb_internal_id...","TableID":104} │ ├── SetIndexName {"IndexID":2,"Name":"t_expr_k_idx","TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} - │ ├── MakeColumnPublic {"ColumnID":3,"TableID":104} - │ ├── RefreshStats {"TableID":104} - │ ├── MakeColumnPublic {"ColumnID":4,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} │ ├── RefreshStats {"TableID":104} │ ├── MakeAddedSecondaryIndexPublic {"IndexID":2,"TableID":104} │ ├── CreateGcJobForIndex {"IndexID":3,"TableID":104} │ ├── MakeIndexAbsent {"IndexID":3,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":3,"TableID":104} + │ ├── RefreshStats {"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":4,"TableID":104} + │ ├── RefreshStats {"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} └── Stage 2 of 2 in PostCommitNonRevertiblePhase diff --git a/pkg/sql/schemachanger/testdata/explain/drop_multiple_columns_separate_statements.rollback_3_of_7 b/pkg/sql/schemachanger/testdata/explain/drop_multiple_columns_separate_statements.rollback_3_of_7 index 79c4f86b0d30..84d3aacf150f 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_multiple_columns_separate_statements.rollback_3_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/drop_multiple_columns_separate_statements.rollback_3_of_7 @@ -23,23 +23,21 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} - │ └── 18 Mutation operations + │ └── 16 Mutation operations │ ├── SetColumnName {"ColumnID":3,"Name":"k","TableID":104} - │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} - │ ├── RefreshStats {"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} │ ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} │ ├── SetColumnName {"ColumnID":4,"Name":"crdb_internal_id...","TableID":104} │ ├── SetIndexName {"IndexID":2,"Name":"t_expr_k_idx","TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} - │ ├── MakeColumnPublic {"ColumnID":3,"TableID":104} - │ ├── RefreshStats {"TableID":104} - │ ├── MakeColumnPublic {"ColumnID":4,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} │ ├── RefreshStats {"TableID":104} │ ├── MakeAddedSecondaryIndexPublic {"IndexID":2,"TableID":104} │ ├── CreateGcJobForIndex {"IndexID":3,"TableID":104} │ ├── MakeIndexAbsent {"IndexID":3,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":3,"TableID":104} + │ ├── RefreshStats {"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":4,"TableID":104} + │ ├── RefreshStats {"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} └── Stage 2 of 2 in PostCommitNonRevertiblePhase diff --git a/pkg/sql/schemachanger/testdata/explain/drop_multiple_columns_separate_statements.rollback_4_of_7 b/pkg/sql/schemachanger/testdata/explain/drop_multiple_columns_separate_statements.rollback_4_of_7 index c1d5e2480333..be6d464361e7 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_multiple_columns_separate_statements.rollback_4_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/drop_multiple_columns_separate_statements.rollback_4_of_7 @@ -23,23 +23,21 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} - │ └── 18 Mutation operations + │ └── 16 Mutation operations │ ├── SetColumnName {"ColumnID":3,"Name":"k","TableID":104} - │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} - │ ├── RefreshStats {"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} │ ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} │ ├── SetColumnName {"ColumnID":4,"Name":"crdb_internal_id...","TableID":104} │ ├── SetIndexName {"IndexID":2,"Name":"t_expr_k_idx","TableID":104} │ ├── CreateGcJobForIndex {"IndexID":3,"TableID":104} │ ├── MakeIndexAbsent {"IndexID":3,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} + │ ├── MakeAddedSecondaryIndexPublic {"IndexID":2,"TableID":104} │ ├── MakeColumnPublic {"ColumnID":3,"TableID":104} │ ├── RefreshStats {"TableID":104} │ ├── MakeColumnPublic {"ColumnID":4,"TableID":104} │ ├── RefreshStats {"TableID":104} - │ ├── MakeAddedSecondaryIndexPublic {"IndexID":2,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} └── Stage 2 of 2 in PostCommitNonRevertiblePhase diff --git a/pkg/sql/schemachanger/testdata/explain/drop_multiple_columns_separate_statements.rollback_5_of_7 b/pkg/sql/schemachanger/testdata/explain/drop_multiple_columns_separate_statements.rollback_5_of_7 index 3fe2bc327f3d..ca606b5d9cab 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_multiple_columns_separate_statements.rollback_5_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/drop_multiple_columns_separate_statements.rollback_5_of_7 @@ -23,22 +23,20 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} - │ └── 17 Mutation operations + │ └── 15 Mutation operations │ ├── SetColumnName {"ColumnID":3,"Name":"k","TableID":104} - │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} - │ ├── RefreshStats {"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} │ ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} │ ├── SetColumnName {"ColumnID":4,"Name":"crdb_internal_id...","TableID":104} │ ├── SetIndexName {"IndexID":2,"Name":"t_expr_k_idx","TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} + │ ├── MakeAddedSecondaryIndexPublic {"IndexID":2,"TableID":104} + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} │ ├── MakeColumnPublic {"ColumnID":3,"TableID":104} │ ├── RefreshStats {"TableID":104} │ ├── MakeColumnPublic {"ColumnID":4,"TableID":104} │ ├── RefreshStats {"TableID":104} - │ ├── MakeAddedSecondaryIndexPublic {"IndexID":2,"TableID":104} - │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} └── Stage 2 of 2 in PostCommitNonRevertiblePhase diff --git a/pkg/sql/schemachanger/testdata/explain/drop_multiple_columns_separate_statements.rollback_6_of_7 b/pkg/sql/schemachanger/testdata/explain/drop_multiple_columns_separate_statements.rollback_6_of_7 index 82dbc493606d..f5d3db3f31ba 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_multiple_columns_separate_statements.rollback_6_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/drop_multiple_columns_separate_statements.rollback_6_of_7 @@ -23,22 +23,20 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} - │ └── 17 Mutation operations + │ └── 15 Mutation operations │ ├── SetColumnName {"ColumnID":3,"Name":"k","TableID":104} - │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} - │ ├── RefreshStats {"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} │ ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} │ ├── SetColumnName {"ColumnID":4,"Name":"crdb_internal_id...","TableID":104} │ ├── SetIndexName {"IndexID":2,"Name":"t_expr_k_idx","TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} + │ ├── MakeAddedSecondaryIndexPublic {"IndexID":2,"TableID":104} + │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} │ ├── MakeColumnPublic {"ColumnID":3,"TableID":104} │ ├── RefreshStats {"TableID":104} │ ├── MakeColumnPublic {"ColumnID":4,"TableID":104} │ ├── RefreshStats {"TableID":104} - │ ├── MakeAddedSecondaryIndexPublic {"IndexID":2,"TableID":104} - │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} └── Stage 2 of 2 in PostCommitNonRevertiblePhase diff --git a/pkg/sql/schemachanger/testdata/explain/drop_multiple_columns_separate_statements.rollback_7_of_7 b/pkg/sql/schemachanger/testdata/explain/drop_multiple_columns_separate_statements.rollback_7_of_7 index 5570af742360..bd510aa98094 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_multiple_columns_separate_statements.rollback_7_of_7 +++ b/pkg/sql/schemachanger/testdata/explain/drop_multiple_columns_separate_statements.rollback_7_of_7 @@ -23,22 +23,20 @@ Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› D │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} - │ └── 17 Mutation operations + │ └── 15 Mutation operations │ ├── SetColumnName {"ColumnID":3,"Name":"k","TableID":104} - │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} - │ ├── RefreshStats {"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":4,"TableID":104} │ ├── SetColumnName {"ColumnID":2,"Name":"j","TableID":104} │ ├── SetColumnName {"ColumnID":4,"Name":"crdb_internal_id...","TableID":104} │ ├── SetIndexName {"IndexID":2,"Name":"t_expr_k_idx","TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":3,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} + │ ├── MakeColumnPublic {"ColumnID":2,"TableID":104} + │ ├── RefreshStats {"TableID":104} + │ ├── MakeAddedSecondaryIndexPublic {"IndexID":2,"TableID":104} │ ├── MakeColumnPublic {"ColumnID":3,"TableID":104} │ ├── RefreshStats {"TableID":104} │ ├── MakeColumnPublic {"ColumnID":4,"TableID":104} │ ├── RefreshStats {"TableID":104} - │ ├── MakeAddedSecondaryIndexPublic {"IndexID":2,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} └── Stage 2 of 2 in PostCommitNonRevertiblePhase diff --git a/pkg/sql/schemachanger/testdata/explain/drop_multiple_columns_separate_statements.statement_1_of_2 b/pkg/sql/schemachanger/testdata/explain/drop_multiple_columns_separate_statements.statement_1_of_2 index 227b953c664f..4ca6238a76a2 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_multiple_columns_separate_statements.statement_1_of_2 +++ b/pkg/sql/schemachanger/testdata/explain/drop_multiple_columns_separate_statements.statement_1_of_2 @@ -14,29 +14,29 @@ Schema change plan for ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COL │ │ ├── PUBLIC → ABSENT ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} │ │ ├── PUBLIC → VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ └── PUBLIC → ABSENT IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} - │ ├── 5 elements transitioning toward PUBLIC - │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} + │ ├── 3 elements transitioning toward PUBLIC │ │ ├── ABSENT → BACKFILL_ONLY PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} + │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ └── ABSENT → PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} + │ ├── 3 elements transitioning toward TRANSIENT_ABSENT + │ │ ├── ABSENT → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} │ │ └── ABSENT → PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4} - │ ├── 1 element transitioning toward TRANSIENT_ABSENT - │ │ └── ABSENT → DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ └── 14 Mutation operations │ ├── MakeDroppedColumnDeleteAndWriteOnly {"ColumnID":2,"TableID":104} │ ├── LogEvent {"TargetStatus":1} │ ├── SetColumnName {"ColumnID":2,"Name":"crdb_internal_co...","TableID":104} - │ ├── MakeDroppedColumnDeleteAndWriteOnly {"ColumnID":4,"TableID":104} - │ ├── LogEvent {"TargetStatus":1} - │ ├── SetColumnName {"ColumnID":4,"Name":"crdb_internal_co...","TableID":104} │ ├── MakeDroppedNonPrimaryIndexDeleteAndWriteOnly {"IndexID":2,"TableID":104} │ ├── SetIndexName {"IndexID":2,"Name":"crdb_internal_in...","TableID":104} │ ├── MakeAddedIndexBackfilling {"Index":{"ConstraintID":2,"IndexID":3,"IsUnique":true,"SourceIndexID":1,"TableID":104,"TemporaryIndexID":4}} + │ ├── AddColumnToIndex {"ColumnID":1,"IndexID":3,"TableID":104} + │ ├── AddColumnToIndex {"ColumnID":3,"IndexID":3,"Kind":2,"TableID":104} │ ├── MakeAddedTempIndexDeleteOnly {"Index":{"ConstraintID":3,"IndexID":4,"IsUnique":true,"SourceIndexID":1,"TableID":104}} │ ├── AddColumnToIndex {"ColumnID":1,"IndexID":4,"TableID":104} │ ├── AddColumnToIndex {"ColumnID":3,"IndexID":4,"Kind":2,"TableID":104} - │ ├── AddColumnToIndex {"ColumnID":1,"IndexID":3,"TableID":104} - │ └── AddColumnToIndex {"ColumnID":3,"IndexID":3,"Kind":2,"TableID":104} + │ ├── MakeDroppedColumnDeleteAndWriteOnly {"ColumnID":4,"TableID":104} + │ ├── LogEvent {"TargetStatus":1} + │ └── SetColumnName {"ColumnID":4,"Name":"crdb_internal_co...","TableID":104} ├── PreCommitPhase │ └── Stage 1 of 1 in PreCommitPhase │ └── 2 Mutation operations @@ -103,51 +103,47 @@ Schema change plan for ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COL │ ├── 2 elements transitioning toward PUBLIC │ │ ├── VALIDATED → PUBLIC PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} - │ ├── 1 element transitioning toward TRANSIENT_ABSENT - │ │ └── WRITE_ONLY → TRANSIENT_DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} - │ └── 16 Mutation operations + │ ├── 3 elements transitioning toward TRANSIENT_ABSENT + │ │ ├── WRITE_ONLY → TRANSIENT_DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → TRANSIENT_ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ └── PUBLIC → TRANSIENT_ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4} + │ └── 10 Mutation operations │ ├── MakeDroppedColumnDeleteOnly {"ColumnID":2,"TableID":104} │ ├── MakeDroppedColumnDeleteOnly {"ColumnID":4,"TableID":104} │ ├── MakeDroppedPrimaryIndexDeleteAndWriteOnly {"IndexID":1,"TableID":104} │ ├── SetIndexName {"IndexID":1,"Name":"crdb_internal_in...","TableID":104} │ ├── SetIndexName {"IndexID":3,"Name":"t_pkey","TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":1,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":1,"Kind":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":1,"Kind":2,"Ordinal":1,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":2,"TableID":104} │ ├── MakeAddedPrimaryIndexPublic {"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":4,"IndexID":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":2,"Ordinal":1,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"Kind":1,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} ├── Stage 2 of 3 in PostCommitNonRevertiblePhase - │ ├── 1 element transitioning toward ABSENT - │ │ └── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ └── 3 Mutation operations + │ ├── 4 elements transitioning toward ABSENT + │ │ ├── DELETE_ONLY → ABSENT Column:{DescID: 104, ColumnID: 4} + │ │ ├── PUBLIC → ABSENT ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 4} + │ │ ├── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ └── DELETE_ONLY → ABSENT SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ ├── 1 element transitioning toward TRANSIENT_ABSENT + │ │ └── TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} + │ └── 9 Mutation operations │ ├── MakeDroppedIndexDeleteOnly {"IndexID":1,"TableID":104} + │ ├── LogEvent {"TargetStatus":1} + │ ├── CreateGcJobForIndex {"IndexID":2,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":2,"TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":4,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":4,"TableID":104} + │ ├── MakeColumnAbsent {"ColumnID":4,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} └── Stage 3 of 3 in PostCommitNonRevertiblePhase - ├── 6 elements transitioning toward ABSENT - │ ├── DELETE_ONLY → ABSENT Column:{DescID: 104, ColumnID: 2} - │ ├── PUBLIC → ABSENT ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} - │ ├── DELETE_ONLY → ABSENT Column:{DescID: 104, ColumnID: 4} - │ ├── PUBLIC → ABSENT ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 4} - │ ├── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ └── DELETE_ONLY → ABSENT SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - ├── 1 element transitioning toward TRANSIENT_ABSENT - │ └── TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} - └── 11 Mutation operations - ├── CreateGcJobForIndex {"IndexID":4,"TableID":104} - ├── MakeIndexAbsent {"IndexID":4,"TableID":104} + ├── 3 elements transitioning toward ABSENT + │ ├── DELETE_ONLY → ABSENT Column:{DescID: 104, ColumnID: 2} + │ ├── PUBLIC → ABSENT ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ └── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + └── 5 Mutation operations ├── CreateGcJobForIndex {"IndexID":1,"TableID":104} ├── MakeIndexAbsent {"IndexID":1,"TableID":104} - ├── LogEvent {"TargetStatus":1} - ├── CreateGcJobForIndex {"IndexID":2,"TableID":104} - ├── MakeIndexAbsent {"IndexID":2,"TableID":104} ├── MakeColumnAbsent {"ColumnID":2,"TableID":104} - ├── MakeColumnAbsent {"ColumnID":4,"TableID":104} ├── RemoveJobStateFromDescriptor {"DescriptorID":104} └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"all stages compl..."} diff --git a/pkg/sql/schemachanger/testdata/explain/drop_multiple_columns_separate_statements.statement_2_of_2 b/pkg/sql/schemachanger/testdata/explain/drop_multiple_columns_separate_statements.statement_2_of_2 index b3095250ad03..ac66bdc75b1b 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_multiple_columns_separate_statements.statement_2_of_2 +++ b/pkg/sql/schemachanger/testdata/explain/drop_multiple_columns_separate_statements.statement_2_of_2 @@ -84,61 +84,55 @@ Schema change plan for ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COL │ ├── 2 elements transitioning toward PUBLIC │ │ ├── VALIDATED → PUBLIC PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ └── ABSENT → PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} - │ ├── 1 element transitioning toward TRANSIENT_ABSENT + │ ├── 2 elements transitioning toward TRANSIENT_ABSENT + │ │ ├── PUBLIC → TRANSIENT_ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} │ │ └── WRITE_ONLY → TRANSIENT_DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} - │ └── 19 Mutation operations + │ └── 12 Mutation operations │ ├── MakeDroppedColumnDeleteOnly {"ColumnID":3,"TableID":104} │ ├── MakeDroppedColumnDeleteOnly {"ColumnID":2,"TableID":104} │ ├── MakeDroppedColumnDeleteOnly {"ColumnID":4,"TableID":104} │ ├── MakeDroppedPrimaryIndexDeleteAndWriteOnly {"IndexID":1,"TableID":104} │ ├── SetIndexName {"IndexID":1,"Name":"crdb_internal_in...","TableID":104} │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":3,"Kind":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":4,"Kind":2,"TableID":104} │ ├── SetIndexName {"IndexID":3,"Name":"t_pkey","TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":4,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":1,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":1,"Kind":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":1,"Kind":2,"Ordinal":1,"TableID":104} │ ├── MakeDroppedIndexDeleteOnly {"IndexID":2,"TableID":104} │ ├── MakeAddedPrimaryIndexPublic {"IndexID":3,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":4,"IndexID":2,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":2,"Ordinal":1,"TableID":104} - │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"Kind":1,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} ├── Stage 2 of 3 in PostCommitNonRevertiblePhase - │ ├── 1 element transitioning toward ABSENT - │ │ └── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ └── 3 Mutation operations + │ ├── 4 elements transitioning toward ABSENT + │ │ ├── DELETE_ONLY → ABSENT Column:{DescID: 104, ColumnID: 4} + │ │ ├── PUBLIC → ABSENT ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 4} + │ │ ├── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ └── DELETE_ONLY → ABSENT SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ ├── 1 element transitioning toward TRANSIENT_ABSENT + │ │ └── TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} + │ └── 9 Mutation operations │ ├── MakeDroppedIndexDeleteOnly {"IndexID":1,"TableID":104} + │ ├── LogEvent {"TargetStatus":1} + │ ├── CreateGcJobForIndex {"IndexID":2,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":2,"TableID":104} + │ ├── CreateGcJobForIndex {"IndexID":4,"TableID":104} + │ ├── MakeIndexAbsent {"IndexID":4,"TableID":104} + │ ├── MakeColumnAbsent {"ColumnID":4,"TableID":104} │ ├── SetJobStateOnDescriptor {"DescriptorID":104} │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} └── Stage 3 of 3 in PostCommitNonRevertiblePhase - ├── 10 elements transitioning toward ABSENT - │ ├── DELETE_ONLY → ABSENT Column:{DescID: 104, ColumnID: 3} - │ ├── PUBLIC → ABSENT ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 3} - │ ├── PUBLIC → ABSENT ColumnDefaultExpression:{DescID: 104, ColumnID: 3} - │ ├── PUBLIC → ABSENT ColumnOnUpdateExpression:{DescID: 104, ColumnID: 3} - │ ├── DELETE_ONLY → ABSENT Column:{DescID: 104, ColumnID: 2} - │ ├── PUBLIC → ABSENT ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} - │ ├── DELETE_ONLY → ABSENT Column:{DescID: 104, ColumnID: 4} - │ ├── PUBLIC → ABSENT ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 4} - │ ├── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ └── DELETE_ONLY → ABSENT SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - ├── 1 element transitioning toward TRANSIENT_ABSENT - │ └── TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} - └── 14 Mutation operations - ├── CreateGcJobForIndex {"IndexID":4,"TableID":104} - ├── MakeIndexAbsent {"IndexID":4,"TableID":104} + ├── 7 elements transitioning toward ABSENT + │ ├── DELETE_ONLY → ABSENT Column:{DescID: 104, ColumnID: 3} + │ ├── PUBLIC → ABSENT ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 3} + │ ├── PUBLIC → ABSENT ColumnDefaultExpression:{DescID: 104, ColumnID: 3} + │ ├── PUBLIC → ABSENT ColumnOnUpdateExpression:{DescID: 104, ColumnID: 3} + │ ├── DELETE_ONLY → ABSENT Column:{DescID: 104, ColumnID: 2} + │ ├── PUBLIC → ABSENT ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ └── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + └── 8 Mutation operations ├── CreateGcJobForIndex {"IndexID":1,"TableID":104} ├── MakeIndexAbsent {"IndexID":1,"TableID":104} - ├── LogEvent {"TargetStatus":1} - ├── CreateGcJobForIndex {"IndexID":2,"TableID":104} - ├── MakeIndexAbsent {"IndexID":2,"TableID":104} ├── RemoveColumnDefaultExpression {"ColumnID":3,"TableID":104} ├── RemoveColumnOnUpdateExpression {"ColumnID":3,"TableID":104} ├── MakeColumnAbsent {"ColumnID":2,"TableID":104} - ├── MakeColumnAbsent {"ColumnID":4,"TableID":104} ├── MakeColumnAbsent {"ColumnID":3,"TableID":104} ├── RemoveJobStateFromDescriptor {"DescriptorID":104} └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"all stages compl..."} diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/add_column b/pkg/sql/schemachanger/testdata/explain_verbose/add_column index f885ea9a66fb..5223609af54d 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/add_column +++ b/pkg/sql/schemachanger/testdata/explain_verbose/add_column @@ -12,7 +12,7 @@ EXPLAIN (ddl, verbose) ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL DEFAU │ │ │ └── • Stage 1 of 1 in StatementPhase │ │ -│ ├── • 9 elements transitioning toward PUBLIC +│ ├── • 7 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 106, ColumnID: 2} │ │ │ ABSENT → DELETE_ONLY @@ -21,14 +21,15 @@ EXPLAIN (ddl, verbose) ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL DEFAU │ │ │ │ ABSENT → PUBLIC │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 2} -│ │ │ rule: "column name set right after column existence" │ │ │ rule: "column existence precedes column dependents" +│ │ │ rule: "column name and type set right after column existence" │ │ │ │ │ ├── • ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 2} │ │ │ │ ABSENT → PUBLIC │ │ │ │ -│ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 106, Name: j, ColumnID: 2} -│ │ │ rule: "column named before column type becomes public" +│ │ │ └── • SameStagePrecedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 2} +│ │ │ rule: "column existence precedes column dependents" +│ │ │ rule: "column name and type set right after column existence" │ │ │ │ │ ├── • ColumnDefaultExpression:{DescID: 106, ColumnID: 2} │ │ │ │ ABSENT → PUBLIC @@ -36,39 +37,40 @@ EXPLAIN (ddl, verbose) ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL DEFAU │ │ │ └── • Precedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 2} │ │ │ rule: "column existence precedes column dependents" │ │ │ -│ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} -│ │ │ │ ABSENT → PUBLIC +│ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ │ ABSENT → BACKFILL_ONLY │ │ │ │ -│ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} -│ │ │ rule: "index-column added to index after index exists" +│ │ │ └── • Precedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 2} +│ │ │ rule: "column existence precedes index existence" │ │ │ -│ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} +│ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} │ │ │ │ ABSENT → PUBLIC │ │ │ │ -│ │ │ ├── • Precedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 2} -│ │ │ │ rule: "column existence precedes column dependents" -│ │ │ │ -│ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 106, Name: j, ColumnID: 2} -│ │ │ │ rule: "column name and type to public after all index column to public" -│ │ │ │ -│ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 2} -│ │ │ │ rule: "column name and type to public after all index column to public" -│ │ │ │ │ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} -│ │ │ rule: "index-column added to index after index exists" +│ │ │ rule: "index existence precedes index dependents" │ │ │ -│ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} -│ │ │ │ ABSENT → BACKFILL_ONLY +│ │ └── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} +│ │ │ ABSENT → PUBLIC +│ │ │ +│ │ ├── • Precedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 2} +│ │ │ rule: "column existence precedes column dependents" +│ │ │ +│ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ rule: "index existence precedes index dependents" +│ │ +│ ├── • 3 elements transitioning toward TRANSIENT_ABSENT +│ │ │ +│ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} +│ │ │ │ ABSENT → DELETE_ONLY │ │ │ │ │ │ │ └── • Precedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 2} -│ │ │ rule: "column existence precedes index existence" +│ │ │ rule: "column existence precedes temp index existence" │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} │ │ │ │ ABSENT → PUBLIC │ │ │ │ │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} -│ │ │ rule: "temp index exists before columns, partitioning, and partial" -│ │ │ rule: "index-column added to index after temp index exists" +│ │ │ rule: "temp index existence precedes index dependents" │ │ │ │ │ └── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} │ │ │ ABSENT → PUBLIC @@ -76,23 +78,8 @@ EXPLAIN (ddl, verbose) ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL DEFAU │ │ ├── • Precedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 2} │ │ │ rule: "column existence precedes column dependents" │ │ │ -│ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 106, Name: j, ColumnID: 2} -│ │ │ rule: "column name and type to public after all index column to public" -│ │ │ -│ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 2} -│ │ │ rule: "column name and type to public after all index column to public" -│ │ │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} -│ │ rule: "temp index exists before columns, partitioning, and partial" -│ │ rule: "index-column added to index after temp index exists" -│ │ -│ ├── • 1 element transitioning toward TRANSIENT_ABSENT -│ │ │ -│ │ └── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} -│ │ │ ABSENT → DELETE_ONLY -│ │ │ -│ │ └── • Precedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 2} -│ │ rule: "column existence precedes temporary index existence" +│ │ rule: "temp index existence precedes index dependents" │ │ │ └── • 11 Mutation operations │ │ @@ -150,33 +137,33 @@ EXPLAIN (ddl, verbose) ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL DEFAU │ │ TableID: 106 │ │ TemporaryIndexID: 3 │ │ -│ ├── • MakeAddedTempIndexDeleteOnly -│ │ Index: -│ │ ConstraintID: 3 -│ │ IndexID: 3 -│ │ IsUnique: true -│ │ SourceIndexID: 1 -│ │ TableID: 106 -│ │ │ ├── • AddColumnToIndex │ │ ColumnID: 1 -│ │ IndexID: 3 +│ │ IndexID: 2 │ │ TableID: 106 │ │ │ ├── • AddColumnToIndex │ │ ColumnID: 2 -│ │ IndexID: 3 +│ │ IndexID: 2 │ │ Kind: 2 │ │ TableID: 106 │ │ +│ ├── • MakeAddedTempIndexDeleteOnly +│ │ Index: +│ │ ConstraintID: 3 +│ │ IndexID: 3 +│ │ IsUnique: true +│ │ SourceIndexID: 1 +│ │ TableID: 106 +│ │ │ ├── • AddColumnToIndex │ │ ColumnID: 1 -│ │ IndexID: 2 +│ │ IndexID: 3 │ │ TableID: 106 │ │ │ └── • AddColumnToIndex │ ColumnID: 2 -│ IndexID: 2 +│ IndexID: 3 │ Kind: 2 │ TableID: 106 │ @@ -365,8 +352,11 @@ EXPLAIN (ddl, verbose) ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL DEFAU │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 1} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} │ │ │ PUBLIC → WRITE_ONLY @@ -375,15 +365,30 @@ EXPLAIN (ddl, verbose) ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL DEFAU │ │ │ PUBLIC → ABSENT │ │ │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} - │ │ rule: "index no longer public before dependents removed" + │ │ rule: "index no longer public before dependents" │ │ │ ├── • 3 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 106, ColumnID: 2} │ │ │ │ WRITE_ONLY → PUBLIC │ │ │ │ - │ │ │ └── • Precedence dependency from PUBLIC PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ rule: "adding column depends on primary index" + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 106, Name: j, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnDefaultExpression:{DescID: 106, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ rule: "swapped primary index public before column" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ │ VALIDATED → PUBLIC @@ -391,21 +396,40 @@ EXPLAIN (ddl, verbose) ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL DEFAU │ │ │ ├── • SameStagePrecedence dependency from VALIDATED PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} │ │ │ │ rule: "primary index swap" │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} - │ │ │ rule: "index named right before index becomes public" + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ rule: "index named right before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ │ │ └── • IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} │ │ │ ABSENT → PUBLIC │ │ │ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ rule: "index existence precedes index name and comment" + │ │ rule: "index existence precedes index dependents" │ │ - │ ├── • 1 element transitioning toward TRANSIENT_ABSENT + │ ├── • 3 elements transitioning toward TRANSIENT_ABSENT │ │ │ - │ │ └── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} - │ │ WRITE_ONLY → TRANSIENT_DELETE_ONLY + │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ WRITE_ONLY → TRANSIENT_DELETE_ONLY + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → TRANSIENT_ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → TRANSIENT_ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ └── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ │ PUBLIC → TRANSIENT_ABSENT + │ │ │ + │ │ └── • skip PUBLIC → TRANSIENT_ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ - │ └── • 10 Mutation operations + │ └── • 9 Mutation operations │ │ │ ├── • MakeDroppedPrimaryIndexDeleteAndWriteOnly │ │ IndexID: 1 @@ -425,11 +449,6 @@ EXPLAIN (ddl, verbose) ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL DEFAU │ │ IndexID: 3 │ │ TableID: 106 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 1 - │ │ TableID: 106 - │ │ │ ├── • MakeAddedPrimaryIndexPublic │ │ EventBase: │ │ Authorization: @@ -465,7 +484,7 @@ EXPLAIN (ddl, verbose) ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL DEFAU │ └── • UpdateSchemaChangerJob │ IsNonCancelable: true │ JobID: 1 - │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 3 with 1 MutationType op pending + │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 3 with 3 MutationType ops pending │ ├── • Stage 2 of 3 in PostCommitNonRevertiblePhase │ │ @@ -474,19 +493,38 @@ EXPLAIN (ddl, verbose) ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL DEFAU │ │ └── • PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} │ │ WRITE_ONLY → DELETE_ONLY │ │ - │ └── • 3 Mutation operations + │ ├── • 1 element transitioning toward TRANSIENT_ABSENT + │ │ │ + │ │ └── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT + │ │ │ + │ │ ├── • Precedence dependency from TRANSIENT_ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from TRANSIENT_ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ rule: "dependents removed before index" + │ │ + │ └── • 5 Mutation operations │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 1 │ │ TableID: 106 │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 3 + │ │ TableID: 106 + │ │ + │ ├── • MakeIndexAbsent + │ │ IndexID: 3 + │ │ TableID: 106 + │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 106 │ │ │ └── • UpdateSchemaChangerJob │ IsNonCancelable: true │ JobID: 1 - │ RunningStatus: PostCommitNonRevertiblePhase stage 3 of 3 with 4 MutationType ops pending + │ RunningStatus: PostCommitNonRevertiblePhase stage 3 of 3 with 2 MutationType ops pending │ └── • Stage 3 of 3 in PostCommitNonRevertiblePhase │ @@ -498,26 +536,10 @@ EXPLAIN (ddl, verbose) ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL DEFAU │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 1} │ │ rule: "dependents removed before index" │ │ - │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 1} - │ │ rule: "dependents removed before index" - │ │ - │ └── • SameStagePrecedence dependency from TRANSIENT_ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} - │ rule: "temp indexes reach absent at the same time as other indexes" + │ └── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 1} + │ rule: "dependents removed before index" │ - ├── • 1 element transitioning toward TRANSIENT_ABSENT - │ │ - │ └── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} - │ TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT - │ - └── • 6 Mutation operations - │ - ├── • CreateGcJobForIndex - │ IndexID: 3 - │ TableID: 106 - │ - ├── • MakeIndexAbsent - │ IndexID: 3 - │ TableID: 106 + └── • 4 Mutation operations │ ├── • CreateGcJobForIndex │ IndexID: 1 diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/add_column.rollback_1_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/add_column.rollback_1_of_7 index 39ab109c74a5..ee3b877fbdf9 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/add_column.rollback_1_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/add_column.rollback_1_of_7 @@ -25,8 +25,17 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 7; │ │ │ rule: "dependents removed before column" │ │ │ rule: "column type removed right before column when not dropping relation" │ │ │ - │ │ └── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ rule: "indexes containing columns reach absent before column" + │ │ ├── • Precedence dependency from ABSENT ColumnDefaultExpression:{DescID: 106, ColumnID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "indexes containing column reach absent before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ rule: "dependents removed before column" │ │ │ ├── • ColumnName:{DescID: 106, Name: j, ColumnID: 2} │ │ PUBLIC → ABSENT @@ -40,24 +49,30 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 7; │ ├── • ColumnDefaultExpression:{DescID: 106, ColumnID: 2} │ │ PUBLIC → ABSENT │ │ - │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} - │ │ PUBLIC → ABSENT - │ │ - │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} - │ │ PUBLIC → ABSENT - │ │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ BACKFILL_ONLY → ABSENT │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} │ │ rule: "dependents removed before index" │ │ + │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" + │ │ + │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" + │ │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ │ DELETE_ONLY → ABSENT │ │ │ @@ -68,40 +83,24 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 7; │ │ rule: "dependents removed before index" │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ └── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} - │ PUBLIC → ABSENT + │ │ PUBLIC → ABSENT + │ │ + │ └── • skip PUBLIC → ABSENT operations + │ rule: "skip index-column removal ops on index removal" │ - └── • 13 Mutation operations + └── • 9 Mutation operations │ ├── • SetColumnName │ ColumnID: 2 │ Name: crdb_internal_column_2_name_placeholder │ TableID: 106 │ - ├── • RemoveColumnFromIndex - │ ColumnID: 1 - │ IndexID: 2 - │ TableID: 106 - │ - ├── • RemoveColumnFromIndex - │ ColumnID: 2 - │ IndexID: 2 - │ Kind: 2 - │ TableID: 106 - │ - ├── • RemoveColumnFromIndex - │ ColumnID: 1 - │ IndexID: 3 - │ TableID: 106 - │ - ├── • RemoveColumnFromIndex - │ ColumnID: 2 - │ IndexID: 3 - │ Kind: 2 - │ TableID: 106 - │ ├── • CreateGcJobForIndex │ IndexID: 2 │ StatementForDropJob: diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/add_column.rollback_2_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/add_column.rollback_2_of_7 index e6d3b9206537..35f9308c6b43 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/add_column.rollback_2_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/add_column.rollback_2_of_7 @@ -22,36 +22,54 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 2 of 7; │ │ │ │ PUBLIC → ABSENT │ │ │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} - │ │ │ rule: "column dependents removed after column no longer public" - │ │ │ - │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} - │ │ │ PUBLIC → ABSENT - │ │ │ - │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} - │ │ │ PUBLIC → ABSENT + │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ │ BACKFILL_ONLY → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} │ │ │ │ rule: "dependents removed before index" │ │ │ │ - │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} │ │ │ │ rule: "dependents removed before index" │ │ │ │ - │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} │ │ │ rule: "dependents removed before index" │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} + │ │ │ rule: "column no longer public before dependents" + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ - │ └── • 11 Mutation operations + │ └── • 7 Mutation operations │ │ │ ├── • MakeDroppedColumnDeleteOnly │ │ ColumnID: 2 @@ -62,32 +80,10 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 2 of 7; │ │ Name: crdb_internal_column_2_name_placeholder │ │ TableID: 106 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 2 - │ │ Kind: 2 - │ │ TableID: 106 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 3 │ │ TableID: 106 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 3 - │ │ Kind: 2 - │ │ TableID: 106 - │ │ │ ├── • CreateGcJobForIndex │ │ IndexID: 2 │ │ StatementForDropJob: @@ -129,20 +125,32 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 2 of 7; │ │ │ rule: "dependents removed before column" │ │ │ rule: "column type removed right before column when not dropping relation" │ │ │ - │ │ └── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ rule: "indexes containing columns reach absent before column" + │ │ ├── • Precedence dependency from ABSENT ColumnDefaultExpression:{DescID: 106, ColumnID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "indexes containing column reach absent before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ rule: "dependents removed before column" │ │ │ ├── • ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 2} │ │ │ PUBLIC → ABSENT │ │ │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} - │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ └── • SameStagePrecedence dependency from ABSENT ColumnDefaultExpression:{DescID: 106, ColumnID: 2} │ │ rule: "column type dependents removed right before column type" │ │ │ ├── • ColumnDefaultExpression:{DescID: 106, ColumnID: 2} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} + │ │ rule: "column no longer public before dependents" │ │ │ └── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ DELETE_ONLY → ABSENT diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/add_column.rollback_3_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/add_column.rollback_3_of_7 index 2897ce887f54..bec277862d5d 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/add_column.rollback_3_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/add_column.rollback_3_of_7 @@ -22,36 +22,54 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 3 of 7; │ │ │ │ PUBLIC → ABSENT │ │ │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} - │ │ │ rule: "column dependents removed after column no longer public" - │ │ │ - │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} - │ │ │ PUBLIC → ABSENT - │ │ │ - │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} - │ │ │ PUBLIC → ABSENT + │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ │ BACKFILL_ONLY → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} │ │ │ │ rule: "dependents removed before index" │ │ │ │ - │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} │ │ │ │ rule: "dependents removed before index" │ │ │ │ - │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} │ │ │ rule: "dependents removed before index" │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} + │ │ │ rule: "column no longer public before dependents" + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ - │ └── • 11 Mutation operations + │ └── • 7 Mutation operations │ │ │ ├── • MakeDroppedColumnDeleteOnly │ │ ColumnID: 2 @@ -62,32 +80,10 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 3 of 7; │ │ Name: crdb_internal_column_2_name_placeholder │ │ TableID: 106 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 2 - │ │ Kind: 2 - │ │ TableID: 106 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 3 │ │ TableID: 106 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 3 - │ │ Kind: 2 - │ │ TableID: 106 - │ │ │ ├── • CreateGcJobForIndex │ │ IndexID: 2 │ │ StatementForDropJob: @@ -129,20 +125,32 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 3 of 7; │ │ │ rule: "dependents removed before column" │ │ │ rule: "column type removed right before column when not dropping relation" │ │ │ - │ │ └── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ rule: "indexes containing columns reach absent before column" + │ │ ├── • Precedence dependency from ABSENT ColumnDefaultExpression:{DescID: 106, ColumnID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "indexes containing column reach absent before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ rule: "dependents removed before column" │ │ │ ├── • ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 2} │ │ │ PUBLIC → ABSENT │ │ │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} - │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ └── • SameStagePrecedence dependency from ABSENT ColumnDefaultExpression:{DescID: 106, ColumnID: 2} │ │ rule: "column type dependents removed right before column type" │ │ │ ├── • ColumnDefaultExpression:{DescID: 106, ColumnID: 2} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} + │ │ rule: "column no longer public before dependents" │ │ │ └── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ DELETE_ONLY → ABSENT diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/add_column.rollback_4_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/add_column.rollback_4_of_7 index dc3334fd2f54..40f94e5ec9fa 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/add_column.rollback_4_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/add_column.rollback_4_of_7 @@ -22,36 +22,54 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 7; │ │ │ │ PUBLIC → ABSENT │ │ │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} - │ │ │ rule: "column dependents removed after column no longer public" - │ │ │ - │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} - │ │ │ PUBLIC → ABSENT - │ │ │ - │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} - │ │ │ PUBLIC → ABSENT + │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ │ DELETE_ONLY → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} │ │ │ │ rule: "dependents removed before index" │ │ │ │ - │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} │ │ │ │ rule: "dependents removed before index" │ │ │ │ - │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} │ │ │ rule: "dependents removed before index" │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} + │ │ │ rule: "column no longer public before dependents" + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ - │ └── • 11 Mutation operations + │ └── • 7 Mutation operations │ │ │ ├── • MakeDroppedColumnDeleteOnly │ │ ColumnID: 2 @@ -62,15 +80,8 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 7; │ │ Name: crdb_internal_column_2_name_placeholder │ │ TableID: 106 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 2 - │ │ Kind: 2 + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 3 │ │ TableID: 106 │ │ │ ├── • CreateGcJobForIndex @@ -92,21 +103,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 7; │ │ IndexID: 2 │ │ TableID: 106 │ │ - │ ├── • MakeDroppedIndexDeleteOnly - │ │ IndexID: 3 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 3 - │ │ Kind: 2 - │ │ TableID: 106 - │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 106 │ │ @@ -129,20 +125,32 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 7; │ │ │ rule: "dependents removed before column" │ │ │ rule: "column type removed right before column when not dropping relation" │ │ │ - │ │ └── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ rule: "indexes containing columns reach absent before column" + │ │ ├── • Precedence dependency from ABSENT ColumnDefaultExpression:{DescID: 106, ColumnID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "indexes containing column reach absent before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ rule: "dependents removed before column" │ │ │ ├── • ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 2} │ │ │ PUBLIC → ABSENT │ │ │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} - │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ └── • SameStagePrecedence dependency from ABSENT ColumnDefaultExpression:{DescID: 106, ColumnID: 2} │ │ rule: "column type dependents removed right before column type" │ │ │ ├── • ColumnDefaultExpression:{DescID: 106, ColumnID: 2} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} + │ │ rule: "column no longer public before dependents" │ │ │ └── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ DELETE_ONLY → ABSENT diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/add_column.rollback_5_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/add_column.rollback_5_of_7 index d2f46e37b5c9..12ce00a4c7e8 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/add_column.rollback_5_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/add_column.rollback_5_of_7 @@ -22,27 +22,45 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 7; │ │ │ │ PUBLIC → ABSENT │ │ │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} - │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ rule: "column no longer public before dependents" + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ MERGE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} - │ │ │ PUBLIC → ABSENT - │ │ │ - │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ MERGE_ONLY → DELETE_ONLY + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} + │ │ │ rule: "column no longer public before dependents" + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ - │ └── • 10 Mutation operations + │ └── • 6 Mutation operations │ │ │ ├── • MakeDroppedColumnDeleteOnly │ │ ColumnID: 2 @@ -53,32 +71,10 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 7; │ │ Name: crdb_internal_column_2_name_placeholder │ │ TableID: 106 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 2 - │ │ Kind: 2 - │ │ TableID: 106 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 3 │ │ TableID: 106 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 3 - │ │ Kind: 2 - │ │ TableID: 106 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 2 │ │ TableID: 106 @@ -105,31 +101,43 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 7; │ │ │ rule: "dependents removed before column" │ │ │ rule: "column type removed right before column when not dropping relation" │ │ │ - │ │ └── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ rule: "indexes containing columns reach absent before column" + │ │ ├── • Precedence dependency from ABSENT ColumnDefaultExpression:{DescID: 106, ColumnID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "indexes containing column reach absent before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ rule: "dependents removed before column" │ │ │ ├── • ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 2} │ │ │ PUBLIC → ABSENT │ │ │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} - │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ └── • SameStagePrecedence dependency from ABSENT ColumnDefaultExpression:{DescID: 106, ColumnID: 2} │ │ rule: "column type dependents removed right before column type" │ │ │ ├── • ColumnDefaultExpression:{DescID: 106, ColumnID: 2} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} + │ │ rule: "column no longer public before dependents" │ │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ DELETE_ONLY → ABSENT │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} │ │ rule: "dependents removed before index" │ │ │ └── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/add_column.rollback_6_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/add_column.rollback_6_of_7 index 1acc2b90861d..67afd60894a1 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/add_column.rollback_6_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/add_column.rollback_6_of_7 @@ -22,27 +22,45 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 7; │ │ │ │ PUBLIC → ABSENT │ │ │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} - │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ rule: "column no longer public before dependents" + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ MERGE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} - │ │ │ PUBLIC → ABSENT - │ │ │ - │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ MERGE_ONLY → DELETE_ONLY + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} + │ │ │ rule: "column no longer public before dependents" + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ - │ └── • 10 Mutation operations + │ └── • 6 Mutation operations │ │ │ ├── • MakeDroppedColumnDeleteOnly │ │ ColumnID: 2 @@ -53,32 +71,10 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 7; │ │ Name: crdb_internal_column_2_name_placeholder │ │ TableID: 106 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 2 - │ │ Kind: 2 - │ │ TableID: 106 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 3 │ │ TableID: 106 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 3 - │ │ Kind: 2 - │ │ TableID: 106 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 2 │ │ TableID: 106 @@ -105,31 +101,43 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 7; │ │ │ rule: "dependents removed before column" │ │ │ rule: "column type removed right before column when not dropping relation" │ │ │ - │ │ └── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ rule: "indexes containing columns reach absent before column" + │ │ ├── • Precedence dependency from ABSENT ColumnDefaultExpression:{DescID: 106, ColumnID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "indexes containing column reach absent before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ rule: "dependents removed before column" │ │ │ ├── • ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 2} │ │ │ PUBLIC → ABSENT │ │ │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} - │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ └── • SameStagePrecedence dependency from ABSENT ColumnDefaultExpression:{DescID: 106, ColumnID: 2} │ │ rule: "column type dependents removed right before column type" │ │ │ ├── • ColumnDefaultExpression:{DescID: 106, ColumnID: 2} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} + │ │ rule: "column no longer public before dependents" │ │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ DELETE_ONLY → ABSENT │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} │ │ rule: "dependents removed before index" │ │ │ └── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/add_column.rollback_7_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/add_column.rollback_7_of_7 index 9d7f4e006686..1fd8c4d71cf1 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/add_column.rollback_7_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/add_column.rollback_7_of_7 @@ -22,27 +22,45 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ │ │ │ PUBLIC → ABSENT │ │ │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} - │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ rule: "column no longer public before dependents" + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} - │ │ │ PUBLIC → ABSENT - │ │ │ - │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} + │ │ │ rule: "column no longer public before dependents" + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ - │ └── • 10 Mutation operations + │ └── • 6 Mutation operations │ │ │ ├── • MakeDroppedColumnDeleteOnly │ │ ColumnID: 2 @@ -53,17 +71,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ │ Name: crdb_internal_column_2_name_placeholder │ │ TableID: 106 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 2 - │ │ Kind: 2 - │ │ TableID: 106 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 2 │ │ TableID: 106 @@ -72,17 +79,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ │ IndexID: 3 │ │ TableID: 106 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 3 - │ │ Kind: 2 - │ │ TableID: 106 - │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 106 │ │ @@ -105,31 +101,43 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ │ │ rule: "dependents removed before column" │ │ │ rule: "column type removed right before column when not dropping relation" │ │ │ - │ │ └── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ rule: "indexes containing columns reach absent before column" + │ │ ├── • Precedence dependency from ABSENT ColumnDefaultExpression:{DescID: 106, ColumnID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "indexes containing column reach absent before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ rule: "dependents removed before column" │ │ │ ├── • ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 2} │ │ │ PUBLIC → ABSENT │ │ │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} - │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ └── • SameStagePrecedence dependency from ABSENT ColumnDefaultExpression:{DescID: 106, ColumnID: 2} │ │ rule: "column type dependents removed right before column type" │ │ │ ├── • ColumnDefaultExpression:{DescID: 106, ColumnID: 2} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} + │ │ rule: "column no longer public before dependents" │ │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ DELETE_ONLY → ABSENT │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} │ │ rule: "dependents removed before index" │ │ │ └── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/add_column_default_seq b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_default_seq index 9f32caf14a5f..7f42f2e53628 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/add_column_default_seq +++ b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_default_seq @@ -12,7 +12,7 @@ EXPLAIN (ddl, verbose) ALTER TABLE db.public.tbl ADD COLUMN l INT NOT NULL DEFAU │ │ │ └── • Stage 1 of 1 in StatementPhase │ │ -│ ├── • 9 elements transitioning toward PUBLIC +│ ├── • 7 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 106, ColumnID: 2} │ │ │ ABSENT → DELETE_ONLY @@ -21,14 +21,15 @@ EXPLAIN (ddl, verbose) ALTER TABLE db.public.tbl ADD COLUMN l INT NOT NULL DEFAU │ │ │ │ ABSENT → PUBLIC │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 2} -│ │ │ rule: "column name set right after column existence" │ │ │ rule: "column existence precedes column dependents" +│ │ │ rule: "column name and type set right after column existence" │ │ │ │ │ ├── • ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 2} │ │ │ │ ABSENT → PUBLIC │ │ │ │ -│ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 106, Name: l, ColumnID: 2} -│ │ │ rule: "column named before column type becomes public" +│ │ │ └── • SameStagePrecedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 2} +│ │ │ rule: "column existence precedes column dependents" +│ │ │ rule: "column name and type set right after column existence" │ │ │ │ │ ├── • ColumnDefaultExpression:{DescID: 106, ColumnID: 2} │ │ │ │ ABSENT → PUBLIC @@ -36,39 +37,40 @@ EXPLAIN (ddl, verbose) ALTER TABLE db.public.tbl ADD COLUMN l INT NOT NULL DEFAU │ │ │ └── • Precedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 2} │ │ │ rule: "column existence precedes column dependents" │ │ │ -│ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} -│ │ │ │ ABSENT → PUBLIC +│ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ │ ABSENT → BACKFILL_ONLY │ │ │ │ -│ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} -│ │ │ rule: "index-column added to index after index exists" +│ │ │ └── • Precedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 2} +│ │ │ rule: "column existence precedes index existence" │ │ │ -│ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} +│ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} │ │ │ │ ABSENT → PUBLIC │ │ │ │ -│ │ │ ├── • Precedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 2} -│ │ │ │ rule: "column existence precedes column dependents" -│ │ │ │ -│ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 106, Name: l, ColumnID: 2} -│ │ │ │ rule: "column name and type to public after all index column to public" -│ │ │ │ -│ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 2} -│ │ │ │ rule: "column name and type to public after all index column to public" -│ │ │ │ │ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} -│ │ │ rule: "index-column added to index after index exists" +│ │ │ rule: "index existence precedes index dependents" │ │ │ -│ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} -│ │ │ │ ABSENT → BACKFILL_ONLY +│ │ └── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} +│ │ │ ABSENT → PUBLIC +│ │ │ +│ │ ├── • Precedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 2} +│ │ │ rule: "column existence precedes column dependents" +│ │ │ +│ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ rule: "index existence precedes index dependents" +│ │ +│ ├── • 3 elements transitioning toward TRANSIENT_ABSENT +│ │ │ +│ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} +│ │ │ │ ABSENT → DELETE_ONLY │ │ │ │ │ │ │ └── • Precedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 2} -│ │ │ rule: "column existence precedes index existence" +│ │ │ rule: "column existence precedes temp index existence" │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} │ │ │ │ ABSENT → PUBLIC │ │ │ │ │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} -│ │ │ rule: "temp index exists before columns, partitioning, and partial" -│ │ │ rule: "index-column added to index after temp index exists" +│ │ │ rule: "temp index existence precedes index dependents" │ │ │ │ │ └── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} │ │ │ ABSENT → PUBLIC @@ -76,23 +78,8 @@ EXPLAIN (ddl, verbose) ALTER TABLE db.public.tbl ADD COLUMN l INT NOT NULL DEFAU │ │ ├── • Precedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 2} │ │ │ rule: "column existence precedes column dependents" │ │ │ -│ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 106, Name: l, ColumnID: 2} -│ │ │ rule: "column name and type to public after all index column to public" -│ │ │ -│ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 2} -│ │ │ rule: "column name and type to public after all index column to public" -│ │ │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} -│ │ rule: "temp index exists before columns, partitioning, and partial" -│ │ rule: "index-column added to index after temp index exists" -│ │ -│ ├── • 1 element transitioning toward TRANSIENT_ABSENT -│ │ │ -│ │ └── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} -│ │ │ ABSENT → DELETE_ONLY -│ │ │ -│ │ └── • Precedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 2} -│ │ rule: "column existence precedes temporary index existence" +│ │ rule: "temp index existence precedes index dependents" │ │ │ └── • 12 Mutation operations │ │ @@ -158,33 +145,33 @@ EXPLAIN (ddl, verbose) ALTER TABLE db.public.tbl ADD COLUMN l INT NOT NULL DEFAU │ │ TableID: 106 │ │ TemporaryIndexID: 3 │ │ -│ ├── • MakeAddedTempIndexDeleteOnly -│ │ Index: -│ │ ConstraintID: 3 -│ │ IndexID: 3 -│ │ IsUnique: true -│ │ SourceIndexID: 1 -│ │ TableID: 106 -│ │ │ ├── • AddColumnToIndex │ │ ColumnID: 1 -│ │ IndexID: 3 +│ │ IndexID: 2 │ │ TableID: 106 │ │ │ ├── • AddColumnToIndex │ │ ColumnID: 2 -│ │ IndexID: 3 +│ │ IndexID: 2 │ │ Kind: 2 │ │ TableID: 106 │ │ +│ ├── • MakeAddedTempIndexDeleteOnly +│ │ Index: +│ │ ConstraintID: 3 +│ │ IndexID: 3 +│ │ IsUnique: true +│ │ SourceIndexID: 1 +│ │ TableID: 106 +│ │ │ ├── • AddColumnToIndex │ │ ColumnID: 1 -│ │ IndexID: 2 +│ │ IndexID: 3 │ │ TableID: 106 │ │ │ └── • AddColumnToIndex │ ColumnID: 2 -│ IndexID: 2 +│ IndexID: 3 │ Kind: 2 │ TableID: 106 │ @@ -390,8 +377,11 @@ EXPLAIN (ddl, verbose) ALTER TABLE db.public.tbl ADD COLUMN l INT NOT NULL DEFAU │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 1} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} │ │ │ PUBLIC → WRITE_ONLY @@ -400,15 +390,30 @@ EXPLAIN (ddl, verbose) ALTER TABLE db.public.tbl ADD COLUMN l INT NOT NULL DEFAU │ │ │ PUBLIC → ABSENT │ │ │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} - │ │ rule: "index no longer public before dependents removed" + │ │ rule: "index no longer public before dependents" │ │ │ ├── • 3 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 106, ColumnID: 2} │ │ │ │ WRITE_ONLY → PUBLIC │ │ │ │ - │ │ │ └── • Precedence dependency from PUBLIC PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ rule: "adding column depends on primary index" + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 106, Name: l, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnDefaultExpression:{DescID: 106, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ rule: "swapped primary index public before column" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ │ VALIDATED → PUBLIC @@ -416,21 +421,40 @@ EXPLAIN (ddl, verbose) ALTER TABLE db.public.tbl ADD COLUMN l INT NOT NULL DEFAU │ │ │ ├── • SameStagePrecedence dependency from VALIDATED PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} │ │ │ │ rule: "primary index swap" │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} - │ │ │ rule: "index named right before index becomes public" + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ rule: "index named right before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ │ │ └── • IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} │ │ │ ABSENT → PUBLIC │ │ │ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ rule: "index existence precedes index name and comment" + │ │ rule: "index existence precedes index dependents" │ │ - │ ├── • 1 element transitioning toward TRANSIENT_ABSENT + │ ├── • 3 elements transitioning toward TRANSIENT_ABSENT │ │ │ - │ │ └── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} - │ │ WRITE_ONLY → TRANSIENT_DELETE_ONLY + │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ WRITE_ONLY → TRANSIENT_DELETE_ONLY + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → TRANSIENT_ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → TRANSIENT_ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ └── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ │ PUBLIC → TRANSIENT_ABSENT + │ │ │ + │ │ └── • skip PUBLIC → TRANSIENT_ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ - │ └── • 11 Mutation operations + │ └── • 10 Mutation operations │ │ │ ├── • MakeDroppedPrimaryIndexDeleteAndWriteOnly │ │ IndexID: 1 @@ -450,11 +474,6 @@ EXPLAIN (ddl, verbose) ALTER TABLE db.public.tbl ADD COLUMN l INT NOT NULL DEFAU │ │ IndexID: 3 │ │ TableID: 106 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 1 - │ │ TableID: 106 - │ │ │ ├── • MakeAddedPrimaryIndexPublic │ │ EventBase: │ │ Authorization: @@ -493,7 +512,7 @@ EXPLAIN (ddl, verbose) ALTER TABLE db.public.tbl ADD COLUMN l INT NOT NULL DEFAU │ └── • UpdateSchemaChangerJob │ IsNonCancelable: true │ JobID: 1 - │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 3 with 1 MutationType op pending + │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 3 with 3 MutationType ops pending │ ├── • Stage 2 of 3 in PostCommitNonRevertiblePhase │ │ @@ -502,12 +521,31 @@ EXPLAIN (ddl, verbose) ALTER TABLE db.public.tbl ADD COLUMN l INT NOT NULL DEFAU │ │ └── • PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} │ │ WRITE_ONLY → DELETE_ONLY │ │ - │ └── • 4 Mutation operations + │ ├── • 1 element transitioning toward TRANSIENT_ABSENT + │ │ │ + │ │ └── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT + │ │ │ + │ │ ├── • Precedence dependency from TRANSIENT_ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from TRANSIENT_ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ rule: "dependents removed before index" + │ │ + │ └── • 6 Mutation operations │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 1 │ │ TableID: 106 │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 3 + │ │ TableID: 106 + │ │ + │ ├── • MakeIndexAbsent + │ │ IndexID: 3 + │ │ TableID: 106 + │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 106 │ │ @@ -517,7 +555,7 @@ EXPLAIN (ddl, verbose) ALTER TABLE db.public.tbl ADD COLUMN l INT NOT NULL DEFAU │ └── • UpdateSchemaChangerJob │ IsNonCancelable: true │ JobID: 1 - │ RunningStatus: PostCommitNonRevertiblePhase stage 3 of 3 with 4 MutationType ops pending + │ RunningStatus: PostCommitNonRevertiblePhase stage 3 of 3 with 2 MutationType ops pending │ └── • Stage 3 of 3 in PostCommitNonRevertiblePhase │ @@ -529,26 +567,10 @@ EXPLAIN (ddl, verbose) ALTER TABLE db.public.tbl ADD COLUMN l INT NOT NULL DEFAU │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 1} │ │ rule: "dependents removed before index" │ │ - │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 1} - │ │ rule: "dependents removed before index" - │ │ - │ └── • SameStagePrecedence dependency from TRANSIENT_ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} - │ rule: "temp indexes reach absent at the same time as other indexes" + │ └── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 1} + │ rule: "dependents removed before index" │ - ├── • 1 element transitioning toward TRANSIENT_ABSENT - │ │ - │ └── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} - │ TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT - │ - └── • 7 Mutation operations - │ - ├── • CreateGcJobForIndex - │ IndexID: 3 - │ TableID: 106 - │ - ├── • MakeIndexAbsent - │ IndexID: 3 - │ TableID: 106 + └── • 5 Mutation operations │ ├── • CreateGcJobForIndex │ IndexID: 1 diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/add_column_default_seq.rollback_1_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_default_seq.rollback_1_of_7 index 4f3dd1f1aa9e..31daede302cf 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/add_column_default_seq.rollback_1_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_default_seq.rollback_1_of_7 @@ -25,8 +25,17 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 7; │ │ │ rule: "dependents removed before column" │ │ │ rule: "column type removed right before column when not dropping relation" │ │ │ - │ │ └── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ rule: "indexes containing columns reach absent before column" + │ │ ├── • Precedence dependency from ABSENT ColumnDefaultExpression:{DescID: 106, ColumnID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "indexes containing column reach absent before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ rule: "dependents removed before column" │ │ │ ├── • ColumnName:{DescID: 106, Name: l, ColumnID: 2} │ │ PUBLIC → ABSENT @@ -40,24 +49,30 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 7; │ ├── • ColumnDefaultExpression:{DescID: 106, ColumnID: 2} │ │ PUBLIC → ABSENT │ │ - │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} - │ │ PUBLIC → ABSENT - │ │ - │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} - │ │ PUBLIC → ABSENT - │ │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ BACKFILL_ONLY → ABSENT │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} │ │ rule: "dependents removed before index" │ │ + │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" + │ │ + │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" + │ │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ │ DELETE_ONLY → ABSENT │ │ │ @@ -68,40 +83,24 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 7; │ │ rule: "dependents removed before index" │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ └── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} - │ PUBLIC → ABSENT + │ │ PUBLIC → ABSENT + │ │ + │ └── • skip PUBLIC → ABSENT operations + │ rule: "skip index-column removal ops on index removal" │ - └── • 15 Mutation operations + └── • 11 Mutation operations │ ├── • SetColumnName │ ColumnID: 2 │ Name: crdb_internal_column_2_name_placeholder │ TableID: 106 │ - ├── • RemoveColumnFromIndex - │ ColumnID: 1 - │ IndexID: 2 - │ TableID: 106 - │ - ├── • RemoveColumnFromIndex - │ ColumnID: 2 - │ IndexID: 2 - │ Kind: 2 - │ TableID: 106 - │ - ├── • RemoveColumnFromIndex - │ ColumnID: 1 - │ IndexID: 3 - │ TableID: 106 - │ - ├── • RemoveColumnFromIndex - │ ColumnID: 2 - │ IndexID: 3 - │ Kind: 2 - │ TableID: 106 - │ ├── • CreateGcJobForIndex │ IndexID: 2 │ StatementForDropJob: diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/add_column_default_seq.rollback_2_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_default_seq.rollback_2_of_7 index f103d58bdf33..67fb00c90418 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/add_column_default_seq.rollback_2_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_default_seq.rollback_2_of_7 @@ -22,36 +22,54 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 2 of 7; │ │ │ │ PUBLIC → ABSENT │ │ │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} - │ │ │ rule: "column dependents removed after column no longer public" - │ │ │ - │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} - │ │ │ PUBLIC → ABSENT - │ │ │ - │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} - │ │ │ PUBLIC → ABSENT + │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ │ BACKFILL_ONLY → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} │ │ │ │ rule: "dependents removed before index" │ │ │ │ - │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} │ │ │ │ rule: "dependents removed before index" │ │ │ │ - │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} │ │ │ rule: "dependents removed before index" │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} + │ │ │ rule: "column no longer public before dependents" + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ - │ └── • 12 Mutation operations + │ └── • 8 Mutation operations │ │ │ ├── • MakeDroppedColumnDeleteOnly │ │ ColumnID: 2 @@ -62,32 +80,10 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 2 of 7; │ │ Name: crdb_internal_column_2_name_placeholder │ │ TableID: 106 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 2 - │ │ Kind: 2 - │ │ TableID: 106 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 3 │ │ TableID: 106 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 3 - │ │ Kind: 2 - │ │ TableID: 106 - │ │ │ ├── • CreateGcJobForIndex │ │ IndexID: 2 │ │ StatementForDropJob: @@ -132,20 +128,32 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 2 of 7; │ │ │ rule: "dependents removed before column" │ │ │ rule: "column type removed right before column when not dropping relation" │ │ │ - │ │ └── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ rule: "indexes containing columns reach absent before column" + │ │ ├── • Precedence dependency from ABSENT ColumnDefaultExpression:{DescID: 106, ColumnID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "indexes containing column reach absent before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ rule: "dependents removed before column" │ │ │ ├── • ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 2} │ │ │ PUBLIC → ABSENT │ │ │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} - │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ └── • SameStagePrecedence dependency from ABSENT ColumnDefaultExpression:{DescID: 106, ColumnID: 2} │ │ rule: "column type dependents removed right before column type" │ │ │ ├── • ColumnDefaultExpression:{DescID: 106, ColumnID: 2} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} + │ │ rule: "column no longer public before dependents" │ │ │ └── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ DELETE_ONLY → ABSENT diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/add_column_default_seq.rollback_3_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_default_seq.rollback_3_of_7 index fd77017e1541..3a5bb384f22d 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/add_column_default_seq.rollback_3_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_default_seq.rollback_3_of_7 @@ -22,36 +22,54 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 3 of 7; │ │ │ │ PUBLIC → ABSENT │ │ │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} - │ │ │ rule: "column dependents removed after column no longer public" - │ │ │ - │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} - │ │ │ PUBLIC → ABSENT - │ │ │ - │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} - │ │ │ PUBLIC → ABSENT + │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ │ BACKFILL_ONLY → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} │ │ │ │ rule: "dependents removed before index" │ │ │ │ - │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} │ │ │ │ rule: "dependents removed before index" │ │ │ │ - │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} │ │ │ rule: "dependents removed before index" │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} + │ │ │ rule: "column no longer public before dependents" + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ - │ └── • 12 Mutation operations + │ └── • 8 Mutation operations │ │ │ ├── • MakeDroppedColumnDeleteOnly │ │ ColumnID: 2 @@ -62,32 +80,10 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 3 of 7; │ │ Name: crdb_internal_column_2_name_placeholder │ │ TableID: 106 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 2 - │ │ Kind: 2 - │ │ TableID: 106 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 3 │ │ TableID: 106 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 3 - │ │ Kind: 2 - │ │ TableID: 106 - │ │ │ ├── • CreateGcJobForIndex │ │ IndexID: 2 │ │ StatementForDropJob: @@ -132,20 +128,32 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 3 of 7; │ │ │ rule: "dependents removed before column" │ │ │ rule: "column type removed right before column when not dropping relation" │ │ │ - │ │ └── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ rule: "indexes containing columns reach absent before column" + │ │ ├── • Precedence dependency from ABSENT ColumnDefaultExpression:{DescID: 106, ColumnID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "indexes containing column reach absent before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ rule: "dependents removed before column" │ │ │ ├── • ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 2} │ │ │ PUBLIC → ABSENT │ │ │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} - │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ └── • SameStagePrecedence dependency from ABSENT ColumnDefaultExpression:{DescID: 106, ColumnID: 2} │ │ rule: "column type dependents removed right before column type" │ │ │ ├── • ColumnDefaultExpression:{DescID: 106, ColumnID: 2} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} + │ │ rule: "column no longer public before dependents" │ │ │ └── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ DELETE_ONLY → ABSENT diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/add_column_default_seq.rollback_4_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_default_seq.rollback_4_of_7 index 09dc38fedaf4..3e88d9d61e59 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/add_column_default_seq.rollback_4_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_default_seq.rollback_4_of_7 @@ -22,36 +22,54 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 7; │ │ │ │ PUBLIC → ABSENT │ │ │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} - │ │ │ rule: "column dependents removed after column no longer public" - │ │ │ - │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} - │ │ │ PUBLIC → ABSENT - │ │ │ - │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} - │ │ │ PUBLIC → ABSENT + │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ │ DELETE_ONLY → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} │ │ │ │ rule: "dependents removed before index" │ │ │ │ - │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} │ │ │ │ rule: "dependents removed before index" │ │ │ │ - │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} │ │ │ rule: "dependents removed before index" │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} + │ │ │ rule: "column no longer public before dependents" + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ - │ └── • 12 Mutation operations + │ └── • 8 Mutation operations │ │ │ ├── • MakeDroppedColumnDeleteOnly │ │ ColumnID: 2 @@ -62,15 +80,8 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 7; │ │ Name: crdb_internal_column_2_name_placeholder │ │ TableID: 106 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 2 - │ │ Kind: 2 + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 3 │ │ TableID: 106 │ │ │ ├── • CreateGcJobForIndex @@ -92,21 +103,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 7; │ │ IndexID: 2 │ │ TableID: 106 │ │ - │ ├── • MakeDroppedIndexDeleteOnly - │ │ IndexID: 3 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 3 - │ │ Kind: 2 - │ │ TableID: 106 - │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 106 │ │ @@ -132,20 +128,32 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 7; │ │ │ rule: "dependents removed before column" │ │ │ rule: "column type removed right before column when not dropping relation" │ │ │ - │ │ └── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ rule: "indexes containing columns reach absent before column" + │ │ ├── • Precedence dependency from ABSENT ColumnDefaultExpression:{DescID: 106, ColumnID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "indexes containing column reach absent before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ rule: "dependents removed before column" │ │ │ ├── • ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 2} │ │ │ PUBLIC → ABSENT │ │ │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} - │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ └── • SameStagePrecedence dependency from ABSENT ColumnDefaultExpression:{DescID: 106, ColumnID: 2} │ │ rule: "column type dependents removed right before column type" │ │ │ ├── • ColumnDefaultExpression:{DescID: 106, ColumnID: 2} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} + │ │ rule: "column no longer public before dependents" │ │ │ └── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ DELETE_ONLY → ABSENT diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/add_column_default_seq.rollback_5_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_default_seq.rollback_5_of_7 index 139fe5155c83..24cd5ffd6919 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/add_column_default_seq.rollback_5_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_default_seq.rollback_5_of_7 @@ -22,27 +22,45 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 7; │ │ │ │ PUBLIC → ABSENT │ │ │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} - │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ rule: "column no longer public before dependents" + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ MERGE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} - │ │ │ PUBLIC → ABSENT - │ │ │ - │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ MERGE_ONLY → DELETE_ONLY + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} + │ │ │ rule: "column no longer public before dependents" + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ - │ └── • 11 Mutation operations + │ └── • 7 Mutation operations │ │ │ ├── • MakeDroppedColumnDeleteOnly │ │ ColumnID: 2 @@ -53,32 +71,10 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 7; │ │ Name: crdb_internal_column_2_name_placeholder │ │ TableID: 106 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 2 - │ │ Kind: 2 - │ │ TableID: 106 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 3 │ │ TableID: 106 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 3 - │ │ Kind: 2 - │ │ TableID: 106 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 2 │ │ TableID: 106 @@ -108,31 +104,43 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 7; │ │ │ rule: "dependents removed before column" │ │ │ rule: "column type removed right before column when not dropping relation" │ │ │ - │ │ └── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ rule: "indexes containing columns reach absent before column" + │ │ ├── • Precedence dependency from ABSENT ColumnDefaultExpression:{DescID: 106, ColumnID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "indexes containing column reach absent before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ rule: "dependents removed before column" │ │ │ ├── • ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 2} │ │ │ PUBLIC → ABSENT │ │ │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} - │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ └── • SameStagePrecedence dependency from ABSENT ColumnDefaultExpression:{DescID: 106, ColumnID: 2} │ │ rule: "column type dependents removed right before column type" │ │ │ ├── • ColumnDefaultExpression:{DescID: 106, ColumnID: 2} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} + │ │ rule: "column no longer public before dependents" │ │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ DELETE_ONLY → ABSENT │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} │ │ rule: "dependents removed before index" │ │ │ └── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/add_column_default_seq.rollback_6_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_default_seq.rollback_6_of_7 index 8623c7f0daed..5d54fe2e19b2 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/add_column_default_seq.rollback_6_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_default_seq.rollback_6_of_7 @@ -22,27 +22,45 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 7; │ │ │ │ PUBLIC → ABSENT │ │ │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} - │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ rule: "column no longer public before dependents" + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ MERGE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} - │ │ │ PUBLIC → ABSENT - │ │ │ - │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ MERGE_ONLY → DELETE_ONLY + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} + │ │ │ rule: "column no longer public before dependents" + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ - │ └── • 11 Mutation operations + │ └── • 7 Mutation operations │ │ │ ├── • MakeDroppedColumnDeleteOnly │ │ ColumnID: 2 @@ -53,32 +71,10 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 7; │ │ Name: crdb_internal_column_2_name_placeholder │ │ TableID: 106 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 2 - │ │ Kind: 2 - │ │ TableID: 106 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 3 │ │ TableID: 106 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 3 - │ │ Kind: 2 - │ │ TableID: 106 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 2 │ │ TableID: 106 @@ -108,31 +104,43 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 7; │ │ │ rule: "dependents removed before column" │ │ │ rule: "column type removed right before column when not dropping relation" │ │ │ - │ │ └── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ rule: "indexes containing columns reach absent before column" + │ │ ├── • Precedence dependency from ABSENT ColumnDefaultExpression:{DescID: 106, ColumnID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "indexes containing column reach absent before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ rule: "dependents removed before column" │ │ │ ├── • ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 2} │ │ │ PUBLIC → ABSENT │ │ │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} - │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ └── • SameStagePrecedence dependency from ABSENT ColumnDefaultExpression:{DescID: 106, ColumnID: 2} │ │ rule: "column type dependents removed right before column type" │ │ │ ├── • ColumnDefaultExpression:{DescID: 106, ColumnID: 2} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} + │ │ rule: "column no longer public before dependents" │ │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ DELETE_ONLY → ABSENT │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} │ │ rule: "dependents removed before index" │ │ │ └── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/add_column_default_seq.rollback_7_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_default_seq.rollback_7_of_7 index c9baa726b02a..50bc4c0a2e3b 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/add_column_default_seq.rollback_7_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_default_seq.rollback_7_of_7 @@ -22,27 +22,45 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ │ │ │ PUBLIC → ABSENT │ │ │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} - │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ rule: "column no longer public before dependents" + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} - │ │ │ PUBLIC → ABSENT - │ │ │ - │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} + │ │ │ rule: "column no longer public before dependents" + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ - │ └── • 11 Mutation operations + │ └── • 7 Mutation operations │ │ │ ├── • MakeDroppedColumnDeleteOnly │ │ ColumnID: 2 @@ -53,17 +71,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ │ Name: crdb_internal_column_2_name_placeholder │ │ TableID: 106 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 2 - │ │ Kind: 2 - │ │ TableID: 106 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 2 │ │ TableID: 106 @@ -72,17 +79,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ │ IndexID: 3 │ │ TableID: 106 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 3 - │ │ Kind: 2 - │ │ TableID: 106 - │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 106 │ │ @@ -108,31 +104,43 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ │ │ rule: "dependents removed before column" │ │ │ rule: "column type removed right before column when not dropping relation" │ │ │ - │ │ └── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ rule: "indexes containing columns reach absent before column" + │ │ ├── • Precedence dependency from ABSENT ColumnDefaultExpression:{DescID: 106, ColumnID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "indexes containing column reach absent before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ rule: "dependents removed before column" │ │ │ ├── • ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 2} │ │ │ PUBLIC → ABSENT │ │ │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} - │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ └── • SameStagePrecedence dependency from ABSENT ColumnDefaultExpression:{DescID: 106, ColumnID: 2} │ │ rule: "column type dependents removed right before column type" │ │ │ ├── • ColumnDefaultExpression:{DescID: 106, ColumnID: 2} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} + │ │ rule: "column no longer public before dependents" │ │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ DELETE_ONLY → ABSENT │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} │ │ rule: "dependents removed before index" │ │ │ └── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/add_column_no_default b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_no_default index 40a2113bdbe9..6bbcb661f867 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/add_column_no_default +++ b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_no_default @@ -20,26 +20,21 @@ EXPLAIN (ddl, verbose) ALTER TABLE db.public.tbl ADD COLUMN j INT; │ │ │ │ ABSENT → PUBLIC │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 2} -│ │ │ rule: "column name set right after column existence" │ │ │ rule: "column existence precedes column dependents" +│ │ │ rule: "column name and type set right after column existence" │ │ │ │ │ ├── • ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 2} │ │ │ │ ABSENT → PUBLIC │ │ │ │ -│ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 106, Name: j, ColumnID: 2} -│ │ │ rule: "column named before column type becomes public" +│ │ │ └── • SameStagePrecedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 2} +│ │ │ rule: "column existence precedes column dependents" +│ │ │ rule: "column name and type set right after column existence" │ │ │ │ │ └── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 1} │ │ │ ABSENT → PUBLIC │ │ │ -│ │ ├── • Precedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 2} -│ │ │ rule: "column existence precedes column dependents" -│ │ │ -│ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 106, Name: j, ColumnID: 2} -│ │ │ rule: "column name and type to public after all index column to public" -│ │ │ -│ │ └── • Precedence dependency from PUBLIC ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 2} -│ │ rule: "column name and type to public after all index column to public" +│ │ └── • Precedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 2} +│ │ rule: "column existence precedes column dependents" │ │ │ └── • 5 Mutation operations │ │ @@ -136,7 +131,16 @@ EXPLAIN (ddl, verbose) ALTER TABLE db.public.tbl ADD COLUMN j INT; ├── • 1 element transitioning toward PUBLIC │ │ │ └── • Column:{DescID: 106, ColumnID: 2} - │ WRITE_ONLY → PUBLIC + │ │ WRITE_ONLY → PUBLIC + │ │ + │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 106, Name: j, ColumnID: 2} + │ │ rule: "column dependents exist before column becomes public" + │ │ + │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 2} + │ │ rule: "column dependents exist before column becomes public" + │ │ + │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 1} + │ rule: "column dependents exist before column becomes public" │ └── • 4 Mutation operations │ diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/add_column_no_default.rollback_1_of_2 b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_no_default.rollback_1_of_2 index 1193914bd295..4675d32c6441 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/add_column_no_default.rollback_1_of_2 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_no_default.rollback_1_of_2 @@ -20,9 +20,12 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 2; │ │ ├── • Precedence dependency from ABSENT ColumnName:{DescID: 106, Name: j, ColumnID: 2} │ │ │ rule: "dependents removed before column" │ │ │ - │ │ └── • SameStagePrecedence dependency from ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 2} + │ │ ├── • SameStagePrecedence dependency from ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ rule: "column type removed right before column when not dropping relation" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 1} │ │ rule: "dependents removed before column" - │ │ rule: "column type removed right before column when not dropping relation" │ │ │ ├── • ColumnName:{DescID: 106, Name: j, ColumnID: 2} │ │ PUBLIC → ABSENT diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/add_column_no_default.rollback_2_of_2 b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_no_default.rollback_2_of_2 index 79f705c77ad0..d30edd7f7b93 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/add_column_no_default.rollback_2_of_2 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_no_default.rollback_2_of_2 @@ -21,10 +21,13 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 2 of 2; │ │ │ │ PUBLIC → ABSENT │ │ │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} - │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ └── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 1} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} + │ │ rule: "column no longer public before dependents" │ │ │ └── • 5 Mutation operations │ │ @@ -61,15 +64,18 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 2 of 2; │ │ ├── • Precedence dependency from ABSENT ColumnName:{DescID: 106, Name: j, ColumnID: 2} │ │ │ rule: "dependents removed before column" │ │ │ - │ │ └── • SameStagePrecedence dependency from ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 2} + │ │ ├── • SameStagePrecedence dependency from ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ rule: "column type removed right before column when not dropping relation" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 1} │ │ rule: "dependents removed before column" - │ │ rule: "column type removed right before column when not dropping relation" │ │ │ └── • ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 2} │ │ PUBLIC → ABSENT │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 2} - │ rule: "column dependents removed after column no longer public" + │ rule: "column no longer public before dependents" │ └── • 3 Mutation operations │ diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid new file mode 100644 index 000000000000..e0be656adee5 --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid @@ -0,0 +1,913 @@ +/* setup */ +CREATE TABLE t (a INT NOT NULL); + +/* test */ +EXPLAIN (ddl, verbose) ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a); +---- +• Schema change plan for ALTER TABLE ‹defaultdb›.‹public›.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›); +│ +├── • StatementPhase +│ │ +│ └── • Stage 1 of 1 in StatementPhase +│ │ +│ ├── • 2 elements transitioning toward ABSENT +│ │ │ +│ │ ├── • Column:{DescID: 104, ColumnID: 2} +│ │ │ PUBLIC → WRITE_ONLY +│ │ │ +│ │ └── • ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} +│ │ │ PUBLIC → ABSENT +│ │ │ +│ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 2} +│ │ rule: "column no longer public before dependents" +│ │ +│ ├── • 2 elements transitioning toward PUBLIC +│ │ │ +│ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} +│ │ │ ABSENT → BACKFILL_ONLY +│ │ │ +│ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} +│ │ │ ABSENT → PUBLIC +│ │ │ +│ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} +│ │ rule: "index existence precedes index dependents" +│ │ +│ ├── • 6 elements transitioning toward TRANSIENT_ABSENT +│ │ │ +│ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ ABSENT → BACKFILL_ONLY +│ │ │ +│ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} +│ │ │ │ ABSENT → PUBLIC +│ │ │ │ +│ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ rule: "index existence precedes index dependents" +│ │ │ +│ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} +│ │ │ │ ABSENT → PUBLIC +│ │ │ │ +│ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ rule: "index existence precedes index dependents" +│ │ │ +│ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} +│ │ │ ABSENT → DELETE_ONLY +│ │ │ +│ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} +│ │ │ │ ABSENT → PUBLIC +│ │ │ │ +│ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} +│ │ │ rule: "temp index existence precedes index dependents" +│ │ │ +│ │ └── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} +│ │ │ ABSENT → PUBLIC +│ │ │ +│ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} +│ │ rule: "temp index existence precedes index dependents" +│ │ +│ └── • 11 Mutation operations +│ │ +│ ├── • MakeDroppedColumnDeleteAndWriteOnly +│ │ ColumnID: 2 +│ │ TableID: 104 +│ │ +│ ├── • LogEvent +│ │ Element: +│ │ Column: +│ │ columnId: 2 +│ │ isHidden: true +│ │ pgAttributeNum: 2 +│ │ tableId: 104 +│ │ EventBase: +│ │ Authorization: +│ │ UserName: root +│ │ Statement: ALTER TABLE ‹defaultdb›.‹public›.‹t› ALTER PRIMARY KEY USING COLUMNS +│ │ (‹a›) +│ │ StatementTag: ALTER TABLE +│ │ TargetMetadata: +│ │ SourceElementID: 1 +│ │ SubWorkID: 1 +│ │ TargetStatus: 1 +│ │ +│ ├── • SetColumnName +│ │ ColumnID: 2 +│ │ Name: crdb_internal_column_2_name_placeholder +│ │ TableID: 104 +│ │ +│ ├── • MakeAddedIndexBackfilling +│ │ Index: +│ │ ConstraintID: 2 +│ │ IndexID: 2 +│ │ IsUnique: true +│ │ SourceIndexID: 1 +│ │ TableID: 104 +│ │ TemporaryIndexID: 3 +│ │ +│ ├── • AddColumnToIndex +│ │ ColumnID: 1 +│ │ IndexID: 2 +│ │ TableID: 104 +│ │ +│ ├── • AddColumnToIndex +│ │ ColumnID: 2 +│ │ IndexID: 2 +│ │ Kind: 2 +│ │ TableID: 104 +│ │ +│ ├── • MakeAddedTempIndexDeleteOnly +│ │ Index: +│ │ ConstraintID: 3 +│ │ IndexID: 3 +│ │ IsUnique: true +│ │ SourceIndexID: 1 +│ │ TableID: 104 +│ │ +│ ├── • AddColumnToIndex +│ │ ColumnID: 1 +│ │ IndexID: 3 +│ │ TableID: 104 +│ │ +│ ├── • AddColumnToIndex +│ │ ColumnID: 2 +│ │ IndexID: 3 +│ │ Kind: 2 +│ │ TableID: 104 +│ │ +│ ├── • MakeAddedIndexBackfilling +│ │ Index: +│ │ ConstraintID: 4 +│ │ IndexID: 4 +│ │ IsUnique: true +│ │ SourceIndexID: 2 +│ │ TableID: 104 +│ │ TemporaryIndexID: 5 +│ │ +│ └── • AddColumnToIndex +│ ColumnID: 1 +│ IndexID: 4 +│ TableID: 104 +│ +├── • PreCommitPhase +│ │ +│ └── • Stage 1 of 1 in PreCommitPhase +│ │ +│ └── • 2 Mutation operations +│ │ +│ ├── • SetJobStateOnDescriptor +│ │ DescriptorID: 104 +│ │ Initialize: true +│ │ +│ └── • CreateSchemaChangerJob +│ Authorization: +│ UserName: root +│ DescriptorIDs: +│ - 104 +│ JobID: 1 +│ RunningStatus: PostCommitPhase stage 1 of 15 with 1 MutationType op pending +│ Statements: +│ - statement: ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a) +│ redactedstatement: ALTER TABLE ‹defaultdb›.‹public›.‹t› ALTER PRIMARY KEY USING +│ COLUMNS (‹a›) +│ statementtag: ALTER TABLE +│ +├── • PostCommitPhase +│ │ +│ ├── • Stage 1 of 15 in PostCommitPhase +│ │ │ +│ │ ├── • 1 element transitioning toward TRANSIENT_ABSENT +│ │ │ │ +│ │ │ └── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} +│ │ │ │ DELETE_ONLY → WRITE_ONLY +│ │ │ │ +│ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} +│ │ │ │ rule: "index-column added to index before temp index receives writes" +│ │ │ │ +│ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} +│ │ │ rule: "index-column added to index before temp index receives writes" +│ │ │ +│ │ └── • 3 Mutation operations +│ │ │ +│ │ ├── • MakeAddedIndexDeleteAndWriteOnly +│ │ │ IndexID: 3 +│ │ │ TableID: 104 +│ │ │ +│ │ ├── • SetJobStateOnDescriptor +│ │ │ DescriptorID: 104 +│ │ │ +│ │ └── • UpdateSchemaChangerJob +│ │ JobID: 1 +│ │ RunningStatus: PostCommitPhase stage 2 of 15 with 1 BackfillType op pending +│ │ +│ ├── • Stage 2 of 15 in PostCommitPhase +│ │ │ +│ │ ├── • 1 element transitioning toward TRANSIENT_ABSENT +│ │ │ │ +│ │ │ └── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ │ BACKFILL_ONLY → BACKFILLED +│ │ │ │ +│ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} +│ │ │ │ rule: "index-column added to index before index is backfilled" +│ │ │ │ +│ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} +│ │ │ │ rule: "index-column added to index before index is backfilled" +│ │ │ │ +│ │ │ └── • Precedence dependency from WRITE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} +│ │ │ rule: "temp index is WRITE_ONLY before backfill" +│ │ │ +│ │ └── • 1 Backfill operation +│ │ │ +│ │ └── • BackfillIndex +│ │ IndexID: 2 +│ │ SourceIndexID: 1 +│ │ TableID: 104 +│ │ +│ ├── • Stage 3 of 15 in PostCommitPhase +│ │ │ +│ │ ├── • 1 element transitioning toward TRANSIENT_ABSENT +│ │ │ │ +│ │ │ └── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ BACKFILLED → DELETE_ONLY +│ │ │ +│ │ └── • 3 Mutation operations +│ │ │ +│ │ ├── • MakeBackfillingIndexDeleteOnly +│ │ │ IndexID: 2 +│ │ │ TableID: 104 +│ │ │ +│ │ ├── • SetJobStateOnDescriptor +│ │ │ DescriptorID: 104 +│ │ │ +│ │ └── • UpdateSchemaChangerJob +│ │ JobID: 1 +│ │ RunningStatus: PostCommitPhase stage 4 of 15 with 1 MutationType op pending +│ │ +│ ├── • Stage 4 of 15 in PostCommitPhase +│ │ │ +│ │ ├── • 1 element transitioning toward TRANSIENT_ABSENT +│ │ │ │ +│ │ │ └── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ DELETE_ONLY → MERGE_ONLY +│ │ │ +│ │ └── • 3 Mutation operations +│ │ │ +│ │ ├── • MakeBackfilledIndexMerging +│ │ │ IndexID: 2 +│ │ │ TableID: 104 +│ │ │ +│ │ ├── • SetJobStateOnDescriptor +│ │ │ DescriptorID: 104 +│ │ │ +│ │ └── • UpdateSchemaChangerJob +│ │ JobID: 1 +│ │ RunningStatus: PostCommitPhase stage 5 of 15 with 1 BackfillType op pending +│ │ +│ ├── • Stage 5 of 15 in PostCommitPhase +│ │ │ +│ │ ├── • 1 element transitioning toward TRANSIENT_ABSENT +│ │ │ │ +│ │ │ └── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ MERGE_ONLY → MERGED +│ │ │ +│ │ └── • 1 Backfill operation +│ │ │ +│ │ └── • MergeIndex +│ │ BackfilledIndexID: 2 +│ │ TableID: 104 +│ │ TemporaryIndexID: 3 +│ │ +│ ├── • Stage 6 of 15 in PostCommitPhase +│ │ │ +│ │ ├── • 1 element transitioning toward TRANSIENT_ABSENT +│ │ │ │ +│ │ │ └── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ MERGED → WRITE_ONLY +│ │ │ +│ │ └── • 3 Mutation operations +│ │ │ +│ │ ├── • MakeMergedIndexWriteOnly +│ │ │ IndexID: 2 +│ │ │ TableID: 104 +│ │ │ +│ │ ├── • SetJobStateOnDescriptor +│ │ │ DescriptorID: 104 +│ │ │ +│ │ └── • UpdateSchemaChangerJob +│ │ JobID: 1 +│ │ RunningStatus: PostCommitPhase stage 7 of 15 with 1 ValidationType op pending +│ │ +│ ├── • Stage 7 of 15 in PostCommitPhase +│ │ │ +│ │ ├── • 1 element transitioning toward TRANSIENT_ABSENT +│ │ │ │ +│ │ │ └── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ WRITE_ONLY → VALIDATED +│ │ │ +│ │ └── • 1 Validation operation +│ │ │ +│ │ └── • ValidateUniqueIndex +│ │ IndexID: 2 +│ │ TableID: 104 +│ │ +│ ├── • Stage 8 of 15 in PostCommitPhase +│ │ │ +│ │ ├── • 2 elements transitioning toward ABSENT +│ │ │ │ +│ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} +│ │ │ │ PUBLIC → VALIDATED +│ │ │ │ +│ │ │ └── • IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} +│ │ │ │ PUBLIC → ABSENT +│ │ │ │ +│ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} +│ │ │ rule: "index no longer public before dependents" +│ │ │ +│ │ ├── • 4 elements transitioning toward TRANSIENT_ABSENT +│ │ │ │ +│ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ │ │ VALIDATED → PUBLIC +│ │ │ │ │ +│ │ │ │ ├── • SameStagePrecedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} +│ │ │ │ │ rule: "primary index swap" +│ │ │ │ │ +│ │ │ │ ├── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} +│ │ │ │ │ rule: "index dependents exist before index becomes public" +│ │ │ │ │ rule: "index named right before index becomes public" +│ │ │ │ │ +│ │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} +│ │ │ │ │ rule: "index dependents exist before index becomes public" +│ │ │ │ │ +│ │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} +│ │ │ │ rule: "index dependents exist before index becomes public" +│ │ │ │ +│ │ │ ├── • IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} +│ │ │ │ │ ABSENT → PUBLIC +│ │ │ │ │ +│ │ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ │ rule: "index existence precedes index dependents" +│ │ │ │ +│ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2} +│ │ │ │ │ ABSENT → DELETE_ONLY +│ │ │ │ │ +│ │ │ │ └── • Precedence dependency from PUBLIC PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ │ rule: "primary index with new columns should exist before temp indexes" +│ │ │ │ +│ │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} +│ │ │ │ ABSENT → PUBLIC +│ │ │ │ +│ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2} +│ │ │ rule: "temp index existence precedes index dependents" +│ │ │ +│ │ └── • 8 Mutation operations +│ │ │ +│ │ ├── • MakeDroppedPrimaryIndexDeleteAndWriteOnly +│ │ │ IndexID: 1 +│ │ │ TableID: 104 +│ │ │ +│ │ ├── • SetIndexName +│ │ │ IndexID: 1 +│ │ │ Name: crdb_internal_index_1_name_placeholder +│ │ │ TableID: 104 +│ │ │ +│ │ ├── • SetIndexName +│ │ │ IndexID: 2 +│ │ │ Name: t_pkey +│ │ │ TableID: 104 +│ │ │ +│ │ ├── • MakeAddedPrimaryIndexPublic +│ │ │ EventBase: +│ │ │ Authorization: +│ │ │ UserName: root +│ │ │ Statement: ALTER TABLE ‹defaultdb›.‹public›.‹t› ALTER PRIMARY KEY USING COLUMNS +│ │ │ (‹a›) +│ │ │ StatementTag: ALTER TABLE +│ │ │ TargetMetadata: +│ │ │ SourceElementID: 1 +│ │ │ SubWorkID: 1 +│ │ │ IndexID: 2 +│ │ │ TableID: 104 +│ │ │ +│ │ ├── • MakeAddedTempIndexDeleteOnly +│ │ │ Index: +│ │ │ ConstraintID: 5 +│ │ │ IndexID: 5 +│ │ │ IsUnique: true +│ │ │ SourceIndexID: 2 +│ │ │ TableID: 104 +│ │ │ +│ │ ├── • AddColumnToIndex +│ │ │ ColumnID: 1 +│ │ │ IndexID: 5 +│ │ │ TableID: 104 +│ │ │ +│ │ ├── • SetJobStateOnDescriptor +│ │ │ DescriptorID: 104 +│ │ │ +│ │ └── • UpdateSchemaChangerJob +│ │ JobID: 1 +│ │ RunningStatus: PostCommitPhase stage 9 of 15 with 1 MutationType op pending +│ │ +│ ├── • Stage 9 of 15 in PostCommitPhase +│ │ │ +│ │ ├── • 1 element transitioning toward TRANSIENT_ABSENT +│ │ │ │ +│ │ │ └── • TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2} +│ │ │ │ DELETE_ONLY → WRITE_ONLY +│ │ │ │ +│ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} +│ │ │ rule: "index-column added to index before temp index receives writes" +│ │ │ +│ │ └── • 3 Mutation operations +│ │ │ +│ │ ├── • MakeAddedIndexDeleteAndWriteOnly +│ │ │ IndexID: 5 +│ │ │ TableID: 104 +│ │ │ +│ │ ├── • SetJobStateOnDescriptor +│ │ │ DescriptorID: 104 +│ │ │ +│ │ └── • UpdateSchemaChangerJob +│ │ JobID: 1 +│ │ RunningStatus: PostCommitPhase stage 10 of 15 with 1 BackfillType op pending +│ │ +│ ├── • Stage 10 of 15 in PostCommitPhase +│ │ │ +│ │ ├── • 1 element transitioning toward PUBLIC +│ │ │ │ +│ │ │ └── • PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} +│ │ │ │ BACKFILL_ONLY → BACKFILLED +│ │ │ │ +│ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} +│ │ │ │ rule: "index-column added to index before index is backfilled" +│ │ │ │ +│ │ │ └── • Precedence dependency from WRITE_ONLY TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2} +│ │ │ rule: "temp index is WRITE_ONLY before backfill" +│ │ │ +│ │ └── • 1 Backfill operation +│ │ │ +│ │ └── • BackfillIndex +│ │ IndexID: 4 +│ │ SourceIndexID: 2 +│ │ TableID: 104 +│ │ +│ ├── • Stage 11 of 15 in PostCommitPhase +│ │ │ +│ │ ├── • 1 element transitioning toward PUBLIC +│ │ │ │ +│ │ │ └── • PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} +│ │ │ BACKFILLED → DELETE_ONLY +│ │ │ +│ │ └── • 3 Mutation operations +│ │ │ +│ │ ├── • MakeBackfillingIndexDeleteOnly +│ │ │ IndexID: 4 +│ │ │ TableID: 104 +│ │ │ +│ │ ├── • SetJobStateOnDescriptor +│ │ │ DescriptorID: 104 +│ │ │ +│ │ └── • UpdateSchemaChangerJob +│ │ JobID: 1 +│ │ RunningStatus: PostCommitPhase stage 12 of 15 with 1 MutationType op pending +│ │ +│ ├── • Stage 12 of 15 in PostCommitPhase +│ │ │ +│ │ ├── • 1 element transitioning toward PUBLIC +│ │ │ │ +│ │ │ └── • PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} +│ │ │ DELETE_ONLY → MERGE_ONLY +│ │ │ +│ │ └── • 3 Mutation operations +│ │ │ +│ │ ├── • MakeBackfilledIndexMerging +│ │ │ IndexID: 4 +│ │ │ TableID: 104 +│ │ │ +│ │ ├── • SetJobStateOnDescriptor +│ │ │ DescriptorID: 104 +│ │ │ +│ │ └── • UpdateSchemaChangerJob +│ │ JobID: 1 +│ │ RunningStatus: PostCommitPhase stage 13 of 15 with 1 BackfillType op pending +│ │ +│ ├── • Stage 13 of 15 in PostCommitPhase +│ │ │ +│ │ ├── • 1 element transitioning toward PUBLIC +│ │ │ │ +│ │ │ └── • PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} +│ │ │ MERGE_ONLY → MERGED +│ │ │ +│ │ └── • 1 Backfill operation +│ │ │ +│ │ └── • MergeIndex +│ │ BackfilledIndexID: 4 +│ │ TableID: 104 +│ │ TemporaryIndexID: 5 +│ │ +│ ├── • Stage 14 of 15 in PostCommitPhase +│ │ │ +│ │ ├── • 1 element transitioning toward PUBLIC +│ │ │ │ +│ │ │ └── • PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} +│ │ │ MERGED → WRITE_ONLY +│ │ │ +│ │ └── • 3 Mutation operations +│ │ │ +│ │ ├── • MakeMergedIndexWriteOnly +│ │ │ IndexID: 4 +│ │ │ TableID: 104 +│ │ │ +│ │ ├── • SetJobStateOnDescriptor +│ │ │ DescriptorID: 104 +│ │ │ +│ │ └── • UpdateSchemaChangerJob +│ │ JobID: 1 +│ │ RunningStatus: PostCommitPhase stage 15 of 15 with 1 ValidationType op pending +│ │ +│ └── • Stage 15 of 15 in PostCommitPhase +│ │ +│ ├── • 1 element transitioning toward PUBLIC +│ │ │ +│ │ └── • PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} +│ │ WRITE_ONLY → VALIDATED +│ │ +│ └── • 1 Validation operation +│ │ +│ └── • ValidateUniqueIndex +│ IndexID: 4 +│ TableID: 104 +│ +└── • PostCommitNonRevertiblePhase + │ + ├── • Stage 1 of 4 in PostCommitNonRevertiblePhase + │ │ + │ ├── • 4 elements transitioning toward ABSENT + │ │ │ + │ │ ├── • Column:{DescID: 104, ColumnID: 2} + │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ └── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ VALIDATED → DELETE_ONLY + │ │ + │ ├── • 5 elements transitioning toward TRANSIENT_ABSENT + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ WRITE_ONLY → TRANSIENT_DELETE_ONLY + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → TRANSIENT_ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → TRANSIENT_ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ │ │ PUBLIC → TRANSIENT_ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → TRANSIENT_ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2} + │ │ │ WRITE_ONLY → TRANSIENT_DELETE_ONLY + │ │ │ + │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} + │ │ │ PUBLIC → TRANSIENT_ABSENT + │ │ │ + │ │ └── • skip PUBLIC → TRANSIENT_ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" + │ │ + │ └── • 6 Mutation operations + │ │ + │ ├── • MakeDroppedColumnDeleteOnly + │ │ ColumnID: 2 + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 3 + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 5 + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 1 + │ │ TableID: 104 + │ │ + │ ├── • SetJobStateOnDescriptor + │ │ DescriptorID: 104 + │ │ + │ └── • UpdateSchemaChangerJob + │ IsNonCancelable: true + │ JobID: 1 + │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 4 with 10 MutationType ops + │ pending + │ + ├── • Stage 2 of 4 in PostCommitNonRevertiblePhase + │ │ + │ ├── • 1 element transitioning toward ABSENT + │ │ │ + │ │ └── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} + │ │ rule: "dependents removed before index" + │ │ + │ ├── • 2 elements transitioning toward PUBLIC + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ │ │ VALIDATED → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ │ │ rule: "old index absent before new index public when swapping with transient" + │ │ │ │ + │ │ │ ├── • SameStagePrecedence dependency from TRANSIENT_VALIDATED PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ rule: "primary index swap" + │ │ │ │ + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 4} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ rule: "index named right before index becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ + │ │ └── • IndexName:{DescID: 104, Name: t_pkey, IndexID: 4} + │ │ │ ABSENT → PUBLIC + │ │ │ + │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ rule: "index existence precedes index dependents" + │ │ + │ ├── • 6 elements transitioning toward TRANSIENT_ABSENT + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ PUBLIC → TRANSIENT_WRITE_ONLY + │ │ │ + │ │ ├── • IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ │ │ PUBLIC → TRANSIENT_ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from TRANSIENT_VALIDATED PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index no longer public before dependents" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → TRANSIENT_ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from TRANSIENT_VALIDATED PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → TRANSIENT_ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ │ PUBLIC → TRANSIENT_ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ ├── • Precedence dependency from TRANSIENT_VALIDATED PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → TRANSIENT_ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ │ TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from TRANSIENT_ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ └── • Precedence dependency from TRANSIENT_ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2} + │ │ │ TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT + │ │ │ + │ │ └── • Precedence dependency from TRANSIENT_ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} + │ │ rule: "dependents removed before index" + │ │ + │ └── • 12 Mutation operations + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 1 + │ │ StatementForDropJob: + │ │ Statement: ALTER TABLE defaultdb.public.t ALTER PRIMARY KEY USING COLUMNS (a) + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.‹public›.‹t› ALTER PRIMARY KEY USING COLUMNS + │ │ (‹a›) + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ IndexID: 1 + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedPrimaryIndexDeleteAndWriteOnly + │ │ IndexID: 2 + │ │ TableID: 104 + │ │ + │ ├── • SetIndexName + │ │ IndexID: 2 + │ │ Name: crdb_internal_index_2_name_placeholder + │ │ TableID: 104 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 3 + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ IndexID: 3 + │ │ TableID: 104 + │ │ + │ ├── • SetIndexName + │ │ IndexID: 4 + │ │ Name: t_pkey + │ │ TableID: 104 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 5 + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ IndexID: 5 + │ │ TableID: 104 + │ │ + │ ├── • MakeAddedPrimaryIndexPublic + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.‹public›.‹t› ALTER PRIMARY KEY USING COLUMNS + │ │ (‹a›) + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ IndexID: 4 + │ │ TableID: 104 + │ │ + │ ├── • SetJobStateOnDescriptor + │ │ DescriptorID: 104 + │ │ + │ └── • UpdateSchemaChangerJob + │ IsNonCancelable: true + │ JobID: 1 + │ RunningStatus: PostCommitNonRevertiblePhase stage 3 of 4 with 1 MutationType op pending + │ + ├── • Stage 3 of 4 in PostCommitNonRevertiblePhase + │ │ + │ ├── • 1 element transitioning toward TRANSIENT_ABSENT + │ │ │ + │ │ └── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ TRANSIENT_WRITE_ONLY → TRANSIENT_DELETE_ONLY + │ │ + │ └── • 3 Mutation operations + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 2 + │ │ TableID: 104 + │ │ + │ ├── • SetJobStateOnDescriptor + │ │ DescriptorID: 104 + │ │ + │ └── • UpdateSchemaChangerJob + │ IsNonCancelable: true + │ JobID: 1 + │ RunningStatus: PostCommitNonRevertiblePhase stage 4 of 4 with 4 MutationType ops pending + │ + └── • Stage 4 of 4 in PostCommitNonRevertiblePhase + │ + ├── • 3 elements transitioning toward ABSENT + │ │ + │ ├── • Column:{DescID: 104, ColumnID: 2} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • Precedence dependency from ABSENT ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • SameStagePrecedence dependency from ABSENT ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ rule: "column type removed right before column when not dropping relation" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT ColumnDefaultExpression:{DescID: 104, ColumnID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ │ rule: "indexes containing column reach absent before column" + │ │ │ + │ │ ├── • Precedence dependency from TRANSIENT_ABSENT PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "indexes containing column reach absent before column" + │ │ │ + │ │ ├── • Precedence dependency from TRANSIENT_ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ └── • Precedence dependency from TRANSIENT_ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ rule: "dependents removed before column" + │ │ + │ ├── • ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 2} + │ │ │ rule: "column no longer public before dependents" + │ │ │ + │ │ └── • SameStagePrecedence dependency from ABSENT ColumnDefaultExpression:{DescID: 104, ColumnID: 2} + │ │ rule: "column type dependents removed right before column type" + │ │ + │ └── • ColumnDefaultExpression:{DescID: 104, ColumnID: 2} + │ │ PUBLIC → ABSENT + │ │ + │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 2} + │ rule: "column no longer public before dependents" + │ + ├── • 1 element transitioning toward TRANSIENT_ABSENT + │ │ + │ └── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT + │ │ + │ ├── • Precedence dependency from TRANSIENT_ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ rule: "dependents removed before index" + │ │ + │ ├── • Precedence dependency from TRANSIENT_ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ rule: "dependents removed before index" + │ │ + │ └── • Precedence dependency from TRANSIENT_ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ rule: "dependents removed before index" + │ + └── • 6 Mutation operations + │ + ├── • CreateGcJobForIndex + │ IndexID: 2 + │ StatementForDropJob: + │ Statement: ALTER TABLE defaultdb.public.t ALTER PRIMARY KEY USING COLUMNS (a) + │ TableID: 104 + │ + ├── • MakeIndexAbsent + │ EventBase: + │ Authorization: + │ UserName: root + │ Statement: ALTER TABLE ‹defaultdb›.‹public›.‹t› ALTER PRIMARY KEY USING COLUMNS + │ (‹a›) + │ StatementTag: ALTER TABLE + │ TargetMetadata: + │ SourceElementID: 1 + │ SubWorkID: 1 + │ IndexID: 2 + │ TableID: 104 + │ + ├── • RemoveColumnDefaultExpression + │ ColumnID: 2 + │ TableID: 104 + │ + ├── • MakeColumnAbsent + │ ColumnID: 2 + │ EventBase: + │ Authorization: + │ UserName: root + │ Statement: ALTER TABLE ‹defaultdb›.‹public›.‹t› ALTER PRIMARY KEY USING COLUMNS + │ (‹a›) + │ StatementTag: ALTER TABLE + │ TargetMetadata: + │ SourceElementID: 1 + │ SubWorkID: 1 + │ TableID: 104 + │ + ├── • RemoveJobStateFromDescriptor + │ DescriptorID: 104 + │ JobID: 1 + │ + └── • UpdateSchemaChangerJob + IsNonCancelable: true + JobID: 1 + RunningStatus: all stages completed diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_10_of_15 b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_10_of_15 new file mode 100644 index 000000000000..360c5d4fcd74 --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_10_of_15 @@ -0,0 +1,300 @@ +/* setup */ +CREATE TABLE t (a INT NOT NULL); + +/* test */ +ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a); +EXPLAIN (ddl, verbose) rollback at post-commit stage 10 of 15; +---- +• Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›); +│ +└── • PostCommitNonRevertiblePhase + │ + ├── • Stage 1 of 3 in PostCommitNonRevertiblePhase + │ │ + │ ├── • 11 elements transitioning toward ABSENT + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ PUBLIC → WRITE_ONLY + │ │ │ + │ │ ├── • IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index no longer public before dependents" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ │ │ BACKFILL_ONLY → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 4} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2} + │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ + │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" + │ │ + │ ├── • 4 elements transitioning toward PUBLIC + │ │ │ + │ │ ├── • Column:{DescID: 104, ColumnID: 2} + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnDefaultExpression:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ ├── • ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ │ │ ABSENT → PUBLIC + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ │ │ VALIDATED → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ rule: "index named right before index becomes public" + │ │ │ │ + │ │ │ └── • SameStagePrecedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "primary index swap" + │ │ │ + │ │ └── • IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} + │ │ ABSENT → PUBLIC + │ │ + │ └── • 13 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 2 + │ │ Name: rowid + │ │ TableID: 104 + │ │ + │ ├── • SetIndexName + │ │ IndexID: 1 + │ │ Name: t_pkey + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedPrimaryIndexDeleteAndWriteOnly + │ │ IndexID: 2 + │ │ TableID: 104 + │ │ + │ ├── • SetIndexName + │ │ IndexID: 2 + │ │ Name: crdb_internal_index_2_name_placeholder + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 3 + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 5 + │ │ TableID: 104 + │ │ + │ ├── • MakeColumnPublic + │ │ ColumnID: 2 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ TableID: 104 + │ │ + │ ├── • RefreshStats + │ │ TableID: 104 + │ │ + │ ├── • MakeAddedPrimaryIndexPublic + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ IndexID: 1 + │ │ TableID: 104 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 4 + │ │ StatementForDropJob: + │ │ Rollback: true + │ │ Statement: ALTER TABLE defaultdb.public.t ALTER PRIMARY KEY USING COLUMNS (a) + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ IndexID: 4 + │ │ TableID: 104 + │ │ + │ ├── • SetJobStateOnDescriptor + │ │ DescriptorID: 104 + │ │ + │ └── • UpdateSchemaChangerJob + │ IsNonCancelable: true + │ JobID: 1 + │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 3 with 5 MutationType ops pending + │ + ├── • Stage 2 of 3 in PostCommitNonRevertiblePhase + │ │ + │ ├── • 3 elements transitioning toward ABSENT + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ │ DELETE_ONLY → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} + │ │ rule: "dependents removed before index" + │ │ + │ └── • 7 Mutation operations + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 2 + │ │ TableID: 104 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 3 + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ IndexID: 3 + │ │ TableID: 104 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 5 + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ IndexID: 5 + │ │ TableID: 104 + │ │ + │ ├── • SetJobStateOnDescriptor + │ │ DescriptorID: 104 + │ │ + │ └── • UpdateSchemaChangerJob + │ IsNonCancelable: true + │ JobID: 1 + │ RunningStatus: PostCommitNonRevertiblePhase stage 3 of 3 with 2 MutationType ops pending + │ + └── • Stage 3 of 3 in PostCommitNonRevertiblePhase + │ + ├── • 1 element transitioning toward ABSENT + │ │ + │ └── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ DELETE_ONLY → ABSENT + │ │ + │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ rule: "dependents removed before index" + │ │ + │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ rule: "dependents removed before index" + │ │ + │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ rule: "dependents removed before index" + │ + └── • 4 Mutation operations + │ + ├── • CreateGcJobForIndex + │ IndexID: 2 + │ StatementForDropJob: + │ Rollback: true + │ Statement: ALTER TABLE defaultdb.public.t ALTER PRIMARY KEY USING COLUMNS (a) + │ TableID: 104 + │ + ├── • MakeIndexAbsent + │ EventBase: + │ Authorization: + │ UserName: root + │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ StatementTag: ALTER TABLE + │ TargetMetadata: + │ SourceElementID: 1 + │ SubWorkID: 1 + │ IndexID: 2 + │ TableID: 104 + │ + ├── • RemoveJobStateFromDescriptor + │ DescriptorID: 104 + │ JobID: 1 + │ + └── • UpdateSchemaChangerJob + IsNonCancelable: true + JobID: 1 + RunningStatus: all stages completed diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_11_of_15 b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_11_of_15 new file mode 100644 index 000000000000..740a6e476ad8 --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_11_of_15 @@ -0,0 +1,300 @@ +/* setup */ +CREATE TABLE t (a INT NOT NULL); + +/* test */ +ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a); +EXPLAIN (ddl, verbose) rollback at post-commit stage 11 of 15; +---- +• Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›); +│ +└── • PostCommitNonRevertiblePhase + │ + ├── • Stage 1 of 3 in PostCommitNonRevertiblePhase + │ │ + │ ├── • 11 elements transitioning toward ABSENT + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ PUBLIC → WRITE_ONLY + │ │ │ + │ │ ├── • IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index no longer public before dependents" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ │ │ BACKFILL_ONLY → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 4} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2} + │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ + │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" + │ │ + │ ├── • 4 elements transitioning toward PUBLIC + │ │ │ + │ │ ├── • Column:{DescID: 104, ColumnID: 2} + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnDefaultExpression:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ ├── • ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ │ │ ABSENT → PUBLIC + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ │ │ VALIDATED → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ rule: "index named right before index becomes public" + │ │ │ │ + │ │ │ └── • SameStagePrecedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "primary index swap" + │ │ │ + │ │ └── • IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} + │ │ ABSENT → PUBLIC + │ │ + │ └── • 13 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 2 + │ │ Name: rowid + │ │ TableID: 104 + │ │ + │ ├── • SetIndexName + │ │ IndexID: 1 + │ │ Name: t_pkey + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedPrimaryIndexDeleteAndWriteOnly + │ │ IndexID: 2 + │ │ TableID: 104 + │ │ + │ ├── • SetIndexName + │ │ IndexID: 2 + │ │ Name: crdb_internal_index_2_name_placeholder + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 3 + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 5 + │ │ TableID: 104 + │ │ + │ ├── • MakeColumnPublic + │ │ ColumnID: 2 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ TableID: 104 + │ │ + │ ├── • RefreshStats + │ │ TableID: 104 + │ │ + │ ├── • MakeAddedPrimaryIndexPublic + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ IndexID: 1 + │ │ TableID: 104 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 4 + │ │ StatementForDropJob: + │ │ Rollback: true + │ │ Statement: ALTER TABLE defaultdb.public.t ALTER PRIMARY KEY USING COLUMNS (a) + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ IndexID: 4 + │ │ TableID: 104 + │ │ + │ ├── • SetJobStateOnDescriptor + │ │ DescriptorID: 104 + │ │ + │ └── • UpdateSchemaChangerJob + │ IsNonCancelable: true + │ JobID: 1 + │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 3 with 5 MutationType ops pending + │ + ├── • Stage 2 of 3 in PostCommitNonRevertiblePhase + │ │ + │ ├── • 3 elements transitioning toward ABSENT + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ │ DELETE_ONLY → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} + │ │ rule: "dependents removed before index" + │ │ + │ └── • 7 Mutation operations + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 2 + │ │ TableID: 104 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 3 + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ IndexID: 3 + │ │ TableID: 104 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 5 + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ IndexID: 5 + │ │ TableID: 104 + │ │ + │ ├── • SetJobStateOnDescriptor + │ │ DescriptorID: 104 + │ │ + │ └── • UpdateSchemaChangerJob + │ IsNonCancelable: true + │ JobID: 1 + │ RunningStatus: PostCommitNonRevertiblePhase stage 3 of 3 with 2 MutationType ops pending + │ + └── • Stage 3 of 3 in PostCommitNonRevertiblePhase + │ + ├── • 1 element transitioning toward ABSENT + │ │ + │ └── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ DELETE_ONLY → ABSENT + │ │ + │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ rule: "dependents removed before index" + │ │ + │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ rule: "dependents removed before index" + │ │ + │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ rule: "dependents removed before index" + │ + └── • 4 Mutation operations + │ + ├── • CreateGcJobForIndex + │ IndexID: 2 + │ StatementForDropJob: + │ Rollback: true + │ Statement: ALTER TABLE defaultdb.public.t ALTER PRIMARY KEY USING COLUMNS (a) + │ TableID: 104 + │ + ├── • MakeIndexAbsent + │ EventBase: + │ Authorization: + │ UserName: root + │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ StatementTag: ALTER TABLE + │ TargetMetadata: + │ SourceElementID: 1 + │ SubWorkID: 1 + │ IndexID: 2 + │ TableID: 104 + │ + ├── • RemoveJobStateFromDescriptor + │ DescriptorID: 104 + │ JobID: 1 + │ + └── • UpdateSchemaChangerJob + IsNonCancelable: true + JobID: 1 + RunningStatus: all stages completed diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_12_of_15 b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_12_of_15 new file mode 100644 index 000000000000..a9d13a2aae08 --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_12_of_15 @@ -0,0 +1,300 @@ +/* setup */ +CREATE TABLE t (a INT NOT NULL); + +/* test */ +ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a); +EXPLAIN (ddl, verbose) rollback at post-commit stage 12 of 15; +---- +• Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›); +│ +└── • PostCommitNonRevertiblePhase + │ + ├── • Stage 1 of 3 in PostCommitNonRevertiblePhase + │ │ + │ ├── • 11 elements transitioning toward ABSENT + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ PUBLIC → WRITE_ONLY + │ │ │ + │ │ ├── • IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index no longer public before dependents" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ │ │ DELETE_ONLY → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 4} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2} + │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ + │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" + │ │ + │ ├── • 4 elements transitioning toward PUBLIC + │ │ │ + │ │ ├── • Column:{DescID: 104, ColumnID: 2} + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnDefaultExpression:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ ├── • ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ │ │ ABSENT → PUBLIC + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ │ │ VALIDATED → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ rule: "index named right before index becomes public" + │ │ │ │ + │ │ │ └── • SameStagePrecedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "primary index swap" + │ │ │ + │ │ └── • IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} + │ │ ABSENT → PUBLIC + │ │ + │ └── • 13 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 2 + │ │ Name: rowid + │ │ TableID: 104 + │ │ + │ ├── • SetIndexName + │ │ IndexID: 1 + │ │ Name: t_pkey + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedPrimaryIndexDeleteAndWriteOnly + │ │ IndexID: 2 + │ │ TableID: 104 + │ │ + │ ├── • SetIndexName + │ │ IndexID: 2 + │ │ Name: crdb_internal_index_2_name_placeholder + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 3 + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 5 + │ │ TableID: 104 + │ │ + │ ├── • MakeColumnPublic + │ │ ColumnID: 2 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ TableID: 104 + │ │ + │ ├── • RefreshStats + │ │ TableID: 104 + │ │ + │ ├── • MakeAddedPrimaryIndexPublic + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ IndexID: 1 + │ │ TableID: 104 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 4 + │ │ StatementForDropJob: + │ │ Rollback: true + │ │ Statement: ALTER TABLE defaultdb.public.t ALTER PRIMARY KEY USING COLUMNS (a) + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ IndexID: 4 + │ │ TableID: 104 + │ │ + │ ├── • SetJobStateOnDescriptor + │ │ DescriptorID: 104 + │ │ + │ └── • UpdateSchemaChangerJob + │ IsNonCancelable: true + │ JobID: 1 + │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 3 with 5 MutationType ops pending + │ + ├── • Stage 2 of 3 in PostCommitNonRevertiblePhase + │ │ + │ ├── • 3 elements transitioning toward ABSENT + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ │ DELETE_ONLY → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} + │ │ rule: "dependents removed before index" + │ │ + │ └── • 7 Mutation operations + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 2 + │ │ TableID: 104 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 3 + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ IndexID: 3 + │ │ TableID: 104 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 5 + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ IndexID: 5 + │ │ TableID: 104 + │ │ + │ ├── • SetJobStateOnDescriptor + │ │ DescriptorID: 104 + │ │ + │ └── • UpdateSchemaChangerJob + │ IsNonCancelable: true + │ JobID: 1 + │ RunningStatus: PostCommitNonRevertiblePhase stage 3 of 3 with 2 MutationType ops pending + │ + └── • Stage 3 of 3 in PostCommitNonRevertiblePhase + │ + ├── • 1 element transitioning toward ABSENT + │ │ + │ └── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ DELETE_ONLY → ABSENT + │ │ + │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ rule: "dependents removed before index" + │ │ + │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ rule: "dependents removed before index" + │ │ + │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ rule: "dependents removed before index" + │ + └── • 4 Mutation operations + │ + ├── • CreateGcJobForIndex + │ IndexID: 2 + │ StatementForDropJob: + │ Rollback: true + │ Statement: ALTER TABLE defaultdb.public.t ALTER PRIMARY KEY USING COLUMNS (a) + │ TableID: 104 + │ + ├── • MakeIndexAbsent + │ EventBase: + │ Authorization: + │ UserName: root + │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ StatementTag: ALTER TABLE + │ TargetMetadata: + │ SourceElementID: 1 + │ SubWorkID: 1 + │ IndexID: 2 + │ TableID: 104 + │ + ├── • RemoveJobStateFromDescriptor + │ DescriptorID: 104 + │ JobID: 1 + │ + └── • UpdateSchemaChangerJob + IsNonCancelable: true + JobID: 1 + RunningStatus: all stages completed diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_13_of_15 b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_13_of_15 new file mode 100644 index 000000000000..1174f0c55601 --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_13_of_15 @@ -0,0 +1,307 @@ +/* setup */ +CREATE TABLE t (a INT NOT NULL); + +/* test */ +ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a); +EXPLAIN (ddl, verbose) rollback at post-commit stage 13 of 15; +---- +• Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›); +│ +└── • PostCommitNonRevertiblePhase + │ + ├── • Stage 1 of 3 in PostCommitNonRevertiblePhase + │ │ + │ ├── • 11 elements transitioning toward ABSENT + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ PUBLIC → WRITE_ONLY + │ │ │ + │ │ ├── • IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index no longer public before dependents" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ │ MERGE_ONLY → DELETE_ONLY + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2} + │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ + │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" + │ │ + │ ├── • 4 elements transitioning toward PUBLIC + │ │ │ + │ │ ├── • Column:{DescID: 104, ColumnID: 2} + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnDefaultExpression:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ ├── • ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ │ │ ABSENT → PUBLIC + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ │ │ VALIDATED → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ rule: "index named right before index becomes public" + │ │ │ │ + │ │ │ └── • SameStagePrecedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "primary index swap" + │ │ │ + │ │ └── • IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} + │ │ ABSENT → PUBLIC + │ │ + │ └── • 12 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 2 + │ │ Name: rowid + │ │ TableID: 104 + │ │ + │ ├── • SetIndexName + │ │ IndexID: 1 + │ │ Name: t_pkey + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedPrimaryIndexDeleteAndWriteOnly + │ │ IndexID: 2 + │ │ TableID: 104 + │ │ + │ ├── • SetIndexName + │ │ IndexID: 2 + │ │ Name: crdb_internal_index_2_name_placeholder + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 3 + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 5 + │ │ TableID: 104 + │ │ + │ ├── • MakeColumnPublic + │ │ ColumnID: 2 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ TableID: 104 + │ │ + │ ├── • RefreshStats + │ │ TableID: 104 + │ │ + │ ├── • MakeAddedPrimaryIndexPublic + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ IndexID: 1 + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 4 + │ │ TableID: 104 + │ │ + │ ├── • SetJobStateOnDescriptor + │ │ DescriptorID: 104 + │ │ + │ └── • UpdateSchemaChangerJob + │ IsNonCancelable: true + │ JobID: 1 + │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 3 with 7 MutationType ops pending + │ + ├── • Stage 2 of 3 in PostCommitNonRevertiblePhase + │ │ + │ ├── • 4 elements transitioning toward ABSENT + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ │ DELETE_ONLY → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ │ │ DELETE_ONLY → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 4} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} + │ │ rule: "dependents removed before index" + │ │ + │ └── • 9 Mutation operations + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 2 + │ │ TableID: 104 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 3 + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ IndexID: 3 + │ │ TableID: 104 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 4 + │ │ StatementForDropJob: + │ │ Rollback: true + │ │ Statement: ALTER TABLE defaultdb.public.t ALTER PRIMARY KEY USING COLUMNS (a) + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ IndexID: 4 + │ │ TableID: 104 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 5 + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ IndexID: 5 + │ │ TableID: 104 + │ │ + │ ├── • SetJobStateOnDescriptor + │ │ DescriptorID: 104 + │ │ + │ └── • UpdateSchemaChangerJob + │ IsNonCancelable: true + │ JobID: 1 + │ RunningStatus: PostCommitNonRevertiblePhase stage 3 of 3 with 2 MutationType ops pending + │ + └── • Stage 3 of 3 in PostCommitNonRevertiblePhase + │ + ├── • 1 element transitioning toward ABSENT + │ │ + │ └── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ DELETE_ONLY → ABSENT + │ │ + │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ rule: "dependents removed before index" + │ │ + │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ rule: "dependents removed before index" + │ │ + │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ rule: "dependents removed before index" + │ + └── • 4 Mutation operations + │ + ├── • CreateGcJobForIndex + │ IndexID: 2 + │ StatementForDropJob: + │ Rollback: true + │ Statement: ALTER TABLE defaultdb.public.t ALTER PRIMARY KEY USING COLUMNS (a) + │ TableID: 104 + │ + ├── • MakeIndexAbsent + │ EventBase: + │ Authorization: + │ UserName: root + │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ StatementTag: ALTER TABLE + │ TargetMetadata: + │ SourceElementID: 1 + │ SubWorkID: 1 + │ IndexID: 2 + │ TableID: 104 + │ + ├── • RemoveJobStateFromDescriptor + │ DescriptorID: 104 + │ JobID: 1 + │ + └── • UpdateSchemaChangerJob + IsNonCancelable: true + JobID: 1 + RunningStatus: all stages completed diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_14_of_15 b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_14_of_15 new file mode 100644 index 000000000000..6ad47dc922c2 --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_14_of_15 @@ -0,0 +1,307 @@ +/* setup */ +CREATE TABLE t (a INT NOT NULL); + +/* test */ +ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a); +EXPLAIN (ddl, verbose) rollback at post-commit stage 14 of 15; +---- +• Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›); +│ +└── • PostCommitNonRevertiblePhase + │ + ├── • Stage 1 of 3 in PostCommitNonRevertiblePhase + │ │ + │ ├── • 11 elements transitioning toward ABSENT + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ PUBLIC → WRITE_ONLY + │ │ │ + │ │ ├── • IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index no longer public before dependents" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ │ MERGE_ONLY → DELETE_ONLY + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2} + │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ + │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" + │ │ + │ ├── • 4 elements transitioning toward PUBLIC + │ │ │ + │ │ ├── • Column:{DescID: 104, ColumnID: 2} + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnDefaultExpression:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ ├── • ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ │ │ ABSENT → PUBLIC + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ │ │ VALIDATED → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ rule: "index named right before index becomes public" + │ │ │ │ + │ │ │ └── • SameStagePrecedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "primary index swap" + │ │ │ + │ │ └── • IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} + │ │ ABSENT → PUBLIC + │ │ + │ └── • 12 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 2 + │ │ Name: rowid + │ │ TableID: 104 + │ │ + │ ├── • SetIndexName + │ │ IndexID: 1 + │ │ Name: t_pkey + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedPrimaryIndexDeleteAndWriteOnly + │ │ IndexID: 2 + │ │ TableID: 104 + │ │ + │ ├── • SetIndexName + │ │ IndexID: 2 + │ │ Name: crdb_internal_index_2_name_placeholder + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 3 + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 5 + │ │ TableID: 104 + │ │ + │ ├── • MakeColumnPublic + │ │ ColumnID: 2 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ TableID: 104 + │ │ + │ ├── • RefreshStats + │ │ TableID: 104 + │ │ + │ ├── • MakeAddedPrimaryIndexPublic + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ IndexID: 1 + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 4 + │ │ TableID: 104 + │ │ + │ ├── • SetJobStateOnDescriptor + │ │ DescriptorID: 104 + │ │ + │ └── • UpdateSchemaChangerJob + │ IsNonCancelable: true + │ JobID: 1 + │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 3 with 7 MutationType ops pending + │ + ├── • Stage 2 of 3 in PostCommitNonRevertiblePhase + │ │ + │ ├── • 4 elements transitioning toward ABSENT + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ │ DELETE_ONLY → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ │ │ DELETE_ONLY → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 4} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} + │ │ rule: "dependents removed before index" + │ │ + │ └── • 9 Mutation operations + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 2 + │ │ TableID: 104 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 3 + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ IndexID: 3 + │ │ TableID: 104 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 4 + │ │ StatementForDropJob: + │ │ Rollback: true + │ │ Statement: ALTER TABLE defaultdb.public.t ALTER PRIMARY KEY USING COLUMNS (a) + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ IndexID: 4 + │ │ TableID: 104 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 5 + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ IndexID: 5 + │ │ TableID: 104 + │ │ + │ ├── • SetJobStateOnDescriptor + │ │ DescriptorID: 104 + │ │ + │ └── • UpdateSchemaChangerJob + │ IsNonCancelable: true + │ JobID: 1 + │ RunningStatus: PostCommitNonRevertiblePhase stage 3 of 3 with 2 MutationType ops pending + │ + └── • Stage 3 of 3 in PostCommitNonRevertiblePhase + │ + ├── • 1 element transitioning toward ABSENT + │ │ + │ └── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ DELETE_ONLY → ABSENT + │ │ + │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ rule: "dependents removed before index" + │ │ + │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ rule: "dependents removed before index" + │ │ + │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ rule: "dependents removed before index" + │ + └── • 4 Mutation operations + │ + ├── • CreateGcJobForIndex + │ IndexID: 2 + │ StatementForDropJob: + │ Rollback: true + │ Statement: ALTER TABLE defaultdb.public.t ALTER PRIMARY KEY USING COLUMNS (a) + │ TableID: 104 + │ + ├── • MakeIndexAbsent + │ EventBase: + │ Authorization: + │ UserName: root + │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ StatementTag: ALTER TABLE + │ TargetMetadata: + │ SourceElementID: 1 + │ SubWorkID: 1 + │ IndexID: 2 + │ TableID: 104 + │ + ├── • RemoveJobStateFromDescriptor + │ DescriptorID: 104 + │ JobID: 1 + │ + └── • UpdateSchemaChangerJob + IsNonCancelable: true + JobID: 1 + RunningStatus: all stages completed diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_15_of_15 b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_15_of_15 new file mode 100644 index 000000000000..2c3ea2373d7f --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_15_of_15 @@ -0,0 +1,307 @@ +/* setup */ +CREATE TABLE t (a INT NOT NULL); + +/* test */ +ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a); +EXPLAIN (ddl, verbose) rollback at post-commit stage 15 of 15; +---- +• Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›); +│ +└── • PostCommitNonRevertiblePhase + │ + ├── • Stage 1 of 3 in PostCommitNonRevertiblePhase + │ │ + │ ├── • 11 elements transitioning toward ABSENT + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ PUBLIC → WRITE_ONLY + │ │ │ + │ │ ├── • IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index no longer public before dependents" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2} + │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ + │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" + │ │ + │ ├── • 4 elements transitioning toward PUBLIC + │ │ │ + │ │ ├── • Column:{DescID: 104, ColumnID: 2} + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnDefaultExpression:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ ├── • ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ │ │ ABSENT → PUBLIC + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ │ │ VALIDATED → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ rule: "index named right before index becomes public" + │ │ │ │ + │ │ │ └── • SameStagePrecedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "primary index swap" + │ │ │ + │ │ └── • IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} + │ │ ABSENT → PUBLIC + │ │ + │ └── • 12 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 2 + │ │ Name: rowid + │ │ TableID: 104 + │ │ + │ ├── • SetIndexName + │ │ IndexID: 1 + │ │ Name: t_pkey + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedPrimaryIndexDeleteAndWriteOnly + │ │ IndexID: 2 + │ │ TableID: 104 + │ │ + │ ├── • SetIndexName + │ │ IndexID: 2 + │ │ Name: crdb_internal_index_2_name_placeholder + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 3 + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 4 + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 5 + │ │ TableID: 104 + │ │ + │ ├── • MakeColumnPublic + │ │ ColumnID: 2 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ TableID: 104 + │ │ + │ ├── • RefreshStats + │ │ TableID: 104 + │ │ + │ ├── • MakeAddedPrimaryIndexPublic + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ IndexID: 1 + │ │ TableID: 104 + │ │ + │ ├── • SetJobStateOnDescriptor + │ │ DescriptorID: 104 + │ │ + │ └── • UpdateSchemaChangerJob + │ IsNonCancelable: true + │ JobID: 1 + │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 3 with 7 MutationType ops pending + │ + ├── • Stage 2 of 3 in PostCommitNonRevertiblePhase + │ │ + │ ├── • 4 elements transitioning toward ABSENT + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ │ DELETE_ONLY → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ │ │ DELETE_ONLY → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 4} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} + │ │ rule: "dependents removed before index" + │ │ + │ └── • 9 Mutation operations + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 2 + │ │ TableID: 104 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 3 + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ IndexID: 3 + │ │ TableID: 104 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 4 + │ │ StatementForDropJob: + │ │ Rollback: true + │ │ Statement: ALTER TABLE defaultdb.public.t ALTER PRIMARY KEY USING COLUMNS (a) + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ IndexID: 4 + │ │ TableID: 104 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 5 + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ IndexID: 5 + │ │ TableID: 104 + │ │ + │ ├── • SetJobStateOnDescriptor + │ │ DescriptorID: 104 + │ │ + │ └── • UpdateSchemaChangerJob + │ IsNonCancelable: true + │ JobID: 1 + │ RunningStatus: PostCommitNonRevertiblePhase stage 3 of 3 with 2 MutationType ops pending + │ + └── • Stage 3 of 3 in PostCommitNonRevertiblePhase + │ + ├── • 1 element transitioning toward ABSENT + │ │ + │ └── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ DELETE_ONLY → ABSENT + │ │ + │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ rule: "dependents removed before index" + │ │ + │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ rule: "dependents removed before index" + │ │ + │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ rule: "dependents removed before index" + │ + └── • 4 Mutation operations + │ + ├── • CreateGcJobForIndex + │ IndexID: 2 + │ StatementForDropJob: + │ Rollback: true + │ Statement: ALTER TABLE defaultdb.public.t ALTER PRIMARY KEY USING COLUMNS (a) + │ TableID: 104 + │ + ├── • MakeIndexAbsent + │ EventBase: + │ Authorization: + │ UserName: root + │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ StatementTag: ALTER TABLE + │ TargetMetadata: + │ SourceElementID: 1 + │ SubWorkID: 1 + │ IndexID: 2 + │ TableID: 104 + │ + ├── • RemoveJobStateFromDescriptor + │ DescriptorID: 104 + │ JobID: 1 + │ + └── • UpdateSchemaChangerJob + IsNonCancelable: true + JobID: 1 + RunningStatus: all stages completed diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_1_of_15 b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_1_of_15 new file mode 100644 index 000000000000..62081fa425ee --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_1_of_15 @@ -0,0 +1,171 @@ +/* setup */ +CREATE TABLE t (a INT NOT NULL); + +/* test */ +ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a); +EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 15; +---- +• Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›); +│ +└── • PostCommitNonRevertiblePhase + │ + └── • Stage 1 of 1 in PostCommitNonRevertiblePhase + │ + ├── • 8 elements transitioning toward ABSENT + │ │ + │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ BACKFILL_ONLY → ABSENT + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ rule: "dependents removed before index" + │ │ + │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" + │ │ + │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" + │ │ + │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ rule: "dependents removed before index" + │ │ + │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" + │ │ + │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" + │ │ + │ ├── • PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ │ BACKFILL_ONLY → ABSENT + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 4} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ rule: "dependents removed before index" + │ │ + │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ PUBLIC → ABSENT + │ │ + │ └── • skip PUBLIC → ABSENT operations + │ rule: "skip index-column removal ops on index removal" + │ + ├── • 2 elements transitioning toward PUBLIC + │ │ + │ ├── • Column:{DescID: 104, ColumnID: 2} + │ │ │ WRITE_ONLY → PUBLIC + │ │ │ + │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ ├── • Precedence dependency from PUBLIC ColumnDefaultExpression:{DescID: 104, ColumnID: 2} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ rule: "column dependents exist before column becomes public" + │ │ + │ └── • ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ ABSENT → PUBLIC + │ + └── • 11 Mutation operations + │ + ├── • SetColumnName + │ ColumnID: 2 + │ Name: rowid + │ TableID: 104 + │ + ├── • MakeColumnPublic + │ ColumnID: 2 + │ EventBase: + │ Authorization: + │ UserName: root + │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ StatementTag: ALTER TABLE + │ TargetMetadata: + │ SourceElementID: 1 + │ SubWorkID: 1 + │ TableID: 104 + │ + ├── • RefreshStats + │ TableID: 104 + │ + ├── • CreateGcJobForIndex + │ IndexID: 2 + │ StatementForDropJob: + │ Rollback: true + │ Statement: ALTER TABLE defaultdb.public.t ALTER PRIMARY KEY USING COLUMNS (a) + │ TableID: 104 + │ + ├── • MakeIndexAbsent + │ EventBase: + │ Authorization: + │ UserName: root + │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ StatementTag: ALTER TABLE + │ TargetMetadata: + │ SourceElementID: 1 + │ SubWorkID: 1 + │ IndexID: 2 + │ TableID: 104 + │ + ├── • CreateGcJobForIndex + │ IndexID: 3 + │ TableID: 104 + │ + ├── • MakeIndexAbsent + │ IndexID: 3 + │ TableID: 104 + │ + ├── • CreateGcJobForIndex + │ IndexID: 4 + │ StatementForDropJob: + │ Rollback: true + │ Statement: ALTER TABLE defaultdb.public.t ALTER PRIMARY KEY USING COLUMNS (a) + │ TableID: 104 + │ + ├── • MakeIndexAbsent + │ EventBase: + │ Authorization: + │ UserName: root + │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ StatementTag: ALTER TABLE + │ TargetMetadata: + │ SourceElementID: 1 + │ SubWorkID: 1 + │ IndexID: 4 + │ TableID: 104 + │ + ├── • RemoveJobStateFromDescriptor + │ DescriptorID: 104 + │ JobID: 1 + │ + └── • UpdateSchemaChangerJob + IsNonCancelable: true + JobID: 1 + RunningStatus: all stages completed diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_2_of_15 b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_2_of_15 new file mode 100644 index 000000000000..8471f6587f94 --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_2_of_15 @@ -0,0 +1,192 @@ +/* setup */ +CREATE TABLE t (a INT NOT NULL); + +/* test */ +ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a); +EXPLAIN (ddl, verbose) rollback at post-commit stage 2 of 15; +---- +• Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›); +│ +└── • PostCommitNonRevertiblePhase + │ + ├── • Stage 1 of 2 in PostCommitNonRevertiblePhase + │ │ + │ ├── • 8 elements transitioning toward ABSENT + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ BACKFILL_ONLY → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ │ │ BACKFILL_ONLY → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 4} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" + │ │ + │ ├── • 2 elements transitioning toward PUBLIC + │ │ │ + │ │ ├── • Column:{DescID: 104, ColumnID: 2} + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnDefaultExpression:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ └── • ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ │ ABSENT → PUBLIC + │ │ + │ └── • 10 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 2 + │ │ Name: rowid + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 3 + │ │ TableID: 104 + │ │ + │ ├── • MakeColumnPublic + │ │ ColumnID: 2 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ TableID: 104 + │ │ + │ ├── • RefreshStats + │ │ TableID: 104 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 2 + │ │ StatementForDropJob: + │ │ Rollback: true + │ │ Statement: ALTER TABLE defaultdb.public.t ALTER PRIMARY KEY USING COLUMNS (a) + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ IndexID: 2 + │ │ TableID: 104 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 4 + │ │ StatementForDropJob: + │ │ Rollback: true + │ │ Statement: ALTER TABLE defaultdb.public.t ALTER PRIMARY KEY USING COLUMNS (a) + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ IndexID: 4 + │ │ TableID: 104 + │ │ + │ ├── • SetJobStateOnDescriptor + │ │ DescriptorID: 104 + │ │ + │ └── • UpdateSchemaChangerJob + │ IsNonCancelable: true + │ JobID: 1 + │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 2 with 2 MutationType ops pending + │ + └── • Stage 2 of 2 in PostCommitNonRevertiblePhase + │ + ├── • 1 element transitioning toward ABSENT + │ │ + │ └── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ DELETE_ONLY → ABSENT + │ │ + │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ rule: "dependents removed before index" + │ │ + │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ rule: "dependents removed before index" + │ + └── • 4 Mutation operations + │ + ├── • CreateGcJobForIndex + │ IndexID: 3 + │ TableID: 104 + │ + ├── • MakeIndexAbsent + │ IndexID: 3 + │ TableID: 104 + │ + ├── • RemoveJobStateFromDescriptor + │ DescriptorID: 104 + │ JobID: 1 + │ + └── • UpdateSchemaChangerJob + IsNonCancelable: true + JobID: 1 + RunningStatus: all stages completed diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_3_of_15 b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_3_of_15 new file mode 100644 index 000000000000..39a7044cb506 --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_3_of_15 @@ -0,0 +1,192 @@ +/* setup */ +CREATE TABLE t (a INT NOT NULL); + +/* test */ +ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a); +EXPLAIN (ddl, verbose) rollback at post-commit stage 3 of 15; +---- +• Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›); +│ +└── • PostCommitNonRevertiblePhase + │ + ├── • Stage 1 of 2 in PostCommitNonRevertiblePhase + │ │ + │ ├── • 8 elements transitioning toward ABSENT + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ BACKFILL_ONLY → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ │ │ BACKFILL_ONLY → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 4} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" + │ │ + │ ├── • 2 elements transitioning toward PUBLIC + │ │ │ + │ │ ├── • Column:{DescID: 104, ColumnID: 2} + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnDefaultExpression:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ └── • ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ │ ABSENT → PUBLIC + │ │ + │ └── • 10 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 2 + │ │ Name: rowid + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 3 + │ │ TableID: 104 + │ │ + │ ├── • MakeColumnPublic + │ │ ColumnID: 2 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ TableID: 104 + │ │ + │ ├── • RefreshStats + │ │ TableID: 104 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 2 + │ │ StatementForDropJob: + │ │ Rollback: true + │ │ Statement: ALTER TABLE defaultdb.public.t ALTER PRIMARY KEY USING COLUMNS (a) + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ IndexID: 2 + │ │ TableID: 104 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 4 + │ │ StatementForDropJob: + │ │ Rollback: true + │ │ Statement: ALTER TABLE defaultdb.public.t ALTER PRIMARY KEY USING COLUMNS (a) + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ IndexID: 4 + │ │ TableID: 104 + │ │ + │ ├── • SetJobStateOnDescriptor + │ │ DescriptorID: 104 + │ │ + │ └── • UpdateSchemaChangerJob + │ IsNonCancelable: true + │ JobID: 1 + │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 2 with 2 MutationType ops pending + │ + └── • Stage 2 of 2 in PostCommitNonRevertiblePhase + │ + ├── • 1 element transitioning toward ABSENT + │ │ + │ └── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ DELETE_ONLY → ABSENT + │ │ + │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ rule: "dependents removed before index" + │ │ + │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ rule: "dependents removed before index" + │ + └── • 4 Mutation operations + │ + ├── • CreateGcJobForIndex + │ IndexID: 3 + │ TableID: 104 + │ + ├── • MakeIndexAbsent + │ IndexID: 3 + │ TableID: 104 + │ + ├── • RemoveJobStateFromDescriptor + │ DescriptorID: 104 + │ JobID: 1 + │ + └── • UpdateSchemaChangerJob + IsNonCancelable: true + JobID: 1 + RunningStatus: all stages completed diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_4_of_15 b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_4_of_15 new file mode 100644 index 000000000000..0e46b751f917 --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_4_of_15 @@ -0,0 +1,192 @@ +/* setup */ +CREATE TABLE t (a INT NOT NULL); + +/* test */ +ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a); +EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 15; +---- +• Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›); +│ +└── • PostCommitNonRevertiblePhase + │ + ├── • Stage 1 of 2 in PostCommitNonRevertiblePhase + │ │ + │ ├── • 8 elements transitioning toward ABSENT + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ DELETE_ONLY → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ │ │ BACKFILL_ONLY → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 4} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" + │ │ + │ ├── • 2 elements transitioning toward PUBLIC + │ │ │ + │ │ ├── • Column:{DescID: 104, ColumnID: 2} + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnDefaultExpression:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ └── • ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ │ ABSENT → PUBLIC + │ │ + │ └── • 10 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 2 + │ │ Name: rowid + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 3 + │ │ TableID: 104 + │ │ + │ ├── • MakeColumnPublic + │ │ ColumnID: 2 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ TableID: 104 + │ │ + │ ├── • RefreshStats + │ │ TableID: 104 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 2 + │ │ StatementForDropJob: + │ │ Rollback: true + │ │ Statement: ALTER TABLE defaultdb.public.t ALTER PRIMARY KEY USING COLUMNS (a) + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ IndexID: 2 + │ │ TableID: 104 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 4 + │ │ StatementForDropJob: + │ │ Rollback: true + │ │ Statement: ALTER TABLE defaultdb.public.t ALTER PRIMARY KEY USING COLUMNS (a) + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ IndexID: 4 + │ │ TableID: 104 + │ │ + │ ├── • SetJobStateOnDescriptor + │ │ DescriptorID: 104 + │ │ + │ └── • UpdateSchemaChangerJob + │ IsNonCancelable: true + │ JobID: 1 + │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 2 with 2 MutationType ops pending + │ + └── • Stage 2 of 2 in PostCommitNonRevertiblePhase + │ + ├── • 1 element transitioning toward ABSENT + │ │ + │ └── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ DELETE_ONLY → ABSENT + │ │ + │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ rule: "dependents removed before index" + │ │ + │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ rule: "dependents removed before index" + │ + └── • 4 Mutation operations + │ + ├── • CreateGcJobForIndex + │ IndexID: 3 + │ TableID: 104 + │ + ├── • MakeIndexAbsent + │ IndexID: 3 + │ TableID: 104 + │ + ├── • RemoveJobStateFromDescriptor + │ DescriptorID: 104 + │ JobID: 1 + │ + └── • UpdateSchemaChangerJob + IsNonCancelable: true + JobID: 1 + RunningStatus: all stages completed diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_5_of_15 b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_5_of_15 new file mode 100644 index 000000000000..6896fa8c2d3e --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_5_of_15 @@ -0,0 +1,199 @@ +/* setup */ +CREATE TABLE t (a INT NOT NULL); + +/* test */ +ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a); +EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 15; +---- +• Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›); +│ +└── • PostCommitNonRevertiblePhase + │ + ├── • Stage 1 of 2 in PostCommitNonRevertiblePhase + │ │ + │ ├── • 8 elements transitioning toward ABSENT + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ MERGE_ONLY → DELETE_ONLY + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ │ │ BACKFILL_ONLY → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 4} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" + │ │ + │ ├── • 2 elements transitioning toward PUBLIC + │ │ │ + │ │ ├── • Column:{DescID: 104, ColumnID: 2} + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnDefaultExpression:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ └── • ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ │ ABSENT → PUBLIC + │ │ + │ └── • 9 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 2 + │ │ Name: rowid + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 3 + │ │ TableID: 104 + │ │ + │ ├── • MakeColumnPublic + │ │ ColumnID: 2 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ TableID: 104 + │ │ + │ ├── • RefreshStats + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 2 + │ │ TableID: 104 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 4 + │ │ StatementForDropJob: + │ │ Rollback: true + │ │ Statement: ALTER TABLE defaultdb.public.t ALTER PRIMARY KEY USING COLUMNS (a) + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ IndexID: 4 + │ │ TableID: 104 + │ │ + │ ├── • SetJobStateOnDescriptor + │ │ DescriptorID: 104 + │ │ + │ └── • UpdateSchemaChangerJob + │ IsNonCancelable: true + │ JobID: 1 + │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 2 with 4 MutationType ops pending + │ + └── • Stage 2 of 2 in PostCommitNonRevertiblePhase + │ + ├── • 2 elements transitioning toward ABSENT + │ │ + │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ rule: "dependents removed before index" + │ │ + │ └── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ DELETE_ONLY → ABSENT + │ │ + │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ rule: "dependents removed before index" + │ │ + │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ rule: "dependents removed before index" + │ + └── • 6 Mutation operations + │ + ├── • CreateGcJobForIndex + │ IndexID: 2 + │ StatementForDropJob: + │ Rollback: true + │ Statement: ALTER TABLE defaultdb.public.t ALTER PRIMARY KEY USING COLUMNS (a) + │ TableID: 104 + │ + ├── • MakeIndexAbsent + │ EventBase: + │ Authorization: + │ UserName: root + │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ StatementTag: ALTER TABLE + │ TargetMetadata: + │ SourceElementID: 1 + │ SubWorkID: 1 + │ IndexID: 2 + │ TableID: 104 + │ + ├── • CreateGcJobForIndex + │ IndexID: 3 + │ TableID: 104 + │ + ├── • MakeIndexAbsent + │ IndexID: 3 + │ TableID: 104 + │ + ├── • RemoveJobStateFromDescriptor + │ DescriptorID: 104 + │ JobID: 1 + │ + └── • UpdateSchemaChangerJob + IsNonCancelable: true + JobID: 1 + RunningStatus: all stages completed diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_6_of_15 b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_6_of_15 new file mode 100644 index 000000000000..012f3fbf38b2 --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_6_of_15 @@ -0,0 +1,199 @@ +/* setup */ +CREATE TABLE t (a INT NOT NULL); + +/* test */ +ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a); +EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 15; +---- +• Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›); +│ +└── • PostCommitNonRevertiblePhase + │ + ├── • Stage 1 of 2 in PostCommitNonRevertiblePhase + │ │ + │ ├── • 8 elements transitioning toward ABSENT + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ MERGE_ONLY → DELETE_ONLY + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ │ │ BACKFILL_ONLY → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 4} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" + │ │ + │ ├── • 2 elements transitioning toward PUBLIC + │ │ │ + │ │ ├── • Column:{DescID: 104, ColumnID: 2} + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnDefaultExpression:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ └── • ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ │ ABSENT → PUBLIC + │ │ + │ └── • 9 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 2 + │ │ Name: rowid + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 3 + │ │ TableID: 104 + │ │ + │ ├── • MakeColumnPublic + │ │ ColumnID: 2 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ TableID: 104 + │ │ + │ ├── • RefreshStats + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 2 + │ │ TableID: 104 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 4 + │ │ StatementForDropJob: + │ │ Rollback: true + │ │ Statement: ALTER TABLE defaultdb.public.t ALTER PRIMARY KEY USING COLUMNS (a) + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ IndexID: 4 + │ │ TableID: 104 + │ │ + │ ├── • SetJobStateOnDescriptor + │ │ DescriptorID: 104 + │ │ + │ └── • UpdateSchemaChangerJob + │ IsNonCancelable: true + │ JobID: 1 + │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 2 with 4 MutationType ops pending + │ + └── • Stage 2 of 2 in PostCommitNonRevertiblePhase + │ + ├── • 2 elements transitioning toward ABSENT + │ │ + │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ rule: "dependents removed before index" + │ │ + │ └── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ DELETE_ONLY → ABSENT + │ │ + │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ rule: "dependents removed before index" + │ │ + │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ rule: "dependents removed before index" + │ + └── • 6 Mutation operations + │ + ├── • CreateGcJobForIndex + │ IndexID: 2 + │ StatementForDropJob: + │ Rollback: true + │ Statement: ALTER TABLE defaultdb.public.t ALTER PRIMARY KEY USING COLUMNS (a) + │ TableID: 104 + │ + ├── • MakeIndexAbsent + │ EventBase: + │ Authorization: + │ UserName: root + │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ StatementTag: ALTER TABLE + │ TargetMetadata: + │ SourceElementID: 1 + │ SubWorkID: 1 + │ IndexID: 2 + │ TableID: 104 + │ + ├── • CreateGcJobForIndex + │ IndexID: 3 + │ TableID: 104 + │ + ├── • MakeIndexAbsent + │ IndexID: 3 + │ TableID: 104 + │ + ├── • RemoveJobStateFromDescriptor + │ DescriptorID: 104 + │ JobID: 1 + │ + └── • UpdateSchemaChangerJob + IsNonCancelable: true + JobID: 1 + RunningStatus: all stages completed diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_7_of_15 b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_7_of_15 new file mode 100644 index 000000000000..1e22b6cb7f2a --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_7_of_15 @@ -0,0 +1,199 @@ +/* setup */ +CREATE TABLE t (a INT NOT NULL); + +/* test */ +ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a); +EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 15; +---- +• Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›); +│ +└── • PostCommitNonRevertiblePhase + │ + ├── • Stage 1 of 2 in PostCommitNonRevertiblePhase + │ │ + │ ├── • 8 elements transitioning toward ABSENT + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ │ │ BACKFILL_ONLY → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 4} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" + │ │ + │ ├── • 2 elements transitioning toward PUBLIC + │ │ │ + │ │ ├── • Column:{DescID: 104, ColumnID: 2} + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnDefaultExpression:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ └── • ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ │ ABSENT → PUBLIC + │ │ + │ └── • 9 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 2 + │ │ Name: rowid + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 2 + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 3 + │ │ TableID: 104 + │ │ + │ ├── • MakeColumnPublic + │ │ ColumnID: 2 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ TableID: 104 + │ │ + │ ├── • RefreshStats + │ │ TableID: 104 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 4 + │ │ StatementForDropJob: + │ │ Rollback: true + │ │ Statement: ALTER TABLE defaultdb.public.t ALTER PRIMARY KEY USING COLUMNS (a) + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ IndexID: 4 + │ │ TableID: 104 + │ │ + │ ├── • SetJobStateOnDescriptor + │ │ DescriptorID: 104 + │ │ + │ └── • UpdateSchemaChangerJob + │ IsNonCancelable: true + │ JobID: 1 + │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 2 with 4 MutationType ops pending + │ + └── • Stage 2 of 2 in PostCommitNonRevertiblePhase + │ + ├── • 2 elements transitioning toward ABSENT + │ │ + │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ rule: "dependents removed before index" + │ │ + │ └── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ DELETE_ONLY → ABSENT + │ │ + │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ rule: "dependents removed before index" + │ │ + │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ rule: "dependents removed before index" + │ + └── • 6 Mutation operations + │ + ├── • CreateGcJobForIndex + │ IndexID: 2 + │ StatementForDropJob: + │ Rollback: true + │ Statement: ALTER TABLE defaultdb.public.t ALTER PRIMARY KEY USING COLUMNS (a) + │ TableID: 104 + │ + ├── • MakeIndexAbsent + │ EventBase: + │ Authorization: + │ UserName: root + │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ StatementTag: ALTER TABLE + │ TargetMetadata: + │ SourceElementID: 1 + │ SubWorkID: 1 + │ IndexID: 2 + │ TableID: 104 + │ + ├── • CreateGcJobForIndex + │ IndexID: 3 + │ TableID: 104 + │ + ├── • MakeIndexAbsent + │ IndexID: 3 + │ TableID: 104 + │ + ├── • RemoveJobStateFromDescriptor + │ DescriptorID: 104 + │ JobID: 1 + │ + └── • UpdateSchemaChangerJob + IsNonCancelable: true + JobID: 1 + RunningStatus: all stages completed diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_8_of_15 b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_8_of_15 new file mode 100644 index 000000000000..fc568b938c90 --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_8_of_15 @@ -0,0 +1,199 @@ +/* setup */ +CREATE TABLE t (a INT NOT NULL); + +/* test */ +ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a); +EXPLAIN (ddl, verbose) rollback at post-commit stage 8 of 15; +---- +• Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›); +│ +└── • PostCommitNonRevertiblePhase + │ + ├── • Stage 1 of 2 in PostCommitNonRevertiblePhase + │ │ + │ ├── • 8 elements transitioning toward ABSENT + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ │ │ BACKFILL_ONLY → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 4} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" + │ │ + │ ├── • 2 elements transitioning toward PUBLIC + │ │ │ + │ │ ├── • Column:{DescID: 104, ColumnID: 2} + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnDefaultExpression:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ └── • ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ │ ABSENT → PUBLIC + │ │ + │ └── • 9 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 2 + │ │ Name: rowid + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 2 + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 3 + │ │ TableID: 104 + │ │ + │ ├── • MakeColumnPublic + │ │ ColumnID: 2 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ TableID: 104 + │ │ + │ ├── • RefreshStats + │ │ TableID: 104 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 4 + │ │ StatementForDropJob: + │ │ Rollback: true + │ │ Statement: ALTER TABLE defaultdb.public.t ALTER PRIMARY KEY USING COLUMNS (a) + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ IndexID: 4 + │ │ TableID: 104 + │ │ + │ ├── • SetJobStateOnDescriptor + │ │ DescriptorID: 104 + │ │ + │ └── • UpdateSchemaChangerJob + │ IsNonCancelable: true + │ JobID: 1 + │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 2 with 4 MutationType ops pending + │ + └── • Stage 2 of 2 in PostCommitNonRevertiblePhase + │ + ├── • 2 elements transitioning toward ABSENT + │ │ + │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ rule: "dependents removed before index" + │ │ + │ └── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ DELETE_ONLY → ABSENT + │ │ + │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ rule: "dependents removed before index" + │ │ + │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ rule: "dependents removed before index" + │ + └── • 6 Mutation operations + │ + ├── • CreateGcJobForIndex + │ IndexID: 2 + │ StatementForDropJob: + │ Rollback: true + │ Statement: ALTER TABLE defaultdb.public.t ALTER PRIMARY KEY USING COLUMNS (a) + │ TableID: 104 + │ + ├── • MakeIndexAbsent + │ EventBase: + │ Authorization: + │ UserName: root + │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ StatementTag: ALTER TABLE + │ TargetMetadata: + │ SourceElementID: 1 + │ SubWorkID: 1 + │ IndexID: 2 + │ TableID: 104 + │ + ├── • CreateGcJobForIndex + │ IndexID: 3 + │ TableID: 104 + │ + ├── • MakeIndexAbsent + │ IndexID: 3 + │ TableID: 104 + │ + ├── • RemoveJobStateFromDescriptor + │ DescriptorID: 104 + │ JobID: 1 + │ + └── • UpdateSchemaChangerJob + IsNonCancelable: true + JobID: 1 + RunningStatus: all stages completed diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_9_of_15 b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_9_of_15 new file mode 100644 index 000000000000..ae01b435b079 --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_9_of_15 @@ -0,0 +1,293 @@ +/* setup */ +CREATE TABLE t (a INT NOT NULL); + +/* test */ +ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a); +EXPLAIN (ddl, verbose) rollback at post-commit stage 9 of 15; +---- +• Schema change plan for rolling back ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›); +│ +└── • PostCommitNonRevertiblePhase + │ + ├── • Stage 1 of 3 in PostCommitNonRevertiblePhase + │ │ + │ ├── • 11 elements transitioning toward ABSENT + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ PUBLIC → WRITE_ONLY + │ │ │ + │ │ ├── • IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index no longer public before dependents" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 2} + │ │ │ │ BACKFILL_ONLY → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 4} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 2} + │ │ │ │ DELETE_ONLY → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" + │ │ + │ ├── • 4 elements transitioning toward PUBLIC + │ │ │ + │ │ ├── • Column:{DescID: 104, ColumnID: 2} + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnDefaultExpression:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ ├── • ColumnName:{DescID: 104, Name: rowid, ColumnID: 2} + │ │ │ ABSENT → PUBLIC + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ │ │ VALIDATED → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ rule: "index named right before index becomes public" + │ │ │ │ + │ │ │ └── • SameStagePrecedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "primary index swap" + │ │ │ + │ │ └── • IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} + │ │ ABSENT → PUBLIC + │ │ + │ └── • 14 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 2 + │ │ Name: rowid + │ │ TableID: 104 + │ │ + │ ├── • SetIndexName + │ │ IndexID: 1 + │ │ Name: t_pkey + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedPrimaryIndexDeleteAndWriteOnly + │ │ IndexID: 2 + │ │ TableID: 104 + │ │ + │ ├── • SetIndexName + │ │ IndexID: 2 + │ │ Name: crdb_internal_index_2_name_placeholder + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 3 + │ │ TableID: 104 + │ │ + │ ├── • MakeColumnPublic + │ │ ColumnID: 2 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ TableID: 104 + │ │ + │ ├── • RefreshStats + │ │ TableID: 104 + │ │ + │ ├── • MakeAddedPrimaryIndexPublic + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ IndexID: 1 + │ │ TableID: 104 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 4 + │ │ StatementForDropJob: + │ │ Rollback: true + │ │ Statement: ALTER TABLE defaultdb.public.t ALTER PRIMARY KEY USING COLUMNS (a) + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ IndexID: 4 + │ │ TableID: 104 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 5 + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ IndexID: 5 + │ │ TableID: 104 + │ │ + │ ├── • SetJobStateOnDescriptor + │ │ DescriptorID: 104 + │ │ + │ └── • UpdateSchemaChangerJob + │ IsNonCancelable: true + │ JobID: 1 + │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 3 with 3 MutationType ops pending + │ + ├── • Stage 2 of 3 in PostCommitNonRevertiblePhase + │ │ + │ ├── • 2 elements transitioning toward ABSENT + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ + │ │ └── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ rule: "dependents removed before index" + │ │ + │ └── • 5 Mutation operations + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 2 + │ │ TableID: 104 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 3 + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ IndexID: 3 + │ │ TableID: 104 + │ │ + │ ├── • SetJobStateOnDescriptor + │ │ DescriptorID: 104 + │ │ + │ └── • UpdateSchemaChangerJob + │ IsNonCancelable: true + │ JobID: 1 + │ RunningStatus: PostCommitNonRevertiblePhase stage 3 of 3 with 2 MutationType ops pending + │ + └── • Stage 3 of 3 in PostCommitNonRevertiblePhase + │ + ├── • 1 element transitioning toward ABSENT + │ │ + │ └── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ DELETE_ONLY → ABSENT + │ │ + │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ rule: "dependents removed before index" + │ │ + │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ rule: "dependents removed before index" + │ │ + │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ rule: "dependents removed before index" + │ + └── • 4 Mutation operations + │ + ├── • CreateGcJobForIndex + │ IndexID: 2 + │ StatementForDropJob: + │ Rollback: true + │ Statement: ALTER TABLE defaultdb.public.t ALTER PRIMARY KEY USING COLUMNS (a) + │ TableID: 104 + │ + ├── • MakeIndexAbsent + │ EventBase: + │ Authorization: + │ UserName: root + │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› ALTER PRIMARY KEY USING COLUMNS (‹a›) + │ StatementTag: ALTER TABLE + │ TargetMetadata: + │ SourceElementID: 1 + │ SubWorkID: 1 + │ IndexID: 2 + │ TableID: 104 + │ + ├── • RemoveJobStateFromDescriptor + │ DescriptorID: 104 + │ JobID: 1 + │ + └── • UpdateSchemaChangerJob + IsNonCancelable: true + JobID: 1 + RunningStatus: all stages completed diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_vanilla b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_vanilla index e17212557538..c98e00852d1f 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_vanilla +++ b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_vanilla @@ -10,36 +10,22 @@ EXPLAIN (ddl, verbose) ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (j); │ │ │ └── • Stage 1 of 1 in StatementPhase │ │ -│ ├── • 10 elements transitioning toward PUBLIC +│ ├── • 8 elements transitioning toward PUBLIC +│ │ │ +│ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ ABSENT → BACKFILL_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} │ │ │ │ ABSENT → PUBLIC │ │ │ │ │ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} -│ │ │ rule: "index-column added to index after index exists" +│ │ │ rule: "index existence precedes index dependents" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ │ │ ABSENT → PUBLIC │ │ │ │ │ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} -│ │ │ rule: "index-column added to index after index exists" -│ │ │ -│ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} -│ │ │ ABSENT → BACKFILL_ONLY -│ │ │ -│ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} -│ │ │ │ ABSENT → PUBLIC -│ │ │ │ -│ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} -│ │ │ rule: "temp index exists before columns, partitioning, and partial" -│ │ │ rule: "index-column added to index after temp index exists" -│ │ │ -│ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} -│ │ │ │ ABSENT → PUBLIC -│ │ │ │ -│ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} -│ │ │ rule: "temp index exists before columns, partitioning, and partial" -│ │ │ rule: "index-column added to index after temp index exists" +│ │ │ rule: "index existence precedes index dependents" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1} │ │ │ ABSENT → BACKFILL_ONLY @@ -48,33 +34,43 @@ EXPLAIN (ddl, verbose) ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (j); │ │ │ │ ABSENT → PUBLIC │ │ │ │ │ │ │ └── • Precedence dependency from BACKFILL_ONLY SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1} -│ │ │ rule: "index-column added to index after index exists" +│ │ │ rule: "index existence precedes index dependents" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} │ │ │ │ ABSENT → PUBLIC │ │ │ │ │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 1} -│ │ │ rule: "temp index exists before columns, partitioning, and partial" -│ │ │ rule: "index-column added to index after temp index exists" +│ │ │ rule: "temp index existence precedes index dependents" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 4} │ │ │ │ ABSENT → PUBLIC │ │ │ │ │ │ │ └── • Precedence dependency from BACKFILL_ONLY SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1} -│ │ │ rule: "index-column added to index after index exists" +│ │ │ rule: "index existence precedes index dependents" │ │ │ │ │ └── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 5} │ │ │ ABSENT → PUBLIC │ │ │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 1} -│ │ rule: "temp index exists before columns, partitioning, and partial" -│ │ rule: "index-column added to index after temp index exists" +│ │ rule: "temp index existence precedes index dependents" │ │ -│ ├── • 2 elements transitioning toward TRANSIENT_ABSENT +│ ├── • 4 elements transitioning toward TRANSIENT_ABSENT │ │ │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ │ ABSENT → DELETE_ONLY │ │ │ +│ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} +│ │ │ │ ABSENT → PUBLIC +│ │ │ │ +│ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} +│ │ │ rule: "temp index existence precedes index dependents" +│ │ │ +│ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} +│ │ │ │ ABSENT → PUBLIC +│ │ │ │ +│ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} +│ │ │ rule: "temp index existence precedes index dependents" +│ │ │ │ │ └── • TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 1} │ │ ABSENT → DELETE_ONLY │ │ @@ -89,6 +85,17 @@ EXPLAIN (ddl, verbose) ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (j); │ │ TableID: 104 │ │ TemporaryIndexID: 3 │ │ +│ ├── • AddColumnToIndex +│ │ ColumnID: 2 +│ │ IndexID: 2 +│ │ TableID: 104 +│ │ +│ ├── • AddColumnToIndex +│ │ ColumnID: 1 +│ │ IndexID: 2 +│ │ Kind: 2 +│ │ TableID: 104 +│ │ │ ├── • MakeAddedTempIndexDeleteOnly │ │ Index: │ │ ConstraintID: 3 @@ -143,21 +150,10 @@ EXPLAIN (ddl, verbose) ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (j); │ │ Kind: 1 │ │ TableID: 104 │ │ -│ ├── • AddColumnToIndex -│ │ ColumnID: 2 -│ │ IndexID: 5 -│ │ Kind: 1 -│ │ TableID: 104 -│ │ -│ ├── • AddColumnToIndex -│ │ ColumnID: 2 -│ │ IndexID: 2 -│ │ TableID: 104 -│ │ │ └── • AddColumnToIndex -│ ColumnID: 1 -│ IndexID: 2 -│ Kind: 2 +│ ColumnID: 2 +│ IndexID: 5 +│ Kind: 1 │ TableID: 104 │ ├── • PreCommitPhase @@ -199,13 +195,7 @@ EXPLAIN (ddl, verbose) ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (j); │ │ │ │ rule: "index-column added to index before temp index receives writes" │ │ │ │ │ │ │ └── • TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 1} -│ │ │ │ DELETE_ONLY → WRITE_ONLY -│ │ │ │ -│ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} -│ │ │ │ rule: "index-column added to index before temp index receives writes" -│ │ │ │ -│ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 5} -│ │ │ rule: "index-column added to index before temp index receives writes" +│ │ │ DELETE_ONLY → WRITE_ONLY │ │ │ │ │ └── • 4 Mutation operations │ │ │ @@ -396,14 +386,20 @@ EXPLAIN (ddl, verbose) ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (j); │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} │ │ │ PUBLIC → WRITE_ONLY @@ -412,7 +408,7 @@ EXPLAIN (ddl, verbose) ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (j); │ │ │ PUBLIC → ABSENT │ │ │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ rule: "index no longer public before dependents removed" + │ │ rule: "index no longer public before dependents" │ │ │ ├── • 4 elements transitioning toward PUBLIC │ │ │ @@ -422,36 +418,62 @@ EXPLAIN (ddl, verbose) ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (j); │ │ │ ├── • SameStagePrecedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} │ │ │ │ rule: "primary index swap" │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} - │ │ │ rule: "index named right before index becomes public" + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ rule: "index named right before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ │ │ ├── • IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} │ │ │ │ ABSENT → PUBLIC │ │ │ │ │ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ rule: "index existence precedes index name and comment" + │ │ │ rule: "index existence precedes index dependents" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 4} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_i_key, IndexID: 4} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ └── • IndexName:{DescID: 104, Name: t_i_key, IndexID: 4} │ │ │ ABSENT → PUBLIC │ │ │ │ │ └── • Precedence dependency from BACKFILL_ONLY SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1} - │ │ rule: "index existence precedes index name and comment" + │ │ rule: "index existence precedes index dependents" │ │ - │ ├── • 2 elements transitioning toward TRANSIENT_ABSENT + │ ├── • 4 elements transitioning toward TRANSIENT_ABSENT │ │ │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → TRANSIENT_DELETE_ONLY │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ │ │ PUBLIC → TRANSIENT_ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → TRANSIENT_ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → TRANSIENT_ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → TRANSIENT_ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ │ │ └── • TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 1} │ │ WRITE_ONLY → TRANSIENT_DELETE_ONLY │ │ - │ └── • 12 Mutation operations + │ └── • 10 Mutation operations │ │ │ ├── • MakeDroppedPrimaryIndexDeleteAndWriteOnly │ │ IndexID: 1 @@ -480,17 +502,6 @@ EXPLAIN (ddl, verbose) ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (j); │ │ Name: t_i_key │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 1 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 1 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ │ ├── • MakeAddedPrimaryIndexPublic │ │ EventBase: │ │ Authorization: @@ -514,7 +525,7 @@ EXPLAIN (ddl, verbose) ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (j); │ └── • UpdateSchemaChangerJob │ IsNonCancelable: true │ JobID: 1 - │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 3 with 1 MutationType op pending + │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 3 with 5 MutationType ops pending │ ├── • Stage 2 of 3 in PostCommitNonRevertiblePhase │ │ @@ -523,19 +534,49 @@ EXPLAIN (ddl, verbose) ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (j); │ │ └── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} │ │ WRITE_ONLY → DELETE_ONLY │ │ - │ └── • 3 Mutation operations + │ ├── • 2 elements transitioning toward TRANSIENT_ABSENT + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ │ TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from TRANSIENT_ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ └── • Precedence dependency from TRANSIENT_ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 1} + │ │ TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT + │ │ + │ └── • 7 Mutation operations │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 1 │ │ TableID: 104 │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 3 + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ IndexID: 3 + │ │ TableID: 104 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 5 + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ IndexID: 5 + │ │ TableID: 104 + │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 104 │ │ │ └── • UpdateSchemaChangerJob │ IsNonCancelable: true │ JobID: 1 - │ RunningStatus: PostCommitNonRevertiblePhase stage 3 of 3 with 6 MutationType ops pending + │ RunningStatus: PostCommitNonRevertiblePhase stage 3 of 3 with 2 MutationType ops pending │ └── • Stage 3 of 3 in PostCommitNonRevertiblePhase │ @@ -550,40 +591,10 @@ EXPLAIN (ddl, verbose) ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (j); │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} │ │ rule: "dependents removed before index" │ │ - │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} - │ │ rule: "dependents removed before index" - │ │ - │ ├── • SameStagePrecedence dependency from TRANSIENT_ABSENT TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} - │ │ rule: "temp indexes reach absent at the same time as other indexes" - │ │ - │ └── • SameStagePrecedence dependency from TRANSIENT_ABSENT TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 1} - │ rule: "temp indexes reach absent at the same time as other indexes" - │ - ├── • 2 elements transitioning toward TRANSIENT_ABSENT - │ │ - │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} - │ │ TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT - │ │ - │ └── • TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 1} - │ TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT + │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} + │ rule: "dependents removed before index" │ - └── • 8 Mutation operations - │ - ├── • CreateGcJobForIndex - │ IndexID: 3 - │ TableID: 104 - │ - ├── • MakeIndexAbsent - │ IndexID: 3 - │ TableID: 104 - │ - ├── • CreateGcJobForIndex - │ IndexID: 5 - │ TableID: 104 - │ - ├── • MakeIndexAbsent - │ IndexID: 5 - │ TableID: 104 + └── • 4 Mutation operations │ ├── • CreateGcJobForIndex │ IndexID: 1 diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_vanilla.rollback_1_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_vanilla.rollback_1_of_7 index 2d57349b9b46..cd38e997f066 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_vanilla.rollback_1_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_vanilla.rollback_1_of_7 @@ -13,24 +13,30 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 7; │ ├── • 12 elements transitioning toward ABSENT │ │ - │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} - │ │ PUBLIC → ABSENT - │ │ - │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} - │ │ PUBLIC → ABSENT - │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ BACKFILL_ONLY → ABSENT │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ rule: "dependents removed before index" │ │ + │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" + │ │ + │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" + │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ │ DELETE_ONLY → ABSENT │ │ │ @@ -41,20 +47,24 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 7; │ │ rule: "dependents removed before index" │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1} │ │ │ BACKFILL_ONLY → ABSENT │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ rule: "dependents removed before index" │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 4} - │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ rule: "dependents removed before index" │ │ │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_i_key, IndexID: 4} @@ -72,66 +82,28 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 7; │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} │ │ │ PUBLIC → ABSENT │ │ │ - │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1} - │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 4} │ │ │ PUBLIC → ABSENT │ │ │ - │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1} - │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ └── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 5} - │ PUBLIC → ABSENT + │ │ PUBLIC → ABSENT + │ │ + │ └── • skip PUBLIC → ABSENT operations + │ rule: "skip index-column removal ops on index removal" │ - └── • 19 Mutation operations - │ - ├── • RemoveColumnFromIndex - │ ColumnID: 2 - │ IndexID: 2 - │ TableID: 104 - │ - ├── • RemoveColumnFromIndex - │ ColumnID: 1 - │ IndexID: 2 - │ Kind: 2 - │ TableID: 104 - │ - ├── • RemoveColumnFromIndex - │ ColumnID: 2 - │ IndexID: 3 - │ TableID: 104 - │ - ├── • RemoveColumnFromIndex - │ ColumnID: 1 - │ IndexID: 3 - │ Kind: 2 - │ TableID: 104 - │ - ├── • RemoveColumnFromIndex - │ ColumnID: 1 - │ IndexID: 4 - │ TableID: 104 - │ - ├── • RemoveColumnFromIndex - │ ColumnID: 1 - │ IndexID: 5 - │ TableID: 104 - │ - ├── • RemoveColumnFromIndex - │ ColumnID: 2 - │ IndexID: 4 - │ Kind: 1 - │ TableID: 104 - │ - ├── • RemoveColumnFromIndex - │ ColumnID: 2 - │ IndexID: 5 - │ Kind: 1 - │ TableID: 104 + └── • 11 Mutation operations │ ├── • CreateGcJobForIndex │ IndexID: 2 diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_vanilla.rollback_2_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_vanilla.rollback_2_of_7 index 2f06d2d5d5b1..eba28bee82bc 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_vanilla.rollback_2_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_vanilla.rollback_2_of_7 @@ -13,42 +13,52 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 2 of 7; │ │ │ ├── • 12 elements transitioning toward ABSENT │ │ │ - │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} - │ │ │ PUBLIC → ABSENT - │ │ │ - │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} - │ │ │ PUBLIC → ABSENT - │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ │ BACKFILL_ONLY → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} │ │ │ │ rule: "dependents removed before index" │ │ │ │ - │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} │ │ │ │ rule: "dependents removed before index" │ │ │ │ - │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ │ rule: "dependents removed before index" │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1} │ │ │ │ BACKFILL_ONLY → ABSENT │ │ │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ │ rule: "dependents removed before index" │ │ │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 4} - │ │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ │ rule: "dependents removed before index" │ │ │ │ │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_i_key, IndexID: 4} @@ -60,75 +70,37 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 2 of 7; │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 4} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 5} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ - │ └── • 17 Mutation operations - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 2 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ Kind: 2 - │ │ TableID: 104 + │ └── • 9 Mutation operations │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 3 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 5 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 5 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 4 - │ │ Kind: 1 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 5 - │ │ Kind: 1 - │ │ TableID: 104 - │ │ │ ├── • CreateGcJobForIndex │ │ IndexID: 2 │ │ StatementForDropJob: diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_vanilla.rollback_3_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_vanilla.rollback_3_of_7 index cc3b98afa989..fa5135e6c99a 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_vanilla.rollback_3_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_vanilla.rollback_3_of_7 @@ -13,42 +13,52 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 3 of 7; │ │ │ ├── • 12 elements transitioning toward ABSENT │ │ │ - │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} - │ │ │ PUBLIC → ABSENT - │ │ │ - │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} - │ │ │ PUBLIC → ABSENT - │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ │ BACKFILL_ONLY → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} │ │ │ │ rule: "dependents removed before index" │ │ │ │ - │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} │ │ │ │ rule: "dependents removed before index" │ │ │ │ - │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ │ rule: "dependents removed before index" │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1} │ │ │ │ BACKFILL_ONLY → ABSENT │ │ │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ │ rule: "dependents removed before index" │ │ │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 4} - │ │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ │ rule: "dependents removed before index" │ │ │ │ │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_i_key, IndexID: 4} @@ -60,75 +70,37 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 3 of 7; │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 4} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 5} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ - │ └── • 17 Mutation operations - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 2 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ Kind: 2 - │ │ TableID: 104 + │ └── • 9 Mutation operations │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 3 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 5 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 5 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 4 - │ │ Kind: 1 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 5 - │ │ Kind: 1 - │ │ TableID: 104 - │ │ │ ├── • CreateGcJobForIndex │ │ IndexID: 2 │ │ StatementForDropJob: diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_vanilla.rollback_4_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_vanilla.rollback_4_of_7 index 653a3b7c87f0..31d7d3a1921a 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_vanilla.rollback_4_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_vanilla.rollback_4_of_7 @@ -13,42 +13,52 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 7; │ │ │ ├── • 12 elements transitioning toward ABSENT │ │ │ - │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} - │ │ │ PUBLIC → ABSENT - │ │ │ - │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} - │ │ │ PUBLIC → ABSENT - │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ │ DELETE_ONLY → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} │ │ │ │ rule: "dependents removed before index" │ │ │ │ - │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} │ │ │ │ rule: "dependents removed before index" │ │ │ │ - │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ │ rule: "dependents removed before index" │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1} │ │ │ │ DELETE_ONLY → ABSENT │ │ │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ │ rule: "dependents removed before index" │ │ │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 4} - │ │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ │ rule: "dependents removed before index" │ │ │ │ │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_i_key, IndexID: 4} @@ -60,32 +70,35 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 7; │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 4} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 5} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ - │ └── • 17 Mutation operations + │ └── • 9 Mutation operations │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 2 + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 3 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ Kind: 2 + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 5 │ │ TableID: 104 │ │ │ ├── • CreateGcJobForIndex @@ -107,47 +120,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 7; │ │ IndexID: 2 │ │ TableID: 104 │ │ - │ ├── • MakeDroppedIndexDeleteOnly - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ - │ ├── • MakeDroppedIndexDeleteOnly - │ │ IndexID: 5 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 5 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 4 - │ │ Kind: 1 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 5 - │ │ Kind: 1 - │ │ TableID: 104 - │ │ │ ├── • LogEvent │ │ Element: │ │ SecondaryIndex: diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_vanilla.rollback_5_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_vanilla.rollback_5_of_7 index c0afcce19d51..eaa5307cf2ae 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_vanilla.rollback_5_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_vanilla.rollback_5_of_7 @@ -13,23 +13,35 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 7; │ │ │ ├── • 12 elements transitioning toward ABSENT │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ MERGE_ONLY → DELETE_ONLY + │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} - │ │ │ PUBLIC → ABSENT - │ │ │ - │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ MERGE_ONLY → DELETE_ONLY + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1} │ │ │ MERGE_ONLY → DELETE_ONLY @@ -40,64 +52,37 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 7; │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 4} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 5} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ - │ └── • 14 Mutation operations - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 2 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ Kind: 2 - │ │ TableID: 104 + │ └── • 6 Mutation operations │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 3 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 5 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 5 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 5 - │ │ Kind: 1 - │ │ TableID: 104 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 2 │ │ TableID: 104 @@ -106,17 +91,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 7; │ │ IndexID: 4 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 4 - │ │ Kind: 1 - │ │ TableID: 104 - │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 104 │ │ @@ -132,13 +106,13 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 7; │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ DELETE_ONLY → ABSENT │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ rule: "dependents removed before index" │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} @@ -154,11 +128,9 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 7; │ │ │ DELETE_ONLY → ABSENT │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ rule: "dependents removed before index" │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 4} - │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ rule: "dependents removed before index" │ │ │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_i_key, IndexID: 4} diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_vanilla.rollback_6_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_vanilla.rollback_6_of_7 index 24bf20a3c3dc..1a39e4f44031 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_vanilla.rollback_6_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_vanilla.rollback_6_of_7 @@ -13,23 +13,35 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 7; │ │ │ ├── • 12 elements transitioning toward ABSENT │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ MERGE_ONLY → DELETE_ONLY + │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} - │ │ │ PUBLIC → ABSENT - │ │ │ - │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ MERGE_ONLY → DELETE_ONLY + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1} │ │ │ MERGE_ONLY → DELETE_ONLY @@ -40,64 +52,37 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 7; │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 4} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 5} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ - │ └── • 14 Mutation operations - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 2 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ Kind: 2 - │ │ TableID: 104 + │ └── • 6 Mutation operations │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 3 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 5 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 5 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 5 - │ │ Kind: 1 - │ │ TableID: 104 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 2 │ │ TableID: 104 @@ -106,17 +91,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 7; │ │ IndexID: 4 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 4 - │ │ Kind: 1 - │ │ TableID: 104 - │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 104 │ │ @@ -132,13 +106,13 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 7; │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ DELETE_ONLY → ABSENT │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ rule: "dependents removed before index" │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} @@ -154,11 +128,9 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 7; │ │ │ DELETE_ONLY → ABSENT │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ rule: "dependents removed before index" │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 4} - │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ rule: "dependents removed before index" │ │ │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_i_key, IndexID: 4} diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_vanilla.rollback_7_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_vanilla.rollback_7_of_7 index 243a4936d03c..950386ac0f40 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_vanilla.rollback_7_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_vanilla.rollback_7_of_7 @@ -13,23 +13,35 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ │ │ ├── • 12 elements transitioning toward ABSENT │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} - │ │ │ PUBLIC → ABSENT - │ │ │ - │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY @@ -40,33 +52,28 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 4} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 5} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ - │ └── • 14 Mutation operations - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 2 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ Kind: 2 - │ │ TableID: 104 + │ └── • 6 Mutation operations │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 2 @@ -76,17 +83,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ │ IndexID: 3 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 4 │ │ TableID: 104 @@ -95,28 +91,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ │ IndexID: 5 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 5 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 4 - │ │ Kind: 1 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 5 - │ │ Kind: 1 - │ │ TableID: 104 - │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 104 │ │ @@ -132,13 +106,13 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ DELETE_ONLY → ABSENT │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ rule: "dependents removed before index" │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} @@ -154,11 +128,9 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ │ │ DELETE_ONLY → ABSENT │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ rule: "dependents removed before index" │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 4} - │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ rule: "dependents removed before index" │ │ │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_i_key, IndexID: 4} diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/create_index b/pkg/sql/schemachanger/testdata/explain_verbose/create_index index 669dd5639bb7..42d2f5c5e10c 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/create_index +++ b/pkg/sql/schemachanger/testdata/explain_verbose/create_index @@ -17,13 +17,13 @@ EXPLAIN (ddl, verbose) CREATE INDEX idx1 ON t (v) WHERE (v = 'a'); │ │ │ │ ABSENT → PUBLIC │ │ │ │ │ │ │ └── • Precedence dependency from BACKFILL_ONLY SecondaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} -│ │ │ rule: "index-column added to index after index exists" +│ │ │ rule: "index existence precedes index dependents" │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} │ │ │ │ ABSENT → PUBLIC │ │ │ │ │ │ │ └── • Precedence dependency from BACKFILL_ONLY SecondaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} -│ │ │ rule: "index-column added to index after index exists" +│ │ │ rule: "index existence precedes index dependents" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ ABSENT → BACKFILL_ONLY @@ -32,15 +32,13 @@ EXPLAIN (ddl, verbose) CREATE INDEX idx1 ON t (v) WHERE (v = 'a'); │ │ │ │ ABSENT → PUBLIC │ │ │ │ │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 0, SourceIndexID: 1} -│ │ │ rule: "temp index exists before columns, partitioning, and partial" -│ │ │ rule: "index-column added to index after temp index exists" +│ │ │ rule: "temp index existence precedes index dependents" │ │ │ │ │ └── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} │ │ │ ABSENT → PUBLIC │ │ │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 0, SourceIndexID: 1} -│ │ rule: "temp index exists before columns, partitioning, and partial" -│ │ rule: "index-column added to index after temp index exists" +│ │ rule: "temp index existence precedes index dependents" │ │ │ ├── • 1 element transitioning toward TRANSIENT_ABSENT │ │ │ @@ -116,13 +114,7 @@ EXPLAIN (ddl, verbose) CREATE INDEX idx1 ON t (v) WHERE (v = 'a'); │ │ ├── • 1 element transitioning toward TRANSIENT_ABSENT │ │ │ │ │ │ │ └── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 0, SourceIndexID: 1} -│ │ │ │ DELETE_ONLY → WRITE_ONLY -│ │ │ │ -│ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} -│ │ │ │ rule: "index-column added to index before temp index receives writes" -│ │ │ │ -│ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} -│ │ │ rule: "index-column added to index before temp index receives writes" +│ │ │ DELETE_ONLY → WRITE_ONLY │ │ │ │ │ └── • 3 Mutation operations │ │ │ @@ -256,14 +248,21 @@ EXPLAIN (ddl, verbose) CREATE INDEX idx1 ON t (v) WHERE (v = 'a'); │ │ ├── • SecondaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 106, Name: idx1, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ └── • IndexName:{DescID: 106, Name: idx1, IndexID: 2} │ │ │ ABSENT → PUBLIC │ │ │ │ │ └── • Precedence dependency from BACKFILL_ONLY SecondaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ rule: "index existence precedes index name and comment" + │ │ rule: "index existence precedes index dependents" │ │ │ ├── • 1 element transitioning toward TRANSIENT_ABSENT │ │ │ diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/create_index.rollback_1_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/create_index.rollback_1_of_7 index 81655b60d97b..00c008d0f250 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/create_index.rollback_1_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/create_index.rollback_1_of_7 @@ -17,24 +17,22 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 7; │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} │ │ │ PUBLIC → ABSENT │ │ │ - │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} │ │ │ PUBLIC → ABSENT │ │ │ - │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • SecondaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ BACKFILL_ONLY → ABSENT │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} - │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ rule: "dependents removed before index" │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} - │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ rule: "dependents removed before index" │ │ │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: idx1, IndexID: 2} @@ -50,34 +48,18 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 7; │ │ rule: "dependents removed before index" │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ └── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} - │ PUBLIC → ABSENT + │ │ PUBLIC → ABSENT + │ │ + │ └── • skip PUBLIC → ABSENT operations + │ rule: "skip index-column removal ops on index removal" │ - └── • 11 Mutation operations - │ - ├── • RemoveColumnFromIndex - │ ColumnID: 2 - │ IndexID: 3 - │ TableID: 106 - │ - ├── • RemoveColumnFromIndex - │ ColumnID: 1 - │ IndexID: 3 - │ Kind: 1 - │ TableID: 106 - │ - ├── • RemoveColumnFromIndex - │ ColumnID: 2 - │ IndexID: 2 - │ TableID: 106 - │ - ├── • RemoveColumnFromIndex - │ ColumnID: 1 - │ IndexID: 2 - │ Kind: 1 - │ TableID: 106 + └── • 7 Mutation operations │ ├── • LogEvent │ Element: diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/create_index.rollback_2_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/create_index.rollback_2_of_7 index e38a8c2f13a2..629600c4cfbc 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/create_index.rollback_2_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/create_index.rollback_2_of_7 @@ -17,24 +17,22 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 2 of 7; │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ │ BACKFILL_ONLY → ABSENT │ │ │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} - │ │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ │ rule: "dependents removed before index" │ │ │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} - │ │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ │ rule: "dependents removed before index" │ │ │ │ │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: idx1, IndexID: 2} @@ -44,39 +42,23 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 2 of 7; │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ - │ └── • 10 Mutation operations + │ └── • 6 Mutation operations │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 3 │ │ TableID: 106 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 3 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ Kind: 1 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 2 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ Kind: 1 - │ │ TableID: 106 - │ │ │ ├── • LogEvent │ │ Element: │ │ SecondaryIndex: diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/create_index.rollback_3_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/create_index.rollback_3_of_7 index c4afc09fe46e..9679554c49df 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/create_index.rollback_3_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/create_index.rollback_3_of_7 @@ -17,24 +17,22 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 3 of 7; │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ │ BACKFILL_ONLY → ABSENT │ │ │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} - │ │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ │ rule: "dependents removed before index" │ │ │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} - │ │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ │ rule: "dependents removed before index" │ │ │ │ │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: idx1, IndexID: 2} @@ -44,39 +42,23 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 3 of 7; │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ - │ └── • 10 Mutation operations + │ └── • 6 Mutation operations │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 3 │ │ TableID: 106 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 3 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ Kind: 1 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 2 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ Kind: 1 - │ │ TableID: 106 - │ │ │ ├── • LogEvent │ │ Element: │ │ SecondaryIndex: diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/create_index.rollback_4_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/create_index.rollback_4_of_7 index ad3109c3b835..88268e6dbbc4 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/create_index.rollback_4_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/create_index.rollback_4_of_7 @@ -17,24 +17,22 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 7; │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ │ DELETE_ONLY → ABSENT │ │ │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} - │ │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ │ rule: "dependents removed before index" │ │ │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} - │ │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ │ rule: "dependents removed before index" │ │ │ │ │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: idx1, IndexID: 2} @@ -44,23 +42,18 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 7; │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ - │ └── • 10 Mutation operations - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 2 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ Kind: 1 - │ │ TableID: 106 + │ └── • 6 Mutation operations │ │ │ ├── • LogEvent │ │ Element: @@ -94,17 +87,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 7; │ │ IndexID: 3 │ │ TableID: 106 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 3 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ Kind: 1 - │ │ TableID: 106 - │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 106 │ │ diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/create_index.rollback_5_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/create_index.rollback_5_of_7 index d85fa15deae1..a3f9fe3e18bb 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/create_index.rollback_5_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/create_index.rollback_5_of_7 @@ -17,14 +17,14 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 7; │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ MERGE_ONLY → DELETE_ONLY @@ -33,43 +33,27 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 7; │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ - │ └── • 8 Mutation operations + │ └── • 4 Mutation operations │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 3 │ │ TableID: 106 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 3 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ Kind: 1 - │ │ TableID: 106 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 2 │ │ TableID: 106 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 2 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ Kind: 1 - │ │ TableID: 106 - │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 106 │ │ @@ -86,11 +70,9 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 7; │ │ │ DELETE_ONLY → ABSENT │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} - │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ rule: "dependents removed before index" │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} - │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ rule: "dependents removed before index" │ │ │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: idx1, IndexID: 2} diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/create_index.rollback_6_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/create_index.rollback_6_of_7 index df57fe2831ae..2f8917697486 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/create_index.rollback_6_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/create_index.rollback_6_of_7 @@ -17,14 +17,14 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 7; │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ MERGE_ONLY → DELETE_ONLY @@ -33,43 +33,27 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 7; │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ - │ └── • 8 Mutation operations + │ └── • 4 Mutation operations │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 3 │ │ TableID: 106 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 3 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ Kind: 1 - │ │ TableID: 106 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 2 │ │ TableID: 106 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 2 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ Kind: 1 - │ │ TableID: 106 - │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 106 │ │ @@ -86,11 +70,9 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 7; │ │ │ DELETE_ONLY → ABSENT │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} - │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ rule: "dependents removed before index" │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} - │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ rule: "dependents removed before index" │ │ │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: idx1, IndexID: 2} diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/create_index.rollback_7_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/create_index.rollback_7_of_7 index 758008b5f817..694b577d5c54 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/create_index.rollback_7_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/create_index.rollback_7_of_7 @@ -17,14 +17,14 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 0, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY @@ -33,12 +33,18 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ - │ └── • 8 Mutation operations + │ └── • 4 Mutation operations │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 2 @@ -48,28 +54,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ │ IndexID: 3 │ │ TableID: 106 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 3 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ Kind: 1 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 2 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ Kind: 1 - │ │ TableID: 106 - │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 106 │ │ @@ -86,11 +70,9 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ │ │ DELETE_ONLY → ABSENT │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} - │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ rule: "dependents removed before index" │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} - │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ rule: "dependents removed before index" │ │ │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: idx1, IndexID: 2} diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_basic b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_basic index 4fd8208f4d07..373e54cb12ef 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_basic +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_basic @@ -19,30 +19,29 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j; │ │ │ PUBLIC → ABSENT │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 2} -│ │ rule: "column dependents removed after column no longer public" +│ │ rule: "column no longer public before dependents" │ │ -│ ├── • 3 elements transitioning toward PUBLIC -│ │ │ -│ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} -│ │ │ │ ABSENT → PUBLIC -│ │ │ │ -│ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} -│ │ │ rule: "index-column added to index after index exists" +│ ├── • 2 elements transitioning toward PUBLIC │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ ABSENT → BACKFILL_ONLY │ │ │ -│ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} +│ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ │ ABSENT → PUBLIC │ │ │ -│ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} -│ │ rule: "temp index exists before columns, partitioning, and partial" -│ │ rule: "index-column added to index after temp index exists" +│ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ rule: "index existence precedes index dependents" │ │ -│ ├── • 1 element transitioning toward TRANSIENT_ABSENT +│ ├── • 2 elements transitioning toward TRANSIENT_ABSENT +│ │ │ +│ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} +│ │ │ ABSENT → DELETE_ONLY │ │ │ -│ │ └── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} -│ │ ABSENT → DELETE_ONLY +│ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} +│ │ │ ABSENT → PUBLIC +│ │ │ +│ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} +│ │ rule: "temp index existence precedes index dependents" │ │ │ └── • 7 Mutation operations │ │ @@ -80,6 +79,11 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j; │ │ TableID: 104 │ │ TemporaryIndexID: 3 │ │ +│ ├── • AddColumnToIndex +│ │ ColumnID: 1 +│ │ IndexID: 2 +│ │ TableID: 104 +│ │ │ ├── • MakeAddedTempIndexDeleteOnly │ │ Index: │ │ ConstraintID: 3 @@ -88,14 +92,9 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j; │ │ SourceIndexID: 1 │ │ TableID: 104 │ │ -│ ├── • AddColumnToIndex -│ │ ColumnID: 1 -│ │ IndexID: 3 -│ │ TableID: 104 -│ │ │ └── • AddColumnToIndex │ ColumnID: 1 -│ IndexID: 2 +│ IndexID: 3 │ TableID: 104 │ ├── • PreCommitPhase @@ -264,14 +263,23 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j; │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} │ │ │ PUBLIC → WRITE_ONLY @@ -280,7 +288,7 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j; │ │ │ PUBLIC → ABSENT │ │ │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ rule: "index no longer public before dependents removed" + │ │ rule: "index no longer public before dependents" │ │ │ ├── • 2 elements transitioning toward PUBLIC │ │ │ @@ -290,21 +298,31 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j; │ │ │ ├── • SameStagePrecedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} │ │ │ │ rule: "primary index swap" │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} - │ │ │ rule: "index named right before index becomes public" + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ rule: "index named right before index becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ │ │ └── • IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} │ │ │ ABSENT → PUBLIC │ │ │ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} - │ │ rule: "index existence precedes index name and comment" + │ │ rule: "index existence precedes index dependents" │ │ - │ ├── • 1 element transitioning toward TRANSIENT_ABSENT + │ ├── • 2 elements transitioning toward TRANSIENT_ABSENT │ │ │ - │ │ └── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} - │ │ WRITE_ONLY → TRANSIENT_DELETE_ONLY + │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ WRITE_ONLY → TRANSIENT_DELETE_ONLY + │ │ │ + │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ PUBLIC → TRANSIENT_ABSENT + │ │ │ + │ │ └── • skip PUBLIC → TRANSIENT_ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ - │ └── • 10 Mutation operations + │ └── • 8 Mutation operations │ │ │ ├── • MakeDroppedColumnDeleteOnly │ │ ColumnID: 2 @@ -328,17 +346,6 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j; │ │ IndexID: 3 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 1 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 1 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ │ ├── • MakeAddedPrimaryIndexPublic │ │ EventBase: │ │ Authorization: @@ -357,7 +364,7 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j; │ └── • UpdateSchemaChangerJob │ IsNonCancelable: true │ JobID: 1 - │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 3 with 1 MutationType op pending + │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 3 with 3 MutationType ops pending │ ├── • Stage 2 of 3 in PostCommitNonRevertiblePhase │ │ @@ -366,19 +373,35 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j; │ │ └── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} │ │ WRITE_ONLY → DELETE_ONLY │ │ - │ └── • 3 Mutation operations + │ ├── • 1 element transitioning toward TRANSIENT_ABSENT + │ │ │ + │ │ └── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT + │ │ │ + │ │ └── • Precedence dependency from TRANSIENT_ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ rule: "dependents removed before index" + │ │ + │ └── • 5 Mutation operations │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 1 │ │ TableID: 104 │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 3 + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ IndexID: 3 + │ │ TableID: 104 + │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 104 │ │ │ └── • UpdateSchemaChangerJob │ IsNonCancelable: true │ JobID: 1 - │ RunningStatus: PostCommitNonRevertiblePhase stage 3 of 3 with 5 MutationType ops pending + │ RunningStatus: PostCommitNonRevertiblePhase stage 3 of 3 with 3 MutationType ops pending │ └── • Stage 3 of 3 in PostCommitNonRevertiblePhase │ @@ -394,14 +417,17 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j; │ │ │ rule: "dependents removed before column" │ │ │ rule: "column type removed right before column when not dropping relation" │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ rule: "dependents removed before column" + │ │ │ │ │ └── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ rule: "indexes containing columns reach absent before column" + │ │ rule: "indexes containing column reach absent before column" │ │ │ ├── • ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} │ │ │ PUBLIC → ABSENT │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 2} - │ │ rule: "column dependents removed after column no longer public" + │ │ rule: "column no longer public before dependents" │ │ │ └── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} │ │ DELETE_ONLY → ABSENT @@ -412,26 +438,10 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j; │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} │ │ rule: "dependents removed before index" │ │ - │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} - │ │ rule: "dependents removed before index" - │ │ - │ └── • SameStagePrecedence dependency from TRANSIENT_ABSENT TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} - │ rule: "temp indexes reach absent at the same time as other indexes" - │ - ├── • 1 element transitioning toward TRANSIENT_ABSENT - │ │ - │ └── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} - │ TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT + │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} + │ rule: "dependents removed before index" │ - └── • 7 Mutation operations - │ - ├── • CreateGcJobForIndex - │ IndexID: 3 - │ TableID: 104 - │ - ├── • MakeIndexAbsent - │ IndexID: 3 - │ TableID: 104 + └── • 5 Mutation operations │ ├── • CreateGcJobForIndex │ IndexID: 1 diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_basic.rollback_1_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_basic.rollback_1_of_7 index 7888bc70202c..245daf91aed5 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_basic.rollback_1_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_basic.rollback_1_of_7 @@ -13,18 +13,21 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 7; │ ├── • 4 elements transitioning toward ABSENT │ │ - │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} - │ │ PUBLIC → ABSENT - │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ BACKFILL_ONLY → ABSENT │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ rule: "dependents removed before index" │ │ + │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" + │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ │ DELETE_ONLY → ABSENT │ │ │ @@ -32,17 +35,34 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 7; │ │ rule: "dependents removed before index" │ │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ PUBLIC → ABSENT + │ │ PUBLIC → ABSENT + │ │ + │ └── • skip PUBLIC → ABSENT operations + │ rule: "skip index-column removal ops on index removal" │ ├── • 2 elements transitioning toward PUBLIC │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ WRITE_ONLY → PUBLIC + │ │ │ WRITE_ONLY → PUBLIC + │ │ │ + │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ rule: "column dependents exist before column becomes public" │ │ │ └── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ ABSENT → PUBLIC │ - └── • 11 Mutation operations + └── • 9 Mutation operations + │ + ├── • SetColumnName + │ ColumnID: 2 + │ Name: j + │ TableID: 104 │ ├── • MakeColumnPublic │ ColumnID: 2 @@ -59,21 +79,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 7; ├── • RefreshStats │ TableID: 104 │ - ├── • SetColumnName - │ ColumnID: 2 - │ Name: j - │ TableID: 104 - │ - ├── • RemoveColumnFromIndex - │ ColumnID: 1 - │ IndexID: 2 - │ TableID: 104 - │ - ├── • RemoveColumnFromIndex - │ ColumnID: 1 - │ IndexID: 3 - │ TableID: 104 - │ ├── • CreateGcJobForIndex │ IndexID: 2 │ StatementForDropJob: diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_basic.rollback_2_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_basic.rollback_2_of_7 index 2cf47a82e811..aa29a0e6d909 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_basic.rollback_2_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_basic.rollback_2_of_7 @@ -13,33 +13,57 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 2 of 7; │ │ │ ├── • 4 elements transitioning toward ABSENT │ │ │ - │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} - │ │ │ PUBLIC → ABSENT - │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ │ BACKFILL_ONLY → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} │ │ │ │ rule: "dependents removed before index" │ │ │ │ - │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ │ rule: "dependents removed before index" │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • 2 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ └── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ ABSENT → PUBLIC │ │ - │ └── • 10 Mutation operations + │ └── • 8 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 2 + │ │ Name: j + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 3 + │ │ TableID: 104 │ │ │ ├── • MakeColumnPublic │ │ ColumnID: 2 @@ -56,25 +80,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 2 of 7; │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • SetColumnName - │ │ ColumnID: 2 - │ │ Name: j - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ TableID: 104 - │ │ - │ ├── • MakeDroppedIndexDeleteOnly - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ │ ├── • CreateGcJobForIndex │ │ IndexID: 2 │ │ StatementForDropJob: diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_basic.rollback_3_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_basic.rollback_3_of_7 index 03f2f7187b28..5e9f38bdcc55 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_basic.rollback_3_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_basic.rollback_3_of_7 @@ -13,33 +13,57 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 3 of 7; │ │ │ ├── • 4 elements transitioning toward ABSENT │ │ │ - │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} - │ │ │ PUBLIC → ABSENT - │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ │ BACKFILL_ONLY → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} │ │ │ │ rule: "dependents removed before index" │ │ │ │ - │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ │ rule: "dependents removed before index" │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • 2 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ └── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ ABSENT → PUBLIC │ │ - │ └── • 10 Mutation operations + │ └── • 8 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 2 + │ │ Name: j + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 3 + │ │ TableID: 104 │ │ │ ├── • MakeColumnPublic │ │ ColumnID: 2 @@ -56,25 +80,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 3 of 7; │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • SetColumnName - │ │ ColumnID: 2 - │ │ Name: j - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ TableID: 104 - │ │ - │ ├── • MakeDroppedIndexDeleteOnly - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ │ ├── • CreateGcJobForIndex │ │ IndexID: 2 │ │ StatementForDropJob: diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_basic.rollback_4_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_basic.rollback_4_of_7 index 7953989eb80f..9181618deb1b 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_basic.rollback_4_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_basic.rollback_4_of_7 @@ -13,33 +13,57 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 7; │ │ │ ├── • 4 elements transitioning toward ABSENT │ │ │ - │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} - │ │ │ PUBLIC → ABSENT - │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ │ DELETE_ONLY → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} │ │ │ │ rule: "dependents removed before index" │ │ │ │ - │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ │ rule: "dependents removed before index" │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • 2 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ └── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ ABSENT → PUBLIC │ │ - │ └── • 10 Mutation operations + │ └── • 8 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 2 + │ │ Name: j + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 3 + │ │ TableID: 104 │ │ │ ├── • MakeColumnPublic │ │ ColumnID: 2 @@ -56,16 +80,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 7; │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • SetColumnName - │ │ ColumnID: 2 - │ │ Name: j - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ TableID: 104 - │ │ │ ├── • CreateGcJobForIndex │ │ IndexID: 2 │ │ StatementForDropJob: @@ -85,15 +99,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 7; │ │ IndexID: 2 │ │ TableID: 104 │ │ - │ ├── • MakeDroppedIndexDeleteOnly - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 104 │ │ diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_basic.rollback_5_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_basic.rollback_5_of_7 index 314267d9d222..c0c32aa8f125 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_basic.rollback_5_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_basic.rollback_5_of_7 @@ -13,27 +13,51 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 7; │ │ │ ├── • 4 elements transitioning toward ABSENT │ │ │ - │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} - │ │ │ PUBLIC → ABSENT - │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ MERGE_ONLY → DELETE_ONLY │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • 2 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ └── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ ABSENT → PUBLIC │ │ - │ └── • 9 Mutation operations + │ └── • 7 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 2 + │ │ Name: j + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 3 + │ │ TableID: 104 │ │ │ ├── • MakeColumnPublic │ │ ColumnID: 2 @@ -50,25 +74,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 7; │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • SetColumnName - │ │ ColumnID: 2 - │ │ Name: j - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ TableID: 104 - │ │ - │ ├── • MakeDroppedIndexDeleteOnly - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 2 │ │ TableID: 104 @@ -88,10 +93,10 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 7; │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ DELETE_ONLY → ABSENT │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ rule: "dependents removed before index" │ │ │ └── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_basic.rollback_6_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_basic.rollback_6_of_7 index 942a7823c028..c0998e2e2a28 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_basic.rollback_6_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_basic.rollback_6_of_7 @@ -13,27 +13,51 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 7; │ │ │ ├── • 4 elements transitioning toward ABSENT │ │ │ - │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} - │ │ │ PUBLIC → ABSENT - │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ MERGE_ONLY → DELETE_ONLY │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • 2 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ └── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ ABSENT → PUBLIC │ │ - │ └── • 9 Mutation operations + │ └── • 7 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 2 + │ │ Name: j + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 3 + │ │ TableID: 104 │ │ │ ├── • MakeColumnPublic │ │ ColumnID: 2 @@ -50,25 +74,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 7; │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • SetColumnName - │ │ ColumnID: 2 - │ │ Name: j - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ TableID: 104 - │ │ - │ ├── • MakeDroppedIndexDeleteOnly - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 2 │ │ TableID: 104 @@ -88,10 +93,10 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 7; │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ DELETE_ONLY → ABSENT │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ rule: "dependents removed before index" │ │ │ └── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_basic.rollback_7_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_basic.rollback_7_of_7 index 1fe3dee2ac06..051c4fb737e7 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_basic.rollback_7_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_basic.rollback_7_of_7 @@ -13,53 +13,48 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ │ │ ├── • 4 elements transitioning toward ABSENT │ │ │ - │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} - │ │ │ PUBLIC → ABSENT - │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • 2 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ └── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ ABSENT → PUBLIC │ │ - │ └── • 9 Mutation operations - │ │ - │ ├── • MakeColumnPublic - │ │ ColumnID: 2 - │ │ EventBase: - │ │ Authorization: - │ │ UserName: root - │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› - │ │ StatementTag: ALTER TABLE - │ │ TargetMetadata: - │ │ SourceElementID: 1 - │ │ SubWorkID: 1 - │ │ TableID: 104 - │ │ - │ ├── • RefreshStats - │ │ TableID: 104 + │ └── • 7 Mutation operations │ │ │ ├── • SetColumnName │ │ ColumnID: 2 │ │ Name: j │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ TableID: 104 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 2 │ │ TableID: 104 @@ -68,9 +63,19 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ │ IndexID: 3 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 + │ ├── • MakeColumnPublic + │ │ ColumnID: 2 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ TableID: 104 + │ │ + │ ├── • RefreshStats │ │ TableID: 104 │ │ │ ├── • SetJobStateOnDescriptor @@ -88,10 +93,10 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ ├── • PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} │ │ │ DELETE_ONLY → ABSENT │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 2} + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ rule: "dependents removed before index" │ │ │ └── • TemporaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_computed_index b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_computed_index index 0d63fe840733..997dc3ebe4d4 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_computed_index +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_computed_index @@ -19,16 +19,19 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j CASCADE; │ │ │ │ PUBLIC → ABSENT │ │ │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 2} -│ │ │ rule: "column dependents removed after column no longer public" +│ │ │ rule: "column no longer public before dependents" │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 3} -│ │ │ PUBLIC → WRITE_ONLY +│ │ │ │ PUBLIC → WRITE_ONLY +│ │ │ │ +│ │ │ └── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} +│ │ │ rule: "secondary indexes containing column as key reach write-only before column" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 3} │ │ │ │ PUBLIC → ABSENT │ │ │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 3} -│ │ │ rule: "column dependents removed after column no longer public" +│ │ │ rule: "column no longer public before dependents" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ PUBLIC → VALIDATED @@ -37,30 +40,29 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j CASCADE; │ │ │ PUBLIC → ABSENT │ │ │ │ │ └── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} -│ │ rule: "index no longer public before dependents removed" +│ │ rule: "index no longer public before dependents" │ │ -│ ├── • 3 elements transitioning toward PUBLIC -│ │ │ -│ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} -│ │ │ │ ABSENT → PUBLIC -│ │ │ │ -│ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} -│ │ │ rule: "index-column added to index after index exists" +│ ├── • 2 elements transitioning toward PUBLIC │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ ABSENT → BACKFILL_ONLY │ │ │ -│ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} +│ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ │ ABSENT → PUBLIC │ │ │ -│ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} -│ │ rule: "temp index exists before columns, partitioning, and partial" -│ │ rule: "index-column added to index after temp index exists" +│ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} +│ │ rule: "index existence precedes index dependents" │ │ -│ ├── • 1 element transitioning toward TRANSIENT_ABSENT +│ ├── • 2 elements transitioning toward TRANSIENT_ABSENT +│ │ │ +│ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} +│ │ │ ABSENT → DELETE_ONLY │ │ │ -│ │ └── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} -│ │ ABSENT → DELETE_ONLY +│ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} +│ │ │ ABSENT → PUBLIC +│ │ │ +│ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} +│ │ rule: "temp index existence precedes index dependents" │ │ │ └── • 12 Mutation operations │ │ @@ -89,32 +91,6 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j CASCADE; │ │ Name: crdb_internal_column_2_name_placeholder │ │ TableID: 104 │ │ -│ ├── • MakeDroppedColumnDeleteAndWriteOnly -│ │ ColumnID: 3 -│ │ TableID: 104 -│ │ -│ ├── • LogEvent -│ │ Element: -│ │ Column: -│ │ columnId: 3 -│ │ isInaccessible: true -│ │ pgAttributeNum: 3 -│ │ tableId: 104 -│ │ EventBase: -│ │ Authorization: -│ │ UserName: root -│ │ Statement: ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COLUMN ‹j› CASCADE -│ │ StatementTag: ALTER TABLE -│ │ TargetMetadata: -│ │ SourceElementID: 1 -│ │ SubWorkID: 1 -│ │ TargetStatus: 1 -│ │ -│ ├── • SetColumnName -│ │ ColumnID: 3 -│ │ Name: crdb_internal_column_3_name_placeholder -│ │ TableID: 104 -│ │ │ ├── • MakeDroppedNonPrimaryIndexDeleteAndWriteOnly │ │ IndexID: 2 │ │ TableID: 104 @@ -133,6 +109,11 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j CASCADE; │ │ TableID: 104 │ │ TemporaryIndexID: 4 │ │ +│ ├── • AddColumnToIndex +│ │ ColumnID: 1 +│ │ IndexID: 3 +│ │ TableID: 104 +│ │ │ ├── • MakeAddedTempIndexDeleteOnly │ │ Index: │ │ ConstraintID: 3 @@ -146,9 +127,30 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j CASCADE; │ │ IndexID: 4 │ │ TableID: 104 │ │ -│ └── • AddColumnToIndex -│ ColumnID: 1 -│ IndexID: 3 +│ ├── • MakeDroppedColumnDeleteAndWriteOnly +│ │ ColumnID: 3 +│ │ TableID: 104 +│ │ +│ ├── • LogEvent +│ │ Element: +│ │ Column: +│ │ columnId: 3 +│ │ isInaccessible: true +│ │ pgAttributeNum: 3 +│ │ tableId: 104 +│ │ EventBase: +│ │ Authorization: +│ │ UserName: root +│ │ Statement: ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COLUMN ‹j› CASCADE +│ │ StatementTag: ALTER TABLE +│ │ TargetMetadata: +│ │ SourceElementID: 1 +│ │ SubWorkID: 1 +│ │ TargetStatus: 1 +│ │ +│ └── • SetColumnName +│ ColumnID: 3 +│ Name: crdb_internal_column_3_name_placeholder │ TableID: 104 │ ├── • PreCommitPhase @@ -320,14 +322,23 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j CASCADE; │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} │ │ │ PUBLIC → WRITE_ONLY @@ -336,25 +347,28 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j CASCADE; │ │ │ │ PUBLIC → ABSENT │ │ │ │ │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ rule: "index no longer public before dependents" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 3} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ ├── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ │ │ │ rule: "index no longer public before dependents" │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ ├── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ │ │ │ rule: "index no longer public before dependents" │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ VALIDATED → DELETE_ONLY @@ -367,21 +381,31 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j CASCADE; │ │ │ ├── • SameStagePrecedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} │ │ │ │ rule: "primary index swap" │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} - │ │ │ rule: "index named right before index becomes public" + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ rule: "index named right before index becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ │ │ └── • IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} │ │ │ ABSENT → PUBLIC │ │ │ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} - │ │ rule: "index existence precedes index name and comment" + │ │ rule: "index existence precedes index dependents" │ │ - │ ├── • 1 element transitioning toward TRANSIENT_ABSENT + │ ├── • 2 elements transitioning toward TRANSIENT_ABSENT │ │ │ - │ │ └── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} - │ │ WRITE_ONLY → TRANSIENT_DELETE_ONLY + │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} + │ │ │ WRITE_ONLY → TRANSIENT_DELETE_ONLY + │ │ │ + │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ │ PUBLIC → TRANSIENT_ABSENT + │ │ │ + │ │ └── • skip PUBLIC → TRANSIENT_ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ - │ └── • 14 Mutation operations + │ └── • 10 Mutation operations │ │ │ ├── • MakeDroppedColumnDeleteOnly │ │ ColumnID: 2 @@ -409,17 +433,6 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j CASCADE; │ │ IndexID: 4 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 1 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 1 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 2 │ │ TableID: 104 @@ -436,49 +449,125 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j CASCADE; │ │ IndexID: 3 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 2 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ Kind: 1 - │ │ TableID: 104 - │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 104 │ │ │ └── • UpdateSchemaChangerJob │ IsNonCancelable: true │ JobID: 1 - │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 3 with 1 MutationType op pending + │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 3 with 7 MutationType ops pending │ ├── • Stage 2 of 3 in PostCommitNonRevertiblePhase │ │ - │ ├── • 1 element transitioning toward ABSENT + │ ├── • 4 elements transitioning toward ABSENT │ │ │ - │ │ └── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ WRITE_ONLY → DELETE_ONLY + │ │ ├── • Column:{DescID: 104, ColumnID: 3} + │ │ │ │ DELETE_ONLY → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 3} + │ │ │ │ rule: "dependents removed before column" + │ │ │ │ + │ │ │ ├── • SameStagePrecedence dependency from ABSENT ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 3} + │ │ │ │ rule: "dependents removed before column" + │ │ │ │ rule: "column type removed right before column when not dropping relation" + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ │ rule: "dependents removed before column" + │ │ │ │ + │ │ │ └── • Precedence dependency from ABSENT SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ │ │ rule: "indexes containing column reach absent before column" + │ │ │ + │ │ ├── • ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 3} + │ │ │ rule: "column no longer public before dependents" + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ + │ │ └── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_expr_idx, IndexID: 2} + │ │ rule: "dependents removed before index" │ │ - │ └── • 3 Mutation operations + │ ├── • 1 element transitioning toward TRANSIENT_ABSENT + │ │ │ + │ │ └── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} + │ │ │ TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT + │ │ │ + │ │ └── • Precedence dependency from TRANSIENT_ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ rule: "dependents removed before index" + │ │ + │ └── • 9 Mutation operations │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 1 │ │ TableID: 104 │ │ + │ ├── • LogEvent + │ │ Element: + │ │ SecondaryIndex: + │ │ indexId: 2 + │ │ tableId: 104 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COLUMN ‹j› CASCADE + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ TargetStatus: 1 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 2 + │ │ StatementForDropJob: + │ │ Statement: ALTER TABLE defaultdb.public.t DROP COLUMN j CASCADE + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ IndexID: 2 + │ │ TableID: 104 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 4 + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ IndexID: 4 + │ │ TableID: 104 + │ │ + │ ├── • MakeColumnAbsent + │ │ ColumnID: 3 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COLUMN ‹j› CASCADE + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ TableID: 104 + │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 104 │ │ │ └── • UpdateSchemaChangerJob │ IsNonCancelable: true │ JobID: 1 - │ RunningStatus: PostCommitNonRevertiblePhase stage 3 of 3 with 9 MutationType ops pending + │ RunningStatus: PostCommitNonRevertiblePhase stage 3 of 3 with 3 MutationType ops pending │ └── • Stage 3 of 3 in PostCommitNonRevertiblePhase │ - ├── • 6 elements transitioning toward ABSENT + ├── • 3 elements transitioning toward ABSENT │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} │ │ │ DELETE_ONLY → ABSENT @@ -490,80 +579,31 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j CASCADE; │ │ │ rule: "dependents removed before column" │ │ │ rule: "column type removed right before column when not dropping relation" │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ rule: "dependents removed before column" + │ │ │ │ │ └── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ rule: "indexes containing columns reach absent before column" + │ │ rule: "indexes containing column reach absent before column" │ │ │ ├── • ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} │ │ │ PUBLIC → ABSENT │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 2} - │ │ rule: "column dependents removed after column no longer public" + │ │ rule: "column no longer public before dependents" │ │ - │ ├── • Column:{DescID: 104, ColumnID: 3} - │ │ │ DELETE_ONLY → ABSENT - │ │ │ - │ │ ├── • Precedence dependency from ABSENT ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 3} - │ │ │ rule: "dependents removed before column" - │ │ │ - │ │ ├── • SameStagePrecedence dependency from ABSENT ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 3} - │ │ │ rule: "dependents removed before column" - │ │ │ rule: "column type removed right before column when not dropping relation" - │ │ │ - │ │ └── • Precedence dependency from ABSENT SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ rule: "indexes containing columns reach absent before column" - │ │ - │ ├── • ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 3} - │ │ │ PUBLIC → ABSENT - │ │ │ - │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 3} - │ │ rule: "column dependents removed after column no longer public" - │ │ - │ ├── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ │ DELETE_ONLY → ABSENT - │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1} - │ │ │ rule: "dependents removed before index" - │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} - │ │ │ rule: "dependents removed before index" - │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} - │ │ │ rule: "dependents removed before index" - │ │ │ - │ │ └── • SameStagePrecedence dependency from TRANSIENT_ABSENT TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} - │ │ rule: "temp indexes reach absent at the same time as other indexes" - │ │ - │ └── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ └── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} │ │ DELETE_ONLY → ABSENT │ │ - │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} - │ │ rule: "secondary index columns removed before removing the index" - │ │ rule: "dependents removed before index" - │ │ - │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} - │ │ rule: "secondary index columns removed before removing the index" + │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1} │ │ rule: "dependents removed before index" │ │ - │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_expr_idx, IndexID: 2} + │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} │ │ rule: "dependents removed before index" │ │ - │ └── • SameStagePrecedence dependency from TRANSIENT_ABSENT TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} - │ rule: "temp indexes reach absent at the same time as other indexes" + │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} + │ rule: "dependents removed before index" │ - ├── • 1 element transitioning toward TRANSIENT_ABSENT - │ │ - │ └── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} - │ TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT - │ - └── • 11 Mutation operations - │ - ├── • CreateGcJobForIndex - │ IndexID: 4 - │ TableID: 104 - │ - ├── • MakeIndexAbsent - │ IndexID: 4 - │ TableID: 104 + └── • 5 Mutation operations │ ├── • CreateGcJobForIndex │ IndexID: 1 @@ -583,31 +623,6 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j CASCADE; │ IndexID: 1 │ TableID: 104 │ - ├── • LogEvent - │ Element: - │ SecondaryIndex: - │ indexId: 2 - │ tableId: 104 - │ EventBase: - │ Authorization: - │ UserName: root - │ Statement: ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COLUMN ‹j› CASCADE - │ StatementTag: ALTER TABLE - │ TargetMetadata: - │ SourceElementID: 1 - │ SubWorkID: 1 - │ TargetStatus: 1 - │ - ├── • CreateGcJobForIndex - │ IndexID: 2 - │ StatementForDropJob: - │ Statement: ALTER TABLE defaultdb.public.t DROP COLUMN j CASCADE - │ TableID: 104 - │ - ├── • MakeIndexAbsent - │ IndexID: 2 - │ TableID: 104 - │ ├── • MakeColumnAbsent │ ColumnID: 2 │ EventBase: @@ -620,18 +635,6 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j CASCADE; │ SubWorkID: 1 │ TableID: 104 │ - ├── • MakeColumnAbsent - │ ColumnID: 3 - │ EventBase: - │ Authorization: - │ UserName: root - │ Statement: ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COLUMN ‹j› CASCADE - │ StatementTag: ALTER TABLE - │ TargetMetadata: - │ SourceElementID: 1 - │ SubWorkID: 1 - │ TableID: 104 - │ ├── • RemoveJobStateFromDescriptor │ DescriptorID: 104 │ JobID: 1 diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_computed_index.rollback_1_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_computed_index.rollback_1_of_7 index 75b1a2cc4c53..bde234b00922 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_computed_index.rollback_1_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_computed_index.rollback_1_of_7 @@ -13,18 +13,21 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 7; │ ├── • 4 elements transitioning toward ABSENT │ │ - │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ PUBLIC → ABSENT - │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ BACKFILL_ONLY → ABSENT │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ rule: "dependents removed before index" │ │ + │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" + │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ │ │ DELETE_ONLY → ABSENT │ │ │ @@ -32,12 +35,24 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 7; │ │ rule: "dependents removed before index" │ │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ PUBLIC → ABSENT + │ │ PUBLIC → ABSENT + │ │ + │ └── • skip PUBLIC → ABSENT operations + │ rule: "skip index-column removal ops on index removal" │ ├── • 6 elements transitioning toward PUBLIC │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ WRITE_ONLY → PUBLIC + │ │ │ WRITE_ONLY → PUBLIC + │ │ │ + │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ rule: "column dependents exist before column becomes public" │ │ │ ├── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ ABSENT → PUBLIC @@ -45,8 +60,17 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 7; │ ├── • Column:{DescID: 104, ColumnID: 3} │ │ │ WRITE_ONLY → PUBLIC │ │ │ - │ │ └── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} - │ │ rule: "ensure columns are in increasing order" + │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ │ rule: "ensure columns are in increasing order" + │ │ │ + │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 3} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 3} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ rule: "column dependents exist before column becomes public" │ │ │ ├── • ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 3} │ │ ABSENT → PUBLIC @@ -54,13 +78,35 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 7; │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ VALIDATED → PUBLIC │ │ │ + │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ + │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_expr_idx, IndexID: 2} + │ │ rule: "index dependents exist before index becomes public" │ │ rule: "index named right before index becomes public" │ │ │ └── • IndexName:{DescID: 104, Name: t_expr_idx, IndexID: 2} │ ABSENT → PUBLIC │ - └── • 16 Mutation operations + └── • 14 Mutation operations + │ + ├── • SetColumnName + │ ColumnID: 2 + │ Name: j + │ TableID: 104 + │ + ├── • SetColumnName + │ ColumnID: 3 + │ Name: crdb_internal_idx_expr + │ TableID: 104 + │ + ├── • SetIndexName + │ IndexID: 2 + │ Name: t_expr_idx + │ TableID: 104 │ ├── • MakeColumnPublic │ ColumnID: 2 @@ -77,11 +123,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 7; ├── • RefreshStats │ TableID: 104 │ - ├── • SetColumnName - │ ColumnID: 2 - │ Name: j - │ TableID: 104 - │ ├── • MakeColumnPublic │ ColumnID: 3 │ EventBase: @@ -97,26 +138,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 7; ├── • RefreshStats │ TableID: 104 │ - ├── • SetColumnName - │ ColumnID: 3 - │ Name: crdb_internal_idx_expr - │ TableID: 104 - │ - ├── • SetIndexName - │ IndexID: 2 - │ Name: t_expr_idx - │ TableID: 104 - │ - ├── • RemoveColumnFromIndex - │ ColumnID: 1 - │ IndexID: 3 - │ TableID: 104 - │ - ├── • RemoveColumnFromIndex - │ ColumnID: 1 - │ IndexID: 4 - │ TableID: 104 - │ ├── • MakeAddedSecondaryIndexPublic │ IndexID: 2 │ TableID: 104 diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_computed_index.rollback_2_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_computed_index.rollback_2_of_7 index 83357035b616..4c0bf9dbbce7 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_computed_index.rollback_2_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_computed_index.rollback_2_of_7 @@ -13,28 +13,43 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 2 of 7; │ │ │ ├── • 4 elements transitioning toward ABSENT │ │ │ - │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT - │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ │ BACKFILL_ONLY → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} │ │ │ │ rule: "dependents removed before index" │ │ │ │ - │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ │ rule: "dependents removed before index" │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • 6 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ │ ABSENT → PUBLIC @@ -42,8 +57,17 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 2 of 7; │ │ ├── • Column:{DescID: 104, ColumnID: 3} │ │ │ │ WRITE_ONLY → PUBLIC │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} - │ │ │ rule: "ensure columns are in increasing order" + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "ensure columns are in increasing order" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 3} │ │ │ ABSENT → PUBLIC @@ -51,13 +75,39 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 2 of 7; │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_expr_idx, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ └── • IndexName:{DescID: 104, Name: t_expr_idx, IndexID: 2} │ │ ABSENT → PUBLIC │ │ - │ └── • 15 Mutation operations + │ └── • 13 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 2 + │ │ Name: j + │ │ TableID: 104 + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 3 + │ │ Name: crdb_internal_idx_expr + │ │ TableID: 104 + │ │ + │ ├── • SetIndexName + │ │ IndexID: 2 + │ │ Name: t_expr_idx + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 4 + │ │ TableID: 104 │ │ │ ├── • MakeColumnPublic │ │ ColumnID: 2 @@ -74,11 +124,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 2 of 7; │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • SetColumnName - │ │ ColumnID: 2 - │ │ Name: j - │ │ TableID: 104 - │ │ │ ├── • MakeColumnPublic │ │ ColumnID: 3 │ │ EventBase: @@ -94,30 +139,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 2 of 7; │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • SetColumnName - │ │ ColumnID: 3 - │ │ Name: crdb_internal_idx_expr - │ │ TableID: 104 - │ │ - │ ├── • SetIndexName - │ │ IndexID: 2 - │ │ Name: t_expr_idx - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ - │ ├── • MakeDroppedIndexDeleteOnly - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ │ ├── • MakeAddedSecondaryIndexPublic │ │ IndexID: 2 │ │ TableID: 104 diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_computed_index.rollback_3_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_computed_index.rollback_3_of_7 index c5235fc96d3b..ff0b9d0fad27 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_computed_index.rollback_3_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_computed_index.rollback_3_of_7 @@ -13,28 +13,43 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 3 of 7; │ │ │ ├── • 4 elements transitioning toward ABSENT │ │ │ - │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT - │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ │ BACKFILL_ONLY → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} │ │ │ │ rule: "dependents removed before index" │ │ │ │ - │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ │ rule: "dependents removed before index" │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • 6 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ │ ABSENT → PUBLIC @@ -42,8 +57,17 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 3 of 7; │ │ ├── • Column:{DescID: 104, ColumnID: 3} │ │ │ │ WRITE_ONLY → PUBLIC │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} - │ │ │ rule: "ensure columns are in increasing order" + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "ensure columns are in increasing order" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 3} │ │ │ ABSENT → PUBLIC @@ -51,13 +75,39 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 3 of 7; │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_expr_idx, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ └── • IndexName:{DescID: 104, Name: t_expr_idx, IndexID: 2} │ │ ABSENT → PUBLIC │ │ - │ └── • 15 Mutation operations + │ └── • 13 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 2 + │ │ Name: j + │ │ TableID: 104 + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 3 + │ │ Name: crdb_internal_idx_expr + │ │ TableID: 104 + │ │ + │ ├── • SetIndexName + │ │ IndexID: 2 + │ │ Name: t_expr_idx + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 4 + │ │ TableID: 104 │ │ │ ├── • MakeColumnPublic │ │ ColumnID: 2 @@ -74,11 +124,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 3 of 7; │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • SetColumnName - │ │ ColumnID: 2 - │ │ Name: j - │ │ TableID: 104 - │ │ │ ├── • MakeColumnPublic │ │ ColumnID: 3 │ │ EventBase: @@ -94,30 +139,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 3 of 7; │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • SetColumnName - │ │ ColumnID: 3 - │ │ Name: crdb_internal_idx_expr - │ │ TableID: 104 - │ │ - │ ├── • SetIndexName - │ │ IndexID: 2 - │ │ Name: t_expr_idx - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ - │ ├── • MakeDroppedIndexDeleteOnly - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ │ ├── • MakeAddedSecondaryIndexPublic │ │ IndexID: 2 │ │ TableID: 104 diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_computed_index.rollback_4_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_computed_index.rollback_4_of_7 index 972b1c2d105a..aaebf618a796 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_computed_index.rollback_4_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_computed_index.rollback_4_of_7 @@ -13,28 +13,43 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 7; │ │ │ ├── • 4 elements transitioning toward ABSENT │ │ │ - │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT - │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ │ DELETE_ONLY → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} │ │ │ │ rule: "dependents removed before index" │ │ │ │ - │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ │ rule: "dependents removed before index" │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • 6 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ │ ABSENT → PUBLIC @@ -42,8 +57,17 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 7; │ │ ├── • Column:{DescID: 104, ColumnID: 3} │ │ │ │ WRITE_ONLY → PUBLIC │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} - │ │ │ rule: "ensure columns are in increasing order" + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "ensure columns are in increasing order" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 3} │ │ │ ABSENT → PUBLIC @@ -51,13 +75,39 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 7; │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_expr_idx, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ └── • IndexName:{DescID: 104, Name: t_expr_idx, IndexID: 2} │ │ ABSENT → PUBLIC │ │ - │ └── • 15 Mutation operations + │ └── • 13 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 2 + │ │ Name: j + │ │ TableID: 104 + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 3 + │ │ Name: crdb_internal_idx_expr + │ │ TableID: 104 + │ │ + │ ├── • SetIndexName + │ │ IndexID: 2 + │ │ Name: t_expr_idx + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 4 + │ │ TableID: 104 │ │ │ ├── • MakeColumnPublic │ │ ColumnID: 2 @@ -74,11 +124,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 7; │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • SetColumnName - │ │ ColumnID: 2 - │ │ Name: j - │ │ TableID: 104 - │ │ │ ├── • MakeColumnPublic │ │ ColumnID: 3 │ │ EventBase: @@ -94,19 +139,8 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 7; │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • SetColumnName - │ │ ColumnID: 3 - │ │ Name: crdb_internal_idx_expr - │ │ TableID: 104 - │ │ - │ ├── • SetIndexName + │ ├── • MakeAddedSecondaryIndexPublic │ │ IndexID: 2 - │ │ Name: t_expr_idx - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 │ │ TableID: 104 │ │ │ ├── • CreateGcJobForIndex @@ -128,19 +162,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 7; │ │ IndexID: 3 │ │ TableID: 104 │ │ - │ ├── • MakeDroppedIndexDeleteOnly - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ - │ ├── • MakeAddedSecondaryIndexPublic - │ │ IndexID: 2 - │ │ TableID: 104 - │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 104 │ │ diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_computed_index.rollback_5_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_computed_index.rollback_5_of_7 index a5f0aca91fec..f8dbece8de40 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_computed_index.rollback_5_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_computed_index.rollback_5_of_7 @@ -13,22 +13,37 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 7; │ │ │ ├── • 4 elements transitioning toward ABSENT │ │ │ - │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT - │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ MERGE_ONLY → DELETE_ONLY │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • 6 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ │ ABSENT → PUBLIC @@ -36,8 +51,17 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 7; │ │ ├── • Column:{DescID: 104, ColumnID: 3} │ │ │ │ WRITE_ONLY → PUBLIC │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} - │ │ │ rule: "ensure columns are in increasing order" + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "ensure columns are in increasing order" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 3} │ │ │ ABSENT → PUBLIC @@ -45,13 +69,39 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 7; │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_expr_idx, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ └── • IndexName:{DescID: 104, Name: t_expr_idx, IndexID: 2} │ │ ABSENT → PUBLIC │ │ - │ └── • 14 Mutation operations + │ └── • 12 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 2 + │ │ Name: j + │ │ TableID: 104 + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 3 + │ │ Name: crdb_internal_idx_expr + │ │ TableID: 104 + │ │ + │ ├── • SetIndexName + │ │ IndexID: 2 + │ │ Name: t_expr_idx + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 4 + │ │ TableID: 104 │ │ │ ├── • MakeColumnPublic │ │ ColumnID: 2 @@ -68,11 +118,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 7; │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • SetColumnName - │ │ ColumnID: 2 - │ │ Name: j - │ │ TableID: 104 - │ │ │ ├── • MakeColumnPublic │ │ ColumnID: 3 │ │ EventBase: @@ -88,30 +133,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 7; │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • SetColumnName - │ │ ColumnID: 3 - │ │ Name: crdb_internal_idx_expr - │ │ TableID: 104 - │ │ - │ ├── • SetIndexName - │ │ IndexID: 2 - │ │ Name: t_expr_idx - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ - │ ├── • MakeDroppedIndexDeleteOnly - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ │ ├── • MakeAddedSecondaryIndexPublic │ │ IndexID: 2 │ │ TableID: 104 @@ -135,10 +156,10 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 7; │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ DELETE_ONLY → ABSENT │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ rule: "dependents removed before index" │ │ │ └── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_computed_index.rollback_6_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_computed_index.rollback_6_of_7 index 43709a25f34b..93c0e45a0a2d 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_computed_index.rollback_6_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_computed_index.rollback_6_of_7 @@ -13,22 +13,37 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 7; │ │ │ ├── • 4 elements transitioning toward ABSENT │ │ │ - │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT - │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ MERGE_ONLY → DELETE_ONLY │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • 6 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ │ ABSENT → PUBLIC @@ -36,8 +51,17 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 7; │ │ ├── • Column:{DescID: 104, ColumnID: 3} │ │ │ │ WRITE_ONLY → PUBLIC │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} - │ │ │ rule: "ensure columns are in increasing order" + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "ensure columns are in increasing order" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 3} │ │ │ ABSENT → PUBLIC @@ -45,13 +69,39 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 7; │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_expr_idx, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ └── • IndexName:{DescID: 104, Name: t_expr_idx, IndexID: 2} │ │ ABSENT → PUBLIC │ │ - │ └── • 14 Mutation operations + │ └── • 12 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 2 + │ │ Name: j + │ │ TableID: 104 + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 3 + │ │ Name: crdb_internal_idx_expr + │ │ TableID: 104 + │ │ + │ ├── • SetIndexName + │ │ IndexID: 2 + │ │ Name: t_expr_idx + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 4 + │ │ TableID: 104 │ │ │ ├── • MakeColumnPublic │ │ ColumnID: 2 @@ -68,11 +118,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 7; │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • SetColumnName - │ │ ColumnID: 2 - │ │ Name: j - │ │ TableID: 104 - │ │ │ ├── • MakeColumnPublic │ │ ColumnID: 3 │ │ EventBase: @@ -88,30 +133,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 7; │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • SetColumnName - │ │ ColumnID: 3 - │ │ Name: crdb_internal_idx_expr - │ │ TableID: 104 - │ │ - │ ├── • SetIndexName - │ │ IndexID: 2 - │ │ Name: t_expr_idx - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ - │ ├── • MakeDroppedIndexDeleteOnly - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ │ ├── • MakeAddedSecondaryIndexPublic │ │ IndexID: 2 │ │ TableID: 104 @@ -135,10 +156,10 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 7; │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ DELETE_ONLY → ABSENT │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ rule: "dependents removed before index" │ │ │ └── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_computed_index.rollback_7_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_computed_index.rollback_7_of_7 index eec52df83e09..abc74e749ce7 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_computed_index.rollback_7_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_computed_index.rollback_7_of_7 @@ -13,22 +13,37 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ │ │ ├── • 4 elements transitioning toward ABSENT │ │ │ - │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT - │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • 6 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ │ ABSENT → PUBLIC @@ -36,8 +51,17 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ │ ├── • Column:{DescID: 104, ColumnID: 3} │ │ │ │ WRITE_ONLY → PUBLIC │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} - │ │ │ rule: "ensure columns are in increasing order" + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "ensure columns are in increasing order" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 3} │ │ │ ABSENT → PUBLIC @@ -45,13 +69,43 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_expr_idx, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ └── • IndexName:{DescID: 104, Name: t_expr_idx, IndexID: 2} │ │ ABSENT → PUBLIC │ │ - │ └── • 14 Mutation operations + │ └── • 12 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 2 + │ │ Name: j + │ │ TableID: 104 + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 3 + │ │ Name: crdb_internal_idx_expr + │ │ TableID: 104 + │ │ + │ ├── • SetIndexName + │ │ IndexID: 2 + │ │ Name: t_expr_idx + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 3 + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 4 + │ │ TableID: 104 │ │ │ ├── • MakeColumnPublic │ │ ColumnID: 2 @@ -68,11 +122,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • SetColumnName - │ │ ColumnID: 2 - │ │ Name: j - │ │ TableID: 104 - │ │ │ ├── • MakeColumnPublic │ │ ColumnID: 3 │ │ EventBase: @@ -88,34 +137,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • SetColumnName - │ │ ColumnID: 3 - │ │ Name: crdb_internal_idx_expr - │ │ TableID: 104 - │ │ - │ ├── • SetIndexName - │ │ IndexID: 2 - │ │ Name: t_expr_idx - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ - │ ├── • MakeDroppedIndexDeleteOnly - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ - │ ├── • MakeDroppedIndexDeleteOnly - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ │ ├── • MakeAddedSecondaryIndexPublic │ │ IndexID: 2 │ │ TableID: 104 @@ -135,10 +156,10 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ DELETE_ONLY → ABSENT │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ rule: "dependents removed before index" │ │ │ └── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_10_of_15 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_10_of_15 index 264f031c2f60..f05213ca9cc3 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_10_of_15 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_10_of_15 @@ -17,20 +17,32 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 10 of 15; │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ PUBLIC → WRITE_ONLY @@ -39,7 +51,7 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 10 of 15; │ │ │ │ PUBLIC → ABSENT │ │ │ │ │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ rule: "index no longer public before dependents" │ │ │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY @@ -47,24 +59,22 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 10 of 15; │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 5} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 4, TemporaryIndexID: 6, SourceIndexID: 3} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 4, TemporaryIndexID: 6, SourceIndexID: 3} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 4, TemporaryIndexID: 6, SourceIndexID: 3} │ │ │ │ BACKFILL_ONLY → ABSENT │ │ │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 5} - │ │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ │ rule: "dependents removed before index" │ │ │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} - │ │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ │ rule: "dependents removed before index" │ │ │ │ │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: idx, IndexID: 5} @@ -74,26 +84,60 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 10 of 15; │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 6} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 6} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • 8 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 4} │ │ │ │ WRITE_ONLY → PUBLIC │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} - │ │ │ rule: "ensure columns are in increasing order" + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "ensure columns are in increasing order" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 4} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ ├── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" │ │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} @@ -105,7 +149,17 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 10 of 15; │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} @@ -117,54 +171,13 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 10 of 15; │ │ └── • IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} │ │ ABSENT → PUBLIC │ │ - │ └── • 27 Mutation operations - │ │ - │ ├── • MakeColumnPublic - │ │ ColumnID: 2 - │ │ EventBase: - │ │ Authorization: - │ │ UserName: root - │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE - │ │ StatementTag: ALTER TABLE - │ │ TargetMetadata: - │ │ SourceElementID: 1 - │ │ SubWorkID: 1 - │ │ TableID: 104 - │ │ - │ ├── • RefreshStats - │ │ TableID: 104 - │ │ - │ ├── • MakeColumnPublic - │ │ ColumnID: 4 - │ │ EventBase: - │ │ Authorization: - │ │ UserName: root - │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE - │ │ StatementTag: ALTER TABLE - │ │ TargetMetadata: - │ │ SourceElementID: 1 - │ │ SubWorkID: 1 - │ │ TableID: 104 - │ │ - │ ├── • RefreshStats - │ │ TableID: 104 + │ └── • 19 Mutation operations │ │ │ ├── • SetIndexName │ │ IndexID: 1 │ │ Name: t_pkey │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 4 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ │ ├── • SetColumnName │ │ ColumnID: 2 │ │ Name: j @@ -197,18 +210,8 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 10 of 15; │ │ IndexID: 6 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 6 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 6 - │ │ Kind: 1 - │ │ TableID: 104 - │ │ - │ ├── • MakeAddedPrimaryIndexPublic + │ ├── • MakeColumnPublic + │ │ ColumnID: 2 │ │ EventBase: │ │ Authorization: │ │ UserName: root @@ -217,33 +220,40 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 10 of 15; │ │ TargetMetadata: │ │ SourceElementID: 1 │ │ SubWorkID: 1 - │ │ IndexID: 1 │ │ TableID: 104 │ │ - │ ├── • MakeAddedSecondaryIndexPublic - │ │ IndexID: 2 + │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 + │ ├── • MakeColumnPublic + │ │ ColumnID: 4 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 3 - │ │ Kind: 2 + │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 5 + │ ├── • MakeAddedPrimaryIndexPublic + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ IndexID: 1 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 5 - │ │ Kind: 1 + │ ├── • MakeAddedSecondaryIndexPublic + │ │ IndexID: 2 │ │ TableID: 104 │ │ │ ├── • LogEvent diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_11_of_15 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_11_of_15 index 73eb7909bcb5..d8bf9dc7912e 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_11_of_15 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_11_of_15 @@ -17,20 +17,32 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 11 of 15; │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ PUBLIC → WRITE_ONLY @@ -39,7 +51,7 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 11 of 15; │ │ │ │ PUBLIC → ABSENT │ │ │ │ │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ rule: "index no longer public before dependents" │ │ │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY @@ -47,24 +59,22 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 11 of 15; │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 5} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 4, TemporaryIndexID: 6, SourceIndexID: 3} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 4, TemporaryIndexID: 6, SourceIndexID: 3} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 4, TemporaryIndexID: 6, SourceIndexID: 3} │ │ │ │ BACKFILL_ONLY → ABSENT │ │ │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 5} - │ │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ │ rule: "dependents removed before index" │ │ │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} - │ │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ │ rule: "dependents removed before index" │ │ │ │ │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: idx, IndexID: 5} @@ -74,26 +84,60 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 11 of 15; │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 6} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 6} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • 8 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 4} │ │ │ │ WRITE_ONLY → PUBLIC │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} - │ │ │ rule: "ensure columns are in increasing order" + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "ensure columns are in increasing order" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 4} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ ├── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" │ │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} @@ -105,7 +149,17 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 11 of 15; │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} @@ -117,54 +171,13 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 11 of 15; │ │ └── • IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} │ │ ABSENT → PUBLIC │ │ - │ └── • 27 Mutation operations - │ │ - │ ├── • MakeColumnPublic - │ │ ColumnID: 2 - │ │ EventBase: - │ │ Authorization: - │ │ UserName: root - │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE - │ │ StatementTag: ALTER TABLE - │ │ TargetMetadata: - │ │ SourceElementID: 1 - │ │ SubWorkID: 1 - │ │ TableID: 104 - │ │ - │ ├── • RefreshStats - │ │ TableID: 104 - │ │ - │ ├── • MakeColumnPublic - │ │ ColumnID: 4 - │ │ EventBase: - │ │ Authorization: - │ │ UserName: root - │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE - │ │ StatementTag: ALTER TABLE - │ │ TargetMetadata: - │ │ SourceElementID: 1 - │ │ SubWorkID: 1 - │ │ TableID: 104 - │ │ - │ ├── • RefreshStats - │ │ TableID: 104 + │ └── • 19 Mutation operations │ │ │ ├── • SetIndexName │ │ IndexID: 1 │ │ Name: t_pkey │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 4 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ │ ├── • SetColumnName │ │ ColumnID: 2 │ │ Name: j @@ -197,18 +210,8 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 11 of 15; │ │ IndexID: 6 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 6 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 6 - │ │ Kind: 1 - │ │ TableID: 104 - │ │ - │ ├── • MakeAddedPrimaryIndexPublic + │ ├── • MakeColumnPublic + │ │ ColumnID: 2 │ │ EventBase: │ │ Authorization: │ │ UserName: root @@ -217,33 +220,40 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 11 of 15; │ │ TargetMetadata: │ │ SourceElementID: 1 │ │ SubWorkID: 1 - │ │ IndexID: 1 │ │ TableID: 104 │ │ - │ ├── • MakeAddedSecondaryIndexPublic - │ │ IndexID: 2 + │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 + │ ├── • MakeColumnPublic + │ │ ColumnID: 4 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 3 - │ │ Kind: 2 + │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 5 + │ ├── • MakeAddedPrimaryIndexPublic + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ IndexID: 1 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 5 - │ │ Kind: 1 + │ ├── • MakeAddedSecondaryIndexPublic + │ │ IndexID: 2 │ │ TableID: 104 │ │ │ ├── • LogEvent diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_12_of_15 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_12_of_15 index 9190a7c8d0a9..5aefa606e47b 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_12_of_15 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_12_of_15 @@ -17,20 +17,32 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 12 of 15; │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ PUBLIC → WRITE_ONLY @@ -39,7 +51,7 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 12 of 15; │ │ │ │ PUBLIC → ABSENT │ │ │ │ │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ rule: "index no longer public before dependents" │ │ │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY @@ -47,24 +59,22 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 12 of 15; │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 5} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 4, TemporaryIndexID: 6, SourceIndexID: 3} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 4, TemporaryIndexID: 6, SourceIndexID: 3} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 4, TemporaryIndexID: 6, SourceIndexID: 3} │ │ │ │ DELETE_ONLY → ABSENT │ │ │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 5} - │ │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ │ rule: "dependents removed before index" │ │ │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} - │ │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ │ rule: "dependents removed before index" │ │ │ │ │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: idx, IndexID: 5} @@ -74,26 +84,60 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 12 of 15; │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 6} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 6} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • 8 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 4} │ │ │ │ WRITE_ONLY → PUBLIC │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} - │ │ │ rule: "ensure columns are in increasing order" + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "ensure columns are in increasing order" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 4} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ ├── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" │ │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} @@ -105,7 +149,17 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 12 of 15; │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} @@ -117,54 +171,13 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 12 of 15; │ │ └── • IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} │ │ ABSENT → PUBLIC │ │ - │ └── • 27 Mutation operations - │ │ - │ ├── • MakeColumnPublic - │ │ ColumnID: 2 - │ │ EventBase: - │ │ Authorization: - │ │ UserName: root - │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE - │ │ StatementTag: ALTER TABLE - │ │ TargetMetadata: - │ │ SourceElementID: 1 - │ │ SubWorkID: 1 - │ │ TableID: 104 - │ │ - │ ├── • RefreshStats - │ │ TableID: 104 - │ │ - │ ├── • MakeColumnPublic - │ │ ColumnID: 4 - │ │ EventBase: - │ │ Authorization: - │ │ UserName: root - │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE - │ │ StatementTag: ALTER TABLE - │ │ TargetMetadata: - │ │ SourceElementID: 1 - │ │ SubWorkID: 1 - │ │ TableID: 104 - │ │ - │ ├── • RefreshStats - │ │ TableID: 104 + │ └── • 19 Mutation operations │ │ │ ├── • SetIndexName │ │ IndexID: 1 │ │ Name: t_pkey │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 4 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ │ ├── • SetColumnName │ │ ColumnID: 2 │ │ Name: j @@ -193,17 +206,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 12 of 15; │ │ IndexID: 4 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 5 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 5 - │ │ Kind: 1 - │ │ TableID: 104 - │ │ │ ├── • LogEvent │ │ Element: │ │ SecondaryIndex: @@ -240,18 +242,23 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 12 of 15; │ │ IndexID: 6 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 6 + │ ├── • MakeColumnPublic + │ │ ColumnID: 2 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 6 - │ │ Kind: 1 + │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • MakeAddedPrimaryIndexPublic + │ ├── • MakeColumnPublic + │ │ ColumnID: 4 │ │ EventBase: │ │ Authorization: │ │ UserName: root @@ -260,22 +267,25 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 12 of 15; │ │ TargetMetadata: │ │ SourceElementID: 1 │ │ SubWorkID: 1 - │ │ IndexID: 1 │ │ TableID: 104 │ │ - │ ├── • MakeAddedSecondaryIndexPublic - │ │ IndexID: 2 + │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 + │ ├── • MakeAddedPrimaryIndexPublic + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ IndexID: 1 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 3 - │ │ Kind: 2 + │ ├── • MakeAddedSecondaryIndexPublic + │ │ IndexID: 2 │ │ TableID: 104 │ │ │ ├── • SetJobStateOnDescriptor diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_13_of_15 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_13_of_15 index c80ada11802c..5cd1f482e48f 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_13_of_15 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_13_of_15 @@ -17,20 +17,32 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 13 of 15; │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ PUBLIC → WRITE_ONLY @@ -39,7 +51,7 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 13 of 15; │ │ │ │ PUBLIC → ABSENT │ │ │ │ │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ rule: "index no longer public before dependents" │ │ │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY @@ -47,14 +59,14 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 13 of 15; │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 5} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 4, TemporaryIndexID: 6, SourceIndexID: 3} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 4, TemporaryIndexID: 6, SourceIndexID: 3} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 4, TemporaryIndexID: 6, SourceIndexID: 3} │ │ │ MERGE_ONLY → DELETE_ONLY @@ -63,26 +75,60 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 13 of 15; │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 6} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 6} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • 8 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 4} │ │ │ │ WRITE_ONLY → PUBLIC │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} - │ │ │ rule: "ensure columns are in increasing order" + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "ensure columns are in increasing order" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 4} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ ├── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" │ │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} @@ -94,7 +140,17 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 13 of 15; │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} @@ -106,54 +162,13 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 13 of 15; │ │ └── • IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} │ │ ABSENT → PUBLIC │ │ - │ └── • 25 Mutation operations - │ │ - │ ├── • MakeColumnPublic - │ │ ColumnID: 2 - │ │ EventBase: - │ │ Authorization: - │ │ UserName: root - │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE - │ │ StatementTag: ALTER TABLE - │ │ TargetMetadata: - │ │ SourceElementID: 1 - │ │ SubWorkID: 1 - │ │ TableID: 104 - │ │ - │ ├── • RefreshStats - │ │ TableID: 104 - │ │ - │ ├── • MakeColumnPublic - │ │ ColumnID: 4 - │ │ EventBase: - │ │ Authorization: - │ │ UserName: root - │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE - │ │ StatementTag: ALTER TABLE - │ │ TargetMetadata: - │ │ SourceElementID: 1 - │ │ SubWorkID: 1 - │ │ TableID: 104 - │ │ - │ ├── • RefreshStats - │ │ TableID: 104 + │ └── • 17 Mutation operations │ │ │ ├── • SetIndexName │ │ IndexID: 1 │ │ Name: t_pkey │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 4 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ │ ├── • SetColumnName │ │ ColumnID: 2 │ │ Name: j @@ -186,18 +201,23 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 13 of 15; │ │ IndexID: 6 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 6 + │ ├── • MakeColumnPublic + │ │ ColumnID: 2 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 6 - │ │ Kind: 1 + │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • MakeAddedPrimaryIndexPublic + │ ├── • MakeColumnPublic + │ │ ColumnID: 4 │ │ EventBase: │ │ Authorization: │ │ UserName: root @@ -206,39 +226,31 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 13 of 15; │ │ TargetMetadata: │ │ SourceElementID: 1 │ │ SubWorkID: 1 - │ │ IndexID: 1 │ │ TableID: 104 │ │ - │ ├── • MakeAddedSecondaryIndexPublic - │ │ IndexID: 2 + │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 + │ ├── • MakeAddedPrimaryIndexPublic + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ IndexID: 1 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 3 - │ │ Kind: 2 + │ ├── • MakeAddedSecondaryIndexPublic + │ │ IndexID: 2 │ │ TableID: 104 │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 5 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 5 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 5 - │ │ Kind: 1 - │ │ TableID: 104 - │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 104 │ │ @@ -267,11 +279,9 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 13 of 15; │ │ │ │ DELETE_ONLY → ABSENT │ │ │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 5} - │ │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ │ rule: "dependents removed before index" │ │ │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} - │ │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ │ rule: "dependents removed before index" │ │ │ │ │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: idx, IndexID: 5} diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_14_of_15 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_14_of_15 index 37f5ca1cccd6..07fcbfe44afe 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_14_of_15 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_14_of_15 @@ -17,20 +17,32 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 14 of 15; │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ PUBLIC → WRITE_ONLY @@ -39,7 +51,7 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 14 of 15; │ │ │ │ PUBLIC → ABSENT │ │ │ │ │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ rule: "index no longer public before dependents" │ │ │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY @@ -47,14 +59,14 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 14 of 15; │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 5} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 4, TemporaryIndexID: 6, SourceIndexID: 3} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 4, TemporaryIndexID: 6, SourceIndexID: 3} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 4, TemporaryIndexID: 6, SourceIndexID: 3} │ │ │ MERGE_ONLY → DELETE_ONLY @@ -63,26 +75,60 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 14 of 15; │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 6} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 6} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • 8 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 4} │ │ │ │ WRITE_ONLY → PUBLIC │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} - │ │ │ rule: "ensure columns are in increasing order" + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "ensure columns are in increasing order" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 4} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ ├── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" │ │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} @@ -94,7 +140,17 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 14 of 15; │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} @@ -106,54 +162,13 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 14 of 15; │ │ └── • IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} │ │ ABSENT → PUBLIC │ │ - │ └── • 25 Mutation operations - │ │ - │ ├── • MakeColumnPublic - │ │ ColumnID: 2 - │ │ EventBase: - │ │ Authorization: - │ │ UserName: root - │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE - │ │ StatementTag: ALTER TABLE - │ │ TargetMetadata: - │ │ SourceElementID: 1 - │ │ SubWorkID: 1 - │ │ TableID: 104 - │ │ - │ ├── • RefreshStats - │ │ TableID: 104 - │ │ - │ ├── • MakeColumnPublic - │ │ ColumnID: 4 - │ │ EventBase: - │ │ Authorization: - │ │ UserName: root - │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE - │ │ StatementTag: ALTER TABLE - │ │ TargetMetadata: - │ │ SourceElementID: 1 - │ │ SubWorkID: 1 - │ │ TableID: 104 - │ │ - │ ├── • RefreshStats - │ │ TableID: 104 + │ └── • 17 Mutation operations │ │ │ ├── • SetIndexName │ │ IndexID: 1 │ │ Name: t_pkey │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 4 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ │ ├── • SetColumnName │ │ ColumnID: 2 │ │ Name: j @@ -186,18 +201,23 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 14 of 15; │ │ IndexID: 6 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 6 + │ ├── • MakeColumnPublic + │ │ ColumnID: 2 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 6 - │ │ Kind: 1 + │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • MakeAddedPrimaryIndexPublic + │ ├── • MakeColumnPublic + │ │ ColumnID: 4 │ │ EventBase: │ │ Authorization: │ │ UserName: root @@ -206,39 +226,31 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 14 of 15; │ │ TargetMetadata: │ │ SourceElementID: 1 │ │ SubWorkID: 1 - │ │ IndexID: 1 │ │ TableID: 104 │ │ - │ ├── • MakeAddedSecondaryIndexPublic - │ │ IndexID: 2 + │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 + │ ├── • MakeAddedPrimaryIndexPublic + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ IndexID: 1 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 3 - │ │ Kind: 2 + │ ├── • MakeAddedSecondaryIndexPublic + │ │ IndexID: 2 │ │ TableID: 104 │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 5 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 5 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 5 - │ │ Kind: 1 - │ │ TableID: 104 - │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 104 │ │ @@ -267,11 +279,9 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 14 of 15; │ │ │ │ DELETE_ONLY → ABSENT │ │ │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 5} - │ │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ │ rule: "dependents removed before index" │ │ │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} - │ │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ │ rule: "dependents removed before index" │ │ │ │ │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: idx, IndexID: 5} diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_15_of_15 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_15_of_15 index d2fbdd7c574f..31fd31cda1e1 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_15_of_15 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_15_of_15 @@ -17,20 +17,32 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 15 of 15; │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ PUBLIC → WRITE_ONLY @@ -39,7 +51,7 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 15 of 15; │ │ │ │ PUBLIC → ABSENT │ │ │ │ │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ rule: "index no longer public before dependents" │ │ │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY @@ -47,14 +59,14 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 15 of 15; │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 5} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 4, TemporaryIndexID: 6, SourceIndexID: 3} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 4, TemporaryIndexID: 6, SourceIndexID: 3} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 4, TemporaryIndexID: 6, SourceIndexID: 3} │ │ │ WRITE_ONLY → DELETE_ONLY @@ -63,26 +75,60 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 15 of 15; │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 6} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 6} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • 8 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 4} │ │ │ │ WRITE_ONLY → PUBLIC │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} - │ │ │ rule: "ensure columns are in increasing order" + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "ensure columns are in increasing order" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 4} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ ├── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" │ │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} @@ -94,7 +140,17 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 15 of 15; │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} @@ -106,54 +162,13 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 15 of 15; │ │ └── • IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} │ │ ABSENT → PUBLIC │ │ - │ └── • 25 Mutation operations - │ │ - │ ├── • MakeColumnPublic - │ │ ColumnID: 2 - │ │ EventBase: - │ │ Authorization: - │ │ UserName: root - │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE - │ │ StatementTag: ALTER TABLE - │ │ TargetMetadata: - │ │ SourceElementID: 1 - │ │ SubWorkID: 1 - │ │ TableID: 104 - │ │ - │ ├── • RefreshStats - │ │ TableID: 104 - │ │ - │ ├── • MakeColumnPublic - │ │ ColumnID: 4 - │ │ EventBase: - │ │ Authorization: - │ │ UserName: root - │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE - │ │ StatementTag: ALTER TABLE - │ │ TargetMetadata: - │ │ SourceElementID: 1 - │ │ SubWorkID: 1 - │ │ TableID: 104 - │ │ - │ ├── • RefreshStats - │ │ TableID: 104 + │ └── • 17 Mutation operations │ │ │ ├── • SetIndexName │ │ IndexID: 1 │ │ Name: t_pkey │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 4 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ │ ├── • SetColumnName │ │ ColumnID: 2 │ │ Name: j @@ -190,18 +205,8 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 15 of 15; │ │ IndexID: 6 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 6 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 6 - │ │ Kind: 1 - │ │ TableID: 104 - │ │ - │ ├── • MakeAddedPrimaryIndexPublic + │ ├── • MakeColumnPublic + │ │ ColumnID: 2 │ │ EventBase: │ │ Authorization: │ │ UserName: root @@ -210,33 +215,40 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 15 of 15; │ │ TargetMetadata: │ │ SourceElementID: 1 │ │ SubWorkID: 1 - │ │ IndexID: 1 │ │ TableID: 104 │ │ - │ ├── • MakeAddedSecondaryIndexPublic - │ │ IndexID: 2 + │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 + │ ├── • MakeColumnPublic + │ │ ColumnID: 4 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 3 - │ │ Kind: 2 + │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 5 + │ ├── • MakeAddedPrimaryIndexPublic + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ IndexID: 1 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 5 - │ │ Kind: 1 + │ ├── • MakeAddedSecondaryIndexPublic + │ │ IndexID: 2 │ │ TableID: 104 │ │ │ ├── • SetJobStateOnDescriptor @@ -267,11 +279,9 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 15 of 15; │ │ │ │ DELETE_ONLY → ABSENT │ │ │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 5} - │ │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ │ rule: "dependents removed before index" │ │ │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} - │ │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ │ rule: "dependents removed before index" │ │ │ │ │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: idx, IndexID: 5} diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_1_of_15 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_1_of_15 index 67bcf9ce4c0e..00caae4639f3 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_1_of_15 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_1_of_15 @@ -15,16 +15,28 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 15; ├── • 6 elements transitioning toward ABSENT │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ BACKFILL_ONLY → ABSENT @@ -50,18 +62,46 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 15; ├── • 6 elements transitioning toward PUBLIC │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ WRITE_ONLY → PUBLIC + │ │ │ WRITE_ONLY → PUBLIC + │ │ │ + │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ rule: "column dependents exist before column becomes public" │ │ │ ├── • Column:{DescID: 104, ColumnID: 4} │ │ │ WRITE_ONLY → PUBLIC │ │ │ - │ │ └── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} - │ │ rule: "ensure columns are in increasing order" + │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ │ rule: "ensure columns are in increasing order" + │ │ │ + │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 4} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} + │ │ rule: "column dependents exist before column becomes public" │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ VALIDATED → PUBLIC │ │ │ + │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ + │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ + │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} + │ │ rule: "index dependents exist before index becomes public" │ │ rule: "index named right before index becomes public" │ │ │ ├── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} @@ -73,7 +113,30 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 15; │ └── • IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} │ ABSENT → PUBLIC │ - └── • 18 Mutation operations + └── • 14 Mutation operations + │ + ├── • SetColumnName + │ ColumnID: 2 + │ Name: j + │ TableID: 104 + │ + ├── • SetColumnName + │ ColumnID: 4 + │ Name: crdb_internal_idx_expr + │ TableID: 104 + │ + ├── • SetIndexName + │ IndexID: 2 + │ Name: t_expr_k_idx + │ TableID: 104 + │ + ├── • CreateGcJobForIndex + │ IndexID: 4 + │ TableID: 104 + │ + ├── • MakeIndexAbsent + │ IndexID: 4 + │ TableID: 104 │ ├── • MakeColumnPublic │ ColumnID: 2 @@ -105,51 +168,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 15; ├── • RefreshStats │ TableID: 104 │ - ├── • RemoveColumnFromIndex - │ ColumnID: 1 - │ IndexID: 3 - │ TableID: 104 - │ - ├── • RemoveColumnFromIndex - │ ColumnID: 3 - │ IndexID: 3 - │ Kind: 2 - │ TableID: 104 - │ - ├── • RemoveColumnFromIndex - │ ColumnID: 1 - │ IndexID: 4 - │ TableID: 104 - │ - ├── • RemoveColumnFromIndex - │ ColumnID: 3 - │ IndexID: 4 - │ Kind: 2 - │ TableID: 104 - │ - ├── • SetColumnName - │ ColumnID: 2 - │ Name: j - │ TableID: 104 - │ - ├── • SetColumnName - │ ColumnID: 4 - │ Name: crdb_internal_idx_expr - │ TableID: 104 - │ - ├── • SetIndexName - │ IndexID: 2 - │ Name: t_expr_k_idx - │ TableID: 104 - │ - ├── • CreateGcJobForIndex - │ IndexID: 4 - │ TableID: 104 - │ - ├── • MakeIndexAbsent - │ IndexID: 4 - │ TableID: 104 - │ ├── • MakeAddedSecondaryIndexPublic │ IndexID: 2 │ TableID: 104 diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_2_of_15 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_2_of_15 index 11e649928b2a..9341293d4412 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_2_of_15 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_2_of_15 @@ -15,16 +15,28 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 2 of 15; │ ├── • 6 elements transitioning toward ABSENT │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ │ BACKFILL_ONLY → ABSENT @@ -44,18 +56,46 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 2 of 15; │ ├── • 6 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 4} │ │ │ │ WRITE_ONLY → PUBLIC │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} - │ │ │ rule: "ensure columns are in increasing order" + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "ensure columns are in increasing order" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 4} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} @@ -67,7 +107,26 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 2 of 15; │ │ └── • IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} │ │ ABSENT → PUBLIC │ │ - │ └── • 17 Mutation operations + │ └── • 13 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 2 + │ │ Name: j + │ │ TableID: 104 + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 4 + │ │ Name: crdb_internal_idx_expr + │ │ TableID: 104 + │ │ + │ ├── • SetIndexName + │ │ IndexID: 2 + │ │ Name: t_expr_k_idx + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 4 + │ │ TableID: 104 │ │ │ ├── • MakeColumnPublic │ │ ColumnID: 2 @@ -99,47 +158,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 2 of 15; │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 3 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 4 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ - │ ├── • SetColumnName - │ │ ColumnID: 2 - │ │ Name: j - │ │ TableID: 104 - │ │ - │ ├── • SetColumnName - │ │ ColumnID: 4 - │ │ Name: crdb_internal_idx_expr - │ │ TableID: 104 - │ │ - │ ├── • SetIndexName - │ │ IndexID: 2 - │ │ Name: t_expr_k_idx - │ │ TableID: 104 - │ │ - │ ├── • MakeDroppedIndexDeleteOnly - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ │ ├── • MakeAddedSecondaryIndexPublic │ │ IndexID: 2 │ │ TableID: 104 diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_3_of_15 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_3_of_15 index b54cc72db84d..16274a9e8a14 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_3_of_15 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_3_of_15 @@ -15,16 +15,28 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 3 of 15; │ ├── • 6 elements transitioning toward ABSENT │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ │ BACKFILL_ONLY → ABSENT @@ -44,18 +56,46 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 3 of 15; │ ├── • 6 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 4} │ │ │ │ WRITE_ONLY → PUBLIC │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} - │ │ │ rule: "ensure columns are in increasing order" + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "ensure columns are in increasing order" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 4} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} @@ -67,7 +107,26 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 3 of 15; │ │ └── • IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} │ │ ABSENT → PUBLIC │ │ - │ └── • 17 Mutation operations + │ └── • 13 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 2 + │ │ Name: j + │ │ TableID: 104 + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 4 + │ │ Name: crdb_internal_idx_expr + │ │ TableID: 104 + │ │ + │ ├── • SetIndexName + │ │ IndexID: 2 + │ │ Name: t_expr_k_idx + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 4 + │ │ TableID: 104 │ │ │ ├── • MakeColumnPublic │ │ ColumnID: 2 @@ -99,47 +158,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 3 of 15; │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 3 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 4 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ - │ ├── • SetColumnName - │ │ ColumnID: 2 - │ │ Name: j - │ │ TableID: 104 - │ │ - │ ├── • SetColumnName - │ │ ColumnID: 4 - │ │ Name: crdb_internal_idx_expr - │ │ TableID: 104 - │ │ - │ ├── • SetIndexName - │ │ IndexID: 2 - │ │ Name: t_expr_k_idx - │ │ TableID: 104 - │ │ - │ ├── • MakeDroppedIndexDeleteOnly - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ │ ├── • MakeAddedSecondaryIndexPublic │ │ IndexID: 2 │ │ TableID: 104 diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_4_of_15 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_4_of_15 index fb15f940fc91..9d1dddf77714 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_4_of_15 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_4_of_15 @@ -15,16 +15,28 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 15; │ ├── • 6 elements transitioning toward ABSENT │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ │ DELETE_ONLY → ABSENT @@ -44,18 +56,46 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 15; │ ├── • 6 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 4} │ │ │ │ WRITE_ONLY → PUBLIC │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} - │ │ │ rule: "ensure columns are in increasing order" + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "ensure columns are in increasing order" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 4} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} @@ -67,10 +107,31 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 15; │ │ └── • IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} │ │ ABSENT → PUBLIC │ │ - │ └── • 17 Mutation operations + │ └── • 13 Mutation operations │ │ - │ ├── • MakeColumnPublic + │ ├── • SetColumnName │ │ ColumnID: 2 + │ │ Name: j + │ │ TableID: 104 + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 4 + │ │ Name: crdb_internal_idx_expr + │ │ TableID: 104 + │ │ + │ ├── • SetIndexName + │ │ IndexID: 2 + │ │ Name: t_expr_k_idx + │ │ TableID: 104 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 3 + │ │ StatementForDropJob: + │ │ Rollback: true + │ │ Statement: ALTER TABLE defaultdb.public.t DROP COLUMN j CASCADE + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent │ │ EventBase: │ │ Authorization: │ │ UserName: root @@ -79,13 +140,15 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 15; │ │ TargetMetadata: │ │ SourceElementID: 1 │ │ SubWorkID: 1 + │ │ IndexID: 3 │ │ TableID: 104 │ │ - │ ├── • RefreshStats + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 4 │ │ TableID: 104 │ │ │ ├── • MakeColumnPublic - │ │ ColumnID: 4 + │ │ ColumnID: 2 │ │ EventBase: │ │ Authorization: │ │ UserName: root @@ -99,51 +162,8 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 15; │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 3 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 4 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ - │ ├── • SetColumnName - │ │ ColumnID: 2 - │ │ Name: j - │ │ TableID: 104 - │ │ - │ ├── • SetColumnName + │ ├── • MakeColumnPublic │ │ ColumnID: 4 - │ │ Name: crdb_internal_idx_expr - │ │ TableID: 104 - │ │ - │ ├── • SetIndexName - │ │ IndexID: 2 - │ │ Name: t_expr_k_idx - │ │ TableID: 104 - │ │ - │ ├── • CreateGcJobForIndex - │ │ IndexID: 3 - │ │ StatementForDropJob: - │ │ Rollback: true - │ │ Statement: ALTER TABLE defaultdb.public.t DROP COLUMN j CASCADE - │ │ TableID: 104 - │ │ - │ ├── • MakeIndexAbsent │ │ EventBase: │ │ Authorization: │ │ UserName: root @@ -152,11 +172,9 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 15; │ │ TargetMetadata: │ │ SourceElementID: 1 │ │ SubWorkID: 1 - │ │ IndexID: 3 │ │ TableID: 104 │ │ - │ ├── • MakeDroppedIndexDeleteOnly - │ │ IndexID: 4 + │ ├── • RefreshStats │ │ TableID: 104 │ │ │ ├── • MakeAddedSecondaryIndexPublic diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_5_of_15 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_5_of_15 index b863f0f7073e..0b9deb3eef5e 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_5_of_15 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_5_of_15 @@ -15,16 +15,28 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 15; │ ├── • 6 elements transitioning toward ABSENT │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ MERGE_ONLY → DELETE_ONLY @@ -35,18 +47,46 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 15; │ ├── • 6 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 4} │ │ │ │ WRITE_ONLY → PUBLIC │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} - │ │ │ rule: "ensure columns are in increasing order" + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "ensure columns are in increasing order" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 4} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} @@ -58,7 +98,26 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 15; │ │ └── • IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} │ │ ABSENT → PUBLIC │ │ - │ └── • 16 Mutation operations + │ └── • 12 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 2 + │ │ Name: j + │ │ TableID: 104 + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 4 + │ │ Name: crdb_internal_idx_expr + │ │ TableID: 104 + │ │ + │ ├── • SetIndexName + │ │ IndexID: 2 + │ │ Name: t_expr_k_idx + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 4 + │ │ TableID: 104 │ │ │ ├── • MakeColumnPublic │ │ ColumnID: 2 @@ -90,47 +149,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 15; │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 3 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 4 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ - │ ├── • SetColumnName - │ │ ColumnID: 2 - │ │ Name: j - │ │ TableID: 104 - │ │ - │ ├── • SetColumnName - │ │ ColumnID: 4 - │ │ Name: crdb_internal_idx_expr - │ │ TableID: 104 - │ │ - │ ├── • SetIndexName - │ │ IndexID: 2 - │ │ Name: t_expr_k_idx - │ │ TableID: 104 - │ │ - │ ├── • MakeDroppedIndexDeleteOnly - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ │ ├── • MakeAddedSecondaryIndexPublic │ │ IndexID: 2 │ │ TableID: 104 diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_6_of_15 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_6_of_15 index 0b3385b53a36..298708bb6371 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_6_of_15 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_6_of_15 @@ -15,16 +15,28 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 15; │ ├── • 6 elements transitioning toward ABSENT │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ MERGE_ONLY → DELETE_ONLY @@ -35,18 +47,46 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 15; │ ├── • 6 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 4} │ │ │ │ WRITE_ONLY → PUBLIC │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} - │ │ │ rule: "ensure columns are in increasing order" + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "ensure columns are in increasing order" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 4} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} @@ -58,7 +98,26 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 15; │ │ └── • IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} │ │ ABSENT → PUBLIC │ │ - │ └── • 16 Mutation operations + │ └── • 12 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 2 + │ │ Name: j + │ │ TableID: 104 + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 4 + │ │ Name: crdb_internal_idx_expr + │ │ TableID: 104 + │ │ + │ ├── • SetIndexName + │ │ IndexID: 2 + │ │ Name: t_expr_k_idx + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 4 + │ │ TableID: 104 │ │ │ ├── • MakeColumnPublic │ │ ColumnID: 2 @@ -90,47 +149,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 15; │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 3 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 4 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ - │ ├── • SetColumnName - │ │ ColumnID: 2 - │ │ Name: j - │ │ TableID: 104 - │ │ - │ ├── • SetColumnName - │ │ ColumnID: 4 - │ │ Name: crdb_internal_idx_expr - │ │ TableID: 104 - │ │ - │ ├── • SetIndexName - │ │ IndexID: 2 - │ │ Name: t_expr_k_idx - │ │ TableID: 104 - │ │ - │ ├── • MakeDroppedIndexDeleteOnly - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ │ ├── • MakeAddedSecondaryIndexPublic │ │ IndexID: 2 │ │ TableID: 104 diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_7_of_15 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_7_of_15 index 6468f442f99c..a2c1c6d9192c 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_7_of_15 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_7_of_15 @@ -15,16 +15,28 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 15; │ ├── • 6 elements transitioning toward ABSENT │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY @@ -35,18 +47,46 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 15; │ ├── • 6 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 4} │ │ │ │ WRITE_ONLY → PUBLIC │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} - │ │ │ rule: "ensure columns are in increasing order" + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "ensure columns are in increasing order" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 4} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} @@ -58,7 +98,30 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 15; │ │ └── • IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} │ │ ABSENT → PUBLIC │ │ - │ └── • 16 Mutation operations + │ └── • 12 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 2 + │ │ Name: j + │ │ TableID: 104 + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 4 + │ │ Name: crdb_internal_idx_expr + │ │ TableID: 104 + │ │ + │ ├── • SetIndexName + │ │ IndexID: 2 + │ │ Name: t_expr_k_idx + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 3 + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 4 + │ │ TableID: 104 │ │ │ ├── • MakeColumnPublic │ │ ColumnID: 2 @@ -90,51 +153,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 15; │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 3 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 4 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ - │ ├── • SetColumnName - │ │ ColumnID: 2 - │ │ Name: j - │ │ TableID: 104 - │ │ - │ ├── • SetColumnName - │ │ ColumnID: 4 - │ │ Name: crdb_internal_idx_expr - │ │ TableID: 104 - │ │ - │ ├── • SetIndexName - │ │ IndexID: 2 - │ │ Name: t_expr_k_idx - │ │ TableID: 104 - │ │ - │ ├── • MakeDroppedIndexDeleteOnly - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ - │ ├── • MakeDroppedIndexDeleteOnly - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ │ ├── • MakeAddedSecondaryIndexPublic │ │ IndexID: 2 │ │ TableID: 104 diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_8_of_15 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_8_of_15 index 3033a52ae2d1..81a068e0f6be 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_8_of_15 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_8_of_15 @@ -15,16 +15,28 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 8 of 15; │ ├── • 6 elements transitioning toward ABSENT │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY @@ -35,18 +47,46 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 8 of 15; │ ├── • 6 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 4} │ │ │ │ WRITE_ONLY → PUBLIC │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} - │ │ │ rule: "ensure columns are in increasing order" + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "ensure columns are in increasing order" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 4} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} @@ -58,7 +98,30 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 8 of 15; │ │ └── • IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} │ │ ABSENT → PUBLIC │ │ - │ └── • 16 Mutation operations + │ └── • 12 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 2 + │ │ Name: j + │ │ TableID: 104 + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 4 + │ │ Name: crdb_internal_idx_expr + │ │ TableID: 104 + │ │ + │ ├── • SetIndexName + │ │ IndexID: 2 + │ │ Name: t_expr_k_idx + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 3 + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 4 + │ │ TableID: 104 │ │ │ ├── • MakeColumnPublic │ │ ColumnID: 2 @@ -90,51 +153,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 8 of 15; │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 3 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 4 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ - │ ├── • SetColumnName - │ │ ColumnID: 2 - │ │ Name: j - │ │ TableID: 104 - │ │ - │ ├── • SetColumnName - │ │ ColumnID: 4 - │ │ Name: crdb_internal_idx_expr - │ │ TableID: 104 - │ │ - │ ├── • SetIndexName - │ │ IndexID: 2 - │ │ Name: t_expr_k_idx - │ │ TableID: 104 - │ │ - │ ├── • MakeDroppedIndexDeleteOnly - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ - │ ├── • MakeDroppedIndexDeleteOnly - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ │ ├── • MakeAddedSecondaryIndexPublic │ │ IndexID: 2 │ │ TableID: 104 diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_9_of_15 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_9_of_15 index e0e810ee23db..8116a9c38a85 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_9_of_15 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.rollback_9_of_15 @@ -17,20 +17,32 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 9 of 15; │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ PUBLIC → WRITE_ONLY @@ -39,7 +51,7 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 9 of 15; │ │ │ │ PUBLIC → ABSENT │ │ │ │ │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ rule: "index no longer public before dependents" │ │ │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY @@ -47,24 +59,22 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 9 of 15; │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 5} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 4, TemporaryIndexID: 6, SourceIndexID: 3} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 4, TemporaryIndexID: 6, SourceIndexID: 3} - │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 4, TemporaryIndexID: 6, SourceIndexID: 3} │ │ │ │ BACKFILL_ONLY → ABSENT │ │ │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 5} - │ │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ │ rule: "dependents removed before index" │ │ │ │ │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} - │ │ │ │ rule: "secondary index columns removed before removing the index" │ │ │ │ rule: "dependents removed before index" │ │ │ │ │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: idx, IndexID: 5} @@ -80,26 +90,60 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 9 of 15; │ │ │ rule: "dependents removed before index" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 6} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 6} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • 8 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 4} │ │ │ │ WRITE_ONLY → PUBLIC │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} - │ │ │ rule: "ensure columns are in increasing order" + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "ensure columns are in increasing order" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 4} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ ├── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} + │ │ │ │ rule: "index dependents exist before index becomes public" │ │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} @@ -111,7 +155,17 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 9 of 15; │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} @@ -123,54 +177,13 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 9 of 15; │ │ └── • IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} │ │ ABSENT → PUBLIC │ │ - │ └── • 28 Mutation operations - │ │ - │ ├── • MakeColumnPublic - │ │ ColumnID: 2 - │ │ EventBase: - │ │ Authorization: - │ │ UserName: root - │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE - │ │ StatementTag: ALTER TABLE - │ │ TargetMetadata: - │ │ SourceElementID: 1 - │ │ SubWorkID: 1 - │ │ TableID: 104 - │ │ - │ ├── • RefreshStats - │ │ TableID: 104 - │ │ - │ ├── • MakeColumnPublic - │ │ ColumnID: 4 - │ │ EventBase: - │ │ Authorization: - │ │ UserName: root - │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE - │ │ StatementTag: ALTER TABLE - │ │ TargetMetadata: - │ │ SourceElementID: 1 - │ │ SubWorkID: 1 - │ │ TableID: 104 - │ │ - │ ├── • RefreshStats - │ │ TableID: 104 + │ └── • 20 Mutation operations │ │ │ ├── • SetIndexName │ │ IndexID: 1 │ │ Name: t_pkey │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 4 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ │ ├── • SetColumnName │ │ ColumnID: 2 │ │ Name: j @@ -199,18 +212,8 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 9 of 15; │ │ IndexID: 4 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 6 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 6 - │ │ Kind: 1 - │ │ TableID: 104 - │ │ - │ ├── • MakeAddedPrimaryIndexPublic + │ ├── • MakeColumnPublic + │ │ ColumnID: 2 │ │ EventBase: │ │ Authorization: │ │ UserName: root @@ -219,33 +222,40 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 9 of 15; │ │ TargetMetadata: │ │ SourceElementID: 1 │ │ SubWorkID: 1 - │ │ IndexID: 1 │ │ TableID: 104 │ │ - │ ├── • MakeAddedSecondaryIndexPublic - │ │ IndexID: 2 + │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 + │ ├── • MakeColumnPublic + │ │ ColumnID: 4 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 3 - │ │ Kind: 2 + │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 5 + │ ├── • MakeAddedPrimaryIndexPublic + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ IndexID: 1 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 5 - │ │ Kind: 1 + │ ├── • MakeAddedSecondaryIndexPublic + │ │ IndexID: 2 │ │ TableID: 104 │ │ │ ├── • LogEvent diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.statement_1_of_2 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.statement_1_of_2 index cfdfc1ec1c1e..f35c6c887d52 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.statement_1_of_2 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.statement_1_of_2 @@ -19,16 +19,19 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j CASCADE; │ │ │ │ PUBLIC → ABSENT │ │ │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 2} -│ │ │ rule: "column dependents removed after column no longer public" +│ │ │ rule: "column no longer public before dependents" │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 4} -│ │ │ PUBLIC → WRITE_ONLY +│ │ │ │ PUBLIC → WRITE_ONLY +│ │ │ │ +│ │ │ └── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} +│ │ │ rule: "secondary indexes containing column as key reach write-only before column" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} │ │ │ │ PUBLIC → ABSENT │ │ │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 4} -│ │ │ rule: "column dependents removed after column no longer public" +│ │ │ rule: "column no longer public before dependents" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ PUBLIC → VALIDATED @@ -37,43 +40,41 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j CASCADE; │ │ │ PUBLIC → ABSENT │ │ │ │ │ └── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} -│ │ rule: "index no longer public before dependents removed" +│ │ rule: "index no longer public before dependents" │ │ -│ ├── • 5 elements transitioning toward PUBLIC +│ ├── • 3 elements transitioning toward PUBLIC +│ │ │ +│ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} +│ │ │ ABSENT → BACKFILL_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ │ │ ABSENT → PUBLIC │ │ │ │ │ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} -│ │ │ rule: "index-column added to index after index exists" +│ │ │ rule: "index existence precedes index dependents" │ │ │ -│ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} -│ │ │ │ ABSENT → PUBLIC -│ │ │ │ -│ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} -│ │ │ rule: "index-column added to index after index exists" +│ │ └── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} +│ │ │ ABSENT → PUBLIC +│ │ │ +│ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} +│ │ rule: "index existence precedes index dependents" +│ │ +│ ├── • 3 elements transitioning toward TRANSIENT_ABSENT │ │ │ -│ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} -│ │ │ ABSENT → BACKFILL_ONLY +│ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} +│ │ │ ABSENT → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} │ │ │ │ ABSENT → PUBLIC │ │ │ │ │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} -│ │ │ rule: "temp index exists before columns, partitioning, and partial" -│ │ │ rule: "index-column added to index after temp index exists" +│ │ │ rule: "temp index existence precedes index dependents" │ │ │ │ │ └── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4} │ │ │ ABSENT → PUBLIC │ │ │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} -│ │ rule: "temp index exists before columns, partitioning, and partial" -│ │ rule: "index-column added to index after temp index exists" -│ │ -│ ├── • 1 element transitioning toward TRANSIENT_ABSENT -│ │ │ -│ │ └── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} -│ │ ABSENT → DELETE_ONLY +│ │ rule: "temp index existence precedes index dependents" │ │ │ └── • 14 Mutation operations │ │ @@ -102,32 +103,6 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j CASCADE; │ │ Name: crdb_internal_column_2_name_placeholder │ │ TableID: 104 │ │ -│ ├── • MakeDroppedColumnDeleteAndWriteOnly -│ │ ColumnID: 4 -│ │ TableID: 104 -│ │ -│ ├── • LogEvent -│ │ Element: -│ │ Column: -│ │ columnId: 4 -│ │ isInaccessible: true -│ │ pgAttributeNum: 4 -│ │ tableId: 104 -│ │ EventBase: -│ │ Authorization: -│ │ UserName: root -│ │ Statement: ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COLUMN ‹j› CASCADE -│ │ StatementTag: ALTER TABLE -│ │ TargetMetadata: -│ │ SourceElementID: 1 -│ │ SubWorkID: 1 -│ │ TargetStatus: 1 -│ │ -│ ├── • SetColumnName -│ │ ColumnID: 4 -│ │ Name: crdb_internal_column_4_name_placeholder -│ │ TableID: 104 -│ │ │ ├── • MakeDroppedNonPrimaryIndexDeleteAndWriteOnly │ │ IndexID: 2 │ │ TableID: 104 @@ -146,6 +121,17 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j CASCADE; │ │ TableID: 104 │ │ TemporaryIndexID: 4 │ │ +│ ├── • AddColumnToIndex +│ │ ColumnID: 1 +│ │ IndexID: 3 +│ │ TableID: 104 +│ │ +│ ├── • AddColumnToIndex +│ │ ColumnID: 3 +│ │ IndexID: 3 +│ │ Kind: 2 +│ │ TableID: 104 +│ │ │ ├── • MakeAddedTempIndexDeleteOnly │ │ Index: │ │ ConstraintID: 3 @@ -165,15 +151,30 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j CASCADE; │ │ Kind: 2 │ │ TableID: 104 │ │ -│ ├── • AddColumnToIndex -│ │ ColumnID: 1 -│ │ IndexID: 3 +│ ├── • MakeDroppedColumnDeleteAndWriteOnly +│ │ ColumnID: 4 │ │ TableID: 104 │ │ -│ └── • AddColumnToIndex -│ ColumnID: 3 -│ IndexID: 3 -│ Kind: 2 +│ ├── • LogEvent +│ │ Element: +│ │ Column: +│ │ columnId: 4 +│ │ isInaccessible: true +│ │ pgAttributeNum: 4 +│ │ tableId: 104 +│ │ EventBase: +│ │ Authorization: +│ │ UserName: root +│ │ Statement: ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COLUMN ‹j› CASCADE +│ │ StatementTag: ALTER TABLE +│ │ TargetMetadata: +│ │ SourceElementID: 1 +│ │ SubWorkID: 1 +│ │ TargetStatus: 1 +│ │ +│ └── • SetColumnName +│ ColumnID: 4 +│ Name: crdb_internal_column_4_name_placeholder │ TableID: 104 │ ├── • PreCommitPhase @@ -351,20 +352,32 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j CASCADE; │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 1} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} │ │ │ PUBLIC → WRITE_ONLY @@ -373,34 +386,37 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j CASCADE; │ │ │ │ PUBLIC → ABSENT │ │ │ │ │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ rule: "index no longer public before dependents" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 4} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ ├── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ │ │ │ rule: "index no longer public before dependents" │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ ├── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ │ │ │ rule: "index no longer public before dependents" │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ ├── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ │ │ │ rule: "index no longer public before dependents" │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ VALIDATED → DELETE_ONLY @@ -413,21 +429,40 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j CASCADE; │ │ │ ├── • SameStagePrecedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} │ │ │ │ rule: "primary index swap" │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} - │ │ │ rule: "index named right before index becomes public" + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ rule: "index named right before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ │ │ └── • IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} │ │ │ ABSENT → PUBLIC │ │ │ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} - │ │ rule: "index existence precedes index name and comment" + │ │ rule: "index existence precedes index dependents" │ │ - │ ├── • 1 element transitioning toward TRANSIENT_ABSENT + │ ├── • 3 elements transitioning toward TRANSIENT_ABSENT │ │ │ - │ │ └── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} - │ │ WRITE_ONLY → TRANSIENT_DELETE_ONLY + │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} + │ │ │ WRITE_ONLY → TRANSIENT_DELETE_ONLY + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ │ │ PUBLIC → TRANSIENT_ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → TRANSIENT_ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ └── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4} + │ │ │ PUBLIC → TRANSIENT_ABSENT + │ │ │ + │ │ └── • skip PUBLIC → TRANSIENT_ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ - │ └── • 16 Mutation operations + │ └── • 10 Mutation operations │ │ │ ├── • MakeDroppedColumnDeleteOnly │ │ ColumnID: 2 @@ -455,24 +490,6 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j CASCADE; │ │ IndexID: 4 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 1 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 1 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 1 - │ │ Kind: 2 - │ │ Ordinal: 1 - │ │ TableID: 104 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 2 │ │ TableID: 104 @@ -489,55 +506,131 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j CASCADE; │ │ IndexID: 3 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 4 - │ │ IndexID: 2 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 2 - │ │ Ordinal: 1 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ Kind: 1 - │ │ TableID: 104 - │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 104 │ │ │ └── • UpdateSchemaChangerJob │ IsNonCancelable: true │ JobID: 1 - │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 3 with 1 MutationType op pending + │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 3 with 7 MutationType ops pending │ ├── • Stage 2 of 3 in PostCommitNonRevertiblePhase │ │ - │ ├── • 1 element transitioning toward ABSENT + │ ├── • 4 elements transitioning toward ABSENT │ │ │ - │ │ └── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ WRITE_ONLY → DELETE_ONLY + │ │ ├── • Column:{DescID: 104, ColumnID: 4} + │ │ │ │ DELETE_ONLY → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} + │ │ │ │ rule: "dependents removed before column" + │ │ │ │ + │ │ │ ├── • SameStagePrecedence dependency from ABSENT ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 4} + │ │ │ │ rule: "dependents removed before column" + │ │ │ │ rule: "column type removed right before column when not dropping relation" + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "dependents removed before column" + │ │ │ │ + │ │ │ └── • Precedence dependency from ABSENT SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ │ │ rule: "indexes containing column reach absent before column" + │ │ │ + │ │ ├── • ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 4} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 4} + │ │ │ rule: "column no longer public before dependents" + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ + │ │ └── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} + │ │ rule: "dependents removed before index" │ │ - │ └── • 3 Mutation operations + │ ├── • 1 element transitioning toward TRANSIENT_ABSENT + │ │ │ + │ │ └── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} + │ │ │ TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT + │ │ │ + │ │ ├── • Precedence dependency from TRANSIENT_ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from TRANSIENT_ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4} + │ │ rule: "dependents removed before index" + │ │ + │ └── • 9 Mutation operations │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 1 │ │ TableID: 104 │ │ + │ ├── • LogEvent + │ │ Element: + │ │ SecondaryIndex: + │ │ indexId: 2 + │ │ tableId: 104 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COLUMN ‹j› CASCADE + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ TargetStatus: 1 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 2 + │ │ StatementForDropJob: + │ │ Statement: ALTER TABLE defaultdb.public.t DROP COLUMN j CASCADE + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ IndexID: 2 + │ │ TableID: 104 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 4 + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ IndexID: 4 + │ │ TableID: 104 + │ │ + │ ├── • MakeColumnAbsent + │ │ ColumnID: 4 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COLUMN ‹j› CASCADE + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ TableID: 104 + │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 104 │ │ │ └── • UpdateSchemaChangerJob │ IsNonCancelable: true │ JobID: 1 - │ RunningStatus: PostCommitNonRevertiblePhase stage 3 of 3 with 9 MutationType ops pending + │ RunningStatus: PostCommitNonRevertiblePhase stage 3 of 3 with 3 MutationType ops pending │ └── • Stage 3 of 3 in PostCommitNonRevertiblePhase │ - ├── • 6 elements transitioning toward ABSENT + ├── • 3 elements transitioning toward ABSENT │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} │ │ │ DELETE_ONLY → ABSENT @@ -549,87 +642,34 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j CASCADE; │ │ │ rule: "dependents removed before column" │ │ │ rule: "column type removed right before column when not dropping relation" │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ rule: "dependents removed before column" + │ │ │ │ │ └── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ rule: "indexes containing columns reach absent before column" + │ │ rule: "indexes containing column reach absent before column" │ │ │ ├── • ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} │ │ │ PUBLIC → ABSENT │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 2} - │ │ rule: "column dependents removed after column no longer public" - │ │ - │ ├── • Column:{DescID: 104, ColumnID: 4} - │ │ │ DELETE_ONLY → ABSENT - │ │ │ - │ │ ├── • Precedence dependency from ABSENT ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} - │ │ │ rule: "dependents removed before column" - │ │ │ - │ │ ├── • SameStagePrecedence dependency from ABSENT ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 4} - │ │ │ rule: "dependents removed before column" - │ │ │ rule: "column type removed right before column when not dropping relation" - │ │ │ - │ │ └── • Precedence dependency from ABSENT SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ rule: "indexes containing columns reach absent before column" - │ │ - │ ├── • ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 4} - │ │ │ PUBLIC → ABSENT - │ │ │ - │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 4} - │ │ rule: "column dependents removed after column no longer public" - │ │ - │ ├── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ │ DELETE_ONLY → ABSENT - │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1} - │ │ │ rule: "dependents removed before index" - │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} - │ │ │ rule: "dependents removed before index" - │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 1} - │ │ │ rule: "dependents removed before index" - │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} - │ │ │ rule: "dependents removed before index" - │ │ │ - │ │ └── • SameStagePrecedence dependency from TRANSIENT_ABSENT TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} - │ │ rule: "temp indexes reach absent at the same time as other indexes" + │ │ rule: "column no longer public before dependents" │ │ - │ └── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ └── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} │ │ DELETE_ONLY → ABSENT │ │ - │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} - │ │ rule: "secondary index columns removed before removing the index" + │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1} │ │ rule: "dependents removed before index" │ │ - │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} - │ │ rule: "secondary index columns removed before removing the index" + │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} │ │ rule: "dependents removed before index" │ │ - │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} - │ │ rule: "secondary index columns removed before removing the index" + │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 1} │ │ rule: "dependents removed before index" │ │ - │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} - │ │ rule: "dependents removed before index" - │ │ - │ └── • SameStagePrecedence dependency from TRANSIENT_ABSENT TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} - │ rule: "temp indexes reach absent at the same time as other indexes" - │ - ├── • 1 element transitioning toward TRANSIENT_ABSENT - │ │ - │ └── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} - │ TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT + │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} + │ rule: "dependents removed before index" │ - └── • 11 Mutation operations - │ - ├── • CreateGcJobForIndex - │ IndexID: 4 - │ TableID: 104 - │ - ├── • MakeIndexAbsent - │ IndexID: 4 - │ TableID: 104 + └── • 5 Mutation operations │ ├── • CreateGcJobForIndex │ IndexID: 1 @@ -649,31 +689,6 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j CASCADE; │ IndexID: 1 │ TableID: 104 │ - ├── • LogEvent - │ Element: - │ SecondaryIndex: - │ indexId: 2 - │ tableId: 104 - │ EventBase: - │ Authorization: - │ UserName: root - │ Statement: ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COLUMN ‹j› CASCADE - │ StatementTag: ALTER TABLE - │ TargetMetadata: - │ SourceElementID: 1 - │ SubWorkID: 1 - │ TargetStatus: 1 - │ - ├── • CreateGcJobForIndex - │ IndexID: 2 - │ StatementForDropJob: - │ Statement: ALTER TABLE defaultdb.public.t DROP COLUMN j CASCADE - │ TableID: 104 - │ - ├── • MakeIndexAbsent - │ IndexID: 2 - │ TableID: 104 - │ ├── • MakeColumnAbsent │ ColumnID: 2 │ EventBase: @@ -686,18 +701,6 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j CASCADE; │ SubWorkID: 1 │ TableID: 104 │ - ├── • MakeColumnAbsent - │ ColumnID: 4 - │ EventBase: - │ Authorization: - │ UserName: root - │ Statement: ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COLUMN ‹j› CASCADE - │ StatementTag: ALTER TABLE - │ TargetMetadata: - │ SourceElementID: 1 - │ SubWorkID: 1 - │ TableID: 104 - │ ├── • RemoveJobStateFromDescriptor │ DescriptorID: 104 │ JobID: 1 diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.statement_2_of_2 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.statement_2_of_2 index eea4b6333128..89f18b0e9cf9 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.statement_2_of_2 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_create_index_separate_statements.statement_2_of_2 @@ -181,7 +181,7 @@ EXPLAIN (ddl, verbose) CREATE UNIQUE INDEX idx ON t(k); │ │ │ │ PUBLIC → ABSENT │ │ │ │ │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} -│ │ │ rule: "index no longer public before dependents removed" +│ │ │ rule: "index no longer public before dependents" │ │ │ │ │ ├── • 7 elements transitioning toward PUBLIC │ │ │ │ @@ -191,26 +191,33 @@ EXPLAIN (ddl, verbose) CREATE UNIQUE INDEX idx ON t(k); │ │ │ │ ├── • SameStagePrecedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} │ │ │ │ │ rule: "primary index swap" │ │ │ │ │ +│ │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} +│ │ │ │ │ rule: "index dependents exist before index becomes public" +│ │ │ │ │ +│ │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} +│ │ │ │ │ rule: "index dependents exist before index becomes public" +│ │ │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} +│ │ │ │ rule: "index dependents exist before index becomes public" │ │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ │ │ ├── • IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} │ │ │ │ │ ABSENT → PUBLIC │ │ │ │ │ │ │ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} -│ │ │ │ rule: "index existence precedes index name and comment" +│ │ │ │ rule: "index existence precedes index dependents" │ │ │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 5} │ │ │ │ │ ABSENT → PUBLIC │ │ │ │ │ │ │ │ │ └── • Precedence dependency from BACKFILL_ONLY SecondaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 4, TemporaryIndexID: 6, SourceIndexID: 3} -│ │ │ │ rule: "index-column added to index after index exists" +│ │ │ │ rule: "index existence precedes index dependents" │ │ │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} │ │ │ │ │ ABSENT → PUBLIC │ │ │ │ │ │ │ │ │ └── • Precedence dependency from BACKFILL_ONLY SecondaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 4, TemporaryIndexID: 6, SourceIndexID: 3} -│ │ │ │ rule: "index-column added to index after index exists" +│ │ │ │ rule: "index existence precedes index dependents" │ │ │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 4, TemporaryIndexID: 6, SourceIndexID: 3} │ │ │ │ │ ABSENT → BACKFILL_ONLY @@ -222,15 +229,13 @@ EXPLAIN (ddl, verbose) CREATE UNIQUE INDEX idx ON t(k); │ │ │ │ │ ABSENT → PUBLIC │ │ │ │ │ │ │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 6, ConstraintID: 4, SourceIndexID: 3} -│ │ │ │ rule: "temp index exists before columns, partitioning, and partial" -│ │ │ │ rule: "index-column added to index after temp index exists" +│ │ │ │ rule: "temp index existence precedes index dependents" │ │ │ │ │ │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 6} │ │ │ │ ABSENT → PUBLIC │ │ │ │ │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 6, ConstraintID: 4, SourceIndexID: 3} -│ │ │ rule: "temp index exists before columns, partitioning, and partial" -│ │ │ rule: "index-column added to index after temp index exists" +│ │ │ rule: "temp index existence precedes index dependents" │ │ │ │ │ ├── • 1 element transitioning toward TRANSIENT_ABSENT │ │ │ │ @@ -321,13 +326,7 @@ EXPLAIN (ddl, verbose) CREATE UNIQUE INDEX idx ON t(k); │ │ ├── • 1 element transitioning toward TRANSIENT_ABSENT │ │ │ │ │ │ │ └── • TemporaryIndex:{DescID: 104, IndexID: 6, ConstraintID: 4, SourceIndexID: 3} -│ │ │ │ DELETE_ONLY → WRITE_ONLY -│ │ │ │ -│ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 6} -│ │ │ │ rule: "index-column added to index before temp index receives writes" -│ │ │ │ -│ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 6} -│ │ │ rule: "index-column added to index before temp index receives writes" +│ │ │ DELETE_ONLY → WRITE_ONLY │ │ │ │ │ └── • 3 Mutation operations │ │ │ @@ -467,20 +466,32 @@ EXPLAIN (ddl, verbose) CREATE UNIQUE INDEX idx ON t(k); │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 1} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} │ │ │ VALIDATED → DELETE_ONLY @@ -488,29 +499,32 @@ EXPLAIN (ddl, verbose) CREATE UNIQUE INDEX idx ON t(k); │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 4} + │ │ │ │ rule: "column no longer public before dependents" │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ ├── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ │ │ │ rule: "index no longer public before dependents" │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ ├── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ │ │ │ rule: "index no longer public before dependents" │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ VALIDATED → DELETE_ONLY @@ -520,16 +534,35 @@ EXPLAIN (ddl, verbose) CREATE UNIQUE INDEX idx ON t(k); │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 4, TemporaryIndexID: 6, SourceIndexID: 3} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 5} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 5} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: idx, IndexID: 5} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ └── • IndexName:{DescID: 104, Name: idx, IndexID: 5} │ │ │ ABSENT → PUBLIC │ │ │ │ │ └── • Precedence dependency from BACKFILL_ONLY SecondaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 4, TemporaryIndexID: 6, SourceIndexID: 3} - │ │ rule: "index existence precedes index name and comment" + │ │ rule: "index existence precedes index dependents" │ │ - │ ├── • 2 elements transitioning toward TRANSIENT_ABSENT + │ ├── • 4 elements transitioning toward TRANSIENT_ABSENT + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ │ │ PUBLIC → TRANSIENT_ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → TRANSIENT_ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4} + │ │ │ │ PUBLIC → TRANSIENT_ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → TRANSIENT_ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → TRANSIENT_DELETE_ONLY @@ -537,7 +570,7 @@ EXPLAIN (ddl, verbose) CREATE UNIQUE INDEX idx ON t(k); │ │ └── • TemporaryIndex:{DescID: 104, IndexID: 6, ConstraintID: 4, SourceIndexID: 3} │ │ WRITE_ONLY → TRANSIENT_DELETE_ONLY │ │ - │ └── • 16 Mutation operations + │ └── • 10 Mutation operations │ │ │ ├── • MakeDroppedColumnDeleteOnly │ │ ColumnID: 2 @@ -547,24 +580,6 @@ EXPLAIN (ddl, verbose) CREATE UNIQUE INDEX idx ON t(k); │ │ ColumnID: 4 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 1 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 1 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 1 - │ │ Kind: 2 - │ │ Ordinal: 1 - │ │ TableID: 104 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 4 │ │ TableID: 104 @@ -590,23 +605,6 @@ EXPLAIN (ddl, verbose) CREATE UNIQUE INDEX idx ON t(k); │ │ IndexID: 5 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 4 - │ │ IndexID: 2 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 2 - │ │ Ordinal: 1 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ Kind: 1 - │ │ TableID: 104 - │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 104 │ │ @@ -627,8 +625,11 @@ EXPLAIN (ddl, verbose) CREATE UNIQUE INDEX idx ON t(k); │ │ │ rule: "dependents removed before column" │ │ │ rule: "column type removed right before column when not dropping relation" │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ rule: "dependents removed before column" + │ │ │ │ │ ├── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ │ rule: "indexes containing columns reach absent before column" + │ │ │ rule: "indexes containing column reach absent before column" │ │ │ │ │ └── • Precedence dependency from ABSENT ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ rule: "dependents removed before column" @@ -637,7 +638,7 @@ EXPLAIN (ddl, verbose) CREATE UNIQUE INDEX idx ON t(k); │ │ │ PUBLIC → ABSENT │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 2} - │ │ rule: "column dependents removed after column no longer public" + │ │ rule: "column no longer public before dependents" │ │ │ ├── • Column:{DescID: 104, ColumnID: 4} │ │ │ DELETE_ONLY → ABSENT @@ -646,8 +647,11 @@ EXPLAIN (ddl, verbose) CREATE UNIQUE INDEX idx ON t(k); │ │ │ rule: "dependents removed before column" │ │ │ rule: "column type removed right before column when not dropping relation" │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ │ │ ├── • Precedence dependency from ABSENT SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ rule: "indexes containing columns reach absent before column" + │ │ │ rule: "indexes containing column reach absent before column" │ │ │ │ │ └── • Precedence dependency from ABSENT ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} │ │ rule: "dependents removed before column" @@ -656,7 +660,7 @@ EXPLAIN (ddl, verbose) CREATE UNIQUE INDEX idx ON t(k); │ │ │ PUBLIC → ABSENT │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 4} - │ │ rule: "column dependents removed after column no longer public" + │ │ rule: "column no longer public before dependents" │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} │ │ │ DELETE_ONLY → ABSENT @@ -670,64 +674,39 @@ EXPLAIN (ddl, verbose) CREATE UNIQUE INDEX idx ON t(k); │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 1} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} - │ │ │ rule: "dependents removed before index" - │ │ │ - │ │ ├── • SameStagePrecedence dependency from TRANSIENT_ABSENT TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} - │ │ │ rule: "temp indexes reach absent at the same time as other indexes" - │ │ │ - │ │ └── • SameStagePrecedence dependency from TRANSIENT_ABSENT TemporaryIndex:{DescID: 104, IndexID: 6, ConstraintID: 4, SourceIndexID: 3} - │ │ rule: "temp indexes reach absent at the same time as other indexes" + │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} + │ │ rule: "dependents removed before index" │ │ │ └── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ DELETE_ONLY → ABSENT │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} - │ │ rule: "secondary index columns removed before removing the index" │ │ rule: "dependents removed before index" │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} - │ │ rule: "secondary index columns removed before removing the index" │ │ rule: "dependents removed before index" │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} - │ │ rule: "secondary index columns removed before removing the index" - │ │ rule: "dependents removed before index" - │ │ - │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} │ │ rule: "dependents removed before index" │ │ - │ ├── • SameStagePrecedence dependency from TRANSIENT_ABSENT TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} - │ │ rule: "temp indexes reach absent at the same time as other indexes" - │ │ - │ └── • SameStagePrecedence dependency from TRANSIENT_ABSENT TemporaryIndex:{DescID: 104, IndexID: 6, ConstraintID: 4, SourceIndexID: 3} - │ rule: "temp indexes reach absent at the same time as other indexes" + │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} + │ rule: "dependents removed before index" │ ├── • 2 elements transitioning toward TRANSIENT_ABSENT │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} - │ │ TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT + │ │ │ TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT + │ │ │ + │ │ ├── • Precedence dependency from TRANSIENT_ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from TRANSIENT_ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4} + │ │ rule: "dependents removed before index" │ │ │ └── • TemporaryIndex:{DescID: 104, IndexID: 6, ConstraintID: 4, SourceIndexID: 3} │ TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT │ └── • 13 Mutation operations - │ - ├── • CreateGcJobForIndex - │ IndexID: 4 - │ TableID: 104 - │ - ├── • MakeIndexAbsent - │ IndexID: 4 - │ TableID: 104 - │ - ├── • CreateGcJobForIndex - │ IndexID: 6 - │ TableID: 104 - │ - ├── • MakeIndexAbsent - │ IndexID: 6 - │ TableID: 104 │ ├── • CreateGcJobForIndex │ IndexID: 1 @@ -772,6 +751,22 @@ EXPLAIN (ddl, verbose) CREATE UNIQUE INDEX idx ON t(k); │ IndexID: 2 │ TableID: 104 │ + ├── • CreateGcJobForIndex + │ IndexID: 4 + │ TableID: 104 + │ + ├── • MakeIndexAbsent + │ IndexID: 4 + │ TableID: 104 + │ + ├── • CreateGcJobForIndex + │ IndexID: 6 + │ TableID: 104 + │ + ├── • MakeIndexAbsent + │ IndexID: 6 + │ TableID: 104 + │ ├── • MakeColumnAbsent │ ColumnID: 2 │ EventBase: diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_unique_index b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_unique_index index 45f73777d6a9..5d0819b20b2b 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_unique_index +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_unique_index @@ -22,56 +22,53 @@ EXPLAIN (ddl, verbose) ALTER TABLE t.test DROP pi; │ │ │ PUBLIC → ABSENT │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} -│ │ rule: "column dependents removed after column no longer public" +│ │ rule: "column no longer public before dependents" │ │ -│ ├── • 7 elements transitioning toward PUBLIC +│ ├── • 4 elements transitioning toward PUBLIC +│ │ │ +│ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 4, ConstraintID: 5, TemporaryIndexID: 5, SourceIndexID: 1} +│ │ │ ABSENT → BACKFILL_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 4} │ │ │ │ ABSENT → PUBLIC │ │ │ │ │ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 4, ConstraintID: 5, TemporaryIndexID: 5, SourceIndexID: 1} -│ │ │ rule: "index-column added to index after index exists" +│ │ │ rule: "index existence precedes index dependents" │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 4} │ │ │ │ ABSENT → PUBLIC │ │ │ │ │ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 4, ConstraintID: 5, TemporaryIndexID: 5, SourceIndexID: 1} -│ │ │ rule: "index-column added to index after index exists" +│ │ │ rule: "index existence precedes index dependents" │ │ │ -│ │ ├── • IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 4} -│ │ │ │ ABSENT → PUBLIC -│ │ │ │ -│ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 4, ConstraintID: 5, TemporaryIndexID: 5, SourceIndexID: 1} -│ │ │ rule: "index-column added to index after index exists" +│ │ └── • IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 4} +│ │ │ ABSENT → PUBLIC +│ │ │ +│ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 4, ConstraintID: 5, TemporaryIndexID: 5, SourceIndexID: 1} +│ │ rule: "index existence precedes index dependents" +│ │ +│ ├── • 4 elements transitioning toward TRANSIENT_ABSENT │ │ │ -│ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 4, ConstraintID: 5, TemporaryIndexID: 5, SourceIndexID: 1} -│ │ │ ABSENT → BACKFILL_ONLY +│ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 5, ConstraintID: 6, SourceIndexID: 1} +│ │ │ ABSENT → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 5} │ │ │ │ ABSENT → PUBLIC │ │ │ │ │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 5, ConstraintID: 6, SourceIndexID: 1} -│ │ │ rule: "temp index exists before columns, partitioning, and partial" -│ │ │ rule: "index-column added to index after temp index exists" +│ │ │ rule: "temp index existence precedes index dependents" │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 5} │ │ │ │ ABSENT → PUBLIC │ │ │ │ │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 5, ConstraintID: 6, SourceIndexID: 1} -│ │ │ rule: "temp index exists before columns, partitioning, and partial" -│ │ │ rule: "index-column added to index after temp index exists" +│ │ │ rule: "temp index existence precedes index dependents" │ │ │ │ │ └── • IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 5} │ │ │ ABSENT → PUBLIC │ │ │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 5, ConstraintID: 6, SourceIndexID: 1} -│ │ rule: "temp index exists before columns, partitioning, and partial" -│ │ rule: "index-column added to index after temp index exists" -│ │ -│ ├── • 1 element transitioning toward TRANSIENT_ABSENT -│ │ │ -│ │ └── • TemporaryIndex:{DescID: 106, IndexID: 5, ConstraintID: 6, SourceIndexID: 1} -│ │ ABSENT → DELETE_ONLY +│ │ rule: "temp index existence precedes index dependents" │ │ │ └── • 11 Mutation operations │ │ @@ -109,46 +106,46 @@ EXPLAIN (ddl, verbose) ALTER TABLE t.test DROP pi; │ │ TableID: 106 │ │ TemporaryIndexID: 5 │ │ -│ ├── • MakeAddedTempIndexDeleteOnly -│ │ Index: -│ │ ConstraintID: 6 -│ │ IndexID: 5 -│ │ IsUnique: true -│ │ SourceIndexID: 1 -│ │ TableID: 106 -│ │ │ ├── • AddColumnToIndex │ │ ColumnID: 1 -│ │ IndexID: 5 +│ │ IndexID: 4 │ │ TableID: 106 │ │ │ ├── • AddColumnToIndex │ │ ColumnID: 2 -│ │ IndexID: 5 +│ │ IndexID: 4 │ │ Kind: 2 │ │ TableID: 106 │ │ │ ├── • AddColumnToIndex │ │ ColumnID: 4 -│ │ IndexID: 5 +│ │ IndexID: 4 │ │ Kind: 2 │ │ Ordinal: 1 │ │ TableID: 106 │ │ +│ ├── • MakeAddedTempIndexDeleteOnly +│ │ Index: +│ │ ConstraintID: 6 +│ │ IndexID: 5 +│ │ IsUnique: true +│ │ SourceIndexID: 1 +│ │ TableID: 106 +│ │ │ ├── • AddColumnToIndex │ │ ColumnID: 1 -│ │ IndexID: 4 +│ │ IndexID: 5 │ │ TableID: 106 │ │ │ ├── • AddColumnToIndex │ │ ColumnID: 2 -│ │ IndexID: 4 +│ │ IndexID: 5 │ │ Kind: 2 │ │ TableID: 106 │ │ │ └── • AddColumnToIndex │ ColumnID: 4 -│ IndexID: 4 +│ IndexID: 5 │ Kind: 2 │ Ordinal: 1 │ TableID: 106 @@ -331,26 +328,41 @@ EXPLAIN (ddl, verbose) ALTER TABLE t.test DROP pi; │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 1} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 1} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 1} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 1} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} │ │ │ PUBLIC → WRITE_ONLY @@ -359,7 +371,7 @@ EXPLAIN (ddl, verbose) ALTER TABLE t.test DROP pi; │ │ │ PUBLIC → ABSENT │ │ │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} - │ │ rule: "index no longer public before dependents removed" + │ │ rule: "index no longer public before dependents" │ │ │ ├── • 2 elements transitioning toward PUBLIC │ │ │ @@ -369,21 +381,49 @@ EXPLAIN (ddl, verbose) ALTER TABLE t.test DROP pi; │ │ │ ├── • SameStagePrecedence dependency from VALIDATED PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} │ │ │ │ rule: "primary index swap" │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 106, Name: test_pkey, IndexID: 4} - │ │ │ rule: "index named right before index becomes public" + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 106, Name: test_pkey, IndexID: 4} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ rule: "index named right before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 4} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 4} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 4} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ │ │ └── • IndexName:{DescID: 106, Name: test_pkey, IndexID: 4} │ │ │ ABSENT → PUBLIC │ │ │ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 4, ConstraintID: 5, TemporaryIndexID: 5, SourceIndexID: 1} - │ │ rule: "index existence precedes index name and comment" + │ │ rule: "index existence precedes index dependents" │ │ - │ ├── • 1 element transitioning toward TRANSIENT_ABSENT + │ ├── • 4 elements transitioning toward TRANSIENT_ABSENT │ │ │ - │ │ └── • TemporaryIndex:{DescID: 106, IndexID: 5, ConstraintID: 6, SourceIndexID: 1} - │ │ WRITE_ONLY → TRANSIENT_DELETE_ONLY + │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 5, ConstraintID: 6, SourceIndexID: 1} + │ │ │ WRITE_ONLY → TRANSIENT_DELETE_ONLY + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 5} + │ │ │ │ PUBLIC → TRANSIENT_ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → TRANSIENT_ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 5} + │ │ │ │ PUBLIC → TRANSIENT_ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → TRANSIENT_ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ └── • IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 5} + │ │ │ PUBLIC → TRANSIENT_ABSENT + │ │ │ + │ │ └── • skip PUBLIC → TRANSIENT_ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ - │ └── • 12 Mutation operations + │ └── • 8 Mutation operations │ │ │ ├── • MakeDroppedColumnDeleteOnly │ │ ColumnID: 3 @@ -407,31 +447,6 @@ EXPLAIN (ddl, verbose) ALTER TABLE t.test DROP pi; │ │ IndexID: 5 │ │ TableID: 106 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 1 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 1 - │ │ Kind: 2 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 1 - │ │ Kind: 2 - │ │ Ordinal: 1 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 4 - │ │ IndexID: 1 - │ │ Kind: 2 - │ │ Ordinal: 2 - │ │ TableID: 106 - │ │ │ ├── • MakeAddedPrimaryIndexPublic │ │ EventBase: │ │ Authorization: @@ -450,7 +465,7 @@ EXPLAIN (ddl, verbose) ALTER TABLE t.test DROP pi; │ └── • UpdateSchemaChangerJob │ IsNonCancelable: true │ JobID: 1 - │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 3 with 1 MutationType op pending + │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 3 with 3 MutationType ops pending │ ├── • Stage 2 of 3 in PostCommitNonRevertiblePhase │ │ @@ -459,19 +474,41 @@ EXPLAIN (ddl, verbose) ALTER TABLE t.test DROP pi; │ │ └── • PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} │ │ WRITE_ONLY → DELETE_ONLY │ │ - │ └── • 3 Mutation operations + │ ├── • 1 element transitioning toward TRANSIENT_ABSENT + │ │ │ + │ │ └── • TemporaryIndex:{DescID: 106, IndexID: 5, ConstraintID: 6, SourceIndexID: 1} + │ │ │ TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT + │ │ │ + │ │ ├── • Precedence dependency from TRANSIENT_ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 5} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from TRANSIENT_ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 5} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from TRANSIENT_ABSENT IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 5} + │ │ rule: "dependents removed before index" + │ │ + │ └── • 5 Mutation operations │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 1 │ │ TableID: 106 │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 5 + │ │ TableID: 106 + │ │ + │ ├── • MakeIndexAbsent + │ │ IndexID: 5 + │ │ TableID: 106 + │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 106 │ │ │ └── • UpdateSchemaChangerJob │ IsNonCancelable: true │ JobID: 1 - │ RunningStatus: PostCommitNonRevertiblePhase stage 3 of 3 with 6 MutationType ops pending + │ RunningStatus: PostCommitNonRevertiblePhase stage 3 of 3 with 4 MutationType ops pending │ └── • Stage 3 of 3 in PostCommitNonRevertiblePhase │ @@ -487,20 +524,29 @@ EXPLAIN (ddl, verbose) ALTER TABLE t.test DROP pi; │ │ │ rule: "dependents removed before column" │ │ │ rule: "column type removed right before column when not dropping relation" │ │ │ + │ │ ├── • Precedence dependency from ABSENT ColumnDefaultExpression:{DescID: 106, ColumnID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 1} + │ │ │ rule: "dependents removed before column" + │ │ │ │ │ └── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} - │ │ rule: "indexes containing columns reach absent before column" + │ │ rule: "indexes containing column reach absent before column" │ │ │ ├── • ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 3} │ │ │ PUBLIC → ABSENT │ │ │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} - │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ └── • SameStagePrecedence dependency from ABSENT ColumnDefaultExpression:{DescID: 106, ColumnID: 3} │ │ rule: "column type dependents removed right before column type" │ │ │ ├── • ColumnDefaultExpression:{DescID: 106, ColumnID: 3} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ rule: "column no longer public before dependents" │ │ │ └── • PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} │ │ DELETE_ONLY → ABSENT @@ -517,26 +563,10 @@ EXPLAIN (ddl, verbose) ALTER TABLE t.test DROP pi; │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 1} │ │ rule: "dependents removed before index" │ │ - │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: test_pkey, IndexID: 1} - │ │ rule: "dependents removed before index" - │ │ - │ └── • SameStagePrecedence dependency from TRANSIENT_ABSENT TemporaryIndex:{DescID: 106, IndexID: 5, ConstraintID: 6, SourceIndexID: 1} - │ rule: "temp indexes reach absent at the same time as other indexes" - │ - ├── • 1 element transitioning toward TRANSIENT_ABSENT - │ │ - │ └── • TemporaryIndex:{DescID: 106, IndexID: 5, ConstraintID: 6, SourceIndexID: 1} - │ TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT + │ └── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: test_pkey, IndexID: 1} + │ rule: "dependents removed before index" │ - └── • 8 Mutation operations - │ - ├── • CreateGcJobForIndex - │ IndexID: 5 - │ TableID: 106 - │ - ├── • MakeIndexAbsent - │ IndexID: 5 - │ TableID: 106 + └── • 6 Mutation operations │ ├── • CreateGcJobForIndex │ IndexID: 1 diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_unique_index.rollback_1_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_unique_index.rollback_1_of_7 index 752943ac9ae4..004496d3175e 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_unique_index.rollback_1_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_unique_index.rollback_1_of_7 @@ -16,30 +16,39 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 7; │ ├── • 8 elements transitioning toward ABSENT │ │ - │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 4} - │ │ PUBLIC → ABSENT - │ │ - │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 4} - │ │ PUBLIC → ABSENT - │ │ - │ ├── • IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 4} - │ │ PUBLIC → ABSENT - │ │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 4, ConstraintID: 5, TemporaryIndexID: 5, SourceIndexID: 1} │ │ │ BACKFILL_ONLY → ABSENT │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 4} + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: test_pkey, IndexID: 4} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 4} + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 4} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 4} + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 4} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: test_pkey, IndexID: 4} + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 4} │ │ rule: "dependents removed before index" │ │ + │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 4} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" + │ │ + │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 4} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" + │ │ + │ ├── • IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 4} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" + │ │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 5, ConstraintID: 6, SourceIndexID: 1} │ │ │ DELETE_ONLY → ABSENT │ │ │ @@ -53,23 +62,49 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 7; │ │ rule: "dependents removed before index" │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 5} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 5} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ └── • IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 5} - │ PUBLIC → ABSENT + │ │ PUBLIC → ABSENT + │ │ + │ └── • skip PUBLIC → ABSENT operations + │ rule: "skip index-column removal ops on index removal" │ ├── • 2 elements transitioning toward PUBLIC │ │ │ ├── • Column:{DescID: 106, ColumnID: 3} - │ │ WRITE_ONLY → PUBLIC + │ │ │ WRITE_ONLY → PUBLIC + │ │ │ + │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 106, Name: pi, ColumnID: 3} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 3} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ ├── • Precedence dependency from PUBLIC ColumnDefaultExpression:{DescID: 106, ColumnID: 3} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 1} + │ │ rule: "column dependents exist before column becomes public" │ │ │ └── • ColumnName:{DescID: 106, Name: pi, ColumnID: 3} │ ABSENT → PUBLIC │ - └── • 15 Mutation operations + └── • 9 Mutation operations + │ + ├── • SetColumnName + │ ColumnID: 3 + │ Name: pi + │ TableID: 106 │ ├── • MakeColumnPublic │ ColumnID: 3 @@ -86,47 +121,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 7; ├── • RefreshStats │ TableID: 106 │ - ├── • SetColumnName - │ ColumnID: 3 - │ Name: pi - │ TableID: 106 - │ - ├── • RemoveColumnFromIndex - │ ColumnID: 1 - │ IndexID: 4 - │ TableID: 106 - │ - ├── • RemoveColumnFromIndex - │ ColumnID: 2 - │ IndexID: 4 - │ Kind: 2 - │ TableID: 106 - │ - ├── • RemoveColumnFromIndex - │ ColumnID: 4 - │ IndexID: 4 - │ Kind: 2 - │ Ordinal: 1 - │ TableID: 106 - │ - ├── • RemoveColumnFromIndex - │ ColumnID: 1 - │ IndexID: 5 - │ TableID: 106 - │ - ├── • RemoveColumnFromIndex - │ ColumnID: 2 - │ IndexID: 5 - │ Kind: 2 - │ TableID: 106 - │ - ├── • RemoveColumnFromIndex - │ ColumnID: 4 - │ IndexID: 5 - │ Kind: 2 - │ Ordinal: 1 - │ TableID: 106 - │ ├── • CreateGcJobForIndex │ IndexID: 4 │ StatementForDropJob: diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_unique_index.rollback_2_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_unique_index.rollback_2_of_7 index 9a6154d50029..5f3f9104f38d 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_unique_index.rollback_2_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_unique_index.rollback_2_of_7 @@ -16,51 +16,90 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 2 of 7; │ │ │ ├── • 8 elements transitioning toward ABSENT │ │ │ - │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 4} - │ │ │ PUBLIC → ABSENT - │ │ │ - │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 4} - │ │ │ PUBLIC → ABSENT - │ │ │ - │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 4} - │ │ │ PUBLIC → ABSENT - │ │ │ │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 4, ConstraintID: 5, TemporaryIndexID: 5, SourceIndexID: 1} │ │ │ │ BACKFILL_ONLY → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 4} + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: test_pkey, IndexID: 4} │ │ │ │ rule: "dependents removed before index" │ │ │ │ - │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 4} + │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 4} │ │ │ │ rule: "dependents removed before index" │ │ │ │ - │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 4} + │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 4} │ │ │ │ rule: "dependents removed before index" │ │ │ │ - │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: test_pkey, IndexID: 4} + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 4} │ │ │ rule: "dependents removed before index" │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 4} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 4} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 4} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 5, ConstraintID: 6, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 5} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 5} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 5} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • 2 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 106, ColumnID: 3} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 106, Name: pi, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnDefaultExpression:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 1} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ └── • ColumnName:{DescID: 106, Name: pi, ColumnID: 3} │ │ ABSENT → PUBLIC │ │ - │ └── • 14 Mutation operations + │ └── • 8 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 3 + │ │ Name: pi + │ │ TableID: 106 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 5 + │ │ TableID: 106 │ │ │ ├── • MakeColumnPublic │ │ ColumnID: 3 @@ -77,51 +116,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 2 of 7; │ ├── • RefreshStats │ │ TableID: 106 │ │ - │ ├── • SetColumnName - │ │ ColumnID: 3 - │ │ Name: pi - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 4 - │ │ Kind: 2 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 4 - │ │ IndexID: 4 - │ │ Kind: 2 - │ │ Ordinal: 1 - │ │ TableID: 106 - │ │ - │ ├── • MakeDroppedIndexDeleteOnly - │ │ IndexID: 5 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 5 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 5 - │ │ Kind: 2 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 4 - │ │ IndexID: 5 - │ │ Kind: 2 - │ │ Ordinal: 1 - │ │ TableID: 106 - │ │ │ ├── • CreateGcJobForIndex │ │ IndexID: 4 │ │ StatementForDropJob: diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_unique_index.rollback_3_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_unique_index.rollback_3_of_7 index 79ce36f8ff98..e0606d4c2adc 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_unique_index.rollback_3_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_unique_index.rollback_3_of_7 @@ -16,51 +16,90 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 3 of 7; │ │ │ ├── • 8 elements transitioning toward ABSENT │ │ │ - │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 4} - │ │ │ PUBLIC → ABSENT - │ │ │ - │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 4} - │ │ │ PUBLIC → ABSENT - │ │ │ - │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 4} - │ │ │ PUBLIC → ABSENT - │ │ │ │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 4, ConstraintID: 5, TemporaryIndexID: 5, SourceIndexID: 1} │ │ │ │ BACKFILL_ONLY → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 4} + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: test_pkey, IndexID: 4} │ │ │ │ rule: "dependents removed before index" │ │ │ │ - │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 4} + │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 4} │ │ │ │ rule: "dependents removed before index" │ │ │ │ - │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 4} + │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 4} │ │ │ │ rule: "dependents removed before index" │ │ │ │ - │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: test_pkey, IndexID: 4} + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 4} │ │ │ rule: "dependents removed before index" │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 4} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 4} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 4} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 5, ConstraintID: 6, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 5} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 5} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 5} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • 2 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 106, ColumnID: 3} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 106, Name: pi, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnDefaultExpression:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 1} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ └── • ColumnName:{DescID: 106, Name: pi, ColumnID: 3} │ │ ABSENT → PUBLIC │ │ - │ └── • 14 Mutation operations + │ └── • 8 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 3 + │ │ Name: pi + │ │ TableID: 106 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 5 + │ │ TableID: 106 │ │ │ ├── • MakeColumnPublic │ │ ColumnID: 3 @@ -77,51 +116,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 3 of 7; │ ├── • RefreshStats │ │ TableID: 106 │ │ - │ ├── • SetColumnName - │ │ ColumnID: 3 - │ │ Name: pi - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 4 - │ │ Kind: 2 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 4 - │ │ IndexID: 4 - │ │ Kind: 2 - │ │ Ordinal: 1 - │ │ TableID: 106 - │ │ - │ ├── • MakeDroppedIndexDeleteOnly - │ │ IndexID: 5 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 5 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 5 - │ │ Kind: 2 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 4 - │ │ IndexID: 5 - │ │ Kind: 2 - │ │ Ordinal: 1 - │ │ TableID: 106 - │ │ │ ├── • CreateGcJobForIndex │ │ IndexID: 4 │ │ StatementForDropJob: diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_unique_index.rollback_4_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_unique_index.rollback_4_of_7 index 4ac47583b34f..fe1c100821c1 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_unique_index.rollback_4_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_unique_index.rollback_4_of_7 @@ -16,51 +16,90 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 7; │ │ │ ├── • 8 elements transitioning toward ABSENT │ │ │ - │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 4} - │ │ │ PUBLIC → ABSENT - │ │ │ - │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 4} - │ │ │ PUBLIC → ABSENT - │ │ │ - │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 4} - │ │ │ PUBLIC → ABSENT - │ │ │ │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 4, ConstraintID: 5, TemporaryIndexID: 5, SourceIndexID: 1} │ │ │ │ DELETE_ONLY → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 4} + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: test_pkey, IndexID: 4} │ │ │ │ rule: "dependents removed before index" │ │ │ │ - │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 4} + │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 4} │ │ │ │ rule: "dependents removed before index" │ │ │ │ - │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 4} + │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 4} │ │ │ │ rule: "dependents removed before index" │ │ │ │ - │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: test_pkey, IndexID: 4} + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 4} │ │ │ rule: "dependents removed before index" │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 4} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 4} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 4} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 5, ConstraintID: 6, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 5} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 5} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 5} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • 2 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 106, ColumnID: 3} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 106, Name: pi, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnDefaultExpression:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 1} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ └── • ColumnName:{DescID: 106, Name: pi, ColumnID: 3} │ │ ABSENT → PUBLIC │ │ - │ └── • 14 Mutation operations + │ └── • 8 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 3 + │ │ Name: pi + │ │ TableID: 106 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 5 + │ │ TableID: 106 │ │ │ ├── • MakeColumnPublic │ │ ColumnID: 3 @@ -77,29 +116,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 7; │ ├── • RefreshStats │ │ TableID: 106 │ │ - │ ├── • SetColumnName - │ │ ColumnID: 3 - │ │ Name: pi - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 4 - │ │ Kind: 2 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 4 - │ │ IndexID: 4 - │ │ Kind: 2 - │ │ Ordinal: 1 - │ │ TableID: 106 - │ │ │ ├── • CreateGcJobForIndex │ │ IndexID: 4 │ │ StatementForDropJob: @@ -119,28 +135,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 7; │ │ IndexID: 4 │ │ TableID: 106 │ │ - │ ├── • MakeDroppedIndexDeleteOnly - │ │ IndexID: 5 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 5 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 5 - │ │ Kind: 2 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 4 - │ │ IndexID: 5 - │ │ Kind: 2 - │ │ Ordinal: 1 - │ │ TableID: 106 - │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 106 │ │ diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_unique_index.rollback_5_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_unique_index.rollback_5_of_7 index fd4e645faa1d..aff17316dc89 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_unique_index.rollback_5_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_unique_index.rollback_5_of_7 @@ -16,39 +16,78 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 7; │ │ │ ├── • 8 elements transitioning toward ABSENT │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 4, ConstraintID: 5, TemporaryIndexID: 5, SourceIndexID: 1} + │ │ │ MERGE_ONLY → DELETE_ONLY + │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 4} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 4} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 4} - │ │ │ PUBLIC → ABSENT - │ │ │ - │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 4, ConstraintID: 5, TemporaryIndexID: 5, SourceIndexID: 1} - │ │ │ MERGE_ONLY → DELETE_ONLY + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 5, ConstraintID: 6, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 5} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 5} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 5} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • 2 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 106, ColumnID: 3} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 106, Name: pi, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnDefaultExpression:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 1} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ └── • ColumnName:{DescID: 106, Name: pi, ColumnID: 3} │ │ ABSENT → PUBLIC │ │ - │ └── • 13 Mutation operations + │ └── • 7 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 3 + │ │ Name: pi + │ │ TableID: 106 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 5 + │ │ TableID: 106 │ │ │ ├── • MakeColumnPublic │ │ ColumnID: 3 @@ -65,51 +104,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 7; │ ├── • RefreshStats │ │ TableID: 106 │ │ - │ ├── • SetColumnName - │ │ ColumnID: 3 - │ │ Name: pi - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 4 - │ │ Kind: 2 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 4 - │ │ IndexID: 4 - │ │ Kind: 2 - │ │ Ordinal: 1 - │ │ TableID: 106 - │ │ - │ ├── • MakeDroppedIndexDeleteOnly - │ │ IndexID: 5 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 5 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 5 - │ │ Kind: 2 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 4 - │ │ IndexID: 5 - │ │ Kind: 2 - │ │ Ordinal: 1 - │ │ TableID: 106 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 4 │ │ TableID: 106 @@ -129,16 +123,16 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 7; │ ├── • PrimaryIndex:{DescID: 106, IndexID: 4, ConstraintID: 5, TemporaryIndexID: 5, SourceIndexID: 1} │ │ │ DELETE_ONLY → ABSENT │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 4} + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: test_pkey, IndexID: 4} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 4} + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 4} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 4} + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 4} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: test_pkey, IndexID: 4} + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 4} │ │ rule: "dependents removed before index" │ │ │ └── • TemporaryIndex:{DescID: 106, IndexID: 5, ConstraintID: 6, SourceIndexID: 1} diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_unique_index.rollback_6_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_unique_index.rollback_6_of_7 index 5f34a441f3e7..5f4247e79190 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_unique_index.rollback_6_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_unique_index.rollback_6_of_7 @@ -16,39 +16,78 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 7; │ │ │ ├── • 8 elements transitioning toward ABSENT │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 4, ConstraintID: 5, TemporaryIndexID: 5, SourceIndexID: 1} + │ │ │ MERGE_ONLY → DELETE_ONLY + │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 4} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 4} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 4} - │ │ │ PUBLIC → ABSENT - │ │ │ - │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 4, ConstraintID: 5, TemporaryIndexID: 5, SourceIndexID: 1} - │ │ │ MERGE_ONLY → DELETE_ONLY + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 5, ConstraintID: 6, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 5} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 5} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 5} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • 2 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 106, ColumnID: 3} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 106, Name: pi, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnDefaultExpression:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 1} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ └── • ColumnName:{DescID: 106, Name: pi, ColumnID: 3} │ │ ABSENT → PUBLIC │ │ - │ └── • 13 Mutation operations + │ └── • 7 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 3 + │ │ Name: pi + │ │ TableID: 106 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 5 + │ │ TableID: 106 │ │ │ ├── • MakeColumnPublic │ │ ColumnID: 3 @@ -65,51 +104,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 7; │ ├── • RefreshStats │ │ TableID: 106 │ │ - │ ├── • SetColumnName - │ │ ColumnID: 3 - │ │ Name: pi - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 4 - │ │ Kind: 2 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 4 - │ │ IndexID: 4 - │ │ Kind: 2 - │ │ Ordinal: 1 - │ │ TableID: 106 - │ │ - │ ├── • MakeDroppedIndexDeleteOnly - │ │ IndexID: 5 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 5 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 5 - │ │ Kind: 2 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 4 - │ │ IndexID: 5 - │ │ Kind: 2 - │ │ Ordinal: 1 - │ │ TableID: 106 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 4 │ │ TableID: 106 @@ -129,16 +123,16 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 7; │ ├── • PrimaryIndex:{DescID: 106, IndexID: 4, ConstraintID: 5, TemporaryIndexID: 5, SourceIndexID: 1} │ │ │ DELETE_ONLY → ABSENT │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 4} + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: test_pkey, IndexID: 4} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 4} + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 4} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 4} + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 4} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: test_pkey, IndexID: 4} + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 4} │ │ rule: "dependents removed before index" │ │ │ └── • TemporaryIndex:{DescID: 106, IndexID: 5, ConstraintID: 6, SourceIndexID: 1} diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_unique_index.rollback_7_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_unique_index.rollback_7_of_7 index 76f715161a42..0dc89d7e443f 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_unique_index.rollback_7_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_unique_index.rollback_7_of_7 @@ -16,78 +16,75 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ │ │ ├── • 8 elements transitioning toward ABSENT │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 4, ConstraintID: 5, TemporaryIndexID: 5, SourceIndexID: 1} + │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 4} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 4} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 4} - │ │ │ PUBLIC → ABSENT - │ │ │ - │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 4, ConstraintID: 5, TemporaryIndexID: 5, SourceIndexID: 1} - │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 5, ConstraintID: 6, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 5} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 5} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 5} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • 2 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 106, ColumnID: 3} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 106, Name: pi, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnDefaultExpression:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 1} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ └── • ColumnName:{DescID: 106, Name: pi, ColumnID: 3} │ │ ABSENT → PUBLIC │ │ - │ └── • 13 Mutation operations - │ │ - │ ├── • MakeColumnPublic - │ │ ColumnID: 3 - │ │ EventBase: - │ │ Authorization: - │ │ UserName: root - │ │ Statement: ALTER TABLE ‹t›.public.‹test› DROP COLUMN ‹pi› - │ │ StatementTag: ALTER TABLE - │ │ TargetMetadata: - │ │ SourceElementID: 1 - │ │ SubWorkID: 1 - │ │ TableID: 106 - │ │ - │ ├── • RefreshStats - │ │ TableID: 106 + │ └── • 7 Mutation operations │ │ │ ├── • SetColumnName │ │ ColumnID: 3 │ │ Name: pi │ │ TableID: 106 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 4 - │ │ Kind: 2 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 4 - │ │ IndexID: 4 - │ │ Kind: 2 - │ │ Ordinal: 1 - │ │ TableID: 106 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 4 │ │ TableID: 106 @@ -96,22 +93,19 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ │ IndexID: 5 │ │ TableID: 106 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 5 - │ │ TableID: 106 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 5 - │ │ Kind: 2 + │ ├── • MakeColumnPublic + │ │ ColumnID: 3 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹t›.public.‹test› DROP COLUMN ‹pi› + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 │ │ TableID: 106 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 4 - │ │ IndexID: 5 - │ │ Kind: 2 - │ │ Ordinal: 1 + │ ├── • RefreshStats │ │ TableID: 106 │ │ │ ├── • SetJobStateOnDescriptor @@ -129,16 +123,16 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ ├── • PrimaryIndex:{DescID: 106, IndexID: 4, ConstraintID: 5, TemporaryIndexID: 5, SourceIndexID: 1} │ │ │ DELETE_ONLY → ABSENT │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 4} + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: test_pkey, IndexID: 4} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 4} + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 4} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 4} + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 4} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: test_pkey, IndexID: 4} + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 4, IndexID: 4} │ │ rule: "dependents removed before index" │ │ │ └── • TemporaryIndex:{DescID: 106, IndexID: 5, ConstraintID: 6, SourceIndexID: 1} diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_with_index b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_with_index index cd7842cfa73f..b41427f836b1 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_with_index +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_with_index @@ -13,13 +13,16 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j; │ ├── • 4 elements transitioning toward ABSENT │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} -│ │ │ PUBLIC → WRITE_ONLY +│ │ │ │ PUBLIC → WRITE_ONLY +│ │ │ │ +│ │ │ └── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} +│ │ │ rule: "secondary indexes containing column as key reach write-only before column" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 2} -│ │ │ rule: "column dependents removed after column no longer public" +│ │ │ rule: "column no longer public before dependents" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ PUBLIC → VALIDATED @@ -28,58 +31,32 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j; │ │ │ PUBLIC → ABSENT │ │ │ │ │ └── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} -│ │ rule: "index no longer public before dependents removed" +│ │ rule: "index no longer public before dependents" │ │ -│ ├── • 3 elements transitioning toward PUBLIC -│ │ │ -│ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} -│ │ │ │ ABSENT → PUBLIC -│ │ │ │ -│ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} -│ │ │ rule: "index-column added to index after index exists" +│ ├── • 2 elements transitioning toward PUBLIC │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ ABSENT → BACKFILL_ONLY │ │ │ -│ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} +│ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ │ ABSENT → PUBLIC │ │ │ -│ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} -│ │ rule: "temp index exists before columns, partitioning, and partial" -│ │ rule: "index-column added to index after temp index exists" +│ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} +│ │ rule: "index existence precedes index dependents" │ │ -│ ├── • 1 element transitioning toward TRANSIENT_ABSENT +│ ├── • 2 elements transitioning toward TRANSIENT_ABSENT │ │ │ -│ │ └── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} -│ │ ABSENT → DELETE_ONLY +│ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} +│ │ │ ABSENT → DELETE_ONLY +│ │ │ +│ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} +│ │ │ ABSENT → PUBLIC +│ │ │ +│ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} +│ │ rule: "temp index existence precedes index dependents" │ │ │ └── • 9 Mutation operations │ │ -│ ├── • MakeDroppedColumnDeleteAndWriteOnly -│ │ ColumnID: 2 -│ │ TableID: 104 -│ │ -│ ├── • LogEvent -│ │ Element: -│ │ Column: -│ │ columnId: 2 -│ │ pgAttributeNum: 2 -│ │ tableId: 104 -│ │ EventBase: -│ │ Authorization: -│ │ UserName: root -│ │ Statement: ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COLUMN ‹j› -│ │ StatementTag: ALTER TABLE -│ │ TargetMetadata: -│ │ SourceElementID: 1 -│ │ SubWorkID: 1 -│ │ TargetStatus: 1 -│ │ -│ ├── • SetColumnName -│ │ ColumnID: 2 -│ │ Name: crdb_internal_column_2_name_placeholder -│ │ TableID: 104 -│ │ │ ├── • MakeDroppedNonPrimaryIndexDeleteAndWriteOnly │ │ IndexID: 2 │ │ TableID: 104 @@ -98,6 +75,11 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j; │ │ TableID: 104 │ │ TemporaryIndexID: 4 │ │ +│ ├── • AddColumnToIndex +│ │ ColumnID: 1 +│ │ IndexID: 3 +│ │ TableID: 104 +│ │ │ ├── • MakeAddedTempIndexDeleteOnly │ │ Index: │ │ ConstraintID: 3 @@ -111,9 +93,29 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j; │ │ IndexID: 4 │ │ TableID: 104 │ │ -│ └── • AddColumnToIndex -│ ColumnID: 1 -│ IndexID: 3 +│ ├── • MakeDroppedColumnDeleteAndWriteOnly +│ │ ColumnID: 2 +│ │ TableID: 104 +│ │ +│ ├── • LogEvent +│ │ Element: +│ │ Column: +│ │ columnId: 2 +│ │ pgAttributeNum: 2 +│ │ tableId: 104 +│ │ EventBase: +│ │ Authorization: +│ │ UserName: root +│ │ Statement: ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COLUMN ‹j› +│ │ StatementTag: ALTER TABLE +│ │ TargetMetadata: +│ │ SourceElementID: 1 +│ │ SubWorkID: 1 +│ │ TargetStatus: 1 +│ │ +│ └── • SetColumnName +│ ColumnID: 2 +│ Name: crdb_internal_column_2_name_placeholder │ TableID: 104 │ ├── • PreCommitPhase @@ -282,14 +284,23 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j; │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} │ │ │ PUBLIC → WRITE_ONLY @@ -298,25 +309,28 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j; │ │ │ │ PUBLIC → ABSENT │ │ │ │ │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ rule: "index no longer public before dependents" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ ├── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ │ │ │ rule: "index no longer public before dependents" │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ ├── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ │ │ │ rule: "index no longer public before dependents" │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ VALIDATED → DELETE_ONLY @@ -329,21 +343,31 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j; │ │ │ ├── • SameStagePrecedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} │ │ │ │ rule: "primary index swap" │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} - │ │ │ rule: "index named right before index becomes public" + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ rule: "index named right before index becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ │ │ └── • IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} │ │ │ ABSENT → PUBLIC │ │ │ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} - │ │ rule: "index existence precedes index name and comment" + │ │ rule: "index existence precedes index dependents" │ │ - │ ├── • 1 element transitioning toward TRANSIENT_ABSENT + │ ├── • 2 elements transitioning toward TRANSIENT_ABSENT │ │ │ - │ │ └── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} - │ │ WRITE_ONLY → TRANSIENT_DELETE_ONLY + │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} + │ │ │ WRITE_ONLY → TRANSIENT_DELETE_ONLY + │ │ │ + │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ │ PUBLIC → TRANSIENT_ABSENT + │ │ │ + │ │ └── • skip PUBLIC → TRANSIENT_ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ - │ └── • 13 Mutation operations + │ └── • 9 Mutation operations │ │ │ ├── • MakeDroppedColumnDeleteOnly │ │ ColumnID: 2 @@ -367,17 +391,6 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j; │ │ IndexID: 4 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 1 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 1 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 2 │ │ TableID: 104 @@ -394,49 +407,91 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j; │ │ IndexID: 3 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 2 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ Kind: 1 - │ │ TableID: 104 - │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 104 │ │ │ └── • UpdateSchemaChangerJob │ IsNonCancelable: true │ JobID: 1 - │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 3 with 1 MutationType op pending + │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 3 with 6 MutationType ops pending │ ├── • Stage 2 of 3 in PostCommitNonRevertiblePhase │ │ - │ ├── • 1 element transitioning toward ABSENT + │ ├── • 2 elements transitioning toward ABSENT + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ + │ │ └── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_j_idx, IndexID: 2} + │ │ rule: "dependents removed before index" + │ │ + │ ├── • 1 element transitioning toward TRANSIENT_ABSENT │ │ │ - │ │ └── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ WRITE_ONLY → DELETE_ONLY + │ │ └── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} + │ │ │ TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT + │ │ │ + │ │ └── • Precedence dependency from TRANSIENT_ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ rule: "dependents removed before index" │ │ - │ └── • 3 Mutation operations + │ └── • 8 Mutation operations │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 1 │ │ TableID: 104 │ │ + │ ├── • LogEvent + │ │ Element: + │ │ SecondaryIndex: + │ │ indexId: 2 + │ │ tableId: 104 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COLUMN ‹j› + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ TargetStatus: 1 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 2 + │ │ StatementForDropJob: + │ │ Statement: ALTER TABLE defaultdb.public.t DROP COLUMN j + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ IndexID: 2 + │ │ TableID: 104 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 4 + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ IndexID: 4 + │ │ TableID: 104 + │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 104 │ │ │ └── • UpdateSchemaChangerJob │ IsNonCancelable: true │ JobID: 1 - │ RunningStatus: PostCommitNonRevertiblePhase stage 3 of 3 with 8 MutationType ops pending + │ RunningStatus: PostCommitNonRevertiblePhase stage 3 of 3 with 3 MutationType ops pending │ └── • Stage 3 of 3 in PostCommitNonRevertiblePhase │ - ├── • 4 elements transitioning toward ABSENT + ├── • 3 elements transitioning toward ABSENT │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} │ │ │ DELETE_ONLY → ABSENT @@ -448,64 +503,37 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j; │ │ │ rule: "dependents removed before column" │ │ │ rule: "column type removed right before column when not dropping relation" │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ rule: "dependents removed before column" + │ │ │ │ │ ├── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ │ rule: "indexes containing columns reach absent before column" + │ │ │ rule: "indexes containing column reach absent before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ rule: "dependents removed before column" │ │ │ │ │ └── • Precedence dependency from ABSENT SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ rule: "indexes containing columns reach absent before column" + │ │ rule: "indexes containing column reach absent before column" │ │ │ ├── • ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} │ │ │ PUBLIC → ABSENT │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 2} - │ │ rule: "column dependents removed after column no longer public" + │ │ rule: "column no longer public before dependents" │ │ - │ ├── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ │ DELETE_ONLY → ABSENT - │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1} - │ │ │ rule: "dependents removed before index" - │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} - │ │ │ rule: "dependents removed before index" - │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} - │ │ │ rule: "dependents removed before index" - │ │ │ - │ │ └── • SameStagePrecedence dependency from TRANSIENT_ABSENT TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} - │ │ rule: "temp indexes reach absent at the same time as other indexes" - │ │ - │ └── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ └── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} │ │ DELETE_ONLY → ABSENT │ │ - │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} - │ │ rule: "secondary index columns removed before removing the index" - │ │ rule: "dependents removed before index" - │ │ - │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} - │ │ rule: "secondary index columns removed before removing the index" + │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1} │ │ rule: "dependents removed before index" │ │ - │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_j_idx, IndexID: 2} + │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} │ │ rule: "dependents removed before index" │ │ - │ └── • SameStagePrecedence dependency from TRANSIENT_ABSENT TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} - │ rule: "temp indexes reach absent at the same time as other indexes" - │ - ├── • 1 element transitioning toward TRANSIENT_ABSENT - │ │ - │ └── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} - │ TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT + │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} + │ rule: "dependents removed before index" │ - └── • 10 Mutation operations - │ - ├── • CreateGcJobForIndex - │ IndexID: 4 - │ TableID: 104 - │ - ├── • MakeIndexAbsent - │ IndexID: 4 - │ TableID: 104 + └── • 5 Mutation operations │ ├── • CreateGcJobForIndex │ IndexID: 1 @@ -525,31 +553,6 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j; │ IndexID: 1 │ TableID: 104 │ - ├── • LogEvent - │ Element: - │ SecondaryIndex: - │ indexId: 2 - │ tableId: 104 - │ EventBase: - │ Authorization: - │ UserName: root - │ Statement: ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COLUMN ‹j› - │ StatementTag: ALTER TABLE - │ TargetMetadata: - │ SourceElementID: 1 - │ SubWorkID: 1 - │ TargetStatus: 1 - │ - ├── • CreateGcJobForIndex - │ IndexID: 2 - │ StatementForDropJob: - │ Statement: ALTER TABLE defaultdb.public.t DROP COLUMN j - │ TableID: 104 - │ - ├── • MakeIndexAbsent - │ IndexID: 2 - │ TableID: 104 - │ ├── • MakeColumnAbsent │ ColumnID: 2 │ EventBase: diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_with_index.rollback_1_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_with_index.rollback_1_of_7 index 8ab54ff17181..6f6b889b7440 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_with_index.rollback_1_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_with_index.rollback_1_of_7 @@ -13,18 +13,21 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 7; │ ├── • 4 elements transitioning toward ABSENT │ │ - │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ PUBLIC → ABSENT - │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ BACKFILL_ONLY → ABSENT │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ rule: "dependents removed before index" │ │ + │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" + │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ │ │ DELETE_ONLY → ABSENT │ │ │ @@ -32,12 +35,27 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 7; │ │ rule: "dependents removed before index" │ │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ PUBLIC → ABSENT + │ │ PUBLIC → ABSENT + │ │ + │ └── • skip PUBLIC → ABSENT operations + │ rule: "skip index-column removal ops on index removal" │ ├── • 4 elements transitioning toward PUBLIC │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ WRITE_ONLY → PUBLIC + │ │ │ WRITE_ONLY → PUBLIC + │ │ │ + │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ rule: "column dependents exist before column becomes public" │ │ │ ├── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ ABSENT → PUBLIC @@ -45,13 +63,30 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 7; │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ VALIDATED → PUBLIC │ │ │ + │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ + │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_j_idx, IndexID: 2} + │ │ rule: "index dependents exist before index becomes public" │ │ rule: "index named right before index becomes public" │ │ │ └── • IndexName:{DescID: 104, Name: t_j_idx, IndexID: 2} │ ABSENT → PUBLIC │ - └── • 13 Mutation operations + └── • 11 Mutation operations + │ + ├── • SetColumnName + │ ColumnID: 2 + │ Name: j + │ TableID: 104 + │ + ├── • SetIndexName + │ IndexID: 2 + │ Name: t_j_idx + │ TableID: 104 │ ├── • MakeColumnPublic │ ColumnID: 2 @@ -68,26 +103,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 7; ├── • RefreshStats │ TableID: 104 │ - ├── • SetColumnName - │ ColumnID: 2 - │ Name: j - │ TableID: 104 - │ - ├── • SetIndexName - │ IndexID: 2 - │ Name: t_j_idx - │ TableID: 104 - │ - ├── • RemoveColumnFromIndex - │ ColumnID: 1 - │ IndexID: 3 - │ TableID: 104 - │ - ├── • RemoveColumnFromIndex - │ ColumnID: 1 - │ IndexID: 4 - │ TableID: 104 - │ ├── • MakeAddedSecondaryIndexPublic │ IndexID: 2 │ TableID: 104 diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_with_index.rollback_2_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_with_index.rollback_2_of_7 index 59d2173d1612..82e4260ba635 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_with_index.rollback_2_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_with_index.rollback_2_of_7 @@ -13,28 +13,46 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 2 of 7; │ │ │ ├── • 4 elements transitioning toward ABSENT │ │ │ - │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT - │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ │ BACKFILL_ONLY → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} │ │ │ │ rule: "dependents removed before index" │ │ │ │ - │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ │ rule: "dependents removed before index" │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • 4 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ │ ABSENT → PUBLIC @@ -42,28 +60,20 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 2 of 7; │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_j_idx, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ └── • IndexName:{DescID: 104, Name: t_j_idx, IndexID: 2} │ │ ABSENT → PUBLIC │ │ - │ └── • 12 Mutation operations - │ │ - │ ├── • MakeColumnPublic - │ │ ColumnID: 2 - │ │ EventBase: - │ │ Authorization: - │ │ UserName: root - │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› - │ │ StatementTag: ALTER TABLE - │ │ TargetMetadata: - │ │ SourceElementID: 1 - │ │ SubWorkID: 1 - │ │ TableID: 104 - │ │ - │ ├── • RefreshStats - │ │ TableID: 104 + │ └── • 10 Mutation operations │ │ │ ├── • SetColumnName │ │ ColumnID: 2 @@ -75,18 +85,23 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 2 of 7; │ │ Name: t_j_idx │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 4 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 + │ ├── • MakeColumnPublic + │ │ ColumnID: 2 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ TableID: 104 + │ │ + │ ├── • RefreshStats │ │ TableID: 104 │ │ │ ├── • MakeAddedSecondaryIndexPublic diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_with_index.rollback_3_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_with_index.rollback_3_of_7 index 624c6a3cdd72..36bb4b14306e 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_with_index.rollback_3_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_with_index.rollback_3_of_7 @@ -13,28 +13,46 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 3 of 7; │ │ │ ├── • 4 elements transitioning toward ABSENT │ │ │ - │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT - │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ │ BACKFILL_ONLY → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} │ │ │ │ rule: "dependents removed before index" │ │ │ │ - │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ │ rule: "dependents removed before index" │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • 4 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ │ ABSENT → PUBLIC @@ -42,28 +60,20 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 3 of 7; │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_j_idx, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ └── • IndexName:{DescID: 104, Name: t_j_idx, IndexID: 2} │ │ ABSENT → PUBLIC │ │ - │ └── • 12 Mutation operations - │ │ - │ ├── • MakeColumnPublic - │ │ ColumnID: 2 - │ │ EventBase: - │ │ Authorization: - │ │ UserName: root - │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› - │ │ StatementTag: ALTER TABLE - │ │ TargetMetadata: - │ │ SourceElementID: 1 - │ │ SubWorkID: 1 - │ │ TableID: 104 - │ │ - │ ├── • RefreshStats - │ │ TableID: 104 + │ └── • 10 Mutation operations │ │ │ ├── • SetColumnName │ │ ColumnID: 2 @@ -75,18 +85,23 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 3 of 7; │ │ Name: t_j_idx │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 4 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 + │ ├── • MakeColumnPublic + │ │ ColumnID: 2 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ TableID: 104 + │ │ + │ ├── • RefreshStats │ │ TableID: 104 │ │ │ ├── • MakeAddedSecondaryIndexPublic diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_with_index.rollback_4_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_with_index.rollback_4_of_7 index fc906197ec85..6c3b6617fb3c 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_with_index.rollback_4_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_with_index.rollback_4_of_7 @@ -13,28 +13,46 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 7; │ │ │ ├── • 4 elements transitioning toward ABSENT │ │ │ - │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT - │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ │ DELETE_ONLY → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} │ │ │ │ rule: "dependents removed before index" │ │ │ │ - │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ │ rule: "dependents removed before index" │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • 4 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ │ ABSENT → PUBLIC @@ -42,13 +60,34 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 7; │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_j_idx, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ └── • IndexName:{DescID: 104, Name: t_j_idx, IndexID: 2} │ │ ABSENT → PUBLIC │ │ - │ └── • 12 Mutation operations + │ └── • 10 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 2 + │ │ Name: j + │ │ TableID: 104 + │ │ + │ ├── • SetIndexName + │ │ IndexID: 2 + │ │ Name: t_j_idx + │ │ TableID: 104 + │ │ + │ ├── • MakeDroppedIndexDeleteOnly + │ │ IndexID: 4 + │ │ TableID: 104 │ │ │ ├── • MakeColumnPublic │ │ ColumnID: 2 @@ -65,19 +104,8 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 7; │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • SetColumnName - │ │ ColumnID: 2 - │ │ Name: j - │ │ TableID: 104 - │ │ - │ ├── • SetIndexName + │ ├── • MakeAddedSecondaryIndexPublic │ │ IndexID: 2 - │ │ Name: t_j_idx - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 │ │ TableID: 104 │ │ │ ├── • CreateGcJobForIndex @@ -99,19 +127,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 7; │ │ IndexID: 3 │ │ TableID: 104 │ │ - │ ├── • MakeDroppedIndexDeleteOnly - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ - │ ├── • MakeAddedSecondaryIndexPublic - │ │ IndexID: 2 - │ │ TableID: 104 - │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 104 │ │ diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_with_index.rollback_5_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_with_index.rollback_5_of_7 index 6a4169bf6485..bf419182fc97 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_with_index.rollback_5_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_with_index.rollback_5_of_7 @@ -13,22 +13,40 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 7; │ │ │ ├── • 4 elements transitioning toward ABSENT │ │ │ - │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT - │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ MERGE_ONLY → DELETE_ONLY │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • 4 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ │ ABSENT → PUBLIC @@ -36,28 +54,20 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 7; │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_j_idx, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ └── • IndexName:{DescID: 104, Name: t_j_idx, IndexID: 2} │ │ ABSENT → PUBLIC │ │ - │ └── • 11 Mutation operations - │ │ - │ ├── • MakeColumnPublic - │ │ ColumnID: 2 - │ │ EventBase: - │ │ Authorization: - │ │ UserName: root - │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› - │ │ StatementTag: ALTER TABLE - │ │ TargetMetadata: - │ │ SourceElementID: 1 - │ │ SubWorkID: 1 - │ │ TableID: 104 - │ │ - │ ├── • RefreshStats - │ │ TableID: 104 + │ └── • 9 Mutation operations │ │ │ ├── • SetColumnName │ │ ColumnID: 2 @@ -69,18 +79,23 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 7; │ │ Name: t_j_idx │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 4 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 + │ ├── • MakeColumnPublic + │ │ ColumnID: 2 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ TableID: 104 + │ │ + │ ├── • RefreshStats │ │ TableID: 104 │ │ │ ├── • MakeAddedSecondaryIndexPublic @@ -106,10 +121,10 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 7; │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ DELETE_ONLY → ABSENT │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ rule: "dependents removed before index" │ │ │ └── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_with_index.rollback_6_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_with_index.rollback_6_of_7 index c91012c01f7e..c3973d89c23d 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_with_index.rollback_6_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_with_index.rollback_6_of_7 @@ -13,22 +13,40 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 7; │ │ │ ├── • 4 elements transitioning toward ABSENT │ │ │ - │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT - │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ MERGE_ONLY → DELETE_ONLY │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • 4 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ │ ABSENT → PUBLIC @@ -36,28 +54,20 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 7; │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_j_idx, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ └── • IndexName:{DescID: 104, Name: t_j_idx, IndexID: 2} │ │ ABSENT → PUBLIC │ │ - │ └── • 11 Mutation operations - │ │ - │ ├── • MakeColumnPublic - │ │ ColumnID: 2 - │ │ EventBase: - │ │ Authorization: - │ │ UserName: root - │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› - │ │ StatementTag: ALTER TABLE - │ │ TargetMetadata: - │ │ SourceElementID: 1 - │ │ SubWorkID: 1 - │ │ TableID: 104 - │ │ - │ ├── • RefreshStats - │ │ TableID: 104 + │ └── • 9 Mutation operations │ │ │ ├── • SetColumnName │ │ ColumnID: 2 @@ -69,18 +79,23 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 7; │ │ Name: t_j_idx │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 4 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 + │ ├── • MakeColumnPublic + │ │ ColumnID: 2 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ TableID: 104 + │ │ + │ ├── • RefreshStats │ │ TableID: 104 │ │ │ ├── • MakeAddedSecondaryIndexPublic @@ -106,10 +121,10 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 7; │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ DELETE_ONLY → ABSENT │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ rule: "dependents removed before index" │ │ │ └── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_with_index.rollback_7_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_with_index.rollback_7_of_7 index e29cc45e0a19..b117b12c35da 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_with_index.rollback_7_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_column_with_index.rollback_7_of_7 @@ -13,22 +13,40 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ │ │ ├── • 4 elements transitioning toward ABSENT │ │ │ - │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT - │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ │ │ └── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • 4 elements transitioning toward PUBLIC │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ │ ABSENT → PUBLIC @@ -36,28 +54,20 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_j_idx, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ └── • IndexName:{DescID: 104, Name: t_j_idx, IndexID: 2} │ │ ABSENT → PUBLIC │ │ - │ └── • 11 Mutation operations - │ │ - │ ├── • MakeColumnPublic - │ │ ColumnID: 2 - │ │ EventBase: - │ │ Authorization: - │ │ UserName: root - │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› - │ │ StatementTag: ALTER TABLE - │ │ TargetMetadata: - │ │ SourceElementID: 1 - │ │ SubWorkID: 1 - │ │ TableID: 104 - │ │ - │ ├── • RefreshStats - │ │ TableID: 104 + │ └── • 9 Mutation operations │ │ │ ├── • SetColumnName │ │ ColumnID: 2 @@ -69,11 +79,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ │ Name: t_j_idx │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 3 │ │ TableID: 104 @@ -82,9 +87,19 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ │ IndexID: 4 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 + │ ├── • MakeColumnPublic + │ │ ColumnID: 2 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ TableID: 104 + │ │ + │ ├── • RefreshStats │ │ TableID: 104 │ │ │ ├── • MakeAddedSecondaryIndexPublic @@ -106,10 +121,10 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ DELETE_ONLY → ABSENT │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} │ │ │ rule: "dependents removed before index" │ │ │ - │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ rule: "dependents removed before index" │ │ │ └── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_index_hash_sharded_index b/pkg/sql/schemachanger/testdata/explain_verbose/drop_index_hash_sharded_index index 0c01eace46c8..41a029039426 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_index_hash_sharded_index +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_index_hash_sharded_index @@ -14,13 +14,16 @@ EXPLAIN (ddl, verbose) DROP INDEX idx CASCADE; │ ├── • 4 elements transitioning toward ABSENT │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 3} -│ │ │ PUBLIC → WRITE_ONLY +│ │ │ │ PUBLIC → WRITE_ONLY +│ │ │ │ +│ │ │ └── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} +│ │ │ rule: "secondary indexes containing column as key reach write-only before column" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: crdb_internal_j_shard_16, ColumnID: 3} │ │ │ │ PUBLIC → ABSENT │ │ │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 3} -│ │ │ rule: "column dependents removed after column no longer public" +│ │ │ rule: "column no longer public before dependents" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ PUBLIC → VALIDATED @@ -29,10 +32,19 @@ EXPLAIN (ddl, verbose) DROP INDEX idx CASCADE; │ │ │ PUBLIC → ABSENT │ │ │ │ │ └── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} -│ │ rule: "index no longer public before dependents removed" +│ │ rule: "index no longer public before dependents" │ │ │ └── • 5 Mutation operations │ │ +│ ├── • MakeDroppedNonPrimaryIndexDeleteAndWriteOnly +│ │ IndexID: 2 +│ │ TableID: 104 +│ │ +│ ├── • SetIndexName +│ │ IndexID: 2 +│ │ Name: crdb_internal_index_2_name_placeholder +│ │ TableID: 104 +│ │ │ ├── • MakeDroppedColumnDeleteAndWriteOnly │ │ ColumnID: 3 │ │ TableID: 104 @@ -54,18 +66,9 @@ EXPLAIN (ddl, verbose) DROP INDEX idx CASCADE; │ │ SubWorkID: 1 │ │ TargetStatus: 1 │ │ -│ ├── • SetColumnName -│ │ ColumnID: 3 -│ │ Name: crdb_internal_column_3_name_placeholder -│ │ TableID: 104 -│ │ -│ ├── • MakeDroppedNonPrimaryIndexDeleteAndWriteOnly -│ │ IndexID: 2 -│ │ TableID: 104 -│ │ -│ └── • SetIndexName -│ IndexID: 2 -│ Name: crdb_internal_index_2_name_placeholder +│ └── • SetColumnName +│ ColumnID: 3 +│ Name: crdb_internal_column_3_name_placeholder │ TableID: 104 │ ├── • PreCommitPhase @@ -85,7 +88,7 @@ EXPLAIN (ddl, verbose) DROP INDEX idx CASCADE; │ - 104 │ JobID: 1 │ NonCancelable: true -│ RunningStatus: PostCommitNonRevertiblePhase stage 1 of 2 with 7 MutationType ops pending +│ RunningStatus: PostCommitNonRevertiblePhase stage 1 of 2 with 4 MutationType ops pending │ Statements: │ - statement: DROP INDEX idx CASCADE │ redactedstatement: DROP INDEX ‹defaultdb›.‹public›.‹t›@‹idx› CASCADE @@ -103,29 +106,32 @@ EXPLAIN (ddl, verbose) DROP INDEX idx CASCADE; │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 3} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ ├── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ │ │ │ rule: "index no longer public before dependents" │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ ├── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ │ │ │ rule: "index no longer public before dependents" │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ ├── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ │ │ │ rule: "index no longer public before dependents" │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ VALIDATED → DELETE_ONLY @@ -136,7 +142,7 @@ EXPLAIN (ddl, verbose) DROP INDEX idx CASCADE; │ │ └── • ConstraintName:{DescID: 104, Name: check_crdb_internal_j_shard_16, ConstraintID: 2} │ │ PUBLIC → ABSENT │ │ - │ └── • 9 Mutation operations + │ └── • 6 Mutation operations │ │ │ ├── • MakeDroppedColumnDeleteOnly │ │ ColumnID: 3 @@ -153,23 +159,6 @@ EXPLAIN (ddl, verbose) DROP INDEX idx CASCADE; │ │ IndexID: 2 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 2 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 2 - │ │ Ordinal: 1 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ Kind: 1 - │ │ TableID: 104 - │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 104 │ │ @@ -192,28 +181,28 @@ EXPLAIN (ddl, verbose) DROP INDEX idx CASCADE; │ │ │ rule: "dependents removed before column" │ │ │ rule: "column type removed right before column when not dropping relation" │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ │ │ └── • Precedence dependency from ABSENT SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ rule: "indexes containing columns reach absent before column" + │ │ rule: "indexes containing column reach absent before column" │ │ │ ├── • ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 3} │ │ │ PUBLIC → ABSENT │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 3} - │ │ rule: "column dependents removed after column no longer public" + │ │ rule: "column no longer public before dependents" │ │ │ └── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ DELETE_ONLY → ABSENT │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} - │ │ rule: "secondary index columns removed before removing the index" │ │ rule: "dependents removed before index" │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} - │ │ rule: "secondary index columns removed before removing the index" │ │ rule: "dependents removed before index" │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} - │ │ rule: "secondary index columns removed before removing the index" │ │ rule: "dependents removed before index" │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: idx, IndexID: 2} diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_index_partial_expression_index b/pkg/sql/schemachanger/testdata/explain_verbose/drop_index_partial_expression_index index a758463eaff7..f97757bb4e55 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_index_partial_expression_index +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_index_partial_expression_index @@ -14,13 +14,16 @@ EXPLAIN (ddl, verbose) DROP INDEX idx CASCADE; │ ├── • 4 elements transitioning toward ABSENT │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 3} -│ │ │ PUBLIC → WRITE_ONLY +│ │ │ │ PUBLIC → WRITE_ONLY +│ │ │ │ +│ │ │ └── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} +│ │ │ rule: "secondary indexes containing column as key reach write-only before column" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 3} │ │ │ │ PUBLIC → ABSENT │ │ │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 3} -│ │ │ rule: "column dependents removed after column no longer public" +│ │ │ rule: "column no longer public before dependents" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ PUBLIC → VALIDATED @@ -29,10 +32,19 @@ EXPLAIN (ddl, verbose) DROP INDEX idx CASCADE; │ │ │ PUBLIC → ABSENT │ │ │ │ │ └── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} -│ │ rule: "index no longer public before dependents removed" +│ │ rule: "index no longer public before dependents" │ │ │ └── • 5 Mutation operations │ │ +│ ├── • MakeDroppedNonPrimaryIndexDeleteAndWriteOnly +│ │ IndexID: 2 +│ │ TableID: 104 +│ │ +│ ├── • SetIndexName +│ │ IndexID: 2 +│ │ Name: crdb_internal_index_2_name_placeholder +│ │ TableID: 104 +│ │ │ ├── • MakeDroppedColumnDeleteAndWriteOnly │ │ ColumnID: 3 │ │ TableID: 104 @@ -54,18 +66,9 @@ EXPLAIN (ddl, verbose) DROP INDEX idx CASCADE; │ │ SubWorkID: 1 │ │ TargetStatus: 1 │ │ -│ ├── • SetColumnName -│ │ ColumnID: 3 -│ │ Name: crdb_internal_column_3_name_placeholder -│ │ TableID: 104 -│ │ -│ ├── • MakeDroppedNonPrimaryIndexDeleteAndWriteOnly -│ │ IndexID: 2 -│ │ TableID: 104 -│ │ -│ └── • SetIndexName -│ IndexID: 2 -│ Name: crdb_internal_index_2_name_placeholder +│ └── • SetColumnName +│ ColumnID: 3 +│ Name: crdb_internal_column_3_name_placeholder │ TableID: 104 │ ├── • PreCommitPhase @@ -85,7 +88,7 @@ EXPLAIN (ddl, verbose) DROP INDEX idx CASCADE; │ - 104 │ JobID: 1 │ NonCancelable: true -│ RunningStatus: PostCommitNonRevertiblePhase stage 1 of 2 with 4 MutationType ops pending +│ RunningStatus: PostCommitNonRevertiblePhase stage 1 of 2 with 2 MutationType ops pending │ Statements: │ - statement: DROP INDEX idx CASCADE │ redactedstatement: DROP INDEX ‹defaultdb›.‹public›.‹t›@‹idx› CASCADE @@ -103,25 +106,28 @@ EXPLAIN (ddl, verbose) DROP INDEX idx CASCADE; │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 3} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ ├── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ │ │ │ rule: "index no longer public before dependents" │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ ├── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ │ │ │ rule: "index no longer public before dependents" │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ VALIDATED → DELETE_ONLY │ │ - │ └── • 6 Mutation operations + │ └── • 4 Mutation operations │ │ │ ├── • MakeDroppedColumnDeleteOnly │ │ ColumnID: 3 @@ -131,17 +137,6 @@ EXPLAIN (ddl, verbose) DROP INDEX idx CASCADE; │ │ IndexID: 2 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 2 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ Kind: 1 - │ │ TableID: 104 - │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 104 │ │ @@ -164,30 +159,31 @@ EXPLAIN (ddl, verbose) DROP INDEX idx CASCADE; │ │ │ rule: "dependents removed before column" │ │ │ rule: "column type removed right before column when not dropping relation" │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ │ │ └── • Precedence dependency from ABSENT SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ rule: "indexes containing columns reach absent before column" + │ │ rule: "indexes containing column reach absent before column" │ │ │ ├── • ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 3} │ │ │ PUBLIC → ABSENT │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 3} - │ │ rule: "column dependents removed after column no longer public" + │ │ rule: "column no longer public before dependents" │ │ │ ├── • SecondaryIndexPartial:{DescID: 104, IndexID: 2} │ │ │ PUBLIC → ABSENT │ │ │ │ │ └── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ rule: "index no longer public before dependents removed" + │ │ rule: "index no longer public before dependents" │ │ │ └── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ DELETE_ONLY → ABSENT │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} - │ │ rule: "secondary index columns removed before removing the index" │ │ rule: "dependents removed before index" │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} - │ │ rule: "secondary index columns removed before removing the index" │ │ rule: "dependents removed before index" │ │ │ ├── • SameStagePrecedence dependency from ABSENT SecondaryIndexPartial:{DescID: 104, IndexID: 2} diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_index_vanilla_index b/pkg/sql/schemachanger/testdata/explain_verbose/drop_index_vanilla_index index 4bf47a17ff21..67d267509c3d 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_index_vanilla_index +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_index_vanilla_index @@ -20,7 +20,7 @@ EXPLAIN (ddl, verbose) DROP INDEX idx CASCADE; │ │ │ PUBLIC → ABSENT │ │ │ │ │ └── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} -│ │ rule: "index no longer public before dependents removed" +│ │ rule: "index no longer public before dependents" │ │ │ └── • 2 Mutation operations │ │ @@ -50,7 +50,7 @@ EXPLAIN (ddl, verbose) DROP INDEX idx CASCADE; │ - 104 │ JobID: 1 │ NonCancelable: true -│ RunningStatus: PostCommitNonRevertiblePhase stage 1 of 2 with 3 MutationType ops pending +│ RunningStatus: PostCommitNonRevertiblePhase stage 1 of 2 with 1 MutationType op pending │ Statements: │ - statement: DROP INDEX idx CASCADE │ redactedstatement: DROP INDEX ‹defaultdb›.‹public›.‹t›@‹idx› CASCADE @@ -65,41 +65,30 @@ EXPLAIN (ddl, verbose) DROP INDEX idx CASCADE; │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ ├── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ │ │ │ rule: "index no longer public before dependents" │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ ├── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ │ │ │ rule: "index no longer public before dependents" │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ VALIDATED → DELETE_ONLY │ │ - │ └── • 5 Mutation operations + │ └── • 3 Mutation operations │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 2 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 2 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ Kind: 1 - │ │ TableID: 104 - │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 104 │ │ @@ -116,11 +105,9 @@ EXPLAIN (ddl, verbose) DROP INDEX idx CASCADE; │ │ DELETE_ONLY → ABSENT │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 2} - │ │ rule: "secondary index columns removed before removing the index" │ │ rule: "dependents removed before index" │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} - │ │ rule: "secondary index columns removed before removing the index" │ │ rule: "dependents removed before index" │ │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: idx, IndexID: 2} diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_multiple_columns_separate_statements.rollback_1_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_multiple_columns_separate_statements.rollback_1_of_7 index 4b45474c0128..19a74f8b3ddb 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_multiple_columns_separate_statements.rollback_1_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_multiple_columns_separate_statements.rollback_1_of_7 @@ -15,10 +15,16 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 7; ├── • 4 elements transitioning toward ABSENT │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ BACKFILL_ONLY → ABSENT @@ -40,14 +46,47 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 7; │ ├── • Column:{DescID: 104, ColumnID: 3} │ │ │ WRITE_ONLY → PUBLIC │ │ │ - │ │ └── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} - │ │ rule: "ensure columns are in increasing order" + │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: k, ColumnID: 3} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 3} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ ├── • Precedence dependency from PUBLIC ColumnDefaultExpression:{DescID: 104, ColumnID: 3} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ ├── • Precedence dependency from PUBLIC ColumnOnUpdateExpression:{DescID: 104, ColumnID: 3} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ │ rule: "ensure columns are in increasing order" + │ │ │ + │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 1} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4} + │ │ rule: "column dependents exist before column becomes public" │ │ │ ├── • ColumnName:{DescID: 104, Name: k, ColumnID: 3} │ │ ABSENT → PUBLIC │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ WRITE_ONLY → PUBLIC + │ │ │ WRITE_ONLY → PUBLIC + │ │ │ + │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ rule: "column dependents exist before column becomes public" │ │ │ ├── • Column:{DescID: 104, ColumnID: 4} │ │ │ WRITE_ONLY → PUBLIC @@ -55,13 +94,32 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 7; │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 3} │ │ │ rule: "ensure columns are in increasing order" │ │ │ - │ │ └── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} - │ │ rule: "ensure columns are in increasing order" + │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ │ rule: "ensure columns are in increasing order" + │ │ │ + │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 4} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} + │ │ rule: "column dependents exist before column becomes public" │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ VALIDATED → PUBLIC │ │ │ + │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ + │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ + │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} + │ │ rule: "index dependents exist before index becomes public" │ │ rule: "index named right before index becomes public" │ │ │ ├── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} @@ -73,38 +131,13 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 7; │ └── • IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} │ ABSENT → PUBLIC │ - └── • 19 Mutation operations + └── • 17 Mutation operations │ ├── • SetColumnName │ ColumnID: 3 │ Name: k │ TableID: 104 │ - ├── • MakeColumnPublic - │ ColumnID: 2 - │ EventBase: - │ Authorization: - │ UserName: root - │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE - │ StatementTag: ALTER TABLE - │ TargetMetadata: - │ SourceElementID: 1 - │ SubWorkID: 1 - │ TableID: 104 - │ - ├── • RefreshStats - │ TableID: 104 - │ - ├── • RemoveColumnFromIndex - │ ColumnID: 1 - │ IndexID: 3 - │ TableID: 104 - │ - ├── • RemoveColumnFromIndex - │ ColumnID: 1 - │ IndexID: 4 - │ TableID: 104 - │ ├── • SetColumnName │ ColumnID: 2 │ Name: j @@ -129,23 +162,7 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 7; │ TableID: 104 │ ├── • MakeColumnPublic - │ ColumnID: 3 - │ EventBase: - │ Authorization: - │ UserName: root - │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹k› CASCADE - │ StatementTag: ALTER TABLE - │ TargetMetadata: - │ SourceElementID: 1 - │ StatementID: 1 - │ SubWorkID: 1 - │ TableID: 104 - │ - ├── • RefreshStats - │ TableID: 104 - │ - ├── • MakeColumnPublic - │ ColumnID: 4 + │ ColumnID: 2 │ EventBase: │ Authorization: │ UserName: root @@ -182,6 +199,37 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 7; │ IndexID: 3 │ TableID: 104 │ + ├── • MakeColumnPublic + │ ColumnID: 3 + │ EventBase: + │ Authorization: + │ UserName: root + │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹k› CASCADE + │ StatementTag: ALTER TABLE + │ TargetMetadata: + │ SourceElementID: 1 + │ StatementID: 1 + │ SubWorkID: 1 + │ TableID: 104 + │ + ├── • RefreshStats + │ TableID: 104 + │ + ├── • MakeColumnPublic + │ ColumnID: 4 + │ EventBase: + │ Authorization: + │ UserName: root + │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE + │ StatementTag: ALTER TABLE + │ TargetMetadata: + │ SourceElementID: 1 + │ SubWorkID: 1 + │ TableID: 104 + │ + ├── • RefreshStats + │ TableID: 104 + │ ├── • RemoveJobStateFromDescriptor │ DescriptorID: 104 │ JobID: 1 diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_multiple_columns_separate_statements.rollback_2_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_multiple_columns_separate_statements.rollback_2_of_7 index 9715397944ff..47440d25bde8 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_multiple_columns_separate_statements.rollback_2_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_multiple_columns_separate_statements.rollback_2_of_7 @@ -15,10 +15,16 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 2 of 7; │ ├── • 4 elements transitioning toward ABSENT │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ │ BACKFILL_ONLY → ABSENT @@ -37,14 +43,47 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 2 of 7; │ │ ├── • Column:{DescID: 104, ColumnID: 3} │ │ │ │ WRITE_ONLY → PUBLIC │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} - │ │ │ rule: "ensure columns are in increasing order" + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: k, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnDefaultExpression:{DescID: 104, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnOnUpdateExpression:{DescID: 104, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "ensure columns are in increasing order" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 1} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: k, ColumnID: 3} │ │ │ ABSENT → PUBLIC │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 4} │ │ │ │ WRITE_ONLY → PUBLIC @@ -52,13 +91,32 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 2 of 7; │ │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 3} │ │ │ │ rule: "ensure columns are in increasing order" │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} - │ │ │ rule: "ensure columns are in increasing order" + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "ensure columns are in increasing order" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 4} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} @@ -70,38 +128,13 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 2 of 7; │ │ └── • IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} │ │ ABSENT → PUBLIC │ │ - │ └── • 18 Mutation operations + │ └── • 16 Mutation operations │ │ │ ├── • SetColumnName │ │ ColumnID: 3 │ │ Name: k │ │ TableID: 104 │ │ - │ ├── • MakeColumnPublic - │ │ ColumnID: 2 - │ │ EventBase: - │ │ Authorization: - │ │ UserName: root - │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE - │ │ StatementTag: ALTER TABLE - │ │ TargetMetadata: - │ │ SourceElementID: 1 - │ │ SubWorkID: 1 - │ │ TableID: 104 - │ │ - │ ├── • RefreshStats - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ │ ├── • SetColumnName │ │ ColumnID: 2 │ │ Name: j @@ -122,23 +155,7 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 2 of 7; │ │ TableID: 104 │ │ │ ├── • MakeColumnPublic - │ │ ColumnID: 3 - │ │ EventBase: - │ │ Authorization: - │ │ UserName: root - │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹k› CASCADE - │ │ StatementTag: ALTER TABLE - │ │ TargetMetadata: - │ │ SourceElementID: 1 - │ │ StatementID: 1 - │ │ SubWorkID: 1 - │ │ TableID: 104 - │ │ - │ ├── • RefreshStats - │ │ TableID: 104 - │ │ - │ ├── • MakeColumnPublic - │ │ ColumnID: 4 + │ │ ColumnID: 2 │ │ EventBase: │ │ Authorization: │ │ UserName: root @@ -175,6 +192,37 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 2 of 7; │ │ IndexID: 3 │ │ TableID: 104 │ │ + │ ├── • MakeColumnPublic + │ │ ColumnID: 3 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹k› CASCADE + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ StatementID: 1 + │ │ SubWorkID: 1 + │ │ TableID: 104 + │ │ + │ ├── • RefreshStats + │ │ TableID: 104 + │ │ + │ ├── • MakeColumnPublic + │ │ ColumnID: 4 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ TableID: 104 + │ │ + │ ├── • RefreshStats + │ │ TableID: 104 + │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 104 │ │ diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_multiple_columns_separate_statements.rollback_3_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_multiple_columns_separate_statements.rollback_3_of_7 index 230bb9d974fb..436f63476a4e 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_multiple_columns_separate_statements.rollback_3_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_multiple_columns_separate_statements.rollback_3_of_7 @@ -15,10 +15,16 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 3 of 7; │ ├── • 4 elements transitioning toward ABSENT │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ │ BACKFILL_ONLY → ABSENT @@ -37,14 +43,47 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 3 of 7; │ │ ├── • Column:{DescID: 104, ColumnID: 3} │ │ │ │ WRITE_ONLY → PUBLIC │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} - │ │ │ rule: "ensure columns are in increasing order" + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: k, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnDefaultExpression:{DescID: 104, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnOnUpdateExpression:{DescID: 104, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "ensure columns are in increasing order" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 1} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: k, ColumnID: 3} │ │ │ ABSENT → PUBLIC │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 4} │ │ │ │ WRITE_ONLY → PUBLIC @@ -52,13 +91,32 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 3 of 7; │ │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 3} │ │ │ │ rule: "ensure columns are in increasing order" │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} - │ │ │ rule: "ensure columns are in increasing order" + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "ensure columns are in increasing order" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 4} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} @@ -70,38 +128,13 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 3 of 7; │ │ └── • IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} │ │ ABSENT → PUBLIC │ │ - │ └── • 18 Mutation operations + │ └── • 16 Mutation operations │ │ │ ├── • SetColumnName │ │ ColumnID: 3 │ │ Name: k │ │ TableID: 104 │ │ - │ ├── • MakeColumnPublic - │ │ ColumnID: 2 - │ │ EventBase: - │ │ Authorization: - │ │ UserName: root - │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE - │ │ StatementTag: ALTER TABLE - │ │ TargetMetadata: - │ │ SourceElementID: 1 - │ │ SubWorkID: 1 - │ │ TableID: 104 - │ │ - │ ├── • RefreshStats - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ │ ├── • SetColumnName │ │ ColumnID: 2 │ │ Name: j @@ -122,23 +155,7 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 3 of 7; │ │ TableID: 104 │ │ │ ├── • MakeColumnPublic - │ │ ColumnID: 3 - │ │ EventBase: - │ │ Authorization: - │ │ UserName: root - │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹k› CASCADE - │ │ StatementTag: ALTER TABLE - │ │ TargetMetadata: - │ │ SourceElementID: 1 - │ │ StatementID: 1 - │ │ SubWorkID: 1 - │ │ TableID: 104 - │ │ - │ ├── • RefreshStats - │ │ TableID: 104 - │ │ - │ ├── • MakeColumnPublic - │ │ ColumnID: 4 + │ │ ColumnID: 2 │ │ EventBase: │ │ Authorization: │ │ UserName: root @@ -175,6 +192,37 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 3 of 7; │ │ IndexID: 3 │ │ TableID: 104 │ │ + │ ├── • MakeColumnPublic + │ │ ColumnID: 3 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹k› CASCADE + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ StatementID: 1 + │ │ SubWorkID: 1 + │ │ TableID: 104 + │ │ + │ ├── • RefreshStats + │ │ TableID: 104 + │ │ + │ ├── • MakeColumnPublic + │ │ ColumnID: 4 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ TableID: 104 + │ │ + │ ├── • RefreshStats + │ │ TableID: 104 + │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 104 │ │ diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_multiple_columns_separate_statements.rollback_4_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_multiple_columns_separate_statements.rollback_4_of_7 index 31928ceaac83..ccccecda5617 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_multiple_columns_separate_statements.rollback_4_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_multiple_columns_separate_statements.rollback_4_of_7 @@ -15,10 +15,16 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 7; │ ├── • 4 elements transitioning toward ABSENT │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ │ DELETE_ONLY → ABSENT @@ -37,14 +43,47 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 7; │ │ ├── • Column:{DescID: 104, ColumnID: 3} │ │ │ │ WRITE_ONLY → PUBLIC │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} - │ │ │ rule: "ensure columns are in increasing order" + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: k, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnDefaultExpression:{DescID: 104, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnOnUpdateExpression:{DescID: 104, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "ensure columns are in increasing order" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 1} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: k, ColumnID: 3} │ │ │ ABSENT → PUBLIC │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 4} │ │ │ │ WRITE_ONLY → PUBLIC @@ -52,13 +91,32 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 7; │ │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 3} │ │ │ │ rule: "ensure columns are in increasing order" │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} - │ │ │ rule: "ensure columns are in increasing order" + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "ensure columns are in increasing order" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 4} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} @@ -70,38 +128,13 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 7; │ │ └── • IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} │ │ ABSENT → PUBLIC │ │ - │ └── • 18 Mutation operations + │ └── • 16 Mutation operations │ │ │ ├── • SetColumnName │ │ ColumnID: 3 │ │ Name: k │ │ TableID: 104 │ │ - │ ├── • MakeColumnPublic - │ │ ColumnID: 2 - │ │ EventBase: - │ │ Authorization: - │ │ UserName: root - │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE - │ │ StatementTag: ALTER TABLE - │ │ TargetMetadata: - │ │ SourceElementID: 1 - │ │ SubWorkID: 1 - │ │ TableID: 104 - │ │ - │ ├── • RefreshStats - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ │ ├── • SetColumnName │ │ ColumnID: 2 │ │ Name: j @@ -141,6 +174,25 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 7; │ │ TableID: 104 │ │ │ ├── • MakeColumnPublic + │ │ ColumnID: 2 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ TableID: 104 + │ │ + │ ├── • RefreshStats + │ │ TableID: 104 + │ │ + │ ├── • MakeAddedSecondaryIndexPublic + │ │ IndexID: 2 + │ │ TableID: 104 + │ │ + │ ├── • MakeColumnPublic │ │ ColumnID: 3 │ │ EventBase: │ │ Authorization: @@ -171,10 +223,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 7; │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • MakeAddedSecondaryIndexPublic - │ │ IndexID: 2 - │ │ TableID: 104 - │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 104 │ │ diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_multiple_columns_separate_statements.rollback_5_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_multiple_columns_separate_statements.rollback_5_of_7 index e02489db9dbe..59017a11e83e 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_multiple_columns_separate_statements.rollback_5_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_multiple_columns_separate_statements.rollback_5_of_7 @@ -15,10 +15,16 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 7; │ ├── • 4 elements transitioning toward ABSENT │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ MERGE_ONLY → DELETE_ONLY @@ -31,14 +37,47 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 7; │ │ ├── • Column:{DescID: 104, ColumnID: 3} │ │ │ │ WRITE_ONLY → PUBLIC │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} - │ │ │ rule: "ensure columns are in increasing order" + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: k, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnDefaultExpression:{DescID: 104, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnOnUpdateExpression:{DescID: 104, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "ensure columns are in increasing order" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 1} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: k, ColumnID: 3} │ │ │ ABSENT → PUBLIC │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 4} │ │ │ │ WRITE_ONLY → PUBLIC @@ -46,13 +85,32 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 7; │ │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 3} │ │ │ │ rule: "ensure columns are in increasing order" │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} - │ │ │ rule: "ensure columns are in increasing order" + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "ensure columns are in increasing order" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 4} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} @@ -64,55 +122,53 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 7; │ │ └── • IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} │ │ ABSENT → PUBLIC │ │ - │ └── • 17 Mutation operations + │ └── • 15 Mutation operations │ │ │ ├── • SetColumnName │ │ ColumnID: 3 │ │ Name: k │ │ TableID: 104 │ │ - │ ├── • MakeColumnPublic + │ ├── • SetColumnName │ │ ColumnID: 2 - │ │ EventBase: - │ │ Authorization: - │ │ UserName: root - │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE - │ │ StatementTag: ALTER TABLE - │ │ TargetMetadata: - │ │ SourceElementID: 1 - │ │ SubWorkID: 1 + │ │ Name: j │ │ TableID: 104 │ │ - │ ├── • RefreshStats + │ ├── • SetColumnName + │ │ ColumnID: 4 + │ │ Name: crdb_internal_idx_expr │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 + │ ├── • SetIndexName + │ │ IndexID: 2 + │ │ Name: t_expr_k_idx │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 + │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 4 │ │ TableID: 104 │ │ - │ ├── • SetColumnName + │ ├── • MakeColumnPublic │ │ ColumnID: 2 - │ │ Name: j + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 │ │ TableID: 104 │ │ - │ ├── • SetColumnName - │ │ ColumnID: 4 - │ │ Name: crdb_internal_idx_expr + │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • SetIndexName + │ ├── • MakeAddedSecondaryIndexPublic │ │ IndexID: 2 - │ │ Name: t_expr_k_idx │ │ TableID: 104 │ │ │ ├── • MakeDroppedIndexDeleteOnly - │ │ IndexID: 4 + │ │ IndexID: 3 │ │ TableID: 104 │ │ │ ├── • MakeColumnPublic @@ -146,14 +202,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 7; │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • MakeAddedSecondaryIndexPublic - │ │ IndexID: 2 - │ │ TableID: 104 - │ │ - │ ├── • MakeDroppedIndexDeleteOnly - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 104 │ │ diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_multiple_columns_separate_statements.rollback_6_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_multiple_columns_separate_statements.rollback_6_of_7 index b724c0dae4dc..e35e72f2c47f 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_multiple_columns_separate_statements.rollback_6_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_multiple_columns_separate_statements.rollback_6_of_7 @@ -15,10 +15,16 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 7; │ ├── • 4 elements transitioning toward ABSENT │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ MERGE_ONLY → DELETE_ONLY @@ -31,14 +37,47 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 7; │ │ ├── • Column:{DescID: 104, ColumnID: 3} │ │ │ │ WRITE_ONLY → PUBLIC │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} - │ │ │ rule: "ensure columns are in increasing order" + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: k, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnDefaultExpression:{DescID: 104, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnOnUpdateExpression:{DescID: 104, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "ensure columns are in increasing order" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 1} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: k, ColumnID: 3} │ │ │ ABSENT → PUBLIC │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 4} │ │ │ │ WRITE_ONLY → PUBLIC @@ -46,13 +85,32 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 7; │ │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 3} │ │ │ │ rule: "ensure columns are in increasing order" │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} - │ │ │ rule: "ensure columns are in increasing order" + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "ensure columns are in increasing order" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 4} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} @@ -64,55 +122,53 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 7; │ │ └── • IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} │ │ ABSENT → PUBLIC │ │ - │ └── • 17 Mutation operations + │ └── • 15 Mutation operations │ │ │ ├── • SetColumnName │ │ ColumnID: 3 │ │ Name: k │ │ TableID: 104 │ │ - │ ├── • MakeColumnPublic + │ ├── • SetColumnName │ │ ColumnID: 2 - │ │ EventBase: - │ │ Authorization: - │ │ UserName: root - │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE - │ │ StatementTag: ALTER TABLE - │ │ TargetMetadata: - │ │ SourceElementID: 1 - │ │ SubWorkID: 1 + │ │ Name: j │ │ TableID: 104 │ │ - │ ├── • RefreshStats + │ ├── • SetColumnName + │ │ ColumnID: 4 + │ │ Name: crdb_internal_idx_expr │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 + │ ├── • SetIndexName + │ │ IndexID: 2 + │ │ Name: t_expr_k_idx │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 + │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 4 │ │ TableID: 104 │ │ - │ ├── • SetColumnName + │ ├── • MakeColumnPublic │ │ ColumnID: 2 - │ │ Name: j + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 │ │ TableID: 104 │ │ - │ ├── • SetColumnName - │ │ ColumnID: 4 - │ │ Name: crdb_internal_idx_expr + │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • SetIndexName + │ ├── • MakeAddedSecondaryIndexPublic │ │ IndexID: 2 - │ │ Name: t_expr_k_idx │ │ TableID: 104 │ │ │ ├── • MakeDroppedIndexDeleteOnly - │ │ IndexID: 4 + │ │ IndexID: 3 │ │ TableID: 104 │ │ │ ├── • MakeColumnPublic @@ -146,14 +202,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 7; │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • MakeAddedSecondaryIndexPublic - │ │ IndexID: 2 - │ │ TableID: 104 - │ │ - │ ├── • MakeDroppedIndexDeleteOnly - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 104 │ │ diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_multiple_columns_separate_statements.rollback_7_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_multiple_columns_separate_statements.rollback_7_of_7 index e8d51b766136..c386157dc870 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_multiple_columns_separate_statements.rollback_7_of_7 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_multiple_columns_separate_statements.rollback_7_of_7 @@ -15,10 +15,16 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ ├── • 4 elements transitioning toward ABSENT │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} │ │ │ WRITE_ONLY → DELETE_ONLY @@ -31,14 +37,47 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ │ ├── • Column:{DescID: 104, ColumnID: 3} │ │ │ │ WRITE_ONLY → PUBLIC │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} - │ │ │ rule: "ensure columns are in increasing order" + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: k, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnDefaultExpression:{DescID: 104, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnOnUpdateExpression:{DescID: 104, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "ensure columns are in increasing order" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 1} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: k, ColumnID: 3} │ │ │ ABSENT → PUBLIC │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} - │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: j, ColumnID: 2} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 4} │ │ │ │ WRITE_ONLY → PUBLIC @@ -46,13 +85,32 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 3} │ │ │ │ rule: "ensure columns are in increasing order" │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} - │ │ │ rule: "ensure columns are in increasing order" + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "ensure columns are in increasing order" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 4} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} + │ │ │ rule: "column dependents exist before column becomes public" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ │ VALIDATED → PUBLIC │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: j, ColumnID: 2} @@ -64,38 +122,13 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ │ └── • IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} │ │ ABSENT → PUBLIC │ │ - │ └── • 17 Mutation operations + │ └── • 15 Mutation operations │ │ │ ├── • SetColumnName │ │ ColumnID: 3 │ │ Name: k │ │ TableID: 104 │ │ - │ ├── • MakeColumnPublic - │ │ ColumnID: 2 - │ │ EventBase: - │ │ Authorization: - │ │ UserName: root - │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE - │ │ StatementTag: ALTER TABLE - │ │ TargetMetadata: - │ │ SourceElementID: 1 - │ │ SubWorkID: 1 - │ │ TableID: 104 - │ │ - │ ├── • RefreshStats - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 3 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 4 - │ │ TableID: 104 - │ │ │ ├── • SetColumnName │ │ ColumnID: 2 │ │ Name: j @@ -120,6 +153,25 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ │ TableID: 104 │ │ │ ├── • MakeColumnPublic + │ │ ColumnID: 2 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.public.‹t› DROP COLUMN ‹j› CASCADE + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ TableID: 104 + │ │ + │ ├── • RefreshStats + │ │ TableID: 104 + │ │ + │ ├── • MakeAddedSecondaryIndexPublic + │ │ IndexID: 2 + │ │ TableID: 104 + │ │ + │ ├── • MakeColumnPublic │ │ ColumnID: 3 │ │ EventBase: │ │ Authorization: @@ -150,10 +202,6 @@ EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; │ ├── • RefreshStats │ │ TableID: 104 │ │ - │ ├── • MakeAddedSecondaryIndexPublic - │ │ IndexID: 2 - │ │ TableID: 104 - │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 104 │ │ diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_multiple_columns_separate_statements.statement_1_of_2 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_multiple_columns_separate_statements.statement_1_of_2 index cfdfc1ec1c1e..f35c6c887d52 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_multiple_columns_separate_statements.statement_1_of_2 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_multiple_columns_separate_statements.statement_1_of_2 @@ -19,16 +19,19 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j CASCADE; │ │ │ │ PUBLIC → ABSENT │ │ │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 2} -│ │ │ rule: "column dependents removed after column no longer public" +│ │ │ rule: "column no longer public before dependents" │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 4} -│ │ │ PUBLIC → WRITE_ONLY +│ │ │ │ PUBLIC → WRITE_ONLY +│ │ │ │ +│ │ │ └── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} +│ │ │ rule: "secondary indexes containing column as key reach write-only before column" │ │ │ │ │ ├── • ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} │ │ │ │ PUBLIC → ABSENT │ │ │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 4} -│ │ │ rule: "column dependents removed after column no longer public" +│ │ │ rule: "column no longer public before dependents" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ PUBLIC → VALIDATED @@ -37,43 +40,41 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j CASCADE; │ │ │ PUBLIC → ABSENT │ │ │ │ │ └── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} -│ │ rule: "index no longer public before dependents removed" +│ │ rule: "index no longer public before dependents" │ │ -│ ├── • 5 elements transitioning toward PUBLIC +│ ├── • 3 elements transitioning toward PUBLIC +│ │ │ +│ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} +│ │ │ ABSENT → BACKFILL_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} │ │ │ │ ABSENT → PUBLIC │ │ │ │ │ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} -│ │ │ rule: "index-column added to index after index exists" +│ │ │ rule: "index existence precedes index dependents" │ │ │ -│ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} -│ │ │ │ ABSENT → PUBLIC -│ │ │ │ -│ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} -│ │ │ rule: "index-column added to index after index exists" +│ │ └── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} +│ │ │ ABSENT → PUBLIC +│ │ │ +│ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} +│ │ rule: "index existence precedes index dependents" +│ │ +│ ├── • 3 elements transitioning toward TRANSIENT_ABSENT │ │ │ -│ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} -│ │ │ ABSENT → BACKFILL_ONLY +│ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} +│ │ │ ABSENT → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} │ │ │ │ ABSENT → PUBLIC │ │ │ │ │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} -│ │ │ rule: "temp index exists before columns, partitioning, and partial" -│ │ │ rule: "index-column added to index after temp index exists" +│ │ │ rule: "temp index existence precedes index dependents" │ │ │ │ │ └── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4} │ │ │ ABSENT → PUBLIC │ │ │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} -│ │ rule: "temp index exists before columns, partitioning, and partial" -│ │ rule: "index-column added to index after temp index exists" -│ │ -│ ├── • 1 element transitioning toward TRANSIENT_ABSENT -│ │ │ -│ │ └── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} -│ │ ABSENT → DELETE_ONLY +│ │ rule: "temp index existence precedes index dependents" │ │ │ └── • 14 Mutation operations │ │ @@ -102,32 +103,6 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j CASCADE; │ │ Name: crdb_internal_column_2_name_placeholder │ │ TableID: 104 │ │ -│ ├── • MakeDroppedColumnDeleteAndWriteOnly -│ │ ColumnID: 4 -│ │ TableID: 104 -│ │ -│ ├── • LogEvent -│ │ Element: -│ │ Column: -│ │ columnId: 4 -│ │ isInaccessible: true -│ │ pgAttributeNum: 4 -│ │ tableId: 104 -│ │ EventBase: -│ │ Authorization: -│ │ UserName: root -│ │ Statement: ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COLUMN ‹j› CASCADE -│ │ StatementTag: ALTER TABLE -│ │ TargetMetadata: -│ │ SourceElementID: 1 -│ │ SubWorkID: 1 -│ │ TargetStatus: 1 -│ │ -│ ├── • SetColumnName -│ │ ColumnID: 4 -│ │ Name: crdb_internal_column_4_name_placeholder -│ │ TableID: 104 -│ │ │ ├── • MakeDroppedNonPrimaryIndexDeleteAndWriteOnly │ │ IndexID: 2 │ │ TableID: 104 @@ -146,6 +121,17 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j CASCADE; │ │ TableID: 104 │ │ TemporaryIndexID: 4 │ │ +│ ├── • AddColumnToIndex +│ │ ColumnID: 1 +│ │ IndexID: 3 +│ │ TableID: 104 +│ │ +│ ├── • AddColumnToIndex +│ │ ColumnID: 3 +│ │ IndexID: 3 +│ │ Kind: 2 +│ │ TableID: 104 +│ │ │ ├── • MakeAddedTempIndexDeleteOnly │ │ Index: │ │ ConstraintID: 3 @@ -165,15 +151,30 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j CASCADE; │ │ Kind: 2 │ │ TableID: 104 │ │ -│ ├── • AddColumnToIndex -│ │ ColumnID: 1 -│ │ IndexID: 3 +│ ├── • MakeDroppedColumnDeleteAndWriteOnly +│ │ ColumnID: 4 │ │ TableID: 104 │ │ -│ └── • AddColumnToIndex -│ ColumnID: 3 -│ IndexID: 3 -│ Kind: 2 +│ ├── • LogEvent +│ │ Element: +│ │ Column: +│ │ columnId: 4 +│ │ isInaccessible: true +│ │ pgAttributeNum: 4 +│ │ tableId: 104 +│ │ EventBase: +│ │ Authorization: +│ │ UserName: root +│ │ Statement: ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COLUMN ‹j› CASCADE +│ │ StatementTag: ALTER TABLE +│ │ TargetMetadata: +│ │ SourceElementID: 1 +│ │ SubWorkID: 1 +│ │ TargetStatus: 1 +│ │ +│ └── • SetColumnName +│ ColumnID: 4 +│ Name: crdb_internal_column_4_name_placeholder │ TableID: 104 │ ├── • PreCommitPhase @@ -351,20 +352,32 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j CASCADE; │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 1} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} │ │ │ PUBLIC → WRITE_ONLY @@ -373,34 +386,37 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j CASCADE; │ │ │ │ PUBLIC → ABSENT │ │ │ │ │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ rule: "index no longer public before dependents" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 4} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ ├── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ │ │ │ rule: "index no longer public before dependents" │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ ├── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ │ │ │ rule: "index no longer public before dependents" │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ ├── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ │ │ │ rule: "index no longer public before dependents" │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ VALIDATED → DELETE_ONLY @@ -413,21 +429,40 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j CASCADE; │ │ │ ├── • SameStagePrecedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} │ │ │ │ rule: "primary index swap" │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} - │ │ │ rule: "index named right before index becomes public" + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ rule: "index named right before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ │ │ └── • IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} │ │ │ ABSENT → PUBLIC │ │ │ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} - │ │ rule: "index existence precedes index name and comment" + │ │ rule: "index existence precedes index dependents" │ │ - │ ├── • 1 element transitioning toward TRANSIENT_ABSENT + │ ├── • 3 elements transitioning toward TRANSIENT_ABSENT │ │ │ - │ │ └── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} - │ │ WRITE_ONLY → TRANSIENT_DELETE_ONLY + │ │ ├── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} + │ │ │ WRITE_ONLY → TRANSIENT_DELETE_ONLY + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ │ │ PUBLIC → TRANSIENT_ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → TRANSIENT_ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" + │ │ │ + │ │ └── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4} + │ │ │ PUBLIC → TRANSIENT_ABSENT + │ │ │ + │ │ └── • skip PUBLIC → TRANSIENT_ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ - │ └── • 16 Mutation operations + │ └── • 10 Mutation operations │ │ │ ├── • MakeDroppedColumnDeleteOnly │ │ ColumnID: 2 @@ -455,24 +490,6 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j CASCADE; │ │ IndexID: 4 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 1 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 1 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 1 - │ │ Kind: 2 - │ │ Ordinal: 1 - │ │ TableID: 104 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 2 │ │ TableID: 104 @@ -489,55 +506,131 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j CASCADE; │ │ IndexID: 3 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 4 - │ │ IndexID: 2 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 2 - │ │ Ordinal: 1 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ Kind: 1 - │ │ TableID: 104 - │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 104 │ │ │ └── • UpdateSchemaChangerJob │ IsNonCancelable: true │ JobID: 1 - │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 3 with 1 MutationType op pending + │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 3 with 7 MutationType ops pending │ ├── • Stage 2 of 3 in PostCommitNonRevertiblePhase │ │ - │ ├── • 1 element transitioning toward ABSENT + │ ├── • 4 elements transitioning toward ABSENT │ │ │ - │ │ └── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ WRITE_ONLY → DELETE_ONLY + │ │ ├── • Column:{DescID: 104, ColumnID: 4} + │ │ │ │ DELETE_ONLY → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} + │ │ │ │ rule: "dependents removed before column" + │ │ │ │ + │ │ │ ├── • SameStagePrecedence dependency from ABSENT ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 4} + │ │ │ │ rule: "dependents removed before column" + │ │ │ │ rule: "column type removed right before column when not dropping relation" + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "dependents removed before column" + │ │ │ │ + │ │ │ └── • Precedence dependency from ABSENT SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ │ │ rule: "indexes containing column reach absent before column" + │ │ │ + │ │ ├── • ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 4} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 4} + │ │ │ rule: "column no longer public before dependents" + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ + │ │ └── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} + │ │ rule: "dependents removed before index" │ │ - │ └── • 3 Mutation operations + │ ├── • 1 element transitioning toward TRANSIENT_ABSENT + │ │ │ + │ │ └── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} + │ │ │ TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT + │ │ │ + │ │ ├── • Precedence dependency from TRANSIENT_ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from TRANSIENT_ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4} + │ │ rule: "dependents removed before index" + │ │ + │ └── • 9 Mutation operations │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 1 │ │ TableID: 104 │ │ + │ ├── • LogEvent + │ │ Element: + │ │ SecondaryIndex: + │ │ indexId: 2 + │ │ tableId: 104 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COLUMN ‹j› CASCADE + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ TargetStatus: 1 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 2 + │ │ StatementForDropJob: + │ │ Statement: ALTER TABLE defaultdb.public.t DROP COLUMN j CASCADE + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ IndexID: 2 + │ │ TableID: 104 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 4 + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ IndexID: 4 + │ │ TableID: 104 + │ │ + │ ├── • MakeColumnAbsent + │ │ ColumnID: 4 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COLUMN ‹j› CASCADE + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ TableID: 104 + │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 104 │ │ │ └── • UpdateSchemaChangerJob │ IsNonCancelable: true │ JobID: 1 - │ RunningStatus: PostCommitNonRevertiblePhase stage 3 of 3 with 9 MutationType ops pending + │ RunningStatus: PostCommitNonRevertiblePhase stage 3 of 3 with 3 MutationType ops pending │ └── • Stage 3 of 3 in PostCommitNonRevertiblePhase │ - ├── • 6 elements transitioning toward ABSENT + ├── • 3 elements transitioning toward ABSENT │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} │ │ │ DELETE_ONLY → ABSENT @@ -549,87 +642,34 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j CASCADE; │ │ │ rule: "dependents removed before column" │ │ │ rule: "column type removed right before column when not dropping relation" │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ rule: "dependents removed before column" + │ │ │ │ │ └── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ rule: "indexes containing columns reach absent before column" + │ │ rule: "indexes containing column reach absent before column" │ │ │ ├── • ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 2} │ │ │ PUBLIC → ABSENT │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 2} - │ │ rule: "column dependents removed after column no longer public" - │ │ - │ ├── • Column:{DescID: 104, ColumnID: 4} - │ │ │ DELETE_ONLY → ABSENT - │ │ │ - │ │ ├── • Precedence dependency from ABSENT ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} - │ │ │ rule: "dependents removed before column" - │ │ │ - │ │ ├── • SameStagePrecedence dependency from ABSENT ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 4} - │ │ │ rule: "dependents removed before column" - │ │ │ rule: "column type removed right before column when not dropping relation" - │ │ │ - │ │ └── • Precedence dependency from ABSENT SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ rule: "indexes containing columns reach absent before column" - │ │ - │ ├── • ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 4} - │ │ │ PUBLIC → ABSENT - │ │ │ - │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 4} - │ │ rule: "column dependents removed after column no longer public" - │ │ - │ ├── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ │ DELETE_ONLY → ABSENT - │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1} - │ │ │ rule: "dependents removed before index" - │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} - │ │ │ rule: "dependents removed before index" - │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 1} - │ │ │ rule: "dependents removed before index" - │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} - │ │ │ rule: "dependents removed before index" - │ │ │ - │ │ └── • SameStagePrecedence dependency from TRANSIENT_ABSENT TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} - │ │ rule: "temp indexes reach absent at the same time as other indexes" + │ │ rule: "column no longer public before dependents" │ │ - │ └── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ └── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} │ │ DELETE_ONLY → ABSENT │ │ - │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} - │ │ rule: "secondary index columns removed before removing the index" + │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1} │ │ rule: "dependents removed before index" │ │ - │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} - │ │ rule: "secondary index columns removed before removing the index" + │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} │ │ rule: "dependents removed before index" │ │ - │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} - │ │ rule: "secondary index columns removed before removing the index" + │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 1} │ │ rule: "dependents removed before index" │ │ - │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} - │ │ rule: "dependents removed before index" - │ │ - │ └── • SameStagePrecedence dependency from TRANSIENT_ABSENT TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} - │ rule: "temp indexes reach absent at the same time as other indexes" - │ - ├── • 1 element transitioning toward TRANSIENT_ABSENT - │ │ - │ └── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} - │ TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT + │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} + │ rule: "dependents removed before index" │ - └── • 11 Mutation operations - │ - ├── • CreateGcJobForIndex - │ IndexID: 4 - │ TableID: 104 - │ - ├── • MakeIndexAbsent - │ IndexID: 4 - │ TableID: 104 + └── • 5 Mutation operations │ ├── • CreateGcJobForIndex │ IndexID: 1 @@ -649,31 +689,6 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j CASCADE; │ IndexID: 1 │ TableID: 104 │ - ├── • LogEvent - │ Element: - │ SecondaryIndex: - │ indexId: 2 - │ tableId: 104 - │ EventBase: - │ Authorization: - │ UserName: root - │ Statement: ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COLUMN ‹j› CASCADE - │ StatementTag: ALTER TABLE - │ TargetMetadata: - │ SourceElementID: 1 - │ SubWorkID: 1 - │ TargetStatus: 1 - │ - ├── • CreateGcJobForIndex - │ IndexID: 2 - │ StatementForDropJob: - │ Statement: ALTER TABLE defaultdb.public.t DROP COLUMN j CASCADE - │ TableID: 104 - │ - ├── • MakeIndexAbsent - │ IndexID: 2 - │ TableID: 104 - │ ├── • MakeColumnAbsent │ ColumnID: 2 │ EventBase: @@ -686,18 +701,6 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN j CASCADE; │ SubWorkID: 1 │ TableID: 104 │ - ├── • MakeColumnAbsent - │ ColumnID: 4 - │ EventBase: - │ Authorization: - │ UserName: root - │ Statement: ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COLUMN ‹j› CASCADE - │ StatementTag: ALTER TABLE - │ TargetMetadata: - │ SourceElementID: 1 - │ SubWorkID: 1 - │ TableID: 104 - │ ├── • RemoveJobStateFromDescriptor │ DescriptorID: 104 │ JobID: 1 diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_multiple_columns_separate_statements.statement_2_of_2 b/pkg/sql/schemachanger/testdata/explain_verbose/drop_multiple_columns_separate_statements.statement_2_of_2 index fba8a52a838f..2d856b577e53 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_multiple_columns_separate_statements.statement_2_of_2 +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_multiple_columns_separate_statements.statement_2_of_2 @@ -14,13 +14,16 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN k CASCADE; │ ├── • 2 elements transitioning toward ABSENT │ │ │ │ │ ├── • Column:{DescID: 104, ColumnID: 3} -│ │ │ PUBLIC → WRITE_ONLY +│ │ │ │ PUBLIC → WRITE_ONLY +│ │ │ │ +│ │ │ └── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} +│ │ │ rule: "secondary indexes containing column as key reach write-only before column" │ │ │ │ │ └── • ColumnName:{DescID: 104, Name: k, ColumnID: 3} │ │ │ PUBLIC → ABSENT │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 3} -│ │ rule: "column dependents removed after column no longer public" +│ │ rule: "column no longer public before dependents" │ │ │ └── • 3 Mutation operations │ │ @@ -225,20 +228,35 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN k CASCADE; │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 2} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 1} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 3} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} │ │ │ PUBLIC → WRITE_ONLY @@ -247,43 +265,58 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN k CASCADE; │ │ │ │ PUBLIC → ABSENT │ │ │ │ │ │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ rule: "index no longer public before dependents" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 4} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ ├── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ │ │ │ rule: "index no longer public before dependents" │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 3} + │ │ │ │ rule: "column no longer public before dependents" │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ ├── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ │ │ │ rule: "index no longer public before dependents" + │ │ │ │ + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ ├── • Precedence dependency from DELETE_ONLY SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ │ rule: "secondary index in DELETE_ONLY before removing columns" + │ │ │ ├── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ │ │ │ rule: "index no longer public before dependents" │ │ │ │ - │ │ │ └── • Precedence dependency from VALIDATED SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ └── • skip PUBLIC → ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} │ │ │ VALIDATED → DELETE_ONLY │ │ │ │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} - │ │ │ PUBLIC → ABSENT + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 3} + │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ └── • IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 3} + │ │ │ rule: "column no longer public before dependents" + │ │ │ + │ │ └── • skip PUBLIC → ABSENT operations + │ │ rule: "skip index-column removal ops on index removal" │ │ │ ├── • 2 elements transitioning toward PUBLIC │ │ │ @@ -293,21 +326,31 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN k CASCADE; │ │ │ ├── • SameStagePrecedence dependency from VALIDATED PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} │ │ │ │ rule: "primary index swap" │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 3} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} + │ │ │ rule: "index dependents exist before index becomes public" │ │ │ rule: "index named right before index becomes public" │ │ │ │ │ └── • IndexName:{DescID: 104, Name: t_pkey, IndexID: 3} │ │ │ ABSENT → PUBLIC │ │ │ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 104, IndexID: 3, ConstraintID: 2, TemporaryIndexID: 4, SourceIndexID: 1} - │ │ rule: "index existence precedes index name and comment" + │ │ rule: "index existence precedes index dependents" │ │ - │ ├── • 1 element transitioning toward TRANSIENT_ABSENT + │ ├── • 2 elements transitioning toward TRANSIENT_ABSENT + │ │ │ + │ │ ├── • IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ │ │ PUBLIC → TRANSIENT_ABSENT + │ │ │ │ + │ │ │ └── • skip PUBLIC → TRANSIENT_ABSENT operations + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ └── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} │ │ WRITE_ONLY → TRANSIENT_DELETE_ONLY │ │ - │ └── • 19 Mutation operations + │ └── • 12 Mutation operations │ │ │ ├── • MakeDroppedColumnDeleteOnly │ │ ColumnID: 3 @@ -336,12 +379,6 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN k CASCADE; │ │ Kind: 2 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 4 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ │ ├── • SetIndexName │ │ IndexID: 3 │ │ Name: t_pkey @@ -351,24 +388,6 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN k CASCADE; │ │ IndexID: 4 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 1 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 2 - │ │ IndexID: 1 - │ │ Kind: 2 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 1 - │ │ Kind: 2 - │ │ Ordinal: 1 - │ │ TableID: 104 - │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 2 │ │ TableID: 104 @@ -385,56 +404,131 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN k CASCADE; │ │ IndexID: 3 │ │ TableID: 104 │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 4 - │ │ IndexID: 2 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 3 - │ │ IndexID: 2 - │ │ Ordinal: 1 - │ │ TableID: 104 - │ │ - │ ├── • RemoveColumnFromIndex - │ │ ColumnID: 1 - │ │ IndexID: 2 - │ │ Kind: 1 - │ │ TableID: 104 - │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 104 │ │ │ └── • UpdateSchemaChangerJob │ IsNonCancelable: true │ JobID: 1 - │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 3 with 1 MutationType op pending + │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 3 with 7 MutationType ops pending │ ├── • Stage 2 of 3 in PostCommitNonRevertiblePhase │ │ - │ ├── • 1 element transitioning toward ABSENT + │ ├── • 4 elements transitioning toward ABSENT + │ │ │ + │ │ ├── • Column:{DescID: 104, ColumnID: 4} + │ │ │ │ DELETE_ONLY → ABSENT + │ │ │ │ + │ │ │ ├── • SameStagePrecedence dependency from ABSENT ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 4} + │ │ │ │ rule: "dependents removed before column" + │ │ │ │ rule: "column type removed right before column when not dropping relation" + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ │ rule: "dependents removed before column" + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ │ │ │ rule: "indexes containing column reach absent before column" + │ │ │ │ + │ │ │ └── • Precedence dependency from ABSENT ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 4} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 4} + │ │ │ rule: "column no longer public before dependents" + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} + │ │ │ WRITE_ONLY → DELETE_ONLY │ │ │ - │ │ └── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ WRITE_ONLY → DELETE_ONLY + │ │ └── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} + │ │ rule: "dependents removed before index" │ │ - │ └── • 3 Mutation operations + │ ├── • 1 element transitioning toward TRANSIENT_ABSENT + │ │ │ + │ │ └── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} + │ │ │ TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT + │ │ │ + │ │ ├── • Precedence dependency from TRANSIENT_ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4} + │ │ rule: "dependents removed before index" + │ │ + │ └── • 9 Mutation operations │ │ │ ├── • MakeDroppedIndexDeleteOnly │ │ IndexID: 1 │ │ TableID: 104 │ │ + │ ├── • LogEvent + │ │ Element: + │ │ SecondaryIndex: + │ │ indexId: 2 + │ │ tableId: 104 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COLUMN ‹j› CASCADE + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ TargetStatus: 1 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 2 + │ │ StatementForDropJob: + │ │ Statement: ALTER TABLE defaultdb.public.t DROP COLUMN j CASCADE + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ IndexID: 2 + │ │ TableID: 104 + │ │ + │ ├── • CreateGcJobForIndex + │ │ IndexID: 4 + │ │ TableID: 104 + │ │ + │ ├── • MakeIndexAbsent + │ │ IndexID: 4 + │ │ TableID: 104 + │ │ + │ ├── • MakeColumnAbsent + │ │ ColumnID: 4 + │ │ EventBase: + │ │ Authorization: + │ │ UserName: root + │ │ Statement: ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COLUMN ‹j› CASCADE + │ │ StatementTag: ALTER TABLE + │ │ TargetMetadata: + │ │ SourceElementID: 1 + │ │ SubWorkID: 1 + │ │ TableID: 104 + │ │ │ ├── • SetJobStateOnDescriptor │ │ DescriptorID: 104 │ │ │ └── • UpdateSchemaChangerJob │ IsNonCancelable: true │ JobID: 1 - │ RunningStatus: PostCommitNonRevertiblePhase stage 3 of 3 with 12 MutationType ops - │ pending + │ RunningStatus: PostCommitNonRevertiblePhase stage 3 of 3 with 6 MutationType ops pending │ └── • Stage 3 of 3 in PostCommitNonRevertiblePhase │ - ├── • 10 elements transitioning toward ABSENT + ├── • 7 elements transitioning toward ABSENT │ │ │ ├── • Column:{DescID: 104, ColumnID: 3} │ │ │ DELETE_ONLY → ABSENT @@ -446,17 +540,35 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN k CASCADE; │ │ │ rule: "dependents removed before column" │ │ │ rule: "column type removed right before column when not dropping relation" │ │ │ + │ │ ├── • Precedence dependency from ABSENT ColumnDefaultExpression:{DescID: 104, ColumnID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT ColumnOnUpdateExpression:{DescID: 104, ColumnID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 1} + │ │ │ rule: "dependents removed before column" + │ │ │ │ │ ├── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ │ rule: "indexes containing columns reach absent before column" + │ │ │ rule: "indexes containing column reach absent before column" │ │ │ - │ │ └── • Precedence dependency from ABSENT SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ rule: "indexes containing columns reach absent before column" + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ │ │ rule: "indexes containing column reach absent before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4} + │ │ rule: "dependents removed before column" │ │ │ ├── • ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 3} │ │ │ PUBLIC → ABSENT │ │ │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 3} - │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ ├── • SameStagePrecedence dependency from ABSENT ColumnDefaultExpression:{DescID: 104, ColumnID: 3} │ │ │ rule: "column type dependents removed right before column type" @@ -465,10 +577,16 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN k CASCADE; │ │ rule: "column type dependents removed right before column type" │ │ │ ├── • ColumnDefaultExpression:{DescID: 104, ColumnID: 3} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 3} + │ │ rule: "column no longer public before dependents" │ │ │ ├── • ColumnOnUpdateExpression:{DescID: 104, ColumnID: 3} - │ │ PUBLIC → ABSENT + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 3} + │ │ rule: "column no longer public before dependents" │ │ │ ├── • Column:{DescID: 104, ColumnID: 2} │ │ │ DELETE_ONLY → ABSENT @@ -477,8 +595,11 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN k CASCADE; │ │ │ rule: "dependents removed before column" │ │ │ rule: "column type removed right before column when not dropping relation" │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} + │ │ │ rule: "dependents removed before column" + │ │ │ │ │ ├── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ │ rule: "indexes containing columns reach absent before column" + │ │ │ rule: "indexes containing column reach absent before column" │ │ │ │ │ └── • Precedence dependency from ABSENT ColumnName:{DescID: 104, Name: j, ColumnID: 2} │ │ rule: "dependents removed before column" @@ -487,80 +608,24 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN k CASCADE; │ │ │ PUBLIC → ABSENT │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 2} - │ │ rule: "column dependents removed after column no longer public" - │ │ - │ ├── • Column:{DescID: 104, ColumnID: 4} - │ │ │ DELETE_ONLY → ABSENT - │ │ │ - │ │ ├── • SameStagePrecedence dependency from ABSENT ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 4} - │ │ │ rule: "dependents removed before column" - │ │ │ rule: "column type removed right before column when not dropping relation" - │ │ │ - │ │ ├── • Precedence dependency from ABSENT SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} - │ │ │ rule: "indexes containing columns reach absent before column" - │ │ │ - │ │ └── • Precedence dependency from ABSENT ColumnName:{DescID: 104, Name: crdb_internal_idx_expr, ColumnID: 4} - │ │ rule: "dependents removed before column" - │ │ - │ ├── • ColumnType:{DescID: 104, ColumnFamilyID: 0, ColumnID: 4} - │ │ │ PUBLIC → ABSENT - │ │ │ - │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 104, ColumnID: 4} - │ │ rule: "column dependents removed after column no longer public" + │ │ rule: "column no longer public before dependents" │ │ - │ ├── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} - │ │ │ DELETE_ONLY → ABSENT - │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1} - │ │ │ rule: "dependents removed before index" - │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} - │ │ │ rule: "dependents removed before index" - │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 1} - │ │ │ rule: "dependents removed before index" - │ │ │ - │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} - │ │ │ rule: "dependents removed before index" - │ │ │ - │ │ └── • SameStagePrecedence dependency from TRANSIENT_ABSENT TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} - │ │ rule: "temp indexes reach absent at the same time as other indexes" - │ │ - │ └── • SecondaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 0} + │ └── • PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1} │ │ DELETE_ONLY → ABSENT │ │ - │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 4, IndexID: 2} - │ │ rule: "secondary index columns removed before removing the index" + │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 1} │ │ rule: "dependents removed before index" │ │ - │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2} - │ │ rule: "secondary index columns removed before removing the index" + │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 2, IndexID: 1} │ │ rule: "dependents removed before index" │ │ - │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 2} - │ │ rule: "secondary index columns removed before removing the index" + │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 1} │ │ rule: "dependents removed before index" │ │ - │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_expr_k_idx, IndexID: 2} - │ │ rule: "dependents removed before index" - │ │ - │ └── • SameStagePrecedence dependency from TRANSIENT_ABSENT TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} - │ rule: "temp indexes reach absent at the same time as other indexes" - │ - ├── • 1 element transitioning toward TRANSIENT_ABSENT - │ │ - │ └── • TemporaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 3, SourceIndexID: 1} - │ TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT + │ └── • Precedence dependency from ABSENT IndexName:{DescID: 104, Name: t_pkey, IndexID: 1} + │ rule: "dependents removed before index" │ - └── • 14 Mutation operations - │ - ├── • CreateGcJobForIndex - │ IndexID: 4 - │ TableID: 104 - │ - ├── • MakeIndexAbsent - │ IndexID: 4 - │ TableID: 104 + └── • 8 Mutation operations │ ├── • CreateGcJobForIndex │ IndexID: 1 @@ -580,31 +645,6 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN k CASCADE; │ IndexID: 1 │ TableID: 104 │ - ├── • LogEvent - │ Element: - │ SecondaryIndex: - │ indexId: 2 - │ tableId: 104 - │ EventBase: - │ Authorization: - │ UserName: root - │ Statement: ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COLUMN ‹j› CASCADE - │ StatementTag: ALTER TABLE - │ TargetMetadata: - │ SourceElementID: 1 - │ SubWorkID: 1 - │ TargetStatus: 1 - │ - ├── • CreateGcJobForIndex - │ IndexID: 2 - │ StatementForDropJob: - │ Statement: ALTER TABLE defaultdb.public.t DROP COLUMN j CASCADE - │ TableID: 104 - │ - ├── • MakeIndexAbsent - │ IndexID: 2 - │ TableID: 104 - │ ├── • RemoveColumnDefaultExpression │ ColumnID: 3 │ TableID: 104 @@ -626,18 +666,6 @@ EXPLAIN (ddl, verbose) ALTER TABLE t DROP COLUMN k CASCADE; │ TableID: 104 │ ├── • MakeColumnAbsent - │ ColumnID: 4 - │ EventBase: - │ Authorization: - │ UserName: root - │ Statement: ALTER TABLE ‹defaultdb›.‹public›.‹t› DROP COLUMN ‹j› CASCADE - │ StatementTag: ALTER TABLE - │ TargetMetadata: - │ SourceElementID: 1 - │ SubWorkID: 1 - │ TableID: 104 - │ - ├── • MakeColumnAbsent │ ColumnID: 3 │ EventBase: │ Authorization: diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_table b/pkg/sql/schemachanger/testdata/explain_verbose/drop_table index 50e8f201db97..9e8e6d5b1379 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_table +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_table @@ -153,7 +153,7 @@ EXPLAIN (ddl, verbose) DROP TABLE db.sc.t; │ │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 107, ColumnID: 1} - │ │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ │ │ └── • skip PUBLIC → ABSENT operations │ │ │ rule: "skip column dependents removal ops on relation drop" @@ -165,7 +165,7 @@ EXPLAIN (ddl, verbose) DROP TABLE db.sc.t; │ │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 107, ColumnID: 1} - │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ ├── • Column:{DescID: 107, ColumnID: 2} │ │ │ │ WRITE_ONLY → DELETE_ONLY @@ -180,7 +180,7 @@ EXPLAIN (ddl, verbose) DROP TABLE db.sc.t; │ │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 107, ColumnID: 2} - │ │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ │ │ └── • skip PUBLIC → ABSENT operations │ │ │ rule: "skip column dependents removal ops on relation drop" @@ -192,7 +192,7 @@ EXPLAIN (ddl, verbose) DROP TABLE db.sc.t; │ │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 107, ColumnID: 2} - │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ ├── • Column:{DescID: 107, ColumnID: 3} │ │ │ │ WRITE_ONLY → DELETE_ONLY @@ -207,7 +207,7 @@ EXPLAIN (ddl, verbose) DROP TABLE db.sc.t; │ │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 107, ColumnID: 3} - │ │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ │ │ └── • skip PUBLIC → ABSENT operations │ │ │ rule: "skip column dependents removal ops on relation drop" @@ -219,7 +219,7 @@ EXPLAIN (ddl, verbose) DROP TABLE db.sc.t; │ │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 107, ColumnID: 3} - │ │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ │ │ └── • SameStagePrecedence dependency from ABSENT ColumnDefaultExpression:{DescID: 107, ColumnID: 3} │ │ │ rule: "column type dependents removed right before column type" @@ -227,8 +227,11 @@ EXPLAIN (ddl, verbose) DROP TABLE db.sc.t; │ │ ├── • ColumnDefaultExpression:{DescID: 107, ColumnID: 3} │ │ │ │ PUBLIC → ABSENT │ │ │ │ - │ │ │ └── • SameStagePrecedence dependency from DROPPED Table:{DescID: 107} - │ │ │ rule: "descriptor drop right before dependent element removal" + │ │ │ ├── • SameStagePrecedence dependency from DROPPED Table:{DescID: 107} + │ │ │ │ rule: "descriptor drop right before dependent element removal" + │ │ │ │ + │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 107, ColumnID: 3} + │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ ├── • Column:{DescID: 107, ColumnID: 4294967295} │ │ │ │ WRITE_ONLY → DELETE_ONLY @@ -243,7 +246,7 @@ EXPLAIN (ddl, verbose) DROP TABLE db.sc.t; │ │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 107, ColumnID: 4294967295} - │ │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ │ │ └── • skip PUBLIC → ABSENT operations │ │ │ rule: "skip column dependents removal ops on relation drop" @@ -255,7 +258,7 @@ EXPLAIN (ddl, verbose) DROP TABLE db.sc.t; │ │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 107, ColumnID: 4294967295} - │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ ├── • Column:{DescID: 107, ColumnID: 4294967294} │ │ │ │ WRITE_ONLY → DELETE_ONLY @@ -270,7 +273,7 @@ EXPLAIN (ddl, verbose) DROP TABLE db.sc.t; │ │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 107, ColumnID: 4294967294} - │ │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ │ │ └── • skip PUBLIC → ABSENT operations │ │ │ rule: "skip column dependents removal ops on relation drop" @@ -282,7 +285,7 @@ EXPLAIN (ddl, verbose) DROP TABLE db.sc.t; │ │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 107, ColumnID: 4294967294} - │ │ │ rule: "column dependents removed after column no longer public" + │ │ │ rule: "column no longer public before dependents" │ │ │ │ │ ├── • IndexColumn:{DescID: 107, ColumnID: 3, IndexID: 1} │ │ │ │ PUBLIC → ABSENT @@ -290,11 +293,15 @@ EXPLAIN (ddl, verbose) DROP TABLE db.sc.t; │ │ │ ├── • SameStagePrecedence dependency from DROPPED Table:{DescID: 107} │ │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 107, ColumnID: 3} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 107, IndexID: 1, ConstraintID: 1} - │ │ │ │ rule: "index no longer public before dependents removed" + │ │ │ │ rule: "index no longer public before dependents" │ │ │ │ │ │ │ └── • skip PUBLIC → ABSENT operations │ │ │ rule: "skip index dependents removal ops on relation drop" + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 107, ColumnID: 1, IndexID: 1} │ │ │ │ PUBLIC → ABSENT @@ -302,11 +309,15 @@ EXPLAIN (ddl, verbose) DROP TABLE db.sc.t; │ │ │ ├── • SameStagePrecedence dependency from DROPPED Table:{DescID: 107} │ │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 107, ColumnID: 1} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 107, IndexID: 1, ConstraintID: 1} - │ │ │ │ rule: "index no longer public before dependents removed" + │ │ │ │ rule: "index no longer public before dependents" │ │ │ │ │ │ │ └── • skip PUBLIC → ABSENT operations │ │ │ rule: "skip index dependents removal ops on relation drop" + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • IndexColumn:{DescID: 107, ColumnID: 2, IndexID: 1} │ │ │ │ PUBLIC → ABSENT @@ -314,11 +325,15 @@ EXPLAIN (ddl, verbose) DROP TABLE db.sc.t; │ │ │ ├── • SameStagePrecedence dependency from DROPPED Table:{DescID: 107} │ │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 107, ColumnID: 2} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 107, IndexID: 1, ConstraintID: 1} - │ │ │ │ rule: "index no longer public before dependents removed" + │ │ │ │ rule: "index no longer public before dependents" │ │ │ │ │ │ │ └── • skip PUBLIC → ABSENT operations │ │ │ rule: "skip index dependents removal ops on relation drop" + │ │ │ rule: "skip index-column removal ops on index removal" │ │ │ │ │ ├── • PrimaryIndex:{DescID: 107, IndexID: 1, ConstraintID: 1} │ │ │ │ VALIDATED → DELETE_ONLY @@ -336,7 +351,7 @@ EXPLAIN (ddl, verbose) DROP TABLE db.sc.t; │ │ │ rule: "descriptor drop right before dependent element removal" │ │ │ │ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 107, IndexID: 1, ConstraintID: 1} - │ │ │ rule: "index no longer public before dependents removed" + │ │ │ rule: "index no longer public before dependents" │ │ │ │ │ └── • skip PUBLIC → ABSENT operations │ │ rule: "skip index dependents removal ops on relation drop" @@ -384,7 +399,10 @@ EXPLAIN (ddl, verbose) DROP TABLE db.sc.t; │ │ ├── • Precedence dependency from ABSENT ColumnName:{DescID: 107, Name: k, ColumnID: 1} │ │ │ rule: "dependents removed before column" │ │ │ - │ │ └── • Precedence dependency from ABSENT ColumnType:{DescID: 107, ColumnFamilyID: 0, ColumnID: 1} + │ │ ├── • Precedence dependency from ABSENT ColumnType:{DescID: 107, ColumnFamilyID: 0, ColumnID: 1} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 107, ColumnID: 1, IndexID: 1} │ │ rule: "dependents removed before column" │ │ │ ├── • Column:{DescID: 107, ColumnID: 2} @@ -396,7 +414,10 @@ EXPLAIN (ddl, verbose) DROP TABLE db.sc.t; │ │ ├── • Precedence dependency from ABSENT ColumnName:{DescID: 107, Name: v, ColumnID: 2} │ │ │ rule: "dependents removed before column" │ │ │ - │ │ └── • Precedence dependency from ABSENT ColumnType:{DescID: 107, ColumnFamilyID: 0, ColumnID: 2} + │ │ ├── • Precedence dependency from ABSENT ColumnType:{DescID: 107, ColumnFamilyID: 0, ColumnID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 107, ColumnID: 2, IndexID: 1} │ │ rule: "dependents removed before column" │ │ │ ├── • Column:{DescID: 107, ColumnID: 3} @@ -408,7 +429,13 @@ EXPLAIN (ddl, verbose) DROP TABLE db.sc.t; │ │ ├── • Precedence dependency from ABSENT ColumnName:{DescID: 107, Name: rowid, ColumnID: 3} │ │ │ rule: "dependents removed before column" │ │ │ - │ │ └── • Precedence dependency from ABSENT ColumnType:{DescID: 107, ColumnFamilyID: 0, ColumnID: 3} + │ │ ├── • Precedence dependency from ABSENT ColumnType:{DescID: 107, ColumnFamilyID: 0, ColumnID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT ColumnDefaultExpression:{DescID: 107, ColumnID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 107, ColumnID: 3, IndexID: 1} │ │ rule: "dependents removed before column" │ │ │ ├── • Column:{DescID: 107, ColumnID: 4294967295} diff --git a/pkg/sql/tests/repair_test.go b/pkg/sql/tests/repair_test.go index d4aa823989ba..27850cb9dae1 100644 --- a/pkg/sql/tests/repair_test.go +++ b/pkg/sql/tests/repair_test.go @@ -381,7 +381,7 @@ SELECT crdb_internal.unsafe_delete_namespace_entry("parentID", 0, 'foo', id) upsertInvalidDuplicateColumnDescriptorBefore, }, op: `SELECT crdb_internal.unsafe_upsert_namespace_entry($defaultDBID, $defaultDBPublicSchemaID, 'foo', $invalidTableID);`, - expErrRE: `relation "foo" \($invalidTableID\): duplicate column name: "i"`, + expErrRE: `relation "foo" \($invalidTableID\): column "i" duplicate ID of column "i"`, }, { // 5 // Upsert a descriptor which is invalid, then try to upsert a namespace @@ -393,7 +393,7 @@ SELECT crdb_internal.unsafe_delete_namespace_entry("parentID", 0, 'foo', id) expEventLogEntries: []eventLogPattern{ { typ: "unsafe_upsert_namespace_entry", - info: `"Force":true,"FailedValidation":true,"ValidationErrors":".*duplicate column name: \\"i\\""`, + info: `"Force":true,"FailedValidation":true,"ValidationErrors":".*duplicate ID of column \\"i\\".*"`, }, }, }, @@ -405,7 +405,7 @@ SELECT crdb_internal.unsafe_delete_namespace_entry("parentID", 0, 'foo', id) `SELECT crdb_internal.unsafe_upsert_namespace_entry($defaultDBID, $defaultDBPublicSchemaID, 'foo', $invalidTableID, true);`, }, op: `SELECT crdb_internal.unsafe_delete_descriptor($invalidTableID);`, - expErrRE: `pq: crdb_internal.unsafe_delete_descriptor\(\): relation "foo" \($invalidTableID\): duplicate column name: "i"`, + expErrRE: `pq: crdb_internal.unsafe_delete_descriptor\(\): relation "foo" \($invalidTableID\): column "i" duplicate ID of column "i"`, }, { // 7 // Upsert a descriptor which is invalid, upsert a namespace entry for it, @@ -418,7 +418,7 @@ SELECT crdb_internal.unsafe_delete_namespace_entry("parentID", 0, 'foo', id) expEventLogEntries: []eventLogPattern{ { typ: "unsafe_delete_descriptor", - info: `"Force":true,.*duplicate column name: \\"i\\""`, + info: `"Force":true,.*duplicate ID of column \\"i\\".*"`, }, }, }, @@ -430,7 +430,7 @@ SELECT crdb_internal.unsafe_delete_namespace_entry("parentID", 0, 'foo', id) `SELECT crdb_internal.unsafe_upsert_namespace_entry($defaultDBID, $defaultDBPublicSchemaID, 'foo', $invalidTableID, true);`, }, op: updateInvalidDuplicateColumnDescriptorNoForce, - expErrRE: `pq: crdb_internal.unsafe_upsert_descriptor\(\): relation "foo" \($invalidTableID\): duplicate column name: "i"`, + expErrRE: `pq: crdb_internal.unsafe_upsert_descriptor\(\): relation "foo" \($invalidTableID\): column "i" duplicate ID of column "i"`, }, { // 9 // Upsert a descriptor which is invalid, upsert a namespace entry for it, @@ -443,7 +443,7 @@ SELECT crdb_internal.unsafe_delete_namespace_entry("parentID", 0, 'foo', id) expEventLogEntries: []eventLogPattern{ { typ: "unsafe_upsert_descriptor", - info: `"Force":true,"ForceNotice":".*duplicate column name: \\"i\\""`, + info: `"Force":true,"ForceNotice":".*duplicate ID of column \\"i\\".*"`, }, }, after: []string{ @@ -459,7 +459,7 @@ SELECT crdb_internal.unsafe_delete_namespace_entry("parentID", 0, 'foo', id) `SELECT crdb_internal.unsafe_upsert_namespace_entry($defaultDBID, $defaultDBPublicSchemaID, 'foo', $invalidTableID, true);`, }, op: `SELECT crdb_internal.unsafe_delete_namespace_entry($defaultDBID, $defaultDBPublicSchemaID, 'foo', $invalidTableID);`, - expErrRE: `pq: crdb_internal.unsafe_delete_namespace_entry\(\): failed to retrieve descriptor $invalidTableID: relation "foo" \($invalidTableID\): duplicate column name: "i"`, + expErrRE: `pq: crdb_internal.unsafe_delete_namespace_entry\(\): failed to retrieve descriptor $invalidTableID: relation "foo" \($invalidTableID\): column "i" duplicate ID of column "i"`, }, { // 11 // Upsert a descriptor which is invalid, upsert a namespace entry for it, @@ -472,7 +472,7 @@ SELECT crdb_internal.unsafe_delete_namespace_entry("parentID", 0, 'foo', id) expEventLogEntries: []eventLogPattern{ { typ: "unsafe_delete_namespace_entry", - info: `"Force":true,"ForceNotice":".*duplicate column name: \\"i\\""`, + info: `"Force":true,"ForceNotice":".*duplicate ID of column \\"i\\".*"`, }, }, },