Skip to content

Commit ccfeb69

Browse files
craig[bot]fqazi
andcommitted
Merge #148101
148101: logictest: enable schema_locked by default for new tables r=fqazi a=fqazi This PR enables schema-locked across the entire logic test suite by doing the following 1. Bypassing SET ZONE CONFIG and ALTER INDEX ... VISIBILITY operations 2. Enabling schema-locked by default on all tests and adding a new config set for the disabled config (local-legacy-schema-changer and local-mixed*). Also search and replacing local-schema-locked with this new config set where appropriate. 3. Updating execbuilder tests to take into account schema_locked. Tests with transactions will toggle schema_locked or avoid creating tables with it. 4. Updating CCL logictests to take into account schema_locked. schema_locked is only bypassed in cases where table locality is set. Note: The final PR will squash the last 3 commits, since those are needed for a stable logic test. To make reviewing easier we have those changes split up. Informs: #129694 Release note: None Co-authored-by: Faizan Qazi <[email protected]>
2 parents 5f95d39 + 4ab8f89 commit ccfeb69

File tree

121 files changed

+1306
-5669
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+1306
-5669
lines changed

pkg/BUILD.bazel

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ ALL_TESTS = [
6262
"//pkg/ccl/logictestccl/tests/local-mixed-25.2:local-mixed-25_2_test",
6363
"//pkg/ccl/logictestccl/tests/local-read-committed:local-read-committed_test",
6464
"//pkg/ccl/logictestccl/tests/local-repeatable-read:local-repeatable-read_test",
65-
"//pkg/ccl/logictestccl/tests/local-schema-locked:local-schema-locked_test",
6665
"//pkg/ccl/logictestccl/tests/local-vec-off:local-vec-off_test",
6766
"//pkg/ccl/logictestccl/tests/local:local_test",
6867
"//pkg/ccl/logictestccl/tests/multiregion-15node-5region-3azs:multiregion-15node-5region-3azs_test",
@@ -508,7 +507,6 @@ ALL_TESTS = [
508507
"//pkg/sql/logictest/tests/fakedist:fakedist_test",
509508
"//pkg/sql/logictest/tests/local-legacy-schema-changer:local-legacy-schema-changer_test",
510509
"//pkg/sql/logictest/tests/local-mixed-25.2:local-mixed-25_2_test",
511-
"//pkg/sql/logictest/tests/local-schema-locked:local-schema-locked_test",
512510
"//pkg/sql/logictest/tests/local-vec-off:local-vec-off_test",
513511
"//pkg/sql/logictest/tests/local:local_test",
514512
"//pkg/sql/logictest/tests/multiregion-9node-3region-3azs:multiregion-9node-3region-3azs_test",
@@ -526,7 +524,6 @@ ALL_TESTS = [
526524
"//pkg/sql/opt/exec/execbuilder/tests/fakedist:fakedist_test",
527525
"//pkg/sql/opt/exec/execbuilder/tests/local-legacy-schema-changer:local-legacy-schema-changer_test",
528526
"//pkg/sql/opt/exec/execbuilder/tests/local-mixed-25.2:local-mixed-25_2_test",
529-
"//pkg/sql/opt/exec/execbuilder/tests/local-schema-locked:local-schema-locked_test",
530527
"//pkg/sql/opt/exec/execbuilder/tests/local-vec-off:local-vec-off_test",
531528
"//pkg/sql/opt/exec/execbuilder/tests/local:local_test",
532529
"//pkg/sql/opt/exec/execbuilder:execbuilder_test",
@@ -632,7 +629,6 @@ ALL_TESTS = [
632629
"//pkg/sql/sqlitelogictest/tests/local-mixed-25.2:local-mixed-25_2_test",
633630
"//pkg/sql/sqlitelogictest/tests/local-read-committed:local-read-committed_test",
634631
"//pkg/sql/sqlitelogictest/tests/local-repeatable-read:local-repeatable-read_test",
635-
"//pkg/sql/sqlitelogictest/tests/local-schema-locked:local-schema-locked_test",
636632
"//pkg/sql/sqlitelogictest/tests/local-vec-off:local-vec-off_test",
637633
"//pkg/sql/sqlitelogictest/tests/local:local_test",
638634
"//pkg/sql/sqlliveness/slinstance:slinstance_test",
@@ -964,7 +960,6 @@ GO_TARGETS = [
964960
"//pkg/ccl/logictestccl/tests/local-mixed-25.2:local-mixed-25_2_test",
965961
"//pkg/ccl/logictestccl/tests/local-read-committed:local-read-committed_test",
966962
"//pkg/ccl/logictestccl/tests/local-repeatable-read:local-repeatable-read_test",
967-
"//pkg/ccl/logictestccl/tests/local-schema-locked:local-schema-locked_test",
968963
"//pkg/ccl/logictestccl/tests/local-vec-off:local-vec-off_test",
969964
"//pkg/ccl/logictestccl/tests/local:local_test",
970965
"//pkg/ccl/logictestccl/tests/multiregion-15node-5region-3azs:multiregion-15node-5region-3azs_test",
@@ -2032,7 +2027,6 @@ GO_TARGETS = [
20322027
"//pkg/sql/logictest/tests/fakedist:fakedist_test",
20332028
"//pkg/sql/logictest/tests/local-legacy-schema-changer:local-legacy-schema-changer_test",
20342029
"//pkg/sql/logictest/tests/local-mixed-25.2:local-mixed-25_2_test",
2035-
"//pkg/sql/logictest/tests/local-schema-locked:local-schema-locked_test",
20362030
"//pkg/sql/logictest/tests/local-vec-off:local-vec-off_test",
20372031
"//pkg/sql/logictest/tests/local:local_test",
20382032
"//pkg/sql/logictest/tests/multiregion-9node-3region-3azs:multiregion-9node-3region-3azs_test",
@@ -2059,7 +2053,6 @@ GO_TARGETS = [
20592053
"//pkg/sql/opt/exec/execbuilder/tests/fakedist:fakedist_test",
20602054
"//pkg/sql/opt/exec/execbuilder/tests/local-legacy-schema-changer:local-legacy-schema-changer_test",
20612055
"//pkg/sql/opt/exec/execbuilder/tests/local-mixed-25.2:local-mixed-25_2_test",
2062-
"//pkg/sql/opt/exec/execbuilder/tests/local-schema-locked:local-schema-locked_test",
20632056
"//pkg/sql/opt/exec/execbuilder/tests/local-vec-off:local-vec-off_test",
20642057
"//pkg/sql/opt/exec/execbuilder/tests/local:local_test",
20652058
"//pkg/sql/opt/exec/execbuilder:execbuilder",
@@ -2312,7 +2305,6 @@ GO_TARGETS = [
23122305
"//pkg/sql/sqlitelogictest/tests/local-mixed-25.2:local-mixed-25_2_test",
23132306
"//pkg/sql/sqlitelogictest/tests/local-read-committed:local-read-committed_test",
23142307
"//pkg/sql/sqlitelogictest/tests/local-repeatable-read:local-repeatable-read_test",
2315-
"//pkg/sql/sqlitelogictest/tests/local-schema-locked:local-schema-locked_test",
23162308
"//pkg/sql/sqlitelogictest/tests/local-vec-off:local-vec-off_test",
23172309
"//pkg/sql/sqlitelogictest/tests/local:local_test",
23182310
"//pkg/sql/sqlitelogictest:sqlitelogictest",

pkg/ccl/logictestccl/testdata/logic_test/alter_table_locality

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# LogicTest: multiregion-9node-3region-3azs multiregion-9node-3region-3azs-no-los
22

3+
# Disable schema_locked for this test since alter table
4+
# locality is only in the legacy schema changer.
5+
statement ok
6+
SET create_table_with_schema_locked=false
7+
38
statement ok
49
CREATE DATABASE alter_locality_test primary region "ca-central-1" regions "ap-southeast-2", "us-east-1"
510

pkg/ccl/logictestccl/testdata/logic_test/auto_rehoming

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ db.public.rbr CREATE TABLE public.rbr (
2424
s STRING NULL,
2525
crdb_region public.crdb_internal_region NOT VISIBLE NOT NULL DEFAULT default_to_database_primary_region(gateway_region())::public.crdb_internal_region ON UPDATE rehome_row()::public.crdb_internal_region,
2626
CONSTRAINT rbr_pkey PRIMARY KEY (p ASC)
27-
) LOCALITY REGIONAL BY ROW;
27+
) WITH (schema_locked = true) LOCALITY REGIONAL BY ROW;
2828

2929

30+
# Locality cannot be modified with schema_locked set, until declarative
31+
# schema changer support is added.
3032
statement ok
31-
CREATE TABLE db.rbr_altered (p INT PRIMARY KEY) LOCALITY REGIONAL BY TABLE IN PRIMARY REGION
33+
CREATE TABLE db.rbr_altered (p INT PRIMARY KEY) WITH (schema_locked=false) LOCALITY REGIONAL BY TABLE IN PRIMARY REGION
3234

3335
statement ok
3436
ALTER TABLE db.rbr_altered SET LOCALITY REGIONAL BY ROW

pkg/ccl/logictestccl/testdata/logic_test/case_sensitive_names

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ p CREATE TABLE public.p (
1717
PARTITION p1 VALUES IN ((1)),
1818
PARTITION "P1" VALUES IN ((2)),
1919
PARTITION "Amélie" VALUES IN ((3))
20-
)
20+
) WITH (schema_locked = true)
2121
-- Warning: Partitioned table with no zone configurations.
2222
;

pkg/ccl/logictestccl/testdata/logic_test/multi_region

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ CREATE TABLE public.regional_primary_region_table (
396396
a INT8 NULL,
397397
rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(),
398398
CONSTRAINT regional_primary_region_table_pkey PRIMARY KEY (rowid ASC)
399-
) LOCALITY REGIONAL BY TABLE IN PRIMARY REGION;
399+
) WITH (schema_locked = true) LOCALITY REGIONAL BY TABLE IN PRIMARY REGION;
400400

401401
query TT
402402
SHOW ZONE CONFIGURATION FOR TABLE regional_primary_region_table
@@ -431,7 +431,7 @@ CREATE TABLE public.regional_implicit_primary_region_table (
431431
a INT8 NULL,
432432
rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(),
433433
CONSTRAINT regional_implicit_primary_region_table_pkey PRIMARY KEY (rowid ASC)
434-
) LOCALITY REGIONAL BY TABLE IN PRIMARY REGION;
434+
) WITH (schema_locked = true) LOCALITY REGIONAL BY TABLE IN PRIMARY REGION;
435435

436436
query TT
437437
SHOW ZONE CONFIGURATION FOR TABLE regional_implicit_primary_region_table
@@ -456,7 +456,7 @@ CREATE TABLE public."regional_us-east-1_table" (
456456
a INT8 NULL,
457457
rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(),
458458
CONSTRAINT "regional_us-east-1_table_pkey" PRIMARY KEY (rowid ASC)
459-
) LOCALITY REGIONAL BY TABLE IN "us-east-1";
459+
) WITH (schema_locked = true) LOCALITY REGIONAL BY TABLE IN "us-east-1";
460460

461461
query TT
462462
SHOW ZONE CONFIGURATION FOR TABLE "regional_us-east-1_table"
@@ -484,7 +484,7 @@ CREATE TABLE public.global_table (
484484
a INT8 NULL,
485485
rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(),
486486
CONSTRAINT global_table_pkey PRIMARY KEY (rowid ASC)
487-
) LOCALITY GLOBAL;
487+
) WITH (schema_locked = true) LOCALITY GLOBAL;
488488

489489
query TT
490490
SHOW ZONE CONFIGURATION FOR TABLE global_table
@@ -1071,7 +1071,7 @@ CREATE TABLE public.t (
10711071
k INT8 NULL,
10721072
rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(),
10731073
CONSTRAINT t_pkey PRIMARY KEY (rowid ASC)
1074-
) LOCALITY REGIONAL BY TABLE IN PRIMARY REGION;
1074+
) WITH (schema_locked = true) LOCALITY REGIONAL BY TABLE IN PRIMARY REGION;
10751075

10761076
statement ok
10771077
CREATE DATABASE non_multi_region_db
@@ -1230,18 +1230,30 @@ CREATE TABLE southeast() LOCALITY REGIONAL BY TABLE IN "ap-southeast-2"
12301230
statement error pq: could not remove enum value "ap-southeast-2" as it is the home region for table "southeast"
12311231
ALTER DATABASE drop_regions_alter_patterns DROP REGION "ap-southeast-2"
12321232

1233+
statement ok
1234+
ALTER TABLE southeast SET (schema_locked=false)
1235+
12331236
statement ok
12341237
ALTER TABLE southeast SET LOCALITY REGIONAL BY TABLE IN PRIMARY REGION
12351238

1239+
statement ok
1240+
ALTER TABLE southeast SET (schema_locked=true)
1241+
12361242
statement ok
12371243
ALTER DATABASE drop_regions_alter_patterns DROP REGION "ap-southeast-2"
12381244

12391245
statement error pq: could not remove enum value "us-east-1" as it is the home region for table "east"
12401246
ALTER DATABASE drop_regions_alter_patterns DROP REGION "us-east-1"
12411247

1248+
statement ok
1249+
ALTER TABLE east SET (schema_locked=false)
1250+
12421251
statement ok
12431252
ALTER TABLE east SET LOCALITY GLOBAL
12441253

1254+
statement ok
1255+
ALTER TABLE east SET (schema_locked=true)
1256+
12451257
statement ok
12461258
ALTER DATABASE drop_regions_alter_patterns DROP REGION "us-east-1"
12471259

@@ -1329,6 +1341,9 @@ DATABASE drop_primary_regions_db ALTER DATABASE drop_primary_regions_db CONFIGU
13291341

13301342

13311343

1344+
statement ok
1345+
ALTER TABLE drop_primary_regions_db.primary SET (schema_locked = false);
1346+
13321347
statement ok
13331348
ALTER TABLE drop_primary_regions_db.primary SET LOCALITY REGIONAL BY TABLE IN "ca-central-1"
13341349

@@ -1338,6 +1353,9 @@ ALTER DATABASE drop_primary_regions_db DROP REGION "ca-central-1"
13381353
statement ok
13391354
ALTER TABLE drop_primary_regions_db.primary SET LOCALITY REGIONAL BY TABLE IN PRIMARY REGION
13401355

1356+
statement ok
1357+
ALTER TABLE drop_primary_regions_db.primary SET (schema_locked = true);
1358+
13411359
statement ok
13421360
ALTER DATABASE drop_primary_regions_db DROP REGION "ca-central-1"
13431361

@@ -1525,12 +1543,19 @@ CREATE TABLE public.t_as (
15251543
crdb_region public.crdb_internal_region NULL,
15261544
rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(),
15271545
CONSTRAINT t_as_pkey PRIMARY KEY (rowid ASC)
1528-
) LOCALITY REGIONAL BY TABLE IN PRIMARY REGION;
1546+
) WITH (schema_locked = true) LOCALITY REGIONAL BY TABLE IN PRIMARY REGION;
1547+
15291548

