diff --git a/pkg/ccl/schemachangerccl/backup_base_generated_test.go b/pkg/ccl/schemachangerccl/backup_base_generated_test.go index 2c9824e46bf3..793b9b594cfc 100644 --- a/pkg/ccl/schemachangerccl/backup_base_generated_test.go +++ b/pkg/ccl/schemachangerccl/backup_base_generated_test.go @@ -38,6 +38,16 @@ func TestBackup_base_add_column_no_default(t *testing.T) { defer log.Scope(t).Close(t) sctest.Backup(t, "pkg/sql/schemachanger/testdata/end_to_end/add_column_no_default", newCluster) } +func TestBackup_base_add_column_with_stored(t *testing.T) { + defer leaktest.AfterTest(t)() + defer log.Scope(t).Close(t) + sctest.Backup(t, "pkg/sql/schemachanger/testdata/end_to_end/add_column_with_stored", newCluster) +} +func TestBackup_base_add_column_with_stored_family(t *testing.T) { + defer leaktest.AfterTest(t)() + defer log.Scope(t).Close(t) + sctest.Backup(t, "pkg/sql/schemachanger/testdata/end_to_end/add_column_with_stored_family", newCluster) +} func TestBackup_base_alter_table_add_check_udf(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) diff --git a/pkg/ccl/schemachangerccl/backup_base_mixed_generated_test.go b/pkg/ccl/schemachangerccl/backup_base_mixed_generated_test.go index 21851a284311..e28424136e88 100644 --- a/pkg/ccl/schemachangerccl/backup_base_mixed_generated_test.go +++ b/pkg/ccl/schemachangerccl/backup_base_mixed_generated_test.go @@ -38,6 +38,16 @@ func TestBackupMixedVersionElements_base_add_column_no_default(t *testing.T) { defer log.Scope(t).Close(t) sctest.BackupMixedVersionElements(t, "pkg/sql/schemachanger/testdata/end_to_end/add_column_no_default", newClusterMixed) } +func TestBackupMixedVersionElements_base_add_column_with_stored(t *testing.T) { + defer leaktest.AfterTest(t)() + defer log.Scope(t).Close(t) + sctest.BackupMixedVersionElements(t, "pkg/sql/schemachanger/testdata/end_to_end/add_column_with_stored", newClusterMixed) +} +func TestBackupMixedVersionElements_base_add_column_with_stored_family(t *testing.T) { + defer leaktest.AfterTest(t)() + defer log.Scope(t).Close(t) + sctest.BackupMixedVersionElements(t, "pkg/sql/schemachanger/testdata/end_to_end/add_column_with_stored_family", newClusterMixed) +} func TestBackupMixedVersionElements_base_alter_table_add_check_udf(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) diff --git a/pkg/sql/schemachanger/scop/immediate_mutation_visitor_generated.go b/pkg/sql/schemachanger/scop/immediate_mutation_visitor_generated.go index a27f9b71e11e..1dcc675da835 100644 --- a/pkg/sql/schemachanger/scop/immediate_mutation_visitor_generated.go +++ b/pkg/sql/schemachanger/scop/immediate_mutation_visitor_generated.go @@ -72,6 +72,7 @@ type ImmediateMutationVisitor interface { RemoveSchemaParent(context.Context, RemoveSchemaParent) error AddIndexPartitionInfo(context.Context, AddIndexPartitionInfo) error AddColumnFamily(context.Context, AddColumnFamily) error + AssertColumnFamilyIsRemoved(context.Context, AssertColumnFamilyIsRemoved) error AddColumnDefaultExpression(context.Context, AddColumnDefaultExpression) error RemoveColumnDefaultExpression(context.Context, RemoveColumnDefaultExpression) error AddColumnOnUpdateExpression(context.Context, AddColumnOnUpdateExpression) error @@ -370,6 +371,11 @@ func (op AddColumnFamily) Visit(ctx context.Context, v ImmediateMutationVisitor) return v.AddColumnFamily(ctx, op) } +// Visit is part of the ImmediateMutationOp interface. +func (op AssertColumnFamilyIsRemoved) Visit(ctx context.Context, v ImmediateMutationVisitor) error { + return v.AssertColumnFamilyIsRemoved(ctx, op) +} + // Visit is part of the ImmediateMutationOp interface. func (op AddColumnDefaultExpression) Visit(ctx context.Context, v ImmediateMutationVisitor) error { return v.AddColumnDefaultExpression(ctx, op) diff --git a/pkg/sql/schemachanger/sctest/cumulative.go b/pkg/sql/schemachanger/sctest/cumulative.go index c7e8645e7a0e..684e04b66620 100644 --- a/pkg/sql/schemachanger/sctest/cumulative.go +++ b/pkg/sql/schemachanger/sctest/cumulative.go @@ -72,6 +72,8 @@ type stageExecStmt struct { expectedOutput string observedOutput string schemaChangeErrorRegex *regexp.Regexp + // schemaChangeErrorRegexRollback will cause a rollback. + schemaChangeErrorRegexRollback *regexp.Regexp } // HasSchemaChangeError indicates if a schema change error will be observed, @@ -80,6 +82,13 @@ func (e *stageExecStmt) HasSchemaChangeError() bool { return e.schemaChangeErrorRegex != nil } +func (e *stageExecStmt) HasAnySchemaChangeError() *regexp.Regexp { + if e.schemaChangeErrorRegex != nil { + return e.schemaChangeErrorRegex + } + return e.schemaChangeErrorRegexRollback +} + // stageKeyOrdinalLatest targets the latest ordinal in a stage. const stageKeyOrdinalLatest = math.MaxUint16 @@ -89,14 +98,16 @@ type stageKey struct { minOrdinal int maxOrdinal int phase scop.Phase + rollback bool } // makeStageKey constructs a stage key targeting a single ordinal. -func makeStageKey(phase scop.Phase, ordinal int) stageKey { +func makeStageKey(phase scop.Phase, ordinal int, rollback bool) stageKey { return stageKey{ phase: phase, minOrdinal: ordinal, maxOrdinal: ordinal, + rollback: rollback, } } @@ -151,6 +162,7 @@ func (m *stageExecStmtMap) getExecStmts(targetKey stageKey) []*stageExecStmt { } for _, key := range m.entries { if key.stageKey.phase == targetKey.phase && + key.stageKey.rollback == targetKey.rollback && targetKey.minOrdinal >= key.stageKey.minOrdinal && targetKey.minOrdinal <= key.stageKey.maxOrdinal { stmts = append(stmts, key.stmt) @@ -162,6 +174,12 @@ func (m *stageExecStmtMap) getExecStmts(targetKey stageKey) []*stageExecStmt { // AssertMapIsUsed asserts that all injected DML statements injected // at various stages. func (m *stageExecStmtMap) AssertMapIsUsed(t *testing.T) { + // If there is any rollback error, then not all stages will be used. + for _, e := range m.entries { + if e.stmt.schemaChangeErrorRegexRollback != nil { + return + } + } if len(m.entries) != len(m.usedMap) { for _, entry := range m.entries { if _, ok := m.usedMap[entry.stmt]; !ok { @@ -213,9 +231,9 @@ func (m *stageExecStmtMap) GetInjectionRanges( panic("unknown phase type for latest") } } - if !key.stmt.HasSchemaChangeError() { + if !key.stmt.HasSchemaChangeError() && !key.rollback { forcedSplitEntries = append(forcedSplitEntries, key) - } else { + } else if !key.rollback { for i := key.minOrdinal; i <= key.maxOrdinal; i++ { forcedSplitEntries = append(forcedSplitEntries, stageKeyEntry{ @@ -223,6 +241,7 @@ func (m *stageExecStmtMap) GetInjectionRanges( minOrdinal: i, maxOrdinal: i, phase: key.phase, + rollback: key.rollback, }, stmt: key.stmt, }, @@ -307,19 +326,25 @@ func (m *stageExecStmtMap) ParseStageExec(t *testing.T, d *datadriven.TestData) // parseStageCommon common fields between stage-exec and stage-query, which // support the following keys: // - phase - The phase in which this statement/query should be injected, of the -// string scop.Phase. +// string scop.Phase. Note: PreCommitPhase with stage 1 can be used to +// inject failures that will only happen for DML injection testing. // - stage / stageStart / stageEnd - The ordinal for the stage where this // statement should be injected. stageEnd accepts the special value // latest which will map to the highest observed stage. +// - schemaChangeExecError a schema change execution error will be encountered +// by injecting at this stage. +// - schemaChangeExecErrorForRollback a schema change execution error that will +// be encountered at a future stage, leading to a rollback. // - statements can refer to builtin variable names with a $ // - $stageKey - A unique identifier for stages and phases // - $successfulStageCount - Number of stages of the that have been successfully -// executed with injections. +// executed with injections func (m *stageExecStmtMap) parseStageCommon( t *testing.T, d *datadriven.TestData, execType stageExecType, ) { var key stageKey var schemaChangeErrorRegex *regexp.Regexp + var schemaChangeErrorRegexRollback *regexp.Regexp stmts := strings.Split(d.Input, ";") require.NotEmpty(t, stmts) // Remove any trailing empty lines. @@ -369,6 +394,14 @@ func (m *stageExecStmtMap) parseStageCommon( } case "schemaChangeExecError": schemaChangeErrorRegex = regexp.MustCompile(strings.Join(cmdArgs.Vals, " ")) + require.Nil(t, schemaChangeErrorRegexRollback, "future and current stage errors cannot be set concurrently") + case "schemaChangeExecErrorForRollback": + schemaChangeErrorRegexRollback = regexp.MustCompile(strings.Join(cmdArgs.Vals, " ")) + require.Nil(t, schemaChangeErrorRegex, "rollback and current stage errors cannot be set concurrently") + case "rollback": + rollback, err := strconv.ParseBool(cmdArgs.Vals[0]) + require.NoError(t, err) + key.rollback = rollback default: require.Failf(t, "unknown key encountered", "key was %s", cmdArgs.Key) } @@ -376,11 +409,12 @@ func (m *stageExecStmtMap) parseStageCommon( entry := stageKeyEntry{ stageKey: key, stmt: &stageExecStmt{ - execType: execType, - stmts: stmts, - observedOutput: "", - expectedOutput: d.Expected, - schemaChangeErrorRegex: schemaChangeErrorRegex, + execType: execType, + stmts: stmts, + observedOutput: "", + expectedOutput: d.Expected, + schemaChangeErrorRegex: schemaChangeErrorRegex, + schemaChangeErrorRegexRollback: schemaChangeErrorRegexRollback, }, } m.entries = append(m.entries, entry) @@ -814,31 +848,36 @@ func ExecuteWithDMLInjection(t *testing.T, relPath string, newCluster NewCluster } testDMLInjectionCase = func(t *testing.T, setup, stmts []parser.Statement, injection stageKey) { var schemaChangeErrorRegex *regexp.Regexp + var lastRollbackStageKey *stageKey usedStages := make(map[int]struct{}) successfulStages := 0 var tdb *sqlutils.SQLRunner _, db, cleanup := newCluster(t, &scexec.TestingKnobs{ BeforeStage: func(p scplan.Plan, stageIdx int) error { - // FIXME: Support rollback detection s := p.Stages[stageIdx] - if !p.CurrentState.InRollback && - !p.InRollback && - injection.phase == p.Stages[stageIdx].Phase && + if (injection.phase == p.Stages[stageIdx].Phase && p.Stages[stageIdx].Ordinal >= injection.minOrdinal && - p.Stages[stageIdx].Ordinal <= injection.maxOrdinal { + p.Stages[stageIdx].Ordinal <= injection.maxOrdinal) || + (p.InRollback || p.CurrentState.InRollback) || /* Rollbacks are always injected */ + (p.Stages[stageIdx].Phase == scop.PreCommitPhase) { jobErrorMutex.Lock() defer jobErrorMutex.Unlock() - key := makeStageKey(s.Phase, s.Ordinal) + key := makeStageKey(s.Phase, s.Ordinal, p.InRollback || p.CurrentState.InRollback) if _, ok := usedStages[key.AsInt()]; !ok { - successfulStages++ + // Rollbacks don't count towards the successful count + if !p.InRollback && !p.CurrentState.InRollback && + p.Stages[stageIdx].Phase != scop.PreCommitPhase { + successfulStages++ + } else { + lastRollbackStageKey = &key + } injectStmts := injectionFunc(key, tdb, successfulStages) regexSetOnce := false - schemaChangeErrorRegex = nil for _, injectStmt := range injectStmts { if injectStmt != nil && - injectStmt.HasSchemaChangeError() { + injectStmt.HasAnySchemaChangeError() != nil { require.Falsef(t, regexSetOnce, "multiple statements are expecting errors in the same phase.") - schemaChangeErrorRegex = injectStmt.schemaChangeErrorRegex + schemaChangeErrorRegex = injectStmt.HasAnySchemaChangeError() regexSetOnce = true t.Logf("Expecting schema change error: %v", schemaChangeErrorRegex) } @@ -867,6 +906,12 @@ func ExecuteWithDMLInjection(t *testing.T, relPath string, newCluster NewCluster require.NoError(t, executeSchemaChangeTxn( context.Background(), t, setup, stmts, db, nil, nil, onError, )) + // Re-inject anything from the rollback once the job transaction + // commits, this enforces any sanity checks one last time in + // the final descriptor state. + if lastRollbackStageKey != nil { + injectionFunc(*lastRollbackStageKey, tdb, successfulStages) + } require.Equal(t, errorDetected, schemaChangeErrorRegex != nil) } cumulativeTest(t, relPath, testFunc) diff --git a/pkg/sql/schemachanger/sctest_generated_test.go b/pkg/sql/schemachanger/sctest_generated_test.go index 77b94d9f7916..4a891cb1c7b4 100644 --- a/pkg/sql/schemachanger/sctest_generated_test.go +++ b/pkg/sql/schemachanger/sctest_generated_test.go @@ -120,6 +120,56 @@ func TestRollback_add_column_no_default(t *testing.T) { defer log.Scope(t).Close(t) sctest.Rollback(t, "pkg/sql/schemachanger/testdata/end_to_end/add_column_no_default", sctest.SingleNodeCluster) } +func TestEndToEndSideEffects_add_column_with_stored(t *testing.T) { + defer leaktest.AfterTest(t)() + defer log.Scope(t).Close(t) + sctest.EndToEndSideEffects(t, "pkg/sql/schemachanger/testdata/end_to_end/add_column_with_stored", sctest.SingleNodeCluster) +} +func TestExecuteWithDMLInjection_add_column_with_stored(t *testing.T) { + defer leaktest.AfterTest(t)() + defer log.Scope(t).Close(t) + sctest.ExecuteWithDMLInjection(t, "pkg/sql/schemachanger/testdata/end_to_end/add_column_with_stored", sctest.SingleNodeCluster) +} +func TestGenerateSchemaChangeCorpus_add_column_with_stored(t *testing.T) { + defer leaktest.AfterTest(t)() + defer log.Scope(t).Close(t) + sctest.GenerateSchemaChangeCorpus(t, "pkg/sql/schemachanger/testdata/end_to_end/add_column_with_stored", sctest.SingleNodeCluster) +} +func TestPause_add_column_with_stored(t *testing.T) { + defer leaktest.AfterTest(t)() + defer log.Scope(t).Close(t) + sctest.Pause(t, "pkg/sql/schemachanger/testdata/end_to_end/add_column_with_stored", sctest.SingleNodeCluster) +} +func TestRollback_add_column_with_stored(t *testing.T) { + defer leaktest.AfterTest(t)() + defer log.Scope(t).Close(t) + sctest.Rollback(t, "pkg/sql/schemachanger/testdata/end_to_end/add_column_with_stored", sctest.SingleNodeCluster) +} +func TestEndToEndSideEffects_add_column_with_stored_family(t *testing.T) { + defer leaktest.AfterTest(t)() + defer log.Scope(t).Close(t) + sctest.EndToEndSideEffects(t, "pkg/sql/schemachanger/testdata/end_to_end/add_column_with_stored_family", sctest.SingleNodeCluster) +} +func TestExecuteWithDMLInjection_add_column_with_stored_family(t *testing.T) { + defer leaktest.AfterTest(t)() + defer log.Scope(t).Close(t) + sctest.ExecuteWithDMLInjection(t, "pkg/sql/schemachanger/testdata/end_to_end/add_column_with_stored_family", sctest.SingleNodeCluster) +} +func TestGenerateSchemaChangeCorpus_add_column_with_stored_family(t *testing.T) { + defer leaktest.AfterTest(t)() + defer log.Scope(t).Close(t) + sctest.GenerateSchemaChangeCorpus(t, "pkg/sql/schemachanger/testdata/end_to_end/add_column_with_stored_family", sctest.SingleNodeCluster) +} +func TestPause_add_column_with_stored_family(t *testing.T) { + defer leaktest.AfterTest(t)() + defer log.Scope(t).Close(t) + sctest.Pause(t, "pkg/sql/schemachanger/testdata/end_to_end/add_column_with_stored_family", sctest.SingleNodeCluster) +} +func TestRollback_add_column_with_stored_family(t *testing.T) { + defer leaktest.AfterTest(t)() + defer log.Scope(t).Close(t) + sctest.Rollback(t, "pkg/sql/schemachanger/testdata/end_to_end/add_column_with_stored_family", sctest.SingleNodeCluster) +} func TestEndToEndSideEffects_alter_table_add_check_udf(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) diff --git a/pkg/sql/schemachanger/sctest_mixed_generated_test.go b/pkg/sql/schemachanger/sctest_mixed_generated_test.go index cee2a720f00e..71f48ad54f4a 100644 --- a/pkg/sql/schemachanger/sctest_mixed_generated_test.go +++ b/pkg/sql/schemachanger/sctest_mixed_generated_test.go @@ -40,6 +40,16 @@ func TestValidateMixedVersionElements_add_column_no_default(t *testing.T) { defer log.Scope(t).Close(t) sctest.ValidateMixedVersionElements(t, "pkg/sql/schemachanger/testdata/end_to_end/add_column_no_default", sctest.SingleNodeMixedCluster) } +func TestValidateMixedVersionElements_add_column_with_stored(t *testing.T) { + defer leaktest.AfterTest(t)() + defer log.Scope(t).Close(t) + sctest.ValidateMixedVersionElements(t, "pkg/sql/schemachanger/testdata/end_to_end/add_column_with_stored", sctest.SingleNodeMixedCluster) +} +func TestValidateMixedVersionElements_add_column_with_stored_family(t *testing.T) { + defer leaktest.AfterTest(t)() + defer log.Scope(t).Close(t) + sctest.ValidateMixedVersionElements(t, "pkg/sql/schemachanger/testdata/end_to_end/add_column_with_stored_family", sctest.SingleNodeMixedCluster) +} func TestValidateMixedVersionElements_alter_table_add_check_udf(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) diff --git a/pkg/sql/schemachanger/testdata/end_to_end/add_column_with_stored b/pkg/sql/schemachanger/testdata/end_to_end/add_column_with_stored new file mode 100644 index 000000000000..a78b3ac066bc --- /dev/null +++ b/pkg/sql/schemachanger/testdata/end_to_end/add_column_with_stored @@ -0,0 +1,716 @@ +setup +CREATE DATABASE db; +CREATE TABLE db.public.tbl (i INT PRIMARY KEY, k INT); +CREATE SEQUENCE db.public.sq1; +---- +... ++database {0 0 db} -> 104 ++schema {104 0 public} -> 105 ++object {104 105 tbl} -> 106 ++object {104 105 sq1} -> 107 + +stage-exec phase=PreCommitPhase stage=1 schemaChangeExecErrorForRollback=(.*validation of column "j" NOT NULL failed on row:.*) +INSERT INTO db.public.tbl VALUES (-1, -1),(-2, -2),(-3, -3), (-7, NULL); +---- + +# Each insert will be injected twice per stage, plus 1 extra. +stage-query phase=PostCommitPhase stage=: rollback=true +SELECT count(*)=($successfulStageCount*2)+4 FROM db.public.tbl; +---- +true + +# Each insert will be injected twice per stage, plus 1 extra. +stage-query phase=PostCommitNonRevertiblePhase stage=: rollback=true +SELECT count(*)=($successfulStageCount*2)+4 FROM db.public.tbl; +---- +true + +stage-exec phase=PostCommitPhase stage=: +INSERT INTO db.public.tbl VALUES($stageKey, 1); +INSERT INTO db.public.tbl VALUES($stageKey + 1, 1); +UPDATE db.public.tbl SET k=$stageKey WHERE i <> -7; +UPDATE db.public.tbl SET k=i WHERE i <> -7; +DELETE FROM db.public.tbl WHERE i=-1; +DELETE FROM db.public.tbl WHERE i=$stageKey; +INSERT INTO db.public.tbl VALUES($stageKey, 1); +INSERT INTO db.public.tbl VALUES(-1, -1); +---- + +# Each insert will be injected twice per stage, plus 1 extra. +stage-query phase=PostCommitPhase stage=: +SELECT count(*)=($successfulStageCount*2)+4 FROM db.public.tbl; +---- +true + + +stage-exec phase=PostCommitNonRevertiblePhase stage=: +INSERT INTO db.public.tbl VALUES($stageKey); +INSERT INTO db.public.tbl VALUES($stageKey + 1); +UPDATE db.public.tbl SET k=$stageKey; +UPDATE db.public.tbl SET k=i; +DELETE FROM db.public.tbl WHERE i=-1; +DELETE FROM db.public.tbl WHERE i=$stageKey; +INSERT INTO db.public.tbl VALUES($stageKey); +INSERT INTO db.public.tbl VALUES(-1); +---- + +# Each insert will be injected twice per stage, , plus 1 extra. +stage-query phase=PostCommitNonRevertiblePhase stage=: +SELECT count(*)=($successfulStageCount*2)+1 FROM db.public.tbl; +---- +true + +test +ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL AS (k) STORED +---- +begin transaction #1 +# begin StatementPhase +checking for feature: ALTER TABLE +increment telemetry for sql.schema.alter_table +increment telemetry for sql.schema.alter_table.add_column +increment telemetry for sql.schema.qualifcation.computed +increment telemetry for sql.schema.new_column_type.int8 +write *eventpb.AlterTable to event log: + mutationId: 1 + sql: + descriptorId: 106 + statement: ALTER TABLE ‹db›.‹public›.‹tbl› ADD COLUMN ‹j› INT8 NOT NULL AS (‹k›) + STORED + tag: ALTER TABLE + user: root + tableName: db.public.tbl +## StatementPhase stage 1 of 1 with 11 MutationType ops +upsert descriptor #106 + ... + - 1 + - 2 + + - 3 + columnNames: + - i + - k + + - j + defaultColumnId: 2 + name: primary + ... + id: 106 + modificationTime: {} + + mutations: + + - column: + + computeExpr: k + + id: 3 + + name: j + + nullable: true + + pgAttributeNum: 3 + + type: + + family: IntFamily + + oid: 20 + + width: 64 + + direction: ADD + + mutationId: 1 + + state: DELETE_ONLY + + - direction: ADD + + index: + + constraintId: 2 + + createdExplicitly: true + + encodingType: 1 + + foreignKey: {} + + geoConfig: {} + + id: 2 + + interleave: {} + + keyColumnDirections: + + - ASC + + keyColumnIds: + + - 1 + + keyColumnNames: + + - i + + name: crdb_internal_index_2_name_placeholder + + partitioning: {} + + sharded: {} + + storeColumnIds: + + - 2 + + - 3 + + storeColumnNames: + + - k + + - j + + 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: + + - i + + name: crdb_internal_index_3_name_placeholder + + partitioning: {} + + sharded: {} + + storeColumnIds: + + - 2 + + - 3 + + storeColumnNames: + + - k + + - j + + unique: true + + useDeletePreservingEncoding: true + + version: 4 + + mutationId: 1 + + state: DELETE_ONLY + name: tbl + - nextColumnId: 3 + - nextConstraintId: 2 + + nextColumnId: 4 + + nextConstraintId: 4 + nextFamilyId: 1 + - nextIndexId: 2 + + nextIndexId: 4 + nextMutationId: 1 + parentId: 104 + ... + time: {} + unexposedParentSchemaId: 105 + - version: "1" + + version: "2" +# end StatementPhase +# begin PreCommitPhase +## PreCommitPhase stage 1 of 2 with 1 MutationType op +undo all catalog changes within txn #1 +persist all catalog changes to storage +## PreCommitPhase stage 2 of 2 with 15 MutationType ops +upsert descriptor #106 + ... + createAsOfTime: + wallTime: "1640995200000000000" + + declarativeSchemaChangerState: + + authorization: + + userName: root + + currentStatuses: + + jobId: "1" + + relevantStatements: + + - statement: + + redactedStatement: ALTER TABLE ‹db›.‹public›.‹tbl› ADD COLUMN ‹j› INT8 NOT + + NULL AS (‹k›) STORED + + statement: ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL AS (k) STORED + + statementTag: ALTER TABLE + + revertible: true + + targetRanks: + + targets: + families: + - columnIds: + - 1 + - 2 + + - 3 + columnNames: + - i + - k + + - j + defaultColumnId: 2 + name: primary + ... + id: 106 + modificationTime: {} + + mutations: + + - column: + + computeExpr: k + + id: 3 + + name: j + + nullable: true + + pgAttributeNum: 3 + + type: + + family: IntFamily + + oid: 20 + + width: 64 + + direction: ADD + + mutationId: 1 + + state: DELETE_ONLY + + - direction: ADD + + index: + + constraintId: 2 + + createdExplicitly: true + + encodingType: 1 + + foreignKey: {} + + geoConfig: {} + + id: 2 + + interleave: {} + + keyColumnDirections: + + - ASC + + keyColumnIds: + + - 1 + + keyColumnNames: + + - i + + name: crdb_internal_index_2_name_placeholder + + partitioning: {} + + sharded: {} + + storeColumnIds: + + - 2 + + - 3 + + storeColumnNames: + + - k + + - j + + 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: + + - i + + name: crdb_internal_index_3_name_placeholder + + partitioning: {} + + sharded: {} + + storeColumnIds: + + - 2 + + - 3 + + storeColumnNames: + + - k + + - j + + unique: true + + useDeletePreservingEncoding: true + + version: 4 + + mutationId: 1 + + state: DELETE_ONLY + name: tbl + - nextColumnId: 3 + - nextConstraintId: 2 + + nextColumnId: 4 + + nextConstraintId: 4 + nextFamilyId: 1 + - nextIndexId: 2 + + nextIndexId: 4 + nextMutationId: 1 + parentId: 104 + ... + time: {} + unexposedParentSchemaId: 105 + - version: "1" + + version: "2" +persist all catalog changes to storage +create job #1 (non-cancelable: false): "ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL AS (k) STORED" + descriptor IDs: [106] +# 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 7 with 5 MutationType ops +upsert descriptor #106 + table: + + checks: + + - columnIds: + + - 3 + + expr: j IS NOT NULL + + isNonNullConstraint: true + + name: j_auto_not_null + + validity: Validating + columns: + - id: 1 + ... + direction: ADD + mutationId: 1 + - state: DELETE_ONLY + + state: WRITE_ONLY + - direction: ADD + index: + ... + version: 4 + mutationId: 1 + - state: DELETE_ONLY + + state: WRITE_ONLY + + - constraint: + + check: + + columnIds: + + - 3 + + expr: j IS NOT NULL + + isNonNullConstraint: true + + name: j_auto_not_null + + validity: Validating + + constraintType: NOT_NULL + + foreignKey: {} + + name: j_auto_not_null + + notNullColumn: 3 + + uniqueWithoutIndexConstraint: {} + + direction: ADD + + mutationId: 1 + + state: WRITE_ONLY + name: tbl + nextColumnId: 4 + ... + time: {} + unexposedParentSchemaId: 105 + - version: "2" + + version: "3" +persist all catalog changes to storage +update progress of schema change job #1: "PostCommitPhase stage 2 of 7 with 1 BackfillType op pending" +commit transaction #3 +begin transaction #4 +## PostCommitPhase stage 2 of 7 with 1 BackfillType op +backfill indexes [2] from index #1 in table #106 +commit transaction #4 +begin transaction #5 +## PostCommitPhase stage 3 of 7 with 3 MutationType ops +upsert descriptor #106 + ... + version: 4 + mutationId: 1 + - state: BACKFILLING + + state: DELETE_ONLY + - direction: ADD + index: + ... + time: {} + unexposedParentSchemaId: 105 + - version: "3" + + version: "4" +persist all catalog changes to storage +update progress of schema change job #1: "PostCommitPhase stage 4 of 7 with 1 MutationType op pending" +commit transaction #5 +begin transaction #6 +## PostCommitPhase stage 4 of 7 with 3 MutationType ops +upsert descriptor #106 + ... + version: 4 + mutationId: 1 + - state: DELETE_ONLY + + state: MERGING + - direction: ADD + index: + ... + time: {} + unexposedParentSchemaId: 105 + - version: "4" + + version: "5" +persist all catalog changes to storage +update progress of schema change job #1: "PostCommitPhase stage 5 of 7 with 1 BackfillType op pending" +commit transaction #6 +begin transaction #7 +## PostCommitPhase stage 5 of 7 with 1 BackfillType op +merge temporary indexes [3] into backfilled indexes [2] in table #106 +commit transaction #7 +begin transaction #8 +## PostCommitPhase stage 6 of 7 with 3 MutationType ops +upsert descriptor #106 + ... + version: 4 + mutationId: 1 + - state: MERGING + + state: WRITE_ONLY + - direction: ADD + index: + ... + time: {} + unexposedParentSchemaId: 105 + - version: "5" + + version: "6" +persist all catalog changes to storage +update progress of schema change job #1: "PostCommitPhase stage 7 of 7 with 2 ValidationType ops pending" +commit transaction #8 +begin transaction #9 +## PostCommitPhase stage 7 of 7 with 2 ValidationType ops +validate forward indexes [2] in table #106 +validate CHECK constraint j_auto_not_null in table #106 +commit transaction #9 +begin transaction #10 +## PostCommitNonRevertiblePhase stage 1 of 3 with 13 MutationType ops +upsert descriptor #106 + table: + - checks: + - - columnIds: + - - 3 + - expr: j IS NOT NULL + - isNonNullConstraint: true + - name: j_auto_not_null + - validity: Validating + + checks: [] + columns: + - id: 1 + ... + oid: 20 + width: 64 + + - computeExpr: k + + id: 3 + + name: j + + pgAttributeNum: 3 + + type: + + family: IntFamily + + oid: 20 + + width: 64 + createAsOfTime: + wallTime: "1640995200000000000" + ... + statement: ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL AS (k) STORED + statementTag: ALTER TABLE + - revertible: true + targetRanks: + targets: + ... + modificationTime: {} + mutations: + - - column: + - computeExpr: k + - id: 3 + - name: j + - nullable: true + - pgAttributeNum: 3 + - type: + - family: IntFamily + - oid: 20 + - width: 64 + - direction: ADD + - mutationId: 1 + - state: WRITE_ONLY + - - direction: ADD + + - direction: DROP + index: + - constraintId: 2 + + constraintId: 3 + createdExplicitly: true + encodingType: 1 + foreignKey: {} + geoConfig: {} + - id: 2 + + id: 3 + interleave: {} + keyColumnDirections: + ... + keyColumnNames: + - i + - name: crdb_internal_index_2_name_placeholder + + name: crdb_internal_index_3_name_placeholder + partitioning: {} + sharded: {} + ... + - j + unique: true + + useDeletePreservingEncoding: true + version: 4 + mutationId: 1 + - state: WRITE_ONLY + - - direction: ADD + + state: DELETE_ONLY + + - direction: DROP + index: + - constraintId: 3 + - createdExplicitly: true + + constraintId: 1 + + createdAtNanos: "1640995200000000000" + encodingType: 1 + foreignKey: {} + geoConfig: {} + - id: 3 + + id: 1 + interleave: {} + keyColumnDirections: + ... + keyColumnNames: + - i + - name: crdb_internal_index_3_name_placeholder + + name: crdb_internal_index_1_name_placeholder + partitioning: {} + sharded: {} + storeColumnIds: + - 2 + - - 3 + storeColumnNames: + - k + - - j + unique: true + - useDeletePreservingEncoding: true + version: 4 + mutationId: 1 + state: WRITE_ONLY + - - constraint: + - check: + - columnIds: + - - 3 + - expr: j IS NOT NULL + - isNonNullConstraint: true + - name: j_auto_not_null + - validity: Validating + - constraintType: NOT_NULL + - foreignKey: {} + - name: j_auto_not_null + - notNullColumn: 3 + - uniqueWithoutIndexConstraint: {} + - direction: ADD + - mutationId: 1 + - state: WRITE_ONLY + name: tbl + nextColumnId: 4 + ... + parentId: 104 + primaryIndex: + - constraintId: 1 + - createdAtNanos: "1640995200000000000" + + constraintId: 2 + + createdExplicitly: true + encodingType: 1 + foreignKey: {} + geoConfig: {} + - id: 1 + + id: 2 + interleave: {} + keyColumnDirections: + ... + storeColumnIds: + - 2 + + - 3 + storeColumnNames: + - k + + - j + unique: true + version: 4 + ... + time: {} + unexposedParentSchemaId: 105 + - version: "6" + + version: "7" +persist all catalog changes to storage +adding table for stats refresh: 106 +update progress of schema change job #1: "PostCommitNonRevertiblePhase stage 2 of 3 with 4 MutationType ops pending" +set schema change job #1 to non-cancellable +commit transaction #10 +begin transaction #11 +## PostCommitNonRevertiblePhase stage 2 of 3 with 6 MutationType ops +upsert descriptor #106 + ... + - direction: DROP + index: + - constraintId: 3 + - createdExplicitly: true + - encodingType: 1 + - foreignKey: {} + - geoConfig: {} + - id: 3 + - interleave: {} + - keyColumnDirections: + - - ASC + - keyColumnIds: + - - 1 + - keyColumnNames: + - - i + - name: crdb_internal_index_3_name_placeholder + - partitioning: {} + - sharded: {} + - storeColumnIds: + - - 2 + - - 3 + - storeColumnNames: + - - k + - - j + - unique: true + - useDeletePreservingEncoding: true + - version: 4 + - mutationId: 1 + - state: DELETE_ONLY + - - direction: DROP + - index: + constraintId: 1 + createdAtNanos: "1640995200000000000" + ... + version: 4 + mutationId: 1 + - state: WRITE_ONLY + + state: DELETE_ONLY + name: tbl + nextColumnId: 4 + ... + time: {} + unexposedParentSchemaId: 105 + - version: "7" + + version: "8" +persist all catalog changes to storage +update progress of schema change job #1: "PostCommitNonRevertiblePhase stage 3 of 3 with 3 MutationType ops pending" +commit transaction #11 +begin transaction #12 +## PostCommitNonRevertiblePhase stage 3 of 3 with 5 MutationType ops +upsert descriptor #106 + ... + createAsOfTime: + wallTime: "1640995200000000000" + - declarativeSchemaChangerState: + - authorization: + - userName: root + - currentStatuses: + - jobId: "1" + - relevantStatements: + - - statement: + - redactedStatement: ALTER TABLE ‹db›.‹public›.‹tbl› ADD COLUMN ‹j› INT8 NOT + - NULL AS (‹k›) STORED + - statement: ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL AS (k) STORED + - statementTag: ALTER TABLE + - targetRanks: + - targets: + families: + - columnIds: + ... + id: 106 + modificationTime: {} + - mutations: + - - direction: DROP + - index: + - constraintId: 1 + - createdAtNanos: "1640995200000000000" + - encodingType: 1 + - foreignKey: {} + - geoConfig: {} + - id: 1 + - interleave: {} + - keyColumnDirections: + - - ASC + - keyColumnIds: + - - 1 + - keyColumnNames: + - - i + - name: crdb_internal_index_1_name_placeholder + - partitioning: {} + - sharded: {} + - storeColumnIds: + - - 2 + - storeColumnNames: + - - k + - unique: true + - version: 4 + - mutationId: 1 + - state: DELETE_ONLY + + mutations: [] + name: tbl + nextColumnId: 4 + ... + time: {} + unexposedParentSchemaId: 105 + - version: "8" + + version: "9" +persist all catalog changes to storage +create job #2 (non-cancelable: true): "GC for ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL AS (k) STORED" + descriptor IDs: [106] +update progress of schema change job #1: "all stages completed" +set schema change job #1 to non-cancellable +updated schema change job #1 descriptor IDs to [] +write *eventpb.FinishSchemaChange to event log: + sc: + descriptorId: 106 +commit transaction #12 +notified job registry to adopt jobs: [2] +# end PostCommitPhase diff --git a/pkg/sql/schemachanger/testdata/end_to_end/add_column_with_stored_family b/pkg/sql/schemachanger/testdata/end_to_end/add_column_with_stored_family new file mode 100644 index 000000000000..a89bbbf7539e --- /dev/null +++ b/pkg/sql/schemachanger/testdata/end_to_end/add_column_with_stored_family @@ -0,0 +1,721 @@ +setup +CREATE DATABASE db; +CREATE TABLE db.public.tbl (i INT PRIMARY KEY, k INT); +CREATE SEQUENCE db.public.sq1; +---- +... ++database {0 0 db} -> 104 ++schema {104 0 public} -> 105 ++object {104 105 tbl} -> 106 ++object {104 105 sq1} -> 107 + +stage-exec phase=PreCommitPhase stage=1 schemaChangeExecErrorForRollback=(.*validation of column "j" NOT NULL failed on row:.*) +INSERT INTO db.public.tbl VALUES (-1, -1),(-2, -2),(-3, -3), (-7, NULL); +---- + +# Each insert will be injected twice per stage, plus 1 extra. +stage-query phase=PostCommitPhase stage=: rollback=true +SELECT count(*)=($successfulStageCount*2)+4 FROM db.public.tbl; +---- +true + +# Each insert will be injected twice per stage, plus 1 extra. +stage-query phase=PostCommitNonRevertiblePhase stage=: rollback=true +SELECT count(*)=($successfulStageCount*2)+4 FROM db.public.tbl; +---- +true + +stage-exec phase=PostCommitPhase stage=: +INSERT INTO db.public.tbl VALUES($stageKey, 1); +INSERT INTO db.public.tbl VALUES($stageKey + 1, 1); +UPDATE db.public.tbl SET k=$stageKey WHERE i <> -7; +UPDATE db.public.tbl SET k=i WHERE i <> -7; +DELETE FROM db.public.tbl WHERE i=-1; +DELETE FROM db.public.tbl WHERE i=$stageKey; +INSERT INTO db.public.tbl VALUES($stageKey, 1); +INSERT INTO db.public.tbl VALUES(-1, -1); +---- + +# Each insert will be injected twice per stage, plus 1 extra. +stage-query phase=PostCommitPhase stage=: +SELECT count(*)=($successfulStageCount*2)+4 FROM db.public.tbl; +---- +true + + +stage-exec phase=PostCommitNonRevertiblePhase stage=: +INSERT INTO db.public.tbl VALUES($stageKey); +INSERT INTO db.public.tbl VALUES($stageKey + 1); +UPDATE db.public.tbl SET k=$stageKey; +UPDATE db.public.tbl SET k=i; +DELETE FROM db.public.tbl WHERE i=-1; +DELETE FROM db.public.tbl WHERE i=$stageKey; +INSERT INTO db.public.tbl VALUES($stageKey); +INSERT INTO db.public.tbl VALUES(-1); +---- + +# Each insert will be injected twice per stage, , plus 1 extra. +stage-query phase=PostCommitNonRevertiblePhase stage=: +SELECT count(*)=($successfulStageCount*2)+1 FROM db.public.tbl; +---- +true + +test +ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL AS (k) STORED CREATE FAMILY bob +---- +begin transaction #1 +# begin StatementPhase +checking for feature: ALTER TABLE +increment telemetry for sql.schema.alter_table +increment telemetry for sql.schema.alter_table.add_column +increment telemetry for sql.schema.qualifcation.computed +increment telemetry for sql.schema.new_column_type.int8 +write *eventpb.AlterTable to event log: + mutationId: 1 + sql: + descriptorId: 106 + statement: ALTER TABLE ‹db›.‹public›.‹tbl› ADD COLUMN ‹j› INT8 NOT NULL AS (‹k›) + STORED CREATE FAMILY ‹bob› + tag: ALTER TABLE + user: root + tableName: db.public.tbl +## StatementPhase stage 1 of 1 with 12 MutationType ops +upsert descriptor #106 + ... + defaultColumnId: 2 + name: primary + + - columnIds: + + - 3 + + columnNames: + + - j + + defaultColumnId: 3 + + id: 1 + + name: bob + formatVersion: 3 + id: 106 + modificationTime: {} + + mutations: + + - column: + + computeExpr: k + + id: 3 + + name: j + + nullable: true + + pgAttributeNum: 3 + + type: + + family: IntFamily + + oid: 20 + + width: 64 + + direction: ADD + + mutationId: 1 + + state: DELETE_ONLY + + - direction: ADD + + index: + + constraintId: 2 + + createdExplicitly: true + + encodingType: 1 + + foreignKey: {} + + geoConfig: {} + + id: 2 + + interleave: {} + + keyColumnDirections: + + - ASC + + keyColumnIds: + + - 1 + + keyColumnNames: + + - i + + name: crdb_internal_index_2_name_placeholder + + partitioning: {} + + sharded: {} + + storeColumnIds: + + - 2 + + - 3 + + storeColumnNames: + + - k + + - j + + 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: + + - i + + name: crdb_internal_index_3_name_placeholder + + partitioning: {} + + sharded: {} + + storeColumnIds: + + - 2 + + - 3 + + storeColumnNames: + + - k + + - j + + unique: true + + useDeletePreservingEncoding: true + + version: 4 + + mutationId: 1 + + state: DELETE_ONLY + name: tbl + - nextColumnId: 3 + - nextConstraintId: 2 + - nextFamilyId: 1 + - nextIndexId: 2 + + nextColumnId: 4 + + nextConstraintId: 4 + + nextFamilyId: 2 + + nextIndexId: 4 + nextMutationId: 1 + parentId: 104 + ... + time: {} + unexposedParentSchemaId: 105 + - version: "1" + + version: "2" +# end StatementPhase +# begin PreCommitPhase +## PreCommitPhase stage 1 of 2 with 1 MutationType op +undo all catalog changes within txn #1 +persist all catalog changes to storage +## PreCommitPhase stage 2 of 2 with 16 MutationType ops +upsert descriptor #106 + ... + createAsOfTime: + wallTime: "1640995200000000000" + + declarativeSchemaChangerState: + + authorization: + + userName: root + + currentStatuses: + + jobId: "1" + + relevantStatements: + + - statement: + + redactedStatement: ALTER TABLE ‹db›.‹public›.‹tbl› ADD COLUMN ‹j› INT8 NOT + + NULL AS (‹k›) STORED CREATE FAMILY ‹bob› + + statement: ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL AS (k) STORED + + CREATE FAMILY bob + + statementTag: ALTER TABLE + + revertible: true + + targetRanks: + + targets: + families: + - columnIds: + ... + defaultColumnId: 2 + name: primary + + - columnIds: + + - 3 + + columnNames: + + - j + + defaultColumnId: 3 + + id: 1 + + name: bob + formatVersion: 3 + id: 106 + modificationTime: {} + + mutations: + + - column: + + computeExpr: k + + id: 3 + + name: j + + nullable: true + + pgAttributeNum: 3 + + type: + + family: IntFamily + + oid: 20 + + width: 64 + + direction: ADD + + mutationId: 1 + + state: DELETE_ONLY + + - direction: ADD + + index: + + constraintId: 2 + + createdExplicitly: true + + encodingType: 1 + + foreignKey: {} + + geoConfig: {} + + id: 2 + + interleave: {} + + keyColumnDirections: + + - ASC + + keyColumnIds: + + - 1 + + keyColumnNames: + + - i + + name: crdb_internal_index_2_name_placeholder + + partitioning: {} + + sharded: {} + + storeColumnIds: + + - 2 + + - 3 + + storeColumnNames: + + - k + + - j + + 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: + + - i + + name: crdb_internal_index_3_name_placeholder + + partitioning: {} + + sharded: {} + + storeColumnIds: + + - 2 + + - 3 + + storeColumnNames: + + - k + + - j + + unique: true + + useDeletePreservingEncoding: true + + version: 4 + + mutationId: 1 + + state: DELETE_ONLY + name: tbl + - nextColumnId: 3 + - nextConstraintId: 2 + - nextFamilyId: 1 + - nextIndexId: 2 + + nextColumnId: 4 + + nextConstraintId: 4 + + nextFamilyId: 2 + + nextIndexId: 4 + nextMutationId: 1 + parentId: 104 + ... + time: {} + unexposedParentSchemaId: 105 + - version: "1" + + version: "2" +persist all catalog changes to storage +create job #1 (non-cancelable: false): "ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL AS (k) STORED CREATE FAMILY bob" + descriptor IDs: [106] +# 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 7 with 5 MutationType ops +upsert descriptor #106 + table: + + checks: + + - columnIds: + + - 3 + + expr: j IS NOT NULL + + isNonNullConstraint: true + + name: j_auto_not_null + + validity: Validating + columns: + - id: 1 + ... + direction: ADD + mutationId: 1 + - state: DELETE_ONLY + + state: WRITE_ONLY + - direction: ADD + index: + ... + version: 4 + mutationId: 1 + - state: DELETE_ONLY + + state: WRITE_ONLY + + - constraint: + + check: + + columnIds: + + - 3 + + expr: j IS NOT NULL + + isNonNullConstraint: true + + name: j_auto_not_null + + validity: Validating + + constraintType: NOT_NULL + + foreignKey: {} + + name: j_auto_not_null + + notNullColumn: 3 + + uniqueWithoutIndexConstraint: {} + + direction: ADD + + mutationId: 1 + + state: WRITE_ONLY + name: tbl + nextColumnId: 4 + ... + time: {} + unexposedParentSchemaId: 105 + - version: "2" + + version: "3" +persist all catalog changes to storage +update progress of schema change job #1: "PostCommitPhase stage 2 of 7 with 1 BackfillType op pending" +commit transaction #3 +begin transaction #4 +## PostCommitPhase stage 2 of 7 with 1 BackfillType op +backfill indexes [2] from index #1 in table #106 +commit transaction #4 +begin transaction #5 +## PostCommitPhase stage 3 of 7 with 3 MutationType ops +upsert descriptor #106 + ... + version: 4 + mutationId: 1 + - state: BACKFILLING + + state: DELETE_ONLY + - direction: ADD + index: + ... + time: {} + unexposedParentSchemaId: 105 + - version: "3" + + version: "4" +persist all catalog changes to storage +update progress of schema change job #1: "PostCommitPhase stage 4 of 7 with 1 MutationType op pending" +commit transaction #5 +begin transaction #6 +## PostCommitPhase stage 4 of 7 with 3 MutationType ops +upsert descriptor #106 + ... + version: 4 + mutationId: 1 + - state: DELETE_ONLY + + state: MERGING + - direction: ADD + index: + ... + time: {} + unexposedParentSchemaId: 105 + - version: "4" + + version: "5" +persist all catalog changes to storage +update progress of schema change job #1: "PostCommitPhase stage 5 of 7 with 1 BackfillType op pending" +commit transaction #6 +begin transaction #7 +## PostCommitPhase stage 5 of 7 with 1 BackfillType op +merge temporary indexes [3] into backfilled indexes [2] in table #106 +commit transaction #7 +begin transaction #8 +## PostCommitPhase stage 6 of 7 with 3 MutationType ops +upsert descriptor #106 + ... + version: 4 + mutationId: 1 + - state: MERGING + + state: WRITE_ONLY + - direction: ADD + index: + ... + time: {} + unexposedParentSchemaId: 105 + - version: "5" + + version: "6" +persist all catalog changes to storage +update progress of schema change job #1: "PostCommitPhase stage 7 of 7 with 2 ValidationType ops pending" +commit transaction #8 +begin transaction #9 +## PostCommitPhase stage 7 of 7 with 2 ValidationType ops +validate forward indexes [2] in table #106 +validate CHECK constraint j_auto_not_null in table #106 +commit transaction #9 +begin transaction #10 +## PostCommitNonRevertiblePhase stage 1 of 3 with 13 MutationType ops +upsert descriptor #106 + table: + - checks: + - - columnIds: + - - 3 + - expr: j IS NOT NULL + - isNonNullConstraint: true + - name: j_auto_not_null + - validity: Validating + + checks: [] + columns: + - id: 1 + ... + oid: 20 + width: 64 + + - computeExpr: k + + id: 3 + + name: j + + pgAttributeNum: 3 + + type: + + family: IntFamily + + oid: 20 + + width: 64 + createAsOfTime: + wallTime: "1640995200000000000" + ... + CREATE FAMILY bob + statementTag: ALTER TABLE + - revertible: true + targetRanks: + targets: + ... + modificationTime: {} + mutations: + - - column: + - computeExpr: k + - id: 3 + - name: j + - nullable: true + - pgAttributeNum: 3 + - type: + - family: IntFamily + - oid: 20 + - width: 64 + - direction: ADD + - mutationId: 1 + - state: WRITE_ONLY + - - direction: ADD + + - direction: DROP + index: + - constraintId: 2 + + constraintId: 3 + createdExplicitly: true + encodingType: 1 + foreignKey: {} + geoConfig: {} + - id: 2 + + id: 3 + interleave: {} + keyColumnDirections: + ... + keyColumnNames: + - i + - name: crdb_internal_index_2_name_placeholder + + name: crdb_internal_index_3_name_placeholder + partitioning: {} + sharded: {} + ... + - j + unique: true + + useDeletePreservingEncoding: true + version: 4 + mutationId: 1 + - state: WRITE_ONLY + - - direction: ADD + + state: DELETE_ONLY + + - direction: DROP + index: + - constraintId: 3 + - createdExplicitly: true + + constraintId: 1 + + createdAtNanos: "1640995200000000000" + encodingType: 1 + foreignKey: {} + geoConfig: {} + - id: 3 + + id: 1 + interleave: {} + keyColumnDirections: + ... + keyColumnNames: + - i + - name: crdb_internal_index_3_name_placeholder + + name: crdb_internal_index_1_name_placeholder + partitioning: {} + sharded: {} + storeColumnIds: + - 2 + - - 3 + storeColumnNames: + - k + - - j + unique: true + - useDeletePreservingEncoding: true + version: 4 + mutationId: 1 + state: WRITE_ONLY + - - constraint: + - check: + - columnIds: + - - 3 + - expr: j IS NOT NULL + - isNonNullConstraint: true + - name: j_auto_not_null + - validity: Validating + - constraintType: NOT_NULL + - foreignKey: {} + - name: j_auto_not_null + - notNullColumn: 3 + - uniqueWithoutIndexConstraint: {} + - direction: ADD + - mutationId: 1 + - state: WRITE_ONLY + name: tbl + nextColumnId: 4 + ... + parentId: 104 + primaryIndex: + - constraintId: 1 + - createdAtNanos: "1640995200000000000" + + constraintId: 2 + + createdExplicitly: true + encodingType: 1 + foreignKey: {} + geoConfig: {} + - id: 1 + + id: 2 + interleave: {} + keyColumnDirections: + ... + storeColumnIds: + - 2 + + - 3 + storeColumnNames: + - k + + - j + unique: true + version: 4 + ... + time: {} + unexposedParentSchemaId: 105 + - version: "6" + + version: "7" +persist all catalog changes to storage +adding table for stats refresh: 106 +update progress of schema change job #1: "PostCommitNonRevertiblePhase stage 2 of 3 with 4 MutationType ops pending" +set schema change job #1 to non-cancellable +commit transaction #10 +begin transaction #11 +## PostCommitNonRevertiblePhase stage 2 of 3 with 6 MutationType ops +upsert descriptor #106 + ... + - direction: DROP + index: + - constraintId: 3 + - createdExplicitly: true + - encodingType: 1 + - foreignKey: {} + - geoConfig: {} + - id: 3 + - interleave: {} + - keyColumnDirections: + - - ASC + - keyColumnIds: + - - 1 + - keyColumnNames: + - - i + - name: crdb_internal_index_3_name_placeholder + - partitioning: {} + - sharded: {} + - storeColumnIds: + - - 2 + - - 3 + - storeColumnNames: + - - k + - - j + - unique: true + - useDeletePreservingEncoding: true + - version: 4 + - mutationId: 1 + - state: DELETE_ONLY + - - direction: DROP + - index: + constraintId: 1 + createdAtNanos: "1640995200000000000" + ... + version: 4 + mutationId: 1 + - state: WRITE_ONLY + + state: DELETE_ONLY + name: tbl + nextColumnId: 4 + ... + time: {} + unexposedParentSchemaId: 105 + - version: "7" + + version: "8" +persist all catalog changes to storage +update progress of schema change job #1: "PostCommitNonRevertiblePhase stage 3 of 3 with 3 MutationType ops pending" +commit transaction #11 +begin transaction #12 +## PostCommitNonRevertiblePhase stage 3 of 3 with 5 MutationType ops +upsert descriptor #106 + ... + createAsOfTime: + wallTime: "1640995200000000000" + - declarativeSchemaChangerState: + - authorization: + - userName: root + - currentStatuses: + - jobId: "1" + - relevantStatements: + - - statement: + - redactedStatement: ALTER TABLE ‹db›.‹public›.‹tbl› ADD COLUMN ‹j› INT8 NOT + - NULL AS (‹k›) STORED CREATE FAMILY ‹bob› + - statement: ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL AS (k) STORED + - CREATE FAMILY bob + - statementTag: ALTER TABLE + - targetRanks: + - targets: + families: + - columnIds: + ... + id: 106 + modificationTime: {} + - mutations: + - - direction: DROP + - index: + - constraintId: 1 + - createdAtNanos: "1640995200000000000" + - encodingType: 1 + - foreignKey: {} + - geoConfig: {} + - id: 1 + - interleave: {} + - keyColumnDirections: + - - ASC + - keyColumnIds: + - - 1 + - keyColumnNames: + - - i + - name: crdb_internal_index_1_name_placeholder + - partitioning: {} + - sharded: {} + - storeColumnIds: + - - 2 + - storeColumnNames: + - - k + - unique: true + - version: 4 + - mutationId: 1 + - state: DELETE_ONLY + + mutations: [] + name: tbl + nextColumnId: 4 + ... + time: {} + unexposedParentSchemaId: 105 + - version: "8" + + version: "9" +persist all catalog changes to storage +create job #2 (non-cancelable: true): "GC for ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL AS (k) STORED CREATE FAMILY bob" + descriptor IDs: [106] +update progress of schema change job #1: "all stages completed" +set schema change job #1 to non-cancellable +updated schema change job #1 descriptor IDs to [] +write *eventpb.FinishSchemaChange to event log: + sc: + descriptorId: 106 +commit transaction #12 +notified job registry to adopt jobs: [2] +# end PostCommitPhase diff --git a/pkg/sql/schemachanger/testdata/explain/add_column_with_stored b/pkg/sql/schemachanger/testdata/explain/add_column_with_stored new file mode 100644 index 000000000000..c2ff3608cf0b --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain/add_column_with_stored @@ -0,0 +1,193 @@ +/* setup */ +CREATE DATABASE db; +CREATE TABLE db.public.tbl (i INT PRIMARY KEY, k INT); +CREATE SEQUENCE db.public.sq1; + +/* test */ +EXPLAIN (ddl) ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL AS (k) STORED; +---- +Schema change plan for ALTER TABLE ‹db›.‹public›.‹tbl› ADD COLUMN ‹j› INT8 NOT NULL AS (‹k›) STORED; + ├── StatementPhase + │ └── Stage 1 of 1 in StatementPhase + │ ├── 8 elements transitioning toward PUBLIC + │ │ ├── ABSENT → DELETE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ ├── ABSENT → PUBLIC ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 3} + │ │ ├── ABSENT → BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ └── ABSENT → PUBLIC IndexData:{DescID: 106, IndexID: 2} + │ ├── 4 elements transitioning toward TRANSIENT_ABSENT + │ │ ├── ABSENT → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ └── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ └── 11 Mutation operations + │ ├── MakeAbsentColumnDeleteOnly {"Column":{"ColumnID":3,"PgAttributeNum":3,"TableID":106}} + │ ├── SetColumnName {"ColumnID":3,"Name":"j","TableID":106} + │ ├── SetAddedColumnType {"ColumnType":{"ColumnID":3,"TableID":106}} + │ ├── MakeAbsentIndexBackfilling {"Index":{"ConstraintID":2,"IndexID":2,"IsUnique":true,"SourceIndexID":1,"TableID":106,"TemporaryIndexID":3}} + │ ├── AddColumnToIndex {"ColumnID":1,"IndexID":2,"TableID":106} + │ ├── AddColumnToIndex {"ColumnID":2,"IndexID":2,"Kind":2,"TableID":106} + │ ├── AddColumnToIndex {"ColumnID":3,"IndexID":2,"Kind":2,"Ordinal":1,"TableID":106} + │ ├── MakeAbsentTempIndexDeleteOnly {"Index":{"ConstraintID":3,"IndexID":3,"IsUnique":true,"SourceIndexID":1,"TableID":106}} + │ ├── AddColumnToIndex {"ColumnID":1,"IndexID":3,"TableID":106} + │ ├── AddColumnToIndex {"ColumnID":2,"IndexID":3,"Kind":2,"TableID":106} + │ └── AddColumnToIndex {"ColumnID":3,"IndexID":3,"Kind":2,"Ordinal":1,"TableID":106} + ├── PreCommitPhase + │ ├── Stage 1 of 2 in PreCommitPhase + │ │ ├── 8 elements transitioning toward PUBLIC + │ │ │ ├── DELETE_ONLY → ABSENT Column:{DescID: 106, ColumnID: 3} + │ │ │ ├── PUBLIC → ABSENT ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ │ ├── PUBLIC → ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 3} + │ │ │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ └── PUBLIC → ABSENT IndexData:{DescID: 106, IndexID: 2} + │ │ ├── 4 elements transitioning toward TRANSIENT_ABSENT + │ │ │ ├── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ └── 1 Mutation operation + │ │ └── UndoAllInTxnImmediateMutationOpSideEffects + │ └── Stage 2 of 2 in PreCommitPhase + │ ├── 8 elements transitioning toward PUBLIC + │ │ ├── ABSENT → DELETE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ ├── ABSENT → PUBLIC ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 3} + │ │ ├── ABSENT → BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ └── ABSENT → PUBLIC IndexData:{DescID: 106, IndexID: 2} + │ ├── 4 elements transitioning toward TRANSIENT_ABSENT + │ │ ├── ABSENT → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ └── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ └── 15 Mutation operations + │ ├── MakeAbsentColumnDeleteOnly {"Column":{"ColumnID":3,"PgAttributeNum":3,"TableID":106}} + │ ├── SetColumnName {"ColumnID":3,"Name":"j","TableID":106} + │ ├── SetAddedColumnType {"ColumnType":{"ColumnID":3,"TableID":106}} + │ ├── MakeAbsentIndexBackfilling {"Index":{"ConstraintID":2,"IndexID":2,"IsUnique":true,"SourceIndexID":1,"TableID":106,"TemporaryIndexID":3}} + │ ├── MaybeAddSplitForIndex {"IndexID":2,"TableID":106} + │ ├── AddColumnToIndex {"ColumnID":1,"IndexID":2,"TableID":106} + │ ├── AddColumnToIndex {"ColumnID":2,"IndexID":2,"Kind":2,"TableID":106} + │ ├── AddColumnToIndex {"ColumnID":3,"IndexID":2,"Kind":2,"Ordinal":1,"TableID":106} + │ ├── MakeAbsentTempIndexDeleteOnly {"Index":{"ConstraintID":3,"IndexID":3,"IsUnique":true,"SourceIndexID":1,"TableID":106}} + │ ├── MaybeAddSplitForIndex {"IndexID":3,"TableID":106} + │ ├── AddColumnToIndex {"ColumnID":1,"IndexID":3,"TableID":106} + │ ├── AddColumnToIndex {"ColumnID":2,"IndexID":3,"Kind":2,"TableID":106} + │ ├── AddColumnToIndex {"ColumnID":3,"IndexID":3,"Kind":2,"Ordinal":1,"TableID":106} + │ ├── SetJobStateOnDescriptor {"DescriptorID":106,"Initialize":true} + │ └── CreateSchemaChangerJob {"RunningStatus":"PostCommitPhase ..."} + ├── PostCommitPhase + │ ├── Stage 1 of 7 in PostCommitPhase + │ │ ├── 2 elements transitioning toward PUBLIC + │ │ │ ├── DELETE_ONLY → WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ └── ABSENT → WRITE_ONLY ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ ├── 2 elements transitioning toward TRANSIENT_ABSENT + │ │ │ ├── DELETE_ONLY → WRITE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ └── ABSENT → PUBLIC IndexData:{DescID: 106, IndexID: 3} + │ │ └── 5 Mutation operations + │ │ ├── MakeDeleteOnlyColumnWriteOnly {"ColumnID":3,"TableID":106} + │ │ ├── MakeDeleteOnlyIndexWriteOnly {"IndexID":3,"TableID":106} + │ │ ├── MakeAbsentColumnNotNullWriteOnly {"ColumnID":3,"TableID":106} + │ │ ├── SetJobStateOnDescriptor {"DescriptorID":106} + │ │ └── UpdateSchemaChangerJob {"RunningStatus":"PostCommitPhase ..."} + │ ├── Stage 2 of 7 in PostCommitPhase + │ │ ├── 1 element transitioning toward PUBLIC + │ │ │ └── BACKFILL_ONLY → BACKFILLED PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ └── 1 Backfill operation + │ │ └── BackfillIndex {"IndexID":2,"SourceIndexID":1,"TableID":106} + │ ├── Stage 3 of 7 in PostCommitPhase + │ │ ├── 1 element transitioning toward PUBLIC + │ │ │ └── BACKFILLED → DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ └── 3 Mutation operations + │ │ ├── MakeBackfillingIndexDeleteOnly {"IndexID":2,"TableID":106} + │ │ ├── SetJobStateOnDescriptor {"DescriptorID":106} + │ │ └── UpdateSchemaChangerJob {"RunningStatus":"PostCommitPhase ..."} + │ ├── Stage 4 of 7 in PostCommitPhase + │ │ ├── 1 element transitioning toward PUBLIC + │ │ │ └── DELETE_ONLY → MERGE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ └── 3 Mutation operations + │ │ ├── MakeBackfilledIndexMerging {"IndexID":2,"TableID":106} + │ │ ├── SetJobStateOnDescriptor {"DescriptorID":106} + │ │ └── UpdateSchemaChangerJob {"RunningStatus":"PostCommitPhase ..."} + │ ├── Stage 5 of 7 in PostCommitPhase + │ │ ├── 1 element transitioning toward PUBLIC + │ │ │ └── MERGE_ONLY → MERGED PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ └── 1 Backfill operation + │ │ └── MergeIndex {"BackfilledIndexID":2,"TableID":106,"TemporaryIndexID":3} + │ ├── Stage 6 of 7 in PostCommitPhase + │ │ ├── 1 element transitioning toward PUBLIC + │ │ │ └── MERGED → WRITE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ └── 3 Mutation operations + │ │ ├── MakeMergedIndexWriteOnly {"IndexID":2,"TableID":106} + │ │ ├── SetJobStateOnDescriptor {"DescriptorID":106} + │ │ └── UpdateSchemaChangerJob {"RunningStatus":"PostCommitPhase ..."} + │ └── Stage 7 of 7 in PostCommitPhase + │ ├── 2 elements transitioning toward PUBLIC + │ │ ├── WRITE_ONLY → VALIDATED PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ └── WRITE_ONLY → VALIDATED ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ └── 2 Validation operations + │ ├── ValidateIndex {"IndexID":2,"TableID":106} + │ └── ValidateColumnNotNull {"ColumnID":3,"IndexIDForValidation":2,"TableID":106} + └── PostCommitNonRevertiblePhase + ├── Stage 1 of 3 in PostCommitNonRevertiblePhase + │ ├── 4 elements transitioning toward PUBLIC + │ │ ├── WRITE_ONLY → PUBLIC Column:{DescID: 106, ColumnID: 3} + │ │ ├── VALIDATED → PUBLIC PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── ABSENT → PUBLIC IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} + │ │ └── VALIDATED → PUBLIC ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ ├── 4 elements transitioning toward TRANSIENT_ABSENT + │ │ ├── WRITE_ONLY → TRANSIENT_DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → TRANSIENT_ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ ├── PUBLIC → TRANSIENT_ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ └── PUBLIC → TRANSIENT_ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ ├── 2 elements transitioning toward ABSENT + │ │ ├── PUBLIC → VALIDATED PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} + │ │ └── PUBLIC → ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 1} + │ └── 13 Mutation operations + │ ├── MakePublicPrimaryIndexWriteOnly {"IndexID":1,"TableID":106} + │ ├── SetIndexName {"IndexID":1,"Name":"crdb_internal_in...","TableID":106} + │ ├── SetIndexName {"IndexID":2,"Name":"tbl_pkey","TableID":106} + │ ├── MakeWriteOnlyIndexDeleteOnly {"IndexID":3,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"Kind":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":3,"Kind":2,"Ordinal":1,"TableID":106} + │ ├── MakeValidatedColumnNotNullPublic {"ColumnID":3,"TableID":106} + │ ├── MakeValidatedPrimaryIndexPublic {"IndexID":2,"TableID":106} + │ ├── MakeWriteOnlyColumnPublic {"ColumnID":3,"TableID":106} + │ ├── RefreshStats {"TableID":106} + │ ├── SetJobStateOnDescriptor {"DescriptorID":106} + │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} + ├── Stage 2 of 3 in PostCommitNonRevertiblePhase + │ ├── 1 element transitioning toward TRANSIENT_ABSENT + │ │ └── TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ ├── 3 elements transitioning toward ABSENT + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 1} + │ │ └── VALIDATED → DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} + │ └── 6 Mutation operations + │ ├── MakeIndexAbsent {"IndexID":3,"TableID":106} + │ ├── MakeWriteOnlyIndexDeleteOnly {"IndexID":1,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":1,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":1,"Kind":2,"TableID":106} + │ ├── SetJobStateOnDescriptor {"DescriptorID":106} + │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} + └── Stage 3 of 3 in PostCommitNonRevertiblePhase + ├── 1 element transitioning toward TRANSIENT_ABSENT + │ └── PUBLIC → TRANSIENT_ABSENT IndexData:{DescID: 106, IndexID: 3} + ├── 2 elements transitioning toward ABSENT + │ ├── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} + │ └── PUBLIC → ABSENT IndexData:{DescID: 106, IndexID: 1} + └── 5 Mutation operations + ├── MakeIndexAbsent {"IndexID":1,"TableID":106} + ├── CreateGCJobForIndex {"IndexID":1,"TableID":106} + ├── CreateGCJobForIndex {"IndexID":3,"TableID":106} + ├── RemoveJobStateFromDescriptor {"DescriptorID":106} + └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"all stages compl..."} diff --git a/pkg/sql/schemachanger/testdata/explain/add_column_with_stored.rollback_1_of_7 b/pkg/sql/schemachanger/testdata/explain/add_column_with_stored.rollback_1_of_7 new file mode 100644 index 000000000000..fd7f0b419e9a --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain/add_column_with_stored.rollback_1_of_7 @@ -0,0 +1,39 @@ +/* setup */ +CREATE DATABASE db; +CREATE TABLE db.public.tbl (i INT PRIMARY KEY, k INT); +CREATE SEQUENCE db.public.sq1; + +/* test */ +ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL AS (k) STORED; +EXPLAIN (ddl) rollback at post-commit stage 1 of 7; +---- +Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD COLUMN ‹j› INT8 NOT NULL AS (‹k›) STORED; + └── PostCommitNonRevertiblePhase + └── Stage 1 of 1 in PostCommitNonRevertiblePhase + ├── 12 elements transitioning toward ABSENT + │ ├── DELETE_ONLY → ABSENT Column:{DescID: 106, ColumnID: 3} + │ ├── PUBLIC → ABSENT ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ ├── PUBLIC → ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 3} + │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ ├── PUBLIC → ABSENT IndexData:{DescID: 106, IndexID: 2} + │ ├── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ └── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + └── 13 Mutation operations + ├── SetColumnName {"ColumnID":3,"Name":"crdb_internal_co...","TableID":106} + ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":106} + ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"Kind":2,"TableID":106} + ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":2,"Kind":2,"Ordinal":1,"TableID":106} + ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":106} + ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"Kind":2,"TableID":106} + ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":3,"Kind":2,"Ordinal":1,"TableID":106} + ├── MakeIndexAbsent {"IndexID":2,"TableID":106} + ├── CreateGCJobForIndex {"IndexID":2,"TableID":106} + ├── MakeIndexAbsent {"IndexID":3,"TableID":106} + ├── MakeDeleteOnlyColumnAbsent {"ColumnID":3,"TableID":106} + ├── RemoveJobStateFromDescriptor {"DescriptorID":106} + └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"all stages compl..."} diff --git a/pkg/sql/schemachanger/testdata/explain/add_column_with_stored.rollback_2_of_7 b/pkg/sql/schemachanger/testdata/explain/add_column_with_stored.rollback_2_of_7 new file mode 100644 index 000000000000..d72f3d55861c --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain/add_column_with_stored.rollback_2_of_7 @@ -0,0 +1,52 @@ +/* setup */ +CREATE DATABASE db; +CREATE TABLE db.public.tbl (i INT PRIMARY KEY, k INT); +CREATE SEQUENCE db.public.sq1; + +/* test */ +ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL AS (k) STORED; +EXPLAIN (ddl) rollback at post-commit stage 2 of 7; +---- +Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD COLUMN ‹j› INT8 NOT NULL AS (‹k›) STORED; + └── PostCommitNonRevertiblePhase + ├── Stage 1 of 2 in PostCommitNonRevertiblePhase + │ ├── 11 elements transitioning toward ABSENT + │ │ ├── WRITE_ONLY → DELETE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ ├── PUBLIC → ABSENT ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ └── WRITE_ONLY → ABSENT ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ └── 13 Mutation operations + │ ├── SetColumnName {"ColumnID":3,"Name":"crdb_internal_co...","TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"Kind":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":2,"Kind":2,"Ordinal":1,"TableID":106} + │ ├── MakeWriteOnlyIndexDeleteOnly {"IndexID":3,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"Kind":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":3,"Kind":2,"Ordinal":1,"TableID":106} + │ ├── MakeIndexAbsent {"IndexID":2,"TableID":106} + │ ├── RemoveColumnNotNull {"ColumnID":3,"TableID":106} + │ ├── MakeWriteOnlyColumnDeleteOnly {"ColumnID":3,"TableID":106} + │ ├── SetJobStateOnDescriptor {"DescriptorID":106} + │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} + └── Stage 2 of 2 in PostCommitNonRevertiblePhase + ├── 5 elements transitioning toward ABSENT + │ ├── DELETE_ONLY → ABSENT Column:{DescID: 106, ColumnID: 3} + │ ├── PUBLIC → ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 3} + │ ├── PUBLIC → ABSENT IndexData:{DescID: 106, IndexID: 2} + │ ├── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ └── PUBLIC → ABSENT IndexData:{DescID: 106, IndexID: 3} + └── 6 Mutation operations + ├── CreateGCJobForIndex {"IndexID":2,"TableID":106} + ├── MakeIndexAbsent {"IndexID":3,"TableID":106} + ├── CreateGCJobForIndex {"IndexID":3,"TableID":106} + ├── MakeDeleteOnlyColumnAbsent {"ColumnID":3,"TableID":106} + ├── RemoveJobStateFromDescriptor {"DescriptorID":106} + └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"all stages compl..."} diff --git a/pkg/sql/schemachanger/testdata/explain/add_column_with_stored.rollback_3_of_7 b/pkg/sql/schemachanger/testdata/explain/add_column_with_stored.rollback_3_of_7 new file mode 100644 index 000000000000..86bbecbe1798 --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain/add_column_with_stored.rollback_3_of_7 @@ -0,0 +1,52 @@ +/* setup */ +CREATE DATABASE db; +CREATE TABLE db.public.tbl (i INT PRIMARY KEY, k INT); +CREATE SEQUENCE db.public.sq1; + +/* test */ +ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL AS (k) STORED; +EXPLAIN (ddl) rollback at post-commit stage 3 of 7; +---- +Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD COLUMN ‹j› INT8 NOT NULL AS (‹k›) STORED; + └── PostCommitNonRevertiblePhase + ├── Stage 1 of 2 in PostCommitNonRevertiblePhase + │ ├── 11 elements transitioning toward ABSENT + │ │ ├── WRITE_ONLY → DELETE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ ├── PUBLIC → ABSENT ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ └── WRITE_ONLY → ABSENT ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ └── 13 Mutation operations + │ ├── SetColumnName {"ColumnID":3,"Name":"crdb_internal_co...","TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"Kind":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":2,"Kind":2,"Ordinal":1,"TableID":106} + │ ├── MakeWriteOnlyIndexDeleteOnly {"IndexID":3,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"Kind":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":3,"Kind":2,"Ordinal":1,"TableID":106} + │ ├── MakeIndexAbsent {"IndexID":2,"TableID":106} + │ ├── RemoveColumnNotNull {"ColumnID":3,"TableID":106} + │ ├── MakeWriteOnlyColumnDeleteOnly {"ColumnID":3,"TableID":106} + │ ├── SetJobStateOnDescriptor {"DescriptorID":106} + │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} + └── Stage 2 of 2 in PostCommitNonRevertiblePhase + ├── 5 elements transitioning toward ABSENT + │ ├── DELETE_ONLY → ABSENT Column:{DescID: 106, ColumnID: 3} + │ ├── PUBLIC → ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 3} + │ ├── PUBLIC → ABSENT IndexData:{DescID: 106, IndexID: 2} + │ ├── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ └── PUBLIC → ABSENT IndexData:{DescID: 106, IndexID: 3} + └── 6 Mutation operations + ├── CreateGCJobForIndex {"IndexID":2,"TableID":106} + ├── MakeIndexAbsent {"IndexID":3,"TableID":106} + ├── CreateGCJobForIndex {"IndexID":3,"TableID":106} + ├── MakeDeleteOnlyColumnAbsent {"ColumnID":3,"TableID":106} + ├── RemoveJobStateFromDescriptor {"DescriptorID":106} + └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"all stages compl..."} diff --git a/pkg/sql/schemachanger/testdata/explain/add_column_with_stored.rollback_4_of_7 b/pkg/sql/schemachanger/testdata/explain/add_column_with_stored.rollback_4_of_7 new file mode 100644 index 000000000000..54840559d545 --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain/add_column_with_stored.rollback_4_of_7 @@ -0,0 +1,52 @@ +/* setup */ +CREATE DATABASE db; +CREATE TABLE db.public.tbl (i INT PRIMARY KEY, k INT); +CREATE SEQUENCE db.public.sq1; + +/* test */ +ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL AS (k) STORED; +EXPLAIN (ddl) rollback at post-commit stage 4 of 7; +---- +Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD COLUMN ‹j› INT8 NOT NULL AS (‹k›) STORED; + └── PostCommitNonRevertiblePhase + ├── Stage 1 of 2 in PostCommitNonRevertiblePhase + │ ├── 11 elements transitioning toward ABSENT + │ │ ├── WRITE_ONLY → DELETE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ ├── PUBLIC → ABSENT ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ ├── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ └── WRITE_ONLY → ABSENT ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ └── 13 Mutation operations + │ ├── SetColumnName {"ColumnID":3,"Name":"crdb_internal_co...","TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"Kind":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":2,"Kind":2,"Ordinal":1,"TableID":106} + │ ├── MakeWriteOnlyIndexDeleteOnly {"IndexID":3,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"Kind":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":3,"Kind":2,"Ordinal":1,"TableID":106} + │ ├── MakeIndexAbsent {"IndexID":2,"TableID":106} + │ ├── RemoveColumnNotNull {"ColumnID":3,"TableID":106} + │ ├── MakeWriteOnlyColumnDeleteOnly {"ColumnID":3,"TableID":106} + │ ├── SetJobStateOnDescriptor {"DescriptorID":106} + │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} + └── Stage 2 of 2 in PostCommitNonRevertiblePhase + ├── 5 elements transitioning toward ABSENT + │ ├── DELETE_ONLY → ABSENT Column:{DescID: 106, ColumnID: 3} + │ ├── PUBLIC → ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 3} + │ ├── PUBLIC → ABSENT IndexData:{DescID: 106, IndexID: 2} + │ ├── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ └── PUBLIC → ABSENT IndexData:{DescID: 106, IndexID: 3} + └── 6 Mutation operations + ├── CreateGCJobForIndex {"IndexID":2,"TableID":106} + ├── MakeIndexAbsent {"IndexID":3,"TableID":106} + ├── CreateGCJobForIndex {"IndexID":3,"TableID":106} + ├── MakeDeleteOnlyColumnAbsent {"ColumnID":3,"TableID":106} + ├── RemoveJobStateFromDescriptor {"DescriptorID":106} + └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"all stages compl..."} diff --git a/pkg/sql/schemachanger/testdata/explain/add_column_with_stored.rollback_5_of_7 b/pkg/sql/schemachanger/testdata/explain/add_column_with_stored.rollback_5_of_7 new file mode 100644 index 000000000000..819f6be5e713 --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain/add_column_with_stored.rollback_5_of_7 @@ -0,0 +1,54 @@ +/* setup */ +CREATE DATABASE db; +CREATE TABLE db.public.tbl (i INT PRIMARY KEY, k INT); +CREATE SEQUENCE db.public.sq1; + +/* test */ +ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL AS (k) STORED; +EXPLAIN (ddl) rollback at post-commit stage 5 of 7; +---- +Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD COLUMN ‹j› INT8 NOT NULL AS (‹k›) STORED; + └── PostCommitNonRevertiblePhase + ├── Stage 1 of 2 in PostCommitNonRevertiblePhase + │ ├── 11 elements transitioning toward ABSENT + │ │ ├── WRITE_ONLY → DELETE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ ├── PUBLIC → ABSENT ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ ├── MERGE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ └── WRITE_ONLY → ABSENT ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ └── 13 Mutation operations + │ ├── SetColumnName {"ColumnID":3,"Name":"crdb_internal_co...","TableID":106} + │ ├── MakeWriteOnlyIndexDeleteOnly {"IndexID":3,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"Kind":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":3,"Kind":2,"Ordinal":1,"TableID":106} + │ ├── MakeWriteOnlyIndexDeleteOnly {"IndexID":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"Kind":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":2,"Kind":2,"Ordinal":1,"TableID":106} + │ ├── RemoveColumnNotNull {"ColumnID":3,"TableID":106} + │ ├── MakeWriteOnlyColumnDeleteOnly {"ColumnID":3,"TableID":106} + │ ├── SetJobStateOnDescriptor {"DescriptorID":106} + │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} + └── Stage 2 of 2 in PostCommitNonRevertiblePhase + ├── 6 elements transitioning toward ABSENT + │ ├── DELETE_ONLY → ABSENT Column:{DescID: 106, ColumnID: 3} + │ ├── PUBLIC → ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 3} + │ ├── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ ├── PUBLIC → ABSENT IndexData:{DescID: 106, IndexID: 2} + │ ├── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ └── PUBLIC → ABSENT IndexData:{DescID: 106, IndexID: 3} + └── 7 Mutation operations + ├── MakeIndexAbsent {"IndexID":2,"TableID":106} + ├── CreateGCJobForIndex {"IndexID":2,"TableID":106} + ├── MakeIndexAbsent {"IndexID":3,"TableID":106} + ├── CreateGCJobForIndex {"IndexID":3,"TableID":106} + ├── MakeDeleteOnlyColumnAbsent {"ColumnID":3,"TableID":106} + ├── RemoveJobStateFromDescriptor {"DescriptorID":106} + └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"all stages compl..."} diff --git a/pkg/sql/schemachanger/testdata/explain/add_column_with_stored.rollback_6_of_7 b/pkg/sql/schemachanger/testdata/explain/add_column_with_stored.rollback_6_of_7 new file mode 100644 index 000000000000..6935290e0aad --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain/add_column_with_stored.rollback_6_of_7 @@ -0,0 +1,54 @@ +/* setup */ +CREATE DATABASE db; +CREATE TABLE db.public.tbl (i INT PRIMARY KEY, k INT); +CREATE SEQUENCE db.public.sq1; + +/* test */ +ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL AS (k) STORED; +EXPLAIN (ddl) rollback at post-commit stage 6 of 7; +---- +Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD COLUMN ‹j› INT8 NOT NULL AS (‹k›) STORED; + └── PostCommitNonRevertiblePhase + ├── Stage 1 of 2 in PostCommitNonRevertiblePhase + │ ├── 11 elements transitioning toward ABSENT + │ │ ├── WRITE_ONLY → DELETE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ ├── PUBLIC → ABSENT ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ ├── MERGE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ └── WRITE_ONLY → ABSENT ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ └── 13 Mutation operations + │ ├── SetColumnName {"ColumnID":3,"Name":"crdb_internal_co...","TableID":106} + │ ├── MakeWriteOnlyIndexDeleteOnly {"IndexID":3,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"Kind":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":3,"Kind":2,"Ordinal":1,"TableID":106} + │ ├── MakeWriteOnlyIndexDeleteOnly {"IndexID":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"Kind":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":2,"Kind":2,"Ordinal":1,"TableID":106} + │ ├── RemoveColumnNotNull {"ColumnID":3,"TableID":106} + │ ├── MakeWriteOnlyColumnDeleteOnly {"ColumnID":3,"TableID":106} + │ ├── SetJobStateOnDescriptor {"DescriptorID":106} + │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} + └── Stage 2 of 2 in PostCommitNonRevertiblePhase + ├── 6 elements transitioning toward ABSENT + │ ├── DELETE_ONLY → ABSENT Column:{DescID: 106, ColumnID: 3} + │ ├── PUBLIC → ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 3} + │ ├── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ ├── PUBLIC → ABSENT IndexData:{DescID: 106, IndexID: 2} + │ ├── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ └── PUBLIC → ABSENT IndexData:{DescID: 106, IndexID: 3} + └── 7 Mutation operations + ├── MakeIndexAbsent {"IndexID":2,"TableID":106} + ├── CreateGCJobForIndex {"IndexID":2,"TableID":106} + ├── MakeIndexAbsent {"IndexID":3,"TableID":106} + ├── CreateGCJobForIndex {"IndexID":3,"TableID":106} + ├── MakeDeleteOnlyColumnAbsent {"ColumnID":3,"TableID":106} + ├── RemoveJobStateFromDescriptor {"DescriptorID":106} + └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"all stages compl..."} diff --git a/pkg/sql/schemachanger/testdata/explain/add_column_with_stored.rollback_7_of_7 b/pkg/sql/schemachanger/testdata/explain/add_column_with_stored.rollback_7_of_7 new file mode 100644 index 000000000000..39e21f0dab4f --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain/add_column_with_stored.rollback_7_of_7 @@ -0,0 +1,54 @@ +/* setup */ +CREATE DATABASE db; +CREATE TABLE db.public.tbl (i INT PRIMARY KEY, k INT); +CREATE SEQUENCE db.public.sq1; + +/* test */ +ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL AS (k) STORED; +EXPLAIN (ddl) rollback at post-commit stage 7 of 7; +---- +Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD COLUMN ‹j› INT8 NOT NULL AS (‹k›) STORED; + └── PostCommitNonRevertiblePhase + ├── Stage 1 of 2 in PostCommitNonRevertiblePhase + │ ├── 11 elements transitioning toward ABSENT + │ │ ├── WRITE_ONLY → DELETE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ ├── PUBLIC → ABSENT ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ ├── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ └── WRITE_ONLY → ABSENT ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ └── 13 Mutation operations + │ ├── SetColumnName {"ColumnID":3,"Name":"crdb_internal_co...","TableID":106} + │ ├── MakeWriteOnlyIndexDeleteOnly {"IndexID":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"Kind":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":2,"Kind":2,"Ordinal":1,"TableID":106} + │ ├── MakeWriteOnlyIndexDeleteOnly {"IndexID":3,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"Kind":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":3,"Kind":2,"Ordinal":1,"TableID":106} + │ ├── RemoveColumnNotNull {"ColumnID":3,"TableID":106} + │ ├── MakeWriteOnlyColumnDeleteOnly {"ColumnID":3,"TableID":106} + │ ├── SetJobStateOnDescriptor {"DescriptorID":106} + │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} + └── Stage 2 of 2 in PostCommitNonRevertiblePhase + ├── 6 elements transitioning toward ABSENT + │ ├── DELETE_ONLY → ABSENT Column:{DescID: 106, ColumnID: 3} + │ ├── PUBLIC → ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 3} + │ ├── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ ├── PUBLIC → ABSENT IndexData:{DescID: 106, IndexID: 2} + │ ├── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ └── PUBLIC → ABSENT IndexData:{DescID: 106, IndexID: 3} + └── 7 Mutation operations + ├── MakeIndexAbsent {"IndexID":2,"TableID":106} + ├── CreateGCJobForIndex {"IndexID":2,"TableID":106} + ├── MakeIndexAbsent {"IndexID":3,"TableID":106} + ├── CreateGCJobForIndex {"IndexID":3,"TableID":106} + ├── MakeDeleteOnlyColumnAbsent {"ColumnID":3,"TableID":106} + ├── RemoveJobStateFromDescriptor {"DescriptorID":106} + └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"all stages compl..."} diff --git a/pkg/sql/schemachanger/testdata/explain/add_column_with_stored_family b/pkg/sql/schemachanger/testdata/explain/add_column_with_stored_family new file mode 100644 index 000000000000..c384afc408dc --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain/add_column_with_stored_family @@ -0,0 +1,198 @@ +/* setup */ +CREATE DATABASE db; +CREATE TABLE db.public.tbl (i INT PRIMARY KEY, k INT); +CREATE SEQUENCE db.public.sq1; + +/* test */ +EXPLAIN (ddl) ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL AS (k) STORED CREATE FAMILY bob; +---- +Schema change plan for ALTER TABLE ‹db›.‹public›.‹tbl› ADD COLUMN ‹j› INT8 NOT NULL AS (‹k›) STORED CREATE FAMILY ‹bob›; + ├── StatementPhase + │ └── Stage 1 of 1 in StatementPhase + │ ├── 9 elements transitioning toward PUBLIC + │ │ ├── ABSENT → DELETE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ ├── ABSENT → PUBLIC ColumnFamily:{DescID: 106, Name: bob, ColumnFamilyID: 1} + │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ ├── ABSENT → PUBLIC ColumnType:{DescID: 106, ColumnFamilyID: 1, ColumnID: 3} + │ │ ├── ABSENT → BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ └── ABSENT → PUBLIC IndexData:{DescID: 106, IndexID: 2} + │ ├── 4 elements transitioning toward TRANSIENT_ABSENT + │ │ ├── ABSENT → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ └── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ └── 12 Mutation operations + │ ├── MakeAbsentColumnDeleteOnly {"Column":{"ColumnID":3,"PgAttributeNum":3,"TableID":106}} + │ ├── AddColumnFamily {"FamilyID":1,"Name":"bob","TableID":106} + │ ├── SetColumnName {"ColumnID":3,"Name":"j","TableID":106} + │ ├── SetAddedColumnType {"ColumnType":{"ColumnID":3,"FamilyID":1,"TableID":106}} + │ ├── MakeAbsentIndexBackfilling {"Index":{"ConstraintID":2,"IndexID":2,"IsUnique":true,"SourceIndexID":1,"TableID":106,"TemporaryIndexID":3}} + │ ├── AddColumnToIndex {"ColumnID":1,"IndexID":2,"TableID":106} + │ ├── AddColumnToIndex {"ColumnID":2,"IndexID":2,"Kind":2,"TableID":106} + │ ├── AddColumnToIndex {"ColumnID":3,"IndexID":2,"Kind":2,"Ordinal":1,"TableID":106} + │ ├── MakeAbsentTempIndexDeleteOnly {"Index":{"ConstraintID":3,"IndexID":3,"IsUnique":true,"SourceIndexID":1,"TableID":106}} + │ ├── AddColumnToIndex {"ColumnID":1,"IndexID":3,"TableID":106} + │ ├── AddColumnToIndex {"ColumnID":2,"IndexID":3,"Kind":2,"TableID":106} + │ └── AddColumnToIndex {"ColumnID":3,"IndexID":3,"Kind":2,"Ordinal":1,"TableID":106} + ├── PreCommitPhase + │ ├── Stage 1 of 2 in PreCommitPhase + │ │ ├── 9 elements transitioning toward PUBLIC + │ │ │ ├── DELETE_ONLY → ABSENT Column:{DescID: 106, ColumnID: 3} + │ │ │ ├── PUBLIC → ABSENT ColumnFamily:{DescID: 106, Name: bob, ColumnFamilyID: 1} + │ │ │ ├── PUBLIC → ABSENT ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ │ ├── PUBLIC → ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 1, ColumnID: 3} + │ │ │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ └── PUBLIC → ABSENT IndexData:{DescID: 106, IndexID: 2} + │ │ ├── 4 elements transitioning toward TRANSIENT_ABSENT + │ │ │ ├── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ │ └── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ └── 1 Mutation operation + │ │ └── UndoAllInTxnImmediateMutationOpSideEffects + │ └── Stage 2 of 2 in PreCommitPhase + │ ├── 9 elements transitioning toward PUBLIC + │ │ ├── ABSENT → DELETE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ ├── ABSENT → PUBLIC ColumnFamily:{DescID: 106, Name: bob, ColumnFamilyID: 1} + │ │ ├── ABSENT → PUBLIC ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ ├── ABSENT → PUBLIC ColumnType:{DescID: 106, ColumnFamilyID: 1, ColumnID: 3} + │ │ ├── ABSENT → BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ └── ABSENT → PUBLIC IndexData:{DescID: 106, IndexID: 2} + │ ├── 4 elements transitioning toward TRANSIENT_ABSENT + │ │ ├── ABSENT → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ ├── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ └── ABSENT → PUBLIC IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ └── 16 Mutation operations + │ ├── MakeAbsentColumnDeleteOnly {"Column":{"ColumnID":3,"PgAttributeNum":3,"TableID":106}} + │ ├── AddColumnFamily {"FamilyID":1,"Name":"bob","TableID":106} + │ ├── SetColumnName {"ColumnID":3,"Name":"j","TableID":106} + │ ├── SetAddedColumnType {"ColumnType":{"ColumnID":3,"FamilyID":1,"TableID":106}} + │ ├── MakeAbsentIndexBackfilling {"Index":{"ConstraintID":2,"IndexID":2,"IsUnique":true,"SourceIndexID":1,"TableID":106,"TemporaryIndexID":3}} + │ ├── MaybeAddSplitForIndex {"IndexID":2,"TableID":106} + │ ├── AddColumnToIndex {"ColumnID":1,"IndexID":2,"TableID":106} + │ ├── AddColumnToIndex {"ColumnID":2,"IndexID":2,"Kind":2,"TableID":106} + │ ├── AddColumnToIndex {"ColumnID":3,"IndexID":2,"Kind":2,"Ordinal":1,"TableID":106} + │ ├── MakeAbsentTempIndexDeleteOnly {"Index":{"ConstraintID":3,"IndexID":3,"IsUnique":true,"SourceIndexID":1,"TableID":106}} + │ ├── MaybeAddSplitForIndex {"IndexID":3,"TableID":106} + │ ├── AddColumnToIndex {"ColumnID":1,"IndexID":3,"TableID":106} + │ ├── AddColumnToIndex {"ColumnID":2,"IndexID":3,"Kind":2,"TableID":106} + │ ├── AddColumnToIndex {"ColumnID":3,"IndexID":3,"Kind":2,"Ordinal":1,"TableID":106} + │ ├── SetJobStateOnDescriptor {"DescriptorID":106,"Initialize":true} + │ └── CreateSchemaChangerJob {"RunningStatus":"PostCommitPhase ..."} + ├── PostCommitPhase + │ ├── Stage 1 of 7 in PostCommitPhase + │ │ ├── 2 elements transitioning toward PUBLIC + │ │ │ ├── DELETE_ONLY → WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ └── ABSENT → WRITE_ONLY ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ ├── 2 elements transitioning toward TRANSIENT_ABSENT + │ │ │ ├── DELETE_ONLY → WRITE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ └── ABSENT → PUBLIC IndexData:{DescID: 106, IndexID: 3} + │ │ └── 5 Mutation operations + │ │ ├── MakeDeleteOnlyColumnWriteOnly {"ColumnID":3,"TableID":106} + │ │ ├── MakeDeleteOnlyIndexWriteOnly {"IndexID":3,"TableID":106} + │ │ ├── MakeAbsentColumnNotNullWriteOnly {"ColumnID":3,"TableID":106} + │ │ ├── SetJobStateOnDescriptor {"DescriptorID":106} + │ │ └── UpdateSchemaChangerJob {"RunningStatus":"PostCommitPhase ..."} + │ ├── Stage 2 of 7 in PostCommitPhase + │ │ ├── 1 element transitioning toward PUBLIC + │ │ │ └── BACKFILL_ONLY → BACKFILLED PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ └── 1 Backfill operation + │ │ └── BackfillIndex {"IndexID":2,"SourceIndexID":1,"TableID":106} + │ ├── Stage 3 of 7 in PostCommitPhase + │ │ ├── 1 element transitioning toward PUBLIC + │ │ │ └── BACKFILLED → DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ └── 3 Mutation operations + │ │ ├── MakeBackfillingIndexDeleteOnly {"IndexID":2,"TableID":106} + │ │ ├── SetJobStateOnDescriptor {"DescriptorID":106} + │ │ └── UpdateSchemaChangerJob {"RunningStatus":"PostCommitPhase ..."} + │ ├── Stage 4 of 7 in PostCommitPhase + │ │ ├── 1 element transitioning toward PUBLIC + │ │ │ └── DELETE_ONLY → MERGE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ └── 3 Mutation operations + │ │ ├── MakeBackfilledIndexMerging {"IndexID":2,"TableID":106} + │ │ ├── SetJobStateOnDescriptor {"DescriptorID":106} + │ │ └── UpdateSchemaChangerJob {"RunningStatus":"PostCommitPhase ..."} + │ ├── Stage 5 of 7 in PostCommitPhase + │ │ ├── 1 element transitioning toward PUBLIC + │ │ │ └── MERGE_ONLY → MERGED PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ └── 1 Backfill operation + │ │ └── MergeIndex {"BackfilledIndexID":2,"TableID":106,"TemporaryIndexID":3} + │ ├── Stage 6 of 7 in PostCommitPhase + │ │ ├── 1 element transitioning toward PUBLIC + │ │ │ └── MERGED → WRITE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ └── 3 Mutation operations + │ │ ├── MakeMergedIndexWriteOnly {"IndexID":2,"TableID":106} + │ │ ├── SetJobStateOnDescriptor {"DescriptorID":106} + │ │ └── UpdateSchemaChangerJob {"RunningStatus":"PostCommitPhase ..."} + │ └── Stage 7 of 7 in PostCommitPhase + │ ├── 2 elements transitioning toward PUBLIC + │ │ ├── WRITE_ONLY → VALIDATED PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ └── WRITE_ONLY → VALIDATED ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ └── 2 Validation operations + │ ├── ValidateIndex {"IndexID":2,"TableID":106} + │ └── ValidateColumnNotNull {"ColumnID":3,"IndexIDForValidation":2,"TableID":106} + └── PostCommitNonRevertiblePhase + ├── Stage 1 of 3 in PostCommitNonRevertiblePhase + │ ├── 4 elements transitioning toward PUBLIC + │ │ ├── WRITE_ONLY → PUBLIC Column:{DescID: 106, ColumnID: 3} + │ │ ├── VALIDATED → PUBLIC PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── ABSENT → PUBLIC IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} + │ │ └── VALIDATED → PUBLIC ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ ├── 4 elements transitioning toward TRANSIENT_ABSENT + │ │ ├── WRITE_ONLY → TRANSIENT_DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → TRANSIENT_ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ ├── PUBLIC → TRANSIENT_ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ └── PUBLIC → TRANSIENT_ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ ├── 2 elements transitioning toward ABSENT + │ │ ├── PUBLIC → VALIDATED PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} + │ │ └── PUBLIC → ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 1} + │ └── 13 Mutation operations + │ ├── MakePublicPrimaryIndexWriteOnly {"IndexID":1,"TableID":106} + │ ├── SetIndexName {"IndexID":1,"Name":"crdb_internal_in...","TableID":106} + │ ├── SetIndexName {"IndexID":2,"Name":"tbl_pkey","TableID":106} + │ ├── MakeWriteOnlyIndexDeleteOnly {"IndexID":3,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"Kind":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":3,"Kind":2,"Ordinal":1,"TableID":106} + │ ├── MakeValidatedColumnNotNullPublic {"ColumnID":3,"TableID":106} + │ ├── MakeValidatedPrimaryIndexPublic {"IndexID":2,"TableID":106} + │ ├── MakeWriteOnlyColumnPublic {"ColumnID":3,"TableID":106} + │ ├── RefreshStats {"TableID":106} + │ ├── SetJobStateOnDescriptor {"DescriptorID":106} + │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} + ├── Stage 2 of 3 in PostCommitNonRevertiblePhase + │ ├── 1 element transitioning toward TRANSIENT_ABSENT + │ │ └── TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ ├── 3 elements transitioning toward ABSENT + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 1} + │ │ └── VALIDATED → DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} + │ └── 6 Mutation operations + │ ├── MakeIndexAbsent {"IndexID":3,"TableID":106} + │ ├── MakeWriteOnlyIndexDeleteOnly {"IndexID":1,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":1,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":1,"Kind":2,"TableID":106} + │ ├── SetJobStateOnDescriptor {"DescriptorID":106} + │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} + └── Stage 3 of 3 in PostCommitNonRevertiblePhase + ├── 1 element transitioning toward TRANSIENT_ABSENT + │ └── PUBLIC → TRANSIENT_ABSENT IndexData:{DescID: 106, IndexID: 3} + ├── 2 elements transitioning toward ABSENT + │ ├── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} + │ └── PUBLIC → ABSENT IndexData:{DescID: 106, IndexID: 1} + └── 5 Mutation operations + ├── MakeIndexAbsent {"IndexID":1,"TableID":106} + ├── CreateGCJobForIndex {"IndexID":1,"TableID":106} + ├── CreateGCJobForIndex {"IndexID":3,"TableID":106} + ├── RemoveJobStateFromDescriptor {"DescriptorID":106} + └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"all stages compl..."} diff --git a/pkg/sql/schemachanger/testdata/explain/add_column_with_stored_family.rollback_1_of_7 b/pkg/sql/schemachanger/testdata/explain/add_column_with_stored_family.rollback_1_of_7 new file mode 100644 index 000000000000..c44aa791b7a3 --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain/add_column_with_stored_family.rollback_1_of_7 @@ -0,0 +1,41 @@ +/* setup */ +CREATE DATABASE db; +CREATE TABLE db.public.tbl (i INT PRIMARY KEY, k INT); +CREATE SEQUENCE db.public.sq1; + +/* test */ +ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL AS (k) STORED CREATE FAMILY bob; +EXPLAIN (ddl) rollback at post-commit stage 1 of 7; +---- +Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD COLUMN ‹j› INT8 NOT NULL AS (‹k›) STORED CREATE FAMILY ‹bob›; + └── PostCommitNonRevertiblePhase + └── Stage 1 of 1 in PostCommitNonRevertiblePhase + ├── 13 elements transitioning toward ABSENT + │ ├── DELETE_ONLY → ABSENT Column:{DescID: 106, ColumnID: 3} + │ ├── PUBLIC → ABSENT ColumnFamily:{DescID: 106, Name: bob, ColumnFamilyID: 1} + │ ├── PUBLIC → ABSENT ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ ├── PUBLIC → ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 1, ColumnID: 3} + │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ ├── PUBLIC → ABSENT IndexData:{DescID: 106, IndexID: 2} + │ ├── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ └── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + └── 14 Mutation operations + ├── SetColumnName {"ColumnID":3,"Name":"crdb_internal_co...","TableID":106} + ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":106} + ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"Kind":2,"TableID":106} + ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":2,"Kind":2,"Ordinal":1,"TableID":106} + ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":106} + ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"Kind":2,"TableID":106} + ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":3,"Kind":2,"Ordinal":1,"TableID":106} + ├── MakeIndexAbsent {"IndexID":2,"TableID":106} + ├── CreateGCJobForIndex {"IndexID":2,"TableID":106} + ├── MakeIndexAbsent {"IndexID":3,"TableID":106} + ├── MakeDeleteOnlyColumnAbsent {"ColumnID":3,"TableID":106} + ├── AssertColumnFamilyIsRemoved {"FamilyID":1,"TableID":106} + ├── RemoveJobStateFromDescriptor {"DescriptorID":106} + └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"all stages compl..."} diff --git a/pkg/sql/schemachanger/testdata/explain/add_column_with_stored_family.rollback_2_of_7 b/pkg/sql/schemachanger/testdata/explain/add_column_with_stored_family.rollback_2_of_7 new file mode 100644 index 000000000000..a9e796abb330 --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain/add_column_with_stored_family.rollback_2_of_7 @@ -0,0 +1,54 @@ +/* setup */ +CREATE DATABASE db; +CREATE TABLE db.public.tbl (i INT PRIMARY KEY, k INT); +CREATE SEQUENCE db.public.sq1; + +/* test */ +ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL AS (k) STORED CREATE FAMILY bob; +EXPLAIN (ddl) rollback at post-commit stage 2 of 7; +---- +Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD COLUMN ‹j› INT8 NOT NULL AS (‹k›) STORED CREATE FAMILY ‹bob›; + └── PostCommitNonRevertiblePhase + ├── Stage 1 of 2 in PostCommitNonRevertiblePhase + │ ├── 11 elements transitioning toward ABSENT + │ │ ├── WRITE_ONLY → DELETE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ ├── PUBLIC → ABSENT ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ └── WRITE_ONLY → ABSENT ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ └── 13 Mutation operations + │ ├── SetColumnName {"ColumnID":3,"Name":"crdb_internal_co...","TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"Kind":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":2,"Kind":2,"Ordinal":1,"TableID":106} + │ ├── MakeWriteOnlyIndexDeleteOnly {"IndexID":3,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"Kind":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":3,"Kind":2,"Ordinal":1,"TableID":106} + │ ├── MakeIndexAbsent {"IndexID":2,"TableID":106} + │ ├── RemoveColumnNotNull {"ColumnID":3,"TableID":106} + │ ├── MakeWriteOnlyColumnDeleteOnly {"ColumnID":3,"TableID":106} + │ ├── SetJobStateOnDescriptor {"DescriptorID":106} + │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} + └── Stage 2 of 2 in PostCommitNonRevertiblePhase + ├── 6 elements transitioning toward ABSENT + │ ├── DELETE_ONLY → ABSENT Column:{DescID: 106, ColumnID: 3} + │ ├── PUBLIC → ABSENT ColumnFamily:{DescID: 106, Name: bob, ColumnFamilyID: 1} + │ ├── PUBLIC → ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 1, ColumnID: 3} + │ ├── PUBLIC → ABSENT IndexData:{DescID: 106, IndexID: 2} + │ ├── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ └── PUBLIC → ABSENT IndexData:{DescID: 106, IndexID: 3} + └── 7 Mutation operations + ├── CreateGCJobForIndex {"IndexID":2,"TableID":106} + ├── MakeIndexAbsent {"IndexID":3,"TableID":106} + ├── CreateGCJobForIndex {"IndexID":3,"TableID":106} + ├── MakeDeleteOnlyColumnAbsent {"ColumnID":3,"TableID":106} + ├── AssertColumnFamilyIsRemoved {"FamilyID":1,"TableID":106} + ├── RemoveJobStateFromDescriptor {"DescriptorID":106} + └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"all stages compl..."} diff --git a/pkg/sql/schemachanger/testdata/explain/add_column_with_stored_family.rollback_3_of_7 b/pkg/sql/schemachanger/testdata/explain/add_column_with_stored_family.rollback_3_of_7 new file mode 100644 index 000000000000..7a05a3c4dcf9 --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain/add_column_with_stored_family.rollback_3_of_7 @@ -0,0 +1,54 @@ +/* setup */ +CREATE DATABASE db; +CREATE TABLE db.public.tbl (i INT PRIMARY KEY, k INT); +CREATE SEQUENCE db.public.sq1; + +/* test */ +ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL AS (k) STORED CREATE FAMILY bob; +EXPLAIN (ddl) rollback at post-commit stage 3 of 7; +---- +Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD COLUMN ‹j› INT8 NOT NULL AS (‹k›) STORED CREATE FAMILY ‹bob›; + └── PostCommitNonRevertiblePhase + ├── Stage 1 of 2 in PostCommitNonRevertiblePhase + │ ├── 11 elements transitioning toward ABSENT + │ │ ├── WRITE_ONLY → DELETE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ ├── PUBLIC → ABSENT ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ ├── BACKFILL_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ └── WRITE_ONLY → ABSENT ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ └── 13 Mutation operations + │ ├── SetColumnName {"ColumnID":3,"Name":"crdb_internal_co...","TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"Kind":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":2,"Kind":2,"Ordinal":1,"TableID":106} + │ ├── MakeWriteOnlyIndexDeleteOnly {"IndexID":3,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"Kind":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":3,"Kind":2,"Ordinal":1,"TableID":106} + │ ├── MakeIndexAbsent {"IndexID":2,"TableID":106} + │ ├── RemoveColumnNotNull {"ColumnID":3,"TableID":106} + │ ├── MakeWriteOnlyColumnDeleteOnly {"ColumnID":3,"TableID":106} + │ ├── SetJobStateOnDescriptor {"DescriptorID":106} + │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} + └── Stage 2 of 2 in PostCommitNonRevertiblePhase + ├── 6 elements transitioning toward ABSENT + │ ├── DELETE_ONLY → ABSENT Column:{DescID: 106, ColumnID: 3} + │ ├── PUBLIC → ABSENT ColumnFamily:{DescID: 106, Name: bob, ColumnFamilyID: 1} + │ ├── PUBLIC → ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 1, ColumnID: 3} + │ ├── PUBLIC → ABSENT IndexData:{DescID: 106, IndexID: 2} + │ ├── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ └── PUBLIC → ABSENT IndexData:{DescID: 106, IndexID: 3} + └── 7 Mutation operations + ├── CreateGCJobForIndex {"IndexID":2,"TableID":106} + ├── MakeIndexAbsent {"IndexID":3,"TableID":106} + ├── CreateGCJobForIndex {"IndexID":3,"TableID":106} + ├── MakeDeleteOnlyColumnAbsent {"ColumnID":3,"TableID":106} + ├── AssertColumnFamilyIsRemoved {"FamilyID":1,"TableID":106} + ├── RemoveJobStateFromDescriptor {"DescriptorID":106} + └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"all stages compl..."} diff --git a/pkg/sql/schemachanger/testdata/explain/add_column_with_stored_family.rollback_4_of_7 b/pkg/sql/schemachanger/testdata/explain/add_column_with_stored_family.rollback_4_of_7 new file mode 100644 index 000000000000..2b2910fe2b22 --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain/add_column_with_stored_family.rollback_4_of_7 @@ -0,0 +1,54 @@ +/* setup */ +CREATE DATABASE db; +CREATE TABLE db.public.tbl (i INT PRIMARY KEY, k INT); +CREATE SEQUENCE db.public.sq1; + +/* test */ +ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL AS (k) STORED CREATE FAMILY bob; +EXPLAIN (ddl) rollback at post-commit stage 4 of 7; +---- +Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD COLUMN ‹j› INT8 NOT NULL AS (‹k›) STORED CREATE FAMILY ‹bob›; + └── PostCommitNonRevertiblePhase + ├── Stage 1 of 2 in PostCommitNonRevertiblePhase + │ ├── 11 elements transitioning toward ABSENT + │ │ ├── WRITE_ONLY → DELETE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ ├── PUBLIC → ABSENT ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ ├── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ └── WRITE_ONLY → ABSENT ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ └── 13 Mutation operations + │ ├── SetColumnName {"ColumnID":3,"Name":"crdb_internal_co...","TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"Kind":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":2,"Kind":2,"Ordinal":1,"TableID":106} + │ ├── MakeWriteOnlyIndexDeleteOnly {"IndexID":3,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"Kind":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":3,"Kind":2,"Ordinal":1,"TableID":106} + │ ├── MakeIndexAbsent {"IndexID":2,"TableID":106} + │ ├── RemoveColumnNotNull {"ColumnID":3,"TableID":106} + │ ├── MakeWriteOnlyColumnDeleteOnly {"ColumnID":3,"TableID":106} + │ ├── SetJobStateOnDescriptor {"DescriptorID":106} + │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} + └── Stage 2 of 2 in PostCommitNonRevertiblePhase + ├── 6 elements transitioning toward ABSENT + │ ├── DELETE_ONLY → ABSENT Column:{DescID: 106, ColumnID: 3} + │ ├── PUBLIC → ABSENT ColumnFamily:{DescID: 106, Name: bob, ColumnFamilyID: 1} + │ ├── PUBLIC → ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 1, ColumnID: 3} + │ ├── PUBLIC → ABSENT IndexData:{DescID: 106, IndexID: 2} + │ ├── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ └── PUBLIC → ABSENT IndexData:{DescID: 106, IndexID: 3} + └── 7 Mutation operations + ├── CreateGCJobForIndex {"IndexID":2,"TableID":106} + ├── MakeIndexAbsent {"IndexID":3,"TableID":106} + ├── CreateGCJobForIndex {"IndexID":3,"TableID":106} + ├── MakeDeleteOnlyColumnAbsent {"ColumnID":3,"TableID":106} + ├── AssertColumnFamilyIsRemoved {"FamilyID":1,"TableID":106} + ├── RemoveJobStateFromDescriptor {"DescriptorID":106} + └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"all stages compl..."} diff --git a/pkg/sql/schemachanger/testdata/explain/add_column_with_stored_family.rollback_5_of_7 b/pkg/sql/schemachanger/testdata/explain/add_column_with_stored_family.rollback_5_of_7 new file mode 100644 index 000000000000..2aacaead247b --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain/add_column_with_stored_family.rollback_5_of_7 @@ -0,0 +1,56 @@ +/* setup */ +CREATE DATABASE db; +CREATE TABLE db.public.tbl (i INT PRIMARY KEY, k INT); +CREATE SEQUENCE db.public.sq1; + +/* test */ +ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL AS (k) STORED CREATE FAMILY bob; +EXPLAIN (ddl) rollback at post-commit stage 5 of 7; +---- +Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD COLUMN ‹j› INT8 NOT NULL AS (‹k›) STORED CREATE FAMILY ‹bob›; + └── PostCommitNonRevertiblePhase + ├── Stage 1 of 2 in PostCommitNonRevertiblePhase + │ ├── 11 elements transitioning toward ABSENT + │ │ ├── WRITE_ONLY → DELETE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ ├── PUBLIC → ABSENT ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ ├── MERGE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ └── WRITE_ONLY → ABSENT ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ └── 13 Mutation operations + │ ├── SetColumnName {"ColumnID":3,"Name":"crdb_internal_co...","TableID":106} + │ ├── MakeWriteOnlyIndexDeleteOnly {"IndexID":3,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"Kind":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":3,"Kind":2,"Ordinal":1,"TableID":106} + │ ├── MakeWriteOnlyIndexDeleteOnly {"IndexID":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"Kind":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":2,"Kind":2,"Ordinal":1,"TableID":106} + │ ├── RemoveColumnNotNull {"ColumnID":3,"TableID":106} + │ ├── MakeWriteOnlyColumnDeleteOnly {"ColumnID":3,"TableID":106} + │ ├── SetJobStateOnDescriptor {"DescriptorID":106} + │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} + └── Stage 2 of 2 in PostCommitNonRevertiblePhase + ├── 7 elements transitioning toward ABSENT + │ ├── DELETE_ONLY → ABSENT Column:{DescID: 106, ColumnID: 3} + │ ├── PUBLIC → ABSENT ColumnFamily:{DescID: 106, Name: bob, ColumnFamilyID: 1} + │ ├── PUBLIC → ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 1, ColumnID: 3} + │ ├── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ ├── PUBLIC → ABSENT IndexData:{DescID: 106, IndexID: 2} + │ ├── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ └── PUBLIC → ABSENT IndexData:{DescID: 106, IndexID: 3} + └── 8 Mutation operations + ├── MakeIndexAbsent {"IndexID":2,"TableID":106} + ├── CreateGCJobForIndex {"IndexID":2,"TableID":106} + ├── MakeIndexAbsent {"IndexID":3,"TableID":106} + ├── CreateGCJobForIndex {"IndexID":3,"TableID":106} + ├── MakeDeleteOnlyColumnAbsent {"ColumnID":3,"TableID":106} + ├── AssertColumnFamilyIsRemoved {"FamilyID":1,"TableID":106} + ├── RemoveJobStateFromDescriptor {"DescriptorID":106} + └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"all stages compl..."} diff --git a/pkg/sql/schemachanger/testdata/explain/add_column_with_stored_family.rollback_6_of_7 b/pkg/sql/schemachanger/testdata/explain/add_column_with_stored_family.rollback_6_of_7 new file mode 100644 index 000000000000..47b9eabcd8c0 --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain/add_column_with_stored_family.rollback_6_of_7 @@ -0,0 +1,56 @@ +/* setup */ +CREATE DATABASE db; +CREATE TABLE db.public.tbl (i INT PRIMARY KEY, k INT); +CREATE SEQUENCE db.public.sq1; + +/* test */ +ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL AS (k) STORED CREATE FAMILY bob; +EXPLAIN (ddl) rollback at post-commit stage 6 of 7; +---- +Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD COLUMN ‹j› INT8 NOT NULL AS (‹k›) STORED CREATE FAMILY ‹bob›; + └── PostCommitNonRevertiblePhase + ├── Stage 1 of 2 in PostCommitNonRevertiblePhase + │ ├── 11 elements transitioning toward ABSENT + │ │ ├── WRITE_ONLY → DELETE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ ├── PUBLIC → ABSENT ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ ├── MERGE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ └── WRITE_ONLY → ABSENT ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ └── 13 Mutation operations + │ ├── SetColumnName {"ColumnID":3,"Name":"crdb_internal_co...","TableID":106} + │ ├── MakeWriteOnlyIndexDeleteOnly {"IndexID":3,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"Kind":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":3,"Kind":2,"Ordinal":1,"TableID":106} + │ ├── MakeWriteOnlyIndexDeleteOnly {"IndexID":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"Kind":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":2,"Kind":2,"Ordinal":1,"TableID":106} + │ ├── RemoveColumnNotNull {"ColumnID":3,"TableID":106} + │ ├── MakeWriteOnlyColumnDeleteOnly {"ColumnID":3,"TableID":106} + │ ├── SetJobStateOnDescriptor {"DescriptorID":106} + │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} + └── Stage 2 of 2 in PostCommitNonRevertiblePhase + ├── 7 elements transitioning toward ABSENT + │ ├── DELETE_ONLY → ABSENT Column:{DescID: 106, ColumnID: 3} + │ ├── PUBLIC → ABSENT ColumnFamily:{DescID: 106, Name: bob, ColumnFamilyID: 1} + │ ├── PUBLIC → ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 1, ColumnID: 3} + │ ├── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ ├── PUBLIC → ABSENT IndexData:{DescID: 106, IndexID: 2} + │ ├── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ └── PUBLIC → ABSENT IndexData:{DescID: 106, IndexID: 3} + └── 8 Mutation operations + ├── MakeIndexAbsent {"IndexID":2,"TableID":106} + ├── CreateGCJobForIndex {"IndexID":2,"TableID":106} + ├── MakeIndexAbsent {"IndexID":3,"TableID":106} + ├── CreateGCJobForIndex {"IndexID":3,"TableID":106} + ├── MakeDeleteOnlyColumnAbsent {"ColumnID":3,"TableID":106} + ├── AssertColumnFamilyIsRemoved {"FamilyID":1,"TableID":106} + ├── RemoveJobStateFromDescriptor {"DescriptorID":106} + └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"all stages compl..."} diff --git a/pkg/sql/schemachanger/testdata/explain/add_column_with_stored_family.rollback_7_of_7 b/pkg/sql/schemachanger/testdata/explain/add_column_with_stored_family.rollback_7_of_7 new file mode 100644 index 000000000000..05702f50767c --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain/add_column_with_stored_family.rollback_7_of_7 @@ -0,0 +1,56 @@ +/* setup */ +CREATE DATABASE db; +CREATE TABLE db.public.tbl (i INT PRIMARY KEY, k INT); +CREATE SEQUENCE db.public.sq1; + +/* test */ +ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL AS (k) STORED CREATE FAMILY bob; +EXPLAIN (ddl) rollback at post-commit stage 7 of 7; +---- +Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD COLUMN ‹j› INT8 NOT NULL AS (‹k›) STORED CREATE FAMILY ‹bob›; + └── PostCommitNonRevertiblePhase + ├── Stage 1 of 2 in PostCommitNonRevertiblePhase + │ ├── 11 elements transitioning toward ABSENT + │ │ ├── WRITE_ONLY → DELETE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ ├── PUBLIC → ABSENT ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ ├── WRITE_ONLY → DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ ├── WRITE_ONLY → DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ └── WRITE_ONLY → ABSENT ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ └── 13 Mutation operations + │ ├── SetColumnName {"ColumnID":3,"Name":"crdb_internal_co...","TableID":106} + │ ├── MakeWriteOnlyIndexDeleteOnly {"IndexID":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":2,"Kind":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":2,"Kind":2,"Ordinal":1,"TableID":106} + │ ├── MakeWriteOnlyIndexDeleteOnly {"IndexID":3,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":1,"IndexID":3,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":2,"IndexID":3,"Kind":2,"TableID":106} + │ ├── RemoveColumnFromIndex {"ColumnID":3,"IndexID":3,"Kind":2,"Ordinal":1,"TableID":106} + │ ├── RemoveColumnNotNull {"ColumnID":3,"TableID":106} + │ ├── MakeWriteOnlyColumnDeleteOnly {"ColumnID":3,"TableID":106} + │ ├── SetJobStateOnDescriptor {"DescriptorID":106} + │ └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"PostCommitNonRev..."} + └── Stage 2 of 2 in PostCommitNonRevertiblePhase + ├── 7 elements transitioning toward ABSENT + │ ├── DELETE_ONLY → ABSENT Column:{DescID: 106, ColumnID: 3} + │ ├── PUBLIC → ABSENT ColumnFamily:{DescID: 106, Name: bob, ColumnFamilyID: 1} + │ ├── PUBLIC → ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 1, ColumnID: 3} + │ ├── DELETE_ONLY → ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ ├── PUBLIC → ABSENT IndexData:{DescID: 106, IndexID: 2} + │ ├── DELETE_ONLY → ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ └── PUBLIC → ABSENT IndexData:{DescID: 106, IndexID: 3} + └── 8 Mutation operations + ├── MakeIndexAbsent {"IndexID":2,"TableID":106} + ├── CreateGCJobForIndex {"IndexID":2,"TableID":106} + ├── MakeIndexAbsent {"IndexID":3,"TableID":106} + ├── CreateGCJobForIndex {"IndexID":3,"TableID":106} + ├── MakeDeleteOnlyColumnAbsent {"ColumnID":3,"TableID":106} + ├── AssertColumnFamilyIsRemoved {"FamilyID":1,"TableID":106} + ├── RemoveJobStateFromDescriptor {"DescriptorID":106} + └── UpdateSchemaChangerJob {"IsNonCancelable":true,"RunningStatus":"all stages compl..."} diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored new file mode 100644 index 000000000000..85cda324878d --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored @@ -0,0 +1,947 @@ +/* setup */ +CREATE DATABASE db; +CREATE TABLE db.public.tbl (i INT PRIMARY KEY, k INT); +CREATE SEQUENCE db.public.sq1; + +/* test */ +EXPLAIN (ddl, verbose) ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL AS (k) STORED; +---- +• Schema change plan for ALTER TABLE ‹db›.‹public›.‹tbl› ADD COLUMN ‹j› INT8 NOT NULL AS (‹k›) STORED; +│ +├── • StatementPhase +│ │ +│ └── • Stage 1 of 1 in StatementPhase +│ │ +│ ├── • 8 elements transitioning toward PUBLIC +│ │ │ +│ │ ├── • Column:{DescID: 106, ColumnID: 3} +│ │ │ │ ABSENT → DELETE_ONLY +│ │ │ │ +│ │ │ └── • PreviousStagePrecedence dependency from ABSENT Column:{DescID: 106, ColumnID: 3} +│ │ │ rule: "Column transitions to PUBLIC uphold 2-version invariant: ABSENT->DELETE_ONLY" +│ │ │ +│ │ ├── • ColumnName:{DescID: 106, Name: j, ColumnID: 3} +│ │ │ │ ABSENT → PUBLIC +│ │ │ │ +│ │ │ └── • SameStagePrecedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} +│ │ │ rule: "column existence precedes column dependents" +│ │ │ rule: "column name and type set right after column existence" +│ │ │ +│ │ ├── • ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 3} +│ │ │ │ ABSENT → PUBLIC +│ │ │ │ +│ │ │ └── • SameStagePrecedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} +│ │ │ rule: "column existence precedes column dependents" +│ │ │ rule: "column name and type set right after column existence" +│ │ │ +│ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ │ ABSENT → BACKFILL_ONLY +│ │ │ │ +│ │ │ ├── • Precedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} +│ │ │ │ rule: "column existence precedes index existence" +│ │ │ │ +│ │ │ └── • PreviousStagePrecedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ rule: "PrimaryIndex transitions to PUBLIC uphold 2-version invariant: ABSENT->BACKFILL_ONLY" +│ │ │ +│ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} +│ │ │ │ ABSENT → PUBLIC +│ │ │ │ +│ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ rule: "index existence precedes index dependents" +│ │ │ +│ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} +│ │ │ │ ABSENT → PUBLIC +│ │ │ │ +│ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ rule: "index existence precedes index dependents" +│ │ │ +│ │ ├── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} +│ │ │ │ ABSENT → PUBLIC +│ │ │ │ +│ │ │ ├── • Precedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} +│ │ │ │ rule: "column existence precedes column dependents" +│ │ │ │ +│ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ rule: "index existence precedes index dependents" +│ │ │ +│ │ └── • IndexData:{DescID: 106, IndexID: 2} +│ │ │ ABSENT → PUBLIC +│ │ │ +│ │ └── • SameStagePrecedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ rule: "index data exists as soon as index accepts backfills" +│ │ +│ ├── • 4 elements transitioning toward TRANSIENT_ABSENT +│ │ │ +│ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} +│ │ │ │ ABSENT → DELETE_ONLY +│ │ │ │ +│ │ │ ├── • Precedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} +│ │ │ │ rule: "column existence precedes temp index existence" +│ │ │ │ +│ │ │ └── • PreviousStagePrecedence dependency from ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} +│ │ │ rule: "TemporaryIndex transitions to TRANSIENT_ABSENT uphold 2-version invariant: ABSENT->DELETE_ONLY" +│ │ │ +│ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} +│ │ │ │ ABSENT → PUBLIC +│ │ │ │ +│ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} +│ │ │ rule: "temp index existence precedes index dependents" +│ │ │ +│ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} +│ │ │ │ ABSENT → PUBLIC +│ │ │ │ +│ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} +│ │ │ rule: "temp index existence precedes index dependents" +│ │ │ +│ │ └── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} +│ │ │ ABSENT → PUBLIC +│ │ │ +│ │ ├── • Precedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} +│ │ │ rule: "column existence precedes column dependents" +│ │ │ +│ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} +│ │ rule: "temp index existence precedes index dependents" +│ │ +│ └── • 11 Mutation operations +│ │ +│ ├── • MakeAbsentColumnDeleteOnly +│ │ Column: +│ │ ColumnID: 3 +│ │ PgAttributeNum: 3 +│ │ TableID: 106 +│ │ +│ ├── • SetColumnName +│ │ ColumnID: 3 +│ │ Name: j +│ │ TableID: 106 +│ │ +│ ├── • SetAddedColumnType +│ │ ColumnType: +│ │ ColumnID: 3 +│ │ ComputeExpr: +│ │ expr: k +│ │ referencedColumnIds: +│ │ - 2 +│ │ ElementCreationMetadata: +│ │ in231OrLater: true +│ │ TableID: 106 +│ │ TypeT: +│ │ Type: +│ │ family: IntFamily +│ │ oid: 20 +│ │ width: 64 +│ │ +│ ├── • MakeAbsentIndexBackfilling +│ │ Index: +│ │ ConstraintID: 2 +│ │ IndexID: 2 +│ │ IsUnique: true +│ │ SourceIndexID: 1 +│ │ TableID: 106 +│ │ TemporaryIndexID: 3 +│ │ +│ ├── • AddColumnToIndex +│ │ ColumnID: 1 +│ │ IndexID: 2 +│ │ TableID: 106 +│ │ +│ ├── • AddColumnToIndex +│ │ ColumnID: 2 +│ │ IndexID: 2 +│ │ Kind: 2 +│ │ TableID: 106 +│ │ +│ ├── • AddColumnToIndex +│ │ ColumnID: 3 +│ │ IndexID: 2 +│ │ Kind: 2 +│ │ Ordinal: 1 +│ │ TableID: 106 +│ │ +│ ├── • MakeAbsentTempIndexDeleteOnly +│ │ Index: +│ │ ConstraintID: 3 +│ │ IndexID: 3 +│ │ IsUnique: true +│ │ SourceIndexID: 1 +│ │ TableID: 106 +│ │ +│ ├── • AddColumnToIndex +│ │ ColumnID: 1 +│ │ IndexID: 3 +│ │ TableID: 106 +│ │ +│ ├── • AddColumnToIndex +│ │ ColumnID: 2 +│ │ IndexID: 3 +│ │ Kind: 2 +│ │ TableID: 106 +│ │ +│ └── • AddColumnToIndex +│ ColumnID: 3 +│ IndexID: 3 +│ Kind: 2 +│ Ordinal: 1 +│ TableID: 106 +│ +├── • PreCommitPhase +│ │ +│ ├── • Stage 1 of 2 in PreCommitPhase +│ │ │ +│ │ ├── • 8 elements transitioning toward PUBLIC +│ │ │ │ +│ │ │ ├── • Column:{DescID: 106, ColumnID: 3} +│ │ │ │ DELETE_ONLY → ABSENT +│ │ │ │ +│ │ │ ├── • ColumnName:{DescID: 106, Name: j, ColumnID: 3} +│ │ │ │ PUBLIC → ABSENT +│ │ │ │ +│ │ │ ├── • ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 3} +│ │ │ │ PUBLIC → ABSENT +│ │ │ │ +│ │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ │ BACKFILL_ONLY → ABSENT +│ │ │ │ +│ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} +│ │ │ │ PUBLIC → ABSENT +│ │ │ │ +│ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} +│ │ │ │ PUBLIC → ABSENT +│ │ │ │ +│ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} +│ │ │ │ PUBLIC → ABSENT +│ │ │ │ +│ │ │ └── • IndexData:{DescID: 106, IndexID: 2} +│ │ │ PUBLIC → ABSENT +│ │ │ +│ │ ├── • 4 elements transitioning toward TRANSIENT_ABSENT +│ │ │ │ +│ │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} +│ │ │ │ DELETE_ONLY → ABSENT +│ │ │ │ +│ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} +│ │ │ │ PUBLIC → ABSENT +│ │ │ │ +│ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} +│ │ │ │ PUBLIC → ABSENT +│ │ │ │ +│ │ │ └── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} +│ │ │ PUBLIC → ABSENT +│ │ │ +│ │ └── • 1 Mutation operation +│ │ │ +│ │ └── • UndoAllInTxnImmediateMutationOpSideEffects +│ │ {} +│ │ +│ └── • Stage 2 of 2 in PreCommitPhase +│ │ +│ ├── • 8 elements transitioning toward PUBLIC +│ │ │ +│ │ ├── • Column:{DescID: 106, ColumnID: 3} +│ │ │ │ ABSENT → DELETE_ONLY +│ │ │ │ +│ │ │ └── • PreviousStagePrecedence dependency from ABSENT Column:{DescID: 106, ColumnID: 3} +│ │ │ rule: "Column transitions to PUBLIC uphold 2-version invariant: ABSENT->DELETE_ONLY" +│ │ │ +│ │ ├── • ColumnName:{DescID: 106, Name: j, ColumnID: 3} +│ │ │ │ ABSENT → PUBLIC +│ │ │ │ +│ │ │ └── • SameStagePrecedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} +│ │ │ rule: "column existence precedes column dependents" +│ │ │ rule: "column name and type set right after column existence" +│ │ │ +│ │ ├── • ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 3} +│ │ │ │ ABSENT → PUBLIC +│ │ │ │ +│ │ │ └── • SameStagePrecedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} +│ │ │ rule: "column existence precedes column dependents" +│ │ │ rule: "column name and type set right after column existence" +│ │ │ +│ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ │ ABSENT → BACKFILL_ONLY +│ │ │ │ +│ │ │ ├── • Precedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} +│ │ │ │ rule: "column existence precedes index existence" +│ │ │ │ +│ │ │ └── • PreviousStagePrecedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ rule: "PrimaryIndex transitions to PUBLIC uphold 2-version invariant: ABSENT->BACKFILL_ONLY" +│ │ │ +│ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} +│ │ │ │ ABSENT → PUBLIC +│ │ │ │ +│ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ rule: "index existence precedes index dependents" +│ │ │ +│ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} +│ │ │ │ ABSENT → PUBLIC +│ │ │ │ +│ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ rule: "index existence precedes index dependents" +│ │ │ +│ │ ├── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} +│ │ │ │ ABSENT → PUBLIC +│ │ │ │ +│ │ │ ├── • Precedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} +│ │ │ │ rule: "column existence precedes column dependents" +│ │ │ │ +│ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ rule: "index existence precedes index dependents" +│ │ │ +│ │ └── • IndexData:{DescID: 106, IndexID: 2} +│ │ │ ABSENT → PUBLIC +│ │ │ +│ │ └── • SameStagePrecedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ rule: "index data exists as soon as index accepts backfills" +│ │ +│ ├── • 4 elements transitioning toward TRANSIENT_ABSENT +│ │ │ +│ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} +│ │ │ │ ABSENT → DELETE_ONLY +│ │ │ │ +│ │ │ ├── • Precedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} +│ │ │ │ rule: "column existence precedes temp index existence" +│ │ │ │ +│ │ │ └── • PreviousStagePrecedence dependency from ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} +│ │ │ rule: "TemporaryIndex transitions to TRANSIENT_ABSENT uphold 2-version invariant: ABSENT->DELETE_ONLY" +│ │ │ +│ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} +│ │ │ │ ABSENT → PUBLIC +│ │ │ │ +│ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} +│ │ │ rule: "temp index existence precedes index dependents" +│ │ │ +│ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} +│ │ │ │ ABSENT → PUBLIC +│ │ │ │ +│ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} +│ │ │ rule: "temp index existence precedes index dependents" +│ │ │ +│ │ └── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} +│ │ │ ABSENT → PUBLIC +│ │ │ +│ │ ├── • Precedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} +│ │ │ rule: "column existence precedes column dependents" +│ │ │ +│ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} +│ │ rule: "temp index existence precedes index dependents" +│ │ +│ └── • 15 Mutation operations +│ │ +│ ├── • MakeAbsentColumnDeleteOnly +│ │ Column: +│ │ ColumnID: 3 +│ │ PgAttributeNum: 3 +│ │ TableID: 106 +│ │ +│ ├── • SetColumnName +│ │ ColumnID: 3 +│ │ Name: j +│ │ TableID: 106 +│ │ +│ ├── • SetAddedColumnType +│ │ ColumnType: +│ │ ColumnID: 3 +│ │ ComputeExpr: +│ │ expr: k +│ │ referencedColumnIds: +│ │ - 2 +│ │ ElementCreationMetadata: +│ │ in231OrLater: true +│ │ TableID: 106 +│ │ TypeT: +│ │ Type: +│ │ family: IntFamily +│ │ oid: 20 +│ │ width: 64 +│ │ +│ ├── • MakeAbsentIndexBackfilling +│ │ Index: +│ │ ConstraintID: 2 +│ │ IndexID: 2 +│ │ IsUnique: true +│ │ SourceIndexID: 1 +│ │ TableID: 106 +│ │ TemporaryIndexID: 3 +│ │ +│ ├── • MaybeAddSplitForIndex +│ │ IndexID: 2 +│ │ TableID: 106 +│ │ +│ ├── • AddColumnToIndex +│ │ ColumnID: 1 +│ │ IndexID: 2 +│ │ TableID: 106 +│ │ +│ ├── • AddColumnToIndex +│ │ ColumnID: 2 +│ │ IndexID: 2 +│ │ Kind: 2 +│ │ TableID: 106 +│ │ +│ ├── • AddColumnToIndex +│ │ ColumnID: 3 +│ │ IndexID: 2 +│ │ Kind: 2 +│ │ Ordinal: 1 +│ │ TableID: 106 +│ │ +│ ├── • MakeAbsentTempIndexDeleteOnly +│ │ Index: +│ │ ConstraintID: 3 +│ │ IndexID: 3 +│ │ IsUnique: true +│ │ SourceIndexID: 1 +│ │ TableID: 106 +│ │ +│ ├── • MaybeAddSplitForIndex +│ │ IndexID: 3 +│ │ TableID: 106 +│ │ +│ ├── • AddColumnToIndex +│ │ ColumnID: 1 +│ │ IndexID: 3 +│ │ TableID: 106 +│ │ +│ ├── • AddColumnToIndex +│ │ ColumnID: 2 +│ │ IndexID: 3 +│ │ Kind: 2 +│ │ TableID: 106 +│ │ +│ ├── • AddColumnToIndex +│ │ ColumnID: 3 +│ │ IndexID: 3 +│ │ Kind: 2 +│ │ Ordinal: 1 +│ │ TableID: 106 +│ │ +│ ├── • SetJobStateOnDescriptor +│ │ DescriptorID: 106 +│ │ Initialize: true +│ │ +│ └── • CreateSchemaChangerJob +│ Authorization: +│ UserName: root +│ DescriptorIDs: +│ - 106 +│ JobID: 1 +│ RunningStatus: PostCommitPhase stage 1 of 7 with 3 MutationType ops pending +│ Statements: +│ - statement: ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL AS (k) STORED +│ redactedstatement: ALTER TABLE ‹db›.‹public›.‹tbl› ADD COLUMN ‹j› INT8 NOT NULL +│ AS (‹k›) STORED +│ statementtag: ALTER TABLE +│ +├── • PostCommitPhase +│ │ +│ ├── • Stage 1 of 7 in PostCommitPhase +│ │ │ +│ │ ├── • 2 elements transitioning toward PUBLIC +│ │ │ │ +│ │ │ ├── • Column:{DescID: 106, ColumnID: 3} +│ │ │ │ │ DELETE_ONLY → WRITE_ONLY +│ │ │ │ │ +│ │ │ │ └── • PreviousStagePrecedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} +│ │ │ │ rule: "Column transitions to PUBLIC uphold 2-version invariant: DELETE_ONLY->WRITE_ONLY" +│ │ │ │ +│ │ │ └── • ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} +│ │ │ │ ABSENT → WRITE_ONLY +│ │ │ │ +│ │ │ ├── • SameStagePrecedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} +│ │ │ │ rule: "column writable right before column constraint is enforced." +│ │ │ │ +│ │ │ └── • PreviousStagePrecedence dependency from ABSENT ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} +│ │ │ rule: "ColumnNotNull transitions to PUBLIC uphold 2-version invariant: ABSENT->WRITE_ONLY" +│ │ │ +│ │ ├── • 2 elements transitioning toward TRANSIENT_ABSENT +│ │ │ │ +│ │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} +│ │ │ │ │ DELETE_ONLY → WRITE_ONLY +│ │ │ │ │ +│ │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} +│ │ │ │ │ rule: "column is WRITE_ONLY before temporary index is WRITE_ONLY" +│ │ │ │ │ +│ │ │ │ ├── • PreviousStagePrecedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} +│ │ │ │ │ rule: "TemporaryIndex transitions to TRANSIENT_ABSENT uphold 2-version invariant: DELETE_ONLY->WRITE_ONLY" +│ │ │ │ │ +│ │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} +│ │ │ │ │ rule: "index-column added to index before temp index receives writes" +│ │ │ │ │ +│ │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} +│ │ │ │ │ rule: "index-column added to index before temp index receives writes" +│ │ │ │ │ +│ │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} +│ │ │ │ rule: "index-column added to index before temp index receives writes" +│ │ │ │ +│ │ │ └── • IndexData:{DescID: 106, IndexID: 3} +│ │ │ │ ABSENT → PUBLIC +│ │ │ │ +│ │ │ └── • SameStagePrecedence dependency from WRITE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} +│ │ │ rule: "temp index data exists as soon as temp index accepts writes" +│ │ │ +│ │ └── • 5 Mutation operations +│ │ │ +│ │ ├── • MakeDeleteOnlyColumnWriteOnly +│ │ │ ColumnID: 3 +│ │ │ TableID: 106 +│ │ │ +│ │ ├── • MakeDeleteOnlyIndexWriteOnly +│ │ │ IndexID: 3 +│ │ │ TableID: 106 +│ │ │ +│ │ ├── • MakeAbsentColumnNotNullWriteOnly +│ │ │ ColumnID: 3 +│ │ │ TableID: 106 +│ │ │ +│ │ ├── • SetJobStateOnDescriptor +│ │ │ DescriptorID: 106 +│ │ │ +│ │ └── • UpdateSchemaChangerJob +│ │ JobID: 1 +│ │ RunningStatus: PostCommitPhase stage 2 of 7 with 1 BackfillType op pending +│ │ +│ ├── • Stage 2 of 7 in PostCommitPhase +│ │ │ +│ │ ├── • 1 element transitioning toward PUBLIC +│ │ │ │ +│ │ │ └── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ │ BACKFILL_ONLY → BACKFILLED +│ │ │ │ +│ │ │ ├── • PreviousStagePrecedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ │ rule: "PrimaryIndex transitions to PUBLIC uphold 2-version invariant: BACKFILL_ONLY->BACKFILLED" +│ │ │ │ +│ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} +│ │ │ │ rule: "index-column added to index before index is backfilled" +│ │ │ │ +│ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} +│ │ │ │ rule: "index-column added to index before index is backfilled" +│ │ │ │ +│ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} +│ │ │ │ rule: "index-column added to index before index is backfilled" +│ │ │ │ +│ │ │ └── • Precedence dependency from WRITE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} +│ │ │ rule: "temp index is WRITE_ONLY before backfill" +│ │ │ +│ │ └── • 1 Backfill operation +│ │ │ +│ │ └── • BackfillIndex +│ │ IndexID: 2 +│ │ SourceIndexID: 1 +│ │ TableID: 106 +│ │ +│ ├── • Stage 3 of 7 in PostCommitPhase +│ │ │ +│ │ ├── • 1 element transitioning toward PUBLIC +│ │ │ │ +│ │ │ └── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ │ BACKFILLED → DELETE_ONLY +│ │ │ │ +│ │ │ └── • PreviousStagePrecedence dependency from BACKFILLED PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ rule: "PrimaryIndex transitions to PUBLIC uphold 2-version invariant: BACKFILLED->DELETE_ONLY" +│ │ │ +│ │ └── • 3 Mutation operations +│ │ │ +│ │ ├── • MakeBackfillingIndexDeleteOnly +│ │ │ IndexID: 2 +│ │ │ TableID: 106 +│ │ │ +│ │ ├── • SetJobStateOnDescriptor +│ │ │ DescriptorID: 106 +│ │ │ +│ │ └── • UpdateSchemaChangerJob +│ │ JobID: 1 +│ │ RunningStatus: PostCommitPhase stage 4 of 7 with 1 MutationType op pending +│ │ +│ ├── • Stage 4 of 7 in PostCommitPhase +│ │ │ +│ │ ├── • 1 element transitioning toward PUBLIC +│ │ │ │ +│ │ │ └── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ │ DELETE_ONLY → MERGE_ONLY +│ │ │ │ +│ │ │ └── • PreviousStagePrecedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ rule: "PrimaryIndex transitions to PUBLIC uphold 2-version invariant: DELETE_ONLY->MERGE_ONLY" +│ │ │ +│ │ └── • 3 Mutation operations +│ │ │ +│ │ ├── • MakeBackfilledIndexMerging +│ │ │ IndexID: 2 +│ │ │ TableID: 106 +│ │ │ +│ │ ├── • SetJobStateOnDescriptor +│ │ │ DescriptorID: 106 +│ │ │ +│ │ └── • UpdateSchemaChangerJob +│ │ JobID: 1 +│ │ RunningStatus: PostCommitPhase stage 5 of 7 with 1 BackfillType op pending +│ │ +│ ├── • Stage 5 of 7 in PostCommitPhase +│ │ │ +│ │ ├── • 1 element transitioning toward PUBLIC +│ │ │ │ +│ │ │ └── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ │ MERGE_ONLY → MERGED +│ │ │ │ +│ │ │ └── • PreviousStagePrecedence dependency from MERGE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ rule: "PrimaryIndex transitions to PUBLIC uphold 2-version invariant: MERGE_ONLY->MERGED" +│ │ │ +│ │ └── • 1 Backfill operation +│ │ │ +│ │ └── • MergeIndex +│ │ BackfilledIndexID: 2 +│ │ TableID: 106 +│ │ TemporaryIndexID: 3 +│ │ +│ ├── • Stage 6 of 7 in PostCommitPhase +│ │ │ +│ │ ├── • 1 element transitioning toward PUBLIC +│ │ │ │ +│ │ │ └── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ │ MERGED → WRITE_ONLY +│ │ │ │ +│ │ │ └── • PreviousStagePrecedence dependency from MERGED PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ rule: "PrimaryIndex transitions to PUBLIC uphold 2-version invariant: MERGED->WRITE_ONLY" +│ │ │ +│ │ └── • 3 Mutation operations +│ │ │ +│ │ ├── • MakeMergedIndexWriteOnly +│ │ │ IndexID: 2 +│ │ │ TableID: 106 +│ │ │ +│ │ ├── • SetJobStateOnDescriptor +│ │ │ DescriptorID: 106 +│ │ │ +│ │ └── • UpdateSchemaChangerJob +│ │ JobID: 1 +│ │ RunningStatus: PostCommitPhase stage 7 of 7 with 2 ValidationType ops pending +│ │ +│ └── • Stage 7 of 7 in PostCommitPhase +│ │ +│ ├── • 2 elements transitioning toward PUBLIC +│ │ │ +│ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ │ WRITE_ONLY → VALIDATED +│ │ │ │ +│ │ │ └── • PreviousStagePrecedence dependency from WRITE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ rule: "PrimaryIndex transitions to PUBLIC uphold 2-version invariant: WRITE_ONLY->VALIDATED" +│ │ │ +│ │ └── • ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} +│ │ │ WRITE_ONLY → VALIDATED +│ │ │ +│ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ rule: "index is ready to be validated before we validate constraint on it" +│ │ │ +│ │ └── • PreviousStagePrecedence dependency from WRITE_ONLY ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} +│ │ rule: "ColumnNotNull transitions to PUBLIC uphold 2-version invariant: WRITE_ONLY->VALIDATED" +│ │ +│ └── • 2 Validation operations +│ │ +│ ├── • ValidateIndex +│ │ IndexID: 2 +│ │ TableID: 106 +│ │ +│ └── • ValidateColumnNotNull +│ ColumnID: 3 +│ IndexIDForValidation: 2 +│ TableID: 106 +│ +└── • PostCommitNonRevertiblePhase + │ + ├── • Stage 1 of 3 in PostCommitNonRevertiblePhase + │ │ + │ ├── • 4 elements transitioning toward PUBLIC + │ │ │ + │ │ ├── • Column:{DescID: 106, ColumnID: 3} + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • PreviousStagePrecedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "Column transitions to PUBLIC uphold 2-version invariant: WRITE_ONLY->PUBLIC" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ rule: "swapped primary index public before column" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ VALIDATED → PUBLIC + │ │ │ │ + │ │ │ ├── • SameStagePrecedence dependency from VALIDATED PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} + │ │ │ │ rule: "primary index swap" + │ │ │ │ + │ │ │ ├── • PreviousStagePrecedence dependency from VALIDATED PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ rule: "PrimaryIndex transitions to PUBLIC uphold 2-version invariant: VALIDATED->PUBLIC" + │ │ │ │ + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ rule: "primary index named right before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ + │ │ ├── • IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} + │ │ │ │ ABSENT → PUBLIC + │ │ │ │ + │ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index existence precedes index dependents" + │ │ │ + │ │ └── • ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ VALIDATED → PUBLIC + │ │ │ + │ │ ├── • Precedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ rule: "column existence precedes column dependents" + │ │ │ + │ │ └── • PreviousStagePrecedence dependency from VALIDATED ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ rule: "ColumnNotNull transitions to PUBLIC uphold 2-version invariant: VALIDATED->PUBLIC" + │ │ + │ ├── • 4 elements transitioning toward TRANSIENT_ABSENT + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ │ WRITE_ONLY → TRANSIENT_DELETE_ONLY + │ │ │ │ + │ │ │ └── • PreviousStagePrecedence dependency from WRITE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "TemporaryIndex transitions to TRANSIENT_ABSENT uphold 2-version invariant: WRITE_ONLY->TRANSIENT_DELETE_ONLY" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → TRANSIENT_ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from TRANSIENT_DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ │ │ PUBLIC → TRANSIENT_ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from TRANSIENT_DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ └── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ │ PUBLIC → TRANSIENT_ABSENT + │ │ │ + │ │ └── • Precedence dependency from TRANSIENT_DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ + │ ├── • 2 elements transitioning toward ABSENT + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} + │ │ │ │ PUBLIC → VALIDATED + │ │ │ │ + │ │ │ └── • PreviousStagePrecedence dependency from PUBLIC PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} + │ │ │ rule: "PrimaryIndex transitions to ABSENT uphold 2-version invariant: PUBLIC->VALIDATED" + │ │ │ + │ │ └── • IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 1} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} + │ │ rule: "index no longer public before dependents, excluding columns" + │ │ + │ └── • 13 Mutation operations + │ │ + │ ├── • MakePublicPrimaryIndexWriteOnly + │ │ IndexID: 1 + │ │ TableID: 106 + │ │ + │ ├── • SetIndexName + │ │ IndexID: 1 + │ │ Name: crdb_internal_index_1_name_placeholder + │ │ TableID: 106 + │ │ + │ ├── • SetIndexName + │ │ IndexID: 2 + │ │ Name: tbl_pkey + │ │ TableID: 106 + │ │ + │ ├── • MakeWriteOnlyIndexDeleteOnly + │ │ IndexID: 3 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 1 + │ │ IndexID: 3 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 2 + │ │ IndexID: 3 + │ │ Kind: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 3 + │ │ IndexID: 3 + │ │ Kind: 2 + │ │ Ordinal: 1 + │ │ TableID: 106 + │ │ + │ ├── • MakeValidatedColumnNotNullPublic + │ │ ColumnID: 3 + │ │ TableID: 106 + │ │ + │ ├── • MakeValidatedPrimaryIndexPublic + │ │ IndexID: 2 + │ │ TableID: 106 + │ │ + │ ├── • MakeWriteOnlyColumnPublic + │ │ ColumnID: 3 + │ │ TableID: 106 + │ │ + │ ├── • RefreshStats + │ │ TableID: 106 + │ │ + │ ├── • SetJobStateOnDescriptor + │ │ DescriptorID: 106 + │ │ + │ └── • UpdateSchemaChangerJob + │ IsNonCancelable: true + │ JobID: 1 + │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 3 with 4 MutationType ops pending + │ + ├── • Stage 2 of 3 in PostCommitNonRevertiblePhase + │ │ + │ ├── • 1 element transitioning toward TRANSIENT_ABSENT + │ │ │ + │ │ └── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from TRANSIENT_DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "TemporaryIndex transitions to TRANSIENT_ABSENT uphold 2-version invariant: TRANSIENT_DELETE_ONLY->TRANSIENT_ABSENT" + │ │ │ + │ │ ├── • Precedence dependency from TRANSIENT_ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from TRANSIENT_ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from TRANSIENT_ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ rule: "dependents removed before index" + │ │ + │ ├── • 3 elements transitioning toward ABSENT + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 1} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 1} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ └── • PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} + │ │ │ VALIDATED → DELETE_ONLY + │ │ │ + │ │ └── • PreviousStagePrecedence dependency from VALIDATED PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} + │ │ rule: "PrimaryIndex transitions to ABSENT uphold 2-version invariant: VALIDATED->WRITE_ONLY" + │ │ + │ └── • 6 Mutation operations + │ │ + │ ├── • MakeIndexAbsent + │ │ IndexID: 3 + │ │ TableID: 106 + │ │ + │ ├── • MakeWriteOnlyIndexDeleteOnly + │ │ IndexID: 1 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 1 + │ │ IndexID: 1 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 2 + │ │ IndexID: 1 + │ │ Kind: 2 + │ │ TableID: 106 + │ │ + │ ├── • SetJobStateOnDescriptor + │ │ DescriptorID: 106 + │ │ + │ └── • UpdateSchemaChangerJob + │ IsNonCancelable: true + │ JobID: 1 + │ RunningStatus: PostCommitNonRevertiblePhase stage 3 of 3 with 3 MutationType ops pending + │ + └── • Stage 3 of 3 in PostCommitNonRevertiblePhase + │ + ├── • 1 element transitioning toward TRANSIENT_ABSENT + │ │ + │ └── • IndexData:{DescID: 106, IndexID: 3} + │ │ PUBLIC → TRANSIENT_ABSENT + │ │ + │ ├── • SameStagePrecedence dependency from DROPPED IndexData:{DescID: 106, IndexID: 1} + │ │ rule: "schedule all GC jobs for a descriptor in the same stage" + │ │ + │ └── • Precedence dependency from TRANSIENT_ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ rule: "index removed before garbage collection" + │ + ├── • 2 elements transitioning toward ABSENT + │ │ + │ ├── • PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 1} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 1} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} + │ │ │ rule: "PrimaryIndex transitions to ABSENT uphold 2-version invariant: DELETE_ONLY->ABSENT" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 1} + │ │ rule: "dependents removed before index" + │ │ + │ └── • IndexData:{DescID: 106, IndexID: 1} + │ │ PUBLIC → ABSENT + │ │ + │ └── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} + │ rule: "index removed before garbage collection" + │ + └── • 5 Mutation operations + │ + ├── • MakeIndexAbsent + │ IndexID: 1 + │ TableID: 106 + │ + ├── • CreateGCJobForIndex + │ IndexID: 1 + │ StatementForDropJob: + │ Statement: ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL AS (k) STORED + │ TableID: 106 + │ + ├── • CreateGCJobForIndex + │ IndexID: 3 + │ StatementForDropJob: + │ Statement: ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL AS (k) STORED + │ TableID: 106 + │ + ├── • RemoveJobStateFromDescriptor + │ DescriptorID: 106 + │ JobID: 1 + │ + └── • UpdateSchemaChangerJob + DescriptorIDsToRemove: + - 106 + IsNonCancelable: true + JobID: 1 + RunningStatus: all stages completed diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored.rollback_1_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored.rollback_1_of_7 new file mode 100644 index 000000000000..6484f56a4a99 --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored.rollback_1_of_7 @@ -0,0 +1,195 @@ +/* setup */ +CREATE DATABASE db; +CREATE TABLE db.public.tbl (i INT PRIMARY KEY, k INT); +CREATE SEQUENCE db.public.sq1; + +/* test */ +ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL AS (k) STORED; +EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 7; +---- +• Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD COLUMN ‹j› INT8 NOT NULL AS (‹k›) STORED; +│ +└── • PostCommitNonRevertiblePhase + │ + └── • Stage 1 of 1 in PostCommitNonRevertiblePhase + │ + ├── • 12 elements transitioning toward ABSENT + │ │ + │ ├── • Column:{DescID: 106, ColumnID: 3} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ rule: "Column transitions to ABSENT uphold 2-version invariant: DELETE_ONLY->ABSENT" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • SameStagePrecedence dependency from ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ rule: "column type removed right before column when not dropping relation" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "indexes containing column reach absent before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ └── • Precedence dependency from ABSENT ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ rule: "dependents removed before column" + │ │ + │ ├── • ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ PUBLIC → ABSENT + │ │ + │ ├── • ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 3} + │ │ PUBLIC → ABSENT + │ │ + │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ BACKFILL_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "PrimaryIndex transitions to ABSENT uphold 2-version invariant: BACKFILL_ONLY->DELETE_ONLY" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ rule: "dependents removed before index" + │ │ + │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ + │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ + │ ├── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ + │ ├── • IndexData:{DescID: 106, IndexID: 2} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ rule: "index removed before garbage collection" + │ │ + │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "TemporaryIndex transitions to ABSENT uphold 2-version invariant: DELETE_ONLY->ABSENT" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ rule: "dependents removed before index" + │ │ + │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ + │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ + │ └── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ PUBLIC → ABSENT + │ │ + │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ rule: "index drop mutation visible before cleaning up index columns" + │ + └── • 13 Mutation operations + │ + ├── • SetColumnName + │ ColumnID: 3 + │ Name: crdb_internal_column_3_name_placeholder + │ TableID: 106 + │ + ├── • RemoveColumnFromIndex + │ ColumnID: 1 + │ IndexID: 2 + │ TableID: 106 + │ + ├── • RemoveColumnFromIndex + │ ColumnID: 2 + │ IndexID: 2 + │ Kind: 2 + │ TableID: 106 + │ + ├── • RemoveColumnFromIndex + │ ColumnID: 3 + │ IndexID: 2 + │ Kind: 2 + │ Ordinal: 1 + │ TableID: 106 + │ + ├── • RemoveColumnFromIndex + │ ColumnID: 1 + │ IndexID: 3 + │ TableID: 106 + │ + ├── • RemoveColumnFromIndex + │ ColumnID: 2 + │ IndexID: 3 + │ Kind: 2 + │ TableID: 106 + │ + ├── • RemoveColumnFromIndex + │ ColumnID: 3 + │ IndexID: 3 + │ Kind: 2 + │ Ordinal: 1 + │ TableID: 106 + │ + ├── • MakeIndexAbsent + │ IndexID: 2 + │ TableID: 106 + │ + ├── • CreateGCJobForIndex + │ IndexID: 2 + │ StatementForDropJob: + │ Rollback: true + │ Statement: ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL AS (k) STORED + │ TableID: 106 + │ + ├── • MakeIndexAbsent + │ IndexID: 3 + │ TableID: 106 + │ + ├── • MakeDeleteOnlyColumnAbsent + │ ColumnID: 3 + │ TableID: 106 + │ + ├── • RemoveJobStateFromDescriptor + │ DescriptorID: 106 + │ JobID: 1 + │ + └── • UpdateSchemaChangerJob + DescriptorIDsToRemove: + - 106 + IsNonCancelable: true + JobID: 1 + RunningStatus: all stages completed diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored.rollback_2_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored.rollback_2_of_7 new file mode 100644 index 000000000000..a9f4944c2520 --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored.rollback_2_of_7 @@ -0,0 +1,273 @@ +/* setup */ +CREATE DATABASE db; +CREATE TABLE db.public.tbl (i INT PRIMARY KEY, k INT); +CREATE SEQUENCE db.public.sq1; + +/* test */ +ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL AS (k) STORED; +EXPLAIN (ddl, verbose) rollback at post-commit stage 2 of 7; +---- +• Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD COLUMN ‹j› INT8 NOT NULL AS (‹k›) STORED; +│ +└── • PostCommitNonRevertiblePhase + │ + ├── • Stage 1 of 2 in PostCommitNonRevertiblePhase + │ │ + │ ├── • 11 elements transitioning toward ABSENT + │ │ │ + │ │ ├── • Column:{DescID: 106, ColumnID: 3} + │ │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ │ + │ │ │ ├── • PreviousStagePrecedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "Column transitions to ABSENT uphold 2-version invariant: WRITE_ONLY->DELETE_ONLY" + │ │ │ │ + │ │ │ └── • SameStagePrecedence dependency from ABSENT ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "column constraint removed right before column reaches delete only" + │ │ │ + │ │ ├── • ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ rule: "column no longer public before dependents" + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ BACKFILL_ONLY → ABSENT + │ │ │ │ + │ │ │ ├── • PreviousStagePrecedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ rule: "PrimaryIndex transitions to ABSENT uphold 2-version invariant: BACKFILL_ONLY->DELETE_ONLY" + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ │ + │ │ │ └── • PreviousStagePrecedence dependency from WRITE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "TemporaryIndex transitions to ABSENT uphold 2-version invariant: WRITE_ONLY->DELETE_ONLY" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ └── • ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ WRITE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from WRITE_ONLY ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "ColumnNotNull transitions to ABSENT uphold 2-version invariant: WRITE_ONLY->VALIDATED" + │ │ │ + │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ rule: "column no longer public before dependents" + │ │ + │ └── • 13 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 3 + │ │ Name: crdb_internal_column_3_name_placeholder + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 1 + │ │ IndexID: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 2 + │ │ IndexID: 2 + │ │ Kind: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 3 + │ │ IndexID: 2 + │ │ Kind: 2 + │ │ Ordinal: 1 + │ │ TableID: 106 + │ │ + │ ├── • MakeWriteOnlyIndexDeleteOnly + │ │ IndexID: 3 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 1 + │ │ IndexID: 3 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 2 + │ │ IndexID: 3 + │ │ Kind: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 3 + │ │ IndexID: 3 + │ │ Kind: 2 + │ │ Ordinal: 1 + │ │ TableID: 106 + │ │ + │ ├── • MakeIndexAbsent + │ │ IndexID: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnNotNull + │ │ ColumnID: 3 + │ │ TableID: 106 + │ │ + │ ├── • MakeWriteOnlyColumnDeleteOnly + │ │ ColumnID: 3 + │ │ TableID: 106 + │ │ + │ ├── • SetJobStateOnDescriptor + │ │ DescriptorID: 106 + │ │ + │ └── • UpdateSchemaChangerJob + │ IsNonCancelable: true + │ JobID: 1 + │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 2 with 4 MutationType ops pending + │ + └── • Stage 2 of 2 in PostCommitNonRevertiblePhase + │ + ├── • 5 elements transitioning toward ABSENT + │ │ + │ ├── • Column:{DescID: 106, ColumnID: 3} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ rule: "Column transitions to ABSENT uphold 2-version invariant: DELETE_ONLY->ABSENT" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • SameStagePrecedence dependency from ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ rule: "column type removed right before column when not dropping relation" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "indexes containing column reach absent before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ └── • Precedence dependency from ABSENT ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ rule: "dependents removed before column" + │ │ + │ ├── • ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 3} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ rule: "column no longer public before dependents" + │ │ + │ ├── • IndexData:{DescID: 106, IndexID: 2} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ rule: "index removed before garbage collection" + │ │ + │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "TemporaryIndex transitions to ABSENT uphold 2-version invariant: DELETE_ONLY->ABSENT" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ rule: "dependents removed before index" + │ │ + │ └── • IndexData:{DescID: 106, IndexID: 3} + │ │ PUBLIC → ABSENT + │ │ + │ ├── • SameStagePrecedence dependency from DROPPED IndexData:{DescID: 106, IndexID: 2} + │ │ rule: "schedule all GC jobs for a descriptor in the same stage" + │ │ + │ └── • Precedence dependency from ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ rule: "index removed before garbage collection" + │ + └── • 6 Mutation operations + │ + ├── • CreateGCJobForIndex + │ IndexID: 2 + │ StatementForDropJob: + │ Rollback: true + │ Statement: ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL AS (k) STORED + │ TableID: 106 + │ + ├── • MakeIndexAbsent + │ IndexID: 3 + │ TableID: 106 + │ + ├── • CreateGCJobForIndex + │ IndexID: 3 + │ StatementForDropJob: + │ Rollback: true + │ Statement: ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL AS (k) STORED + │ TableID: 106 + │ + ├── • MakeDeleteOnlyColumnAbsent + │ ColumnID: 3 + │ TableID: 106 + │ + ├── • RemoveJobStateFromDescriptor + │ DescriptorID: 106 + │ JobID: 1 + │ + └── • UpdateSchemaChangerJob + DescriptorIDsToRemove: + - 106 + IsNonCancelable: true + JobID: 1 + RunningStatus: all stages completed diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored.rollback_3_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored.rollback_3_of_7 new file mode 100644 index 000000000000..4c44edf1d102 --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored.rollback_3_of_7 @@ -0,0 +1,273 @@ +/* setup */ +CREATE DATABASE db; +CREATE TABLE db.public.tbl (i INT PRIMARY KEY, k INT); +CREATE SEQUENCE db.public.sq1; + +/* test */ +ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL AS (k) STORED; +EXPLAIN (ddl, verbose) rollback at post-commit stage 3 of 7; +---- +• Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD COLUMN ‹j› INT8 NOT NULL AS (‹k›) STORED; +│ +└── • PostCommitNonRevertiblePhase + │ + ├── • Stage 1 of 2 in PostCommitNonRevertiblePhase + │ │ + │ ├── • 11 elements transitioning toward ABSENT + │ │ │ + │ │ ├── • Column:{DescID: 106, ColumnID: 3} + │ │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ │ + │ │ │ ├── • PreviousStagePrecedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "Column transitions to ABSENT uphold 2-version invariant: WRITE_ONLY->DELETE_ONLY" + │ │ │ │ + │ │ │ └── • SameStagePrecedence dependency from ABSENT ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "column constraint removed right before column reaches delete only" + │ │ │ + │ │ ├── • ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ rule: "column no longer public before dependents" + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ BACKFILL_ONLY → ABSENT + │ │ │ │ + │ │ │ ├── • PreviousStagePrecedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ rule: "PrimaryIndex transitions to ABSENT uphold 2-version invariant: BACKFILL_ONLY->DELETE_ONLY" + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ │ + │ │ │ └── • PreviousStagePrecedence dependency from WRITE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "TemporaryIndex transitions to ABSENT uphold 2-version invariant: WRITE_ONLY->DELETE_ONLY" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ └── • ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ WRITE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from WRITE_ONLY ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "ColumnNotNull transitions to ABSENT uphold 2-version invariant: WRITE_ONLY->VALIDATED" + │ │ │ + │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ rule: "column no longer public before dependents" + │ │ + │ └── • 13 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 3 + │ │ Name: crdb_internal_column_3_name_placeholder + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 1 + │ │ IndexID: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 2 + │ │ IndexID: 2 + │ │ Kind: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 3 + │ │ IndexID: 2 + │ │ Kind: 2 + │ │ Ordinal: 1 + │ │ TableID: 106 + │ │ + │ ├── • MakeWriteOnlyIndexDeleteOnly + │ │ IndexID: 3 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 1 + │ │ IndexID: 3 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 2 + │ │ IndexID: 3 + │ │ Kind: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 3 + │ │ IndexID: 3 + │ │ Kind: 2 + │ │ Ordinal: 1 + │ │ TableID: 106 + │ │ + │ ├── • MakeIndexAbsent + │ │ IndexID: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnNotNull + │ │ ColumnID: 3 + │ │ TableID: 106 + │ │ + │ ├── • MakeWriteOnlyColumnDeleteOnly + │ │ ColumnID: 3 + │ │ TableID: 106 + │ │ + │ ├── • SetJobStateOnDescriptor + │ │ DescriptorID: 106 + │ │ + │ └── • UpdateSchemaChangerJob + │ IsNonCancelable: true + │ JobID: 1 + │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 2 with 4 MutationType ops pending + │ + └── • Stage 2 of 2 in PostCommitNonRevertiblePhase + │ + ├── • 5 elements transitioning toward ABSENT + │ │ + │ ├── • Column:{DescID: 106, ColumnID: 3} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ rule: "Column transitions to ABSENT uphold 2-version invariant: DELETE_ONLY->ABSENT" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • SameStagePrecedence dependency from ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ rule: "column type removed right before column when not dropping relation" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "indexes containing column reach absent before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ └── • Precedence dependency from ABSENT ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ rule: "dependents removed before column" + │ │ + │ ├── • ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 3} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ rule: "column no longer public before dependents" + │ │ + │ ├── • IndexData:{DescID: 106, IndexID: 2} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ rule: "index removed before garbage collection" + │ │ + │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "TemporaryIndex transitions to ABSENT uphold 2-version invariant: DELETE_ONLY->ABSENT" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ rule: "dependents removed before index" + │ │ + │ └── • IndexData:{DescID: 106, IndexID: 3} + │ │ PUBLIC → ABSENT + │ │ + │ ├── • SameStagePrecedence dependency from DROPPED IndexData:{DescID: 106, IndexID: 2} + │ │ rule: "schedule all GC jobs for a descriptor in the same stage" + │ │ + │ └── • Precedence dependency from ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ rule: "index removed before garbage collection" + │ + └── • 6 Mutation operations + │ + ├── • CreateGCJobForIndex + │ IndexID: 2 + │ StatementForDropJob: + │ Rollback: true + │ Statement: ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL AS (k) STORED + │ TableID: 106 + │ + ├── • MakeIndexAbsent + │ IndexID: 3 + │ TableID: 106 + │ + ├── • CreateGCJobForIndex + │ IndexID: 3 + │ StatementForDropJob: + │ Rollback: true + │ Statement: ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL AS (k) STORED + │ TableID: 106 + │ + ├── • MakeDeleteOnlyColumnAbsent + │ ColumnID: 3 + │ TableID: 106 + │ + ├── • RemoveJobStateFromDescriptor + │ DescriptorID: 106 + │ JobID: 1 + │ + └── • UpdateSchemaChangerJob + DescriptorIDsToRemove: + - 106 + IsNonCancelable: true + JobID: 1 + RunningStatus: all stages completed diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored.rollback_4_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored.rollback_4_of_7 new file mode 100644 index 000000000000..8c96ca6bfc9c --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored.rollback_4_of_7 @@ -0,0 +1,273 @@ +/* setup */ +CREATE DATABASE db; +CREATE TABLE db.public.tbl (i INT PRIMARY KEY, k INT); +CREATE SEQUENCE db.public.sq1; + +/* test */ +ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL AS (k) STORED; +EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 7; +---- +• Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD COLUMN ‹j› INT8 NOT NULL AS (‹k›) STORED; +│ +└── • PostCommitNonRevertiblePhase + │ + ├── • Stage 1 of 2 in PostCommitNonRevertiblePhase + │ │ + │ ├── • 11 elements transitioning toward ABSENT + │ │ │ + │ │ ├── • Column:{DescID: 106, ColumnID: 3} + │ │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ │ + │ │ │ ├── • PreviousStagePrecedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "Column transitions to ABSENT uphold 2-version invariant: WRITE_ONLY->DELETE_ONLY" + │ │ │ │ + │ │ │ └── • SameStagePrecedence dependency from ABSENT ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "column constraint removed right before column reaches delete only" + │ │ │ + │ │ ├── • ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ rule: "column no longer public before dependents" + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ DELETE_ONLY → ABSENT + │ │ │ │ + │ │ │ ├── • PreviousStagePrecedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ rule: "PrimaryIndex transitions to ABSENT uphold 2-version invariant: DELETE_ONLY->ABSENT" + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ │ + │ │ │ └── • PreviousStagePrecedence dependency from WRITE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "TemporaryIndex transitions to ABSENT uphold 2-version invariant: WRITE_ONLY->DELETE_ONLY" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ └── • ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ WRITE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from WRITE_ONLY ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "ColumnNotNull transitions to ABSENT uphold 2-version invariant: WRITE_ONLY->VALIDATED" + │ │ │ + │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ rule: "column no longer public before dependents" + │ │ + │ └── • 13 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 3 + │ │ Name: crdb_internal_column_3_name_placeholder + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 1 + │ │ IndexID: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 2 + │ │ IndexID: 2 + │ │ Kind: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 3 + │ │ IndexID: 2 + │ │ Kind: 2 + │ │ Ordinal: 1 + │ │ TableID: 106 + │ │ + │ ├── • MakeWriteOnlyIndexDeleteOnly + │ │ IndexID: 3 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 1 + │ │ IndexID: 3 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 2 + │ │ IndexID: 3 + │ │ Kind: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 3 + │ │ IndexID: 3 + │ │ Kind: 2 + │ │ Ordinal: 1 + │ │ TableID: 106 + │ │ + │ ├── • MakeIndexAbsent + │ │ IndexID: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnNotNull + │ │ ColumnID: 3 + │ │ TableID: 106 + │ │ + │ ├── • MakeWriteOnlyColumnDeleteOnly + │ │ ColumnID: 3 + │ │ TableID: 106 + │ │ + │ ├── • SetJobStateOnDescriptor + │ │ DescriptorID: 106 + │ │ + │ └── • UpdateSchemaChangerJob + │ IsNonCancelable: true + │ JobID: 1 + │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 2 with 4 MutationType ops pending + │ + └── • Stage 2 of 2 in PostCommitNonRevertiblePhase + │ + ├── • 5 elements transitioning toward ABSENT + │ │ + │ ├── • Column:{DescID: 106, ColumnID: 3} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ rule: "Column transitions to ABSENT uphold 2-version invariant: DELETE_ONLY->ABSENT" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • SameStagePrecedence dependency from ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ rule: "column type removed right before column when not dropping relation" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "indexes containing column reach absent before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ └── • Precedence dependency from ABSENT ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ rule: "dependents removed before column" + │ │ + │ ├── • ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 3} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ rule: "column no longer public before dependents" + │ │ + │ ├── • IndexData:{DescID: 106, IndexID: 2} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ rule: "index removed before garbage collection" + │ │ + │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "TemporaryIndex transitions to ABSENT uphold 2-version invariant: DELETE_ONLY->ABSENT" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ rule: "dependents removed before index" + │ │ + │ └── • IndexData:{DescID: 106, IndexID: 3} + │ │ PUBLIC → ABSENT + │ │ + │ ├── • SameStagePrecedence dependency from DROPPED IndexData:{DescID: 106, IndexID: 2} + │ │ rule: "schedule all GC jobs for a descriptor in the same stage" + │ │ + │ └── • Precedence dependency from ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ rule: "index removed before garbage collection" + │ + └── • 6 Mutation operations + │ + ├── • CreateGCJobForIndex + │ IndexID: 2 + │ StatementForDropJob: + │ Rollback: true + │ Statement: ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL AS (k) STORED + │ TableID: 106 + │ + ├── • MakeIndexAbsent + │ IndexID: 3 + │ TableID: 106 + │ + ├── • CreateGCJobForIndex + │ IndexID: 3 + │ StatementForDropJob: + │ Rollback: true + │ Statement: ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL AS (k) STORED + │ TableID: 106 + │ + ├── • MakeDeleteOnlyColumnAbsent + │ ColumnID: 3 + │ TableID: 106 + │ + ├── • RemoveJobStateFromDescriptor + │ DescriptorID: 106 + │ JobID: 1 + │ + └── • UpdateSchemaChangerJob + DescriptorIDsToRemove: + - 106 + IsNonCancelable: true + JobID: 1 + RunningStatus: all stages completed diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored.rollback_5_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored.rollback_5_of_7 new file mode 100644 index 000000000000..78f100cd52f8 --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored.rollback_5_of_7 @@ -0,0 +1,283 @@ +/* setup */ +CREATE DATABASE db; +CREATE TABLE db.public.tbl (i INT PRIMARY KEY, k INT); +CREATE SEQUENCE db.public.sq1; + +/* test */ +ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL AS (k) STORED; +EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 7; +---- +• Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD COLUMN ‹j› INT8 NOT NULL AS (‹k›) STORED; +│ +└── • PostCommitNonRevertiblePhase + │ + ├── • Stage 1 of 2 in PostCommitNonRevertiblePhase + │ │ + │ ├── • 11 elements transitioning toward ABSENT + │ │ │ + │ │ ├── • Column:{DescID: 106, ColumnID: 3} + │ │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ │ + │ │ │ ├── • PreviousStagePrecedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "Column transitions to ABSENT uphold 2-version invariant: WRITE_ONLY->DELETE_ONLY" + │ │ │ │ + │ │ │ └── • SameStagePrecedence dependency from ABSENT ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "column constraint removed right before column reaches delete only" + │ │ │ + │ │ ├── • ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ rule: "column no longer public before dependents" + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ MERGE_ONLY → DELETE_ONLY + │ │ │ │ + │ │ │ └── • PreviousStagePrecedence dependency from MERGE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "PrimaryIndex transitions to ABSENT uphold 2-version invariant: MERGE_ONLY->WRITE_ONLY" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ │ + │ │ │ └── • PreviousStagePrecedence dependency from WRITE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "TemporaryIndex transitions to ABSENT uphold 2-version invariant: WRITE_ONLY->DELETE_ONLY" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ └── • ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ WRITE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from WRITE_ONLY ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "ColumnNotNull transitions to ABSENT uphold 2-version invariant: WRITE_ONLY->VALIDATED" + │ │ │ + │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ rule: "column no longer public before dependents" + │ │ + │ └── • 13 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 3 + │ │ Name: crdb_internal_column_3_name_placeholder + │ │ TableID: 106 + │ │ + │ ├── • MakeWriteOnlyIndexDeleteOnly + │ │ IndexID: 3 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 1 + │ │ IndexID: 3 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 2 + │ │ IndexID: 3 + │ │ Kind: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 3 + │ │ IndexID: 3 + │ │ Kind: 2 + │ │ Ordinal: 1 + │ │ TableID: 106 + │ │ + │ ├── • MakeWriteOnlyIndexDeleteOnly + │ │ IndexID: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 1 + │ │ IndexID: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 2 + │ │ IndexID: 2 + │ │ Kind: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 3 + │ │ IndexID: 2 + │ │ Kind: 2 + │ │ Ordinal: 1 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnNotNull + │ │ ColumnID: 3 + │ │ TableID: 106 + │ │ + │ ├── • MakeWriteOnlyColumnDeleteOnly + │ │ ColumnID: 3 + │ │ TableID: 106 + │ │ + │ ├── • SetJobStateOnDescriptor + │ │ DescriptorID: 106 + │ │ + │ └── • UpdateSchemaChangerJob + │ IsNonCancelable: true + │ JobID: 1 + │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 2 with 5 MutationType ops pending + │ + └── • Stage 2 of 2 in PostCommitNonRevertiblePhase + │ + ├── • 6 elements transitioning toward ABSENT + │ │ + │ ├── • Column:{DescID: 106, ColumnID: 3} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ rule: "Column transitions to ABSENT uphold 2-version invariant: DELETE_ONLY->ABSENT" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • SameStagePrecedence dependency from ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ rule: "column type removed right before column when not dropping relation" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "indexes containing column reach absent before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ └── • Precedence dependency from ABSENT ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ rule: "dependents removed before column" + │ │ + │ ├── • ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 3} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ rule: "column no longer public before dependents" + │ │ + │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "PrimaryIndex transitions to ABSENT uphold 2-version invariant: DELETE_ONLY->ABSENT" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ rule: "dependents removed before index" + │ │ + │ ├── • IndexData:{DescID: 106, IndexID: 2} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ rule: "index removed before garbage collection" + │ │ + │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "TemporaryIndex transitions to ABSENT uphold 2-version invariant: DELETE_ONLY->ABSENT" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ rule: "dependents removed before index" + │ │ + │ └── • IndexData:{DescID: 106, IndexID: 3} + │ │ PUBLIC → ABSENT + │ │ + │ ├── • SameStagePrecedence dependency from DROPPED IndexData:{DescID: 106, IndexID: 2} + │ │ rule: "schedule all GC jobs for a descriptor in the same stage" + │ │ + │ └── • Precedence dependency from ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ rule: "index removed before garbage collection" + │ + └── • 7 Mutation operations + │ + ├── • MakeIndexAbsent + │ IndexID: 2 + │ TableID: 106 + │ + ├── • CreateGCJobForIndex + │ IndexID: 2 + │ StatementForDropJob: + │ Rollback: true + │ Statement: ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL AS (k) STORED + │ TableID: 106 + │ + ├── • MakeIndexAbsent + │ IndexID: 3 + │ TableID: 106 + │ + ├── • CreateGCJobForIndex + │ IndexID: 3 + │ StatementForDropJob: + │ Rollback: true + │ Statement: ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL AS (k) STORED + │ TableID: 106 + │ + ├── • MakeDeleteOnlyColumnAbsent + │ ColumnID: 3 + │ TableID: 106 + │ + ├── • RemoveJobStateFromDescriptor + │ DescriptorID: 106 + │ JobID: 1 + │ + └── • UpdateSchemaChangerJob + DescriptorIDsToRemove: + - 106 + IsNonCancelable: true + JobID: 1 + RunningStatus: all stages completed diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored.rollback_6_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored.rollback_6_of_7 new file mode 100644 index 000000000000..9c4e098e3fd3 --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored.rollback_6_of_7 @@ -0,0 +1,283 @@ +/* setup */ +CREATE DATABASE db; +CREATE TABLE db.public.tbl (i INT PRIMARY KEY, k INT); +CREATE SEQUENCE db.public.sq1; + +/* test */ +ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL AS (k) STORED; +EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 7; +---- +• Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD COLUMN ‹j› INT8 NOT NULL AS (‹k›) STORED; +│ +└── • PostCommitNonRevertiblePhase + │ + ├── • Stage 1 of 2 in PostCommitNonRevertiblePhase + │ │ + │ ├── • 11 elements transitioning toward ABSENT + │ │ │ + │ │ ├── • Column:{DescID: 106, ColumnID: 3} + │ │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ │ + │ │ │ ├── • PreviousStagePrecedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "Column transitions to ABSENT uphold 2-version invariant: WRITE_ONLY->DELETE_ONLY" + │ │ │ │ + │ │ │ └── • SameStagePrecedence dependency from ABSENT ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "column constraint removed right before column reaches delete only" + │ │ │ + │ │ ├── • ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ rule: "column no longer public before dependents" + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ MERGE_ONLY → DELETE_ONLY + │ │ │ │ + │ │ │ └── • PreviousStagePrecedence dependency from MERGE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "PrimaryIndex transitions to ABSENT uphold 2-version invariant: MERGE_ONLY->WRITE_ONLY" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ │ + │ │ │ └── • PreviousStagePrecedence dependency from WRITE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "TemporaryIndex transitions to ABSENT uphold 2-version invariant: WRITE_ONLY->DELETE_ONLY" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ └── • ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ WRITE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from WRITE_ONLY ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "ColumnNotNull transitions to ABSENT uphold 2-version invariant: WRITE_ONLY->VALIDATED" + │ │ │ + │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ rule: "column no longer public before dependents" + │ │ + │ └── • 13 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 3 + │ │ Name: crdb_internal_column_3_name_placeholder + │ │ TableID: 106 + │ │ + │ ├── • MakeWriteOnlyIndexDeleteOnly + │ │ IndexID: 3 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 1 + │ │ IndexID: 3 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 2 + │ │ IndexID: 3 + │ │ Kind: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 3 + │ │ IndexID: 3 + │ │ Kind: 2 + │ │ Ordinal: 1 + │ │ TableID: 106 + │ │ + │ ├── • MakeWriteOnlyIndexDeleteOnly + │ │ IndexID: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 1 + │ │ IndexID: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 2 + │ │ IndexID: 2 + │ │ Kind: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 3 + │ │ IndexID: 2 + │ │ Kind: 2 + │ │ Ordinal: 1 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnNotNull + │ │ ColumnID: 3 + │ │ TableID: 106 + │ │ + │ ├── • MakeWriteOnlyColumnDeleteOnly + │ │ ColumnID: 3 + │ │ TableID: 106 + │ │ + │ ├── • SetJobStateOnDescriptor + │ │ DescriptorID: 106 + │ │ + │ └── • UpdateSchemaChangerJob + │ IsNonCancelable: true + │ JobID: 1 + │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 2 with 5 MutationType ops pending + │ + └── • Stage 2 of 2 in PostCommitNonRevertiblePhase + │ + ├── • 6 elements transitioning toward ABSENT + │ │ + │ ├── • Column:{DescID: 106, ColumnID: 3} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ rule: "Column transitions to ABSENT uphold 2-version invariant: DELETE_ONLY->ABSENT" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • SameStagePrecedence dependency from ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ rule: "column type removed right before column when not dropping relation" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "indexes containing column reach absent before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ └── • Precedence dependency from ABSENT ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ rule: "dependents removed before column" + │ │ + │ ├── • ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 3} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ rule: "column no longer public before dependents" + │ │ + │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "PrimaryIndex transitions to ABSENT uphold 2-version invariant: DELETE_ONLY->ABSENT" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ rule: "dependents removed before index" + │ │ + │ ├── • IndexData:{DescID: 106, IndexID: 2} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ rule: "index removed before garbage collection" + │ │ + │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "TemporaryIndex transitions to ABSENT uphold 2-version invariant: DELETE_ONLY->ABSENT" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ rule: "dependents removed before index" + │ │ + │ └── • IndexData:{DescID: 106, IndexID: 3} + │ │ PUBLIC → ABSENT + │ │ + │ ├── • SameStagePrecedence dependency from DROPPED IndexData:{DescID: 106, IndexID: 2} + │ │ rule: "schedule all GC jobs for a descriptor in the same stage" + │ │ + │ └── • Precedence dependency from ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ rule: "index removed before garbage collection" + │ + └── • 7 Mutation operations + │ + ├── • MakeIndexAbsent + │ IndexID: 2 + │ TableID: 106 + │ + ├── • CreateGCJobForIndex + │ IndexID: 2 + │ StatementForDropJob: + │ Rollback: true + │ Statement: ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL AS (k) STORED + │ TableID: 106 + │ + ├── • MakeIndexAbsent + │ IndexID: 3 + │ TableID: 106 + │ + ├── • CreateGCJobForIndex + │ IndexID: 3 + │ StatementForDropJob: + │ Rollback: true + │ Statement: ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL AS (k) STORED + │ TableID: 106 + │ + ├── • MakeDeleteOnlyColumnAbsent + │ ColumnID: 3 + │ TableID: 106 + │ + ├── • RemoveJobStateFromDescriptor + │ DescriptorID: 106 + │ JobID: 1 + │ + └── • UpdateSchemaChangerJob + DescriptorIDsToRemove: + - 106 + IsNonCancelable: true + JobID: 1 + RunningStatus: all stages completed diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored.rollback_7_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored.rollback_7_of_7 new file mode 100644 index 000000000000..62990e923aab --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored.rollback_7_of_7 @@ -0,0 +1,283 @@ +/* setup */ +CREATE DATABASE db; +CREATE TABLE db.public.tbl (i INT PRIMARY KEY, k INT); +CREATE SEQUENCE db.public.sq1; + +/* test */ +ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL AS (k) STORED; +EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; +---- +• Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD COLUMN ‹j› INT8 NOT NULL AS (‹k›) STORED; +│ +└── • PostCommitNonRevertiblePhase + │ + ├── • Stage 1 of 2 in PostCommitNonRevertiblePhase + │ │ + │ ├── • 11 elements transitioning toward ABSENT + │ │ │ + │ │ ├── • Column:{DescID: 106, ColumnID: 3} + │ │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ │ + │ │ │ ├── • PreviousStagePrecedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "Column transitions to ABSENT uphold 2-version invariant: WRITE_ONLY->DELETE_ONLY" + │ │ │ │ + │ │ │ └── • SameStagePrecedence dependency from ABSENT ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "column constraint removed right before column reaches delete only" + │ │ │ + │ │ ├── • ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ rule: "column no longer public before dependents" + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ │ + │ │ │ └── • PreviousStagePrecedence dependency from WRITE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "PrimaryIndex transitions to ABSENT uphold 2-version invariant: WRITE_ONLY->DELETE_ONLY" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ │ + │ │ │ └── • PreviousStagePrecedence dependency from WRITE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "TemporaryIndex transitions to ABSENT uphold 2-version invariant: WRITE_ONLY->DELETE_ONLY" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ └── • ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ WRITE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from WRITE_ONLY ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "ColumnNotNull transitions to ABSENT uphold 2-version invariant: WRITE_ONLY->VALIDATED" + │ │ │ + │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ rule: "column no longer public before dependents" + │ │ + │ └── • 13 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 3 + │ │ Name: crdb_internal_column_3_name_placeholder + │ │ TableID: 106 + │ │ + │ ├── • MakeWriteOnlyIndexDeleteOnly + │ │ IndexID: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 1 + │ │ IndexID: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 2 + │ │ IndexID: 2 + │ │ Kind: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 3 + │ │ IndexID: 2 + │ │ Kind: 2 + │ │ Ordinal: 1 + │ │ TableID: 106 + │ │ + │ ├── • MakeWriteOnlyIndexDeleteOnly + │ │ IndexID: 3 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 1 + │ │ IndexID: 3 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 2 + │ │ IndexID: 3 + │ │ Kind: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 3 + │ │ IndexID: 3 + │ │ Kind: 2 + │ │ Ordinal: 1 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnNotNull + │ │ ColumnID: 3 + │ │ TableID: 106 + │ │ + │ ├── • MakeWriteOnlyColumnDeleteOnly + │ │ ColumnID: 3 + │ │ TableID: 106 + │ │ + │ ├── • SetJobStateOnDescriptor + │ │ DescriptorID: 106 + │ │ + │ └── • UpdateSchemaChangerJob + │ IsNonCancelable: true + │ JobID: 1 + │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 2 with 5 MutationType ops pending + │ + └── • Stage 2 of 2 in PostCommitNonRevertiblePhase + │ + ├── • 6 elements transitioning toward ABSENT + │ │ + │ ├── • Column:{DescID: 106, ColumnID: 3} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ rule: "Column transitions to ABSENT uphold 2-version invariant: DELETE_ONLY->ABSENT" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • SameStagePrecedence dependency from ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ rule: "column type removed right before column when not dropping relation" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "indexes containing column reach absent before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ └── • Precedence dependency from ABSENT ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ rule: "dependents removed before column" + │ │ + │ ├── • ColumnType:{DescID: 106, ColumnFamilyID: 0, ColumnID: 3} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ rule: "column no longer public before dependents" + │ │ + │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "PrimaryIndex transitions to ABSENT uphold 2-version invariant: DELETE_ONLY->ABSENT" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ rule: "dependents removed before index" + │ │ + │ ├── • IndexData:{DescID: 106, IndexID: 2} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ rule: "index removed before garbage collection" + │ │ + │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "TemporaryIndex transitions to ABSENT uphold 2-version invariant: DELETE_ONLY->ABSENT" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ rule: "dependents removed before index" + │ │ + │ └── • IndexData:{DescID: 106, IndexID: 3} + │ │ PUBLIC → ABSENT + │ │ + │ ├── • SameStagePrecedence dependency from DROPPED IndexData:{DescID: 106, IndexID: 2} + │ │ rule: "schedule all GC jobs for a descriptor in the same stage" + │ │ + │ └── • Precedence dependency from ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ rule: "index removed before garbage collection" + │ + └── • 7 Mutation operations + │ + ├── • MakeIndexAbsent + │ IndexID: 2 + │ TableID: 106 + │ + ├── • CreateGCJobForIndex + │ IndexID: 2 + │ StatementForDropJob: + │ Rollback: true + │ Statement: ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL AS (k) STORED + │ TableID: 106 + │ + ├── • MakeIndexAbsent + │ IndexID: 3 + │ TableID: 106 + │ + ├── • CreateGCJobForIndex + │ IndexID: 3 + │ StatementForDropJob: + │ Rollback: true + │ Statement: ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL AS (k) STORED + │ TableID: 106 + │ + ├── • MakeDeleteOnlyColumnAbsent + │ ColumnID: 3 + │ TableID: 106 + │ + ├── • RemoveJobStateFromDescriptor + │ DescriptorID: 106 + │ JobID: 1 + │ + └── • UpdateSchemaChangerJob + DescriptorIDsToRemove: + - 106 + IsNonCancelable: true + JobID: 1 + RunningStatus: all stages completed diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored_family b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored_family new file mode 100644 index 000000000000..efc37195ea52 --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored_family @@ -0,0 +1,971 @@ +/* setup */ +CREATE DATABASE db; +CREATE TABLE db.public.tbl (i INT PRIMARY KEY, k INT); +CREATE SEQUENCE db.public.sq1; + +/* test */ +EXPLAIN (ddl, verbose) ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL AS (k) STORED CREATE FAMILY bob; +---- +• Schema change plan for ALTER TABLE ‹db›.‹public›.‹tbl› ADD COLUMN ‹j› INT8 NOT NULL AS (‹k›) STORED CREATE FAMILY ‹bob›; +│ +├── • StatementPhase +│ │ +│ └── • Stage 1 of 1 in StatementPhase +│ │ +│ ├── • 9 elements transitioning toward PUBLIC +│ │ │ +│ │ ├── • Column:{DescID: 106, ColumnID: 3} +│ │ │ │ ABSENT → DELETE_ONLY +│ │ │ │ +│ │ │ └── • PreviousStagePrecedence dependency from ABSENT Column:{DescID: 106, ColumnID: 3} +│ │ │ rule: "Column transitions to PUBLIC uphold 2-version invariant: ABSENT->DELETE_ONLY" +│ │ │ +│ │ ├── • ColumnFamily:{DescID: 106, Name: bob, ColumnFamilyID: 1} +│ │ │ ABSENT → PUBLIC +│ │ │ +│ │ ├── • ColumnName:{DescID: 106, Name: j, ColumnID: 3} +│ │ │ │ ABSENT → PUBLIC +│ │ │ │ +│ │ │ └── • SameStagePrecedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} +│ │ │ rule: "column existence precedes column dependents" +│ │ │ rule: "column name and type set right after column existence" +│ │ │ +│ │ ├── • ColumnType:{DescID: 106, ColumnFamilyID: 1, ColumnID: 3} +│ │ │ │ ABSENT → PUBLIC +│ │ │ │ +│ │ │ └── • SameStagePrecedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} +│ │ │ rule: "column existence precedes column dependents" +│ │ │ rule: "column name and type set right after column existence" +│ │ │ +│ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ │ ABSENT → BACKFILL_ONLY +│ │ │ │ +│ │ │ ├── • Precedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} +│ │ │ │ rule: "column existence precedes index existence" +│ │ │ │ +│ │ │ └── • PreviousStagePrecedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ rule: "PrimaryIndex transitions to PUBLIC uphold 2-version invariant: ABSENT->BACKFILL_ONLY" +│ │ │ +│ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} +│ │ │ │ ABSENT → PUBLIC +│ │ │ │ +│ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ rule: "index existence precedes index dependents" +│ │ │ +│ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} +│ │ │ │ ABSENT → PUBLIC +│ │ │ │ +│ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ rule: "index existence precedes index dependents" +│ │ │ +│ │ ├── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} +│ │ │ │ ABSENT → PUBLIC +│ │ │ │ +│ │ │ ├── • Precedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} +│ │ │ │ rule: "column existence precedes column dependents" +│ │ │ │ +│ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ rule: "index existence precedes index dependents" +│ │ │ +│ │ └── • IndexData:{DescID: 106, IndexID: 2} +│ │ │ ABSENT → PUBLIC +│ │ │ +│ │ └── • SameStagePrecedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ rule: "index data exists as soon as index accepts backfills" +│ │ +│ ├── • 4 elements transitioning toward TRANSIENT_ABSENT +│ │ │ +│ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} +│ │ │ │ ABSENT → DELETE_ONLY +│ │ │ │ +│ │ │ ├── • Precedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} +│ │ │ │ rule: "column existence precedes temp index existence" +│ │ │ │ +│ │ │ └── • PreviousStagePrecedence dependency from ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} +│ │ │ rule: "TemporaryIndex transitions to TRANSIENT_ABSENT uphold 2-version invariant: ABSENT->DELETE_ONLY" +│ │ │ +│ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} +│ │ │ │ ABSENT → PUBLIC +│ │ │ │ +│ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} +│ │ │ rule: "temp index existence precedes index dependents" +│ │ │ +│ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} +│ │ │ │ ABSENT → PUBLIC +│ │ │ │ +│ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} +│ │ │ rule: "temp index existence precedes index dependents" +│ │ │ +│ │ └── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} +│ │ │ ABSENT → PUBLIC +│ │ │ +│ │ ├── • Precedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} +│ │ │ rule: "column existence precedes column dependents" +│ │ │ +│ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} +│ │ rule: "temp index existence precedes index dependents" +│ │ +│ └── • 12 Mutation operations +│ │ +│ ├── • MakeAbsentColumnDeleteOnly +│ │ Column: +│ │ ColumnID: 3 +│ │ PgAttributeNum: 3 +│ │ TableID: 106 +│ │ +│ ├── • AddColumnFamily +│ │ FamilyID: 1 +│ │ Name: bob +│ │ TableID: 106 +│ │ +│ ├── • SetColumnName +│ │ ColumnID: 3 +│ │ Name: j +│ │ TableID: 106 +│ │ +│ ├── • SetAddedColumnType +│ │ ColumnType: +│ │ ColumnID: 3 +│ │ ComputeExpr: +│ │ expr: k +│ │ referencedColumnIds: +│ │ - 2 +│ │ ElementCreationMetadata: +│ │ in231OrLater: true +│ │ FamilyID: 1 +│ │ TableID: 106 +│ │ TypeT: +│ │ Type: +│ │ family: IntFamily +│ │ oid: 20 +│ │ width: 64 +│ │ +│ ├── • MakeAbsentIndexBackfilling +│ │ Index: +│ │ ConstraintID: 2 +│ │ IndexID: 2 +│ │ IsUnique: true +│ │ SourceIndexID: 1 +│ │ TableID: 106 +│ │ TemporaryIndexID: 3 +│ │ +│ ├── • AddColumnToIndex +│ │ ColumnID: 1 +│ │ IndexID: 2 +│ │ TableID: 106 +│ │ +│ ├── • AddColumnToIndex +│ │ ColumnID: 2 +│ │ IndexID: 2 +│ │ Kind: 2 +│ │ TableID: 106 +│ │ +│ ├── • AddColumnToIndex +│ │ ColumnID: 3 +│ │ IndexID: 2 +│ │ Kind: 2 +│ │ Ordinal: 1 +│ │ TableID: 106 +│ │ +│ ├── • MakeAbsentTempIndexDeleteOnly +│ │ Index: +│ │ ConstraintID: 3 +│ │ IndexID: 3 +│ │ IsUnique: true +│ │ SourceIndexID: 1 +│ │ TableID: 106 +│ │ +│ ├── • AddColumnToIndex +│ │ ColumnID: 1 +│ │ IndexID: 3 +│ │ TableID: 106 +│ │ +│ ├── • AddColumnToIndex +│ │ ColumnID: 2 +│ │ IndexID: 3 +│ │ Kind: 2 +│ │ TableID: 106 +│ │ +│ └── • AddColumnToIndex +│ ColumnID: 3 +│ IndexID: 3 +│ Kind: 2 +│ Ordinal: 1 +│ TableID: 106 +│ +├── • PreCommitPhase +│ │ +│ ├── • Stage 1 of 2 in PreCommitPhase +│ │ │ +│ │ ├── • 9 elements transitioning toward PUBLIC +│ │ │ │ +│ │ │ ├── • Column:{DescID: 106, ColumnID: 3} +│ │ │ │ DELETE_ONLY → ABSENT +│ │ │ │ +│ │ │ ├── • ColumnFamily:{DescID: 106, Name: bob, ColumnFamilyID: 1} +│ │ │ │ PUBLIC → ABSENT +│ │ │ │ +│ │ │ ├── • ColumnName:{DescID: 106, Name: j, ColumnID: 3} +│ │ │ │ PUBLIC → ABSENT +│ │ │ │ +│ │ │ ├── • ColumnType:{DescID: 106, ColumnFamilyID: 1, ColumnID: 3} +│ │ │ │ PUBLIC → ABSENT +│ │ │ │ +│ │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ │ BACKFILL_ONLY → ABSENT +│ │ │ │ +│ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} +│ │ │ │ PUBLIC → ABSENT +│ │ │ │ +│ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} +│ │ │ │ PUBLIC → ABSENT +│ │ │ │ +│ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} +│ │ │ │ PUBLIC → ABSENT +│ │ │ │ +│ │ │ └── • IndexData:{DescID: 106, IndexID: 2} +│ │ │ PUBLIC → ABSENT +│ │ │ +│ │ ├── • 4 elements transitioning toward TRANSIENT_ABSENT +│ │ │ │ +│ │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} +│ │ │ │ DELETE_ONLY → ABSENT +│ │ │ │ +│ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} +│ │ │ │ PUBLIC → ABSENT +│ │ │ │ +│ │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} +│ │ │ │ PUBLIC → ABSENT +│ │ │ │ +│ │ │ └── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} +│ │ │ PUBLIC → ABSENT +│ │ │ +│ │ └── • 1 Mutation operation +│ │ │ +│ │ └── • UndoAllInTxnImmediateMutationOpSideEffects +│ │ {} +│ │ +│ └── • Stage 2 of 2 in PreCommitPhase +│ │ +│ ├── • 9 elements transitioning toward PUBLIC +│ │ │ +│ │ ├── • Column:{DescID: 106, ColumnID: 3} +│ │ │ │ ABSENT → DELETE_ONLY +│ │ │ │ +│ │ │ └── • PreviousStagePrecedence dependency from ABSENT Column:{DescID: 106, ColumnID: 3} +│ │ │ rule: "Column transitions to PUBLIC uphold 2-version invariant: ABSENT->DELETE_ONLY" +│ │ │ +│ │ ├── • ColumnFamily:{DescID: 106, Name: bob, ColumnFamilyID: 1} +│ │ │ ABSENT → PUBLIC +│ │ │ +│ │ ├── • ColumnName:{DescID: 106, Name: j, ColumnID: 3} +│ │ │ │ ABSENT → PUBLIC +│ │ │ │ +│ │ │ └── • SameStagePrecedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} +│ │ │ rule: "column existence precedes column dependents" +│ │ │ rule: "column name and type set right after column existence" +│ │ │ +│ │ ├── • ColumnType:{DescID: 106, ColumnFamilyID: 1, ColumnID: 3} +│ │ │ │ ABSENT → PUBLIC +│ │ │ │ +│ │ │ └── • SameStagePrecedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} +│ │ │ rule: "column existence precedes column dependents" +│ │ │ rule: "column name and type set right after column existence" +│ │ │ +│ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ │ ABSENT → BACKFILL_ONLY +│ │ │ │ +│ │ │ ├── • Precedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} +│ │ │ │ rule: "column existence precedes index existence" +│ │ │ │ +│ │ │ └── • PreviousStagePrecedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ rule: "PrimaryIndex transitions to PUBLIC uphold 2-version invariant: ABSENT->BACKFILL_ONLY" +│ │ │ +│ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} +│ │ │ │ ABSENT → PUBLIC +│ │ │ │ +│ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ rule: "index existence precedes index dependents" +│ │ │ +│ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} +│ │ │ │ ABSENT → PUBLIC +│ │ │ │ +│ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ rule: "index existence precedes index dependents" +│ │ │ +│ │ ├── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} +│ │ │ │ ABSENT → PUBLIC +│ │ │ │ +│ │ │ ├── • Precedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} +│ │ │ │ rule: "column existence precedes column dependents" +│ │ │ │ +│ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ rule: "index existence precedes index dependents" +│ │ │ +│ │ └── • IndexData:{DescID: 106, IndexID: 2} +│ │ │ ABSENT → PUBLIC +│ │ │ +│ │ └── • SameStagePrecedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ rule: "index data exists as soon as index accepts backfills" +│ │ +│ ├── • 4 elements transitioning toward TRANSIENT_ABSENT +│ │ │ +│ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} +│ │ │ │ ABSENT → DELETE_ONLY +│ │ │ │ +│ │ │ ├── • Precedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} +│ │ │ │ rule: "column existence precedes temp index existence" +│ │ │ │ +│ │ │ └── • PreviousStagePrecedence dependency from ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} +│ │ │ rule: "TemporaryIndex transitions to TRANSIENT_ABSENT uphold 2-version invariant: ABSENT->DELETE_ONLY" +│ │ │ +│ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} +│ │ │ │ ABSENT → PUBLIC +│ │ │ │ +│ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} +│ │ │ rule: "temp index existence precedes index dependents" +│ │ │ +│ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} +│ │ │ │ ABSENT → PUBLIC +│ │ │ │ +│ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} +│ │ │ rule: "temp index existence precedes index dependents" +│ │ │ +│ │ └── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} +│ │ │ ABSENT → PUBLIC +│ │ │ +│ │ ├── • Precedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} +│ │ │ rule: "column existence precedes column dependents" +│ │ │ +│ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} +│ │ rule: "temp index existence precedes index dependents" +│ │ +│ └── • 16 Mutation operations +│ │ +│ ├── • MakeAbsentColumnDeleteOnly +│ │ Column: +│ │ ColumnID: 3 +│ │ PgAttributeNum: 3 +│ │ TableID: 106 +│ │ +│ ├── • AddColumnFamily +│ │ FamilyID: 1 +│ │ Name: bob +│ │ TableID: 106 +│ │ +│ ├── • SetColumnName +│ │ ColumnID: 3 +│ │ Name: j +│ │ TableID: 106 +│ │ +│ ├── • SetAddedColumnType +│ │ ColumnType: +│ │ ColumnID: 3 +│ │ ComputeExpr: +│ │ expr: k +│ │ referencedColumnIds: +│ │ - 2 +│ │ ElementCreationMetadata: +│ │ in231OrLater: true +│ │ FamilyID: 1 +│ │ TableID: 106 +│ │ TypeT: +│ │ Type: +│ │ family: IntFamily +│ │ oid: 20 +│ │ width: 64 +│ │ +│ ├── • MakeAbsentIndexBackfilling +│ │ Index: +│ │ ConstraintID: 2 +│ │ IndexID: 2 +│ │ IsUnique: true +│ │ SourceIndexID: 1 +│ │ TableID: 106 +│ │ TemporaryIndexID: 3 +│ │ +│ ├── • MaybeAddSplitForIndex +│ │ IndexID: 2 +│ │ TableID: 106 +│ │ +│ ├── • AddColumnToIndex +│ │ ColumnID: 1 +│ │ IndexID: 2 +│ │ TableID: 106 +│ │ +│ ├── • AddColumnToIndex +│ │ ColumnID: 2 +│ │ IndexID: 2 +│ │ Kind: 2 +│ │ TableID: 106 +│ │ +│ ├── • AddColumnToIndex +│ │ ColumnID: 3 +│ │ IndexID: 2 +│ │ Kind: 2 +│ │ Ordinal: 1 +│ │ TableID: 106 +│ │ +│ ├── • MakeAbsentTempIndexDeleteOnly +│ │ Index: +│ │ ConstraintID: 3 +│ │ IndexID: 3 +│ │ IsUnique: true +│ │ SourceIndexID: 1 +│ │ TableID: 106 +│ │ +│ ├── • MaybeAddSplitForIndex +│ │ IndexID: 3 +│ │ TableID: 106 +│ │ +│ ├── • AddColumnToIndex +│ │ ColumnID: 1 +│ │ IndexID: 3 +│ │ TableID: 106 +│ │ +│ ├── • AddColumnToIndex +│ │ ColumnID: 2 +│ │ IndexID: 3 +│ │ Kind: 2 +│ │ TableID: 106 +│ │ +│ ├── • AddColumnToIndex +│ │ ColumnID: 3 +│ │ IndexID: 3 +│ │ Kind: 2 +│ │ Ordinal: 1 +│ │ TableID: 106 +│ │ +│ ├── • SetJobStateOnDescriptor +│ │ DescriptorID: 106 +│ │ Initialize: true +│ │ +│ └── • CreateSchemaChangerJob +│ Authorization: +│ UserName: root +│ DescriptorIDs: +│ - 106 +│ JobID: 1 +│ RunningStatus: PostCommitPhase stage 1 of 7 with 3 MutationType ops pending +│ Statements: +│ - statement: ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL AS (k) STORED CREATE +│ FAMILY bob +│ redactedstatement: ALTER TABLE ‹db›.‹public›.‹tbl› ADD COLUMN ‹j› INT8 NOT NULL +│ AS (‹k›) STORED CREATE FAMILY ‹bob› +│ statementtag: ALTER TABLE +│ +├── • PostCommitPhase +│ │ +│ ├── • Stage 1 of 7 in PostCommitPhase +│ │ │ +│ │ ├── • 2 elements transitioning toward PUBLIC +│ │ │ │ +│ │ │ ├── • Column:{DescID: 106, ColumnID: 3} +│ │ │ │ │ DELETE_ONLY → WRITE_ONLY +│ │ │ │ │ +│ │ │ │ └── • PreviousStagePrecedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} +│ │ │ │ rule: "Column transitions to PUBLIC uphold 2-version invariant: DELETE_ONLY->WRITE_ONLY" +│ │ │ │ +│ │ │ └── • ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} +│ │ │ │ ABSENT → WRITE_ONLY +│ │ │ │ +│ │ │ ├── • SameStagePrecedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} +│ │ │ │ rule: "column writable right before column constraint is enforced." +│ │ │ │ +│ │ │ └── • PreviousStagePrecedence dependency from ABSENT ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} +│ │ │ rule: "ColumnNotNull transitions to PUBLIC uphold 2-version invariant: ABSENT->WRITE_ONLY" +│ │ │ +│ │ ├── • 2 elements transitioning toward TRANSIENT_ABSENT +│ │ │ │ +│ │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} +│ │ │ │ │ DELETE_ONLY → WRITE_ONLY +│ │ │ │ │ +│ │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} +│ │ │ │ │ rule: "column is WRITE_ONLY before temporary index is WRITE_ONLY" +│ │ │ │ │ +│ │ │ │ ├── • PreviousStagePrecedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} +│ │ │ │ │ rule: "TemporaryIndex transitions to TRANSIENT_ABSENT uphold 2-version invariant: DELETE_ONLY->WRITE_ONLY" +│ │ │ │ │ +│ │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} +│ │ │ │ │ rule: "index-column added to index before temp index receives writes" +│ │ │ │ │ +│ │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} +│ │ │ │ │ rule: "index-column added to index before temp index receives writes" +│ │ │ │ │ +│ │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} +│ │ │ │ rule: "index-column added to index before temp index receives writes" +│ │ │ │ +│ │ │ └── • IndexData:{DescID: 106, IndexID: 3} +│ │ │ │ ABSENT → PUBLIC +│ │ │ │ +│ │ │ └── • SameStagePrecedence dependency from WRITE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} +│ │ │ rule: "temp index data exists as soon as temp index accepts writes" +│ │ │ +│ │ └── • 5 Mutation operations +│ │ │ +│ │ ├── • MakeDeleteOnlyColumnWriteOnly +│ │ │ ColumnID: 3 +│ │ │ TableID: 106 +│ │ │ +│ │ ├── • MakeDeleteOnlyIndexWriteOnly +│ │ │ IndexID: 3 +│ │ │ TableID: 106 +│ │ │ +│ │ ├── • MakeAbsentColumnNotNullWriteOnly +│ │ │ ColumnID: 3 +│ │ │ TableID: 106 +│ │ │ +│ │ ├── • SetJobStateOnDescriptor +│ │ │ DescriptorID: 106 +│ │ │ +│ │ └── • UpdateSchemaChangerJob +│ │ JobID: 1 +│ │ RunningStatus: PostCommitPhase stage 2 of 7 with 1 BackfillType op pending +│ │ +│ ├── • Stage 2 of 7 in PostCommitPhase +│ │ │ +│ │ ├── • 1 element transitioning toward PUBLIC +│ │ │ │ +│ │ │ └── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ │ BACKFILL_ONLY → BACKFILLED +│ │ │ │ +│ │ │ ├── • PreviousStagePrecedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ │ rule: "PrimaryIndex transitions to PUBLIC uphold 2-version invariant: BACKFILL_ONLY->BACKFILLED" +│ │ │ │ +│ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} +│ │ │ │ rule: "index-column added to index before index is backfilled" +│ │ │ │ +│ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} +│ │ │ │ rule: "index-column added to index before index is backfilled" +│ │ │ │ +│ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} +│ │ │ │ rule: "index-column added to index before index is backfilled" +│ │ │ │ +│ │ │ └── • Precedence dependency from WRITE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} +│ │ │ rule: "temp index is WRITE_ONLY before backfill" +│ │ │ +│ │ └── • 1 Backfill operation +│ │ │ +│ │ └── • BackfillIndex +│ │ IndexID: 2 +│ │ SourceIndexID: 1 +│ │ TableID: 106 +│ │ +│ ├── • Stage 3 of 7 in PostCommitPhase +│ │ │ +│ │ ├── • 1 element transitioning toward PUBLIC +│ │ │ │ +│ │ │ └── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ │ BACKFILLED → DELETE_ONLY +│ │ │ │ +│ │ │ └── • PreviousStagePrecedence dependency from BACKFILLED PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ rule: "PrimaryIndex transitions to PUBLIC uphold 2-version invariant: BACKFILLED->DELETE_ONLY" +│ │ │ +│ │ └── • 3 Mutation operations +│ │ │ +│ │ ├── • MakeBackfillingIndexDeleteOnly +│ │ │ IndexID: 2 +│ │ │ TableID: 106 +│ │ │ +│ │ ├── • SetJobStateOnDescriptor +│ │ │ DescriptorID: 106 +│ │ │ +│ │ └── • UpdateSchemaChangerJob +│ │ JobID: 1 +│ │ RunningStatus: PostCommitPhase stage 4 of 7 with 1 MutationType op pending +│ │ +│ ├── • Stage 4 of 7 in PostCommitPhase +│ │ │ +│ │ ├── • 1 element transitioning toward PUBLIC +│ │ │ │ +│ │ │ └── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ │ DELETE_ONLY → MERGE_ONLY +│ │ │ │ +│ │ │ └── • PreviousStagePrecedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ rule: "PrimaryIndex transitions to PUBLIC uphold 2-version invariant: DELETE_ONLY->MERGE_ONLY" +│ │ │ +│ │ └── • 3 Mutation operations +│ │ │ +│ │ ├── • MakeBackfilledIndexMerging +│ │ │ IndexID: 2 +│ │ │ TableID: 106 +│ │ │ +│ │ ├── • SetJobStateOnDescriptor +│ │ │ DescriptorID: 106 +│ │ │ +│ │ └── • UpdateSchemaChangerJob +│ │ JobID: 1 +│ │ RunningStatus: PostCommitPhase stage 5 of 7 with 1 BackfillType op pending +│ │ +│ ├── • Stage 5 of 7 in PostCommitPhase +│ │ │ +│ │ ├── • 1 element transitioning toward PUBLIC +│ │ │ │ +│ │ │ └── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ │ MERGE_ONLY → MERGED +│ │ │ │ +│ │ │ └── • PreviousStagePrecedence dependency from MERGE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ rule: "PrimaryIndex transitions to PUBLIC uphold 2-version invariant: MERGE_ONLY->MERGED" +│ │ │ +│ │ └── • 1 Backfill operation +│ │ │ +│ │ └── • MergeIndex +│ │ BackfilledIndexID: 2 +│ │ TableID: 106 +│ │ TemporaryIndexID: 3 +│ │ +│ ├── • Stage 6 of 7 in PostCommitPhase +│ │ │ +│ │ ├── • 1 element transitioning toward PUBLIC +│ │ │ │ +│ │ │ └── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ │ MERGED → WRITE_ONLY +│ │ │ │ +│ │ │ └── • PreviousStagePrecedence dependency from MERGED PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ rule: "PrimaryIndex transitions to PUBLIC uphold 2-version invariant: MERGED->WRITE_ONLY" +│ │ │ +│ │ └── • 3 Mutation operations +│ │ │ +│ │ ├── • MakeMergedIndexWriteOnly +│ │ │ IndexID: 2 +│ │ │ TableID: 106 +│ │ │ +│ │ ├── • SetJobStateOnDescriptor +│ │ │ DescriptorID: 106 +│ │ │ +│ │ └── • UpdateSchemaChangerJob +│ │ JobID: 1 +│ │ RunningStatus: PostCommitPhase stage 7 of 7 with 2 ValidationType ops pending +│ │ +│ └── • Stage 7 of 7 in PostCommitPhase +│ │ +│ ├── • 2 elements transitioning toward PUBLIC +│ │ │ +│ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ │ WRITE_ONLY → VALIDATED +│ │ │ │ +│ │ │ └── • PreviousStagePrecedence dependency from WRITE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ rule: "PrimaryIndex transitions to PUBLIC uphold 2-version invariant: WRITE_ONLY->VALIDATED" +│ │ │ +│ │ └── • ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} +│ │ │ WRITE_ONLY → VALIDATED +│ │ │ +│ │ ├── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} +│ │ │ rule: "index is ready to be validated before we validate constraint on it" +│ │ │ +│ │ └── • PreviousStagePrecedence dependency from WRITE_ONLY ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} +│ │ rule: "ColumnNotNull transitions to PUBLIC uphold 2-version invariant: WRITE_ONLY->VALIDATED" +│ │ +│ └── • 2 Validation operations +│ │ +│ ├── • ValidateIndex +│ │ IndexID: 2 +│ │ TableID: 106 +│ │ +│ └── • ValidateColumnNotNull +│ ColumnID: 3 +│ IndexIDForValidation: 2 +│ TableID: 106 +│ +└── • PostCommitNonRevertiblePhase + │ + ├── • Stage 1 of 3 in PostCommitNonRevertiblePhase + │ │ + │ ├── • 4 elements transitioning toward PUBLIC + │ │ │ + │ │ ├── • Column:{DescID: 106, ColumnID: 3} + │ │ │ │ WRITE_ONLY → PUBLIC + │ │ │ │ + │ │ │ ├── • PreviousStagePrecedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "Column transitions to PUBLIC uphold 2-version invariant: WRITE_ONLY->PUBLIC" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC ColumnType:{DescID: 106, ColumnFamilyID: 1, ColumnID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ rule: "swapped primary index public before column" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "column dependents exist before column becomes public" + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ VALIDATED → PUBLIC + │ │ │ │ + │ │ │ ├── • SameStagePrecedence dependency from VALIDATED PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} + │ │ │ │ rule: "primary index swap" + │ │ │ │ + │ │ │ ├── • PreviousStagePrecedence dependency from VALIDATED PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ rule: "PrimaryIndex transitions to PUBLIC uphold 2-version invariant: VALIDATED->PUBLIC" + │ │ │ │ + │ │ │ ├── • SameStagePrecedence dependency from PUBLIC IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ rule: "primary index named right before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ ├── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ │ + │ │ │ └── • Precedence dependency from PUBLIC IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "index dependents exist before index becomes public" + │ │ │ + │ │ ├── • IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} + │ │ │ │ ABSENT → PUBLIC + │ │ │ │ + │ │ │ └── • Precedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index existence precedes index dependents" + │ │ │ + │ │ └── • ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ VALIDATED → PUBLIC + │ │ │ + │ │ ├── • Precedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ rule: "column existence precedes column dependents" + │ │ │ + │ │ └── • PreviousStagePrecedence dependency from VALIDATED ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ rule: "ColumnNotNull transitions to PUBLIC uphold 2-version invariant: VALIDATED->PUBLIC" + │ │ + │ ├── • 4 elements transitioning toward TRANSIENT_ABSENT + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ │ WRITE_ONLY → TRANSIENT_DELETE_ONLY + │ │ │ │ + │ │ │ └── • PreviousStagePrecedence dependency from WRITE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "TemporaryIndex transitions to TRANSIENT_ABSENT uphold 2-version invariant: WRITE_ONLY->TRANSIENT_DELETE_ONLY" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → TRANSIENT_ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from TRANSIENT_DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ │ │ PUBLIC → TRANSIENT_ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from TRANSIENT_DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ └── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ │ PUBLIC → TRANSIENT_ABSENT + │ │ │ + │ │ └── • Precedence dependency from TRANSIENT_DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ + │ ├── • 2 elements transitioning toward ABSENT + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} + │ │ │ │ PUBLIC → VALIDATED + │ │ │ │ + │ │ │ └── • PreviousStagePrecedence dependency from PUBLIC PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} + │ │ │ rule: "PrimaryIndex transitions to ABSENT uphold 2-version invariant: PUBLIC->VALIDATED" + │ │ │ + │ │ └── • IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 1} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from VALIDATED PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} + │ │ rule: "index no longer public before dependents, excluding columns" + │ │ + │ └── • 13 Mutation operations + │ │ + │ ├── • MakePublicPrimaryIndexWriteOnly + │ │ IndexID: 1 + │ │ TableID: 106 + │ │ + │ ├── • SetIndexName + │ │ IndexID: 1 + │ │ Name: crdb_internal_index_1_name_placeholder + │ │ TableID: 106 + │ │ + │ ├── • SetIndexName + │ │ IndexID: 2 + │ │ Name: tbl_pkey + │ │ TableID: 106 + │ │ + │ ├── • MakeWriteOnlyIndexDeleteOnly + │ │ IndexID: 3 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 1 + │ │ IndexID: 3 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 2 + │ │ IndexID: 3 + │ │ Kind: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 3 + │ │ IndexID: 3 + │ │ Kind: 2 + │ │ Ordinal: 1 + │ │ TableID: 106 + │ │ + │ ├── • MakeValidatedColumnNotNullPublic + │ │ ColumnID: 3 + │ │ TableID: 106 + │ │ + │ ├── • MakeValidatedPrimaryIndexPublic + │ │ IndexID: 2 + │ │ TableID: 106 + │ │ + │ ├── • MakeWriteOnlyColumnPublic + │ │ ColumnID: 3 + │ │ TableID: 106 + │ │ + │ ├── • RefreshStats + │ │ TableID: 106 + │ │ + │ ├── • SetJobStateOnDescriptor + │ │ DescriptorID: 106 + │ │ + │ └── • UpdateSchemaChangerJob + │ IsNonCancelable: true + │ JobID: 1 + │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 3 with 4 MutationType ops pending + │ + ├── • Stage 2 of 3 in PostCommitNonRevertiblePhase + │ │ + │ ├── • 1 element transitioning toward TRANSIENT_ABSENT + │ │ │ + │ │ └── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ TRANSIENT_DELETE_ONLY → TRANSIENT_ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from TRANSIENT_DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "TemporaryIndex transitions to TRANSIENT_ABSENT uphold 2-version invariant: TRANSIENT_DELETE_ONLY->TRANSIENT_ABSENT" + │ │ │ + │ │ ├── • Precedence dependency from TRANSIENT_ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from TRANSIENT_ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from TRANSIENT_ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ rule: "dependents removed before index" + │ │ + │ ├── • 3 elements transitioning toward ABSENT + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 1} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 1} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ └── • PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} + │ │ │ VALIDATED → DELETE_ONLY + │ │ │ + │ │ └── • PreviousStagePrecedence dependency from VALIDATED PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} + │ │ rule: "PrimaryIndex transitions to ABSENT uphold 2-version invariant: VALIDATED->WRITE_ONLY" + │ │ + │ └── • 6 Mutation operations + │ │ + │ ├── • MakeIndexAbsent + │ │ IndexID: 3 + │ │ TableID: 106 + │ │ + │ ├── • MakeWriteOnlyIndexDeleteOnly + │ │ IndexID: 1 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 1 + │ │ IndexID: 1 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 2 + │ │ IndexID: 1 + │ │ Kind: 2 + │ │ TableID: 106 + │ │ + │ ├── • SetJobStateOnDescriptor + │ │ DescriptorID: 106 + │ │ + │ └── • UpdateSchemaChangerJob + │ IsNonCancelable: true + │ JobID: 1 + │ RunningStatus: PostCommitNonRevertiblePhase stage 3 of 3 with 3 MutationType ops pending + │ + └── • Stage 3 of 3 in PostCommitNonRevertiblePhase + │ + ├── • 1 element transitioning toward TRANSIENT_ABSENT + │ │ + │ └── • IndexData:{DescID: 106, IndexID: 3} + │ │ PUBLIC → TRANSIENT_ABSENT + │ │ + │ ├── • SameStagePrecedence dependency from DROPPED IndexData:{DescID: 106, IndexID: 1} + │ │ rule: "schedule all GC jobs for a descriptor in the same stage" + │ │ + │ └── • Precedence dependency from TRANSIENT_ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ rule: "index removed before garbage collection" + │ + ├── • 2 elements transitioning toward ABSENT + │ │ + │ ├── • PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 1} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 1} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} + │ │ │ rule: "PrimaryIndex transitions to ABSENT uphold 2-version invariant: DELETE_ONLY->ABSENT" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 1} + │ │ rule: "dependents removed before index" + │ │ + │ └── • IndexData:{DescID: 106, IndexID: 1} + │ │ PUBLIC → ABSENT + │ │ + │ └── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 1, ConstraintID: 1} + │ rule: "index removed before garbage collection" + │ + └── • 5 Mutation operations + │ + ├── • MakeIndexAbsent + │ IndexID: 1 + │ TableID: 106 + │ + ├── • CreateGCJobForIndex + │ IndexID: 1 + │ StatementForDropJob: + │ Statement: ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL AS (k) STORED CREATE + │ FAMILY bob + │ TableID: 106 + │ + ├── • CreateGCJobForIndex + │ IndexID: 3 + │ StatementForDropJob: + │ Statement: ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL AS (k) STORED CREATE + │ FAMILY bob + │ TableID: 106 + │ + ├── • RemoveJobStateFromDescriptor + │ DescriptorID: 106 + │ JobID: 1 + │ + └── • UpdateSchemaChangerJob + DescriptorIDsToRemove: + - 106 + IsNonCancelable: true + JobID: 1 + RunningStatus: all stages completed diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored_family.rollback_1_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored_family.rollback_1_of_7 new file mode 100644 index 000000000000..80f0a4fdc423 --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored_family.rollback_1_of_7 @@ -0,0 +1,206 @@ +/* setup */ +CREATE DATABASE db; +CREATE TABLE db.public.tbl (i INT PRIMARY KEY, k INT); +CREATE SEQUENCE db.public.sq1; + +/* test */ +ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL AS (k) STORED CREATE FAMILY bob; +EXPLAIN (ddl, verbose) rollback at post-commit stage 1 of 7; +---- +• Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD COLUMN ‹j› INT8 NOT NULL AS (‹k›) STORED CREATE FAMILY ‹bob›; +│ +└── • PostCommitNonRevertiblePhase + │ + └── • Stage 1 of 1 in PostCommitNonRevertiblePhase + │ + ├── • 13 elements transitioning toward ABSENT + │ │ + │ ├── • Column:{DescID: 106, ColumnID: 3} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ rule: "Column transitions to ABSENT uphold 2-version invariant: DELETE_ONLY->ABSENT" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • SameStagePrecedence dependency from ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 1, ColumnID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ rule: "column type removed right before column when not dropping relation" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "indexes containing column reach absent before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ └── • Precedence dependency from ABSENT ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ rule: "dependents removed before column" + │ │ + │ ├── • ColumnFamily:{DescID: 106, Name: bob, ColumnFamilyID: 1} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 1, ColumnID: 3} + │ │ rule: "column type removed before column family" + │ │ + │ ├── • ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ PUBLIC → ABSENT + │ │ + │ ├── • ColumnType:{DescID: 106, ColumnFamilyID: 1, ColumnID: 3} + │ │ PUBLIC → ABSENT + │ │ + │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ BACKFILL_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "PrimaryIndex transitions to ABSENT uphold 2-version invariant: BACKFILL_ONLY->DELETE_ONLY" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ rule: "dependents removed before index" + │ │ + │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ + │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ + │ ├── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ + │ ├── • IndexData:{DescID: 106, IndexID: 2} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ rule: "index removed before garbage collection" + │ │ + │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "TemporaryIndex transitions to ABSENT uphold 2-version invariant: DELETE_ONLY->ABSENT" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ rule: "dependents removed before index" + │ │ + │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ + │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ + │ └── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ PUBLIC → ABSENT + │ │ + │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ rule: "index drop mutation visible before cleaning up index columns" + │ + └── • 14 Mutation operations + │ + ├── • SetColumnName + │ ColumnID: 3 + │ Name: crdb_internal_column_3_name_placeholder + │ TableID: 106 + │ + ├── • RemoveColumnFromIndex + │ ColumnID: 1 + │ IndexID: 2 + │ TableID: 106 + │ + ├── • RemoveColumnFromIndex + │ ColumnID: 2 + │ IndexID: 2 + │ Kind: 2 + │ TableID: 106 + │ + ├── • RemoveColumnFromIndex + │ ColumnID: 3 + │ IndexID: 2 + │ Kind: 2 + │ Ordinal: 1 + │ TableID: 106 + │ + ├── • RemoveColumnFromIndex + │ ColumnID: 1 + │ IndexID: 3 + │ TableID: 106 + │ + ├── • RemoveColumnFromIndex + │ ColumnID: 2 + │ IndexID: 3 + │ Kind: 2 + │ TableID: 106 + │ + ├── • RemoveColumnFromIndex + │ ColumnID: 3 + │ IndexID: 3 + │ Kind: 2 + │ Ordinal: 1 + │ TableID: 106 + │ + ├── • MakeIndexAbsent + │ IndexID: 2 + │ TableID: 106 + │ + ├── • CreateGCJobForIndex + │ IndexID: 2 + │ StatementForDropJob: + │ Rollback: true + │ Statement: ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL AS (k) STORED CREATE + │ FAMILY bob + │ TableID: 106 + │ + ├── • MakeIndexAbsent + │ IndexID: 3 + │ TableID: 106 + │ + ├── • MakeDeleteOnlyColumnAbsent + │ ColumnID: 3 + │ TableID: 106 + │ + ├── • AssertColumnFamilyIsRemoved + │ FamilyID: 1 + │ TableID: 106 + │ + ├── • RemoveJobStateFromDescriptor + │ DescriptorID: 106 + │ JobID: 1 + │ + └── • UpdateSchemaChangerJob + DescriptorIDsToRemove: + - 106 + IsNonCancelable: true + JobID: 1 + RunningStatus: all stages completed diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored_family.rollback_2_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored_family.rollback_2_of_7 new file mode 100644 index 000000000000..a8dd30793374 --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored_family.rollback_2_of_7 @@ -0,0 +1,285 @@ +/* setup */ +CREATE DATABASE db; +CREATE TABLE db.public.tbl (i INT PRIMARY KEY, k INT); +CREATE SEQUENCE db.public.sq1; + +/* test */ +ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL AS (k) STORED CREATE FAMILY bob; +EXPLAIN (ddl, verbose) rollback at post-commit stage 2 of 7; +---- +• Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD COLUMN ‹j› INT8 NOT NULL AS (‹k›) STORED CREATE FAMILY ‹bob›; +│ +└── • PostCommitNonRevertiblePhase + │ + ├── • Stage 1 of 2 in PostCommitNonRevertiblePhase + │ │ + │ ├── • 11 elements transitioning toward ABSENT + │ │ │ + │ │ ├── • Column:{DescID: 106, ColumnID: 3} + │ │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ │ + │ │ │ ├── • PreviousStagePrecedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "Column transitions to ABSENT uphold 2-version invariant: WRITE_ONLY->DELETE_ONLY" + │ │ │ │ + │ │ │ └── • SameStagePrecedence dependency from ABSENT ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "column constraint removed right before column reaches delete only" + │ │ │ + │ │ ├── • ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ rule: "column no longer public before dependents" + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ BACKFILL_ONLY → ABSENT + │ │ │ │ + │ │ │ ├── • PreviousStagePrecedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ rule: "PrimaryIndex transitions to ABSENT uphold 2-version invariant: BACKFILL_ONLY->DELETE_ONLY" + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ │ + │ │ │ └── • PreviousStagePrecedence dependency from WRITE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "TemporaryIndex transitions to ABSENT uphold 2-version invariant: WRITE_ONLY->DELETE_ONLY" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ └── • ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ WRITE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from WRITE_ONLY ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "ColumnNotNull transitions to ABSENT uphold 2-version invariant: WRITE_ONLY->VALIDATED" + │ │ │ + │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ rule: "column no longer public before dependents" + │ │ + │ └── • 13 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 3 + │ │ Name: crdb_internal_column_3_name_placeholder + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 1 + │ │ IndexID: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 2 + │ │ IndexID: 2 + │ │ Kind: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 3 + │ │ IndexID: 2 + │ │ Kind: 2 + │ │ Ordinal: 1 + │ │ TableID: 106 + │ │ + │ ├── • MakeWriteOnlyIndexDeleteOnly + │ │ IndexID: 3 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 1 + │ │ IndexID: 3 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 2 + │ │ IndexID: 3 + │ │ Kind: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 3 + │ │ IndexID: 3 + │ │ Kind: 2 + │ │ Ordinal: 1 + │ │ TableID: 106 + │ │ + │ ├── • MakeIndexAbsent + │ │ IndexID: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnNotNull + │ │ ColumnID: 3 + │ │ TableID: 106 + │ │ + │ ├── • MakeWriteOnlyColumnDeleteOnly + │ │ ColumnID: 3 + │ │ TableID: 106 + │ │ + │ ├── • SetJobStateOnDescriptor + │ │ DescriptorID: 106 + │ │ + │ └── • UpdateSchemaChangerJob + │ IsNonCancelable: true + │ JobID: 1 + │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 2 with 5 MutationType ops pending + │ + └── • Stage 2 of 2 in PostCommitNonRevertiblePhase + │ + ├── • 6 elements transitioning toward ABSENT + │ │ + │ ├── • Column:{DescID: 106, ColumnID: 3} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ rule: "Column transitions to ABSENT uphold 2-version invariant: DELETE_ONLY->ABSENT" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • SameStagePrecedence dependency from ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 1, ColumnID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ rule: "column type removed right before column when not dropping relation" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "indexes containing column reach absent before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ └── • Precedence dependency from ABSENT ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ rule: "dependents removed before column" + │ │ + │ ├── • ColumnFamily:{DescID: 106, Name: bob, ColumnFamilyID: 1} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 1, ColumnID: 3} + │ │ rule: "column type removed before column family" + │ │ + │ ├── • ColumnType:{DescID: 106, ColumnFamilyID: 1, ColumnID: 3} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ rule: "column no longer public before dependents" + │ │ + │ ├── • IndexData:{DescID: 106, IndexID: 2} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ rule: "index removed before garbage collection" + │ │ + │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "TemporaryIndex transitions to ABSENT uphold 2-version invariant: DELETE_ONLY->ABSENT" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ rule: "dependents removed before index" + │ │ + │ └── • IndexData:{DescID: 106, IndexID: 3} + │ │ PUBLIC → ABSENT + │ │ + │ ├── • SameStagePrecedence dependency from DROPPED IndexData:{DescID: 106, IndexID: 2} + │ │ rule: "schedule all GC jobs for a descriptor in the same stage" + │ │ + │ └── • Precedence dependency from ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ rule: "index removed before garbage collection" + │ + └── • 7 Mutation operations + │ + ├── • CreateGCJobForIndex + │ IndexID: 2 + │ StatementForDropJob: + │ Rollback: true + │ Statement: ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL AS (k) STORED CREATE + │ FAMILY bob + │ TableID: 106 + │ + ├── • MakeIndexAbsent + │ IndexID: 3 + │ TableID: 106 + │ + ├── • CreateGCJobForIndex + │ IndexID: 3 + │ StatementForDropJob: + │ Rollback: true + │ Statement: ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL AS (k) STORED CREATE + │ FAMILY bob + │ TableID: 106 + │ + ├── • MakeDeleteOnlyColumnAbsent + │ ColumnID: 3 + │ TableID: 106 + │ + ├── • AssertColumnFamilyIsRemoved + │ FamilyID: 1 + │ TableID: 106 + │ + ├── • RemoveJobStateFromDescriptor + │ DescriptorID: 106 + │ JobID: 1 + │ + └── • UpdateSchemaChangerJob + DescriptorIDsToRemove: + - 106 + IsNonCancelable: true + JobID: 1 + RunningStatus: all stages completed diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored_family.rollback_3_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored_family.rollback_3_of_7 new file mode 100644 index 000000000000..8eaca35940e4 --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored_family.rollback_3_of_7 @@ -0,0 +1,285 @@ +/* setup */ +CREATE DATABASE db; +CREATE TABLE db.public.tbl (i INT PRIMARY KEY, k INT); +CREATE SEQUENCE db.public.sq1; + +/* test */ +ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL AS (k) STORED CREATE FAMILY bob; +EXPLAIN (ddl, verbose) rollback at post-commit stage 3 of 7; +---- +• Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD COLUMN ‹j› INT8 NOT NULL AS (‹k›) STORED CREATE FAMILY ‹bob›; +│ +└── • PostCommitNonRevertiblePhase + │ + ├── • Stage 1 of 2 in PostCommitNonRevertiblePhase + │ │ + │ ├── • 11 elements transitioning toward ABSENT + │ │ │ + │ │ ├── • Column:{DescID: 106, ColumnID: 3} + │ │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ │ + │ │ │ ├── • PreviousStagePrecedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "Column transitions to ABSENT uphold 2-version invariant: WRITE_ONLY->DELETE_ONLY" + │ │ │ │ + │ │ │ └── • SameStagePrecedence dependency from ABSENT ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "column constraint removed right before column reaches delete only" + │ │ │ + │ │ ├── • ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ rule: "column no longer public before dependents" + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ BACKFILL_ONLY → ABSENT + │ │ │ │ + │ │ │ ├── • PreviousStagePrecedence dependency from BACKFILL_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ rule: "PrimaryIndex transitions to ABSENT uphold 2-version invariant: BACKFILL_ONLY->DELETE_ONLY" + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ │ + │ │ │ └── • PreviousStagePrecedence dependency from WRITE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "TemporaryIndex transitions to ABSENT uphold 2-version invariant: WRITE_ONLY->DELETE_ONLY" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ └── • ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ WRITE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from WRITE_ONLY ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "ColumnNotNull transitions to ABSENT uphold 2-version invariant: WRITE_ONLY->VALIDATED" + │ │ │ + │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ rule: "column no longer public before dependents" + │ │ + │ └── • 13 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 3 + │ │ Name: crdb_internal_column_3_name_placeholder + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 1 + │ │ IndexID: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 2 + │ │ IndexID: 2 + │ │ Kind: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 3 + │ │ IndexID: 2 + │ │ Kind: 2 + │ │ Ordinal: 1 + │ │ TableID: 106 + │ │ + │ ├── • MakeWriteOnlyIndexDeleteOnly + │ │ IndexID: 3 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 1 + │ │ IndexID: 3 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 2 + │ │ IndexID: 3 + │ │ Kind: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 3 + │ │ IndexID: 3 + │ │ Kind: 2 + │ │ Ordinal: 1 + │ │ TableID: 106 + │ │ + │ ├── • MakeIndexAbsent + │ │ IndexID: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnNotNull + │ │ ColumnID: 3 + │ │ TableID: 106 + │ │ + │ ├── • MakeWriteOnlyColumnDeleteOnly + │ │ ColumnID: 3 + │ │ TableID: 106 + │ │ + │ ├── • SetJobStateOnDescriptor + │ │ DescriptorID: 106 + │ │ + │ └── • UpdateSchemaChangerJob + │ IsNonCancelable: true + │ JobID: 1 + │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 2 with 5 MutationType ops pending + │ + └── • Stage 2 of 2 in PostCommitNonRevertiblePhase + │ + ├── • 6 elements transitioning toward ABSENT + │ │ + │ ├── • Column:{DescID: 106, ColumnID: 3} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ rule: "Column transitions to ABSENT uphold 2-version invariant: DELETE_ONLY->ABSENT" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • SameStagePrecedence dependency from ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 1, ColumnID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ rule: "column type removed right before column when not dropping relation" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "indexes containing column reach absent before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ └── • Precedence dependency from ABSENT ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ rule: "dependents removed before column" + │ │ + │ ├── • ColumnFamily:{DescID: 106, Name: bob, ColumnFamilyID: 1} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 1, ColumnID: 3} + │ │ rule: "column type removed before column family" + │ │ + │ ├── • ColumnType:{DescID: 106, ColumnFamilyID: 1, ColumnID: 3} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ rule: "column no longer public before dependents" + │ │ + │ ├── • IndexData:{DescID: 106, IndexID: 2} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ rule: "index removed before garbage collection" + │ │ + │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "TemporaryIndex transitions to ABSENT uphold 2-version invariant: DELETE_ONLY->ABSENT" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ rule: "dependents removed before index" + │ │ + │ └── • IndexData:{DescID: 106, IndexID: 3} + │ │ PUBLIC → ABSENT + │ │ + │ ├── • SameStagePrecedence dependency from DROPPED IndexData:{DescID: 106, IndexID: 2} + │ │ rule: "schedule all GC jobs for a descriptor in the same stage" + │ │ + │ └── • Precedence dependency from ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ rule: "index removed before garbage collection" + │ + └── • 7 Mutation operations + │ + ├── • CreateGCJobForIndex + │ IndexID: 2 + │ StatementForDropJob: + │ Rollback: true + │ Statement: ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL AS (k) STORED CREATE + │ FAMILY bob + │ TableID: 106 + │ + ├── • MakeIndexAbsent + │ IndexID: 3 + │ TableID: 106 + │ + ├── • CreateGCJobForIndex + │ IndexID: 3 + │ StatementForDropJob: + │ Rollback: true + │ Statement: ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL AS (k) STORED CREATE + │ FAMILY bob + │ TableID: 106 + │ + ├── • MakeDeleteOnlyColumnAbsent + │ ColumnID: 3 + │ TableID: 106 + │ + ├── • AssertColumnFamilyIsRemoved + │ FamilyID: 1 + │ TableID: 106 + │ + ├── • RemoveJobStateFromDescriptor + │ DescriptorID: 106 + │ JobID: 1 + │ + └── • UpdateSchemaChangerJob + DescriptorIDsToRemove: + - 106 + IsNonCancelable: true + JobID: 1 + RunningStatus: all stages completed diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored_family.rollback_4_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored_family.rollback_4_of_7 new file mode 100644 index 000000000000..20da6383c080 --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored_family.rollback_4_of_7 @@ -0,0 +1,285 @@ +/* setup */ +CREATE DATABASE db; +CREATE TABLE db.public.tbl (i INT PRIMARY KEY, k INT); +CREATE SEQUENCE db.public.sq1; + +/* test */ +ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL AS (k) STORED CREATE FAMILY bob; +EXPLAIN (ddl, verbose) rollback at post-commit stage 4 of 7; +---- +• Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD COLUMN ‹j› INT8 NOT NULL AS (‹k›) STORED CREATE FAMILY ‹bob›; +│ +└── • PostCommitNonRevertiblePhase + │ + ├── • Stage 1 of 2 in PostCommitNonRevertiblePhase + │ │ + │ ├── • 11 elements transitioning toward ABSENT + │ │ │ + │ │ ├── • Column:{DescID: 106, ColumnID: 3} + │ │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ │ + │ │ │ ├── • PreviousStagePrecedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "Column transitions to ABSENT uphold 2-version invariant: WRITE_ONLY->DELETE_ONLY" + │ │ │ │ + │ │ │ └── • SameStagePrecedence dependency from ABSENT ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "column constraint removed right before column reaches delete only" + │ │ │ + │ │ ├── • ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ rule: "column no longer public before dependents" + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ DELETE_ONLY → ABSENT + │ │ │ │ + │ │ │ ├── • PreviousStagePrecedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ rule: "PrimaryIndex transitions to ABSENT uphold 2-version invariant: DELETE_ONLY->ABSENT" + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ │ rule: "dependents removed before index" + │ │ │ │ + │ │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ │ + │ │ │ └── • PreviousStagePrecedence dependency from WRITE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "TemporaryIndex transitions to ABSENT uphold 2-version invariant: WRITE_ONLY->DELETE_ONLY" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ └── • ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ WRITE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from WRITE_ONLY ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "ColumnNotNull transitions to ABSENT uphold 2-version invariant: WRITE_ONLY->VALIDATED" + │ │ │ + │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ rule: "column no longer public before dependents" + │ │ + │ └── • 13 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 3 + │ │ Name: crdb_internal_column_3_name_placeholder + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 1 + │ │ IndexID: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 2 + │ │ IndexID: 2 + │ │ Kind: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 3 + │ │ IndexID: 2 + │ │ Kind: 2 + │ │ Ordinal: 1 + │ │ TableID: 106 + │ │ + │ ├── • MakeWriteOnlyIndexDeleteOnly + │ │ IndexID: 3 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 1 + │ │ IndexID: 3 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 2 + │ │ IndexID: 3 + │ │ Kind: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 3 + │ │ IndexID: 3 + │ │ Kind: 2 + │ │ Ordinal: 1 + │ │ TableID: 106 + │ │ + │ ├── • MakeIndexAbsent + │ │ IndexID: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnNotNull + │ │ ColumnID: 3 + │ │ TableID: 106 + │ │ + │ ├── • MakeWriteOnlyColumnDeleteOnly + │ │ ColumnID: 3 + │ │ TableID: 106 + │ │ + │ ├── • SetJobStateOnDescriptor + │ │ DescriptorID: 106 + │ │ + │ └── • UpdateSchemaChangerJob + │ IsNonCancelable: true + │ JobID: 1 + │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 2 with 5 MutationType ops pending + │ + └── • Stage 2 of 2 in PostCommitNonRevertiblePhase + │ + ├── • 6 elements transitioning toward ABSENT + │ │ + │ ├── • Column:{DescID: 106, ColumnID: 3} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ rule: "Column transitions to ABSENT uphold 2-version invariant: DELETE_ONLY->ABSENT" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • SameStagePrecedence dependency from ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 1, ColumnID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ rule: "column type removed right before column when not dropping relation" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "indexes containing column reach absent before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ └── • Precedence dependency from ABSENT ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ rule: "dependents removed before column" + │ │ + │ ├── • ColumnFamily:{DescID: 106, Name: bob, ColumnFamilyID: 1} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 1, ColumnID: 3} + │ │ rule: "column type removed before column family" + │ │ + │ ├── • ColumnType:{DescID: 106, ColumnFamilyID: 1, ColumnID: 3} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ rule: "column no longer public before dependents" + │ │ + │ ├── • IndexData:{DescID: 106, IndexID: 2} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ rule: "index removed before garbage collection" + │ │ + │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "TemporaryIndex transitions to ABSENT uphold 2-version invariant: DELETE_ONLY->ABSENT" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ rule: "dependents removed before index" + │ │ + │ └── • IndexData:{DescID: 106, IndexID: 3} + │ │ PUBLIC → ABSENT + │ │ + │ ├── • SameStagePrecedence dependency from DROPPED IndexData:{DescID: 106, IndexID: 2} + │ │ rule: "schedule all GC jobs for a descriptor in the same stage" + │ │ + │ └── • Precedence dependency from ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ rule: "index removed before garbage collection" + │ + └── • 7 Mutation operations + │ + ├── • CreateGCJobForIndex + │ IndexID: 2 + │ StatementForDropJob: + │ Rollback: true + │ Statement: ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL AS (k) STORED CREATE + │ FAMILY bob + │ TableID: 106 + │ + ├── • MakeIndexAbsent + │ IndexID: 3 + │ TableID: 106 + │ + ├── • CreateGCJobForIndex + │ IndexID: 3 + │ StatementForDropJob: + │ Rollback: true + │ Statement: ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL AS (k) STORED CREATE + │ FAMILY bob + │ TableID: 106 + │ + ├── • MakeDeleteOnlyColumnAbsent + │ ColumnID: 3 + │ TableID: 106 + │ + ├── • AssertColumnFamilyIsRemoved + │ FamilyID: 1 + │ TableID: 106 + │ + ├── • RemoveJobStateFromDescriptor + │ DescriptorID: 106 + │ JobID: 1 + │ + └── • UpdateSchemaChangerJob + DescriptorIDsToRemove: + - 106 + IsNonCancelable: true + JobID: 1 + RunningStatus: all stages completed diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored_family.rollback_5_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored_family.rollback_5_of_7 new file mode 100644 index 000000000000..af4d87bcf3c3 --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored_family.rollback_5_of_7 @@ -0,0 +1,295 @@ +/* setup */ +CREATE DATABASE db; +CREATE TABLE db.public.tbl (i INT PRIMARY KEY, k INT); +CREATE SEQUENCE db.public.sq1; + +/* test */ +ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL AS (k) STORED CREATE FAMILY bob; +EXPLAIN (ddl, verbose) rollback at post-commit stage 5 of 7; +---- +• Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD COLUMN ‹j› INT8 NOT NULL AS (‹k›) STORED CREATE FAMILY ‹bob›; +│ +└── • PostCommitNonRevertiblePhase + │ + ├── • Stage 1 of 2 in PostCommitNonRevertiblePhase + │ │ + │ ├── • 11 elements transitioning toward ABSENT + │ │ │ + │ │ ├── • Column:{DescID: 106, ColumnID: 3} + │ │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ │ + │ │ │ ├── • PreviousStagePrecedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "Column transitions to ABSENT uphold 2-version invariant: WRITE_ONLY->DELETE_ONLY" + │ │ │ │ + │ │ │ └── • SameStagePrecedence dependency from ABSENT ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "column constraint removed right before column reaches delete only" + │ │ │ + │ │ ├── • ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ rule: "column no longer public before dependents" + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ MERGE_ONLY → DELETE_ONLY + │ │ │ │ + │ │ │ └── • PreviousStagePrecedence dependency from MERGE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "PrimaryIndex transitions to ABSENT uphold 2-version invariant: MERGE_ONLY->WRITE_ONLY" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ │ + │ │ │ └── • PreviousStagePrecedence dependency from WRITE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "TemporaryIndex transitions to ABSENT uphold 2-version invariant: WRITE_ONLY->DELETE_ONLY" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ └── • ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ WRITE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from WRITE_ONLY ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "ColumnNotNull transitions to ABSENT uphold 2-version invariant: WRITE_ONLY->VALIDATED" + │ │ │ + │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ rule: "column no longer public before dependents" + │ │ + │ └── • 13 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 3 + │ │ Name: crdb_internal_column_3_name_placeholder + │ │ TableID: 106 + │ │ + │ ├── • MakeWriteOnlyIndexDeleteOnly + │ │ IndexID: 3 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 1 + │ │ IndexID: 3 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 2 + │ │ IndexID: 3 + │ │ Kind: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 3 + │ │ IndexID: 3 + │ │ Kind: 2 + │ │ Ordinal: 1 + │ │ TableID: 106 + │ │ + │ ├── • MakeWriteOnlyIndexDeleteOnly + │ │ IndexID: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 1 + │ │ IndexID: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 2 + │ │ IndexID: 2 + │ │ Kind: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 3 + │ │ IndexID: 2 + │ │ Kind: 2 + │ │ Ordinal: 1 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnNotNull + │ │ ColumnID: 3 + │ │ TableID: 106 + │ │ + │ ├── • MakeWriteOnlyColumnDeleteOnly + │ │ ColumnID: 3 + │ │ TableID: 106 + │ │ + │ ├── • SetJobStateOnDescriptor + │ │ DescriptorID: 106 + │ │ + │ └── • UpdateSchemaChangerJob + │ IsNonCancelable: true + │ JobID: 1 + │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 2 with 6 MutationType ops pending + │ + └── • Stage 2 of 2 in PostCommitNonRevertiblePhase + │ + ├── • 7 elements transitioning toward ABSENT + │ │ + │ ├── • Column:{DescID: 106, ColumnID: 3} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ rule: "Column transitions to ABSENT uphold 2-version invariant: DELETE_ONLY->ABSENT" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • SameStagePrecedence dependency from ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 1, ColumnID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ rule: "column type removed right before column when not dropping relation" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "indexes containing column reach absent before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ └── • Precedence dependency from ABSENT ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ rule: "dependents removed before column" + │ │ + │ ├── • ColumnFamily:{DescID: 106, Name: bob, ColumnFamilyID: 1} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 1, ColumnID: 3} + │ │ rule: "column type removed before column family" + │ │ + │ ├── • ColumnType:{DescID: 106, ColumnFamilyID: 1, ColumnID: 3} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ rule: "column no longer public before dependents" + │ │ + │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "PrimaryIndex transitions to ABSENT uphold 2-version invariant: DELETE_ONLY->ABSENT" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ rule: "dependents removed before index" + │ │ + │ ├── • IndexData:{DescID: 106, IndexID: 2} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ rule: "index removed before garbage collection" + │ │ + │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "TemporaryIndex transitions to ABSENT uphold 2-version invariant: DELETE_ONLY->ABSENT" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ rule: "dependents removed before index" + │ │ + │ └── • IndexData:{DescID: 106, IndexID: 3} + │ │ PUBLIC → ABSENT + │ │ + │ ├── • SameStagePrecedence dependency from DROPPED IndexData:{DescID: 106, IndexID: 2} + │ │ rule: "schedule all GC jobs for a descriptor in the same stage" + │ │ + │ └── • Precedence dependency from ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ rule: "index removed before garbage collection" + │ + └── • 8 Mutation operations + │ + ├── • MakeIndexAbsent + │ IndexID: 2 + │ TableID: 106 + │ + ├── • CreateGCJobForIndex + │ IndexID: 2 + │ StatementForDropJob: + │ Rollback: true + │ Statement: ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL AS (k) STORED CREATE + │ FAMILY bob + │ TableID: 106 + │ + ├── • MakeIndexAbsent + │ IndexID: 3 + │ TableID: 106 + │ + ├── • CreateGCJobForIndex + │ IndexID: 3 + │ StatementForDropJob: + │ Rollback: true + │ Statement: ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL AS (k) STORED CREATE + │ FAMILY bob + │ TableID: 106 + │ + ├── • MakeDeleteOnlyColumnAbsent + │ ColumnID: 3 + │ TableID: 106 + │ + ├── • AssertColumnFamilyIsRemoved + │ FamilyID: 1 + │ TableID: 106 + │ + ├── • RemoveJobStateFromDescriptor + │ DescriptorID: 106 + │ JobID: 1 + │ + └── • UpdateSchemaChangerJob + DescriptorIDsToRemove: + - 106 + IsNonCancelable: true + JobID: 1 + RunningStatus: all stages completed diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored_family.rollback_6_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored_family.rollback_6_of_7 new file mode 100644 index 000000000000..cc75c5cf5d10 --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored_family.rollback_6_of_7 @@ -0,0 +1,295 @@ +/* setup */ +CREATE DATABASE db; +CREATE TABLE db.public.tbl (i INT PRIMARY KEY, k INT); +CREATE SEQUENCE db.public.sq1; + +/* test */ +ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL AS (k) STORED CREATE FAMILY bob; +EXPLAIN (ddl, verbose) rollback at post-commit stage 6 of 7; +---- +• Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD COLUMN ‹j› INT8 NOT NULL AS (‹k›) STORED CREATE FAMILY ‹bob›; +│ +└── • PostCommitNonRevertiblePhase + │ + ├── • Stage 1 of 2 in PostCommitNonRevertiblePhase + │ │ + │ ├── • 11 elements transitioning toward ABSENT + │ │ │ + │ │ ├── • Column:{DescID: 106, ColumnID: 3} + │ │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ │ + │ │ │ ├── • PreviousStagePrecedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "Column transitions to ABSENT uphold 2-version invariant: WRITE_ONLY->DELETE_ONLY" + │ │ │ │ + │ │ │ └── • SameStagePrecedence dependency from ABSENT ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "column constraint removed right before column reaches delete only" + │ │ │ + │ │ ├── • ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ rule: "column no longer public before dependents" + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ MERGE_ONLY → DELETE_ONLY + │ │ │ │ + │ │ │ └── • PreviousStagePrecedence dependency from MERGE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "PrimaryIndex transitions to ABSENT uphold 2-version invariant: MERGE_ONLY->WRITE_ONLY" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ │ + │ │ │ └── • PreviousStagePrecedence dependency from WRITE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "TemporaryIndex transitions to ABSENT uphold 2-version invariant: WRITE_ONLY->DELETE_ONLY" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ └── • ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ WRITE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from WRITE_ONLY ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "ColumnNotNull transitions to ABSENT uphold 2-version invariant: WRITE_ONLY->VALIDATED" + │ │ │ + │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ rule: "column no longer public before dependents" + │ │ + │ └── • 13 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 3 + │ │ Name: crdb_internal_column_3_name_placeholder + │ │ TableID: 106 + │ │ + │ ├── • MakeWriteOnlyIndexDeleteOnly + │ │ IndexID: 3 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 1 + │ │ IndexID: 3 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 2 + │ │ IndexID: 3 + │ │ Kind: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 3 + │ │ IndexID: 3 + │ │ Kind: 2 + │ │ Ordinal: 1 + │ │ TableID: 106 + │ │ + │ ├── • MakeWriteOnlyIndexDeleteOnly + │ │ IndexID: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 1 + │ │ IndexID: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 2 + │ │ IndexID: 2 + │ │ Kind: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 3 + │ │ IndexID: 2 + │ │ Kind: 2 + │ │ Ordinal: 1 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnNotNull + │ │ ColumnID: 3 + │ │ TableID: 106 + │ │ + │ ├── • MakeWriteOnlyColumnDeleteOnly + │ │ ColumnID: 3 + │ │ TableID: 106 + │ │ + │ ├── • SetJobStateOnDescriptor + │ │ DescriptorID: 106 + │ │ + │ └── • UpdateSchemaChangerJob + │ IsNonCancelable: true + │ JobID: 1 + │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 2 with 6 MutationType ops pending + │ + └── • Stage 2 of 2 in PostCommitNonRevertiblePhase + │ + ├── • 7 elements transitioning toward ABSENT + │ │ + │ ├── • Column:{DescID: 106, ColumnID: 3} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ rule: "Column transitions to ABSENT uphold 2-version invariant: DELETE_ONLY->ABSENT" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • SameStagePrecedence dependency from ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 1, ColumnID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ rule: "column type removed right before column when not dropping relation" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "indexes containing column reach absent before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ └── • Precedence dependency from ABSENT ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ rule: "dependents removed before column" + │ │ + │ ├── • ColumnFamily:{DescID: 106, Name: bob, ColumnFamilyID: 1} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 1, ColumnID: 3} + │ │ rule: "column type removed before column family" + │ │ + │ ├── • ColumnType:{DescID: 106, ColumnFamilyID: 1, ColumnID: 3} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ rule: "column no longer public before dependents" + │ │ + │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "PrimaryIndex transitions to ABSENT uphold 2-version invariant: DELETE_ONLY->ABSENT" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ rule: "dependents removed before index" + │ │ + │ ├── • IndexData:{DescID: 106, IndexID: 2} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ rule: "index removed before garbage collection" + │ │ + │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "TemporaryIndex transitions to ABSENT uphold 2-version invariant: DELETE_ONLY->ABSENT" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ rule: "dependents removed before index" + │ │ + │ └── • IndexData:{DescID: 106, IndexID: 3} + │ │ PUBLIC → ABSENT + │ │ + │ ├── • SameStagePrecedence dependency from DROPPED IndexData:{DescID: 106, IndexID: 2} + │ │ rule: "schedule all GC jobs for a descriptor in the same stage" + │ │ + │ └── • Precedence dependency from ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ rule: "index removed before garbage collection" + │ + └── • 8 Mutation operations + │ + ├── • MakeIndexAbsent + │ IndexID: 2 + │ TableID: 106 + │ + ├── • CreateGCJobForIndex + │ IndexID: 2 + │ StatementForDropJob: + │ Rollback: true + │ Statement: ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL AS (k) STORED CREATE + │ FAMILY bob + │ TableID: 106 + │ + ├── • MakeIndexAbsent + │ IndexID: 3 + │ TableID: 106 + │ + ├── • CreateGCJobForIndex + │ IndexID: 3 + │ StatementForDropJob: + │ Rollback: true + │ Statement: ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL AS (k) STORED CREATE + │ FAMILY bob + │ TableID: 106 + │ + ├── • MakeDeleteOnlyColumnAbsent + │ ColumnID: 3 + │ TableID: 106 + │ + ├── • AssertColumnFamilyIsRemoved + │ FamilyID: 1 + │ TableID: 106 + │ + ├── • RemoveJobStateFromDescriptor + │ DescriptorID: 106 + │ JobID: 1 + │ + └── • UpdateSchemaChangerJob + DescriptorIDsToRemove: + - 106 + IsNonCancelable: true + JobID: 1 + RunningStatus: all stages completed diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored_family.rollback_7_of_7 b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored_family.rollback_7_of_7 new file mode 100644 index 000000000000..6939acbf94e1 --- /dev/null +++ b/pkg/sql/schemachanger/testdata/explain_verbose/add_column_with_stored_family.rollback_7_of_7 @@ -0,0 +1,295 @@ +/* setup */ +CREATE DATABASE db; +CREATE TABLE db.public.tbl (i INT PRIMARY KEY, k INT); +CREATE SEQUENCE db.public.sq1; + +/* test */ +ALTER TABLE db.public.tbl ADD COLUMN j INT NOT NULL AS (k) STORED CREATE FAMILY bob; +EXPLAIN (ddl, verbose) rollback at post-commit stage 7 of 7; +---- +• Schema change plan for rolling back ALTER TABLE ‹db›.public.‹tbl› ADD COLUMN ‹j› INT8 NOT NULL AS (‹k›) STORED CREATE FAMILY ‹bob›; +│ +└── • PostCommitNonRevertiblePhase + │ + ├── • Stage 1 of 2 in PostCommitNonRevertiblePhase + │ │ + │ ├── • 11 elements transitioning toward ABSENT + │ │ │ + │ │ ├── • Column:{DescID: 106, ColumnID: 3} + │ │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ │ + │ │ │ ├── • PreviousStagePrecedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "Column transitions to ABSENT uphold 2-version invariant: WRITE_ONLY->DELETE_ONLY" + │ │ │ │ + │ │ │ └── • SameStagePrecedence dependency from ABSENT ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "column constraint removed right before column reaches delete only" + │ │ │ + │ │ ├── • ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ rule: "column no longer public before dependents" + │ │ │ + │ │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ │ + │ │ │ └── • PreviousStagePrecedence dependency from WRITE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "PrimaryIndex transitions to ABSENT uphold 2-version invariant: WRITE_ONLY->DELETE_ONLY" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ │ WRITE_ONLY → DELETE_ONLY + │ │ │ │ + │ │ │ └── • PreviousStagePrecedence dependency from WRITE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "TemporaryIndex transitions to ABSENT uphold 2-version invariant: WRITE_ONLY->DELETE_ONLY" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ ├── • IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ │ │ PUBLIC → ABSENT + │ │ │ │ + │ │ │ ├── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ │ rule: "column no longer public before dependents" + │ │ │ │ + │ │ │ └── • Precedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "index drop mutation visible before cleaning up index columns" + │ │ │ + │ │ └── • ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ WRITE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from WRITE_ONLY ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "ColumnNotNull transitions to ABSENT uphold 2-version invariant: WRITE_ONLY->VALIDATED" + │ │ │ + │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ rule: "column no longer public before dependents" + │ │ + │ └── • 13 Mutation operations + │ │ + │ ├── • SetColumnName + │ │ ColumnID: 3 + │ │ Name: crdb_internal_column_3_name_placeholder + │ │ TableID: 106 + │ │ + │ ├── • MakeWriteOnlyIndexDeleteOnly + │ │ IndexID: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 1 + │ │ IndexID: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 2 + │ │ IndexID: 2 + │ │ Kind: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 3 + │ │ IndexID: 2 + │ │ Kind: 2 + │ │ Ordinal: 1 + │ │ TableID: 106 + │ │ + │ ├── • MakeWriteOnlyIndexDeleteOnly + │ │ IndexID: 3 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 1 + │ │ IndexID: 3 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 2 + │ │ IndexID: 3 + │ │ Kind: 2 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnFromIndex + │ │ ColumnID: 3 + │ │ IndexID: 3 + │ │ Kind: 2 + │ │ Ordinal: 1 + │ │ TableID: 106 + │ │ + │ ├── • RemoveColumnNotNull + │ │ ColumnID: 3 + │ │ TableID: 106 + │ │ + │ ├── • MakeWriteOnlyColumnDeleteOnly + │ │ ColumnID: 3 + │ │ TableID: 106 + │ │ + │ ├── • SetJobStateOnDescriptor + │ │ DescriptorID: 106 + │ │ + │ └── • UpdateSchemaChangerJob + │ IsNonCancelable: true + │ JobID: 1 + │ RunningStatus: PostCommitNonRevertiblePhase stage 2 of 2 with 6 MutationType ops pending + │ + └── • Stage 2 of 2 in PostCommitNonRevertiblePhase + │ + ├── • 7 elements transitioning toward ABSENT + │ │ + │ ├── • Column:{DescID: 106, ColumnID: 3} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from DELETE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ │ rule: "Column transitions to ABSENT uphold 2-version invariant: DELETE_ONLY->ABSENT" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT ColumnName:{DescID: 106, Name: j, ColumnID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • SameStagePrecedence dependency from ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 1, ColumnID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ rule: "column type removed right before column when not dropping relation" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "indexes containing column reach absent before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ │ rule: "dependents removed before column" + │ │ │ + │ │ └── • Precedence dependency from ABSENT ColumnNotNull:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ rule: "dependents removed before column" + │ │ + │ ├── • ColumnFamily:{DescID: 106, Name: bob, ColumnFamilyID: 1} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from ABSENT ColumnType:{DescID: 106, ColumnFamilyID: 1, ColumnID: 3} + │ │ rule: "column type removed before column family" + │ │ + │ ├── • ColumnType:{DescID: 106, ColumnFamilyID: 1, ColumnID: 3} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from WRITE_ONLY Column:{DescID: 106, ColumnID: 3} + │ │ rule: "column no longer public before dependents" + │ │ + │ ├── • PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from DELETE_ONLY PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ │ rule: "PrimaryIndex transitions to ABSENT uphold 2-version invariant: DELETE_ONLY->ABSENT" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexName:{DescID: 106, Name: tbl_pkey, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 2} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 2} + │ │ rule: "dependents removed before index" + │ │ + │ ├── • IndexData:{DescID: 106, IndexID: 2} + │ │ │ PUBLIC → ABSENT + │ │ │ + │ │ └── • Precedence dependency from ABSENT PrimaryIndex:{DescID: 106, IndexID: 2, ConstraintID: 2, TemporaryIndexID: 3, SourceIndexID: 1} + │ │ rule: "index removed before garbage collection" + │ │ + │ ├── • TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ DELETE_ONLY → ABSENT + │ │ │ + │ │ ├── • PreviousStagePrecedence dependency from DELETE_ONLY TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ │ │ rule: "TemporaryIndex transitions to ABSENT uphold 2-version invariant: DELETE_ONLY->ABSENT" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 1, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ ├── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 2, IndexID: 3} + │ │ │ rule: "dependents removed before index" + │ │ │ + │ │ └── • Precedence dependency from ABSENT IndexColumn:{DescID: 106, ColumnID: 3, IndexID: 3} + │ │ rule: "dependents removed before index" + │ │ + │ └── • IndexData:{DescID: 106, IndexID: 3} + │ │ PUBLIC → ABSENT + │ │ + │ ├── • SameStagePrecedence dependency from DROPPED IndexData:{DescID: 106, IndexID: 2} + │ │ rule: "schedule all GC jobs for a descriptor in the same stage" + │ │ + │ └── • Precedence dependency from ABSENT TemporaryIndex:{DescID: 106, IndexID: 3, ConstraintID: 3, SourceIndexID: 1} + │ rule: "index removed before garbage collection" + │ + └── • 8 Mutation operations + │ + ├── • MakeIndexAbsent + │ IndexID: 2 + │ TableID: 106 + │ + ├── • CreateGCJobForIndex + │ IndexID: 2 + │ StatementForDropJob: + │ Rollback: true + │ Statement: ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL AS (k) STORED CREATE + │ FAMILY bob + │ TableID: 106 + │ + ├── • MakeIndexAbsent + │ IndexID: 3 + │ TableID: 106 + │ + ├── • CreateGCJobForIndex + │ IndexID: 3 + │ StatementForDropJob: + │ Rollback: true + │ Statement: ALTER TABLE db.public.tbl ADD COLUMN j INT8 NOT NULL AS (k) STORED CREATE + │ FAMILY bob + │ TableID: 106 + │ + ├── • MakeDeleteOnlyColumnAbsent + │ ColumnID: 3 + │ TableID: 106 + │ + ├── • AssertColumnFamilyIsRemoved + │ FamilyID: 1 + │ TableID: 106 + │ + ├── • RemoveJobStateFromDescriptor + │ DescriptorID: 106 + │ JobID: 1 + │ + └── • UpdateSchemaChangerJob + DescriptorIDsToRemove: + - 106 + IsNonCancelable: true + JobID: 1 + RunningStatus: all stages completed