Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/ccl/changefeedccl/cdcevent/event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,9 @@ func TestEventColumnOrderingWithSchemaChanges(t *testing.T) {
sqlDB := sqlutils.MakeSQLRunner(db)
// Use alter column type to force column reordering.
sqlDB.Exec(t, `SET enable_experimental_alter_column_type_general = true`)
// TODO(#133040): force the legacy schema changer. When run with the DSC,
// the ordering changes in the column family. This needs to be revisited in 133040.
sqlDB.Exec(t, `SET use_declarative_schema_changer = 'off'`)

type decodeExpectation struct {
expectUnwatchedErr bool
Expand Down
28 changes: 28 additions & 0 deletions pkg/ccl/schemachangerccl/backup_base_generated_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions pkg/ccl/schemachangerccl/testdata/decomp/multiregion
Original file line number Diff line number Diff line change
Expand Up @@ -190,31 +190,37 @@ ElementState:
tableId: 110
Status: PUBLIC
- ColumnName:
absentName: ""
columnId: 1
name: b
tableId: 110
Status: PUBLIC
- ColumnName:
absentName: ""
columnId: 2
name: rowid
tableId: 110
Status: PUBLIC
- ColumnName:
absentName: ""
columnId: 4.294967292e+09
name: crdb_internal_origin_timestamp
tableId: 110
Status: PUBLIC
- ColumnName:
absentName: ""
columnId: 4.294967293e+09
name: crdb_internal_origin_id
tableId: 110
Status: PUBLIC
- ColumnName:
absentName: ""
columnId: 4.294967294e+09
name: tableoid
tableId: 110
Status: PUBLIC
- ColumnName:
absentName: ""
columnId: 4.294967295e+09
name: crdb_internal_mvcc_timestamp
tableId: 110
Expand Down Expand Up @@ -579,31 +585,37 @@ ElementState:
tableId: 109
Status: PUBLIC
- ColumnName:
absentName: ""
columnId: 1
name: a
tableId: 109
Status: PUBLIC
- ColumnName:
absentName: ""
columnId: 2
name: rowid
tableId: 109
Status: PUBLIC
- ColumnName:
absentName: ""
columnId: 4.294967292e+09
name: crdb_internal_origin_timestamp
tableId: 109
Status: PUBLIC
- ColumnName:
absentName: ""
columnId: 4.294967293e+09
name: crdb_internal_origin_id
tableId: 109
Status: PUBLIC
- ColumnName:
absentName: ""
columnId: 4.294967294e+09
name: tableoid
tableId: 109
Status: PUBLIC
- ColumnName:
absentName: ""
columnId: 4.294967295e+09
name: crdb_internal_mvcc_timestamp
tableId: 109
Expand Down Expand Up @@ -997,36 +1009,43 @@ ElementState:
tableId: 108
Status: PUBLIC
- ColumnName:
absentName: ""
columnId: 1
name: k
tableId: 108
Status: PUBLIC
- ColumnName:
absentName: ""
columnId: 2
name: v
tableId: 108
Status: PUBLIC
- ColumnName:
absentName: ""
columnId: 3
name: crdb_region
tableId: 108
Status: PUBLIC
- ColumnName:
absentName: ""
columnId: 4.294967292e+09
name: crdb_internal_origin_timestamp
tableId: 108
Status: PUBLIC
- ColumnName:
absentName: ""
columnId: 4.294967293e+09
name: crdb_internal_origin_id
tableId: 108
Status: PUBLIC
- ColumnName:
absentName: ""
columnId: 4.294967294e+09
name: tableoid
tableId: 108
Status: PUBLIC
- ColumnName:
absentName: ""
columnId: 4.294967295e+09
name: crdb_internal_mvcc_timestamp
tableId: 108
Expand Down
13 changes: 13 additions & 0 deletions pkg/ccl/schemachangerccl/testdata/decomp/partitioning
Original file line number Diff line number Diff line change
Expand Up @@ -111,36 +111,43 @@ ElementState:
tableId: 104
Status: PUBLIC
- ColumnName:
absentName: ""
columnId: 1
name: pk
tableId: 104
Status: PUBLIC
- ColumnName:
absentName: ""
columnId: 2
name: a
tableId: 104
Status: PUBLIC
- ColumnName:
absentName: ""
columnId: 3
name: j
tableId: 104
Status: PUBLIC
- ColumnName:
absentName: ""
columnId: 4.294967292e+09
name: crdb_internal_origin_timestamp
tableId: 104
Status: PUBLIC
- ColumnName:
absentName: ""
columnId: 4.294967293e+09
name: crdb_internal_origin_id
tableId: 104
Status: PUBLIC
- ColumnName:
absentName: ""
columnId: 4.294967294e+09
name: tableoid
tableId: 104
Status: PUBLIC
- ColumnName:
absentName: ""
columnId: 4.294967295e+09
name: crdb_internal_mvcc_timestamp
tableId: 104
Expand Down Expand Up @@ -617,31 +624,37 @@ ElementState:
tableId: 105
Status: PUBLIC
- ColumnName:
absentName: ""
columnId: 1
name: a
tableId: 105
Status: PUBLIC
- ColumnName:
absentName: ""
columnId: 2
name: b
tableId: 105
Status: PUBLIC
- ColumnName:
absentName: ""
columnId: 4.294967292e+09
name: crdb_internal_origin_timestamp
tableId: 105
Status: PUBLIC
- ColumnName:
absentName: ""
columnId: 4.294967293e+09
name: crdb_internal_origin_id
tableId: 105
Status: PUBLIC
- ColumnName:
absentName: ""
columnId: 4.294967294e+09
name: tableoid
tableId: 105
Status: PUBLIC
- ColumnName:
absentName: ""
columnId: 4.294967295e+09
name: crdb_internal_mvcc_timestamp
tableId: 105
Expand Down
6 changes: 1 addition & 5 deletions pkg/sql/alter_column_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ import (
var AlterColTypeInTxnNotSupportedErr = unimplemented.NewWithIssuef(
49351, "ALTER COLUMN TYPE is not supported inside a transaction")

var alterColTypeInCombinationNotSupportedErr = unimplemented.NewWithIssuef(
49351, "ALTER COLUMN TYPE cannot be used in combination "+
"with other ALTER TABLE commands")

// AlterColumnType takes an AlterTableAlterColumnType, determines
// which conversion to use and applies the type conversion.
func AlterColumnType(
Expand Down Expand Up @@ -216,7 +212,7 @@ func alterColumnTypeGeneral(
}

if len(cmds) > 1 {
return alterColTypeInCombinationNotSupportedErr
return sqlerrors.NewAlterColTypeInCombinationNotSupportedError()
}

// Disallow ALTER COLUMN TYPE general if the table is already undergoing
Expand Down
13 changes: 11 additions & 2 deletions pkg/sql/alter_column_type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ INSERT INTO test2 VALUES ('hello');`)
go func() {
sqlDB.ExecMultiple(t,
`SET enable_experimental_alter_column_type_general = true;`,
// TODO(spilchen): This test is designed for the legacy schema changer.
// Update it for the declarative schema changer (DSC).
`SET use_declarative_schema_changer = 'off';`,
`ALTER TABLE test ALTER COLUMN x TYPE STRING;`)
wg.Done()
}()
Expand Down Expand Up @@ -151,6 +154,9 @@ INSERT INTO test2 VALUES (true);
go func() {
sqlDB.ExecMultiple(t,
`SET enable_experimental_alter_column_type_general = true;`,
// TODO(spilchen): This test is designed for the legacy schema changer.
// Update it for the declarative schema changer (DSC).
`SET use_declarative_schema_changer = 'off';`,
`ALTER TABLE test ALTER COLUMN x TYPE BOOL USING (x > 0);`)
wg.Done()
}()
Expand Down Expand Up @@ -203,7 +209,10 @@ func TestVisibilityDuringAlterColumnType(t *testing.T) {
sqlDB := sqlutils.MakeSQLRunner(db)
defer s.Stopper().Stop(ctx)

sqlDB.Exec(t, `SET enable_experimental_alter_column_type_general = true;`)
sqlDB.ExecMultiple(t, `SET enable_experimental_alter_column_type_general = true;`,
// TODO(spilchen): This test is designed for the legacy schema changer.
// Update it for the declarative schema changer (DSC).
`SET use_declarative_schema_changer = 'off'`)

sqlDB.Exec(t, `
CREATE DATABASE t;
Expand Down Expand Up @@ -259,7 +268,7 @@ func TestAlterColumnTypeFailureRollback(t *testing.T) {
sqlDB.Exec(t, `CREATE TABLE t.test (x STRING);`)
sqlDB.Exec(t, `INSERT INTO t.test VALUES ('1'), ('2'), ('HELLO');`)

expected := "pq: could not parse \"HELLO\" as type int: strconv.ParseInt: parsing \"HELLO\": invalid syntax"
expected := "pq: failed to construct index entries during backfill: could not parse \"HELLO\" as type int: strconv.ParseInt: parsing \"HELLO\": invalid syntax"
sqlDB.ExpectErr(t, expected, `ALTER TABLE t.test ALTER COLUMN x TYPE INT USING x::INT8;`)

// Ensure that the add column and column swap mutations are cleaned up.
Expand Down
Loading
Loading