1549+
statement ok
1550+
ALTER TABLE t_as SET (schema_locked = false);
15301551

15311552
statement error cannot use column crdb_region for REGIONAL BY ROW table as it may contain NULL values
15321553
ALTER TABLE t_as SET LOCALITY REGIONAL BY ROW AS crdb_region
15331554

1555+
1556+
statement ok
1557+
ALTER TABLE t_as SET (schema_locked = true);
1558+
15341559
statement ok
15351560
ALTER TABLE t_as ALTER COLUMN crdb_region SET NOT NULL
15361561

@@ -1540,9 +1565,15 @@ ALTER TABLE t_as ALTER COLUMN crdb_region SET NOT VISIBLE
15401565
statement ok
15411566
ALTER TABLE t_as ALTER COLUMN crdb_region SET DEFAULT default_to_database_primary_region(gateway_region())::public.crdb_internal_region
15421567

1568+
statement ok
1569+
ALTER TABLE t_as SET (schema_locked = false);
1570+
15431571
statement ok
15441572
ALTER TABLE t_as SET LOCALITY REGIONAL BY ROW AS crdb_region
15451573

1574+
statement ok
1575+
ALTER TABLE t_as SET (schema_locked = true);
1576+
15461577
query T colnames
15471578
SELECT create_statement from [SHOW CREATE TABLE t_as]
15481579
----
@@ -1552,7 +1583,7 @@ CREATE TABLE public.t_as (
15521583
crdb_region public.crdb_internal_region NOT VISIBLE NOT NULL DEFAULT default_to_database_primary_region(gateway_region())::public.crdb_internal_region,
15531584
rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(),
15541585
CONSTRAINT t_as_pkey PRIMARY KEY (rowid ASC)
1555-
) LOCALITY REGIONAL BY ROW AS crdb_region;
1586+
) WITH (schema_locked = true) LOCALITY REGIONAL BY ROW AS crdb_region;
15561587

