@@ -4128,9 +4128,6 @@ alter table roach add column serial_id2 SERIAL
41284128
41294129subtest end
41304130
4131- statement ok
4132- set use_declarative_schema_changer = on
4133-
41344131# Tests for #131948 where we incorrectly backfilled empty column
41354132# families for composite datums.
41364133subtest composite_type_131948
@@ -4454,6 +4451,7 @@ CREATE TABLE alter_table_alter_primary_key_duplicate_storage_params_a (
44544451 b TEXT NOT NULL
44554452);
44564453
4454+ skipif config local-legacy-schema-changer
44574455statement error pgcode 22023 pq: parameter "bucket_count" specified more than once
44584456ALTER TABLE alter_table_alter_primary_key_duplicate_storage_params_a
44594457 ALTER PRIMARY KEY
@@ -4468,6 +4466,11 @@ subtest end
44684466# when adding a column with an invalid geometry expression.
44694467subtest alter_table_add_column_with_invalid_geometry_expression
44704468
4469+ let $use_decl_sc
4470+ SHOW use_declarative_schema_changer
4471+
4472+ statement ok
4473+ set use_declarative_schema_changer = on
44714474
44724475statement ok
44734476CREATE TABLE alter_table_add_column_with_invalid_geometry_expression (
@@ -4478,4 +4481,85 @@ INSERT INTO alter_table_add_column_with_invalid_geometry_expression VALUES (1);
44784481statement error pgcode 22023 pq: failed to construct index entries during backfill: error parsing EWKB: unexpected EOF
44794482ALTER TABLE alter_table_add_column_with_invalid_geometry_expression ADD COLUMN geom GEOMETRY NULL DEFAULT x'001a'
44804483
4484+ statement ok
4485+ SET use_declarative_schema_changer = $use_decl_sc;
4486+
4487+ subtest end
4488+
4489+ # This is a regression test for #144293 where we were bumping the UDT version of
4490+ # all types unconditionally in the legacy schema changer.
4491+ subtest conditional_bump_udt_version
4492+
4493+ statement ok
4494+ CREATE TABLE t_conditional_bump_udt_version (
4495+ id INT PRIMARY KEY
4496+ );
4497+
4498+ statement ok
4499+ CREATE TYPE e1 AS ENUM ('a', 'b', 'c');
4500+
4501+ let $e1_version
4502+ SELECT crdb_internal.pb_to_json('descriptor', descriptor) -> 'type' ->> 'version'
4503+ from system.descriptor
4504+ where id = 'e1'::REGTYPE::INT - 100000;
4505+
4506+ # Add a column using e1. We expect a version bump in the enum.
4507+ statement ok
4508+ ALTER TABLE t_conditional_bump_udt_version ADD COLUMN e1_col e1;
4509+
4510+ query I
4511+ SELECT 1
4512+ FROM system.descriptor
4513+ WHERE id = 'e1'::REGTYPE::INT - 100000 AND
4514+ (crdb_internal.pb_to_json('descriptor', descriptor) -> 'type' ->> 'version')::INT > $e1_version;
4515+ ----
4516+ 1
4517+
4518+ let $e1_version
4519+ SELECT crdb_internal.pb_to_json('descriptor', descriptor) -> 'type' ->> 'version'
4520+ from system.descriptor
4521+ where id = 'e1'::REGTYPE::INT - 100000;
4522+
4523+ # Add a regular int column. That should not bump the version.
4524+ statement ok
4525+ ALTER TABLE t_conditional_bump_udt_version ADD COLUMN i_col INT;
4526+
4527+ query I
4528+ SELECT 1
4529+ FROM system.descriptor
4530+ WHERE id = 'e1'::REGTYPE::INT - 100000 AND
4531+ (crdb_internal.pb_to_json('descriptor', descriptor) -> 'type' ->> 'version')::INT = $e1_version;
4532+ ----
4533+ 1
4534+
4535+ # No bump for drop column.
4536+ statement ok
4537+ ALTER TABLE t_conditional_bump_udt_version DROP COLUMN i_col;
4538+
4539+ query I
4540+ SELECT 1
4541+ FROM system.descriptor
4542+ WHERE id = 'e1'::REGTYPE::INT - 100000 AND
4543+ (crdb_internal.pb_to_json('descriptor', descriptor) -> 'type' ->> 'version')::INT = $e1_version;
4544+ ----
4545+ 1
4546+
4547+ # Ensure version bump happens when we drop the column using the type.
4548+ statement ok
4549+ ALTER TABLE t_conditional_bump_udt_version DROP COLUMN e1_col;
4550+
4551+ query I
4552+ SELECT 1
4553+ FROM system.descriptor
4554+ WHERE id = 'e1'::REGTYPE::INT - 100000 AND
4555+ (crdb_internal.pb_to_json('descriptor', descriptor) -> 'type' ->> 'version')::INT > $e1_version;
4556+ ----
4557+ 1
4558+
4559+ statement ok
4560+ DROP TABLE t_conditional_bump_udt_version;
4561+
4562+ statement ok
4563+ DROP TYPE e1;
4564+
44814565subtest end
0 commit comments