From c15d1ad82a4acef6316a456afa5102861176040c Mon Sep 17 00:00:00 2001 From: Marius Posta Date: Tue, 9 Aug 2022 17:04:11 -0400 Subject: [PATCH] scbuildstmt: ALTER PK drops rowid column when possible This commit improves the ALTER TABLE ... ALTER PRIMARY KEY ... implementation in the declarative schema changer by also having it drop the hidden rowid column when possible. This required introducing a transient public index which includes rowid as a storing column. This transient index is then swapped out with the definitive primary index which does not include rowid at all. This commit adds a rule to ensure that the second swapping takes place only after the original primary index, in which rowid was the PK, has been completely removed. Otherwise, we run into some nasty issues when faced with concurrent writes. Fixes #80149. Release note (sql change): When performed by the declarative schema changer (as is the case by default) the ALTER PRIMARY KEY statement now also drops the rowid column when no references are held to it anywhere. The rowid column is a hidden column which is implicitly added and serves as primary key on any table which is created without explicitly specifying a primary key. --- .../testdata/logic_test/alter_primary_key | 109 ++- .../alter_table_alter_primary_key.go | 97 +- .../testdata/alter_table_alter_primary_key | 38 +- .../rules/dep_add_index_and_column.go | 2 +- .../scplan/internal/rules/dep_swap_index.go | 36 + .../scplan/internal/rules/helpers.go | 12 +- .../scplan/internal/rules/testdata/deprules | 204 ++-- .../scplan/internal/rules/testdata/oprules | 6 +- .../scplan/internal/scstage/build.go | 9 +- .../testdata/alter_table_alter_primary_key | 519 +++++++--- .../alter_table_alter_primary_key_drop_rowid | 893 +++++++++++++++++ .../alter_table_alter_primary_key_drop_rowid | 211 ++++ ...r_primary_key_drop_rowid.rollback_10_of_15 | 62 ++ ...r_primary_key_drop_rowid.rollback_11_of_15 | 62 ++ ...r_primary_key_drop_rowid.rollback_12_of_15 | 62 ++ ...r_primary_key_drop_rowid.rollback_13_of_15 | 64 ++ ...r_primary_key_drop_rowid.rollback_14_of_15 | 64 ++ ...r_primary_key_drop_rowid.rollback_15_of_15 | 64 ++ ...er_primary_key_drop_rowid.rollback_1_of_15 | 34 + ...er_primary_key_drop_rowid.rollback_2_of_15 | 41 + ...er_primary_key_drop_rowid.rollback_3_of_15 | 41 + ...er_primary_key_drop_rowid.rollback_4_of_15 | 41 + ...er_primary_key_drop_rowid.rollback_5_of_15 | 43 + ...er_primary_key_drop_rowid.rollback_6_of_15 | 43 + ...er_primary_key_drop_rowid.rollback_7_of_15 | 43 + ...er_primary_key_drop_rowid.rollback_8_of_15 | 43 + ...er_primary_key_drop_rowid.rollback_9_of_15 | 60 ++ .../alter_table_alter_primary_key_drop_rowid | 913 ++++++++++++++++++ ...r_primary_key_drop_rowid.rollback_10_of_15 | 300 ++++++ ...r_primary_key_drop_rowid.rollback_11_of_15 | 300 ++++++ ...r_primary_key_drop_rowid.rollback_12_of_15 | 300 ++++++ ...r_primary_key_drop_rowid.rollback_13_of_15 | 307 ++++++ ...r_primary_key_drop_rowid.rollback_14_of_15 | 307 ++++++ ...r_primary_key_drop_rowid.rollback_15_of_15 | 307 ++++++ ...er_primary_key_drop_rowid.rollback_1_of_15 | 171 ++++ ...er_primary_key_drop_rowid.rollback_2_of_15 | 192 ++++ ...er_primary_key_drop_rowid.rollback_3_of_15 | 192 ++++ ...er_primary_key_drop_rowid.rollback_4_of_15 | 192 ++++ ...er_primary_key_drop_rowid.rollback_5_of_15 | 199 ++++ ...er_primary_key_drop_rowid.rollback_6_of_15 | 199 ++++ ...er_primary_key_drop_rowid.rollback_7_of_15 | 199 ++++ ...er_primary_key_drop_rowid.rollback_8_of_15 | 199 ++++ ...er_primary_key_drop_rowid.rollback_9_of_15 | 293 ++++++ 43 files changed, 7172 insertions(+), 301 deletions(-) create mode 100644 pkg/sql/schemachanger/testdata/end_to_end/alter_table_alter_primary_key_drop_rowid create mode 100644 pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid create mode 100644 pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_10_of_15 create mode 100644 pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_11_of_15 create mode 100644 pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_12_of_15 create mode 100644 pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_13_of_15 create mode 100644 pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_14_of_15 create mode 100644 pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_15_of_15 create mode 100644 pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_1_of_15 create mode 100644 pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_2_of_15 create mode 100644 pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_3_of_15 create mode 100644 pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_4_of_15 create mode 100644 pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_5_of_15 create mode 100644 pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_6_of_15 create mode 100644 pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_7_of_15 create mode 100644 pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_8_of_15 create mode 100644 pkg/sql/schemachanger/testdata/explain/alter_table_alter_primary_key_drop_rowid.rollback_9_of_15 create mode 100644 pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid create mode 100644 pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_10_of_15 create mode 100644 pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_11_of_15 create mode 100644 pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_12_of_15 create mode 100644 pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_13_of_15 create mode 100644 pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_14_of_15 create mode 100644 pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_15_of_15 create mode 100644 pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_1_of_15 create mode 100644 pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_2_of_15 create mode 100644 pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_3_of_15 create mode 100644 pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_4_of_15 create mode 100644 pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_5_of_15 create mode 100644 pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_6_of_15 create mode 100644 pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_7_of_15 create mode 100644 pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_8_of_15 create mode 100644 pkg/sql/schemachanger/testdata/explain_verbose/alter_table_alter_primary_key_drop_rowid.rollback_9_of_15 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_alter_primary_key.go b/pkg/sql/schemachanger/scbuild/internal/scbuildstmt/alter_table_alter_primary_key.go index f71ae3631dd7..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 @@ -67,6 +67,40 @@ func alterTableAlterPrimaryKey( panic(errors.AssertionFailedf("programming error: new primary index has already existed.")) } + // 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)) { @@ -80,6 +114,9 @@ func alterTableAlterPrimaryKey( if !exist { panic(fmt.Sprintf("table %v does not have a column named %v", tn.String(), col.Column)) } + if rowidToDrop != nil && colID == rowidToDrop.ColumnID { + rowidToDrop = nil + } inColumns = append(inColumns, indexColumnSpec{ columnID: colID, kind: scpb.IndexColumn_KEY, @@ -92,7 +129,8 @@ func alterTableAlterPrimaryKey( 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 } inColumns = append(inColumns, indexColumnSpec{ @@ -103,16 +141,39 @@ func alterTableAlterPrimaryKey( } out.apply(b.Drop) sharding := makeShardedDescriptor(b, t) - in, tempIn := makeSwapPrimaryIndexSpec(b, out, inColumns) - in.idx.Sharding = sharding - in.apply(b.Add) - tempIn.apply(b.AddTransient) - newPrimaryIndexElem = in.idx + 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 @@ -461,9 +522,10 @@ func maybeAddUniqueIndexForOldPrimaryKey( tbl *scpb.Table, t *tree.AlterTableAlterPrimaryKey, oldPrimaryIndex, newPrimaryIndex *scpb.PrimaryIndex, + rowidToDrop *scpb.Column, ) { if shouldCreateUniqueIndexOnOldPrimaryKeyColumns( - b, tbl, oldPrimaryIndex.IndexID, newPrimaryIndex.IndexID, + b, tbl, oldPrimaryIndex.IndexID, newPrimaryIndex.IndexID, rowidToDrop, ) { newUniqueSecondaryIndex, tempIndex := addNewUniqueSecondaryIndexAndTempIndex(b, tn, tbl, oldPrimaryIndex) addIndexColumnsForNewUniqueSecondaryIndexAndTempIndex(b, tn, tbl, t, @@ -598,7 +660,10 @@ func addIndexNameForNewUniqueSecondaryIndex(b BuildCtx, tbl *scpb.Table, indexID // * There is no partitioning change. // * There is no existing secondary index on the old primary key columns. func shouldCreateUniqueIndexOnOldPrimaryKeyColumns( - b BuildCtx, tbl *scpb.Table, oldPrimaryIndexID catid.IndexID, newPrimaryIndexID catid.IndexID, + b BuildCtx, + tbl *scpb.Table, + 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. @@ -668,7 +733,19 @@ func shouldCreateUniqueIndexOnOldPrimaryKeyColumns( } // If there already exist suitable unique indexes, then don't create any. - return !alreadyHasSecondaryIndexOnPKColumns(b, tbl.TableID, oldPrimaryIndexID) + 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 } // getPrimaryIndexDefaultRowIDColumn checks whether the primary key is on the diff --git a/pkg/sql/schemachanger/scbuild/testdata/alter_table_alter_primary_key b/pkg/sql/schemachanger/scbuild/testdata/alter_table_alter_primary_key index fa55fdbaebf5..e037c30ec85a 100644 --- a/pkg/sql/schemachanger/scbuild/testdata/alter_table_alter_primary_key +++ b/pkg/sql/schemachanger/scbuild/testdata/alter_table_alter_primary_key @@ -46,6 +46,14 @@ ALTER TABLE defaultdb.foo ALTER PRIMARY KEY USING COLUMNS (j) 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] @@ -54,13 +62,13 @@ ALTER TABLE defaultdb.bar ALTER PRIMARY KEY USING COLUMNS (i) {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}, PUBLIC], ABSENT] +- [[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}, PUBLIC], ABSENT] +- [[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}, PUBLIC], ABSENT] +- [[IndexColumn:{DescID: 105, ColumnID: 1, IndexID: 2}, TRANSIENT_ABSENT], ABSENT] {columnId: 1, indexId: 2, tableId: 105} -- [[IndexColumn:{DescID: 105, ColumnID: 2, IndexID: 2}, PUBLIC], ABSENT] +- [[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} @@ -68,17 +76,13 @@ ALTER TABLE defaultdb.bar ALTER PRIMARY KEY USING COLUMNS (i) {columnId: 1, indexId: 3, tableId: 105} - [[IndexColumn:{DescID: 105, ColumnID: 2, IndexID: 3}, TRANSIENT_ABSENT], ABSENT] {columnId: 2, indexId: 3, kind: STORED, tableId: 105} -- [[SecondaryIndex:{DescID: 105, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1}, PUBLIC], ABSENT] - {constraintId: 4, indexId: 4, isUnique: true, sourceIndexId: 1, tableId: 105, temporaryIndexId: 5} -- [[TemporaryIndex:{DescID: 105, IndexID: 5, ConstraintID: 5, SourceIndexID: 1}, TRANSIENT_ABSENT], ABSENT] - {constraintId: 5, indexId: 5, isUnique: true, isUsingSecondaryEncoding: true, sourceIndexId: 1, tableId: 105} -- [[IndexColumn:{DescID: 105, ColumnID: 2, IndexID: 4}, PUBLIC], ABSENT] - {columnId: 2, indexId: 4, tableId: 105} -- [[IndexColumn:{DescID: 105, ColumnID: 2, IndexID: 5}, PUBLIC], ABSENT] - {columnId: 2, indexId: 5, 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, kind: KEY_SUFFIX, tableId: 105} -- [[IndexColumn:{DescID: 105, ColumnID: 1, IndexID: 5}, PUBLIC], ABSENT] - {columnId: 1, indexId: 5, kind: KEY_SUFFIX, tableId: 105} -- [[IndexName:{DescID: 105, Name: bar_rowid_key, IndexID: 4}, PUBLIC], ABSENT] - {indexId: 4, name: bar_rowid_key, tableId: 105} + {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/scplan/internal/rules/dep_add_index_and_column.go b/pkg/sql/schemachanger/scplan/internal/rules/dep_add_index_and_column.go index f38e3aaf7666..f6f12b15699b 100644 --- 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 @@ -114,7 +114,7 @@ func init() { return rel.Clauses{ from.Type((*scpb.PrimaryIndex)(nil)), to.Type((*scpb.Column)(nil)), - columnInPrimaryIndexSwap(ic, from, relationID, columnID, "index-id"), + 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_swap_index.go b/pkg/sql/schemachanger/scplan/internal/rules/dep_swap_index.go index 9f5435d3ddde..b55bd7266f1a 100644 --- a/pkg/sql/schemachanger/scplan/internal/rules/dep_swap_index.go +++ b/pkg/sql/schemachanger/scplan/internal/rules/dep_swap_index.go @@ -88,3 +88,39 @@ func init() { }, ) } + +// 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 d36b28b82e5c..8ca12d7aea63 100644 --- a/pkg/sql/schemachanger/scplan/internal/rules/helpers.go +++ b/pkg/sql/schemachanger/scplan/internal/rules/helpers.go @@ -117,10 +117,10 @@ 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 ( @@ -216,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{ @@ -224,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 { @@ -233,7 +233,7 @@ var ( columnInIndexUntyped( indexColumn, index, tableID, columnID, indexID, ), - sourceIndexNotSetUntyped(index), + sourceIndexIsSetUntyped(index), } }) ) diff --git a/pkg/sql/schemachanger/scplan/internal/rules/testdata/deprules b/pkg/sql/schemachanger/scplan/internal/rules/testdata/deprules index d4907fa9a4c1..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,7 +35,7 @@ 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 @@ -151,9 +151,10 @@ deprules - $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-target[TargetStatus] = ABSENT - $column-node[CurrentStatus] = WRITE_ONLY - - $dependent-node[CurrentStatus] = ABSENT + - $dependent-target[TargetStatus] = TRANSIENT_ABSENT + - $dependent-node[CurrentStatus] = TRANSIENT_ABSENT - joinTargetNode($column, $column-target, $column-node) - joinTargetNode($dependent, $dependent-target, $dependent-node) - name: column no longer public before dependents @@ -164,10 +165,10 @@ deprules - $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] = ABSENT - - $column-node[CurrentStatus] = WRITE_ONLY - - $dependent-target[TargetStatus] = TRANSIENT_ABSENT - - $dependent-node[CurrentStatus] = TRANSIENT_ABSENT + - $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 @@ -178,10 +179,9 @@ deprules - $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 + - transient($column-target, $dependent-target) - $column-node[CurrentStatus] = TRANSIENT_WRITE_ONLY - - $dependent-target[TargetStatus] = ABSENT - - $dependent-node[CurrentStatus] = ABSENT + - $dependent-node[CurrentStatus] = TRANSIENT_ABSENT - joinTargetNode($column, $column-target, $column-node) - joinTargetNode($dependent, $dependent-target, $dependent-node) - name: column no longer public before dependents @@ -192,9 +192,9 @@ deprules - $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 + - 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 @@ -232,10 +232,9 @@ deprules - $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 + - toAbsent($dependent-target, $column-target) - $dependent-node[CurrentStatus] = ABSENT - - $column-target[TargetStatus] = TRANSIENT_ABSENT - - $column-node[CurrentStatus] = TRANSIENT_ABSENT + - $column-node[CurrentStatus] = ABSENT - joinTargetNode($dependent, $dependent-target, $dependent-node) - joinTargetNode($column, $column-target, $column-node) - name: dependents removed before column @@ -246,10 +245,9 @@ deprules - $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 + - transient($dependent-target, $column-target) - $dependent-node[CurrentStatus] = TRANSIENT_ABSENT - - $column-target[TargetStatus] = ABSENT - - $column-node[CurrentStatus] = ABSENT + - $column-node[CurrentStatus] = TRANSIENT_ABSENT - joinTargetNode($dependent, $dependent-target, $dependent-node) - joinTargetNode($column, $column-target, $column-node) - name: dependents removed before column @@ -260,9 +258,10 @@ deprules - $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-target[TargetStatus] = ABSENT - $dependent-node[CurrentStatus] = ABSENT - - $column-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 @@ -273,9 +272,10 @@ deprules - $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) - - transient($dependent-target, $column-target) + - $dependent-target[TargetStatus] = TRANSIENT_ABSENT - $dependent-node[CurrentStatus] = TRANSIENT_ABSENT - - $column-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 @@ -286,9 +286,10 @@ deprules - $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) - - toAbsent($dependent-target, $index-target) + - $dependent-target[TargetStatus] = ABSENT - $dependent-node[CurrentStatus] = ABSENT - - $index-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 @@ -299,9 +300,10 @@ deprules - $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-target[TargetStatus] = TRANSIENT_ABSENT - $dependent-node[CurrentStatus] = TRANSIENT_ABSENT - - $index-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 @@ -312,10 +314,9 @@ deprules - $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 + - transient($dependent-target, $index-target) - $dependent-node[CurrentStatus] = TRANSIENT_ABSENT - - $index-target[TargetStatus] = ABSENT - - $index-node[CurrentStatus] = ABSENT + - $index-node[CurrentStatus] = TRANSIENT_ABSENT - joinTargetNode($dependent, $dependent-target, $dependent-node) - joinTargetNode($index, $index-target, $index-node) - name: dependents removed before index @@ -326,10 +327,9 @@ deprules - $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 + - toAbsent($dependent-target, $index-target) - $dependent-node[CurrentStatus] = ABSENT - - $index-target[TargetStatus] = TRANSIENT_ABSENT - - $index-node[CurrentStatus] = TRANSIENT_ABSENT + - $index-node[CurrentStatus] = ABSENT - joinTargetNode($dependent, $dependent-target, $dependent-node) - joinTargetNode($index, $index-target, $index-node) - name: descriptor drop right before dependent element removal @@ -459,9 +459,9 @@ deprules - $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 + - toAbsent($index-target, $dependent-target) + - $index-node[CurrentStatus] = VALIDATED + - $dependent-node[CurrentStatus] = ABSENT - joinTargetNode($index, $index-target, $index-node) - joinTargetNode($dependent, $dependent-target, $dependent-node) - name: index no longer public before dependents @@ -500,9 +500,9 @@ deprules - $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) - - toAbsent($index-target, $dependent-target) - - $index-node[CurrentStatus] = VALIDATED - - $dependent-node[CurrentStatus] = ABSENT + - 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 @@ -543,10 +543,9 @@ deprules - 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 + - toAbsent($index-target, $column-target) - $index-node[CurrentStatus] = ABSENT - - $column-target[TargetStatus] = TRANSIENT_ABSENT - - $column-node[CurrentStatus] = TRANSIENT_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 @@ -561,10 +560,10 @@ deprules - 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 + - $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 @@ -579,9 +578,10 @@ deprules - 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-target[TargetStatus] = TRANSIENT_ABSENT - $index-node[CurrentStatus] = TRANSIENT_ABSENT - - $column-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 @@ -596,11 +596,31 @@ deprules - 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 + - 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 @@ -610,10 +630,10 @@ deprules - $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 + - $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 @@ -625,10 +645,10 @@ deprules - $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 + - $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 @@ -659,22 +679,6 @@ deprules - $index-node[CurrentStatus] = TRANSIENT_ABSENT - joinTargetNode($partial-predicate, $partial-predicate-target, $partial-predicate-node) - joinTargetNode($index, $index-target, $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 swap from: old-index-node kind: SameStagePrecedence @@ -685,8 +689,8 @@ deprules - 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 + - $old-index-target[TargetStatus] = ABSENT + - $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) @@ -701,12 +705,28 @@ deprules - joinOnDescID($old-index, $new-index, $table-id) - $old-index[IndexID] = $old-index-id - $new-index[SourceIndexID] = $old-index-id - - $old-index-target[TargetStatus] = ABSENT - - $old-index-node[CurrentStatus] = VALIDATED + - $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 - 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 @@ -745,10 +765,9 @@ deprules - $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 + - toAbsent($index-target, $index-column-target) - $index-node[CurrentStatus] = DELETE_ONLY - - $index-column-target[TargetStatus] = TRANSIENT_ABSENT - - $index-column-node[CurrentStatus] = TRANSIENT_ABSENT + - $index-column-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 @@ -759,10 +778,9 @@ deprules - $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] = TRANSIENT_ABSENT + - transient($index-target, $index-column-target) - $index-node[CurrentStatus] = TRANSIENT_DELETE_ONLY - - $index-column-target[TargetStatus] = ABSENT - - $index-column-node[CurrentStatus] = ABSENT + - $index-column-node[CurrentStatus] = TRANSIENT_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 @@ -773,9 +791,10 @@ deprules - $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-target[TargetStatus] = TRANSIENT_ABSENT - $index-node[CurrentStatus] = TRANSIENT_DELETE_ONLY - - $index-column-node[CurrentStatus] = TRANSIENT_ABSENT + - $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: remove columns from index right before removing index @@ -786,9 +805,10 @@ deprules - $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-target[TargetStatus] = ABSENT - $index-node[CurrentStatus] = DELETE_ONLY - - $index-column-node[CurrentStatus] = ABSENT + - $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 @@ -816,7 +836,7 @@ deprules query: - $index[Type] = '*scpb.PrimaryIndex' - $column[Type] = '*scpb.Column' - - columnInPrimaryIndexSwap($index-column, $index, $table-id, $column-id, $index-id) + - 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 diff --git a/pkg/sql/schemachanger/scplan/internal/rules/testdata/oprules b/pkg/sql/schemachanger/scplan/internal/rules/testdata/oprules index 9cf9a1318091..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,7 +35,7 @@ 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 diff --git a/pkg/sql/schemachanger/scplan/internal/scstage/build.go b/pkg/sql/schemachanger/scplan/internal/scstage/build.go index 36639d71f13a..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) diff --git a/pkg/sql/schemachanger/scplan/testdata/alter_table_alter_primary_key b/pkg/sql/schemachanger/scplan/testdata/alter_table_alter_primary_key index ef4fcfc67b9d..06c1ab8ee30d 100644 --- a/pkg/sql/schemachanger/scplan/testdata/alter_table_alter_primary_key +++ b/pkg/sql/schemachanger/scplan/testdata/alter_table_alter_primary_key @@ -7,21 +7,43 @@ ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (k); ---- StatementPhase stage 1 of 1 with 14 MutationType ops transitions: - [[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 - [[IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 2}, PUBLIC], ABSENT] -> PUBLIC + [[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 - [[SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1}, PUBLIC], ABSENT] -> BACKFILL_ONLY - [[TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 1}, TRANSIENT_ABSENT], ABSENT] -> DELETE_ONLY - [[IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4}, PUBLIC], ABSENT] -> PUBLIC - [[IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 5}, PUBLIC], 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: 1, IndexID: 5}, 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 @@ -72,35 +94,17 @@ StatementPhase stage 1 of 1 with 14 MutationType ops ConstraintID: 4 IndexID: 4 IsUnique: true - SourceIndexID: 1 + SourceIndexID: 2 TableID: 104 TemporaryIndexID: 5 - IsSecondaryIndex: true - *scop.MakeAddedTempIndexDeleteOnly - Index: - ConstraintID: 5 - IndexID: 5 - IsUnique: true - SourceIndexID: 1 - TableID: 104 - IsSecondaryIndex: true - *scop.AddColumnToIndex - ColumnID: 3 - IndexID: 4 - TableID: 104 - *scop.AddColumnToIndex - ColumnID: 3 - IndexID: 5 - TableID: 104 *scop.AddColumnToIndex ColumnID: 1 IndexID: 4 - Kind: 1 TableID: 104 *scop.AddColumnToIndex - ColumnID: 1 - IndexID: 5 - Kind: 1 + ColumnID: 2 + IndexID: 4 + Kind: 2 TableID: 104 PreCommitPhase stage 1 of 1 with 2 MutationType ops transitions: @@ -114,125 +118,88 @@ PreCommitPhase stage 1 of 1 with 2 MutationType ops DescriptorIDs: - 104 JobID: 1 - RunningStatus: PostCommitPhase stage 1 of 7 with 2 MutationType ops pending + 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 7 with 4 MutationType ops +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 - [[TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 1}, TRANSIENT_ABSENT], DELETE_ONLY] -> WRITE_ONLY ops: *scop.MakeAddedIndexDeleteAndWriteOnly IndexID: 3 TableID: 104 - *scop.MakeAddedIndexDeleteAndWriteOnly - IndexID: 5 - TableID: 104 *scop.SetJobStateOnDescriptor DescriptorID: 104 *scop.UpdateSchemaChangerJob JobID: 1 -PostCommitPhase stage 2 of 7 with 2 BackfillType ops +PostCommitPhase stage 2 of 15 with 1 BackfillType op transitions: - [[PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC], BACKFILL_ONLY] -> BACKFILLED - [[SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1}, PUBLIC], BACKFILL_ONLY] -> BACKFILLED + [[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 - *scop.BackfillIndex - IndexID: 4 - SourceIndexID: 1 - TableID: 104 -PostCommitPhase stage 3 of 7 with 4 MutationType ops +PostCommitPhase stage 3 of 15 with 3 MutationType ops transitions: - [[PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC], BACKFILLED] -> DELETE_ONLY - [[SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1}, PUBLIC], BACKFILLED] -> DELETE_ONLY + [[PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], BACKFILLED] -> DELETE_ONLY ops: *scop.MakeBackfillingIndexDeleteOnly IndexID: 2 TableID: 104 - *scop.MakeBackfillingIndexDeleteOnly - IndexID: 4 - TableID: 104 *scop.SetJobStateOnDescriptor DescriptorID: 104 *scop.UpdateSchemaChangerJob JobID: 1 -PostCommitPhase stage 4 of 7 with 4 MutationType ops +PostCommitPhase stage 4 of 15 with 3 MutationType ops transitions: - [[PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC], DELETE_ONLY] -> MERGE_ONLY - [[SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1}, PUBLIC], DELETE_ONLY] -> MERGE_ONLY + [[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.MakeBackfilledIndexMerging - IndexID: 4 - TableID: 104 *scop.SetJobStateOnDescriptor DescriptorID: 104 *scop.UpdateSchemaChangerJob JobID: 1 -PostCommitPhase stage 5 of 7 with 2 BackfillType ops +PostCommitPhase stage 5 of 15 with 1 BackfillType op transitions: - [[PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC], MERGE_ONLY] -> MERGED - [[SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1}, PUBLIC], MERGE_ONLY] -> MERGED + [[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 - *scop.MergeIndex - BackfilledIndexID: 4 - TableID: 104 - TemporaryIndexID: 5 -PostCommitPhase stage 6 of 7 with 4 MutationType ops +PostCommitPhase stage 6 of 15 with 3 MutationType ops transitions: - [[PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC], MERGED] -> WRITE_ONLY - [[SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1}, PUBLIC], MERGED] -> WRITE_ONLY + [[PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], MERGED] -> WRITE_ONLY ops: *scop.MakeMergedIndexWriteOnly IndexID: 2 TableID: 104 - *scop.MakeMergedIndexWriteOnly - IndexID: 4 - TableID: 104 *scop.SetJobStateOnDescriptor DescriptorID: 104 *scop.UpdateSchemaChangerJob JobID: 1 -PostCommitPhase stage 7 of 7 with 2 ValidationType ops +PostCommitPhase stage 7 of 15 with 1 ValidationType op transitions: - [[PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, PUBLIC], WRITE_ONLY] -> VALIDATED - [[SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1}, PUBLIC], WRITE_ONLY] -> VALIDATED + [[PrimaryIndex:{DescID: 104, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1}, TRANSIENT_ABSENT], WRITE_ONLY] -> VALIDATED ops: *scop.ValidateUniqueIndex IndexID: 2 TableID: 104 - *scop.ValidateUniqueIndex - IndexID: 4 - TableID: 104 -PostCommitNonRevertiblePhase stage 1 of 3 with 10 MutationType ops +PostCommitPhase stage 8 of 15 with 9 MutationType ops transitions: - [[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], PUBLIC] -> WRITE_ONLY + [[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}, PUBLIC], VALIDATED] -> PUBLIC - [[IndexName:{DescID: 104, Name: t_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 - [[IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 3}, TRANSIENT_ABSENT], PUBLIC] -> TRANSIENT_ABSENT - [[SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1}, PUBLIC], VALIDATED] -> PUBLIC - [[TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, SourceIndexID: 1}, TRANSIENT_ABSENT], WRITE_ONLY] -> TRANSIENT_DELETE_ONLY - [[IndexName:{DescID: 104, Name: t_rowid_key, IndexID: 4}, PUBLIC], ABSENT] -> PUBLIC + [[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 @@ -245,16 +212,6 @@ PostCommitNonRevertiblePhase stage 1 of 3 with 10 MutationType ops IndexID: 2 Name: t_pkey TableID: 104 - *scop.MakeDroppedIndexDeleteOnly - IndexID: 3 - TableID: 104 - *scop.MakeDroppedIndexDeleteOnly - IndexID: 5 - TableID: 104 - *scop.SetIndexName - IndexID: 4 - Name: t_rowid_key - TableID: 104 *scop.MakeAddedPrimaryIndexPublic EventBase: Authorization: @@ -266,46 +223,214 @@ PostCommitNonRevertiblePhase stage 1 of 3 with 10 MutationType ops SubWorkID: 1 IndexID: 2 TableID: 104 - *scop.MakeAddedSecondaryIndexPublic + *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 3 with 7 MutationType ops +PostCommitNonRevertiblePhase stage 2 of 4 with 12 MutationType ops transitions: - [[PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1}, ABSENT], WRITE_ONLY] -> DELETE_ONLY + [[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 - [[TemporaryIndex:{DescID: 104, IndexID: 5, ConstraintID: 5, 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.MakeDroppedIndexDeleteOnly + *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 3 with 4 MutationType ops +PostCommitNonRevertiblePhase stage 3 of 4 with 3 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], 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: 1 + IndexID: 2 StatementForDropJob: Statement: ALTER TABLE defaultdb.public.t ALTER PRIMARY KEY USING COLUMNS (k) TableID: 104 @@ -318,7 +443,21 @@ PostCommitNonRevertiblePhase stage 3 of 3 with 4 MutationType ops TargetMetadata: SourceElementID: 1 SubWorkID: 1 - IndexID: 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 @@ -330,6 +469,46 @@ PostCommitNonRevertiblePhase stage 3 of 3 with 4 MutationType ops 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 @@ -342,6 +521,10 @@ ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (k); 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 @@ -351,13 +534,21 @@ ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (k); kind: Precedence rule: dependents removed before index - from: [IndexColumn:{DescID: 104, ColumnID: 1, IndexID: 4}, PUBLIC] - to: [SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1}, BACKFILLED] + 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: [SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1}, 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 @@ -370,6 +561,10 @@ ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (k); 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 @@ -378,6 +573,26 @@ ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (k); 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 @@ -390,22 +605,26 @@ ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (k); 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: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4}, PUBLIC] - to: [SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1}, BACKFILLED] - kind: Precedence - rule: index-column added to index before index is backfilled -- from: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4}, PUBLIC] - to: [SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1}, PUBLIC] - kind: Precedence - rule: index dependents exist before index becomes public - from: [IndexName:{DescID: 104, Name: t_pkey, IndexID: 1}, ABSENT] to: [PrimaryIndex:{DescID: 104, IndexID: 1, ConstraintID: 1}, ABSENT] kind: Precedence @@ -414,10 +633,22 @@ ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (k); 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_rowid_key, IndexID: 4}, PUBLIC] - to: [SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1}, 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 @@ -454,16 +685,44 @@ ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (k); to: [IndexName:{DescID: 104, Name: t_pkey, IndexID: 2}, PUBLIC] kind: Precedence rule: index existence precedes index dependents -- from: [SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1}, BACKFILL_ONLY] +- 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: [SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1}, BACKFILL_ONLY] - to: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 4}, PUBLIC] +- 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: [SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1}, BACKFILL_ONLY] - to: [IndexName:{DescID: 104, Name: t_rowid_key, IndexID: 4}, PUBLIC] +- 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] @@ -482,15 +741,15 @@ ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (k); 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: 1}, DELETE_ONLY] +- 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: 1}, DELETE_ONLY] - to: [IndexColumn:{DescID: 104, ColumnID: 3, IndexID: 5}, PUBLIC] +- 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: 1}, WRITE_ONLY] - to: [SecondaryIndex:{DescID: 104, IndexID: 4, ConstraintID: 4, TemporaryIndexID: 5, SourceIndexID: 1}, BACKFILLED] +- 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/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/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_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