15571588
query TI colnames,rowsort
15581589
SELECT crdb_region, i FROM t_as
@@ -1594,7 +1625,7 @@ CREATE TABLE public.t_as (
15941625
i INT8 NOT NULL,
15951626
crdb_region public.crdb_internal_region NOT VISIBLE NOT NULL DEFAULT default_to_database_primary_region(gateway_region())::public.crdb_internal_region,
15961627
CONSTRAINT t_as_pkey PRIMARY KEY (i ASC)
1597-
) LOCALITY REGIONAL BY ROW AS crdb_region;
1628+
) WITH (schema_locked = true) LOCALITY REGIONAL BY ROW AS crdb_region;
15981629

15991630
query T colnames
16001631
SELECT create_statement from [SHOW CREATE TABLE t]
@@ -1604,7 +1635,7 @@ CREATE TABLE public.t (
16041635
i INT8 NOT NULL,
16051636
crdb_region public.crdb_internal_region NOT VISIBLE NOT NULL DEFAULT default_to_database_primary_region(gateway_region())::public.crdb_internal_region,
16061637
CONSTRAINT t_pkey PRIMARY KEY (i ASC)
1607-
) LOCALITY REGIONAL BY ROW;
1638+
) WITH (schema_locked = true) LOCALITY REGIONAL BY ROW;
16081639

16091640
# Declare victory, as this is the closest we can get.
16101641
statement ok

pkg/ccl/logictestccl/testdata/logic_test/multi_region_alter_table_regional_by_row

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ CREATE DATABASE region_test_db PRIMARY REGION "ap-southeast-2" SURVIVE ZONE FAIL
1010
statement ok
1111
USE region_test_db;
1212

13+
# This test is only focused on locality changes which are only supported
14+
# by the legacy schema changer.
1315
statement ok
14-
CREATE TABLE t (i INT8 NULL, INDEX (i));
16+
CREATE TABLE t (i INT8 NULL, INDEX (i)) WITH (schema_locked = false);
1517

1618
statement ok
1719
INSERT INTO t VALUES (1);

0 commit comments

Comments
 (0)