diff --git a/docs/generated/http/full.md b/docs/generated/http/full.md index 0058540ac85a..ee226f4f2aad 100644 --- a/docs/generated/http/full.md +++ b/docs/generated/http/full.md @@ -4181,6 +4181,7 @@ Response object returned by TableIndexStatsResponse. | index_name | [string](#cockroach.server.serverpb.TableIndexStatsResponse-string) | | index_name is the name of the index. | [reserved](#support-status) | | index_type | [string](#cockroach.server.serverpb.TableIndexStatsResponse-string) | | index_type is the type of the index i.e. primary, secondary. | [reserved](#support-status) | | create_statement | [string](#cockroach.server.serverpb.TableIndexStatsResponse-string) | | create_statement is the SQL statement that would re-create the current index if executed. | [reserved](#support-status) | +| created_at | [google.protobuf.Timestamp](#cockroach.server.serverpb.TableIndexStatsResponse-google.protobuf.Timestamp) | | CreatedAt is an approximate timestamp at which the index was created. Note that it may not always be populated. | [reserved](#support-status) | diff --git a/pkg/ccl/backupccl/show_test.go b/pkg/ccl/backupccl/show_test.go index b78f8b177415..4d20984aec9a 100644 --- a/pkg/ccl/backupccl/show_test.go +++ b/pkg/ccl/backupccl/show_test.go @@ -236,8 +236,7 @@ ORDER BY object_type, object_name`, full) a INT8 NOT NULL, b INT8 NULL, CONSTRAINT tablea_pkey PRIMARY KEY (a ASC), - INDEX tablea_b_idx (b ASC), - FAMILY "primary" (a, b) + INDEX tablea_b_idx (b ASC) )` expectedCreateView := "CREATE VIEW viewa (\n\ta\n) AS SELECT a FROM data.public.tablea" expectedCreateSeq := `CREATE SEQUENCE seqa MINVALUE 1 MAXVALUE 20 INCREMENT 2 START 1` @@ -271,15 +270,13 @@ ORDER BY object_type, object_name`, full) a INT8 NOT NULL, b INT8 NULL, CONSTRAINT fkreftable_pkey PRIMARY KEY (a ASC), - CONSTRAINT fkreftable_b_fkey FOREIGN KEY (b) REFERENCES public.fksrc(a), - FAMILY "primary" (a, b) + CONSTRAINT fkreftable_b_fkey FOREIGN KEY (b) REFERENCES public.fksrc(a) )` wantDiffDB := `CREATE TABLE fkreftable ( a INT8 NOT NULL, b INT8 NULL, CONSTRAINT fkreftable_pkey PRIMARY KEY (a ASC), - CONSTRAINT fkreftable_b_fkey FOREIGN KEY (b) REFERENCES data.public.fksrc(a), - FAMILY "primary" (a, b) + CONSTRAINT fkreftable_b_fkey FOREIGN KEY (b) REFERENCES data.public.fksrc(a) )` showBackupRows = sqlDBRestore.QueryStr(t, fmt.Sprintf(`SELECT create_statement FROM [SHOW BACKUP SCHEMAS '%s'] WHERE object_type='table'`, includedFK)) @@ -303,8 +300,7 @@ ORDER BY object_type, object_name`, full) want := `CREATE TABLE fkreftable ( a INT8 NOT NULL, b INT8 NULL, - CONSTRAINT fkreftable_pkey PRIMARY KEY (a ASC), - FAMILY "primary" (a, b) + CONSTRAINT fkreftable_pkey PRIMARY KEY (a ASC) )` showBackupRows = sqlDBRestore.QueryStr(t, fmt.Sprintf(`SELECT create_statement FROM [SHOW BACKUP SCHEMAS '%s'] WHERE object_type='table'`, missingFK)) @@ -607,15 +603,15 @@ func showUpgradedForeignKeysTest(exportDir string) func(t *testing.T) { for _, tc := range []testCase{ { "circular", - "CONSTRAINT self_fk FOREIGN KEY \\(selfid\\) REFERENCES public\\.circular\\(selfid\\) NOT VALID,", + "CONSTRAINT self_fk FOREIGN KEY \\(selfid\\) REFERENCES public\\.circular\\(selfid\\) NOT VALID", }, { "child", - "CONSTRAINT \\w+ FOREIGN KEY \\(\\w+\\) REFERENCES public\\.parent\\(\\w+\\),", + "CONSTRAINT \\w+ FOREIGN KEY \\(\\w+\\) REFERENCES public\\.parent\\(\\w+\\)", }, { "child_pk", - "CONSTRAINT \\w+ FOREIGN KEY \\(\\w+\\) REFERENCES public\\.parent\\(\\w+\\),", + "CONSTRAINT \\w+ FOREIGN KEY \\(\\w+\\) REFERENCES public\\.parent\\(\\w+\\)", }, } { results := sqlDB.QueryStr(t, ` diff --git a/pkg/ccl/backupccl/testdata/backup-restore/virtual-columns b/pkg/ccl/backupccl/testdata/backup-restore/virtual-columns index 819cf7c9196f..3a64f4f37016 100644 --- a/pkg/ccl/backupccl/testdata/backup-restore/virtual-columns +++ b/pkg/ccl/backupccl/testdata/backup-restore/virtual-columns @@ -46,6 +46,5 @@ d.public.tab CREATE TABLE public.tab ( v INT8 NULL AS (a + b) VIRTUAL, CONSTRAINT tab_pkey PRIMARY KEY (k ASC), INDEX tab_v_idx (v ASC), - UNIQUE INDEX tab_a_b_key (a ASC, b ASC) WHERE v > 0:::INT8, - FAMILY "primary" (k, a, b) + UNIQUE INDEX tab_a_b_key (a ASC, b ASC) WHERE v > 0:::INT8 ) diff --git a/pkg/ccl/importccl/import_stmt_test.go b/pkg/ccl/importccl/import_stmt_test.go index eaf67d1d4f1f..6c502b67c408 100644 --- a/pkg/ccl/importccl/import_stmt_test.go +++ b/pkg/ccl/importccl/import_stmt_test.go @@ -877,14 +877,12 @@ END; k INT8 NULL, CONSTRAINT a_pkey PRIMARY KEY (i ASC), CONSTRAINT a_i_fkey FOREIGN KEY (i) REFERENCES public.b(j) NOT VALID, - CONSTRAINT a_k_fkey FOREIGN KEY (k) REFERENCES public.a(i) NOT VALID, - FAMILY "primary" (i, k) + CONSTRAINT a_k_fkey FOREIGN KEY (k) REFERENCES public.a(i) NOT VALID )`}, { `CREATE TABLE public.b ( j INT8 NOT NULL, CONSTRAINT b_pkey PRIMARY KEY (j ASC), - CONSTRAINT b_j_fkey FOREIGN KEY (j) REFERENCES public.a(i) NOT VALID, - FAMILY "primary" (j) + CONSTRAINT b_j_fkey FOREIGN KEY (j) REFERENCES public.a(i) NOT VALID )`, }}, @@ -996,8 +994,7 @@ END; `CREATE TABLE public.t ( a INT8 NOT NULL, b INT8 NOT NULL, - CONSTRAINT t_pkey PRIMARY KEY (a ASC), - FAMILY "primary" (a, b) + CONSTRAINT t_pkey PRIMARY KEY (a ASC) )`, }, }, @@ -1019,8 +1016,7 @@ END; a INT8 NOT NULL, b INT8 NOT VISIBLE NULL, c INT8 NULL, - CONSTRAINT t_pkey PRIMARY KEY (a ASC), - FAMILY "primary" (a, b, c) + CONSTRAINT t_pkey PRIMARY KEY (a ASC) )`, }, }, @@ -1040,8 +1036,7 @@ END; `CREATE TABLE public.t ( a INT8 NOT NULL, b INT8 NULL DEFAULT 8:::INT8, - CONSTRAINT t_pkey PRIMARY KEY (a ASC), - FAMILY "primary" (a, b) + CONSTRAINT t_pkey PRIMARY KEY (a ASC) )`, }, }, @@ -1470,8 +1465,7 @@ END const ( testPgdumpCreateCities = `CREATE TABLE public.cities ( city VARCHAR(80) NOT NULL, - CONSTRAINT cities_pkey PRIMARY KEY (city ASC), - FAMILY "primary" (city) + CONSTRAINT cities_pkey PRIMARY KEY (city ASC) )` testPgdumpCreateWeather = `CREATE TABLE public.weather ( city VARCHAR(80) NULL, @@ -1481,8 +1475,7 @@ const ( date DATE NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), CONSTRAINT weather_pkey PRIMARY KEY (rowid ASC), - CONSTRAINT weather_city_fkey FOREIGN KEY (city) REFERENCES public.cities(city) NOT VALID, - FAMILY "primary" (city, temp_lo, temp_hi, prcp, date, rowid) + CONSTRAINT weather_city_fkey FOREIGN KEY (city) REFERENCES public.cities(city) NOT VALID )` testPgdumpFk = ` CREATE TABLE public.cities ( @@ -5479,8 +5472,7 @@ func TestImportPgDump(t *testing.T) { b BYTES NULL, CONSTRAINT simple_pkey PRIMARY KEY (i ASC), UNIQUE INDEX simple_b_s_idx (b ASC, s ASC), - INDEX simple_s_idx (s ASC), - FAMILY "primary" (i, s, b) + INDEX simple_s_idx (s ASC) )`, }}) @@ -5518,8 +5510,7 @@ func TestImportPgDump(t *testing.T) { "second", `CREATE TABLE public.second ( i INT8 NOT NULL, s STRING NULL, - CONSTRAINT second_pkey PRIMARY KEY (i ASC), - FAMILY "primary" (i, s) + CONSTRAINT second_pkey PRIMARY KEY (i ASC) )`, }}) res := sqlDB.QueryStr(t, "SELECT * FROM second ORDER BY i") @@ -5545,8 +5536,7 @@ func TestImportPgDump(t *testing.T) { a INT8 NULL DEFAULT nextval('public.a_seq'::REGCLASS), b INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT seqtable_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, b, rowid) + CONSTRAINT seqtable_pkey PRIMARY KEY (rowid ASC) )`, }}) sqlDB.CheckQueryResults(t, `SHOW CREATE SEQUENCE a_seq`, [][]string{{ @@ -6198,16 +6188,14 @@ func TestImportCockroachDump(t *testing.T) { i INT8 NOT NULL, t STRING NULL, CONSTRAINT "primary" PRIMARY KEY (i ASC), - INDEX t_t_idx (t ASC), - FAMILY "primary" (i, t) + INDEX t_t_idx (t ASC) )`}, }) sqlDB.CheckQueryResults(t, "SHOW CREATE TABLE a", [][]string{ {"a", `CREATE TABLE public.a ( i INT8 NOT NULL, CONSTRAINT "primary" PRIMARY KEY (i ASC), - CONSTRAINT fk_i_ref_t FOREIGN KEY (i) REFERENCES public.t(i) NOT VALID, - FAMILY "primary" (i) + CONSTRAINT fk_i_ref_t FOREIGN KEY (i) REFERENCES public.t(i) NOT VALID )`}, }) } diff --git a/pkg/ccl/importccl/import_table_creation.go b/pkg/ccl/importccl/import_table_creation.go index 2dfec9aca408..fc6a240c23a3 100644 --- a/pkg/ccl/importccl/import_table_creation.go +++ b/pkg/ccl/importccl/import_table_creation.go @@ -34,6 +34,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/types" "github.com/cockroachdb/cockroach/pkg/util/errorutil/unimplemented" "github.com/cockroachdb/cockroach/pkg/util/hlc" + "github.com/cockroachdb/cockroach/pkg/util/timeutil" "github.com/cockroachdb/errors" "github.com/lib/pq/oid" ) @@ -168,6 +169,7 @@ func MakeSimpleTableDescriptor( Regions: makeImportRegionOperator(""), SessionDataStack: sessiondata.NewStack(&sessiondata.SessionData{}), ClientNoticeSender: &faketreeeval.DummyClientNoticeSender{}, + TxnTimestamp: timeutil.Unix(0, walltime), Settings: st, } affected := make(map[descpb.ID]*tabledesc.Mutable) diff --git a/pkg/ccl/logictestccl/testdata/logic_test/alter_table_locality b/pkg/ccl/logictestccl/testdata/logic_test/alter_table_locality index d4e499e3e31d..fbfd7ccda1c9 100644 --- a/pkg/ccl/logictestccl/testdata/logic_test/alter_table_locality +++ b/pkg/ccl/logictestccl/testdata/logic_test/alter_table_locality @@ -1224,8 +1224,7 @@ SHOW CREATE TABLE regional_by_table_no_region regional_by_table_no_region CREATE TABLE public.regional_by_table_no_region ( i INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT regional_by_table_no_region_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (i, rowid) + CONSTRAINT regional_by_table_no_region_pkey PRIMARY KEY (rowid ASC) ) LOCALITY REGIONAL BY TABLE IN PRIMARY REGION query TTT @@ -1273,8 +1272,7 @@ SHOW CREATE TABLE regional_by_table_no_region regional_by_table_no_region CREATE TABLE public.regional_by_table_no_region ( i INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT regional_by_table_no_region_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (i, rowid) + CONSTRAINT regional_by_table_no_region_pkey PRIMARY KEY (rowid ASC) ) LOCALITY GLOBAL query TTT diff --git a/pkg/ccl/logictestccl/testdata/logic_test/auto_rehoming b/pkg/ccl/logictestccl/testdata/logic_test/auto_rehoming index fe900638df85..581d983896dd 100644 --- a/pkg/ccl/logictestccl/testdata/logic_test/auto_rehoming +++ b/pkg/ccl/logictestccl/testdata/logic_test/auto_rehoming @@ -23,8 +23,7 @@ db.public.rbr CREATE TABLE public.rbr ( p INT8 NOT NULL, s STRING NULL, 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, - CONSTRAINT rbr_pkey PRIMARY KEY (p ASC), - FAMILY "primary" (p, s, crdb_region) + CONSTRAINT rbr_pkey PRIMARY KEY (p ASC) ) LOCALITY REGIONAL BY ROW @@ -40,6 +39,5 @@ SHOW CREATE TABLE db.rbr_altered db.public.rbr_altered CREATE TABLE public.rbr_altered ( p INT8 NOT NULL, 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, - CONSTRAINT rbr_altered_pkey PRIMARY KEY (p ASC), - FAMILY "primary" (p, crdb_region) + CONSTRAINT rbr_altered_pkey PRIMARY KEY (p ASC) ) LOCALITY REGIONAL BY ROW diff --git a/pkg/ccl/logictestccl/testdata/logic_test/case_sensitive_names b/pkg/ccl/logictestccl/testdata/logic_test/case_sensitive_names index 3447ad9b9ba7..0d77bdbebdc5 100644 --- a/pkg/ccl/logictestccl/testdata/logic_test/case_sensitive_names +++ b/pkg/ccl/logictestccl/testdata/logic_test/case_sensitive_names @@ -12,8 +12,7 @@ SHOW CREATE TABLE p ---- p CREATE TABLE public.p ( a INT8 NOT NULL, - CONSTRAINT p_pkey PRIMARY KEY (a ASC), - FAMILY "primary" (a) + CONSTRAINT p_pkey PRIMARY KEY (a ASC) ) PARTITION BY LIST (a) ( PARTITION p1 VALUES IN ((1)), PARTITION "P1" VALUES IN ((2)), diff --git a/pkg/ccl/logictestccl/testdata/logic_test/crdb_internal_tenant b/pkg/ccl/logictestccl/testdata/logic_test/crdb_internal_tenant index 670e099bbeb7..c4477aa8a6fd 100644 --- a/pkg/ccl/logictestccl/testdata/logic_test/crdb_internal_tenant +++ b/pkg/ccl/logictestccl/testdata/logic_test/crdb_internal_tenant @@ -275,10 +275,10 @@ SELECT * FROM crdb_internal.table_columns WHERE descriptor_name = '' ---- descriptor_id descriptor_name column_id column_name column_type nullable default_expr hidden -query ITITTBBB colnames +query ITITTBBBT colnames SELECT * FROM crdb_internal.table_indexes WHERE descriptor_name = '' ---- -descriptor_id descriptor_name index_id index_name index_type is_unique is_inverted is_sharded +descriptor_id descriptor_name index_id index_name index_type is_unique is_inverted is_sharded created_at query ITITTITTB colnames SELECT * FROM crdb_internal.index_columns WHERE descriptor_name = '' diff --git a/pkg/ccl/logictestccl/testdata/logic_test/multi_region b/pkg/ccl/logictestccl/testdata/logic_test/multi_region index 28b6bd835300..0f506d15d014 100644 --- a/pkg/ccl/logictestccl/testdata/logic_test/multi_region +++ b/pkg/ccl/logictestccl/testdata/logic_test/multi_region @@ -385,8 +385,7 @@ SELECT create_statement FROM [SHOW CREATE TABLE regional_primary_region_table] CREATE TABLE public.regional_primary_region_table ( a INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT regional_primary_region_table_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, rowid) + CONSTRAINT regional_primary_region_table_pkey PRIMARY KEY (rowid ASC) ) LOCALITY REGIONAL BY TABLE IN PRIMARY REGION query TT @@ -421,8 +420,7 @@ SELECT create_statement FROM [SHOW CREATE TABLE regional_implicit_primary_region CREATE TABLE public.regional_implicit_primary_region_table ( a INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT regional_implicit_primary_region_table_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, rowid) + CONSTRAINT regional_implicit_primary_region_table_pkey PRIMARY KEY (rowid ASC) ) LOCALITY REGIONAL BY TABLE IN PRIMARY REGION query TT @@ -447,8 +445,7 @@ SELECT create_statement FROM [SHOW CREATE TABLE "regional_us-east-1_table"] CREATE TABLE public."regional_us-east-1_table" ( a INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT "regional_us-east-1_table_pkey" PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, rowid) + CONSTRAINT "regional_us-east-1_table_pkey" PRIMARY KEY (rowid ASC) ) LOCALITY REGIONAL BY TABLE IN "us-east-1" query TT @@ -476,8 +473,7 @@ SELECT create_statement FROM [SHOW CREATE TABLE global_table] CREATE TABLE public.global_table ( a INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT global_table_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, rowid) + CONSTRAINT global_table_pkey PRIMARY KEY (rowid ASC) ) LOCALITY GLOBAL query TT @@ -1030,8 +1026,7 @@ SELECT create_statement FROM [SHOW CREATE TABLE no_initial_region.t] CREATE TABLE public.t ( k INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT t_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (k, rowid) + CONSTRAINT t_pkey PRIMARY KEY (rowid ASC) ) LOCALITY REGIONAL BY TABLE IN PRIMARY REGION statement ok @@ -1457,8 +1452,7 @@ CREATE TABLE public.t_as ( i INT8 NULL, crdb_region public.crdb_internal_region NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT t_as_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (i, crdb_region, rowid) + CONSTRAINT t_as_pkey PRIMARY KEY (rowid ASC) ) LOCALITY REGIONAL BY TABLE IN PRIMARY REGION @@ -1485,8 +1479,7 @@ CREATE TABLE public.t_as ( i INT8 NULL, crdb_region public.crdb_internal_region NOT VISIBLE NOT NULL DEFAULT default_to_database_primary_region(gateway_region())::public.crdb_internal_region, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT t_as_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (i, crdb_region, rowid) + CONSTRAINT t_as_pkey PRIMARY KEY (rowid ASC) ) LOCALITY REGIONAL BY ROW AS crdb_region query TI colnames @@ -1528,8 +1521,7 @@ create_statement CREATE TABLE public.t_as ( i INT8 NOT NULL, crdb_region public.crdb_internal_region NOT VISIBLE NOT NULL DEFAULT default_to_database_primary_region(gateway_region())::public.crdb_internal_region, - CONSTRAINT t_as_pkey PRIMARY KEY (i ASC), - FAMILY "primary" (i, crdb_region) + CONSTRAINT t_as_pkey PRIMARY KEY (i ASC) ) LOCALITY REGIONAL BY ROW AS crdb_region query T colnames @@ -1539,8 +1531,7 @@ create_statement CREATE TABLE public.t ( i INT8 NOT NULL, crdb_region public.crdb_internal_region NOT VISIBLE NOT NULL DEFAULT default_to_database_primary_region(gateway_region())::public.crdb_internal_region, - CONSTRAINT t_pkey PRIMARY KEY (i ASC), - FAMILY "primary" (i, crdb_region) + CONSTRAINT t_pkey PRIMARY KEY (i ASC) ) LOCALITY REGIONAL BY ROW # Declare victory, as this is the closest we can get. diff --git a/pkg/ccl/logictestccl/testdata/logic_test/multi_region_backup b/pkg/ccl/logictestccl/testdata/logic_test/multi_region_backup index 9b384e5bf0f7..dee4eddaa12e 100644 --- a/pkg/ccl/logictestccl/testdata/logic_test/multi_region_backup +++ b/pkg/ccl/logictestccl/testdata/logic_test/multi_region_backup @@ -1241,8 +1241,7 @@ SHOW CREATE TABLE non_mr_table non_mr_table CREATE TABLE public.non_mr_table ( i INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT non_mr_table_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (i, rowid) + CONSTRAINT non_mr_table_pkey PRIMARY KEY (rowid ASC) ) LOCALITY REGIONAL BY TABLE IN PRIMARY REGION diff --git a/pkg/ccl/logictestccl/testdata/logic_test/multi_region_import_export b/pkg/ccl/logictestccl/testdata/logic_test/multi_region_import_export index 703d75d3b577..84c2e2217202 100644 --- a/pkg/ccl/logictestccl/testdata/logic_test/multi_region_import_export +++ b/pkg/ccl/logictestccl/testdata/logic_test/multi_region_import_export @@ -99,6 +99,5 @@ team CREATE TABLE public.team ( name STRING NULL, likes STRING[] NULL, dislikes STRING[] NULL, - CONSTRAINT team_pkey PRIMARY KEY (id ASC), - FAMILY "primary" (id, name, likes, dislikes) + CONSTRAINT team_pkey PRIMARY KEY (id ASC) ) LOCALITY REGIONAL BY TABLE IN PRIMARY REGION diff --git a/pkg/ccl/logictestccl/testdata/logic_test/partitioning b/pkg/ccl/logictestccl/testdata/logic_test/partitioning index 5a2eddd1015e..89fdd9272609 100644 --- a/pkg/ccl/logictestccl/testdata/logic_test/partitioning +++ b/pkg/ccl/logictestccl/testdata/logic_test/partitioning @@ -390,8 +390,7 @@ ok1 CREATE TABLE public.ok1 ( a INT8 NOT NULL, b INT8 NOT NULL, c INT8 NULL, - CONSTRAINT ok1_pkey PRIMARY KEY (a ASC, b ASC), - FAMILY "primary" (a, b, c) + CONSTRAINT ok1_pkey PRIMARY KEY (a ASC, b ASC) ) PARTITION BY LIST (a) ( PARTITION p1 VALUES IN ((1)), PARTITION p2 VALUES IN ((2)) @@ -443,8 +442,7 @@ ok2 CREATE TABLE public.ok2 ( a INT8 NOT NULL, b INT8 NOT NULL, c INT8 NULL, - CONSTRAINT ok2_pkey PRIMARY KEY (a ASC, b ASC), - FAMILY "primary" (a, b, c) + CONSTRAINT ok2_pkey PRIMARY KEY (a ASC, b ASC) ) PARTITION BY LIST (a) ( PARTITION p1 VALUES IN ((1)), PARTITION p2 VALUES IN ((2)) @@ -491,8 +489,7 @@ ok3 CREATE TABLE public.ok3 ( a INT8 NOT NULL, b INT8 NOT NULL, c INT8 NULL, - CONSTRAINT ok3_pkey PRIMARY KEY (a ASC, b ASC), - FAMILY "primary" (a, b, c) + CONSTRAINT ok3_pkey PRIMARY KEY (a ASC, b ASC) ) PARTITION BY LIST (a) ( PARTITION p1 VALUES IN ((1)), PARTITION p2 VALUES IN ((DEFAULT)) @@ -541,8 +538,7 @@ ok4 CREATE TABLE public.ok4 ( a INT8 NOT NULL, b INT8 NOT NULL, c INT8 NULL, - CONSTRAINT ok4_pkey PRIMARY KEY (a ASC, b ASC), - FAMILY "primary" (a, b, c) + CONSTRAINT ok4_pkey PRIMARY KEY (a ASC, b ASC) ) PARTITION BY LIST (a, b) ( PARTITION p1 VALUES IN ((1, 1)), PARTITION p2 VALUES IN ((1, DEFAULT)), @@ -631,8 +627,7 @@ ok5 CREATE TABLE public.ok5 ( a INT8 NOT NULL, b INT8 NOT NULL, c INT8 NULL, - CONSTRAINT ok5_pkey PRIMARY KEY (a ASC, b ASC), - FAMILY "primary" (a, b, c) + CONSTRAINT ok5_pkey PRIMARY KEY (a ASC, b ASC) ) PARTITION BY LIST (a) ( PARTITION p1 VALUES IN ((1)) PARTITION BY LIST (b) ( PARTITION p1_1 VALUES IN ((1)), @@ -664,8 +659,7 @@ ok6 CREATE TABLE public.ok6 ( a INT8 NOT NULL, b INT8 NOT NULL, c INT8 NULL, - CONSTRAINT ok6_pkey PRIMARY KEY (a ASC, b ASC), - FAMILY "primary" (a, b, c) + CONSTRAINT ok6_pkey PRIMARY KEY (a ASC, b ASC) ) PARTITION BY RANGE (a) ( PARTITION p1 VALUES FROM (0) TO (1), PARTITION p2 VALUES FROM (1) TO (2) @@ -702,8 +696,7 @@ ok7 CREATE TABLE public.ok7 ( a INT8 NOT NULL, b INT8 NOT NULL, c INT8 NULL, - CONSTRAINT ok7_pkey PRIMARY KEY (a ASC, b ASC), - FAMILY "primary" (a, b, c) + CONSTRAINT ok7_pkey PRIMARY KEY (a ASC, b ASC) ) PARTITION BY RANGE (a) ( PARTITION p1 VALUES FROM (0) TO (1) ) @@ -743,8 +736,7 @@ ok8 CREATE TABLE public.ok8 ( a INT8 NOT NULL, b INT8 NOT NULL, c INT8 NULL, - CONSTRAINT ok8_pkey PRIMARY KEY (a ASC, b ASC), - FAMILY "primary" (a, b, c) + CONSTRAINT ok8_pkey PRIMARY KEY (a ASC, b ASC) ) PARTITION BY RANGE (a) ( PARTITION p1 VALUES FROM (MINVALUE) TO (1), PARTITION p2 VALUES FROM (1) TO (2), @@ -787,8 +779,7 @@ ok9 CREATE TABLE public.ok9 ( a INT8 NOT NULL, b INT8 NOT NULL, c INT8 NULL, - CONSTRAINT ok9_pkey PRIMARY KEY (a ASC, b ASC), - FAMILY "primary" (a, b, c) + CONSTRAINT ok9_pkey PRIMARY KEY (a ASC, b ASC) ) PARTITION BY RANGE (a, b) ( PARTITION p1 VALUES FROM (MINVALUE, MINVALUE) TO (1, MAXVALUE), PARTITION p2 VALUES FROM (1, MAXVALUE) TO (3, MINVALUE), @@ -833,8 +824,7 @@ ok10 CREATE TABLE public.ok10 ( a INT8 NOT NULL, b INT8 NOT NULL, c INT8 NULL, - CONSTRAINT ok10_pkey PRIMARY KEY (a ASC, b ASC), - FAMILY "primary" (a, b, c) + CONSTRAINT ok10_pkey PRIMARY KEY (a ASC, b ASC) ) PARTITION BY RANGE (a, b) ( PARTITION p1 VALUES FROM (MINVALUE, MINVALUE) TO (1, 1), PARTITION p2 VALUES FROM (1, 1) TO (1, MAXVALUE), @@ -885,8 +875,7 @@ ok11 CREATE TABLE public.ok11 ( a INT8 NOT NULL, b INT8 NOT NULL, c INT8 NOT NULL, - CONSTRAINT ok11_pkey PRIMARY KEY (a ASC, b ASC, c ASC), - FAMILY "primary" (a, b, c) + CONSTRAINT ok11_pkey PRIMARY KEY (a ASC, b ASC, c ASC) ) PARTITION BY LIST (a) ( PARTITION p1 VALUES IN ((1)) PARTITION BY LIST (b) ( PARTITION p1_1 VALUES IN ((3)) PARTITION BY LIST (c) ( @@ -942,8 +931,7 @@ ok12 CREATE TABLE public.ok12 ( a INT8 NOT NULL, b INT8 NOT NULL, c INT8 NULL, - CONSTRAINT ok12_pkey PRIMARY KEY (a ASC, b ASC), - FAMILY "primary" (a, b, c) + CONSTRAINT ok12_pkey PRIMARY KEY (a ASC, b ASC) ) PARTITION BY LIST (a) ( PARTITION pu VALUES IN ((NULL)), PARTITION p1 VALUES IN ((1)), diff --git a/pkg/ccl/logictestccl/testdata/logic_test/partitioning_index b/pkg/ccl/logictestccl/testdata/logic_test/partitioning_index index 5a955b5554a1..666807fc3e1c 100644 --- a/pkg/ccl/logictestccl/testdata/logic_test/partitioning_index +++ b/pkg/ccl/logictestccl/testdata/logic_test/partitioning_index @@ -20,8 +20,7 @@ ok1 CREATE TABLE public.ok1 ( INDEX ok1_b_idx (b ASC) PARTITION BY LIST (b) ( PARTITION p1 VALUES IN ((1)), PARTITION pu VALUES IN ((NULL)) - ), - FAMILY "primary" (a, b) + ) ) -- Warning: Partitioned table with no zone configurations. @@ -48,8 +47,7 @@ ok2 CREATE TABLE public.ok2 ( CONSTRAINT ok2_pkey PRIMARY KEY (a ASC), UNIQUE INDEX ok2_b_key (b ASC) PARTITION BY LIST (b) ( PARTITION p1 VALUES IN ((1)) - ), - FAMILY "primary" (a, b) + ) ) -- Warning: Partitioned table with no zone configurations. @@ -82,8 +80,7 @@ ok3 CREATE TABLE public.ok3 ( ), UNIQUE INDEX ok3_b_key2 (b ASC) PARTITION BY LIST (b) ( PARTITION p2 VALUES IN ((1)) - ), - FAMILY "primary" (a, b) + ) ) -- Warning: Partitioned table with no zone configurations. @@ -146,8 +143,7 @@ indexes CREATE TABLE public.indexes ( ), INDEX i5 (b ASC) PARTITION BY LIST (b) ( PARTITION p1 VALUES IN ((1)) - ), - FAMILY "primary" (a, b) + ) ) -- Warning: Partitioned table with no zone configurations. @@ -180,8 +176,7 @@ inverted CREATE TABLE public.inverted ( ), INVERTED INDEX inv_idx (b, j) PARTITION BY LIST (b) ( PARTITION p1 VALUES IN ((1)) - ), - FAMILY "primary" (a, b, j) + ) ) -- Warning: Partitioned table with no zone configurations. diff --git a/pkg/ccl/logictestccl/testdata/logic_test/regional_by_row b/pkg/ccl/logictestccl/testdata/logic_test/regional_by_row index 06d0b3a433db..1f8cfabbb6c3 100644 --- a/pkg/ccl/logictestccl/testdata/logic_test/regional_by_row +++ b/pkg/ccl/logictestccl/testdata/logic_test/regional_by_row @@ -622,8 +622,7 @@ SELECT create_statement FROM [SHOW CREATE TABLE regional_by_row_table_pk_defined CREATE TABLE public.regional_by_row_table_pk_defined_separately ( pk INT8 NOT NULL, crdb_region public.crdb_internal_region NOT VISIBLE NOT NULL DEFAULT default_to_database_primary_region(gateway_region())::public.crdb_internal_region, - CONSTRAINT "primary" PRIMARY KEY (pk ASC), - FAMILY "primary" (pk, crdb_region) + CONSTRAINT "primary" PRIMARY KEY (pk ASC) ) LOCALITY REGIONAL BY ROW # Tests for REGIONAL BY TABLE AS @@ -1277,8 +1276,7 @@ regional_by_row_like CREATE TABLE public.regional_by_ i INT8 NULL, crdb_region public.crdb_internal_region NOT VISIBLE NOT NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT regional_by_row_like_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (pk, i, crdb_region, rowid) + CONSTRAINT regional_by_row_like_pkey PRIMARY KEY (rowid ASC) ) LOCALITY REGIONAL BY TABLE IN PRIMARY REGION statement ok @@ -1293,8 +1291,7 @@ regional_by_row_like CREATE TABLE public.regional_by_ i INT8 NULL, crdb_region public.crdb_internal_region NOT VISIBLE NOT NULL DEFAULT default_to_database_primary_region(gateway_region())::public.crdb_internal_region, CONSTRAINT regional_by_row_pkey PRIMARY KEY (crdb_region ASC, pk ASC), - INDEX regional_by_row_i_idx (crdb_region ASC, i ASC), - FAMILY "primary" (pk, i, crdb_region) + INDEX regional_by_row_i_idx (crdb_region ASC, i ASC) ) LOCALITY REGIONAL BY TABLE IN PRIMARY REGION @@ -1310,8 +1307,7 @@ regional_by_row_like CREATE TABLE public.regional_by_ i INT8 NULL, crdb_region public.crdb_internal_region NOT VISIBLE NOT NULL DEFAULT default_to_database_primary_region(gateway_region())::public.crdb_internal_region, CONSTRAINT regional_by_row_pkey PRIMARY KEY (crdb_region ASC, pk ASC), - INDEX regional_by_row_i_idx (crdb_region ASC, i ASC), - FAMILY "primary" (pk, i, crdb_region) + INDEX regional_by_row_i_idx (crdb_region ASC, i ASC) ) LOCALITY REGIONAL BY TABLE IN PRIMARY REGION statement ok diff --git a/pkg/ccl/logictestccl/testdata/logic_test/zone b/pkg/ccl/logictestccl/testdata/logic_test/zone index 82747cf50328..7201f7123194 100644 --- a/pkg/ccl/logictestccl/testdata/logic_test/zone +++ b/pkg/ccl/logictestccl/testdata/logic_test/zone @@ -639,8 +639,7 @@ SHOW CREATE TABLE show_test ---- show_test CREATE TABLE public.show_test ( x INT8 NOT NULL, - CONSTRAINT show_test_pkey PRIMARY KEY (x ASC), - FAMILY "primary" (x) + CONSTRAINT show_test_pkey PRIMARY KEY (x ASC) ) PARTITION BY LIST (x) ( PARTITION p1 VALUES IN ((1)), PARTITION p2 VALUES IN ((2)) @@ -662,8 +661,7 @@ SHOW CREATE warning ---- warning CREATE TABLE public.warning ( x INT8 NOT NULL, - CONSTRAINT warning_pkey PRIMARY KEY (x ASC), - FAMILY "primary" (x) + CONSTRAINT warning_pkey PRIMARY KEY (x ASC) ) PARTITION BY LIST (x) ( PARTITION p1 VALUES IN ((1)) ) @@ -741,8 +739,7 @@ SHOW CREATE TABLE t40417 ---- t40417 CREATE TABLE public.t40417 ( x INT8 NOT NULL, - CONSTRAINT t40417_pkey PRIMARY KEY (x ASC), - FAMILY "primary" (x) + CONSTRAINT t40417_pkey PRIMARY KEY (x ASC) ) PARTITION BY LIST (x) ( PARTITION p1 VALUES IN ((1)) ); diff --git a/pkg/ccl/multiregionccl/show_test.go b/pkg/ccl/multiregionccl/show_test.go index e0bd613d18fd..748cce0c04a6 100644 --- a/pkg/ccl/multiregionccl/show_test.go +++ b/pkg/ccl/multiregionccl/show_test.go @@ -31,8 +31,7 @@ func TestShowCreateTable(t *testing.T) { Expect: `CREATE TABLE public.%[1]s ( a INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT %[1]s_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, rowid) + CONSTRAINT %[1]s_pkey PRIMARY KEY (rowid ASC) ) LOCALITY GLOBAL`, Database: "mrdb", }, @@ -44,8 +43,7 @@ func TestShowCreateTable(t *testing.T) { Expect: `CREATE TABLE public.%[1]s ( a INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT %[1]s_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, rowid) + CONSTRAINT %[1]s_pkey PRIMARY KEY (rowid ASC) ) LOCALITY REGIONAL BY TABLE IN PRIMARY REGION`, Database: "mrdb", }, @@ -56,8 +54,7 @@ func TestShowCreateTable(t *testing.T) { Expect: `CREATE TABLE public.%[1]s ( a INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT %[1]s_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, rowid) + CONSTRAINT %[1]s_pkey PRIMARY KEY (rowid ASC) ) LOCALITY REGIONAL BY TABLE IN "us-west1"`, Database: "mrdb", }, @@ -72,8 +69,7 @@ func TestShowCreateTable(t *testing.T) { crdb_region public.crdb_internal_region NOT VISIBLE NOT NULL DEFAULT default_to_database_primary_region(gateway_region())::public.crdb_internal_region, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), CONSTRAINT %[1]s_pkey PRIMARY KEY (rowid ASC), - INDEX a_idx (a ASC), - FAMILY "primary" (a, crdb_region, rowid) + INDEX a_idx (a ASC) ) LOCALITY REGIONAL BY ROW`, Database: "mrdb", }, @@ -88,8 +84,7 @@ func TestShowCreateTable(t *testing.T) { crdb_region_col public.crdb_internal_region NOT NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), CONSTRAINT %[1]s_pkey PRIMARY KEY (rowid ASC), - INDEX a_idx (a ASC), - FAMILY "primary" (a, crdb_region_col, rowid) + INDEX a_idx (a ASC) ) LOCALITY REGIONAL BY ROW AS crdb_region_col`, Database: "mrdb", }, @@ -104,8 +99,7 @@ func TestShowCreateTable(t *testing.T) { crdb_region_col public.crdb_internal_region NOT NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), CONSTRAINT %[1]s_pkey PRIMARY KEY (rowid ASC), - INDEX a_idx (a ASC) WHERE a > 0:::INT8, - FAMILY "primary" (a, crdb_region_col, rowid) + INDEX a_idx (a ASC) WHERE a > 0:::INT8 ) LOCALITY REGIONAL BY ROW AS crdb_region_col`, Database: "mrdb", }, diff --git a/pkg/ccl/serverccl/statusccl/tenant_status_test.go b/pkg/ccl/serverccl/statusccl/tenant_status_test.go index ef0a87c06a17..1bea8f4d9fa1 100644 --- a/pkg/ccl/serverccl/statusccl/tenant_status_test.go +++ b/pkg/ccl/serverccl/statusccl/tenant_status_test.go @@ -508,7 +508,7 @@ WHERE } func testTableIndexStats(ctx context.Context, t *testing.T, testHelper *tenantTestHelper) { - getTableIndexStats := func(helper *tenantTestHelper, db string) *serverpb.TableIndexStatsResponse { + getTableIndexStats := func(t *testing.T, helper *tenantTestHelper, db string) *serverpb.TableIndexStatsResponse { // Get index usage stats using function call. cluster := helper.testCluster() status := cluster.tenantStatusSrv(randomServer) @@ -520,6 +520,8 @@ func testTableIndexStats(ctx context.Context, t *testing.T, testHelper *tenantTe cluster := testHelper.testCluster() + timePreCreate := timeutil.Now() + // Create table on a database. cluster.tenantConn(0).Exec(t, ` CREATE DATABASE test_db1; @@ -555,21 +557,61 @@ FROM pg_catalog.pg_indexes WHERE tablename = 'test' AND indexname = $1` // Get index usage stats and assert expected results. - resp := getTableIndexStats(testHelper, "test_db1") - require.Equal(t, uint64(1), resp.Statistics[0].Statistics.Stats.TotalReadCount) - require.True(t, resp.Statistics[0].Statistics.Stats.LastRead.After(timePreRead)) - indexName := resp.Statistics[0].IndexName - createStmt := cluster.tenantConn(0).QueryStr(t, getCreateStmtQuery, indexName)[0][0] - print(createStmt) - require.Equal(t, resp.Statistics[0].CreateStatement, createStmt) - - resp = getTableIndexStats(testHelper, "test_db2") - require.Equal(t, uint64(0), resp.Statistics[0].Statistics.Stats.TotalReadCount) - require.Equal(t, resp.Statistics[0].Statistics.Stats.LastRead, time.Time{}) - indexName = resp.Statistics[0].IndexName - cluster.tenantConn(0).Exec(t, `SET DATABASE=test_db2`) - createStmt = cluster.tenantConn(0).QueryStr(t, getCreateStmtQuery, indexName)[0][0] - require.Equal(t, resp.Statistics[0].CreateStatement, createStmt) + requireAfter := func(t *testing.T, a, b *time.Time) { + t.Helper() + require.NotNil(t, a) + require.NotNil(t, b) + require.Truef(t, a.After(*b), "%v is not after %v", a, b) + } + requireBetween := func(t *testing.T, before time.Time, ts *time.Time, after time.Time) { + t.Helper() + requireAfter(t, ts, &before) + requireAfter(t, &after, ts) + } + + t.Run("validate read index", func(t *testing.T) { + resp := getTableIndexStats(t, testHelper, "test_db1") + require.Equal(t, uint64(1), resp.Statistics[0].Statistics.Stats.TotalReadCount) + requireAfter(t, &resp.Statistics[0].Statistics.Stats.LastRead, &timePreRead) + indexName := resp.Statistics[0].IndexName + createStmt := cluster.tenantConn(0).QueryStr(t, getCreateStmtQuery, indexName)[0][0] + print(createStmt) + require.Equal(t, resp.Statistics[0].CreateStatement, createStmt) + requireBetween(t, timePreCreate, resp.Statistics[0].CreatedAt, timePreRead) + }) + + t.Run("validate unread index", func(t *testing.T) { + resp := getTableIndexStats(t, testHelper, "test_db2") + require.Equal(t, uint64(0), resp.Statistics[0].Statistics.Stats.TotalReadCount) + require.Equal(t, resp.Statistics[0].Statistics.Stats.LastRead, time.Time{}) + indexName := resp.Statistics[0].IndexName + cluster.tenantConn(0).Exec(t, `SET DATABASE=test_db2`) + createStmt := cluster.tenantConn(0).QueryStr(t, getCreateStmtQuery, indexName)[0][0] + require.Equal(t, resp.Statistics[0].CreateStatement, createStmt) + requireBetween(t, timePreCreate, resp.Statistics[0].CreatedAt, timePreRead) + }) + + // Test that a subsequent index creation has an appropriate timestamp. + t.Run("validate CreatedAt for new index", func(t *testing.T) { + timeBeforeCreateNewIndex := timeutil.Now() + cluster.tenantConn(0).Exec(t, ` +SET DATABASE=test_db2; +CREATE INDEX idx2 ON test (b, a)`) + timeAfterCreateNewIndex := timeutil.Now() + + resp := getTableIndexStats(t, testHelper, "test_db2") + var stat serverpb.TableIndexStatsResponse_ExtendedCollectedIndexUsageStatistics + var found bool + for _, idx := range resp.Statistics { + if found = idx.IndexName == "idx2"; found { + stat = *idx + break + } + } + require.True(t, found) + requireBetween(t, + timeBeforeCreateNewIndex, stat.CreatedAt, timeAfterCreateNewIndex) + }) } func ensureExpectedStmtFingerprintExistsInRPCResponse( diff --git a/pkg/cli/testdata/doctor/test_recreate_zipdir b/pkg/cli/testdata/doctor/test_recreate_zipdir index 2c0249ed2b11..63931053831a 100644 --- a/pkg/cli/testdata/doctor/test_recreate_zipdir +++ b/pkg/cli/testdata/doctor/test_recreate_zipdir @@ -12,16 +12,16 @@ SELECT crdb_internal.unsafe_upsert_descriptor(50, decode('12380a0964656661756c74 SELECT crdb_internal.unsafe_upsert_namespace_entry(0, 0, 'defaultdb', 50, true); SELECT crdb_internal.unsafe_upsert_descriptor(51, decode('12370a08706f73746772657310331a210a0b0a0561646d696e100218000a0a0a04726f6f74100218001204726f6f7418012200280140004a00', 'hex'), true); SELECT crdb_internal.unsafe_upsert_namespace_entry(0, 0, 'postgres', 51, true); -SELECT crdb_internal.unsafe_upsert_descriptor(53, decode('0afa040a0575736572731835203428013a0042280a02696410011a0d080e100018003000508617600020003000680070007800800100880100980100422a0a046369747910021a0d0807100018003007509308600020003000680070007800800100880100980100422a0a046e616d6510031a0d0807100018003007509308600020013000680070007800800100880100980100422d0a076164647265737310041a0d080710001800300750930860002001300068007000780080010088010098010042310a0b6372656469745f6361726410051a0d08071000180030075093086000200130006800700078008001008801009801004806525d0a077072696d617279100118012204636974792202696430023001400040004a10080010001a00200028003000380040005a007a0408002000800100880100900101980100a20106080012001800a80100b20100ba0100c0010088020060026a210a0b0a0561646d696e100218000a0a0a04726f6f74100218001204726f6f741801800101880103980100b2013d0a077072696d61727910001a0269641a04636974791a046e616d651a07616464726573731a0b6372656469745f63617264200120022003200420052800b80101c20100e80100f2010408001200f801008002009202009a0200aa02290836100210041802180120352a11666b5f636974795f7265665f757365727330023800400048007000aa02290837100210041802180120352a11666b5f636974795f7265665f757365727330023800400048007000aa0229083a100110021802180120352a11666b5f636974795f7265665f757365727330023800400048007000b20200b80200c0021dc80200e00200f00200800300880300', 'hex'), true); +SELECT crdb_internal.unsafe_upsert_descriptor(53, decode('0afd040a0575736572731835203428013a0042280a02696410011a0d080e100018003000508617600020003000680070007800800100880100980100422a0a046369747910021a0d0807100018003007509308600020003000680070007800800100880100980100422a0a046e616d6510031a0d0807100018003007509308600020013000680070007800800100880100980100422d0a076164647265737310041a0d080710001800300750930860002001300068007000780080010088010098010042310a0b6372656469745f6361726410051a0d0807100018003007509308600020013000680070007800800100880100980100480652600a077072696d617279100118012204636974792202696430023001400040004a10080010001a00200028003000380040005a007a0408002000800100880100900101980100a20106080012001800a80100b20100ba0100c00100c8010088020060026a210a0b0a0561646d696e100218000a0a0a04726f6f74100218001204726f6f741801800101880103980100b2013d0a077072696d61727910001a0269641a04636974791a046e616d651a07616464726573731a0b6372656469745f63617264200120022003200420052800b80101c20100e80100f2010408001200f801008002009202009a0200aa02290836100210041802180120352a11666b5f636974795f7265665f757365727330023800400048007000aa02290837100210041802180120352a11666b5f636974795f7265665f757365727330023800400048007000aa0229083a100110021802180120352a11666b5f636974795f7265665f757365727330023800400048007000b20200b80200c0021dc80200e00200f00200800300880300', 'hex'), true); SELECT crdb_internal.unsafe_upsert_namespace_entry(52, 29, 'users', 53, true); -SELECT crdb_internal.unsafe_upsert_descriptor(54, decode('0a9e070a0876656869636c65731836203428013a0042280a02696410011a0d080e100018003000508617600020003000680070007800800100880100980100422a0a046369747910021a0d0807100018003007509308600020003000680070007800800100880100980100422a0a047479706510031a0d0807100018003007509308600020013000680070007800800100880100980100422e0a086f776e65725f696410041a0d080e10001800300050861760002001300068007000780080010088010098010042330a0d6372656174696f6e5f74696d6510051a0d080510001800300050da08600020013000680070007800800100880100980100422c0a0673746174757310061a0d080710001800300750930860002001300068007000780080010088010098010042360a1063757272656e745f6c6f636174696f6e10071a0d080710001800300750930860002001300068007000780080010088010098010042290a0365787410081a0d081210001800300050da1d6000200130006800700078008001008801009801004809525d0a077072696d617279100118012204636974792202696430023001400040004a10080010001a00200028003000380040005a007a0408002000800100880100900101980100a20106080012001800a80100b20100ba0100c001008802005a83010a2576656869636c65735f6175746f5f696e6465785f666b5f636974795f7265665f75736572731002180022046369747922086f776e65725f6964300230043801400040004a10080010001a00200028003000380040005a007a0408002000800100880100900101980100a20106080012001800a80100b20100ba0100c0010088020060036a210a0b0a0561646d696e100218000a0a0a04726f6f74100218001204726f6f741801800102880103980100b201650a077072696d61727910001a0269641a04636974791a04747970651a086f776e65725f69641a0d6372656174696f6e5f74696d651a067374617475731a1063757272656e745f6c6f636174696f6e1a03657874200120022003200420052006200720082800b80101c20100e80100f2010408001200f801008002009202009a0200a202290836100210041802180120352a11666b5f636974795f7265665f757365727330003800400048007000aa02340837100310051802180120362a1c666b5f76656869636c655f636974795f7265665f76656869636c657330023800400048007000b20200b80200c0021dc80200e00200f00200800300880300', 'hex'), true); +SELECT crdb_internal.unsafe_upsert_descriptor(54, decode('0aa4070a0876656869636c65731836203428013a0042280a02696410011a0d080e100018003000508617600020003000680070007800800100880100980100422a0a046369747910021a0d0807100018003007509308600020003000680070007800800100880100980100422a0a047479706510031a0d0807100018003007509308600020013000680070007800800100880100980100422e0a086f776e65725f696410041a0d080e10001800300050861760002001300068007000780080010088010098010042330a0d6372656174696f6e5f74696d6510051a0d080510001800300050da08600020013000680070007800800100880100980100422c0a0673746174757310061a0d080710001800300750930860002001300068007000780080010088010098010042360a1063757272656e745f6c6f636174696f6e10071a0d080710001800300750930860002001300068007000780080010088010098010042290a0365787410081a0d081210001800300050da1d600020013000680070007800800100880100980100480952600a077072696d617279100118012204636974792202696430023001400040004a10080010001a00200028003000380040005a007a0408002000800100880100900101980100a20106080012001800a80100b20100ba0100c00100c801008802005a86010a2576656869636c65735f6175746f5f696e6465785f666b5f636974795f7265665f75736572731002180022046369747922086f776e65725f6964300230043801400040004a10080010001a00200028003000380040005a007a0408002000800100880100900101980100a20106080012001800a80100b20100ba0100c00100c8010088020060036a210a0b0a0561646d696e100218000a0a0a04726f6f74100218001204726f6f741801800102880103980100b201650a077072696d61727910001a0269641a04636974791a04747970651a086f776e65725f69641a0d6372656174696f6e5f74696d651a067374617475731a1063757272656e745f6c6f636174696f6e1a03657874200120022003200420052006200720082800b80101c20100e80100f2010408001200f801008002009202009a0200a202290836100210041802180120352a11666b5f636974795f7265665f757365727330003800400048007000aa02340837100310051802180120362a1c666b5f76656869636c655f636974795f7265665f76656869636c657330023800400048007000b20200b80200c0021dc80200e00200f00200800300880300', 'hex'), true); SELECT crdb_internal.unsafe_upsert_namespace_entry(52, 29, 'vehicles', 54, true); -SELECT crdb_internal.unsafe_upsert_descriptor(55, decode('0aae0a0a0572696465731837203428013a0042280a02696410011a0d080e100018003000508617600020003000680070007800800100880100980100422a0a046369747910021a0d080710001800300750930860002000300068007000780080010088010098010042320a0c76656869636c655f6369747910031a0d0807100018003007509308600020013000680070007800800100880100980100422e0a0872696465725f696410041a0d080e10001800300050861760002001300068007000780080010088010098010042300a0a76656869636c655f696410051a0d080e10001800300050861760002001300068007000780080010088010098010042330a0d73746172745f6164647265737310061a0d080710001800300750930860002001300068007000780080010088010098010042310a0b656e645f6164647265737310071a0d080710001800300750930860002001300068007000780080010088010098010042300a0a73746172745f74696d6510081a0d080510001800300050da08600020013000680070007800800100880100980100422e0a08656e645f74696d6510091a0d080510001800300050da08600020013000680070007800800100880100980100422d0a07726576656e7565100a1a0d08031002180a300050a40d600020013000680070007800800100880100980100480b525d0a077072696d617279100118012204636974792202696430023001400040004a10080010001a00200028003000380040005a007a0408002000800100880100900101980100a20106080012001800a80100b20100ba0100c001008802005a80010a2272696465735f6175746f5f696e6465785f666b5f636974795f7265665f757365727310021800220463697479220872696465725f6964300230043801400040004a10080010001a00200028003000380040005a007a0408002000800100880100900101980100a20106080012001800a80100b20100ba0100c001008802005a97010a2d72696465735f6175746f5f696e6465785f666b5f76656869636c655f636974795f7265665f76656869636c657310031800220c76656869636c655f63697479220a76656869636c655f69643003300538023801400040004a10080010001a00200028003000380040005a007a0408002000800100880100900101980100a20106080012001800a80100b20100ba0100c0010088020060046a210a0b0a0561646d696e100218000a0a0a04726f6f74100218001204726f6f741801800103880103980100a2013a0a1376656869636c655f63697479203d20636974791217636865636b5f76656869636c655f636974795f63697479180028022803300038004000b2018a010a077072696d61727910001a0269641a04636974791a0c76656869636c655f636974791a0872696465725f69641a0a76656869636c655f69641a0d73746172745f616464726573731a0b656e645f616464726573731a0a73746172745f74696d651a08656e645f74696d651a07726576656e7565200120022003200420052006200720082009200a2800b80101c20100e80100f2010408001200f801008002009202009a0200a202290837100210041802180120352a11666b5f636974795f7265665f757365727330003800400048007000a202340837100310051802180120362a1c666b5f76656869636c655f636974795f7265665f76656869636c657330003800400048007000aa02290838100110021802180120372a11666b5f636974795f7265665f726964657330023800400048007000b20200b80200c0021dc80200e00200f00200800300880300', 'hex'), true); +SELECT crdb_internal.unsafe_upsert_descriptor(55, decode('0ab70a0a0572696465731837203428013a0042280a02696410011a0d080e100018003000508617600020003000680070007800800100880100980100422a0a046369747910021a0d080710001800300750930860002000300068007000780080010088010098010042320a0c76656869636c655f6369747910031a0d0807100018003007509308600020013000680070007800800100880100980100422e0a0872696465725f696410041a0d080e10001800300050861760002001300068007000780080010088010098010042300a0a76656869636c655f696410051a0d080e10001800300050861760002001300068007000780080010088010098010042330a0d73746172745f6164647265737310061a0d080710001800300750930860002001300068007000780080010088010098010042310a0b656e645f6164647265737310071a0d080710001800300750930860002001300068007000780080010088010098010042300a0a73746172745f74696d6510081a0d080510001800300050da08600020013000680070007800800100880100980100422e0a08656e645f74696d6510091a0d080510001800300050da08600020013000680070007800800100880100980100422d0a07726576656e7565100a1a0d08031002180a300050a40d600020013000680070007800800100880100980100480b52600a077072696d617279100118012204636974792202696430023001400040004a10080010001a00200028003000380040005a007a0408002000800100880100900101980100a20106080012001800a80100b20100ba0100c00100c801008802005a83010a2272696465735f6175746f5f696e6465785f666b5f636974795f7265665f757365727310021800220463697479220872696465725f6964300230043801400040004a10080010001a00200028003000380040005a007a0408002000800100880100900101980100a20106080012001800a80100b20100ba0100c00100c801008802005a9a010a2d72696465735f6175746f5f696e6465785f666b5f76656869636c655f636974795f7265665f76656869636c657310031800220c76656869636c655f63697479220a76656869636c655f69643003300538023801400040004a10080010001a00200028003000380040005a007a0408002000800100880100900101980100a20106080012001800a80100b20100ba0100c00100c8010088020060046a210a0b0a0561646d696e100218000a0a0a04726f6f74100218001204726f6f741801800103880103980100a2013a0a1376656869636c655f63697479203d20636974791217636865636b5f76656869636c655f636974795f63697479180028022803300038004000b2018a010a077072696d61727910001a0269641a04636974791a0c76656869636c655f636974791a0872696465725f69641a0a76656869636c655f69641a0d73746172745f616464726573731a0b656e645f616464726573731a0a73746172745f74696d651a08656e645f74696d651a07726576656e7565200120022003200420052006200720082009200a2800b80101c20100e80100f2010408001200f801008002009202009a0200a202290837100210041802180120352a11666b5f636974795f7265665f757365727330003800400048007000a202340837100310051802180120362a1c666b5f76656869636c655f636974795f7265665f76656869636c657330003800400048007000aa02290838100110021802180120372a11666b5f636974795f7265665f726964657330023800400048007000b20200b80200c0021dc80200e00200f00200800300880300', 'hex'), true); SELECT crdb_internal.unsafe_upsert_namespace_entry(52, 29, 'rides', 55, true); -SELECT crdb_internal.unsafe_upsert_descriptor(56, decode('0ac9040a1a76656869636c655f6c6f636174696f6e5f686973746f726965731838203428013a00422a0a046369747910011a0d0807100018003007509308600020003000680070007800800100880100980100422d0a07726964655f696410021a0d080e100018003000508617600020003000680070007800800100880100980100422f0a0974696d657374616d7010031a0d080510001800300050da0860002000300068007000780080010088010098010042290a036c617410041a0d080210401800300050bd05600020013000680070007800800100880100980100422a0a046c6f6e6710051a0d080210401800300050bd05600020013000680070007800800100880100980100480652710a077072696d617279100118012204636974792207726964655f6964220974696d657374616d703001300230034000400040004a10080010001a00200028003000380040005a007a0408002000800100880100900101980100a20106080012001800a80100b20100ba0100c0010088020060026a210a0b0a0561646d696e100218000a0a0a04726f6f74100218001204726f6f741801800102880103980100b2013c0a077072696d61727910001a04636974791a07726964655f69641a0974696d657374616d701a036c61741a046c6f6e67200120022003200420052800b80101c20100e80100f2010408001200f801008002009202009a0200a202290838100110021802180120372a11666b5f636974795f7265665f726964657330003800400048007000b20200b80200c0021dc80200e00200f00200800300880300', 'hex'), true); +SELECT crdb_internal.unsafe_upsert_descriptor(56, decode('0acc040a1a76656869636c655f6c6f636174696f6e5f686973746f726965731838203428013a00422a0a046369747910011a0d0807100018003007509308600020003000680070007800800100880100980100422d0a07726964655f696410021a0d080e100018003000508617600020003000680070007800800100880100980100422f0a0974696d657374616d7010031a0d080510001800300050da0860002000300068007000780080010088010098010042290a036c617410041a0d080210401800300050bd05600020013000680070007800800100880100980100422a0a046c6f6e6710051a0d080210401800300050bd05600020013000680070007800800100880100980100480652740a077072696d617279100118012204636974792207726964655f6964220974696d657374616d703001300230034000400040004a10080010001a00200028003000380040005a007a0408002000800100880100900101980100a20106080012001800a80100b20100ba0100c00100c8010088020060026a210a0b0a0561646d696e100218000a0a0a04726f6f74100218001204726f6f741801800102880103980100b2013c0a077072696d61727910001a04636974791a07726964655f69641a0974696d657374616d701a036c61741a046c6f6e67200120022003200420052800b80101c20100e80100f2010408001200f801008002009202009a0200a202290838100110021802180120372a11666b5f636974795f7265665f726964657330003800400048007000b20200b80200c0021dc80200e00200f00200800300880300', 'hex'), true); SELECT crdb_internal.unsafe_upsert_namespace_entry(52, 29, 'vehicle_location_histories', 56, true); -SELECT crdb_internal.unsafe_upsert_descriptor(57, decode('0a9c040a0b70726f6d6f5f636f6465731839203428013a00422a0a04636f646510011a0d080710001800300750930860002000300068007000780080010088010098010042310a0b6465736372697074696f6e10021a0d080710001800300750930860002001300068007000780080010088010098010042330a0d6372656174696f6e5f74696d6510031a0d080510001800300050da0860002001300068007000780080010088010098010042350a0f65787069726174696f6e5f74696d6510041a0d080510001800300050da08600020013000680070007800800100880100980100422b0a0572756c657310051a0d081210001800300050da1d600020013000680070007800800100880100980100480652550a077072696d617279100118012204636f6465300140004a10080010001a00200028003000380040005a007a0408002000800100880100900101980100a20106080012001800a80100b20100ba0100c0010088020060026a210a0b0a0561646d696e100218000a0a0a04726f6f74100218001204726f6f741801800101880103980100b201510a077072696d61727910001a04636f64651a0b6465736372697074696f6e1a0d6372656174696f6e5f74696d651a0f65787069726174696f6e5f74696d651a0572756c6573200120022003200420052800b80101c20100e80100f2010408001200f801008002009202009a0200b20200b80200c0021dc80200e00200f00200800300880300', 'hex'), true); +SELECT crdb_internal.unsafe_upsert_descriptor(57, decode('0a9f040a0b70726f6d6f5f636f6465731839203428013a00422a0a04636f646510011a0d080710001800300750930860002000300068007000780080010088010098010042310a0b6465736372697074696f6e10021a0d080710001800300750930860002001300068007000780080010088010098010042330a0d6372656174696f6e5f74696d6510031a0d080510001800300050da0860002001300068007000780080010088010098010042350a0f65787069726174696f6e5f74696d6510041a0d080510001800300050da08600020013000680070007800800100880100980100422b0a0572756c657310051a0d081210001800300050da1d600020013000680070007800800100880100980100480652580a077072696d617279100118012204636f6465300140004a10080010001a00200028003000380040005a007a0408002000800100880100900101980100a20106080012001800a80100b20100ba0100c00100c8010088020060026a210a0b0a0561646d696e100218000a0a0a04726f6f74100218001204726f6f741801800101880103980100b201510a077072696d61727910001a04636f64651a0b6465736372697074696f6e1a0d6372656174696f6e5f74696d651a0f65787069726174696f6e5f74696d651a0572756c6573200120022003200420052800b80101c20100e80100f2010408001200f801008002009202009a0200b20200b80200c0021dc80200e00200f00200800300880300', 'hex'), true); SELECT crdb_internal.unsafe_upsert_namespace_entry(52, 29, 'promo_codes', 57, true); -SELECT crdb_internal.unsafe_upsert_descriptor(58, decode('0ac9040a10757365725f70726f6d6f5f636f646573183a203428013a00422a0a046369747910011a0d0807100018003007509308600020003000680070007800800100880100980100422d0a07757365725f696410021a0d080e100018003000508617600020003000680070007800800100880100980100422a0a04636f646510031a0d0807100018003007509308600020003000680070007800800100880100980100422f0a0974696d657374616d7010041a0d080510001800300050da0860002001300068007000780080010088010098010042300a0b75736167655f636f756e7410051a0c080110401800300050146000200130006800700078008001008801009801004806526c0a077072696d617279100118012204636974792207757365725f69642204636f64653001300230034000400040004a10080010001a00200028003000380040005a007a0408002000800100880100900101980100a20106080012001800a80100b20100ba0100c0010088020060026a210a0b0a0561646d696e100218000a0a0a04726f6f74100218001204726f6f741801800102880103980100b201440a077072696d61727910001a04636974791a07757365725f69641a04636f64651a0974696d657374616d701a0b75736167655f636f756e74200120022003200420052800b80101c20100e80100f2010408001200f801008002009202009a0200a20229083a100110021802180120352a11666b5f636974795f7265665f757365727330003800400048007000b20200b80200c0021dc80200e00200f00200800300880300', 'hex'), true); +SELECT crdb_internal.unsafe_upsert_descriptor(58, decode('0acc040a10757365725f70726f6d6f5f636f646573183a203428013a00422a0a046369747910011a0d0807100018003007509308600020003000680070007800800100880100980100422d0a07757365725f696410021a0d080e100018003000508617600020003000680070007800800100880100980100422a0a04636f646510031a0d0807100018003007509308600020003000680070007800800100880100980100422f0a0974696d657374616d7010041a0d080510001800300050da0860002001300068007000780080010088010098010042300a0b75736167655f636f756e7410051a0c080110401800300050146000200130006800700078008001008801009801004806526f0a077072696d617279100118012204636974792207757365725f69642204636f64653001300230034000400040004a10080010001a00200028003000380040005a007a0408002000800100880100900101980100a20106080012001800a80100b20100ba0100c00100c8010088020060026a210a0b0a0561646d696e100218000a0a0a04726f6f74100218001204726f6f741801800102880103980100b201440a077072696d61727910001a04636974791a07757365725f69641a04636f64651a0974696d657374616d701a0b75736167655f636f756e74200120022003200420052800b80101c20100e80100f2010408001200f801008002009202009a0200a20229083a100110021802180120352a11666b5f636974795f7265665f757365727330003800400048007000b20200b80200c0021dc80200e00200f00200800300880300', 'hex'), true); SELECT crdb_internal.unsafe_upsert_namespace_entry(52, 29, 'user_promo_codes', 58, true); COMMIT; diff --git a/pkg/migration/migrations/descriptor_utils_test.go b/pkg/migration/migrations/descriptor_utils_test.go index 639c4eccbd83..14ba90a12cc5 100644 --- a/pkg/migration/migrations/descriptor_utils_test.go +++ b/pkg/migration/migrations/descriptor_utils_test.go @@ -35,8 +35,7 @@ func TestCreateSystemTable(t *testing.T) { fakeTableSchema := `CREATE TABLE public.fake_table ( id UUID NOT NULL, - CONSTRAINT "primary" PRIMARY KEY (id ASC), - FAMILY "primary" (id) + CONSTRAINT "primary" PRIMARY KEY (id ASC) )` fakeTable := descpb.TableDescriptor{ Name: "fake_table", diff --git a/pkg/server/index_usage_stats.go b/pkg/server/index_usage_stats.go index 102d864469c3..204a4ba7cbc7 100644 --- a/pkg/server/index_usage_stats.go +++ b/pkg/server/index_usage_stats.go @@ -230,7 +230,8 @@ func getTableIndexUsageStats( ti.index_type, total_reads, last_read, - indexdef + indexdef, + ti.created_at FROM crdb_internal.index_usage_statistics AS us JOIN crdb_internal.table_indexes AS ti ON us.index_id = ti.index_id AND us.table_id = ti.descriptor_id @@ -241,7 +242,7 @@ func getTableIndexUsageStats( tableID, ) - const expectedNumDatums = 6 + const expectedNumDatums = 7 it, err := ie.QueryIteratorEx(ctx, "index-usage-stats", nil, sessiondata.InternalExecutorOverride{ @@ -279,6 +280,11 @@ func getTableIndexUsageStats( lastRead = tree.MustBeDTimestampTZ(row[4]).Time } createStmt := tree.MustBeDString(row[5]) + var createdAt *time.Time + if row[6] != tree.DNull { + ts := tree.MustBeDTimestamp(row[6]) + createdAt = &ts.Time + } if err != nil { return nil, err @@ -298,6 +304,7 @@ func getTableIndexUsageStats( IndexName: string(indexName), IndexType: string(indexType), CreateStatement: string(createStmt), + CreatedAt: createdAt, } idxUsageStats = append(idxUsageStats, idxStatsRow) diff --git a/pkg/server/serverpb/status.proto b/pkg/server/serverpb/status.proto index 68ebbbe70ba0..87747bda1697 100644 --- a/pkg/server/serverpb/status.proto +++ b/pkg/server/serverpb/status.proto @@ -1426,6 +1426,10 @@ message TableIndexStatsResponse { // create_statement is the SQL statement that would re-create the // current index if executed. string create_statement = 4; + // CreatedAt is an approximate timestamp at which the index was created. + // Note that it may not always be populated. + google.protobuf.Timestamp created_at = 5 [(gogoproto.stdtime) = true]; + } repeated ExtendedCollectedIndexUsageStatistics statistics = 1; diff --git a/pkg/sql/alter_column_type_test.go b/pkg/sql/alter_column_type_test.go index a41b8fbd565b..da238f7b1dd7 100644 --- a/pkg/sql/alter_column_type_test.go +++ b/pkg/sql/alter_column_type_test.go @@ -231,8 +231,7 @@ INSERT INTO t.test VALUES (1), (2), (3); `CREATE TABLE public.test ( x INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT test_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (x, rowid) + CONSTRAINT test_pkey PRIMARY KEY (rowid ASC) )`}} sqlDB.CheckQueryResults(t, "SHOW CREATE TABLE t.test", expected) @@ -245,8 +244,7 @@ INSERT INTO t.test VALUES (1), (2), (3); `CREATE TABLE public.test ( x STRING NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT test_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (x, rowid) + CONSTRAINT test_pkey PRIMARY KEY (rowid ASC) )`}} sqlDB.CheckQueryResults(t, "SHOW CREATE TABLE t.test", expected) diff --git a/pkg/sql/alter_primary_key.go b/pkg/sql/alter_primary_key.go index 351bbd37964d..2ea5d128bb16 100644 --- a/pkg/sql/alter_primary_key.go +++ b/pkg/sql/alter_primary_key.go @@ -12,6 +12,7 @@ package sql import ( "context" + "time" "github.com/cockroachdb/cockroach/pkg/server/telemetry" "github.com/cockroachdb/cockroach/pkg/sql/catalog" @@ -180,6 +181,7 @@ func (p *planner) AlterPrimaryKey( Type: descpb.IndexDescriptor_FORWARD, Version: descpb.LatestNonPrimaryIndexDescriptorVersion, ConstraintID: tableDesc.GetNextConstraintID(), + CreatedAtNanos: p.EvalContext().GetTxnTimestamp(time.Microsecond).UnixNano(), } tableDesc.NextConstraintID++ diff --git a/pkg/sql/alter_table.go b/pkg/sql/alter_table.go index 591124956e6b..a53a5916c649 100644 --- a/pkg/sql/alter_table.go +++ b/pkg/sql/alter_table.go @@ -16,6 +16,7 @@ import ( gojson "encoding/json" "fmt" "sort" + "time" "github.com/cockroachdb/cockroach/pkg/clusterversion" "github.com/cockroachdb/cockroach/pkg/keys" @@ -270,6 +271,7 @@ func (n *alterTableNode) startExec(params runParams) error { Name: string(d.Name), Unique: true, StoreColumnNames: d.Storing.ToStrings(), + CreatedAtNanos: params.EvalContext().GetTxnTimestamp(time.Microsecond).UnixNano(), } if err := idx.FillColumns(d.Columns); err != nil { return err diff --git a/pkg/sql/catalog/descpb/structured.proto b/pkg/sql/catalog/descpb/structured.proto index ae60b9f7e5be..554f1775c0ba 100644 --- a/pkg/sql/catalog/descpb/structured.proto +++ b/pkg/sql/catalog/descpb/structured.proto @@ -538,6 +538,10 @@ message IndexDescriptor { // indexes. optional uint32 constraint_id = 33 [(gogoproto.customname) = "ConstraintID", (gogoproto.casttype) = "ConstraintID", (gogoproto.nullable) = false]; + + // CreatedAtNanos, if non-zero, represents an approximate time at which the + // index was created. + optional int64 created_at_nanos = 25 [(gogoproto.nullable) = false]; } // ConstraintToUpdate represents a constraint to be added to the table and diff --git a/pkg/sql/catalog/table_elements.go b/pkg/sql/catalog/table_elements.go index b9f4bbda105d..cfaf24b62d59 100644 --- a/pkg/sql/catalog/table_elements.go +++ b/pkg/sql/catalog/table_elements.go @@ -11,6 +11,8 @@ package catalog import ( + "time" + "github.com/cockroachdb/cockroach/pkg/geo/geoindex" "github.com/cockroachdb/cockroach/pkg/sql/catalog/catpb" "github.com/cockroachdb/cockroach/pkg/sql/catalog/descpb" @@ -209,6 +211,11 @@ type Index interface { // checked by the schema changer before they are brought back // online. ForcePut() bool + + // CreatedAt is an approximate timestamp at which the index was created. + // It is derived from the statement time at which the relevant statement + // was issued. + CreatedAt() time.Time } // Column is an interface around the column descriptor types. diff --git a/pkg/sql/catalog/tabledesc/BUILD.bazel b/pkg/sql/catalog/tabledesc/BUILD.bazel index ed810895514c..bcbc9b271937 100644 --- a/pkg/sql/catalog/tabledesc/BUILD.bazel +++ b/pkg/sql/catalog/tabledesc/BUILD.bazel @@ -47,6 +47,7 @@ go_library( "//pkg/util/iterutil", "//pkg/util/log", "//pkg/util/protoutil", + "//pkg/util/timeutil", "@com_github_cockroachdb_errors//:errors", "@com_github_cockroachdb_redact//:redact", "@com_github_lib_pq//oid", diff --git a/pkg/sql/catalog/tabledesc/index.go b/pkg/sql/catalog/tabledesc/index.go index 35bef93eb28b..6bc028c6b293 100644 --- a/pkg/sql/catalog/tabledesc/index.go +++ b/pkg/sql/catalog/tabledesc/index.go @@ -13,6 +13,7 @@ package tabledesc import ( "fmt" "strings" + "time" "github.com/cockroachdb/cockroach/pkg/geo/geoindex" "github.com/cockroachdb/cockroach/pkg/sql/catalog" @@ -21,6 +22,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/types" "github.com/cockroachdb/cockroach/pkg/util/iterutil" "github.com/cockroachdb/cockroach/pkg/util/protoutil" + "github.com/cockroachdb/cockroach/pkg/util/timeutil" ) var _ catalog.Index = (*index)(nil) @@ -351,6 +353,13 @@ func (w index) ForcePut() bool { return w.Merging() || w.desc.UseDeletePreservingEncoding } +func (w index) CreatedAt() time.Time { + if w.desc.CreatedAtNanos == 0 { + return time.Time{} + } + return timeutil.Unix(0, w.desc.CreatedAtNanos) +} + // partitioning is the backing struct for a catalog.Partitioning interface. type partitioning struct { desc *descpb.PartitioningDescriptor diff --git a/pkg/sql/catalog/tabledesc/table_desc_builder.go b/pkg/sql/catalog/tabledesc/table_desc_builder.go index 31487e7f7f0c..95555dd83d67 100644 --- a/pkg/sql/catalog/tabledesc/table_desc_builder.go +++ b/pkg/sql/catalog/tabledesc/table_desc_builder.go @@ -464,6 +464,10 @@ func maybeUpgradeFormatVersion(desc *descpb.TableDescriptor) (wasUpgraded bool) return wasUpgraded } +// FamilyPrimaryName is the name of the "primary" family, which is autogenerated +// the family clause is not specified. +const FamilyPrimaryName = "primary" + func upgradeToFamilyFormatVersion(desc *descpb.TableDescriptor) { var primaryIndexColumnIDs catalog.TableColSet for _, colID := range desc.PrimaryIndex.KeyColumnIDs { @@ -471,7 +475,7 @@ func upgradeToFamilyFormatVersion(desc *descpb.TableDescriptor) { } desc.Families = []descpb.ColumnFamilyDescriptor{ - {ID: 0, Name: "primary"}, + {ID: 0, Name: FamilyPrimaryName}, } desc.NextFamilyID = desc.Families[0].ID + 1 addFamilyForCol := func(col *descpb.ColumnDescriptor) { diff --git a/pkg/sql/catalog/tabledesc/validate_test.go b/pkg/sql/catalog/tabledesc/validate_test.go index 9ffcd7d29441..f83eca7b0f3a 100644 --- a/pkg/sql/catalog/tabledesc/validate_test.go +++ b/pkg/sql/catalog/tabledesc/validate_test.go @@ -170,6 +170,7 @@ var validationMap = []struct { "Predicate": {status: iSolemnlySwearThisFieldIsValidated}, "UseDeletePreservingEncoding": {status: thisFieldReferencesNoObjects}, "ConstraintID": {status: iSolemnlySwearThisFieldIsValidated}, + "CreatedAtNanos": {status: thisFieldReferencesNoObjects}, }, }, { diff --git a/pkg/sql/crdb_internal.go b/pkg/sql/crdb_internal.go index ba379ae3b4d5..462996a28a82 100644 --- a/pkg/sql/crdb_internal.go +++ b/pkg/sql/crdb_internal.go @@ -2623,8 +2623,6 @@ CREATE TABLE crdb_internal.table_columns ( } // crdbInternalTableIndexesTable exposes the index descriptors. -// -// TODO(tbg): prefix with kv_. var crdbInternalTableIndexesTable = virtualSchemaTable{ comment: "indexes accessible by current user in current database (KV scan)", schema: ` @@ -2636,7 +2634,8 @@ CREATE TABLE crdb_internal.table_indexes ( index_type STRING NOT NULL, is_unique BOOL NOT NULL, is_inverted BOOL NOT NULL, - is_sharded BOOL NOT NULL + is_sharded BOOL NOT NULL, + created_at TIMESTAMP ) `, generator: func(ctx context.Context, p *planner, dbContext catalog.DatabaseDescriptor, stopper *stop.Stopper) (virtualTableGenerator, cleanupFunc, error) { @@ -2658,6 +2657,15 @@ CREATE TABLE crdb_internal.table_indexes ( if idx.Primary() { idxType = primary } + createdAt := tree.DNull + if ts := idx.CreatedAt(); !ts.IsZero() { + tsDatum, err := tree.MakeDTimestamp(ts, time.Nanosecond) + if err != nil { + log.Warningf(ctx, "failed to construct timestamp for index: %v", err) + } else { + createdAt = tsDatum + } + } row = append(row, tableID, tableName, @@ -2667,6 +2675,7 @@ CREATE TABLE crdb_internal.table_indexes ( tree.MakeDBool(tree.DBool(idx.IsUnique())), tree.MakeDBool(idx.GetType() == descpb.IndexDescriptor_INVERTED), tree.MakeDBool(tree.DBool(idx.IsSharded())), + createdAt, ) return pusher.pushRow(row...) }) diff --git a/pkg/sql/create_index.go b/pkg/sql/create_index.go index e7cad505a074..cfb0d30617e6 100644 --- a/pkg/sql/create_index.go +++ b/pkg/sql/create_index.go @@ -12,6 +12,7 @@ package sql import ( "context" + "time" "github.com/cockroachdb/cockroach/pkg/docs" "github.com/cockroachdb/cockroach/pkg/geo/geoindex" @@ -195,6 +196,7 @@ func makeIndexDescriptor( Unique: n.Unique, StoreColumnNames: n.Storing.ToStrings(), CreatedExplicitly: true, + CreatedAtNanos: params.EvalContext().GetTxnTimestamp(time.Microsecond).UnixNano(), } if n.Inverted { diff --git a/pkg/sql/create_sequence.go b/pkg/sql/create_sequence.go index 0a854910dffa..83e23144f035 100644 --- a/pkg/sql/create_sequence.go +++ b/pkg/sql/create_sequence.go @@ -278,6 +278,7 @@ func NewSequenceTableDesc( KeyColumnDirections: []descpb.IndexDescriptor_Direction{descpb.IndexDescriptor_ASC}, EncodingType: descpb.PrimaryIndexEncoding, Version: descpb.LatestPrimaryIndexDescriptorVersion, + CreatedAtNanos: creationTime.WallTime, }) desc.Families = []descpb.ColumnFamilyDescriptor{ { diff --git a/pkg/sql/create_table.go b/pkg/sql/create_table.go index 04eca6a63b84..abc4cb467bf5 100644 --- a/pkg/sql/create_table.go +++ b/pkg/sql/create_table.go @@ -16,6 +16,7 @@ import ( "go/constant" "strconv" "strings" + "time" "github.com/cockroachdb/cockroach/pkg/build" "github.com/cockroachdb/cockroach/pkg/docs" @@ -2172,6 +2173,17 @@ func NewTableDesc( return nil, err } + // Note that due to historical reasons, the automatic creation of the primary + // index occurs in AllocateIDs. That call does not have access to the current + // timestamp to set the created_at timestamp. + if desc.IsPhysicalTable() && !catalog.IsSystemDescriptor(&desc) { + ts := evalCtx.GetTxnTimestamp(time.Microsecond).UnixNano() + _ = catalog.ForEachNonDropIndex(&desc, func(idx catalog.Index) error { + idx.IndexDesc().CreatedAtNanos = ts + return nil + }) + } + // Record the types of indexes that the table has. if err := catalog.ForEachNonDropIndex(&desc, func(idx catalog.Index) error { if idx.IsSharded() { diff --git a/pkg/sql/logictest/testdata/logic_test/alter_column_type b/pkg/sql/logictest/testdata/logic_test/alter_column_type index ce2470a37400..e52e882368e4 100644 --- a/pkg/sql/logictest/testdata/logic_test/alter_column_type +++ b/pkg/sql/logictest/testdata/logic_test/alter_column_type @@ -75,8 +75,7 @@ t CREATE TABLE public.t ( a INT8 NOT NULL, i INT8 NULL, CONSTRAINT t_pkey PRIMARY KEY (a ASC), - INDEX idx2 (i ASC), - FAMILY "primary" (a, i) + INDEX idx2 (i ASC) ) statement ok @@ -286,8 +285,7 @@ SHOW CREATE TABLE t8 t8 CREATE TABLE public.t8 ( x STRING NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT t8_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (x, rowid) + CONSTRAINT t8_pkey PRIMARY KEY (rowid ASC) ) # Ensure ALTER COLUMN TYPE is disallowed if column is part of primary key. @@ -445,8 +443,7 @@ table_name create_statement t24 CREATE TABLE public.t24 ( x STRING NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT t24_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (x, rowid) + CONSTRAINT t24_pkey PRIMARY KEY (rowid ASC) ) # Ensure USING EXPRESSION rolls back if the USING EXPRESSION does not conform diff --git a/pkg/sql/logictest/testdata/logic_test/alter_primary_key b/pkg/sql/logictest/testdata/logic_test/alter_primary_key index 9722fb0c0e4b..c35d0bf74baa 100644 --- a/pkg/sql/logictest/testdata/logic_test/alter_primary_key +++ b/pkg/sql/logictest/testdata/logic_test/alter_primary_key @@ -450,8 +450,7 @@ SHOW CREATE t t CREATE TABLE public.t ( rowid INT8 NOT NULL, rowid_1 INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT t_pkey PRIMARY KEY (rowid_1 ASC), - FAMILY "primary" (rowid, rowid_1) + CONSTRAINT t_pkey PRIMARY KEY (rowid_1 ASC) ) statement ok @@ -463,8 +462,7 @@ SHOW CREATE t t CREATE TABLE public.t ( rowid INT8 NOT NULL, rowid_1 INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT t_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (rowid, rowid_1) + CONSTRAINT t_pkey PRIMARY KEY (rowid ASC) ) # Regression for old primary key not using PrimaryIndexEncoding as its encoding type. @@ -535,8 +533,7 @@ SHOW CREATE t t CREATE TABLE public.t ( x INT8 NOT NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT t_pkey PRIMARY KEY (x ASC), - FAMILY "primary" (x, rowid) + CONSTRAINT t_pkey PRIMARY KEY (x ASC) ) statement ok @@ -551,8 +548,7 @@ t CREATE TABLE public.t ( x INT8 NOT NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), crdb_internal_x_shard_4 INT4 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(x)), 4:::INT8)) VIRTUAL, - CONSTRAINT t_pkey PRIMARY KEY (x ASC) USING HASH WITH (bucket_count=4), - FAMILY "primary" (x, rowid) + CONSTRAINT t_pkey PRIMARY KEY (x ASC) USING HASH WITH (bucket_count=4) ) statement ok @@ -566,8 +562,7 @@ SHOW CREATE t t CREATE TABLE public.t ( x INT8 NOT NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT my_pk PRIMARY KEY (x ASC), - FAMILY "primary" (x, rowid) + CONSTRAINT my_pk PRIMARY KEY (x ASC) ) statement ok @@ -944,8 +939,7 @@ t CREATE TABLE public.t ( crdb_internal_x_shard_2 INT4 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(x)), 2:::INT8)) VIRTUAL, x INT8 NOT NULL, crdb_internal_x_shard_3 INT4 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(x)), 3:::INT8)) VIRTUAL, - CONSTRAINT t_pkey PRIMARY KEY (x ASC) USING HASH WITH (bucket_count=3), - FAMILY "primary" (x) + CONSTRAINT t_pkey PRIMARY KEY (x ASC) USING HASH WITH (bucket_count=3) ) # Changes on a hash sharded index that change the columns will cause the old @@ -1236,13 +1230,12 @@ query T SELECT @2 FROM [SHOW CREATE TABLE t]; ---- CREATE TABLE public.t ( - a INT8 NOT NULL, - b INT8 NOT NULL, - k INT8 NOT NULL AS (a + b) VIRTUAL, - CONSTRAINT t_pkey PRIMARY KEY (k ASC), - UNIQUE INDEX t_a_key (a ASC), - INDEX t_idx_b_k (b ASC, k ASC), - FAMILY "primary" (a, b) + a INT8 NOT NULL, + b INT8 NOT NULL, + k INT8 NOT NULL AS (a + b) VIRTUAL, + CONSTRAINT t_pkey PRIMARY KEY (k ASC), + UNIQUE INDEX t_a_key (a ASC), + INDEX t_idx_b_k (b ASC, k ASC) ) query III colnames,rowsort @@ -1273,14 +1266,13 @@ query T SELECT @2 FROM [SHOW CREATE TABLE t]; ---- CREATE TABLE public.t ( - a INT8 NOT NULL, - b INT8 NOT NULL, - k INT8 NOT NULL AS (a + b) VIRTUAL, - CONSTRAINT t_pkey PRIMARY KEY (b ASC, k ASC), - UNIQUE INDEX t_k_key (k ASC), - UNIQUE INDEX t_a_key (a ASC), - INDEX t_idx_b_k (b ASC, k ASC), - FAMILY "primary" (a, b) + a INT8 NOT NULL, + b INT8 NOT NULL, + k INT8 NOT NULL AS (a + b) VIRTUAL, + CONSTRAINT t_pkey PRIMARY KEY (b ASC, k ASC), + UNIQUE INDEX t_k_key (k ASC), + UNIQUE INDEX t_a_key (a ASC), + INDEX t_idx_b_k (b ASC, k ASC) ) query III colnames,rowsort @@ -1318,15 +1310,14 @@ query T SELECT @2 FROM [SHOW CREATE TABLE t]; ---- CREATE TABLE public.t ( - a INT8 NOT NULL, - b INT8 NOT NULL, - k INT8 NOT NULL AS (a + b) VIRTUAL, - CONSTRAINT t_pkey PRIMARY KEY (a ASC), - UNIQUE INDEX t_b_k_key (b ASC, k ASC), - UNIQUE INDEX t_k_key (k ASC), - UNIQUE INDEX t_a_key (a ASC), - INDEX t_idx_b_k (b ASC, k ASC), - FAMILY "primary" (a, b) + a INT8 NOT NULL, + b INT8 NOT NULL, + k INT8 NOT NULL AS (a + b) VIRTUAL, + CONSTRAINT t_pkey PRIMARY KEY (a ASC), + UNIQUE INDEX t_b_k_key (b ASC, k ASC), + UNIQUE INDEX t_k_key (k ASC), + UNIQUE INDEX t_a_key (a ASC), + INDEX t_idx_b_k (b ASC, k ASC) ) query III colnames,rowsort diff --git a/pkg/sql/logictest/testdata/logic_test/alter_table b/pkg/sql/logictest/testdata/logic_test/alter_table index 5ff79f344aa0..3c74ce98db30 100644 --- a/pkg/sql/logictest/testdata/logic_test/alter_table +++ b/pkg/sql/logictest/testdata/logic_test/alter_table @@ -816,8 +816,7 @@ show create table decomputed_column decomputed_column CREATE TABLE public.decomputed_column ( a INT8 NOT NULL, b INT8 NULL, - CONSTRAINT decomputed_column_pkey PRIMARY KEY (a ASC), - FAMILY "primary" (a, b) + CONSTRAINT decomputed_column_pkey PRIMARY KEY (a ASC) ) # Test for https://github.com/cockroachdb/cockroach/issues/26483 @@ -1154,8 +1153,7 @@ t2 CREATE TABLE public.t2 ( rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), x INT8 NULL, CONSTRAINT t2_pkey PRIMARY KEY (rowid ASC), - CONSTRAINT t2_x_fkey FOREIGN KEY (x) REFERENCES public.t1(x), - FAMILY "primary" (y, rowid, x) + CONSTRAINT t2_x_fkey FOREIGN KEY (x) REFERENCES public.t1(x) ) # Test that only one index gets created when adding a column @@ -1175,8 +1173,7 @@ t3 CREATE TABLE public.t3 ( x INT8 NULL, CONSTRAINT t3_pkey PRIMARY KEY (rowid ASC), CONSTRAINT t3_x_fkey FOREIGN KEY (x) REFERENCES public.t1(x), - UNIQUE INDEX t3_x_key (x ASC), - FAMILY "primary" (y, rowid, x) + UNIQUE INDEX t3_x_key (x ASC) ) # We allowed the foreign key validation code to look into the mutations @@ -1211,8 +1208,7 @@ t1 CREATE TABLE public.t1 ( x INT8 NOT NULL, x2 INT8 NULL, CONSTRAINT t1_pkey PRIMARY KEY (x ASC), - CONSTRAINT t1_x2_fkey FOREIGN KEY (x2) REFERENCES public.t1(x), - FAMILY "primary" (x, x2) + CONSTRAINT t1_x2_fkey FOREIGN KEY (x2) REFERENCES public.t1(x) ) statement error pq: insert on table "t1" violates foreign key constraint "t1_x2_fkey" @@ -1237,8 +1233,7 @@ t2 CREATE TABLE public.t2 ( rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), x INT8 NULL, CONSTRAINT t2_pkey PRIMARY KEY (rowid ASC), - CONSTRAINT t2_x_fkey FOREIGN KEY (x) REFERENCES public.t1(x) NOT VALID, - FAMILY "primary" (y, rowid, x) + CONSTRAINT t2_x_fkey FOREIGN KEY (x) REFERENCES public.t1(x) NOT VALID ) # Test that we can also add a column and then an FK in the same txn. @@ -1261,8 +1256,7 @@ t2 CREATE TABLE public.t2 ( rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), x INT8 NULL, CONSTRAINT t2_pkey PRIMARY KEY (rowid ASC), - CONSTRAINT t2_x_fkey FOREIGN KEY (x) REFERENCES public.t1(x) NOT VALID, - FAMILY "primary" (y, rowid, x) + CONSTRAINT t2_x_fkey FOREIGN KEY (x) REFERENCES public.t1(x) NOT VALID ) # Test that we can add a column and an index to an FK in the same txn. @@ -1289,8 +1283,7 @@ t2 CREATE TABLE public.t2 ( x INT8 NULL, CONSTRAINT t2_pkey PRIMARY KEY (rowid ASC), CONSTRAINT t2_x_fkey FOREIGN KEY (x) REFERENCES public.t1(x) NOT VALID, - INDEX t2_x_idx (x ASC), - FAMILY "primary" (y, rowid, x) + INDEX t2_x_idx (x ASC) ) # Test the above on a table not created in the same txn. @@ -1315,8 +1308,7 @@ t2 CREATE TABLE public.t2 ( x INT8 NULL, CONSTRAINT t2_pkey PRIMARY KEY (rowid ASC), CONSTRAINT t2_x_fkey FOREIGN KEY (x) REFERENCES public.t1(x), - INDEX t2_x_idx (x ASC), - FAMILY "primary" (y, rowid, x) + INDEX t2_x_idx (x ASC) ) # Test that an FK can use a newly created index. @@ -1339,8 +1331,7 @@ t2 CREATE TABLE public.t2 ( rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), CONSTRAINT t2_pkey PRIMARY KEY (rowid ASC), CONSTRAINT t2_x_fkey FOREIGN KEY (x) REFERENCES public.t1(x), - INDEX t2_x_idx (x ASC), - FAMILY "primary" (x, rowid) + INDEX t2_x_idx (x ASC) ) # Test when default column value leads to an FK violation. @@ -1369,8 +1360,7 @@ t2 CREATE TABLE public.t2 ( x INT8 NULL DEFAULT 1:::INT8, CONSTRAINT t2_pkey PRIMARY KEY (rowid ASC), CONSTRAINT t2_x_fkey FOREIGN KEY (x) REFERENCES public.t1(x), - UNIQUE INDEX t2_x_key (x ASC), - FAMILY "primary" (y, rowid, x) + UNIQUE INDEX t2_x_key (x ASC) ) # Regression 50069, computed exprs must only refer to columns inside the @@ -1807,8 +1797,7 @@ SHOW CREATE TABLE visible_table ---- visible_table CREATE TABLE public.visible_table ( a INT8 NOT NULL, - CONSTRAINT visible_table_pkey PRIMARY KEY (a ASC), - FAMILY "primary" (a) + CONSTRAINT visible_table_pkey PRIMARY KEY (a ASC) ) statement ok @@ -1819,8 +1808,7 @@ SHOW CREATE TABLE visible_table ---- visible_table CREATE TABLE public.visible_table ( a INT8 NOT VISIBLE NOT NULL, - CONSTRAINT visible_table_pkey PRIMARY KEY (a ASC), - FAMILY "primary" (a) + CONSTRAINT visible_table_pkey PRIMARY KEY (a ASC) ) subtest if_table_exists_already @@ -1917,8 +1905,7 @@ t CREATE TABLE public.t ( b INT8 NOT NULL GENERATED ALWAYS AS IDENTITY, c INT8 NOT NULL GENERATED BY DEFAULT AS IDENTITY, CONSTRAINT t_pkey PRIMARY KEY (rowid ASC), - UNIQUE INDEX t_a_key (a ASC), - FAMILY "primary" (a, rowid, b, c) + UNIQUE INDEX t_a_key (a ASC) ) statement ok @@ -1981,8 +1968,7 @@ t CREATE TABLE public.t ( b INT8 NOT NULL GENERATED BY DEFAULT AS IDENTITY (START 1 INCREMENT 3), c INT8 NOT NULL GENERATED BY DEFAULT AS IDENTITY (START 1 INCREMENT 3 CACHE 10), CONSTRAINT t_pkey PRIMARY KEY (rowid ASC), - UNIQUE INDEX t_a_key (a ASC), - FAMILY "primary" (a, rowid, b, c) + UNIQUE INDEX t_a_key (a ASC) ) statement ok @@ -2029,8 +2015,7 @@ SHOW CREATE TABLE t t CREATE TABLE public.t ( id INT8 NOT NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT t_pkey PRIMARY KEY (id ASC), - FAMILY "primary" (id, rowid) + CONSTRAINT t_pkey PRIMARY KEY (id ASC) ) # Table has a PRIMARY KEY named index; check it errors when assinging PRIMARY KEY to id. diff --git a/pkg/sql/logictest/testdata/logic_test/array b/pkg/sql/logictest/testdata/logic_test/array index 0a4bd3a81f48..7e3bb8b96f44 100644 --- a/pkg/sql/logictest/testdata/logic_test/array +++ b/pkg/sql/logictest/testdata/logic_test/array @@ -467,8 +467,7 @@ SHOW CREATE TABLE a a CREATE TABLE public.a ( b INT8[] NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT a_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (b, rowid) + CONSTRAINT a_pkey PRIMARY KEY (rowid ASC) ) statement ok @@ -528,8 +527,7 @@ SHOW CREATE TABLE a a CREATE TABLE public.a ( b INT8[] NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT a_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (b, rowid) + CONSTRAINT a_pkey PRIMARY KEY (rowid ASC) ) statement error could not parse "foo" as type int @@ -601,8 +599,7 @@ SHOW CREATE TABLE a a CREATE TABLE public.a ( b INT2[] NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT a_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (b, rowid) + CONSTRAINT a_pkey PRIMARY KEY (rowid ASC) ) statement error integer out of range for type int2 diff --git a/pkg/sql/logictest/testdata/logic_test/bit b/pkg/sql/logictest/testdata/logic_test/bit index 00a19befedc0..90fe34b90313 100644 --- a/pkg/sql/logictest/testdata/logic_test/bit +++ b/pkg/sql/logictest/testdata/logic_test/bit @@ -21,8 +21,7 @@ bits CREATE TABLE public.bits ( c VARBIT NULL, d VARBIT(4) NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT bits_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, b, c, d, rowid) + CONSTRAINT bits_pkey PRIMARY KEY (rowid ASC) ) subtest bit_fixed1 @@ -269,8 +268,7 @@ SELECT create_statement FROM [SHOW CREATE obitsa] CREATE TABLE public.obitsa ( x VARBIT(20)[] NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT obitsa_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (x, rowid) + CONSTRAINT obitsa_pkey PRIMARY KEY (rowid ASC) ) # Check unindexed ordering. diff --git a/pkg/sql/logictest/testdata/logic_test/check_constraints b/pkg/sql/logictest/testdata/logic_test/check_constraints index 23f4cd6f07f9..4e959ba20498 100644 --- a/pkg/sql/logictest/testdata/logic_test/check_constraints +++ b/pkg/sql/logictest/testdata/logic_test/check_constraints @@ -221,7 +221,6 @@ t7 CREATE TABLE public.t7 ( z INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), CONSTRAINT t7_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (x, y, z, rowid), CONSTRAINT check_x CHECK (x > 0:::INT8), CONSTRAINT check_x_y CHECK ((x + y) > 0:::INT8), CONSTRAINT check_y_z CHECK ((y + z) > 0:::INT8), @@ -258,7 +257,6 @@ t8 CREATE TABLE public.t8 ( a INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), CONSTRAINT t8_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, rowid), CONSTRAINT check_a CHECK (a > 0:::INT8), CONSTRAINT check_a1 CHECK (a > 0:::INT8), CONSTRAINT check_a2 CHECK (a > 0:::INT8) diff --git a/pkg/sql/logictest/testdata/logic_test/collatedstring b/pkg/sql/logictest/testdata/logic_test/collatedstring index 14eb1c96d702..0a889df11dc1 100644 --- a/pkg/sql/logictest/testdata/logic_test/collatedstring +++ b/pkg/sql/logictest/testdata/logic_test/collatedstring @@ -218,8 +218,7 @@ SHOW CREATE TABLE t t CREATE TABLE public.t ( a STRING COLLATE en NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT t_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, rowid) + CONSTRAINT t_pkey PRIMARY KEY (rowid ASC) ) statement ok @@ -368,8 +367,7 @@ quoted_coll CREATE TABLE public.quoted_coll ( d STRING COLLATE en_u_ks_level1 NULL DEFAULT 'd':::STRING COLLATE en_u_ks_level1, e STRING COLLATE en_US NULL AS (a COLLATE en_US) STORED, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT quoted_coll_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, b, c, d, e, rowid) + CONSTRAINT quoted_coll_pkey PRIMARY KEY (rowid ASC) ) # Regression for #46570. @@ -471,8 +469,7 @@ SHOW CREATE TABLE collation_name_case collation_name_case CREATE TABLE public.collation_name_case ( s STRING COLLATE en_US_u_ks_level2 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT collation_name_case_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (s, rowid) + CONSTRAINT collation_name_case_pkey PRIMARY KEY (rowid ASC) ) statement error invalid locale en-US-u-ks-le"vel2: language: tag is not well-formed diff --git a/pkg/sql/logictest/testdata/logic_test/computed b/pkg/sql/logictest/testdata/logic_test/computed index 84fa6aba8a2b..d895c5363777 100644 --- a/pkg/sql/logictest/testdata/logic_test/computed +++ b/pkg/sql/logictest/testdata/logic_test/computed @@ -17,8 +17,7 @@ with_no_column_refs CREATE TABLE public.with_no_column_refs ( b INT8 NULL, c INT8 NULL AS (3:::INT8) STORED, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT with_no_column_refs_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, b, c, rowid) + CONSTRAINT with_no_column_refs_pkey PRIMARY KEY (rowid ASC) ) statement ok @@ -37,8 +36,7 @@ extra_parens CREATE TABLE public.extra_parens ( b INT8 NULL, c INT8 NULL AS (3:::INT8) STORED, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT extra_parens_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, b, c, rowid) + CONSTRAINT extra_parens_pkey PRIMARY KEY (rowid ASC) ) @@ -93,8 +91,7 @@ x CREATE TABLE public.x ( c INT8 NULL AS (a) STORED, d INT8 NULL AS (a + b) STORED, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT x_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, b, c, d, rowid) + CONSTRAINT x_pkey PRIMARY KEY (rowid ASC) ) query TTBTTTB colnames @@ -721,8 +718,7 @@ x CREATE TABLE public.x ( a INT8 NULL, b INT8 NULL AS (a) STORED, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT x_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, b, rowid) + CONSTRAINT x_pkey PRIMARY KEY (rowid ASC) ) statement ok @@ -746,8 +742,7 @@ x CREATE TABLE public.x ( c INT8 NULL, b INT8 NULL AS (c) STORED, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT x_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (c, b, rowid) + CONSTRAINT x_pkey PRIMARY KEY (rowid ASC) ) statement ok @@ -788,8 +783,7 @@ x CREATE TABLE public.x ( b INT8 NULL AS (a * 2:::INT8) STORED, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), c INT8 NOT NULL AS (a + 4:::INT8) STORED, - CONSTRAINT x_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, b, rowid, c) + CONSTRAINT x_pkey PRIMARY KEY (rowid ASC) ) statement ok @@ -922,8 +916,7 @@ t42418 CREATE TABLE public.t42418 ( x INT8 NULL AS (1:::INT8) STORED, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), y INT8 NULL AS (1:::INT8) STORED, - CONSTRAINT t42418_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (x, rowid, y) + CONSTRAINT t42418_pkey PRIMARY KEY (rowid ASC) ) # Tests for computed column rewrites. @@ -980,8 +973,7 @@ CREATE TABLE public.trewrite_copy ( k INT8 NOT NULL, ts TIMESTAMPTZ NULL, c STRING NULL AS (timezone('utc':::STRING, ts)::STRING) STORED, - CONSTRAINT trewrite_pkey PRIMARY KEY (k ASC), - FAMILY "primary" (k, ts, c) + CONSTRAINT trewrite_pkey PRIMARY KEY (k ASC) ) statement ok diff --git a/pkg/sql/logictest/testdata/logic_test/crdb_internal b/pkg/sql/logictest/testdata/logic_test/crdb_internal index 72c43296b0d2..0f75accd8cf9 100644 --- a/pkg/sql/logictest/testdata/logic_test/crdb_internal +++ b/pkg/sql/logictest/testdata/logic_test/crdb_internal @@ -396,10 +396,10 @@ SELECT * FROM crdb_internal.table_columns WHERE descriptor_name = '' ---- descriptor_id descriptor_name column_id column_name column_type nullable default_expr hidden -query ITITTBBB colnames +query ITITTBBBT colnames SELECT * FROM crdb_internal.table_indexes WHERE descriptor_name = '' ---- -descriptor_id descriptor_name index_id index_name index_type is_unique is_inverted is_sharded +descriptor_id descriptor_name index_id index_name index_type is_unique is_inverted is_sharded created_at query ITITTITTB colnames SELECT * FROM crdb_internal.index_columns WHERE descriptor_name = '' diff --git a/pkg/sql/logictest/testdata/logic_test/create_as b/pkg/sql/logictest/testdata/logic_test/create_as index 9f086c78d969..9ace5116b5c8 100644 --- a/pkg/sql/logictest/testdata/logic_test/create_as +++ b/pkg/sql/logictest/testdata/logic_test/create_as @@ -158,8 +158,7 @@ foo5 CREATE TABLE public.foo5 ( a INT8 NULL, b INT8 NOT NULL, c INT8 NULL, - CONSTRAINT foo5_pkey PRIMARY KEY (b ASC), - FAMILY "primary" (a, b, c) + CONSTRAINT foo5_pkey PRIMARY KEY (b ASC) ) statement ok @@ -176,8 +175,7 @@ foo6 CREATE TABLE public.foo6 ( a INT8 NOT NULL, b INT8 NULL, c INT8 NULL, - CONSTRAINT foo6_pkey PRIMARY KEY (a ASC), - FAMILY "primary" (a, b, c) + CONSTRAINT foo6_pkey PRIMARY KEY (a ASC) ) statement error generate insert row: null value in column "x" violates not-null constraint @@ -192,8 +190,7 @@ SHOW CREATE TABLE foo8 foo8 CREATE TABLE public.foo8 ( item STRING NOT NULL, qty INT8 NULL, - CONSTRAINT foo8_pkey PRIMARY KEY (item ASC), - FAMILY "primary" (item, qty) + CONSTRAINT foo8_pkey PRIMARY KEY (item ASC) ) # Allow CREATE TABLE AS to specify composite primary keys. @@ -212,8 +209,7 @@ foo9 CREATE TABLE public.foo9 ( a INT8 NOT NULL, b INT8 NULL, c INT8 NOT NULL, - CONSTRAINT foo9_pkey PRIMARY KEY (a ASC, c ASC), - FAMILY "primary" (a, b, c) + CONSTRAINT foo9_pkey PRIMARY KEY (a ASC, c ASC) ) statement ok @@ -226,8 +222,7 @@ foo10 CREATE TABLE public.foo10 ( a INT8 NOT NULL, b INT8 NOT NULL, c INT8 NOT NULL, - CONSTRAINT foo10_pkey PRIMARY KEY (c ASC, b ASC, a ASC), - FAMILY "primary" (a, b, c) + CONSTRAINT foo10_pkey PRIMARY KEY (c ASC, b ASC, a ASC) ) statement ok @@ -245,8 +240,7 @@ foo11 CREATE TABLE public.foo11 ( x INT8 NOT NULL, y INT8 NULL, z INT8 NOT NULL, - CONSTRAINT foo11_pkey PRIMARY KEY (x ASC, z ASC), - FAMILY "primary" (x, y, z) + CONSTRAINT foo11_pkey PRIMARY KEY (x ASC, z ASC) ) statement error pq: multiple primary keys for table "foo12" are not allowed diff --git a/pkg/sql/logictest/testdata/logic_test/create_index b/pkg/sql/logictest/testdata/logic_test/create_index index 48f4eabde04f..6667244de49d 100644 --- a/pkg/sql/logictest/testdata/logic_test/create_index +++ b/pkg/sql/logictest/testdata/logic_test/create_index @@ -170,8 +170,7 @@ create_index_concurrently_tbl CREATE TABLE public.create_index_concurrently_tbl a INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), CONSTRAINT create_index_concurrently_tbl_pkey PRIMARY KEY (rowid ASC), - INDEX create_index_concurrently_idx (a ASC), - FAMILY "primary" (a, rowid) + INDEX create_index_concurrently_idx (a ASC) ) query T noticetrace @@ -192,8 +191,7 @@ SHOW CREATE TABLE create_index_concurrently_tbl create_index_concurrently_tbl CREATE TABLE public.create_index_concurrently_tbl ( a INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT create_index_concurrently_tbl_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, rowid) + CONSTRAINT create_index_concurrently_tbl_pkey PRIMARY KEY (rowid ASC) ) statement ok diff --git a/pkg/sql/logictest/testdata/logic_test/create_statements b/pkg/sql/logictest/testdata/logic_test/create_statements index 17fdb42c0429..abe177d165d8 100644 --- a/pkg/sql/logictest/testdata/logic_test/create_statements +++ b/pkg/sql/logictest/testdata/logic_test/create_statements @@ -1444,7 +1444,8 @@ CREATE TABLE crdb_internal.table_indexes ( index_type STRING NOT NULL, is_unique BOOL NOT NULL, is_inverted BOOL NOT NULL, - is_sharded BOOL NOT NULL + is_sharded BOOL NOT NULL, + created_at TIMESTAMP NULL ) CREATE TABLE crdb_internal.table_indexes ( descriptor_id INT8 NULL, descriptor_name STRING NOT NULL, @@ -1453,7 +1454,8 @@ CREATE TABLE crdb_internal.table_indexes ( index_type STRING NOT NULL, is_unique BOOL NOT NULL, is_inverted BOOL NOT NULL, - is_sharded BOOL NOT NULL + is_sharded BOOL NOT NULL, + created_at TIMESTAMP NULL ) {} {} CREATE TABLE crdb_internal.table_row_statistics ( table_id INT8 NOT NULL, @@ -6512,13 +6514,11 @@ CREATE TABLE public.t ( a INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), CONSTRAINT t_pkey PRIMARY KEY (rowid ASC), - CONSTRAINT t_a_fkey FOREIGN KEY (a) REFERENCES public.t(rowid), - FAMILY "primary" (a, rowid) + CONSTRAINT t_a_fkey FOREIGN KEY (a) REFERENCES public.t(rowid) ) CREATE TABLE public.t ( a INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT t_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, rowid) + CONSTRAINT t_pkey PRIMARY KEY (rowid ASC) ) {"ALTER TABLE public.t ADD CONSTRAINT t_a_fkey FOREIGN KEY (a) REFERENCES public.t(rowid)"} {"ALTER TABLE public.t VALIDATE CONSTRAINT t_a_fkey"} CREATE TABLE public.v ( "'" INT8 NULL, @@ -6527,15 +6527,13 @@ CREATE TABLE public.v ( CONSTRAINT v_pkey PRIMARY KEY (rowid ASC), CONSTRAINT "v_'_fkey" FOREIGN KEY ("'") REFERENCES public.t(rowid), CONSTRAINT v_s_fkey FOREIGN KEY (s) REFERENCES public.v(s), - UNIQUE INDEX v_s_key (s ASC), - FAMILY "primary" ("'", s, rowid) + UNIQUE INDEX v_s_key (s ASC) ) CREATE TABLE public.v ( "'" INT8 NULL, s STRING NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), CONSTRAINT v_pkey PRIMARY KEY (rowid ASC), - UNIQUE INDEX v_s_key (s ASC), - FAMILY "primary" ("'", s, rowid) + UNIQUE INDEX v_s_key (s ASC) ) {"ALTER TABLE public.v ADD CONSTRAINT \"v_'_fkey\" FOREIGN KEY (\"'\") REFERENCES public.t(rowid)","ALTER TABLE public.v ADD CONSTRAINT v_s_fkey FOREIGN KEY (s) REFERENCES public.v(s)"} {"ALTER TABLE public.v VALIDATE CONSTRAINT \"v_'_fkey\"","ALTER TABLE public.v VALIDATE CONSTRAINT v_s_fkey"} CREATE TABLE public.c ( a INT8 NOT NULL, @@ -6571,8 +6569,7 @@ SHOW CREATE TABLE unlogged_tbl ---- unlogged_tbl CREATE TABLE public.unlogged_tbl ( col INT8 NOT NULL, - CONSTRAINT unlogged_tbl_pkey PRIMARY KEY (col ASC), - FAMILY "primary" (col) + CONSTRAINT unlogged_tbl_pkey PRIMARY KEY (col ASC) ) statement error pgcode 22023 invalid storage parameter "foo" diff --git a/pkg/sql/logictest/testdata/logic_test/create_table b/pkg/sql/logictest/testdata/logic_test/create_table index 10e80bf84a5c..0b54c4b56a52 100644 --- a/pkg/sql/logictest/testdata/logic_test/create_table +++ b/pkg/sql/logictest/testdata/logic_test/create_table @@ -154,8 +154,7 @@ like_none CREATE TABLE public.like_none ( k INT8 NULL, t TIMESTAMPTZ NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT like_none_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, b, c, h, j, k, t, rowid) + CONSTRAINT like_none_pkey PRIMARY KEY (rowid ASC) ) statement ok @@ -174,7 +173,6 @@ like_constraints CREATE TABLE public.like_constraints ( t TIMESTAMPTZ NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), CONSTRAINT like_constraints_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, b, c, h, j, k, t, rowid), CONSTRAINT check_a CHECK (a > 3:::INT8), CONSTRAINT unique_k UNIQUE WITHOUT INDEX (k), CONSTRAINT unique_h UNIQUE WITHOUT INDEX (h), @@ -198,8 +196,7 @@ like_indexes CREATE TABLE public.like_indexes ( CONSTRAINT like_table_pkey PRIMARY KEY (a ASC, b ASC), UNIQUE INDEX foo (b DESC, c ASC), INDEX like_table_c_idx (c ASC) STORING (j), - INVERTED INDEX like_table_j_idx (j), - FAMILY "primary" (a, b, c, h, j, k, t) + INVERTED INDEX like_table_j_idx (j) ) # INCLUDING GENERATED adds "generated columns", aka stored columns. @@ -218,8 +215,7 @@ like_generated CREATE TABLE public.like_generated ( k INT8 NULL, t TIMESTAMPTZ NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT like_generated_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, b, c, h, j, k, t, rowid) + CONSTRAINT like_generated_pkey PRIMARY KEY (rowid ASC) ) statement ok @@ -237,8 +233,7 @@ like_defaults CREATE TABLE public.like_defaults ( k INT8 NULL, t TIMESTAMPTZ NULL DEFAULT current_timestamp():::TIMESTAMPTZ - '00:00:05':::INTERVAL ON UPDATE current_timestamp():::TIMESTAMPTZ, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT like_defaults_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, b, c, h, j, k, t, rowid) + CONSTRAINT like_defaults_pkey PRIMARY KEY (rowid ASC) ) statement ok @@ -259,7 +254,6 @@ like_all CREATE TABLE public.like_all ( UNIQUE INDEX foo (b DESC, c ASC), INDEX like_table_c_idx (c ASC) STORING (j), INVERTED INDEX like_table_j_idx (j), - FAMILY "primary" (a, b, c, h, j, k, t), CONSTRAINT check_a CHECK (a > 3:::INT8), CONSTRAINT unique_k UNIQUE WITHOUT INDEX (k), CONSTRAINT unique_h UNIQUE WITHOUT INDEX (h), @@ -285,8 +279,7 @@ like_mixed CREATE TABLE public.like_mixed ( CONSTRAINT like_table_pkey PRIMARY KEY (a ASC, b ASC), UNIQUE INDEX foo (b DESC, c ASC), INDEX like_table_c_idx (c ASC) STORING (j), - INVERTED INDEX like_table_j_idx (j), - FAMILY "primary" (a, b, c, h, j, k, t) + INVERTED INDEX like_table_j_idx (j) ) statement ok @@ -304,8 +297,7 @@ like_no_pk_rowid_hidden CREATE TABLE public.like_no_pk_rowid_hidden ( a INT8 NULL, b INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT like_no_pk_table_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, b, rowid) + CONSTRAINT like_no_pk_table_pkey PRIMARY KEY (rowid ASC) ) statement error duplicate column name @@ -335,8 +327,7 @@ like_more_specifiers CREATE TABLE public.like_more_specifiers ( rowid INT8 NOT VISIBLE NOT NULL, rowid_1 INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), CONSTRAINT like_more_specifiers_pkey PRIMARY KEY (rowid_1 ASC), - INDEX like_more_specifiers_a_blah_z_idx (a ASC, blah ASC, z ASC), - FAMILY "primary" (a, b, c, h, j, k, t, z, blah, rowid, rowid_1) + INDEX like_more_specifiers_a_blah_z_idx (a ASC, blah ASC, z ASC) ) statement ok @@ -353,8 +344,7 @@ like_hash CREATE TABLE public.like_hash ( crdb_internal_a_shard_4 INT4 NOT VISIBLE NOT NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), CONSTRAINT like_hash_base_pkey PRIMARY KEY (rowid ASC), - INDEX like_hash_base_a_idx (a ASC) USING HASH WITH (bucket_count=4), - FAMILY "primary" (a, crdb_internal_a_shard_4, rowid) + INDEX like_hash_base_a_idx (a ASC) USING HASH WITH (bucket_count=4) ) statement ok @@ -368,8 +358,7 @@ like_hash CREATE TABLE public.like_hash ( crdb_internal_a_shard_4 INT4 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(a)), 4:::INT8)) VIRTUAL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), CONSTRAINT like_hash_base_pkey PRIMARY KEY (rowid ASC), - INDEX like_hash_base_a_idx (a ASC) USING HASH WITH (bucket_count=4), - FAMILY "primary" (a, rowid) + INDEX like_hash_base_a_idx (a ASC) USING HASH WITH (bucket_count=4) ) statement ok @@ -383,8 +372,7 @@ regression_67196_like CREATE TABLE public.regression_67196_like ( pk INT8 NOT NULL, hidden INT8 NOT VISIBLE NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT regression_67196_like_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (pk, hidden, rowid) + CONSTRAINT regression_67196_like_pkey PRIMARY KEY (rowid ASC) ) statement error unimplemented @@ -857,14 +845,13 @@ query T SELECT @2 FROM [SHOW CREATE TABLE t_good_hash_indexes_1]; ---- CREATE TABLE public.t_good_hash_indexes_1 ( - crdb_internal_a_shard_5 INT4 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(a)), 5:::INT8)) VIRTUAL, - a INT8 NOT NULL, - b INT8 NULL, - c INT8 NULL, - crdb_internal_b_shard_5 INT4 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(b)), 5:::INT8)) VIRTUAL, - CONSTRAINT t_good_hash_indexes_1_pkey PRIMARY KEY (a ASC) USING HASH WITH (bucket_count=5), - INDEX t_good_hash_indexes_1_b_idx (b ASC) USING HASH WITH (bucket_count=5), - FAMILY "primary" (a, b, c) + crdb_internal_a_shard_5 INT4 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(a)), 5:::INT8)) VIRTUAL, + a INT8 NOT NULL, + b INT8 NULL, + c INT8 NULL, + crdb_internal_b_shard_5 INT4 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(b)), 5:::INT8)) VIRTUAL, + CONSTRAINT t_good_hash_indexes_1_pkey PRIMARY KEY (a ASC) USING HASH WITH (bucket_count=5), + INDEX t_good_hash_indexes_1_b_idx (b ASC) USING HASH WITH (bucket_count=5) ) statement ok @@ -877,8 +864,7 @@ query T SELECT @2 FROM [SHOW CREATE TABLE t_good_hash_indexes_2]; ---- CREATE TABLE public.t_good_hash_indexes_2 ( - a INT8 NOT NULL, - crdb_internal_a_shard_5 INT4 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(a)), 5:::INT8)) VIRTUAL, - CONSTRAINT t_good_hash_indexes_2_pkey PRIMARY KEY (a ASC) USING HASH WITH (bucket_count=5), - FAMILY "primary" (a) + a INT8 NOT NULL, + crdb_internal_a_shard_5 INT4 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(a)), 5:::INT8)) VIRTUAL, + CONSTRAINT t_good_hash_indexes_2_pkey PRIMARY KEY (a ASC) USING HASH WITH (bucket_count=5) ) diff --git a/pkg/sql/logictest/testdata/logic_test/delete b/pkg/sql/logictest/testdata/logic_test/delete index d77de50a637d..dc1d5a2db7c5 100644 --- a/pkg/sql/logictest/testdata/logic_test/delete +++ b/pkg/sql/logictest/testdata/logic_test/delete @@ -239,8 +239,7 @@ SELECT create_statement FROM [SHOW CREATE t29494] ---- CREATE TABLE public.t29494 ( x INT8 NOT NULL, - CONSTRAINT t29494_pkey PRIMARY KEY (x ASC), - FAMILY "primary" (x) + CONSTRAINT t29494_pkey PRIMARY KEY (x ASC) ) # Check that the new column is not usable in RETURNING diff --git a/pkg/sql/logictest/testdata/logic_test/dependencies b/pkg/sql/logictest/testdata/logic_test/dependencies index 41dcfcfa5492..0d18cbab6770 100644 --- a/pkg/sql/logictest/testdata/logic_test/dependencies +++ b/pkg/sql/logictest/testdata/logic_test/dependencies @@ -42,7 +42,10 @@ descriptor_id descriptor_name column_id column_name column_type 115 test_uwi_child 2 rowid family:IntFamily width:64 precision:0 locale:"" visible_type:0 oid:20 time_precision_is_set:false false unique_rowid() true query ITITTBBB colnames -SELECT * FROM crdb_internal.table_indexes WHERE descriptor_name LIKE 'test_%' ORDER BY descriptor_id, index_id + SELECT descriptor_id, descriptor_name, index_id, index_name, index_type, is_unique, is_inverted, is_sharded + FROM crdb_internal.table_indexes + WHERE descriptor_name LIKE 'test_%' +ORDER BY descriptor_id, index_id ---- descriptor_id descriptor_name index_id index_name index_type is_unique is_inverted is_sharded 106 test_kv 1 test_kv_pkey primary true false false diff --git a/pkg/sql/logictest/testdata/logic_test/drop_index b/pkg/sql/logictest/testdata/logic_test/drop_index index 3d41d285f6af..f7e18659a9b3 100644 --- a/pkg/sql/logictest/testdata/logic_test/drop_index +++ b/pkg/sql/logictest/testdata/logic_test/drop_index @@ -301,8 +301,7 @@ fk1 CREATE TABLE public.fk1 ( rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), CONSTRAINT fk1_pkey PRIMARY KEY (rowid ASC), CONSTRAINT fk1 FOREIGN KEY (x) REFERENCES public.fk2(x), - INDEX i2 (x ASC), - FAMILY "primary" (x, rowid) + INDEX i2 (x ASC) ) # test that notices are generated on index drops diff --git a/pkg/sql/logictest/testdata/logic_test/drop_sequence b/pkg/sql/logictest/testdata/logic_test/drop_sequence index cea0078cc0a6..bf0a4a15e38f 100644 --- a/pkg/sql/logictest/testdata/logic_test/drop_sequence +++ b/pkg/sql/logictest/testdata/logic_test/drop_sequence @@ -36,8 +36,7 @@ SHOW CREATE TABLE t1 t1 CREATE TABLE public.t1 ( i INT8 NOT NULL DEFAULT nextval('public.drop_test'::REGCLASS), rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT t1_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (i, rowid) + CONSTRAINT t1_pkey PRIMARY KEY (rowid ASC) ) query T @@ -57,8 +56,7 @@ SHOW CREATE TABLE t1 t1 CREATE TABLE public.t1 ( i INT8 NOT NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT t1_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (i, rowid) + CONSTRAINT t1_pkey PRIMARY KEY (rowid ASC) ) query T @@ -222,8 +220,7 @@ SHOW CREATE TABLE t3 t3 CREATE TABLE public.t3 ( i INT8 NOT NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT t3_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (i, rowid) + CONSTRAINT t3_pkey PRIMARY KEY (rowid ASC) ) query T @@ -257,8 +254,7 @@ SHOW CREATE TABLE t4 t4 CREATE TABLE public.t4 ( i INT8 NOT NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT t4_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (i, rowid) + CONSTRAINT t4_pkey PRIMARY KEY (rowid ASC) ) query T @@ -303,8 +299,7 @@ SHOW CREATE TABLE t6 t6 CREATE TABLE public.t6 ( i INT8 NOT NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT t6_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (i, rowid) + CONSTRAINT t6_pkey PRIMARY KEY (rowid ASC) ) query T diff --git a/pkg/sql/logictest/testdata/logic_test/enums b/pkg/sql/logictest/testdata/logic_test/enums index 2b0bd4dba35b..8c85ebbf08b3 100644 --- a/pkg/sql/logictest/testdata/logic_test/enums +++ b/pkg/sql/logictest/testdata/logic_test/enums @@ -375,8 +375,7 @@ t1 CREATE TABLE public.t1 ( x public.greeting NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), CONSTRAINT t1_pkey PRIMARY KEY (rowid ASC), - INDEX i (x ASC), - FAMILY "primary" (x, rowid) + INDEX i (x ASC) ) # SHOW CREATE uses a virtual index, so also check the code path where a @@ -388,8 +387,7 @@ CREATE TABLE public.t1 ( x public.greeting NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), CONSTRAINT t1_pkey PRIMARY KEY (rowid ASC), - INDEX i (x ASC), - FAMILY "primary" (x, rowid) + INDEX i (x ASC) ) # Test that the implicit array type has been created, and that we can use it. @@ -585,7 +583,6 @@ enum_checks CREATE TABLE public.enum_checks ( x public.greeting NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), CONSTRAINT enum_checks_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (x, rowid), CONSTRAINT check_x CHECK (x = 'hello':::public.greeting), CONSTRAINT "check" CHECK ('hello':::public.greeting = 'hello':::public.greeting) ) diff --git a/pkg/sql/logictest/testdata/logic_test/exclude_data_from_backup b/pkg/sql/logictest/testdata/logic_test/exclude_data_from_backup index a5dc10453884..baf4f52454e5 100644 --- a/pkg/sql/logictest/testdata/logic_test/exclude_data_from_backup +++ b/pkg/sql/logictest/testdata/logic_test/exclude_data_from_backup @@ -13,11 +13,10 @@ ALTER TABLE t SET (exclude_data_from_backup = true); query TT SHOW CREATE TABLE t ---- -t CREATE TABLE public.t ( - x INT8 NOT NULL, - CONSTRAINT t_pkey PRIMARY KEY (x ASC), - FAMILY "primary" (x) - ) WITH (exclude_data_from_backup = true) +t CREATE TABLE public.t ( + x INT8 NOT NULL, + CONSTRAINT t_pkey PRIMARY KEY (x ASC) +) WITH (exclude_data_from_backup = true) statement ok ALTER TABLE t SET (exclude_data_from_backup = false); @@ -25,11 +24,10 @@ ALTER TABLE t SET (exclude_data_from_backup = false); query TT SHOW CREATE TABLE t ---- -t CREATE TABLE public.t ( - x INT8 NOT NULL, - CONSTRAINT t_pkey PRIMARY KEY (x ASC), - FAMILY "primary" (x) - ) +t CREATE TABLE public.t ( + x INT8 NOT NULL, + CONSTRAINT t_pkey PRIMARY KEY (x ASC) +) # Ensure we cannot set schema to a temporary schema. statement ok @@ -56,12 +54,11 @@ query TT SHOW CREATE TABLE t2 ---- t2 CREATE TABLE public.t2 ( - x INT8 NULL, - rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT t2_pkey PRIMARY KEY (rowid ASC), - CONSTRAINT t2_x_fkey FOREIGN KEY (x) REFERENCES public.t(x) ON DELETE CASCADE, - FAMILY "primary" (x, rowid) - ) WITH (exclude_data_from_backup = true) + x INT8 NULL, + rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), + CONSTRAINT t2_pkey PRIMARY KEY (rowid ASC), + CONSTRAINT t2_x_fkey FOREIGN KEY (x) REFERENCES public.t(x) ON DELETE CASCADE +) WITH (exclude_data_from_backup = true) # Check that we can reset exclude_data_from_backup on a table. statement ok @@ -70,10 +67,9 @@ ALTER TABLE t2 RESET (exclude_data_from_backup); query TT SHOW CREATE TABLE t2 ---- -t2 CREATE TABLE public.t2 ( - x INT8 NULL, - rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT t2_pkey PRIMARY KEY (rowid ASC), - CONSTRAINT t2_x_fkey FOREIGN KEY (x) REFERENCES public.t(x) ON DELETE CASCADE, - FAMILY "primary" (x, rowid) - ) +t2 CREATE TABLE public.t2 ( + x INT8 NULL, + rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), + CONSTRAINT t2_pkey PRIMARY KEY (rowid ASC), + CONSTRAINT t2_x_fkey FOREIGN KEY (x) REFERENCES public.t(x) ON DELETE CASCADE +) diff --git a/pkg/sql/logictest/testdata/logic_test/expression_index b/pkg/sql/logictest/testdata/logic_test/expression_index index 35ef478d064f..b271a1b86892 100644 --- a/pkg/sql/logictest/testdata/logic_test/expression_index +++ b/pkg/sql/logictest/testdata/logic_test/expression_index @@ -371,8 +371,7 @@ CREATE TABLE public.copy ( j JSONB NULL, comp INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT copy_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (k, a, b, j, comp, rowid) + CONSTRAINT copy_pkey PRIMARY KEY (rowid ASC) ) # Inaccessible expression index columns should not be copied if the indexes are @@ -396,8 +395,7 @@ CREATE TABLE public.copy_generated ( j JSONB NULL, comp INT8 NULL AS (1:::INT8 + 10:::INT8) VIRTUAL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT copy_generated_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (k, a, b, j, rowid) + CONSTRAINT copy_generated_pkey PRIMARY KEY (rowid ASC) ) # Inaccessible expression index columns should not be copied if the indexes are @@ -424,8 +422,7 @@ CREATE TABLE public.copy_indexes ( INDEX src_expr_idx ((a + b) ASC), INDEX named_idx ((a + 1:::INT8) ASC), UNIQUE INDEX src_expr_key ((a + 10:::INT8) ASC), - INVERTED INDEX src_expr_expr1_idx ((a + b), (j->'a':::STRING)), - FAMILY "primary" (k, a, b, j, comp) + INVERTED INDEX src_expr_expr1_idx ((a + b), (j->'a':::STRING)) ) # Inaccessible expression index columns should be copied if the indexes are @@ -452,8 +449,7 @@ CREATE TABLE public.copy_all ( INDEX src_expr_idx ((a + b) ASC), INDEX named_idx ((a + 1:::INT8) ASC), UNIQUE INDEX src_expr_key ((a + 10:::INT8) ASC), - INVERTED INDEX src_expr_expr1_idx ((a + b), (j->'a':::STRING)), - FAMILY "primary" (k, a, b, j) + INVERTED INDEX src_expr_expr1_idx ((a + b), (j->'a':::STRING)) ) # Inaccessible expression index columns should be copied if the indexes are @@ -918,8 +914,7 @@ t72012 CREATE TABLE public.t72012 ( col INT8 NOT NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), CONSTRAINT t72012_pkey PRIMARY KEY (rowid ASC), - INDEX t72012_idx (abs(col) ASC), - FAMILY "primary" (col, rowid) + INDEX t72012_idx (abs(col) ASC) ) statement ok diff --git a/pkg/sql/logictest/testdata/logic_test/family b/pkg/sql/logictest/testdata/logic_test/family index 43db81ea42af..602a50c654f7 100644 --- a/pkg/sql/logictest/testdata/logic_test/family +++ b/pkg/sql/logictest/testdata/logic_test/family @@ -196,8 +196,7 @@ f1 CREATE TABLE public.f1 ( a INT8 NOT NULL, b STRING NULL, c STRING NULL, - CONSTRAINT f1_pkey PRIMARY KEY (a ASC), - FAMILY "primary" (a, b, c) + CONSTRAINT f1_pkey PRIMARY KEY (a ASC) ) statement ok diff --git a/pkg/sql/logictest/testdata/logic_test/fk b/pkg/sql/logictest/testdata/logic_test/fk index 1bd036ed1bb1..8ace0bff36b9 100644 --- a/pkg/sql/logictest/testdata/logic_test/fk +++ b/pkg/sql/logictest/testdata/logic_test/fk @@ -506,8 +506,7 @@ delivery CREATE TABLE public.delivery ( CONSTRAINT delivery_pkey PRIMARY KEY (rowid ASC), CONSTRAINT delivery_order_shipment_fkey FOREIGN KEY ("order", shipment) REFERENCES public.orders(id, shipment), CONSTRAINT delivery_item_fkey FOREIGN KEY (item) REFERENCES public.products(upc), - INDEX delivery_item_idx (item ASC), - FAMILY "primary" (ts, "order", shipment, item, rowid) + INDEX delivery_item_idx (item ASC) ) statement ok @@ -828,8 +827,7 @@ refpairs CREATE TABLE public.refpairs ( rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), CONSTRAINT refpairs_pkey PRIMARY KEY (rowid ASC), CONSTRAINT refpairs_a_b_fkey FOREIGN KEY (a, b) REFERENCES public.pairs(src, dest) ON UPDATE RESTRICT, - INDEX refpairs_a_b_c_idx (a ASC, b ASC, c ASC), - FAMILY "primary" (a, b, c, rowid) + INDEX refpairs_a_b_c_idx (a ASC, b ASC, c ASC) ) statement error pgcode 23503 insert on table "refpairs" violates foreign key constraint "refpairs_a_b_fkey"\nDETAIL: Key \(a, b\)=\(100, 'two'\) is not present in table "pairs". @@ -1049,8 +1047,7 @@ refers CREATE TABLE public.refers ( CONSTRAINT refers_pkey PRIMARY KEY (rowid ASC), CONSTRAINT refers_a_fkey FOREIGN KEY (a) REFERENCES public.referee(id), INDEX another_idx (b ASC), - INDEX foo (a ASC), - FAMILY "primary" (a, b, rowid) + INDEX foo (a ASC) ) statement ok @@ -1129,8 +1126,7 @@ SHOW CREATE TABLE pkref_b pkref_b CREATE TABLE public.pkref_b ( b INT8 NOT NULL, CONSTRAINT pkref_b_pkey PRIMARY KEY (b ASC), - CONSTRAINT pkref_b_b_fkey FOREIGN KEY (b) REFERENCES public.pkref_a(a) ON DELETE RESTRICT, - FAMILY "primary" (b) + CONSTRAINT pkref_b_b_fkey FOREIGN KEY (b) REFERENCES public.pkref_a(a) ON DELETE RESTRICT ) subtest 20042 diff --git a/pkg/sql/logictest/testdata/logic_test/geospatial b/pkg/sql/logictest/testdata/logic_test/geospatial index b048c71ec5a6..1ab244316bfa 100644 --- a/pkg/sql/logictest/testdata/logic_test/geospatial +++ b/pkg/sql/logictest/testdata/logic_test/geospatial @@ -77,8 +77,7 @@ SELECT create_statement FROM [SHOW CREATE TABLE geom_table_negative_values] CREATE TABLE public.geom_table_negative_values ( a GEOMETRY(GEOMETRY) NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT geom_table_negative_values_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, rowid) + CONSTRAINT geom_table_negative_values_pkey PRIMARY KEY (rowid ASC) ) statement ok @@ -92,8 +91,7 @@ SELECT create_statement FROM [SHOW CREATE TABLE geog_table_negative_values] CREATE TABLE public.geog_table_negative_values ( a GEOGRAPHY(GEOMETRY) NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT geog_table_negative_values_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, rowid) + CONSTRAINT geog_table_negative_values_pkey PRIMARY KEY (rowid ASC) ) statement error SRID 3857 cannot be used for geography as it is not in a lon/lat coordinate system diff --git a/pkg/sql/logictest/testdata/logic_test/hash_sharded_index b/pkg/sql/logictest/testdata/logic_test/hash_sharded_index index 8c5ce19dffe5..551270e6e8fe 100644 --- a/pkg/sql/logictest/testdata/logic_test/hash_sharded_index +++ b/pkg/sql/logictest/testdata/logic_test/hash_sharded_index @@ -11,8 +11,7 @@ SHOW CREATE TABLE sharded_primary sharded_primary CREATE TABLE public.sharded_primary ( crdb_internal_a_shard_10 INT4 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(a)), 10:::INT8)) VIRTUAL, a INT8 NOT NULL, - CONSTRAINT sharded_primary_pkey PRIMARY KEY (a ASC) USING HASH WITH (bucket_count=10), - FAMILY "primary" (a) + CONSTRAINT sharded_primary_pkey PRIMARY KEY (a ASC) USING HASH WITH (bucket_count=10) ) statement error pgcode 22023 BUCKET_COUNT must be a 32-bit integer greater than 1, got -1 @@ -47,8 +46,7 @@ SHOW CREATE TABLE sharded_primary sharded_primary CREATE TABLE public.sharded_primary ( a INT8 NOT NULL, crdb_internal_a_shard_10 INT4 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(a)), 10:::INT8)) VIRTUAL, - CONSTRAINT "primary" PRIMARY KEY (a ASC) USING HASH WITH (bucket_count=10), - FAMILY "primary" (a) + CONSTRAINT "primary" PRIMARY KEY (a ASC) USING HASH WITH (bucket_count=10) ) query TTT colnames @@ -120,8 +118,7 @@ sharded_secondary CREATE TABLE public.sharded_secondary ( crdb_internal_a_shard_4 INT4 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(a)), 4:::INT8)) VIRTUAL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), CONSTRAINT sharded_secondary_pkey PRIMARY KEY (rowid ASC), - INDEX sharded_secondary_a_idx (a ASC) USING HASH WITH (bucket_count=4), - FAMILY "primary" (a, rowid) + INDEX sharded_secondary_a_idx (a ASC) USING HASH WITH (bucket_count=4) ) statement ok @@ -142,8 +139,7 @@ sharded_secondary CREATE TABLE public.sharded_secondary ( crdb_internal_a_shard_4 INT4 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(a)), 4:::INT8)) VIRTUAL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), CONSTRAINT sharded_secondary_pkey PRIMARY KEY (rowid ASC), - INDEX sharded_secondary_crdb_internal_a_shard_4_a_idx (a ASC) USING HASH WITH (bucket_count=4), - FAMILY "primary" (a, rowid) + INDEX sharded_secondary_crdb_internal_a_shard_4_a_idx (a ASC) USING HASH WITH (bucket_count=4) ) statement ok @@ -171,8 +167,7 @@ sharded_secondary CREATE TABLE public.sharded_secondary ( rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), crdb_internal_a_shard_10 INT4 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(a)), 10:::INT8)) VIRTUAL, CONSTRAINT sharded_secondary_pkey PRIMARY KEY (rowid ASC), - INDEX sharded_secondary_a_idx (a ASC) USING HASH WITH (bucket_count=10), - FAMILY "primary" (a, rowid) + INDEX sharded_secondary_a_idx (a ASC) USING HASH WITH (bucket_count=10) ) statement ok @@ -192,8 +187,7 @@ sharded_secondary CREATE TABLE public.sharded_secondary ( crdb_internal_a_shard_4 INT4 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(a)), 4:::INT8)) VIRTUAL, CONSTRAINT sharded_secondary_pkey PRIMARY KEY (rowid ASC), INDEX sharded_secondary_a_idx (a ASC) USING HASH WITH (bucket_count=10), - INDEX sharded_secondary_a_idx1 (a ASC) USING HASH WITH (bucket_count=4), - FAMILY "primary" (a, rowid) + INDEX sharded_secondary_a_idx1 (a ASC) USING HASH WITH (bucket_count=4) ) # Drop a sharded index and ensure that the shard column is dropped with it. @@ -208,8 +202,7 @@ sharded_secondary CREATE TABLE public.sharded_secondary ( rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), crdb_internal_a_shard_4 INT4 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(a)), 4:::INT8)) VIRTUAL, CONSTRAINT sharded_secondary_pkey PRIMARY KEY (rowid ASC), - INDEX sharded_secondary_a_idx1 (a ASC) USING HASH WITH (bucket_count=4), - FAMILY "primary" (a, rowid) + INDEX sharded_secondary_a_idx1 (a ASC) USING HASH WITH (bucket_count=4) ) statement ok @@ -222,8 +215,7 @@ SHOW CREATE TABLE sharded_secondary sharded_secondary CREATE TABLE public.sharded_secondary ( a INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT sharded_secondary_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, rowid) + CONSTRAINT sharded_secondary_pkey PRIMARY KEY (rowid ASC) ) # Ensure that the shard column cannot be used in the same txn if its dropped along with @@ -269,8 +261,7 @@ sharded_secondary CREATE TABLE public.sharded_secondary ( CONSTRAINT sharded_secondary_pkey PRIMARY KEY (rowid ASC), INDEX sharded_secondary_a_idx (a ASC) USING HASH WITH (bucket_count=10), INDEX sharded_secondary_a_idx1 (a ASC) USING HASH WITH (bucket_count=10), - INDEX sharded_secondary_a_idx2 (a ASC) USING HASH WITH (bucket_count=10), - FAMILY "primary" (a, rowid) + INDEX sharded_secondary_a_idx2 (a ASC) USING HASH WITH (bucket_count=10) ) @@ -291,8 +282,7 @@ sharded_primary CREATE TABLE public.sharded_primary ( crdb_internal_a_shard_10 INT4 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(a)), 10:::INT8)) VIRTUAL, crdb_internal_a_shard_4 INT4 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(a)), 4:::INT8)) VIRTUAL, CONSTRAINT "primary" PRIMARY KEY (a ASC) USING HASH WITH (bucket_count=10), - INDEX sharded_primary_a_idx (a ASC) USING HASH WITH (bucket_count=4), - FAMILY "primary" (a) + INDEX sharded_primary_a_idx (a ASC) USING HASH WITH (bucket_count=4) ) statement ok @@ -307,8 +297,7 @@ SHOW CREATE TABLE sharded_primary sharded_primary CREATE TABLE public.sharded_primary ( a INT8 NOT NULL, crdb_internal_a_shard_10 INT4 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(a)), 10:::INT8)) VIRTUAL, - CONSTRAINT "primary" PRIMARY KEY (a ASC) USING HASH WITH (bucket_count=10), - FAMILY "primary" (a) + CONSTRAINT "primary" PRIMARY KEY (a ASC) USING HASH WITH (bucket_count=10) ) statement ok @@ -321,8 +310,7 @@ sharded_primary CREATE TABLE public.sharded_primary ( a INT8 NOT NULL, crdb_internal_a_shard_10 INT4 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(a)), 10:::INT8)) VIRTUAL, CONSTRAINT "primary" PRIMARY KEY (a ASC) USING HASH WITH (bucket_count=10), - INDEX sharded_primary_a_idx (a ASC) USING HASH WITH (bucket_count=10), - FAMILY "primary" (a) + INDEX sharded_primary_a_idx (a ASC) USING HASH WITH (bucket_count=10) ) statement ok @@ -401,8 +389,7 @@ column_used_on_unsharded CREATE TABLE public.column_used_on_unsharded ( crdb_internal_a_shard_10 INT4 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(a)), 10:::INT8)) VIRTUAL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), CONSTRAINT column_used_on_unsharded_pkey PRIMARY KEY (rowid ASC), - INDEX column_used_on_unsharded_crdb_internal_a_shard_10_idx (crdb_internal_a_shard_10 ASC), - FAMILY "primary" (a, rowid) + INDEX column_used_on_unsharded_crdb_internal_a_shard_10_idx (crdb_internal_a_shard_10 ASC) ) statement ok @@ -426,8 +413,7 @@ column_used_on_unsharded_create_table CREATE TABLE public.column_used_on_unshar crdb_internal_a_shard_10 INT4 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(a)), 10:::INT8)) VIRTUAL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), CONSTRAINT column_used_on_unsharded_create_table_pkey PRIMARY KEY (rowid ASC), - INDEX column_used_on_unsharded_create_table_crdb_internal_a_shard_10_idx (crdb_internal_a_shard_10 ASC), - FAMILY "primary" (a, rowid) + INDEX column_used_on_unsharded_create_table_crdb_internal_a_shard_10_idx (crdb_internal_a_shard_10 ASC) ) statement ok @@ -482,8 +468,7 @@ weird_names CREATE TABLE public.weird_names ( "'quotes' in the column's name" INT8 NULL, "crdb_internal_'quotes' in the column's name_shard_4" INT4 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes("'quotes' in the column's name")), 4:::INT8)) VIRTUAL, CONSTRAINT weird_names_pkey PRIMARY KEY ("I am a column with spaces" ASC) USING HASH WITH (bucket_count=12), - INDEX foo ("'quotes' in the column's name" ASC) USING HASH WITH (bucket_count=4), - FAMILY "primary" ("I am a column with spaces", "'quotes' in the column's name") + INDEX foo ("'quotes' in the column's name" ASC) USING HASH WITH (bucket_count=4) ) subtest column_does_not_exist @@ -558,8 +543,7 @@ rename_column CREATE TABLE public.rename_column ( crdb_internal_c0_c1_shard_8 INT4 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(c0, c1)), 8:::INT8)) VIRTUAL, crdb_internal_c2_shard_8 INT4 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(c2)), 8:::INT8)) VIRTUAL, CONSTRAINT rename_column_pkey PRIMARY KEY (c0 ASC, c1 ASC) USING HASH WITH (bucket_count=8), - INDEX rename_column_c2_idx (c2 ASC) USING HASH WITH (bucket_count=8), - FAMILY "primary" (c0, c1, c2) + INDEX rename_column_c2_idx (c2 ASC) USING HASH WITH (bucket_count=8) ) statement ok @@ -582,8 +566,7 @@ rename_column CREATE TABLE public.rename_column ( crdb_internal_c1_c2_shard_8 INT4 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(c1, c2)), 8:::INT8)) VIRTUAL, crdb_internal_c3_shard_8 INT4 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(c3)), 8:::INT8)) VIRTUAL, CONSTRAINT rename_column_pkey PRIMARY KEY (c1 ASC, c2 ASC) USING HASH WITH (bucket_count=8), - INDEX rename_column_c2_idx (c3 ASC) USING HASH WITH (bucket_count=8), - FAMILY "primary" (c1, c2, c3) + INDEX rename_column_c2_idx (c3 ASC) USING HASH WITH (bucket_count=8) ) query III @@ -605,8 +588,7 @@ rename_column CREATE TABLE public.rename_column ( crdb_internal_c0_c1_shard_8 INT4 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(c0, c1)), 8:::INT8)) VIRTUAL, crdb_internal_c2_shard_8 INT4 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(c2)), 8:::INT8)) VIRTUAL, CONSTRAINT rename_column_pkey PRIMARY KEY (c0 ASC, c1 ASC) USING HASH WITH (bucket_count=8), - INDEX rename_column_c2_idx (c2 ASC) USING HASH WITH (bucket_count=8), - FAMILY "primary" (c0, c1, c2) + INDEX rename_column_c2_idx (c2 ASC) USING HASH WITH (bucket_count=8) ) query III @@ -648,7 +630,9 @@ statement ok CREATE TABLE poor_t (a INT PRIMARY KEY, b INT, INDEX t_idx_b (b) USING HASH WITH (bucket_count=8)) query ITITTBBB colnames -SELECT * FROM crdb_internal.table_indexes WHERE descriptor_name = 'poor_t' +SELECT descriptor_id, descriptor_name, index_id, index_name, index_type, is_unique, is_inverted, is_sharded + FROM crdb_internal.table_indexes + WHERE descriptor_name = 'poor_t' ---- descriptor_id descriptor_name index_id index_name index_type is_unique is_inverted is_sharded 130 poor_t 1 poor_t_pkey primary true false false @@ -809,10 +793,9 @@ query T SELECT @2 FROM [SHOW CREATE TABLE t] ---- CREATE TABLE public.t ( - crdb_internal_a_shard_8 INT4 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(a)), 8:::INT8)) VIRTUAL, - a INT8 NOT NULL, - CONSTRAINT t_pkey PRIMARY KEY (a ASC) USING HASH WITH (bucket_count=8), - FAMILY "primary" (a) + crdb_internal_a_shard_8 INT4 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(a)), 8:::INT8)) VIRTUAL, + a INT8 NOT NULL, + CONSTRAINT t_pkey PRIMARY KEY (a ASC) USING HASH WITH (bucket_count=8) ) # Make sure user defined constraint is used if it's equivalent to the shard @@ -833,11 +816,10 @@ query T SELECT @2 FROM [SHOW CREATE TABLE t] ---- CREATE TABLE public.t ( - crdb_internal_a_shard_8 INT4 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(a)), 8:::INT8)) VIRTUAL, - a INT8 NOT NULL, - CONSTRAINT t_pkey PRIMARY KEY (a ASC) USING HASH WITH (bucket_count=8), - FAMILY "primary" (a), - CONSTRAINT check_crdb_internal_a_shard_8 CHECK (crdb_internal_a_shard_8 IN (0:::INT8, 1:::INT8, 2:::INT8, 3:::INT8, 4:::INT8, 5:::INT8, 6:::INT8, 7:::INT8)) + crdb_internal_a_shard_8 INT4 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(a)), 8:::INT8)) VIRTUAL, + a INT8 NOT NULL, + CONSTRAINT t_pkey PRIMARY KEY (a ASC) USING HASH WITH (bucket_count=8), + CONSTRAINT check_crdb_internal_a_shard_8 CHECK (crdb_internal_a_shard_8 IN (0:::INT8, 1:::INT8, 2:::INT8, 3:::INT8, 4:::INT8, 5:::INT8, 6:::INT8, 7:::INT8)) ) subtest test_hash_index_presplit @@ -924,8 +906,7 @@ SELECT @2 FROM [SHOW CREATE TABLE t_default_bucket_8] CREATE TABLE public.t_default_bucket_8 ( crdb_internal_a_shard_8 INT4 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(a)), 8:::INT8)) VIRTUAL, a INT8 NOT NULL, - CONSTRAINT t_default_bucket_8_pkey PRIMARY KEY (a ASC) USING HASH WITH (bucket_count=8), - FAMILY "primary" (a) + CONSTRAINT t_default_bucket_8_pkey PRIMARY KEY (a ASC) USING HASH WITH (bucket_count=8) ) # Make sure that uniqueness is guaranteed with hash index. diff --git a/pkg/sql/logictest/testdata/logic_test/hidden_columns b/pkg/sql/logictest/testdata/logic_test/hidden_columns index 80747391c3b5..4cef58690783 100644 --- a/pkg/sql/logictest/testdata/logic_test/hidden_columns +++ b/pkg/sql/logictest/testdata/logic_test/hidden_columns @@ -29,8 +29,7 @@ SHOW CREATE TABLE t t CREATE TABLE public.t ( x INT8 NOT VISIBLE NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT t_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (x, rowid) + CONSTRAINT t_pkey PRIMARY KEY (rowid ASC) ) # Check that stars expand to no columns. diff --git a/pkg/sql/logictest/testdata/logic_test/insert b/pkg/sql/logictest/testdata/logic_test/insert index 2cc19ea9cf61..acecee54fc93 100644 --- a/pkg/sql/logictest/testdata/logic_test/insert +++ b/pkg/sql/logictest/testdata/logic_test/insert @@ -492,8 +492,7 @@ CREATE TABLE public.sw ( ec STRING COLLATE en NULL, fc STRING(3) COLLATE en NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT sw_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, b, c, d, e, f, g, ac, bc, cc, dc, ec, fc, rowid) + CONSTRAINT sw_pkey PRIMARY KEY (rowid ASC) ) statement ok @@ -605,8 +604,7 @@ SELECT create_statement FROM [SHOW CREATE t29494] CREATE TABLE public.t29494 ( x INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT t29494_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (x, rowid) + CONSTRAINT t29494_pkey PRIMARY KEY (rowid ASC) ) # Check that the new column is not usable in RETURNING. @@ -646,8 +644,7 @@ CREATE TABLE public.t32759 ( x INT8 NULL, z INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT t32759_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (x, z, rowid) + CONSTRAINT t32759_pkey PRIMARY KEY (rowid ASC) ) # Check that values cannot be inserted into the dropped column. diff --git a/pkg/sql/logictest/testdata/logic_test/int_size b/pkg/sql/logictest/testdata/logic_test/int_size index c925d29cbd95..697ce8146778 100644 --- a/pkg/sql/logictest/testdata/logic_test/int_size +++ b/pkg/sql/logictest/testdata/logic_test/int_size @@ -24,8 +24,7 @@ SHOW CREATE TABLE i4 i4 CREATE TABLE public.i4 ( i4 INT4 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT i4_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (i4, rowid) + CONSTRAINT i4_pkey PRIMARY KEY (rowid ASC) ) subtest set_int8 @@ -47,8 +46,7 @@ SHOW CREATE TABLE i8 i8 CREATE TABLE public.i8 ( i8 INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT i8_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (i8, rowid) + CONSTRAINT i8_pkey PRIMARY KEY (rowid ASC) ) # https://github.com/cockroachdb/cockroach/issues/32846 @@ -68,8 +66,7 @@ SHOW CREATE TABLE late4 late4 CREATE TABLE public.late4 ( a INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT late4_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, rowid) + CONSTRAINT late4_pkey PRIMARY KEY (rowid ASC) ) query T @@ -101,8 +98,7 @@ SHOW CREATE TABLE i4_rowid i4_rowid CREATE TABLE public.i4_rowid ( a INT8 NOT NULL DEFAULT unique_rowid(), rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT i4_rowid_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, rowid) + CONSTRAINT i4_rowid_pkey PRIMARY KEY (rowid ASC) ) statement ok @@ -117,8 +113,7 @@ SHOW CREATE TABLE i8_rowid i8_rowid CREATE TABLE public.i8_rowid ( a INT8 NOT NULL DEFAULT unique_rowid(), rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT i8_rowid_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, rowid) + CONSTRAINT i8_rowid_pkey PRIMARY KEY (rowid ASC) ) subtest serial_sql_sequence @@ -136,8 +131,7 @@ SHOW CREATE TABLE i4_sql_sequence i4_sql_sequence CREATE TABLE public.i4_sql_sequence ( a INT4 NOT NULL DEFAULT nextval('public.i4_sql_sequence_a_seq'::REGCLASS), rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT i4_sql_sequence_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, rowid) + CONSTRAINT i4_sql_sequence_pkey PRIMARY KEY (rowid ASC) ) statement ok @@ -152,8 +146,7 @@ SHOW CREATE TABLE i8_sql_sequence i8_sql_sequence CREATE TABLE public.i8_sql_sequence ( a INT8 NOT NULL DEFAULT nextval('public.i8_sql_sequence_a_seq'::REGCLASS), rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT i8_sql_sequence_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, rowid) + CONSTRAINT i8_sql_sequence_pkey PRIMARY KEY (rowid ASC) ) subtest serial_virtual_sequence @@ -172,8 +165,7 @@ SHOW CREATE TABLE i4_virtual_sequence i4_virtual_sequence CREATE TABLE public.i4_virtual_sequence ( a INT8 NOT NULL DEFAULT nextval('public.i4_virtual_sequence_a_seq'::REGCLASS), rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT i4_virtual_sequence_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, rowid) + CONSTRAINT i4_virtual_sequence_pkey PRIMARY KEY (rowid ASC) ) statement ok @@ -188,6 +180,5 @@ SHOW CREATE TABLE i8_virtual_sequence i8_virtual_sequence CREATE TABLE public.i8_virtual_sequence ( a INT8 NOT NULL DEFAULT nextval('public.i8_virtual_sequence_a_seq'::REGCLASS), rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT i8_virtual_sequence_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, rowid) + CONSTRAINT i8_virtual_sequence_pkey PRIMARY KEY (rowid ASC) ) diff --git a/pkg/sql/logictest/testdata/logic_test/inverted_index b/pkg/sql/logictest/testdata/logic_test/inverted_index index 06a196b334e5..df38d941282a 100644 --- a/pkg/sql/logictest/testdata/logic_test/inverted_index +++ b/pkg/sql/logictest/testdata/logic_test/inverted_index @@ -43,8 +43,7 @@ c CREATE TABLE public.c ( "qUuX" JSONB NULL, CONSTRAINT c_pkey PRIMARY KEY (id ASC), INVERTED INDEX c_foo_idx (foo), - INVERTED INDEX "c_bAr_idx" ("bAr"), - FAMILY "primary" (id, foo, "bAr", "qUuX") + INVERTED INDEX "c_bAr_idx" ("bAr") ) # Regression test for #42944: make sure that mixed-case columns can be @@ -1118,8 +1117,7 @@ c CREATE TABLE public.c ( bar STRING[] NULL, CONSTRAINT c_pkey PRIMARY KEY (id ASC), INVERTED INDEX c_foo_idx (foo), - INVERTED INDEX c_bar_idx (bar), - FAMILY "primary" (id, foo, bar) + INVERTED INDEX c_bar_idx (bar) ) query ITT diff --git a/pkg/sql/logictest/testdata/logic_test/inverted_index_multi_column b/pkg/sql/logictest/testdata/logic_test/inverted_index_multi_column index 4b23a14f93fa..ae1dba10b91e 100644 --- a/pkg/sql/logictest/testdata/logic_test/inverted_index_multi_column +++ b/pkg/sql/logictest/testdata/logic_test/inverted_index_multi_column @@ -105,8 +105,7 @@ CREATE TABLE public.dst ( rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), CONSTRAINT src_pkey PRIMARY KEY (rowid ASC), INVERTED INDEX src_a_j_idx (a, j), - INVERTED INDEX src_a_b_j_idx (a, b, j), - FAMILY "primary" (a, b, j, rowid) + INVERTED INDEX src_a_b_j_idx (a, b, j) ) # Test dropping a table with a multi-column inverted index. diff --git a/pkg/sql/logictest/testdata/logic_test/name_escapes b/pkg/sql/logictest/testdata/logic_test/name_escapes index 8dee2b76eca0..c48c1dac6adb 100644 --- a/pkg/sql/logictest/testdata/logic_test/name_escapes +++ b/pkg/sql/logictest/testdata/logic_test/name_escapes @@ -67,6 +67,5 @@ SHOW CREATE TABLE ";--dontask" b INT8 NULL, c INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT ";--dontask_pkey" PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, b, c, rowid) + CONSTRAINT ";--dontask_pkey" PRIMARY KEY (rowid ASC) ) diff --git a/pkg/sql/logictest/testdata/logic_test/partial_index b/pkg/sql/logictest/testdata/logic_test/partial_index index 9550658cc9f7..368dbe01d70b 100644 --- a/pkg/sql/logictest/testdata/logic_test/partial_index +++ b/pkg/sql/logictest/testdata/logic_test/partial_index @@ -125,8 +125,7 @@ t6 CREATE TABLE public.t6 ( UNIQUE INDEX t6_a_key2 (a DESC) WHERE a > 5:::INT8, INDEX t6i1 (a ASC) WHERE a > 6:::INT8, INDEX t6i2 (a ASC) WHERE a > 7:::INT8, - INDEX t6i3 (a DESC) WHERE a > 8:::INT8, - FAMILY "primary" (a, rowid) + INDEX t6i3 (a DESC) WHERE a > 8:::INT8 ) # Renaming a column updates the index predicates. @@ -149,8 +148,7 @@ t6 CREATE TABLE public.t6 ( UNIQUE INDEX t6_a_key2 (b DESC) WHERE b > 5:::INT8, INDEX t6i1 (b ASC) WHERE b > 6:::INT8, INDEX t6i2 (b ASC) WHERE b > 7:::INT8, - INDEX t6i3 (b DESC) WHERE b > 8:::INT8, - FAMILY "primary" (b, rowid) + INDEX t6i3 (b DESC) WHERE b > 8:::INT8 ) # Renaming a table keeps the index predicates intact. @@ -173,8 +171,7 @@ t7 CREATE TABLE public.t7 ( UNIQUE INDEX t6_a_key2 (b DESC) WHERE b > 5:::INT8, INDEX t6i1 (b ASC) WHERE b > 6:::INT8, INDEX t6i2 (b ASC) WHERE b > 7:::INT8, - INDEX t6i3 (b DESC) WHERE b > 8:::INT8, - FAMILY "primary" (b, rowid) + INDEX t6i3 (b DESC) WHERE b > 8:::INT8 ) # Dropping a column referenced in the predicate drops the index. @@ -221,8 +218,7 @@ t10 CREATE TABLE public.t10 ( b INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), CONSTRAINT t9_pkey PRIMARY KEY (rowid ASC), - INDEX t9_a_idx (a ASC) WHERE b > 1:::INT8, - FAMILY "primary" (a, b, rowid) + INDEX t9_a_idx (a ASC) WHERE b > 1:::INT8 ) # SHOW CONSTRAINTS includes partial index predicate of UNIQUE partial indexes. diff --git a/pkg/sql/logictest/testdata/logic_test/partial_txn_commit b/pkg/sql/logictest/testdata/logic_test/partial_txn_commit index 363df6a1fd94..628487e6f7fd 100644 --- a/pkg/sql/logictest/testdata/logic_test/partial_txn_commit +++ b/pkg/sql/logictest/testdata/logic_test/partial_txn_commit @@ -33,6 +33,5 @@ SHOW CREATE t t CREATE TABLE public.t ( x INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT t_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (x, rowid) + CONSTRAINT t_pkey PRIMARY KEY (rowid ASC) ) diff --git a/pkg/sql/logictest/testdata/logic_test/rename_constraint b/pkg/sql/logictest/testdata/logic_test/rename_constraint index 99acdef07ea7..26fa075b4574 100644 --- a/pkg/sql/logictest/testdata/logic_test/rename_constraint +++ b/pkg/sql/logictest/testdata/logic_test/rename_constraint @@ -17,7 +17,6 @@ CREATE TABLE public.t ( CONSTRAINT t_pkey PRIMARY KEY (rowid ASC), CONSTRAINT cf FOREIGN KEY (x) REFERENCES public.t(x), UNIQUE INDEX cu (x ASC), - FAMILY "primary" (x, y, rowid), CONSTRAINT cc CHECK (x > 10:::INT8) ) @@ -45,7 +44,6 @@ CREATE TABLE public.t ( CONSTRAINT t_pkey PRIMARY KEY (rowid ASC), CONSTRAINT cf2 FOREIGN KEY (x) REFERENCES public.t(x), UNIQUE INDEX cu2 (x ASC), - FAMILY "primary" (x, y, rowid), CONSTRAINT cc2 CHECK (x > 10:::INT8) ) @@ -97,7 +95,6 @@ CREATE TABLE public.t ( CONSTRAINT t_pkey PRIMARY KEY (rowid ASC), CONSTRAINT cf4 FOREIGN KEY (x) REFERENCES public.t(x), UNIQUE INDEX cu4 (x ASC), - FAMILY "primary" (x, y, rowid), CONSTRAINT cc4 CHECK (x > 10:::INT8) ) diff --git a/pkg/sql/logictest/testdata/logic_test/schema_change_in_txn b/pkg/sql/logictest/testdata/logic_test/schema_change_in_txn index 9aa1daf613e6..b1b98a41992d 100644 --- a/pkg/sql/logictest/testdata/logic_test/schema_change_in_txn +++ b/pkg/sql/logictest/testdata/logic_test/schema_change_in_txn @@ -282,8 +282,7 @@ b CREATE TABLE public.b ( CONSTRAINT b_pkey PRIMARY KEY (rowid ASC), CONSTRAINT b_parent_id_fkey FOREIGN KEY (parent_id) REFERENCES public.parent(id), INDEX foo (parent_id ASC), - UNIQUE INDEX bar (parent_id ASC), - FAMILY "primary" (parent_id, rowid, d) + UNIQUE INDEX bar (parent_id ASC) ) # table b is not visible to the transaction #17949 diff --git a/pkg/sql/logictest/testdata/logic_test/sequences_regclass b/pkg/sql/logictest/testdata/logic_test/sequences_regclass index d2ac96990ee4..2d7704f74a6f 100644 --- a/pkg/sql/logictest/testdata/logic_test/sequences_regclass +++ b/pkg/sql/logictest/testdata/logic_test/sequences_regclass @@ -48,8 +48,7 @@ foo CREATE TABLE public.foo ( j INT8 NOT NULL DEFAULT nextval('public.test_seq'::REGCLASS), k INT8 NOT NULL DEFAULT nextval('public.foo_k_seq'::REGCLASS), l INT8 NOT NULL DEFAULT currval('diff_db.public.test_seq'::REGCLASS), - CONSTRAINT foo_pkey PRIMARY KEY (i ASC), - FAMILY "primary" (i, j, k, l) + CONSTRAINT foo_pkey PRIMARY KEY (i ASC) ) statement ok diff --git a/pkg/sql/logictest/testdata/logic_test/serial b/pkg/sql/logictest/testdata/logic_test/serial index e6fa85b19c79..151dbb9c7015 100644 --- a/pkg/sql/logictest/testdata/logic_test/serial +++ b/pkg/sql/logictest/testdata/logic_test/serial @@ -17,8 +17,7 @@ serial CREATE TABLE public.serial ( b INT8 NULL DEFAULT 7:::INT8, c INT8 NOT NULL DEFAULT unique_rowid(), CONSTRAINT serial_pkey PRIMARY KEY (a ASC), - UNIQUE INDEX serial_c_key (c ASC), - FAMILY "primary" (a, b, c) + UNIQUE INDEX serial_c_key (c ASC) ) statement ok @@ -55,8 +54,7 @@ smallbig CREATE TABLE public.smallbig ( b INT8 NOT NULL DEFAULT unique_rowid(), c INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT smallbig_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, b, c, rowid) + CONSTRAINT smallbig_pkey PRIMARY KEY (rowid ASC) ) query III @@ -79,8 +77,7 @@ serials CREATE TABLE public.serials ( c INT8 NOT NULL DEFAULT unique_rowid(), d INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT serials_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, b, c, d, rowid) + CONSTRAINT serials_pkey PRIMARY KEY (rowid ASC) ) statement ok @@ -121,8 +118,7 @@ serial CREATE TABLE public.serial ( b INT8 NULL DEFAULT 7:::INT8, c INT8 NOT NULL DEFAULT nextval('public.serial_c_seq2'::REGCLASS), CONSTRAINT serial_pkey PRIMARY KEY (a ASC), - UNIQUE INDEX serial_c_key (c ASC), - FAMILY "primary" (a, b, c) + UNIQUE INDEX serial_c_key (c ASC) ) query TT @@ -164,8 +160,7 @@ smallbig CREATE TABLE public.smallbig ( b INT8 NOT NULL DEFAULT nextval('public.smallbig_b_seq'::REGCLASS), c INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT smallbig_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, b, c, rowid) + CONSTRAINT smallbig_pkey PRIMARY KEY (rowid ASC) ) query III @@ -188,8 +183,7 @@ serials CREATE TABLE public.serials ( c INT8 NOT NULL DEFAULT nextval('public.serials_c_seq'::REGCLASS), d INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT serials_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, b, c, d, rowid) + CONSTRAINT serials_pkey PRIMARY KEY (rowid ASC) ) statement ok @@ -226,8 +220,7 @@ serial CREATE TABLE public.serial ( b INT8 NULL DEFAULT 7:::INT8, c INT8 NOT NULL DEFAULT nextval('public.serial_c_seq2'::REGCLASS), CONSTRAINT serial_pkey PRIMARY KEY (a ASC), - UNIQUE INDEX serial_c_key (c ASC), - FAMILY "primary" (a, b, c) + UNIQUE INDEX serial_c_key (c ASC) ) query TT @@ -282,8 +275,7 @@ SHOW CREATE TABLE "serial_MixedCase" b INT8 NULL DEFAULT 7:::INT8, c INT8 NOT NULL DEFAULT nextval('public."serial_MixedCase_c_seq"'::REGCLASS), CONSTRAINT "serial_MixedCase_pkey" PRIMARY KEY (a ASC), - UNIQUE INDEX "serial_MixedCase_c_key" (c ASC), - FAMILY "primary" (a, b, c) + UNIQUE INDEX "serial_MixedCase_c_key" (c ASC) ) statement error multiple default values specified for column "a" of table "s1" @@ -309,8 +301,7 @@ smallbig CREATE TABLE public.smallbig ( b INT8 NOT NULL DEFAULT nextval('public.smallbig_b_seq'::REGCLASS), c INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT smallbig_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, b, c, rowid) + CONSTRAINT smallbig_pkey PRIMARY KEY (rowid ASC) ) query III @@ -333,8 +324,7 @@ serials CREATE TABLE public.serials ( c INT8 NOT NULL DEFAULT nextval('public.serials_c_seq'::REGCLASS), d INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT serials_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, b, c, d, rowid) + CONSTRAINT serials_pkey PRIMARY KEY (rowid ASC) ) statement ok diff --git a/pkg/sql/logictest/testdata/logic_test/show_create_all_tables b/pkg/sql/logictest/testdata/logic_test/show_create_all_tables index a22f131bac8a..7206f92a35ee 100644 --- a/pkg/sql/logictest/testdata/logic_test/show_create_all_tables +++ b/pkg/sql/logictest/testdata/logic_test/show_create_all_tables @@ -172,19 +172,16 @@ SHOW CREATE ALL TABLES create_statement CREATE TABLE public.b ( i INT8 NOT NULL, - CONSTRAINT b_pkey PRIMARY KEY (i ASC), - FAMILY "primary" (i) + CONSTRAINT b_pkey PRIMARY KEY (i ASC) ); CREATE TABLE public.a ( i INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT a_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (i, rowid) + CONSTRAINT a_pkey PRIMARY KEY (rowid ASC) ); CREATE TABLE public.g ( i INT8 NOT NULL, - CONSTRAINT g_pkey PRIMARY KEY (i ASC), - FAMILY "primary" (i) + CONSTRAINT g_pkey PRIMARY KEY (i ASC) ); CREATE TABLE public.f ( i INT8 NOT NULL, @@ -194,8 +191,7 @@ CREATE TABLE public.f ( ); CREATE TABLE public.e ( i INT8 NOT NULL, - CONSTRAINT e_pkey PRIMARY KEY (i ASC), - FAMILY "primary" (i) + CONSTRAINT e_pkey PRIMARY KEY (i ASC) ); CREATE TABLE public.d ( i INT8 NOT NULL, @@ -207,8 +203,7 @@ CREATE TABLE public.d ( CREATE TABLE public.c ( i INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT c_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (i, rowid) + CONSTRAINT c_pkey PRIMARY KEY (rowid ASC) ); CREATE SEQUENCE public.s MINVALUE 1 MAXVALUE 9223372036854775807 INCREMENT 1 START 1; CREATE TABLE public.s_tbl ( @@ -285,8 +280,7 @@ SHOW CREATE ALL TABLES create_statement CREATE TABLE public.t ( i INT8 NOT NULL, - CONSTRAINT pk_name PRIMARY KEY (i ASC), - FAMILY "primary" (i) + CONSTRAINT pk_name PRIMARY KEY (i ASC) ); # Test that computed columns are shown correctly. @@ -326,8 +320,7 @@ CREATE TABLE public.";" ( ";" INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), CONSTRAINT ";_pkey" PRIMARY KEY (rowid ASC), - INDEX ";_;_idx" (";" ASC), - FAMILY "primary" (";", rowid) + INDEX ";_;_idx" (";" ASC) ); # Ensure quotes in comments are properly escaped, also that the object names @@ -346,8 +339,7 @@ SHOW CREATE ALL TABLES create_statement CREATE TABLE public."t t" ( "x'" INT8 NOT NULL, - CONSTRAINT "t t_pkey" PRIMARY KEY ("x'" ASC), - FAMILY "primary" ("x'") + CONSTRAINT "t t_pkey" PRIMARY KEY ("x'" ASC) ); COMMENT ON TABLE public."t t" IS e'has \' quotes'; COMMENT ON COLUMN public."t t"."x'" IS e'i \' just \' love \' quotes'; @@ -369,14 +361,12 @@ create_statement CREATE TABLE sc1.t ( x INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT t_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (x, rowid) + CONSTRAINT t_pkey PRIMARY KEY (rowid ASC) ); CREATE TABLE sc2.t ( x INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT t_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (x, rowid) + CONSTRAINT t_pkey PRIMARY KEY (rowid ASC) ); # Ensure sequences are shown correctly. @@ -405,8 +395,7 @@ create_statement CREATE TABLE public.t ( x public.test NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT t_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (x, rowid) + CONSTRAINT t_pkey PRIMARY KEY (rowid ASC) ); # Test with column families. diff --git a/pkg/sql/logictest/testdata/logic_test/show_create_all_tables_builtin b/pkg/sql/logictest/testdata/logic_test/show_create_all_tables_builtin index f622b805614a..f9978c2ce40f 100644 --- a/pkg/sql/logictest/testdata/logic_test/show_create_all_tables_builtin +++ b/pkg/sql/logictest/testdata/logic_test/show_create_all_tables_builtin @@ -167,19 +167,16 @@ SELECT crdb_internal.show_create_all_tables('test_fk_order') ---- CREATE TABLE public.b ( i INT8 NOT NULL, - CONSTRAINT b_pkey PRIMARY KEY (i ASC), - FAMILY "primary" (i) + CONSTRAINT b_pkey PRIMARY KEY (i ASC) ); CREATE TABLE public.a ( i INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT a_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (i, rowid) + CONSTRAINT a_pkey PRIMARY KEY (rowid ASC) ); CREATE TABLE public.g ( i INT8 NOT NULL, - CONSTRAINT g_pkey PRIMARY KEY (i ASC), - FAMILY "primary" (i) + CONSTRAINT g_pkey PRIMARY KEY (i ASC) ); CREATE TABLE public.f ( i INT8 NOT NULL, @@ -189,8 +186,7 @@ CREATE TABLE public.f ( ); CREATE TABLE public.e ( i INT8 NOT NULL, - CONSTRAINT e_pkey PRIMARY KEY (i ASC), - FAMILY "primary" (i) + CONSTRAINT e_pkey PRIMARY KEY (i ASC) ); CREATE TABLE public.d ( i INT8 NOT NULL, @@ -202,8 +198,7 @@ CREATE TABLE public.d ( CREATE TABLE public.c ( i INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT c_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (i, rowid) + CONSTRAINT c_pkey PRIMARY KEY (rowid ASC) ); CREATE SEQUENCE public.s MINVALUE 1 MAXVALUE 9223372036854775807 INCREMENT 1 START 1; CREATE TABLE public.s_tbl ( @@ -276,9 +271,8 @@ query T SELECT crdb_internal.show_create_all_tables('test_primary_key') ---- CREATE TABLE public.t ( - i INT8 NOT NULL, - CONSTRAINT pk_name PRIMARY KEY (i ASC), - FAMILY "primary" (i) + i INT8 NOT NULL, + CONSTRAINT pk_name PRIMARY KEY (i ASC) ); # Test that computed columns are shown correctly. @@ -314,8 +308,7 @@ CREATE TABLE public.";" ( ";" INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), CONSTRAINT ";_pkey" PRIMARY KEY (rowid ASC), - INDEX ";_;_idx" (";" ASC), - FAMILY "primary" (";", rowid) + INDEX ";_;_idx" (";" ASC) ); # Ensure quotes in comments are properly escaped, also that the object names @@ -332,8 +325,7 @@ SELECT crdb_internal.show_create_all_tables('test_comment') ---- CREATE TABLE public."t t" ( "x'" INT8 NOT NULL, - CONSTRAINT "t t_pkey" PRIMARY KEY ("x'" ASC), - FAMILY "primary" ("x'") + CONSTRAINT "t t_pkey" PRIMARY KEY ("x'" ASC) ); COMMENT ON TABLE public."t t" IS e'has \' quotes'; COMMENT ON COLUMN public."t t"."x'" IS e'i \' just \' love \' quotes'; @@ -354,14 +346,12 @@ SELECT crdb_internal.show_create_all_tables('test_schema') CREATE TABLE sc1.t ( x INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT t_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (x, rowid) + CONSTRAINT t_pkey PRIMARY KEY (rowid ASC) ); CREATE TABLE sc2.t ( x INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT t_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (x, rowid) + CONSTRAINT t_pkey PRIMARY KEY (rowid ASC) ); # Ensure sequences are shown correctly. @@ -388,14 +378,12 @@ COMMIT; CREATE TABLE sc1.t ( x INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT t_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (x, rowid) + CONSTRAINT t_pkey PRIMARY KEY (rowid ASC) ); CREATE TABLE sc2.t ( x INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT t_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (x, rowid) + CONSTRAINT t_pkey PRIMARY KEY (rowid ASC) ); query T @@ -407,12 +395,10 @@ COMMIT; CREATE TABLE sc1.t ( x INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT t_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (x, rowid) + CONSTRAINT t_pkey PRIMARY KEY (rowid ASC) ); CREATE TABLE sc2.t ( x INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT t_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (x, rowid) + CONSTRAINT t_pkey PRIMARY KEY (rowid ASC) ); diff --git a/pkg/sql/logictest/testdata/logic_test/table b/pkg/sql/logictest/testdata/logic_test/table index 86788224324a..54aa6746ac7b 100644 --- a/pkg/sql/logictest/testdata/logic_test/table +++ b/pkg/sql/logictest/testdata/logic_test/table @@ -499,8 +499,7 @@ SHOW CREATE TABLE test.null_default test.public.null_default CREATE TABLE public.null_default ( ts TIMESTAMP NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT null_default_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (ts, rowid) + CONSTRAINT null_default_pkey PRIMARY KEY (rowid ASC) ) # Issue #13873: don't permit invalid default columns diff --git a/pkg/sql/logictest/testdata/logic_test/update b/pkg/sql/logictest/testdata/logic_test/update index 5191f8962807..1e2fcebebc63 100644 --- a/pkg/sql/logictest/testdata/logic_test/update +++ b/pkg/sql/logictest/testdata/logic_test/update @@ -481,8 +481,7 @@ SELECT create_statement FROM [SHOW CREATE t29494] ---- CREATE TABLE public.t29494 ( x INT8 NOT NULL, - CONSTRAINT t29494_pkey PRIMARY KEY (x ASC), - FAMILY "primary" (x) + CONSTRAINT t29494_pkey PRIMARY KEY (x ASC) ) # Check that the new column is not usable in RETURNING diff --git a/pkg/sql/logictest/testdata/logic_test/upsert b/pkg/sql/logictest/testdata/logic_test/upsert index cbb48a5f57b4..8de929c5cdee 100644 --- a/pkg/sql/logictest/testdata/logic_test/upsert +++ b/pkg/sql/logictest/testdata/logic_test/upsert @@ -636,8 +636,7 @@ SELECT create_statement FROM [SHOW CREATE t29494] CREATE TABLE public.t29494 ( x INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT t29494_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (x, rowid) + CONSTRAINT t29494_pkey PRIMARY KEY (rowid ASC) ) # Check that the new column is not usable in RETURNING diff --git a/pkg/sql/logictest/testdata/logic_test/virtual_columns b/pkg/sql/logictest/testdata/logic_test/virtual_columns index 5f1faf1f18c1..b26e95f4343c 100644 --- a/pkg/sql/logictest/testdata/logic_test/virtual_columns +++ b/pkg/sql/logictest/testdata/logic_test/virtual_columns @@ -1182,8 +1182,7 @@ CREATE TABLE public.t63167_b ( a INT8 NULL, v INT8 NULL AS (a + 1:::INT8) VIRTUAL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT t63167_a_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (a, rowid) + CONSTRAINT t63167_a_pkey PRIMARY KEY (rowid ASC) ) # Test that columns backfills to tables with virtual columns work. diff --git a/pkg/sql/logictest/testdata/logic_test/zone_config b/pkg/sql/logictest/testdata/logic_test/zone_config index aa08d3714ff2..f083ec7c91ab 100644 --- a/pkg/sql/logictest/testdata/logic_test/zone_config +++ b/pkg/sql/logictest/testdata/logic_test/zone_config @@ -167,8 +167,7 @@ SHOW CREATE TABLE a ---- a CREATE TABLE public.a ( id INT8 NOT NULL, - CONSTRAINT a_pkey PRIMARY KEY (id ASC), - FAMILY "primary" (id) + CONSTRAINT a_pkey PRIMARY KEY (id ASC) ); ALTER TABLE test.public.a CONFIGURE ZONE USING range_min_bytes = 200001, @@ -322,8 +321,7 @@ SHOW CREATE TABLE same_table_name ---- same_table_name CREATE TABLE public.same_table_name ( rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT same_table_name_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (rowid) + CONSTRAINT same_table_name_pkey PRIMARY KEY (rowid ASC) ); ALTER TABLE test.public.same_table_name CONFIGURE ZONE USING gc.ttlseconds = 500 @@ -333,8 +331,7 @@ SHOW CREATE TABLE alternative_schema.same_table_name ---- alternative_schema.same_table_name CREATE TABLE alternative_schema.same_table_name ( rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), - CONSTRAINT same_table_name_pkey PRIMARY KEY (rowid ASC), - FAMILY "primary" (rowid) + CONSTRAINT same_table_name_pkey PRIMARY KEY (rowid ASC) ); ALTER TABLE test.alternative_schema.same_table_name CONFIGURE ZONE USING gc.ttlseconds = 600 diff --git a/pkg/sql/opt/exec/execbuilder/testdata/explain_env b/pkg/sql/opt/exec/execbuilder/testdata/explain_env index cc628b2d8ff8..1aea7a134929 100644 --- a/pkg/sql/opt/exec/execbuilder/testdata/explain_env +++ b/pkg/sql/opt/exec/execbuilder/testdata/explain_env @@ -37,7 +37,7 @@ CREATE TABLE y ( query T EXPLAIN (OPT, ENV) SELECT * FROM x WHERE b = 3 ---- -https://cockroachdb.github.io/text/decode.html#eJy0lNFu6jYYx6_rp_iUmwMTGQncVEFHWg4n1bLRUEHWtaoqy0kMeBg7cxwITJP6EDxhn2RyQls2iaJqKhdI_vL_ff77-zuxbbilqmBSeDCU6VJJki6-fwNa0TQpGc-oAk0LDetGhZBtg6JSZVThPyQTBeZsxTQsSAF6QSGjM1JyDWvCS-rBpdFTQRJO8Y7Nd2ReU6fkUhi9zDVbsR1VuCwoXrBCy7kiq-Ij1KrkmqWS40ITfYbkMiWc6S1-aZHhnCjNNJOCZpiJjFa4SMkZ27mSOZkTTTETealxPSQm5iep2azB6IwqzKVclvlhpjOp8Gx52nZDMqGpWhNe6C2nuJlydobJiInzA3pWEM7lBs9KzrGugzSjOOeNEzWnDWTkWMnNScR1HMcwqSx00xxvmF7ggwzXMbIdfW_LaRAbr7r4k8NXUxkAGPv_VpJSS7PTmqZaqvdaCoSGk8CPA4j9b6MA8jLhLP2xgha6IBBG8SVE4xii30ajDrpIDpVmNRxH03jih1EMFc6XdAs3k_Dan9zDr8E9tAj402G7gy7C6HtwBxVOMMsqaCUv9Sv_Ohzdg5UrtiJqa0GLdCBpo_YAIX8UB5P_egqjX4JhDNPYj8NpHA6n8OUBAQD8Vf-bn0XW83qIlgdO562cSl6uRGF58PBabPTW6_rxWK8o0TTDRFseWD3HvbQd13ZccFzPcTzHsY7EJhAmUpNgKQzgOsd71292na7e5saYdQwLc3dewGNMyc1bw17f7fXrZ393_u-Rk085cu3w806NHr8MEArubkZ-GEFrfBN3IIhu2zANRuZS_ABXk_E1VPD7z8EkgAS-Qn-AbNu2Uf1Jq346XEAEz_v98_7pef8EqRSFVoQJ7UG313U9eOj2wYZu_xH9EwAA___co-HC +https://cockroachdb.github.io/text/decode.html#eJy0lNFu8jYUx6_rpzjKzUcnMhK4qYIqLaWZlo2GCrKuVVVZTmLAw9iZ40BgmtSH4An7JJMT2rJJFFWfygWST_6_c_4-5yS2DXdUFUwKDwYyXShJ0vn1FdCKpknJeEYVaFpoWDUqhGwbFJUqowr_KZkoMGdLpmFOCtBzChmdkpJrWBFeUg8ujJ4KknCKt2y2JbOaOiaXwuhlrtmSbanCZUHxnBVazhRZFp-hliXXLJUcF5roEySXKeFMb_BrigznRGmmmRQ0w0xktMJFSk7YzpXMyYxoipnIS43rJjExO0pNpw1Gp1RhLuWizPc9nUqFp4vjthuSCU3VivBCbzjFTZezE0xGzDg_oWcF4Vyu8bTkHOt6kKYVp7xxoma0gYwcK7k-iriO4xgmlYVukuM103O8l-F6jGxLPyo5CWLjVRd_cbg0kT6Asf9fJSm1NJVWNNVSfZRSIDQYB34cQOxfDQPIy4Sz9McKWuiMQBjFFxCNYoh-Hw7b6CzZR5rTYBRN4rEfRjFUOF_QDdyOwxt__AC_BQ_QIuBPBudtdBZG18E9VDjBLKugldRxdN5HyB_Gwfj_lcPo12AQwyT243ASh4MJfHtEAAB_1__mZ5HVrG6V5YHTfg-nkpdLUVgePL4FG731dn461CtKNM0w0ZYHVtdxL2zHtR0XHNdzHM9xrAOxaTsTqZlTKQzgOoe16_e3nqHe5MaYdQgLsyGv4CGm5Po9Ybfndnv1s3_a33vl5EuuXDv8ulujp299hIL726EfRtAa3cZtCKK7c5gEQ7MUP8DP49ENVPDHL8E4gAQuoddHtm3bqP5wVT_t1wzBy273snt-2T1DKkWhFWFCe9DpdlwPHjs9sKHTe0L_BgAA__-x9NrZ statement error ENV only supported with \(OPT\) option EXPLAIN (ENV) SELECT * FROM x WHERE b = 3 @@ -49,7 +49,7 @@ EXPLAIN (ENV) SELECT * FROM x WHERE b = 3 query T EXPLAIN (OPT, ENV) SELECT * FROM x, y WHERE b = 3 ---- -https://cockroachdb.github.io/text/decode.html#eJy0ldFu2zYUhq-rpzjQTe3BWuT4JlBQYKrLbNocOZC1rkEQEJRE2VxoUiMpxcowoNgz-HJPlycZKDmJu8YNiqG-MKCj7yd_nvPT9jx4T5VmUgQwlfmNkiRfvXsLdEPzrGa8oAoM1QaannIczwNFpSqowr9LJjTmbM0MrIgGs6JQ0JLU3EBDeE0DOLE8FSTjFN-x5R1ZdqpDuBSWl5Vha3ZHFa41xSumjVwqstZfo1rX3LBccqwNMS8oucwJZ6bFD0sUuCLKMMOkoAVmoqAbrHPygu1KyYosiaGYiao2uGsSE8uDqrLsZbSkCnMpb-pq19NSKlzeHLbdK5kwVDWEa9NyivsuFy9oCmLH-RU804RzeYvLmnNsukHaVrzkjRO1pL3I4ljJ24OSse_7VpNLbfrF8S0zK7zDcDdGdke_tOUCpdar0X9weGMrpwDW_qckqY20OzU0N1J9aUnhONMEhSmCNHw7Q1DVGWf59xsYOK8IRHF6AvE8hfjX2WzkvMp2lf5pOo8XaRJGcQobXN3QFi6S6DxMLuEXdAkDAuFiOhw5r6L4HfoAG5xhVmxgkD3Uz8LzaHYJbqXYmqjWhQEZQTZ0hqeOE85SlPzXUxT_jKYpLNIwjRZpNF3A6ysHAODP7tt-XNIsuya6Afijp3Iueb0W2g3g6rHY8-7j8_U-rygxtMDEuAG4x_74xPPHnj8Gfxz4fuD77h5sB8JEbidYCysY-_t7dze7m65pK2vM3RcLm50H4b5MydunBY8n4-NJ9-6v0f89cvZNjtw5_Handq5fnz6f1dZmtf4sq82hrLbPZLV-yOQnXINLS57NExT9GPdkM4QEnaEExVO0eIzmgDwF3eq6oDeHg16PoDkY9PbZoHfnRx8uZmEUw2B-kY4Axe-HsEAzy34HZ8n8HDYjaOG3n1CCIIM3MDl1PM_zHCYEVV73lzTIldR66MD99p_77cf77UfofvPbzyqbH3Z31r75207hfrvdAbkU2ijChAng6PhoHMDV0QQ8OJpcO3tYybihSsPAqJoOnX8DAAD__3W7TB0= +https://cockroachdb.github.io/text/decode.html#eJy0ld9u2zYUxq_DpzjwTe3BWuT4JlBQYK7LbNpcOZC1rkUQELRE2VxoUiMpRcowoNgz-HJPlycZKDmJu8YJiqG-MKCj38fz76PtefCeacOVDGCq0mutaLp--wZYzdJlyUXGNFhmLFQdhZDngWZKZ0yT3xWXhgi-4RbW1IBdM8hYTkthoaKiZAGcOp5JuhSM3PLVLV21qkO4ko5XheUbfss0KQ0ja26sWmm6MV-j2pTC8lQJYiy1LyiFSqngtiH3R2SkoNpyy5VkGeEyYzUxKX2h7EKrgq6oZYTLorSkHRKXq4OqPO9kLGeaCKWuy2I301xpkl8fLrtTcmmZrqgwthGMdFPOXtBk1K3zK3huqBDqhuSlEMS2i3SjeKk2QfWKdSKHE61uDkpGvu87TaqM7Q4nN9yuyQ4j7Rr5LXsu5QInrlZr_hDw2kXOAFz5n5O0tMplqlhqlX7uSInQNMaTBEMyeTPDUJRLwdPva-ijIwphlJxCNE8g-nU2G6Kj5S7SPU3n0SKJJ2GUQE2Ka9bARRy-m8Qf4Rf8EfoUJovpYIiOwugt_gA1WRKe1dBftnE0OENoMktw_N_MYfQzniawSCZJuEjC6QJeXSIAgD_bb_fp0WrVjqoXgD98DKdKlBtpegFcPgQ7vvfwfLXPa0Ytywi1vQB6J_7o1PNHnj8CfxT4fuD7vT3YjZ3L1O2plE4w8vdzt_e33aFtCldYb18snUPuhfsyrW4eDzwZj07G7bu_hv-35eU3abmt8Nt1ja5enT3tyMY5svzCkdUhRzZPOLK8d-RnXEVyR57PYxz-GHVkNYAYn-MYR1O8eLBmnz7a2elaO1fP2rl50s5tl_jDxWwSRtCfXyRDwNH7ASzwzLHfwXk8fwf1EBr47SccY1jCaxifIc_zPMSlZNpr_176qVbGDBDcbf-52366236C9ve7-SJS_7C7f-7N327Wd9vtDkiVNFZTLm0AxyfHowAuj8fgwfH4Cu1hOReWaQN9q0s2QP8GAAD__wMoPiM= # # Same table twice should only show up once. @@ -58,7 +58,7 @@ https://cockroachdb.github.io/text/decode.html#eJy0ldFu2zYUhq-rpzjQTe3BWuT4JlBQY query T EXPLAIN (OPT, ENV) SELECT * FROM x one, x two ---- -https://cockroachdb.github.io/text/decode.html#eJy0lFFv2zYQx5_DT3HQS-3BGuT0JXDQB9VVAW2OElha0SAICEo62VxoUiMpW_YwoB_Cj_t0-SQDJaf1BrhGMcQPhnn3_x3_vKPp-_AJteFKTmCqiietWLH88B6wxSJvuChRg0VjYd2rCPF90Kh0iZr-rrg0VPAVt7BkBuwSocSKNcLCmokGJ3Dl9ChZLpDu-GLHFh11Sq6k06va8hXfoaaNQbrkxqqFZivzI9SqEZYXSlBjmT1DClUwwe2WvpQoac205ZYriSXlssSWmoKdsV1rVbMFs0i5rBtLuyZxuThJVVWPYYWaCqWemvrQ00ppWj2dtt2TXFrUayaM3QqkfZfLM0zJ3Dh_QM8NE0JtaNUIQW03SNeKc94E0wvsISenWm1OIuMgCBxTKGP74nTD7ZIeZLQbI9_h97ZMo8x5teYPAe9c5BrA2f-3kjVWuZ3WWFilv1dSEjKdR2EWQRa-n0VQN7ngxc8tDMgFgzjJriC5zSD5bTYbkYv8EOlX09skzeZhnGTQ0voJt3A3j2_C-T38Gt3DgEGYTocjchEnH6LP0NKc8rKFQf4S_xjexLN78GrNV0xvPRiwEeRDMrwmJJxl0fy_nuLkl2iaQZqFWZxm8TSFNw8EAODP7tt9PLZedE30JhCMvoULJZqVNN4EHr4Ge733df14rNfILJaUWW8C3mUwvvKDsR-MIRhPgmASBN6R2A2Ey8JNsJEOGAfHe3f_7G66dls7Y94xLN3deQGPMa023wpevh1fvu1yf43-75HzVzly5_D1Tk0e31wTEn2-m4VxAoPbu2wEUfJpCGk0c5fiJ_g4v72BFsIUlMRR_8tu1DXxfd8nXErUfvcoDwqtjBkSeN7__bz_8rz_At2r18IDM--UxMcTKbtRXWp_SFVcWNQGBlY3OCT_BAAA___pUfo2 +https://cockroachdb.github.io/text/decode.html#eJy0lMGO2zYQhs_LpxjoEruwCnlzWdjIQXFUQK0jLyw1SLBYELQ0slnTpEpStuyiQB7Cxz7dPklByUncAo6xCFYHQZz5v5nhDEXfhw-oDVdyBBOVr7Vi-erdW8AG80XNRYEaLBoL205FiO-DRqUL1PQPxaWhgm-4hRUzYFcIBZasFha2TNQ4gjunR8kWAumBLw9s2VKX5Eo6vaos3_ADalobpCturFpqtjHPoTa1sDxXghrL7BVSqJwJbvf0S4iCVkxbbrmSWFAuC2yoydmVsiutKrZkFimXVW1p2yQulxepsuwwLFFTodS6rk49LZWm5fpy2R3JpUW9ZcLYvUDadbm4whTMjfMZem6YEGpHy1oIattBulZcq00wvcQOcnKq1e4iMgyCwDG5MrYLTnfcruhJRtsx8gN-L2UaZa5Wa_4U8MZZxgCu_P8qWW2Vy7TF3Cr9vZCSkMk8CrMIsvDtNIKqXgie_9xAj9wwiJPsDpJZBsnv0-mA3CxOlm41mSVpNg_jJIOGVmvcw_08fh_OP8Fv0SfoMQjTSX9AbuLkXfQRGrqgvGigt2jtpD8mJJxm0fz_mePk12iSQZqFWZxm8SSFVw8EAOCv9u0ej22Xbau8EQSDb-ZciXojjTeCh6_GTu99XT-e6zUyiwVl1huBdxsM7_xg6AdDCIajIBgFgXcmdm3nMndzqqUDhsF57vb_bWdo95UrzDuHpTshX8BzTKvdt4C3r4e3r1vf34Mf3fLiRbbcVvhyuyaPr8aERB_vp2GcQG92nw0gSj70IY2m7lD8BL_MZ--hgTAFJXHQfdmdGhPf933CpUTtt1dvL9fKmD6Bp-M_T8fPT8fP0N5tDTww80ZJfLzgsjvVuo4nV8mFRW2gZ3WNffJvAAAA__9lEfNN # # Set a relevant session variable to a non-default value and ensure it shows up @@ -71,7 +71,7 @@ SET reorder_joins_limit = 63 query T EXPLAIN (OPT, ENV) SELECT * FROM y WHERE u = 3 ---- -https://cockroachdb.github.io/text/decode.html#eJyUk89O4zoUh9f4KY7Y0F6RC6jSCLViEYI7k5mQosTDgBCyTOK0nrpxxn9C0xUP0SfkSUZJYIMGKpaxvu_45HeOPQ-uuTZClWMIVLbUimWLi3Pga549OCFzrsFyY6HuKYRSTEBzpXOu6W8lSkOlWAkLZ_BlNAHwPMh5wZy0UDPp-BhOkecBL9mD5HQj5hs27zxYMAN2wd_iqmx5VVmxEhuuqTOcLoSxaq7ZynzGWjlpRaYkNZbZHaZUGZPCNvS1RE4rpq2wQpU8p6LM-ZqajO1ou9KqYnNmORVl5SztYhLl_F2rKHqNF1xTqdTSVS-pFkrTYvl-270pSst1zaSxjeS0Tznf4eSsnegneGGYlOqRFk5KartBtlHs6k0yPee91OJUq8d3lZPj4-PWyZSxfXH6KOyCvmC0G6PY8I-ubDczF8aaPxLO2pN_riNzVrU31TyzSn9UskQoSLBPMBD_PMJQuQcpsv8bGKA9B2FMTiGeEYh_RtEh2qtfTvqvYBanJPHDmEBDqyVv4CoJL_3kFn7gWxg48NNg-JaradGS01mCw69xT9ZDSPAUJzgOcPrawnrAWjmML_BN54l8DYP6tejUvwyjW9ivtFgx3ezDwB1CPUTDCUJ-RHDy9ofC-DsOCKTEJ2FKwiCFg7v7gwlC-OYq8sMYBrMrcgg4vh5CiqOW_Q-myewSGvj1DScYHJzBaII8z_NQ90waBM_b7fP26Xn7BJkqjdVMlHYMRydjuDsagQdHo3v0NwAA__-DroEQ +https://cockroachdb.github.io/text/decode.html#eJyUk8FO4zoUhtf4Kc6O9opcQJVGqBWLEMxMZkqKkgwDQsgyidN66sYZ-zg0XfEQfUKeZJQENmigYhnr-45__cfxPLgWxkpdjiHQ2dJoni3Oz0CsRfbgpMqFARQWoe4pQhKaghHa5MKw31qWlim5kgin8GU0AfA8yEXBnUKouXJiDCfE80CU_EEJtpHzDZ93Hiy4BVyIt7guW15XKFdyIwxzVrCFtKjnhq_sZ6yVUygzrZhFjjtMpTOuJDbsdUTOKm5QotSlyJksc7FmNuM7YldGV3zOUTBZVg5ZV5Ms5-9aRdFrohCGKa2XrnpptdCGFcv3Y_emLFGYmiuLjRKsbznf4eS83egneGm5UvqRFU4pht0i2yp2ZVPczEUvtTgz-vFd5fjo6Kh1Mm2xH84eJS7YC8a6NcqN-OjK9mXm0qL9o-C0Pfnnc-QOdXtTLTLU5qORJSFBTP2UQuqfTSlU7kHJ7P8GBmTPQRilJxDNUoh-TqcHZK9-Oem_glmUpLEfRik0rFqKBq7i8NKPb-EHvYWBAz8Jhm-5mhUteTGLafg16sl6CDG9oDGNApq8RlgPeCuH0Tm96TyZr2FQd0PJcEKIP01p_DZ2GH2nQQpJ6qdhkoZBAvt39_sTQujN1dQPIxjMrtIDoNH1EBI6bdn_4CKeXUIDv77RmIKDUxhNiOd5Hul-hobA83b7vH163j5BpkuLhssSx3B4PIa7wxF4cDi6J38DAAD__-ufef8= # Make sure it shows up correctly even if it matches the cluster setting. statement ok @@ -81,7 +81,7 @@ SET CLUSTER SETTING sql.defaults.reorder_joins_limit = 63 query T EXPLAIN (OPT, ENV) SELECT * FROM y WHERE u = 3 ---- -https://cockroachdb.github.io/text/decode.html#eJyUk89O4zoUh9f4KY7Y0F6RC6jSCLViEYI7k5mQosTDgBCyTOK0nrpxxn9C0xUP0SfkSUZJYIMGKpaxvu_45HeOPQ-uuTZClWMIVLbUimWLi3Pga549OCFzrsFyY6HuKYRSTEBzpXOu6W8lSkOlWAkLZ_BlNAHwPMh5wZy0UDPp-BhOkecBL9mD5HQj5hs27zxYMAN2wd_iqmx5VVmxEhuuqTOcLoSxaq7ZynzGWjlpRaYkNZbZHaZUGZPCNvS1RE4rpq2wQpU8p6LM-ZqajO1ou9KqYnNmORVl5SztYhLl_F2rKHqNF1xTqdTSVS-pFkrTYvl-270pSst1zaSxjeS0Tznf4eSsnegneGGYlOqRFk5KartBtlHs6k0yPee91OJUq8d3lZPj4-PWyZSxfXH6KOyCvmC0G6PY8I-ubDczF8aaPxLO2pN_riNzVrU31TyzSn9UskQoSLBPMBD_PMJQuQcpsv8bGKA9B2FMTiGeEYh_RtEh2qtfTvqvYBanJPHDmEBDqyVv4CoJL_3kFn7gWxg48NNg-JaradGS01mCw69xT9ZDSPAUJzgOcPrawnrAWjmML_BN54l8DYP6tejUvwyjW9ivtFgx3ezDwB1CPUTDCUJ-RHDy9ofC-DsOCKTEJ2FKwiCFg7v7gwlC-OYq8sMYBrMrcgg4vh5CiqOW_Q-myewSGvj1DScYHJzBaII8z_NQ90waBM_b7fP26Xn7BJkqjdVMlHYMRydjuDsagQdHo3v0NwAA__-DroEQ +https://cockroachdb.github.io/text/decode.html#eJyUk8FO4zoUhtf4Kc6O9opcQJVGqBWLEMxMZkqKkgwDQsgyidN66sYZ-zg0XfEQfUKeZJQENmigYhnr-45__cfxPLgWxkpdjiHQ2dJoni3Oz0CsRfbgpMqFARQWoe4pQhKaghHa5MKw31qWlim5kgin8GU0AfA8yEXBnUKouXJiDCfE80CU_EEJtpHzDZ93Hiy4BVyIt7guW15XKFdyIwxzVrCFtKjnhq_sZ6yVUygzrZhFjjtMpTOuJDbsdUTOKm5QotSlyJksc7FmNuM7YldGV3zOUTBZVg5ZV5Ms5-9aRdFrohCGKa2XrnpptdCGFcv3Y_emLFGYmiuLjRKsbznf4eS83egneGm5UvqRFU4pht0i2yp2ZVPczEUvtTgz-vFd5fjo6Kh1Mm2xH84eJS7YC8a6NcqN-OjK9mXm0qL9o-C0Pfnnc-QOdXtTLTLU5qORJSFBTP2UQuqfTSlU7kHJ7P8GBmTPQRilJxDNUoh-TqcHZK9-Oem_glmUpLEfRik0rFqKBq7i8NKPb-EHvYWBAz8Jhm-5mhUteTGLafg16sl6CDG9oDGNApq8RlgPeCuH0Tm96TyZr2FQd0PJcEKIP01p_DZ2GH2nQQpJ6qdhkoZBAvt39_sTQujN1dQPIxjMrtIDoNH1EBI6bdn_4CKeXUIDv77RmIKDUxhNiOd5Hul-hobA83b7vH163j5BpkuLhssSx3B4PIa7wxF4cDi6J38DAAD__-ufef8= statement ok SET enable_zigzag_join = false @@ -89,7 +89,7 @@ SET enable_zigzag_join = false query T EXPLAIN (OPT, ENV) SELECT * FROM y WHERE u = 3 ---- -https://cockroachdb.github.io/text/decode.html#eJyUk99O2zwYxo_xVbzihPYT-QBVmlArDkJwt2whRUnGQAhZJnFar66d-U9oesRF9Aq5kikJnKBRtsNEv9_jN8_reB5cM224kmMIVL7UiuaLi3Nga5Y_OC4KpsEyY6HuKYRSnIFmShdMk5-KS0MEX3ELZ_BpNAHwPChYSZ2wUFPh2BhOO4VJ-iAY2fD5hs47Ec5AleUfFSWR54GqLF_xDdPEGUYW3Fg113RlYEEN2AX7G2vlhOW5EsRYaj8whcqp4LYhrxEFqai23HIlWUG4LNiamJzK3TGVVhWdU8sIl5WzpKuKy_m7Vln2GiuZJkKppatemi2VJuXy_bF7k0vLdE2FsY1gpC-6-MApaLvVf-C5oUKoR1I6IYjtdtlW8dFsguo566UWJ1o9vqucHB8ft06ujO3DySO3C_KCkW6NfMN2HdletYIba36JHfeLOqvak2qWW6V3RUqEggT7GYbMP48wVO5B8Pz_BgZoz0EYZ6cQzzKIv0fRIdqrX970T8EsTrPED-MMGlItWQNXSXjpJ7fwDd_CwIGfBsO3XE3KlpzOEhx-jnuyHkKCpzjBcYDT1xHWA9rKYXyBbzqPF2sY1K-hU_8yjG5hv9J8RXWzDwN3CPUQDScI-VGGk7cfFMZfcZBBmvlZmGZhkMLB3f3BBCF8cxX5YQyD2VV2CDi-HkKKo5b9D6bJ7BIa-PEFJxgcnMFogjzP81D3mzQInrfb5-3T8_YJciWN1ZRLO4ajkzHcHY3Ag6PRPfodAAD__8JdgXI= +https://cockroachdb.github.io/text/decode.html#eJyUk99O2zwYxo_xVbxntJ_IB6jShFpxEILZspUUJR4DIWSZxGm9unbmP6HpERfRK-RKpiRwgkbZDhP9fo9fPa8dBHDNjRVajSHS-dJoli_Oz4Cvef7ghSy4Acetg7qnEMowAcO1KbihP7VQlkqxEg5O4dNoAhAEUPCSeemgZtLzMZx0ClfsQXK6EfMNm3cinIIuyz8qWqEgAF05sRIbbqi3nC6EdXpu2MrCgllwC_431spLJ3ItqXXMfWBKnTMpXENfIwpaMeOEE1rxggpV8DW1OVO7YyqjKzZnjlOhKu9oV5VQ83etsuw1XnJDpdZLX700W2pDy-X7Y_emUI6bmknrGslpX3TxgVOwdqv_wAvLpNSPtPRSUtftsq3io9kkM3PeSy1OjX58Vzk-OjpqnVxb14fTR-EW9AWj3RrFhu86sr1qhbDO_pI77hfzTrcn1Tx32uyKVAhFKQ4JBhKeTTFU_kGK_P8GBmjPQ5yQE0hmBJLv0-kB2qtf_vRf0SzJSBrGCYGGVkvewFUaX4bpLXzDtzDwEGbR8C1X07IlL2Ypjj8nPVkPIcUXOMVJhLPXEdYD1spxco5vOk8UaxjUXSgaThAKpwSnb8eOk684IpCRkMQZiaMM9u_u9ycI4ZuraRgnMJhdkQPAyfUQMjxt2f_gIp1dQgM_vuAUg4dTGE1QEAQB6h5Dg-B5u33ePj1vnyDXyjrDhHJjODwew93hCAI4HN2j3wEAAP__IGl6YQ== statement ok SET optimizer_use_histograms = false @@ -97,7 +97,7 @@ SET optimizer_use_histograms = false query T EXPLAIN (OPT, ENV) SELECT * FROM y WHERE u = 3 ---- -https://cockroachdb.github.io/text/decode.html#eJyUk81O4zwUhtf4Ko7Y0H4iH6BKI9SKRQjuTGZCipIMA0LIMonTeuraGf-EpisuolfIlYySwAZB0SwTPc_rk_c4ngfXTBuu5BgClS-1ovni4hzYmuUPjouCabDMWKh7CqEUZ6CZ0gXT5Lfi0hDBV9zCGXwZTQA8DwpWUics1FQ4NobTTmGSPghGNny-ofNOhDNQZfmuomTnqMryFd8wTZxhZMGNVXNNV2a36XlvxJUTludKEGOpNbCgBuyCvW8KlVPBbUNeIwpSUW255UqygnBZsDUxOZW7YyqtKjqnlhEuK2dJVxeX8w-tsuw1VjJNhFJLV720WypNyuXHY_cml5bpmgpjG8FIX3bxiVPQdrP_wHNDhVCPpHRCENvts63is9kE1XPWSy1OtHr8UDk5Pj5unVwZ24eTR24X5AUj3Rr5hu06sr06BTfW_BE7bgp1VrUn1Sy3Su-KlAgFCfYzDJl_HmGo3IPg-f8NDNCegzDOTiGeZRD_jKJDtFe_vOmfglmcZokfxhk0pFqyBq6S8NJPbuEHvoWBAz8Nhm-5mpQtOZ0lOPwa92Q9hARPcYLjAKevI6wHtJXD-ALfdB4v1jCoX0On_mUY3cJ-pfmK6mYfBu4Q6iEaThDyowwnbz8ojL_jIIM087MwzcIghYO7-4MJQvjmKvLDGAazq-wQcHw9hBRHLfsfTJPZJTTw6xtOMDg4g9EEeZ7noe43aRA8b7fP26fn7RPkShqrKZd2DEcnY7g7GoEHR6N79DcAAP__PjmB1A== +https://cockroachdb.github.io/text/decode.html#eJyUk81O4zwUhtf4Ks6O9hP5AFUaoVYsQjAzmSkpSjwMCCHLJE7rqWtn_BOarriIXiFXMkoCGwRFs0z0PK-P3mMHAVxzY4VWY4h0vjSa5YvzM-Brnj94IQtuwHHroO4phDJMwHBtCm7oby2UpVKshINT-DKaAAQBFLxkXjqomfR8DCedwhV7kJxuxHzD5p0Ip6DL8l1Fq87RlRMrseGGesvpQlin54at7G4zCN6IKy-dyLWk1jFnYcEsuAV_35Q6Z1K4hr5GFLRixgkntOIFFarga2pzpnbHVEZXbM4cp0JV3tGuLqHmH1pl2Wu85IZKrZe-emm31IaWy4_H7k2hHDc1k9Y1ktO-7OITp2DtZv-BF5ZJqR9p6aWkrttnW8Vns0lm5ryXWpwa_fihcnx0dNQ6ubauD6ePwi3oC0a7NYoN33Vke3UKYZ39I3fcFOadbk-qee602RWpEIpSHBIMJDybYqj8gxT5_w0M0J6HOCEnkMwIJD-n0wO0V7_86b-iWZKRNIwTAg2tlryBqzS-DNNb-IFvYeAhzKLhW66mZUtezFIcf016sh5Cii9wipMIZ68jrAeslePkHN90nijWMKi7UDScIBROCU7fjh0n33FEICMhiTMSRxns393vTxDCN1fTME5gMLsiB4CT6yFkeNqy_8FFOruEBn59wykGD6cwmqAgCALUPYYGwfN2-7x9et4-Qa6VdYYJ5cZweDyGu8MRBHA4ukd_AwAA__-SQnrD statement ok SET optimizer_use_multicol_stats = false @@ -105,7 +105,7 @@ SET optimizer_use_multicol_stats = false query T EXPLAIN (OPT, ENV) SELECT * FROM y WHERE u = 3 ---- -https://cockroachdb.github.io/text/decode.html#eJyUk89O4zoUxtf4KY7Y0F6RC6jSFWrFIgT3TmZCipIMA0LIMonTeuraGf8JTVc8RJ-QJxklgQ0CKpaJfr_PJ-eLPQ-umTZcyTEEKl9qRfPFxTmwNcsfHBcF02CZsVD3FEIpzkAzpQumyW_FpSGCr7iFM_hvNAHwPChYSZ2wUFPh2BhOO4VJ-iAY2fD5hs47Ec5AleW7ipKdoyrLV3zDNHGGkQU3Vs01XZmvmisnLM-VIMZSu8P2PBAqp4LbhrymFKSi2nLLlWQF4bJga2JyKmFBDdgFez-m0qqic2oZ4bJylnQr43L-oVWWvcZKpolQaumqlw2XSpNyaXaYXFqmayqMbQQj_cKLHU5B23a_wHNDhVCPpHRCENt12q5i12yC6jnrpRYnWj1-qJwcHx-3Tq6M7cPJI7cL8oKRrkm-YZ8d2f4EBTfW_BGf9E2dVe1JNcut0p9FSoSCBPsZhsw_jzBU7kHw_N8GBmjPQRhnpxDPMoh_RtEh2qtf3vRPwSxOs8QP4wwaUi1ZA1dJeOknt_AD38LAgZ8Gw7dcTcqWnM4SHP4f92Q9hARPcYLjAKevI6wHtJXD-ALfdB4v1jCoX0On_mUY3cJ-pfmK6mYfBu4Q6iEaThDyowwnbz8ojL_jIIM087MwzcIghYO7-4MJQvjmKvLDGAazq-wQcHw9hBRHLfsPTJPZJTTw6xtOMDg4g9EEeZ7noe6aNAiet9vn7dPz9glyJY3VlEs7hqOTMdwdjcCDo9E9-hsAAP___GiCNg== +https://cockroachdb.github.io/text/decode.html#eJyUk89O4zoUxtf4Kc6O9opcQJWuUCsWIZg7mSkpSjwMCCHLJE7rqWtn_Cc0XfEQfUKeZJQENgioWCb6_b5zdL4kCOCaGyu0GkOk86XRLF-cnwFf8_zBC1lwA45bB3VPIZRhAoZrU3BDf2uhLJViJRycwn-jCUAQQMFL5qWDmknPx3DSKVyxB8npRsw3bN6JcAq6LN9VtOocXTmxEhtuqLecLoR1em7Yyn7VXHnpRK4ltY65HXYQgNQ5k8I19DWloBUzTjihFS-oUAVfU5szBQtmwS34-zGV0RWbM8epUJV3tDuZUPMPrbLsNV5yQ6XWS1-9XLjUhpZLu8MUynFTM2ldIzntD17scArWtvsFXlgmpX6kpZeSuq7T9hS7dpPMzHkvtTg1-vFD5fjo6Kh1cm1dH04fhVvQF4x2TYoN_2xk-xEUwjr7R37SN_NOt5NqnjttPotUCEUpDgkGEp5NMVT-QYr83wYGaM9DnJATSGYEkp_T6QHaq1_e9E_RLMlIGsYJgYZWS97AVRpfhukt_MC3MPAQZtHwLVfTsiUvZimO_096sh5Cii9wipMIZ68rrAeslePkHN90nijWMKi7UDScIBROCU7frh0n33FEICMhiTMSRxns393vTxDCN1fTME5gMLsiB4CT6yFkeNqy_8BFOruEBn59wykGD6cwmqAgCALU_QwNguft9nn79Lx9glwr6wwTyo3h8HgMd4cjCOBwdI_-BgAA__9GjHsl statement ok RESET reorder_joins_limit @@ -141,7 +141,7 @@ CREATE VIEW v AS SELECT a, b, u, v FROM x, y WHERE b = 3 query T EXPLAIN (OPT, ENV) SELECT * FROM v ---- -https://cockroachdb.github.io/text/decode.html#eJy0Vd1u2zYUvg6f4kA3tQepkWNgKGwEmOoymzZHDmQtbRAEBC3RNhda1EhKsTIMKPYMvtzT5UkGSnbitnGDYqgvDPDw-87vd0TPg0umNJf5AEYyvVWSpst3b4GtWToruciYAsO0gapFITTFCSgmVcYU-UPyXBPBV9zAKfzYHwJ4HmRsTkthoKKiZAN4gzwPWE5ngpF7vrini4YHS6rBLNnncJlbvCwMX_F7pkipGVlybeRC0ZX-FtaqFIanUhBtqHmBKWRKBTc12bnISEGV4YbLnGWE5xlbE53SF9IulCzoghpGeF6UhjRt4vniIGs-b2lszhQRUt6Wxbarc6nI_PZw2i2T54apigptasFI2-XsBU5G7US_Ac81FULekXkpBDHNIG0rXspNULVgLcnCiZJ3Byk93_ctJ5XatM7JHTdLsoWRZoz8nn0tpFVmxrXRfwo4tZZn5UhLI22kiqVGqq-5zBEaxThIMCTB2zGGopwJnr5eQwcdUQij5A1EkwSi38djFx3Ntpb2NJpE0yQOwiiBNSluWQ0XcXgexFfwG76CDoVgOuq66CiM3uEPsCYzwrM1dGY7-1lwHo6vwCkUX1FVO9ChLsy6qDtEKBgnOP48pzD6FY8SmCZBEk6TcDSFV9cIAOCv5t_-HFotmiY6A_DdJ3MqRbnKtTOA60dji3cezzf7eMWoYRmhxhmAc-L33nh-z_N74PcGvj_wfWcPbAfC89ROsMwtoefvx242u5muqQubmLNPzq12dsR9mpJ3Tw5P-r2TfnP3t_t_S559l5KbDL9f1ejm1fB5rdZWq-UXWq0OabV-RqvlTpOf4Coyt8izSYzDn6MWWXUhxmc4xtEITx-l2aFPQre8RujVYaGXLlQHhV4_K_T9-i9D_H6HrppVtcvpoqPSFo66EExhisfWh10pF2w8OIsn581D93qXtvvJsYb3v-AYwwxOoT9ECH-4GAdhBJ3JReICji67O6c_tL6qIfI8z0M8z5nymgevkyqpdRfBw-bfh83Hh81HaF6U-gvL-qftF8He_GNn_LDZbAGpzLVRlOdmAMcnx70BXB_3wYPj_g3ag825MExp6BhVsi76LwAA__9onmWt +https://cockroachdb.github.io/text/decode.html#eJy0Vd1u2zYUvg6f4sA3tQepkWNgCBwEmOsymzZXDmQtbREEBC1RNhea1EhKsTIMKPYMvtzT5UkGSnbitvlBMVQXAnj4fef3O6DvwwXThis5hLFKr7Wi6fLtG2Brls5LLjKmwTJjoWpRCM1wApopnTFN_lBcGiL4ils4hR8HJwC-DxnLaSksVFSUbAjHyPeBSToXjNzyxS1dNDxYUgN2yb6EK-nwqrB8xW-ZJqVhZMmNVQtNV-ZbWKtSWJ4qQYyl9gWmUCkV3NZk5yIjBdWWW64kywiXGVsTk9IX0i60KuiCWka4LEpLmjZxuXiSlectjeVME6HUdVlsu5orTfLrp9NumVxapisqjK0FI22Xsxc4GXUT_QY8N1QIdUPyUghim0G6VryUm6B6wVqSgxOtbp6k9IMgcJxUGds6JzfcLskWRpox8lv2XEinzIwba_4UcOosj8qRlla5SBVLrdLPuZQIjWM8SjAkozcTDEU5Fzx9vYYuOqAQRskxRNMEot8nEw8dzLeW9jSeRrMkHoVRAmtSXLMazuPw3Sj-CL_hj9ClMJqNex46CKO3-AOsyZzwbA3deWNHvROERpMEx19GDqNf8TiBWTJKwlkSjmfw6hIBAPzV_N3XodWiaVVnCIH3YE6VKFfSdIZweW9s8Z3789U-XjNqWUao7QyhcxT0j_2g7wd9CPrDIBgGQWcP7NrOZermVEpH6Af7sZv9bWZo68Il1tknS6eQHXGfptXNg8OjQf9o0Nz97f3fkuffpeQmw-9XNbp6dfK4ImunyPIrRVZPKbJ-RJHlTpGf4SqSO-TZNMbhz1GLrHoQ4zMc42iMZ_fS7NIHOTteI-fqWTnXj8p5v8qLEL_foatm7dyieeigdOWhHoxmMMMT54N6MPeg9KCCs3j6rnm0Xu-S8z471vD-FxxjmMMpDE4Qwh_OJ6Mwgu70PPEARxe9ndMfWl_VCfJ930dcSqb95vHqploZ00Nwt_n3bvPpbvMJmteh_sqy_mm73e7mHzfJu81mC0iVNFZTLu0QDo8O-0O4PByAD4eDK7QHy7mwTBvoWl2yHvovAAD__-qlV7M= # # Test tables in user-defined schemas. @@ -154,4 +154,4 @@ CREATE TABLE s.t (a int primary key) query T EXPLAIN (OPT, ENV) SELECT * FROM s.t; ---- -https://cockroachdb.github.io/text/decode.html#eJyUkkFr20wQhs_eXzHkEvvD-nAplBCTg6IqoFaWjbQNNaUsG2kkb73WqrsjO_avL5JSKKWOyXV4npnhnfE8eETrlKlvITD51hqZbz7eAz5j_tQqXaAFQkewHyjGspCDRWMLtOKHUbUTWu0UwR18eD8H8DwosJStJthL3eIt3DDPA6zlk0ZxUtVJVr0HG-mANvg3buqONw2pnTqhFa1DsVGOTGXlzr3F2rWaVG60cCTpgqlNLrWio_jdohCNtKRImRoLoeoCn4XL5YW1G2saWUlCoeqmJdHHpOrqrFWWg4YlWqGN2bbNS6qlsaLcnl97MFVNaPdSOzpqFEPKxQWnkN1F38ArJ7U2B1G2WgvqD9lFcWk3LW2Fg9ThwprDWeXdbDbrnNw4GpqLg6KNeMFEf0Z1wtdGdp9ZKEfup4a7rvLPd5QtmW7SHnMy9rWWNWNBGvo8BO7fxyG4_wnGbCQhSvgNJEsOyZc4nrJRsEwynvpRwoFEs8UjrNJo4adr-ByuYSzBz4LJlI0e_EUUr-GqsWon7fEKxnLCJnPG_JiH6R9TouRTGHDIuM-jjEdBBtffvl_PGQu_rmI_SmC8XPEphMnjBLIw7tj_4CFdLjp7zjzP81j_rMR-BQAA__-oFVBT +https://cockroachdb.github.io/text/decode.html#eJyUklFr2zAQx5-rT3FvbUY9MgajNPTB9Tzw5jrB1srKGIdqnx0tiuVJ56TJpx-OOxhjaeir-P3-Ov53QQD35Ly27TVEtlw5q8rlx1ugJyofe20qcsDkGTYjJUQRS3BkXUUOf1rdejR6rRlu4MP7GUAQQEW16g3DRpmeruFKBAFQqx4N4V43e9UcPFgqD7ykf3HbDrztWK_1nhz2nnCpPdvGqbV_jbXuDevSGvSs-IRpbKmM5h3-iaiwU441a9tShbqt6Al9qU6M3TnbqUYxoW67nvFQk26bo1ZdjxrV5NBYu-q751Zr67BeHR97NHXL5DbKeN4ZwrHl6oRTqWGjr-C1V8bYLda9MciHRQ5VnJrNKNfQKA04Ors9qrybTqeDU1rPYzhuNS_xGcPDGvWeXvpyuMxKe_a_DNwML_89R9WzHX7aUMnWvRTZChHlcShjkOFtGoN_y3AhzhQkmbyCbC4h-5qml-IsmmeFzMMkk8DYrWgHizy5C_MH-BI_wIWCsIgmYjITIkxlnP8Vl2Sf40hCIUOZFDKJCjj__uN8JkT8bZGGSQYX84W8hDi7n0ARpwP7Bj7l87vBnokgCAJxuEoWvwMAAP__iItKGA== diff --git a/pkg/sql/opt/exec/execbuilder/testdata/hash_sharded_index b/pkg/sql/opt/exec/execbuilder/testdata/hash_sharded_index index 2dfb7df39fa9..8a2efc81eb7a 100644 --- a/pkg/sql/opt/exec/execbuilder/testdata/hash_sharded_index +++ b/pkg/sql/opt/exec/execbuilder/testdata/hash_sharded_index @@ -165,10 +165,9 @@ query T SELECT @2 FROM [SHOW CREATE TABLE t] ---- CREATE TABLE public.t ( - crdb_internal_a_shard_8 INT4 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(a)), 8:::INT8)) VIRTUAL, - a INT8 NOT NULL, - CONSTRAINT t_pkey PRIMARY KEY (a ASC) USING HASH WITH (bucket_count=8), - FAMILY "primary" (a) + crdb_internal_a_shard_8 INT4 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(a)), 8:::INT8)) VIRTUAL, + a INT8 NOT NULL, + CONSTRAINT t_pkey PRIMARY KEY (a ASC) USING HASH WITH (bucket_count=8) ) query T diff --git a/pkg/sql/opt/exec/execbuilder/testdata/show_trace_nonmetamorphic b/pkg/sql/opt/exec/execbuilder/testdata/show_trace_nonmetamorphic index 41a7a3c03562..75494f499b47 100644 --- a/pkg/sql/opt/exec/execbuilder/testdata/show_trace_nonmetamorphic +++ b/pkg/sql/opt/exec/execbuilder/testdata/show_trace_nonmetamorphic @@ -2,20 +2,48 @@ # Check SHOW KV TRACE FOR SESSION. +let $trace_query +SELECT $$ + SELECT + operation, + regexp_replace( + regexp_replace( + regexp_replace( + regexp_replace( + message, + 'create_as_of_time:<[^>]+>', + 'create_as_of_time:<...>' + ), + 'created_at_nanos:[1-9]\d*', + 'created_at_nanos:...', + 'g' + ), + 'mutationJobs:<[^>]*>', + 'mutationJobs:<...>' + ), + 'drop_time:[1-9]\d*', + 'drop_time:...' + ) + AS message + FROM + [SHOW KV TRACE FOR SESSION] + WHERE + message NOT LIKE '%Z/%' + AND operation NOT LIKE 'kv.DistSender: sending partial batch%' + AND message NOT SIMILAR TO '%(PushTxn|ResolveIntent|SystemConfigSpan)%' + AND tag NOT LIKE '%intExec=%' + AND tag NOT LIKE '%scExec%' + AND tag NOT LIKE '%IndexBackfiller%' + AND operation != 'dist sender send' +$$ + statement ok SET tracing = on,kv,results; CREATE DATABASE t; SET tracing = off # Check the KV trace; we need to remove the eventlog entry and # internal queries since the timestamp is non-deterministic. query TT -SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] -WHERE message NOT LIKE '%Z/%' - AND operation NOT LIKE 'kv.DistSender: sending partial batch%' -- order of partial batches is not deterministic - AND message NOT SIMILAR TO '%(PushTxn|ResolveIntent|SystemConfigSpan)%' - AND tag NOT LIKE '%intExec=%' - AND tag NOT LIKE '%scExec%' - AND tag NOT LIKE '%IndexBackfiller%' - AND operation != 'dist sender send' +$trace_query ---- batch flow coordinator CPut /NamespaceTable/30/1/106/0/"public"/4/1 -> 107 batch flow coordinator CPut /Table/3/1/107/2/1 -> schema: version:1 parent_id:106 privileges: users: users: owner_proto:"admin" version:2 > > @@ -29,18 +57,10 @@ statement ok SET tracing = on,kv,results; CREATE TABLE t.kv(k INT PRIMARY KEY, v INT, FAMILY "primary" (k, v)); SET tracing = off query TT -SELECT operation, regexp_replace(message, 'create_as_of_time:<[^>]+>', 'create_as_of_time:<...>') as message - FROM [SHOW KV TRACE FOR SESSION] -WHERE message NOT LIKE '%Z/%' - AND operation NOT LIKE 'kv.DistSender: sending partial batch%' -- order of partial batches is not deterministic - AND message NOT SIMILAR TO '%(PushTxn|ResolveIntent|SystemConfigSpan)%' - AND tag NOT LIKE '%intExec=%' - AND tag NOT LIKE '%scExec%' - AND tag NOT LIKE '%IndexBackfiller%' - AND operation != 'dist sender send' +$trace_query ---- batch flow coordinator CPut /NamespaceTable/30/1/106/107/"kv"/4/1 -> 108 -batch flow coordinator CPut /Table/3/1/108/2/1 -> table: parent_id:106 unexposed_parent_schema_id:107 columns: nullable:false hidden:false inaccessible:false generated_as_identity_type:NOT_IDENTITY_COLUMN virtual:false pg_attribute_num:0 alter_column_type_in_progress:false system_column_kind:NONE > columns: nullable:true hidden:false inaccessible:false generated_as_identity_type:NOT_IDENTITY_COLUMN virtual:false pg_attribute_num:0 alter_column_type_in_progress:false system_column_kind:NONE > next_column_id:3 families: next_family_id:1 primary_index: interleave:<> partitioning: type:FORWARD created_explicitly:false encoding_type:1 sharded: disabled:false geo_config:<> predicate:"" use_delete_preserving_encoding:false constraint_id:1 > next_index_id:2 privileges: users: users: owner_proto:"root" version:2 > next_mutation_id:1 format_version:3 state:PUBLIC offline_reason:"" view_query:"" is_materialized_view:false new_schema_change_job_id:0 drop_time:0 replacement_of: > audit_mode:DISABLED drop_job_id:0 create_query:"" create_as_of_time:<> temporary:false partition_all_by:false exclude_data_from_backup:false next_constraint_id:2 > +batch flow coordinator CPut /Table/3/1/108/2/1 -> table: parent_id:106 unexposed_parent_schema_id:107 columns: nullable:false hidden:false inaccessible:false generated_as_identity_type:NOT_IDENTITY_COLUMN virtual:false pg_attribute_num:0 alter_column_type_in_progress:false system_column_kind:NONE > columns: nullable:true hidden:false inaccessible:false generated_as_identity_type:NOT_IDENTITY_COLUMN virtual:false pg_attribute_num:0 alter_column_type_in_progress:false system_column_kind:NONE > next_column_id:3 families: next_family_id:1 primary_index: interleave:<> partitioning: type:FORWARD created_explicitly:false encoding_type:1 sharded: disabled:false geo_config:<> predicate:"" use_delete_preserving_encoding:false constraint_id:1 created_at_nanos:... > next_index_id:2 privileges: users: users: owner_proto:"root" version:2 > next_mutation_id:1 format_version:3 state:PUBLIC offline_reason:"" view_query:"" is_materialized_view:false new_schema_change_job_id:0 drop_time:0 replacement_of: > audit_mode:DISABLED drop_job_id:0 create_query:"" create_as_of_time:<> temporary:false partition_all_by:false exclude_data_from_backup:false next_constraint_id:2 > sql query rows affected: 0 # We avoid using the full trace output, because that would make the @@ -53,28 +73,16 @@ statement ok SET tracing = on,kv,results; CREATE UNIQUE INDEX woo ON t.kv(v); SET tracing = off query TT -SELECT operation, - regexp_replace(regexp_replace(message, 'create_as_of_time:<[^>]+>', 'create_as_of_time:<...>'), 'mutationJobs:<[^>]*>', 'mutationJobs:<...>') as message - FROM [SHOW KV TRACE FOR SESSION] -WHERE message NOT LIKE '%Z/%' AND message NOT LIKE 'querying next range at%' - AND operation NOT LIKE 'kv.DistSender: sending partial batch%' -- order of partial batches is not deterministic - /* since the transactions involved are multi-range, intent resolving is async and - sometimes there's still intents around */ - AND message NOT SIMILAR TO '%(PushTxn|ResolveIntent|SystemConfigSpan)%' - AND tag NOT LIKE '%intExec=%' - AND tag NOT LIKE '%scExec%' - AND tag NOT LIKE '%IndexBackfiller%' - AND operation != 'dist sender send' +$trace_query ---- -batch flow coordinator Put /Table/3/1/108/2/1 -> table: parent_id:106 unexposed_parent_schema_id:107 columns: nullable:false hidden:false inaccessible:false generated_as_identity_type:NOT_IDENTITY_COLUMN virtual:false pg_attribute_num:0 alter_column_type_in_progress:false system_column_kind:NONE > columns: nullable:true hidden:false inaccessible:false generated_as_identity_type:NOT_IDENTITY_COLUMN virtual:false pg_attribute_num:0 alter_column_type_in_progress:false system_column_kind:NONE > next_column_id:3 families: next_family_id:1 primary_index: interleave:<> partitioning: type:FORWARD created_explicitly:false encoding_type:1 sharded: disabled:false geo_config:<> predicate:"" use_delete_preserving_encoding:false constraint_id:1 > next_index_id:3 privileges: users: users: owner_proto:"root" version:2 > mutations: interleave:<> partitioning: type:FORWARD created_explicitly:true encoding_type:0 sharded: disabled:false geo_config:<> predicate:"" use_delete_preserving_encoding:false constraint_id:2 > state:DELETE_ONLY direction:ADD mutation_id:1 rollback:false > next_mutation_id:2 format_version:3 state:PUBLIC offline_reason:"" view_query:"" is_materialized_view:false mutationJobs:<...> new_schema_change_job_id:0 drop_time:0 replacement_of: > audit_mode:DISABLED drop_job_id:0 create_query:"" create_as_of_time:<...> temporary:false partition_all_by:false exclude_data_from_backup:false next_constraint_id:3 > +batch flow coordinator Put /Table/3/1/108/2/1 -> table: parent_id:106 unexposed_parent_schema_id:107 columns: nullable:false hidden:false inaccessible:false generated_as_identity_type:NOT_IDENTITY_COLUMN virtual:false pg_attribute_num:0 alter_column_type_in_progress:false system_column_kind:NONE > columns: nullable:true hidden:false inaccessible:false generated_as_identity_type:NOT_IDENTITY_COLUMN virtual:false pg_attribute_num:0 alter_column_type_in_progress:false system_column_kind:NONE > next_column_id:3 families: next_family_id:1 primary_index: interleave:<> partitioning: type:FORWARD created_explicitly:false encoding_type:1 sharded: disabled:false geo_config:<> predicate:"" use_delete_preserving_encoding:false constraint_id:1 created_at_nanos:... > next_index_id:3 privileges: users: users: owner_proto:"root" version:2 > mutations: interleave:<> partitioning: type:FORWARD created_explicitly:true encoding_type:0 sharded: disabled:false geo_config:<> predicate:"" use_delete_preserving_encoding:false constraint_id:2 created_at_nanos:... > state:DELETE_ONLY direction:ADD mutation_id:1 rollback:false > next_mutation_id:2 format_version:3 state:PUBLIC offline_reason:"" view_query:"" is_materialized_view:false mutationJobs:<...> new_schema_change_job_id:0 drop_time:0 replacement_of: > audit_mode:DISABLED drop_job_id:0 create_query:"" create_as_of_time:<...> temporary:false partition_all_by:false exclude_data_from_backup:false next_constraint_id:3 > sql query rows affected: 0 statement ok SET tracing = on,kv,results; INSERT INTO t.kv(k, v) VALUES (1,2); SET tracing = off query TT -SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] - WHERE operation != 'dist sender send' AND operation != 'kv.DistSender: sending partial batch' +$trace_query ---- batch flow coordinator CPut /Table/108/1/1/0 -> /TUPLE/2:2:Int/2 batch flow coordinator InitPut /Table/108/2/2/0 -> /BYTES/0x89 @@ -87,8 +95,7 @@ SET tracing = on,kv,results; INSERT INTO t.kv(k, v) VALUES (1,2); SET tracing = query TT set tracing=off; -SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] - WHERE operation != 'dist sender send' AND operation != 'kv.DistSender: sending partial batch' +$trace_query ---- batch flow coordinator CPut /Table/108/1/1/0 -> /TUPLE/2:2:Int/2 batch flow coordinator InitPut /Table/108/2/2/0 -> /BYTES/0x89 @@ -99,8 +106,7 @@ SET tracing = on,kv,results; INSERT INTO t.kv(k, v) VALUES (2,2); SET tracing = query TT set tracing=off; -SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] - WHERE operation != 'dist sender send' AND operation != 'kv.DistSender: sending partial batch' +$trace_query ---- batch flow coordinator CPut /Table/108/1/2/0 -> /TUPLE/2:2:Int/2 batch flow coordinator InitPut /Table/108/2/2/0 -> /BYTES/0x8a @@ -110,32 +116,17 @@ statement ok SET tracing = on,kv,results; CREATE TABLE t.kv2 AS TABLE t.kv; SET tracing = off query TT -SELECT operation, regexp_replace(regexp_replace(message, 'create_as_of_time:<[^>]+>', 'create_as_of_time:<...>'), '\d\d\d\d\d+', '...PK...') as message - FROM [SHOW KV TRACE FOR SESSION] -WHERE message NOT LIKE '%Z/%' - AND operation NOT LIKE 'kv.DistSender: sending partial batch%' -- order of partial batches is not deterministic - AND message NOT SIMILAR TO '%(PushTxn|ResolveIntent|SystemConfigSpan)%' - AND tag NOT LIKE '%intExec=%' - AND tag NOT LIKE '%scExec%' - AND tag NOT LIKE '%IndexBackfiller%' - AND operation != 'dist sender send' +$trace_query ---- batch flow coordinator CPut /NamespaceTable/30/1/106/107/"kv2"/4/1 -> 109 -batch flow coordinator CPut /Table/3/1/109/2/1 -> table: parent_id:106 unexposed_parent_schema_id:107 columns: nullable:true hidden:false inaccessible:false generated_as_identity_type:NOT_IDENTITY_COLUMN virtual:false pg_attribute_num:0 alter_column_type_in_progress:false system_column_kind:NONE > columns: nullable:true hidden:false inaccessible:false generated_as_identity_type:NOT_IDENTITY_COLUMN virtual:false pg_attribute_num:0 alter_column_type_in_progress:false system_column_kind:NONE > columns: nullable:false default_expr:"unique_rowid()" hidden:true inaccessible:false generated_as_identity_type:NOT_IDENTITY_COLUMN virtual:false pg_attribute_num:0 alter_column_type_in_progress:false system_column_kind:NONE > next_column_id:4 families: next_family_id:1 primary_index: interleave:<> partitioning: type:FORWARD created_explicitly:false encoding_type:1 sharded: disabled:false geo_config:<> predicate:"" use_delete_preserving_encoding:false constraint_id:1 > next_index_id:2 privileges: users: users: owner_proto:"root" version:2 > next_mutation_id:1 format_version:3 state:ADD offline_reason:"" view_query:"" is_materialized_view:false new_schema_change_job_id:0 drop_time:0 replacement_of: > audit_mode:DISABLED drop_job_id:0 create_query:"TABLE t.public.kv" create_as_of_time:<> temporary:false partition_all_by:false exclude_data_from_backup:false next_constraint_id:2 > +batch flow coordinator CPut /Table/3/1/109/2/1 -> table: parent_id:106 unexposed_parent_schema_id:107 columns: nullable:true hidden:false inaccessible:false generated_as_identity_type:NOT_IDENTITY_COLUMN virtual:false pg_attribute_num:0 alter_column_type_in_progress:false system_column_kind:NONE > columns: nullable:true hidden:false inaccessible:false generated_as_identity_type:NOT_IDENTITY_COLUMN virtual:false pg_attribute_num:0 alter_column_type_in_progress:false system_column_kind:NONE > columns: nullable:false default_expr:"unique_rowid()" hidden:true inaccessible:false generated_as_identity_type:NOT_IDENTITY_COLUMN virtual:false pg_attribute_num:0 alter_column_type_in_progress:false system_column_kind:NONE > next_column_id:4 families: next_family_id:1 primary_index: interleave:<> partitioning: type:FORWARD created_explicitly:false encoding_type:1 sharded: disabled:false geo_config:<> predicate:"" use_delete_preserving_encoding:false constraint_id:1 created_at_nanos:... > next_index_id:2 privileges: users: users: owner_proto:"root" version:2 > next_mutation_id:1 format_version:3 state:ADD offline_reason:"" view_query:"" is_materialized_view:false new_schema_change_job_id:0 drop_time:0 replacement_of: > audit_mode:DISABLED drop_job_id:0 create_query:"TABLE t.public.kv" create_as_of_time:<> temporary:false partition_all_by:false exclude_data_from_backup:false next_constraint_id:2 > sql query rows affected: 0 statement ok SET tracing = on,kv,results; UPDATE t.kv2 SET v = v + 2; SET tracing = off query TT -SELECT operation, message - FROM [SHOW KV TRACE FOR SESSION] -WHERE message NOT LIKE '%Z/%' - AND message NOT SIMILAR TO '%(PushTxn|ResolveIntent|SystemConfigSpan)%' - AND tag NOT LIKE '%intExec=%' - AND tag NOT LIKE '%scExec%' - AND tag NOT LIKE '%IndexBackfiller%' - AND operation != 'dist sender send' +$trace_query ---- colbatchscan Scan /Table/109/{1-2} colbatchscan fetched: /kv2/kv2_pkey/-9222809086901354496/k/v -> /1/2 @@ -147,8 +138,7 @@ statement ok SET tracing = on,kv,results; DELETE FROM t.kv2; SET tracing = off query TT -SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] - WHERE operation != 'dist sender send' +$trace_query ---- batch flow coordinator DelRange /Table/109/1 - /Table/109/2 batch flow coordinator fast path completed @@ -158,27 +148,17 @@ statement ok SET tracing = on,kv,results; DROP TABLE t.kv2; SET tracing = off query TT -SELECT operation, - regexp_replace(regexp_replace(regexp_replace(message, 'create_as_of_time:<[^>]+>', 'create_as_of_time:<...>'), 'drop_job_id:[1-9]\d*', 'drop_job_id:...'), 'drop_time:\d+', 'drop_time:...') as message - FROM [SHOW KV TRACE FOR SESSION] -WHERE message NOT LIKE '%Z/%' AND message NOT LIKE 'querying next range at%' - AND operation NOT LIKE 'kv.DistSender: sending partial batch%' -- order of partial batches is not deterministic - AND message NOT SIMILAR TO '%(PushTxn|ResolveIntent|SystemConfigSpan)%' - AND tag NOT LIKE '%intExec=%' - AND tag NOT LIKE '%scExec%' - AND tag NOT LIKE '%IndexBackfiller%' - AND operation != 'dist sender send' +$trace_query ---- batch flow coordinator Del /NamespaceTable/30/1/106/107/"kv2"/4/1 -batch flow coordinator Put /Table/3/1/109/2/1 -> table: parent_id:106 unexposed_parent_schema_id:107 columns: nullable:true hidden:false inaccessible:false generated_as_identity_type:NOT_IDENTITY_COLUMN virtual:false pg_attribute_num:0 alter_column_type_in_progress:false system_column_kind:NONE > columns: nullable:true hidden:false inaccessible:false generated_as_identity_type:NOT_IDENTITY_COLUMN virtual:false pg_attribute_num:0 alter_column_type_in_progress:false system_column_kind:NONE > columns: nullable:false default_expr:"unique_rowid()" hidden:true inaccessible:false generated_as_identity_type:NOT_IDENTITY_COLUMN virtual:false pg_attribute_num:0 alter_column_type_in_progress:false system_column_kind:NONE > next_column_id:4 families: next_family_id:1 primary_index: interleave:<> partitioning: type:FORWARD created_explicitly:false encoding_type:1 sharded: disabled:false geo_config:<> predicate:"" use_delete_preserving_encoding:false constraint_id:1 > next_index_id:2 privileges: users: users: owner_proto:"root" version:2 > next_mutation_id:1 format_version:3 state:DROP offline_reason:"" view_query:"" is_materialized_view:false new_schema_change_job_id:0 drop_time:... replacement_of: > audit_mode:DISABLED drop_job_id:0 create_query:"TABLE t.public.kv" create_as_of_time:<...> temporary:false partition_all_by:false exclude_data_from_backup:false next_constraint_id:2 > +batch flow coordinator Put /Table/3/1/109/2/1 -> table: parent_id:106 unexposed_parent_schema_id:107 columns: nullable:true hidden:false inaccessible:false generated_as_identity_type:NOT_IDENTITY_COLUMN virtual:false pg_attribute_num:0 alter_column_type_in_progress:false system_column_kind:NONE > columns: nullable:true hidden:false inaccessible:false generated_as_identity_type:NOT_IDENTITY_COLUMN virtual:false pg_attribute_num:0 alter_column_type_in_progress:false system_column_kind:NONE > columns: nullable:false default_expr:"unique_rowid()" hidden:true inaccessible:false generated_as_identity_type:NOT_IDENTITY_COLUMN virtual:false pg_attribute_num:0 alter_column_type_in_progress:false system_column_kind:NONE > next_column_id:4 families: next_family_id:1 primary_index: interleave:<> partitioning: type:FORWARD created_explicitly:false encoding_type:1 sharded: disabled:false geo_config:<> predicate:"" use_delete_preserving_encoding:false constraint_id:1 created_at_nanos:... > next_index_id:2 privileges: users: users: owner_proto:"root" version:2 > next_mutation_id:1 format_version:3 state:DROP offline_reason:"" view_query:"" is_materialized_view:false new_schema_change_job_id:0 drop_time:... replacement_of: > audit_mode:DISABLED drop_job_id:0 create_query:"TABLE t.public.kv" create_as_of_time:<...> temporary:false partition_all_by:false exclude_data_from_backup:false next_constraint_id:2 > sql query rows affected: 0 statement ok SET tracing = on,kv,results; DELETE FROM t.kv; SET tracing = off query TT -SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] - WHERE operation != 'dist sender send' AND operation != 'kv.DistSender: sending partial batch' +$trace_query ---- colbatchscan Scan /Table/108/{1-2} colbatchscan fetched: /kv/kv_pkey/1/v -> /2 @@ -191,38 +171,19 @@ statement ok SET tracing = on,kv,results; DROP INDEX t.kv@woo CASCADE; SET tracing = off query TT -SELECT operation, - regexp_replace(regexp_replace(message, 'create_as_of_time:<[^>]+>', 'create_as_of_time:<...>'), 'mutationJobs:<[^>]*>', 'mutationJobs:<...>') as message - FROM [SHOW KV TRACE FOR SESSION] -WHERE message NOT LIKE '%Z/%' AND message NOT LIKE 'querying next range at%' - AND operation NOT LIKE 'kv.DistSender: sending partial batch%' -- order of partial batches is not deterministic - /* since the transactions involved are multi-range, intent resolving is async and - sometimes there's still intents around */ - AND message NOT SIMILAR TO '%(PushTxn|ResolveIntent|SystemConfigSpan)%' - AND tag NOT LIKE '%intExec=%' - AND tag NOT LIKE '%scExec%' - AND tag NOT LIKE '%IndexBackfiller%' - AND operation != 'dist sender send' +$trace_query ---- -batch flow coordinator Put /Table/3/1/108/2/1 -> table: parent_id:106 unexposed_parent_schema_id:107 columns: nullable:false hidden:false inaccessible:false generated_as_identity_type:NOT_IDENTITY_COLUMN virtual:false pg_attribute_num:0 alter_column_type_in_progress:false system_column_kind:NONE > columns: nullable:true hidden:false inaccessible:false generated_as_identity_type:NOT_IDENTITY_COLUMN virtual:false pg_attribute_num:0 alter_column_type_in_progress:false system_column_kind:NONE > next_column_id:3 families: next_family_id:1 primary_index: interleave:<> partitioning: type:FORWARD created_explicitly:false encoding_type:1 sharded: disabled:false geo_config:<> predicate:"" use_delete_preserving_encoding:false constraint_id:1 > next_index_id:3 privileges: users: users: owner_proto:"root" version:2 > mutations: interleave:<> partitioning: type:FORWARD created_explicitly:true encoding_type:0 sharded: disabled:false geo_config:<> predicate:"" use_delete_preserving_encoding:false constraint_id:4 > state:DELETE_AND_WRITE_ONLY direction:DROP mutation_id:2 rollback:false > next_mutation_id:3 format_version:3 state:PUBLIC offline_reason:"" view_query:"" is_materialized_view:false mutationJobs:<...> new_schema_change_job_id:0 drop_time:0 replacement_of: > audit_mode:DISABLED drop_job_id:0 create_query:"" create_as_of_time:<...> temporary:false partition_all_by:false exclude_data_from_backup:false next_constraint_id:5 > +batch flow coordinator Put /Table/3/1/108/2/1 -> table: parent_id:106 unexposed_parent_schema_id:107 columns: nullable:false hidden:false inaccessible:false generated_as_identity_type:NOT_IDENTITY_COLUMN virtual:false pg_attribute_num:0 alter_column_type_in_progress:false system_column_kind:NONE > columns: nullable:true hidden:false inaccessible:false generated_as_identity_type:NOT_IDENTITY_COLUMN virtual:false pg_attribute_num:0 alter_column_type_in_progress:false system_column_kind:NONE > next_column_id:3 families: next_family_id:1 primary_index: interleave:<> partitioning: type:FORWARD created_explicitly:false encoding_type:1 sharded: disabled:false geo_config:<> predicate:"" use_delete_preserving_encoding:false constraint_id:1 created_at_nanos:... > next_index_id:3 privileges: users: users: owner_proto:"root" version:2 > mutations: interleave:<> partitioning: type:FORWARD created_explicitly:true encoding_type:0 sharded: disabled:false geo_config:<> predicate:"" use_delete_preserving_encoding:false constraint_id:4 created_at_nanos:... > state:DELETE_AND_WRITE_ONLY direction:DROP mutation_id:2 rollback:false > next_mutation_id:3 format_version:3 state:PUBLIC offline_reason:"" view_query:"" is_materialized_view:false mutationJobs:<...> new_schema_change_job_id:0 drop_time:0 replacement_of: > audit_mode:DISABLED drop_job_id:0 create_query:"" create_as_of_time:<...> temporary:false partition_all_by:false exclude_data_from_backup:false next_constraint_id:5 > sql query rows affected: 0 statement ok SET tracing = on,kv,results; DROP TABLE t.kv; SET tracing = off query TT -SELECT operation, regexp_replace(regexp_replace(regexp_replace(message, 'create_as_of_time:<[^>]+>', 'create_as_of_time:<...>'), 'job_id:[1-9]\d*', 'job_id:...', 'g'), 'drop_time:\d+', 'drop_time:...', 'g') as message - FROM [SHOW KV TRACE FOR SESSION] -WHERE message NOT LIKE '%Z/%' AND message NOT LIKE 'querying next range at%' - AND operation NOT LIKE 'kv.DistSender: sending partial batch%' -- order of partial batches is not deterministic - AND message NOT SIMILAR TO '%(PushTxn|ResolveIntent|SystemConfigSpan)%' - AND tag NOT LIKE '%intExec=%' - AND tag NOT LIKE '%scExec%' - AND tag NOT LIKE '%IndexBackfiller%' - AND operation != 'dist sender send' +$trace_query ---- batch flow coordinator Del /NamespaceTable/30/1/106/107/"kv"/4/1 -batch flow coordinator Put /Table/3/1/108/2/1 -> table: parent_id:106 unexposed_parent_schema_id:107 columns: nullable:false hidden:false inaccessible:false generated_as_identity_type:NOT_IDENTITY_COLUMN virtual:false pg_attribute_num:0 alter_column_type_in_progress:false system_column_kind:NONE > columns: nullable:true hidden:false inaccessible:false generated_as_identity_type:NOT_IDENTITY_COLUMN virtual:false pg_attribute_num:0 alter_column_type_in_progress:false system_column_kind:NONE > next_column_id:3 families: next_family_id:1 primary_index: interleave:<> partitioning: type:FORWARD created_explicitly:false encoding_type:1 sharded: disabled:false geo_config:<> predicate:"" use_delete_preserving_encoding:false constraint_id:1 > next_index_id:3 privileges: users: users: owner_proto:"root" version:2 > next_mutation_id:3 format_version:3 state:DROP offline_reason:"" view_query:"" is_materialized_view:false new_schema_change_job_id:0 drop_time:... replacement_of: > audit_mode:DISABLED drop_job_id:0 create_query:"" create_as_of_time:<...> temporary:false partition_all_by:false exclude_data_from_backup:false next_constraint_id:5 > +batch flow coordinator Put /Table/3/1/108/2/1 -> table: parent_id:106 unexposed_parent_schema_id:107 columns: nullable:false hidden:false inaccessible:false generated_as_identity_type:NOT_IDENTITY_COLUMN virtual:false pg_attribute_num:0 alter_column_type_in_progress:false system_column_kind:NONE > columns: nullable:true hidden:false inaccessible:false generated_as_identity_type:NOT_IDENTITY_COLUMN virtual:false pg_attribute_num:0 alter_column_type_in_progress:false system_column_kind:NONE > next_column_id:3 families: next_family_id:1 primary_index: interleave:<> partitioning: type:FORWARD created_explicitly:false encoding_type:1 sharded: disabled:false geo_config:<> predicate:"" use_delete_preserving_encoding:false constraint_id:1 created_at_nanos:... > next_index_id:3 privileges: users: users: owner_proto:"root" version:2 > next_mutation_id:3 format_version:3 state:DROP offline_reason:"" view_query:"" is_materialized_view:false new_schema_change_job_id:0 drop_time:... replacement_of: > audit_mode:DISABLED drop_job_id:0 create_query:"" create_as_of_time:<...> temporary:false partition_all_by:false exclude_data_from_backup:false next_constraint_id:5 > sql query rows affected: 0 # Check that session tracing does not inhibit the fast path for inserts & diff --git a/pkg/sql/opt/exec/execbuilder/testdata/sql_fn b/pkg/sql/opt/exec/execbuilder/testdata/sql_fn index 816714708bab..3e04e627d985 100644 --- a/pkg/sql/opt/exec/execbuilder/testdata/sql_fn +++ b/pkg/sql/opt/exec/execbuilder/testdata/sql_fn @@ -44,8 +44,7 @@ SELECT create_statement FROM [SHOW CREATE TABLE my_spatial_table] CREATE TABLE public.my_spatial_table ( k INT8 NOT NULL, geom1 GEOMETRY(POINT,4326) NULL, - CONSTRAINT my_spatial_table_pkey PRIMARY KEY (k ASC), - FAMILY "primary" (k, geom1) + CONSTRAINT my_spatial_table_pkey PRIMARY KEY (k ASC) ) query T @@ -60,8 +59,7 @@ CREATE TABLE public.my_spatial_table ( k INT8 NOT NULL, geom1 GEOMETRY(POINT,4326) NULL, geom2 GEOMETRY(POLYGON,4326) NULL, - CONSTRAINT my_spatial_table_pkey PRIMARY KEY (k ASC), - FAMILY "primary" (k, geom1, geom2) + CONSTRAINT my_spatial_table_pkey PRIMARY KEY (k ASC) ) query T @@ -77,8 +75,7 @@ CREATE TABLE public.my_spatial_table ( geom1 GEOMETRY(POINT,4326) NULL, geom2 GEOMETRY(POLYGON,4326) NULL, geom3 GEOMETRY(MULTIPOLYGON,4326) NULL, - CONSTRAINT my_spatial_table_pkey PRIMARY KEY (k ASC), - FAMILY "primary" (k, geom1, geom2, geom3) + CONSTRAINT my_spatial_table_pkey PRIMARY KEY (k ASC) ) query T @@ -95,8 +92,7 @@ CREATE TABLE public.my_spatial_table ( geom2 GEOMETRY(POLYGON,4326) NULL, geom3 GEOMETRY(MULTIPOLYGON,4326) NULL, geom4 GEOMETRY(LINESTRING,4326) NULL, - CONSTRAINT my_spatial_table_pkey PRIMARY KEY (k ASC), - FAMILY "primary" (k, geom1, geom2, geom3, geom4) + CONSTRAINT my_spatial_table_pkey PRIMARY KEY (k ASC) ) query T @@ -114,8 +110,7 @@ CREATE TABLE public.my_spatial_table ( geom3 GEOMETRY(MULTIPOLYGON,4326) NULL, geom4 GEOMETRY(LINESTRING,4326) NULL, geom5 GEOMETRY(MULTIPOINT,4326) NULL, - CONSTRAINT my_spatial_table_pkey PRIMARY KEY (k ASC), - FAMILY "primary" (k, geom1, geom2, geom3, geom4, geom5) + CONSTRAINT my_spatial_table_pkey PRIMARY KEY (k ASC) ) query T @@ -134,8 +129,7 @@ CREATE TABLE public.my_spatial_table ( geom4 GEOMETRY(LINESTRING,4326) NULL, geom5 GEOMETRY(MULTIPOINT,4326) NULL, geom6 GEOMETRY(MULTILINESTRING,4326) NULL, - CONSTRAINT my_spatial_table_pkey PRIMARY KEY (k ASC), - FAMILY "primary" (k, geom1, geom2, geom3, geom4, geom5, geom6) + CONSTRAINT my_spatial_table_pkey PRIMARY KEY (k ASC) ) query error relation "missing_table" does not exist @@ -236,8 +230,7 @@ CREATE TABLE public.my_spatial_table ( geom6 GEOMETRY(MULTILINESTRING,4326) NULL, geom7 GEOMETRY(POINT,4326) NULL, geom8 GEOMETRY(POINT,4326) NULL, - CONSTRAINT my_spatial_table_pkey PRIMARY KEY (k ASC), - FAMILY "primary" (k, geom1, geom2, geom3, geom4, geom5, geom6, geom7, geom8) + CONSTRAINT my_spatial_table_pkey PRIMARY KEY (k ASC) ) # In a WHERE clause. @@ -268,8 +261,7 @@ CREATE TABLE public.my_spatial_table ( geom8 GEOMETRY(POINT,4326) NULL, geom9 GEOMETRY(GEOMETRY,4326) NULL, geom10 GEOMETRY(GEOMETRYCOLLECTION) NULL, - CONSTRAINT my_spatial_table_pkey PRIMARY KEY (k ASC), - FAMILY "primary" (k, geom1, geom2, geom3, geom4, geom5, geom6, geom7, geom8, geom9, geom10) + CONSTRAINT my_spatial_table_pkey PRIMARY KEY (k ASC) ) # Regression test for #50296. Using AddGeometryColumn with NULL arguments must diff --git a/pkg/sql/schema_change_plan_node.go b/pkg/sql/schema_change_plan_node.go index a1013369113c..828a2956d801 100644 --- a/pkg/sql/schema_change_plan_node.go +++ b/pkg/sql/schema_change_plan_node.go @@ -185,6 +185,7 @@ func newSchemaChangerTxnRunDependencies( scdeps.NewNoopPeriodicProgressFlusher(), execCfg.IndexValidator, scdeps.NewPartitioner(execCfg.Settings, evalContext), + scdeps.NewConstantClock(evalContext.GetTxnTimestamp(time.Microsecond).Time), execCfg.DescMetadaUpdaterFactory, NewSchemaChangerEventLogger(txn, execCfg, 1), schemaChangerJobID, diff --git a/pkg/sql/schema_changer_test.go b/pkg/sql/schema_changer_test.go index 0717e45ad465..81223137faa4 100644 --- a/pkg/sql/schema_changer_test.go +++ b/pkg/sql/schema_changer_test.go @@ -2290,8 +2290,7 @@ INSERT INTO t.test VALUES (1, 1, 1), (2, 2, 2), (3, 3, 3); y INT8 NOT NULL, z INT8 NULL, CONSTRAINT test_pkey PRIMARY KEY (x ASC), - INDEX i (z ASC), - FAMILY "primary" (x, y, z) + INDEX i (z ASC) )` if create != expected { t.Fatalf("expected %s, found %s", expected, create) @@ -2312,8 +2311,7 @@ INSERT INTO t.test VALUES (1, 1, 1), (2, 2, 2), (3, 3, 3); z INT8 NULL, CONSTRAINT test_pkey PRIMARY KEY (y ASC), UNIQUE INDEX test_x_key (x ASC), - INDEX i (z ASC), - FAMILY "primary" (x, y, z) + INDEX i (z ASC) )` if create != expected { t.Fatalf("expected %s, found %s", expected, create) @@ -3473,8 +3471,7 @@ INSERT INTO t.test (k, v, length) VALUES (2, 3, 1); v INT8 NULL, length INT8 NOT NULL, CONSTRAINT "primary" PRIMARY KEY (k ASC), - INDEX v_idx (v ASC), - FAMILY "primary" (k, v, length) + INDEX v_idx (v ASC) )` if create != expect { t.Fatalf("got: %s\nexpected: %s", create, expect) diff --git a/pkg/sql/schemachanger/scbuild/testdata/alter_table b/pkg/sql/schemachanger/scbuild/testdata/alter_table index 3866d4da2c2b..69ea0b4a36fb 100644 --- a/pkg/sql/schemachanger/scbuild/testdata/alter_table +++ b/pkg/sql/schemachanger/scbuild/testdata/alter_table @@ -34,7 +34,7 @@ ALTER TABLE defaultdb.foo ADD COLUMN j INT - [[PrimaryIndex:{DescID: 104, IndexID: 1}, ABSENT], PUBLIC] details: indexId: 1 - keyColumnDirection: + keyColumnDirections: - ASC keyColumnIds: - 1 @@ -45,7 +45,7 @@ ALTER TABLE defaultdb.foo ADD COLUMN j INT - [[PrimaryIndex:{DescID: 104, IndexID: 2}, PUBLIC], ABSENT] details: indexId: 2 - keyColumnDirection: + keyColumnDirections: - ASC keyColumnIds: - 1 @@ -89,7 +89,7 @@ ALTER TABLE defaultdb.foo ADD COLUMN j INT DEFAULT 123 - [[PrimaryIndex:{DescID: 104, IndexID: 1}, ABSENT], PUBLIC] details: indexId: 1 - keyColumnDirection: + keyColumnDirections: - ASC keyColumnIds: - 1 @@ -100,7 +100,7 @@ ALTER TABLE defaultdb.foo ADD COLUMN j INT DEFAULT 123 - [[PrimaryIndex:{DescID: 104, IndexID: 2}, PUBLIC], ABSENT] details: indexId: 2 - keyColumnDirection: + keyColumnDirections: - ASC keyColumnIds: - 1 @@ -162,7 +162,7 @@ ALTER TABLE defaultdb.foo ADD COLUMN k INT DEFAULT 456; - [[PrimaryIndex:{DescID: 104, IndexID: 1}, ABSENT], PUBLIC] details: indexId: 1 - keyColumnDirection: + keyColumnDirections: - ASC keyColumnIds: - 1 @@ -173,7 +173,7 @@ ALTER TABLE defaultdb.foo ADD COLUMN k INT DEFAULT 456; - [[PrimaryIndex:{DescID: 104, IndexID: 2}, PUBLIC], ABSENT] details: indexId: 2 - keyColumnDirection: + keyColumnDirections: - ASC keyColumnIds: - 1 @@ -218,7 +218,7 @@ ALTER TABLE defaultdb.foo ADD COLUMN a INT AS (i+1) STORED - [[PrimaryIndex:{DescID: 104, IndexID: 1}, ABSENT], PUBLIC] details: indexId: 1 - keyColumnDirection: + keyColumnDirections: - ASC keyColumnIds: - 1 @@ -229,7 +229,7 @@ ALTER TABLE defaultdb.foo ADD COLUMN a INT AS (i+1) STORED - [[PrimaryIndex:{DescID: 104, IndexID: 2}, PUBLIC], ABSENT] details: indexId: 2 - keyColumnDirection: + keyColumnDirections: - ASC keyColumnIds: - 1 @@ -303,7 +303,7 @@ ALTER TABLE defaultdb.bar ADD COLUMN b INT; - [[PrimaryIndex:{DescID: 104, IndexID: 1}, ABSENT], PUBLIC] details: indexId: 1 - keyColumnDirection: + keyColumnDirections: - ASC keyColumnIds: - 1 @@ -314,7 +314,7 @@ ALTER TABLE defaultdb.bar ADD COLUMN b INT; - [[PrimaryIndex:{DescID: 104, IndexID: 2}, PUBLIC], ABSENT] details: indexId: 2 - keyColumnDirection: + keyColumnDirections: - ASC keyColumnIds: - 1 @@ -327,7 +327,7 @@ ALTER TABLE defaultdb.bar ADD COLUMN b INT; - [[PrimaryIndex:{DescID: 105, IndexID: 1}, ABSENT], PUBLIC] details: indexId: 1 - keyColumnDirection: + keyColumnDirections: - ASC keyColumnIds: - 2 @@ -340,7 +340,7 @@ ALTER TABLE defaultdb.bar ADD COLUMN b INT; - [[PrimaryIndex:{DescID: 105, IndexID: 2}, PUBLIC], ABSENT] details: indexId: 2 - keyColumnDirection: + keyColumnDirections: - ASC keyColumnIds: - 2 diff --git a/pkg/sql/schemachanger/scbuild/testdata/create_index b/pkg/sql/schemachanger/scbuild/testdata/create_index index 239c377d2e57..c948593be9e3 100644 --- a/pkg/sql/schemachanger/scbuild/testdata/create_index +++ b/pkg/sql/schemachanger/scbuild/testdata/create_index @@ -13,7 +13,7 @@ CREATE INDEX id1 ON defaultdb.t1(id, name) STORING (money) - [[SecondaryIndex:{DescID: 104, IndexID: 2}, PUBLIC], ABSENT] details: indexId: 2 - keyColumnDirection: + keyColumnDirections: - ASC - ASC keyColumnIds: @@ -38,7 +38,7 @@ CREATE INVERTED INDEX CONCURRENTLY id2 concurrently: true indexId: 2 inverted: true - keyColumnDirection: + keyColumnDirections: - ASC - ASC keyColumnIds: @@ -74,7 +74,7 @@ CREATE INDEX id3 - [[SecondaryIndex:{DescID: 104, IndexID: 2}, PUBLIC], ABSENT] details: indexId: 2 - keyColumnDirection: + keyColumnDirections: - ASC - ASC keyColumnIds: @@ -119,7 +119,7 @@ CREATE INDEX id4 - [[PrimaryIndex:{DescID: 104, IndexID: 1}, ABSENT], PUBLIC] details: indexId: 1 - keyColumnDirection: + keyColumnDirections: - ASC keyColumnIds: - 1 @@ -133,7 +133,7 @@ CREATE INDEX id4 - [[PrimaryIndex:{DescID: 104, IndexID: 2}, PUBLIC], ABSENT] details: indexId: 2 - keyColumnDirection: + keyColumnDirections: - ASC keyColumnIds: - 1 @@ -148,7 +148,7 @@ CREATE INDEX id4 - [[SecondaryIndex:{DescID: 104, IndexID: 3}, PUBLIC], ABSENT] details: indexId: 3 - keyColumnDirection: + keyColumnDirections: - ASC - ASC keyColumnIds: diff --git a/pkg/sql/schemachanger/scbuild/testdata/drop_database b/pkg/sql/schemachanger/scbuild/testdata/drop_database index c1c3dfada44a..b0a1331d0f9e 100644 --- a/pkg/sql/schemachanger/scbuild/testdata/drop_database +++ b/pkg/sql/schemachanger/scbuild/testdata/drop_database @@ -391,7 +391,7 @@ DROP DATABASE db1 CASCADE - [[PrimaryIndex:{DescID: 109, IndexID: 1}, ABSENT], PUBLIC] details: indexId: 1 - keyColumnDirection: + keyColumnDirections: - ASC keyColumnIds: - 1 @@ -405,7 +405,7 @@ DROP DATABASE db1 CASCADE - [[PrimaryIndex:{DescID: 110, IndexID: 1}, ABSENT], PUBLIC] details: indexId: 1 - keyColumnDirection: + keyColumnDirections: - ASC keyColumnIds: - 1 diff --git a/pkg/sql/schemachanger/scbuild/testdata/drop_schema b/pkg/sql/schemachanger/scbuild/testdata/drop_schema index c38ca7bb8fe8..ea121ef7b0b2 100644 --- a/pkg/sql/schemachanger/scbuild/testdata/drop_schema +++ b/pkg/sql/schemachanger/scbuild/testdata/drop_schema @@ -261,7 +261,7 @@ DROP SCHEMA defaultdb.SC1 CASCADE - [[PrimaryIndex:{DescID: 107, IndexID: 1}, ABSENT], PUBLIC] details: indexId: 1 - keyColumnDirection: + keyColumnDirections: - ASC keyColumnIds: - 1 diff --git a/pkg/sql/schemachanger/scbuild/testdata/drop_table b/pkg/sql/schemachanger/scbuild/testdata/drop_table index cfccdc13173f..3fd61d716ea4 100644 --- a/pkg/sql/schemachanger/scbuild/testdata/drop_table +++ b/pkg/sql/schemachanger/scbuild/testdata/drop_table @@ -317,7 +317,7 @@ DROP TABLE defaultdb.shipments CASCADE; - [[PrimaryIndex:{DescID: 109, IndexID: 1}, ABSENT], PUBLIC] details: indexId: 1 - keyColumnDirection: + keyColumnDirections: - ASC keyColumnIds: - 1 diff --git a/pkg/sql/schemachanger/scdeps/exec_deps.go b/pkg/sql/schemachanger/scdeps/exec_deps.go index d5a9118bc768..067404b9f4b9 100644 --- a/pkg/sql/schemachanger/scdeps/exec_deps.go +++ b/pkg/sql/schemachanger/scdeps/exec_deps.go @@ -56,6 +56,7 @@ func NewExecutorDependencies( backfillFlusher scexec.PeriodicProgressFlusher, indexValidator scexec.IndexValidator, partitioner scmutationexec.Partitioner, + clock scmutationexec.Clock, commentUpdaterFactory scexec.DescriptorMetadataUpdaterFactory, eventLogger scexec.EventLogger, schemaChangerJobID jobspb.JobID, @@ -79,6 +80,7 @@ func NewExecutorDependencies( partitioner: partitioner, user: user, sessionData: sessionData, + clock: clock, } } @@ -314,6 +316,7 @@ func (d *txnDeps) SetResumeSpans( type execDeps struct { txnDeps partitioner scmutationexec.Partitioner + clock scmutationexec.Clock commentUpdaterFactory scexec.DescriptorMetadataUpdaterFactory backfiller scexec.Backfiller backfillTracker scexec.BackfillTracker @@ -323,6 +326,10 @@ type execDeps struct { sessionData *sessiondata.SessionData } +func (d *execDeps) Clock() scmutationexec.Clock { + return d.clock +} + var _ scexec.Dependencies = (*execDeps)(nil) // Catalog implements the scexec.Dependencies interface. @@ -439,3 +446,16 @@ func (n noopPeriodicProgressFlusher) StartPeriodicUpdates( ) (stop func() error) { return func() error { return nil } } + +type constantClock struct { + ts time.Time +} + +// NewConstantClock constructs a new clock for use in execution. +func NewConstantClock(ts time.Time) scmutationexec.Clock { + return constantClock{ts: ts} +} + +func (c constantClock) ApproximateTime() time.Time { + return c.ts +} diff --git a/pkg/sql/schemachanger/scdeps/run_deps.go b/pkg/sql/schemachanger/scdeps/run_deps.go index 47b8eed2fda3..3deb9e297d45 100644 --- a/pkg/sql/schemachanger/scdeps/run_deps.go +++ b/pkg/sql/schemachanger/scdeps/run_deps.go @@ -23,6 +23,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scrun" "github.com/cockroachdb/cockroach/pkg/sql/sessiondata" "github.com/cockroachdb/cockroach/pkg/sql/sqlutil" + "github.com/cockroachdb/cockroach/pkg/util/timeutil" ) // NewJobRunDependencies returns an scrun.JobRunDependencies implementation built from the @@ -119,7 +120,8 @@ func (d *jobExecutionDeps) WithTxnInJob(ctx context.Context, fn scrun.JobTxnFunc periodicProgressFlusher: newPeriodicProgressFlusher(d.settings), statements: d.statements, partitioner: d.partitioner, - user: d.job.Payload().UsernameProto.Decode(), + user: pl.UsernameProto.Decode(), + clock: NewConstantClock(timeutil.FromUnixMicros(pl.StartedMicros)), commentUpdaterFactory: d.commentUpdaterFactory, sessionData: d.sessionData, }) diff --git a/pkg/sql/schemachanger/scdeps/sctestdeps/config.go b/pkg/sql/schemachanger/scdeps/sctestdeps/config.go index 3a03820c052e..9f7e0048a1d1 100644 --- a/pkg/sql/schemachanger/scdeps/sctestdeps/config.go +++ b/pkg/sql/schemachanger/scdeps/sctestdeps/config.go @@ -11,8 +11,11 @@ package sctestdeps import ( + "time" + "github.com/cockroachdb/cockroach/pkg/sql/catalog" "github.com/cockroachdb/cockroach/pkg/sql/catalog/nstree" + "github.com/cockroachdb/cockroach/pkg/sql/catalog/tabledesc" "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scexec" "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scrun" "github.com/cockroachdb/cockroach/pkg/sql/sessiondata" @@ -40,9 +43,19 @@ func WithNamespace(c nstree.Catalog) Option { } // WithDescriptors sets the TestState descriptors to the provided value. +// This function also scrubs any volatile timestamps from the descriptor. func WithDescriptors(c nstree.Catalog) Option { return optionFunc(func(state *TestState) { _ = c.ForEachDescriptorEntry(func(desc catalog.Descriptor) error { + if table, isTable := desc.(catalog.TableDescriptor); isTable { + mut := table.NewBuilder().BuildExistingMutable().(*tabledesc.Mutable) + for _, idx := range mut.AllIndexes() { + if !idx.CreatedAt().IsZero() { + idx.IndexDesc().CreatedAtNanos = defaultOverriddenCreatedAt.UnixNano() + } + } + desc = mut.ImmutableCopy() + } state.catalog.UpsertDescriptorEntry(desc) return nil }) @@ -95,10 +108,22 @@ func WithBackfiller(backfiller scexec.Backfiller) Option { }) } +var ( + // defaultOverriddenCreatedAt is used to populate the CreatedAt timestamp for + // all descriptors injected into the catalog. We inject this to make the + // tests deterministic. + defaultOverriddenCreatedAt = time.Date(2022, time.January, 1, 0, 0, 0, 0, time.UTC) + + // defaultCreatedAt is used to populated the CreatedAt timestamp for all newly + // created indexes. + defaultCreatedAt = defaultOverriddenCreatedAt.Add(time.Hour) +) + var defaultOptions = []Option{ optionFunc(func(state *TestState) { state.backfillTracker = &testBackfillTracker{deps: state} state.backfiller = &testBackfiller{s: state} state.indexSpanSplitter = &indexSpanSplitter{} + state.approximateTimestamp = defaultCreatedAt }), } diff --git a/pkg/sql/schemachanger/scdeps/sctestdeps/test_deps.go b/pkg/sql/schemachanger/scdeps/sctestdeps/test_deps.go index cd9fc7fcfd06..ac904a9552e9 100644 --- a/pkg/sql/schemachanger/scdeps/sctestdeps/test_deps.go +++ b/pkg/sql/schemachanger/scdeps/sctestdeps/test_deps.go @@ -13,6 +13,7 @@ package sctestdeps import ( "context" "sort" + "time" "github.com/cockroachdb/cockroach/pkg/clusterversion" "github.com/cockroachdb/cockroach/pkg/jobs" @@ -455,6 +456,16 @@ func (s *TestState) descBuilderWithSynthetic(id descpb.ID) catalog.DescriptorBui var _ scexec.Dependencies = (*TestState)(nil) +// Clock is part of the scexec.Dependencies interface. +func (s *TestState) Clock() scmutationexec.Clock { + return s +} + +// ApproximateTime is part of the scmutationexec.Clock interface. +func (s *TestState) ApproximateTime() time.Time { + return s.approximateTimestamp +} + // Catalog implements the scexec.Dependencies interface. func (s *TestState) Catalog() scexec.Catalog { return s diff --git a/pkg/sql/schemachanger/scdeps/sctestdeps/test_state.go b/pkg/sql/schemachanger/scdeps/sctestdeps/test_state.go index 58645b5eb93a..66d15258a845 100644 --- a/pkg/sql/schemachanger/scdeps/sctestdeps/test_state.go +++ b/pkg/sql/schemachanger/scdeps/sctestdeps/test_state.go @@ -14,6 +14,7 @@ import ( "context" "fmt" "strings" + "time" "github.com/cockroachdb/cockroach/pkg/jobs" "github.com/cockroachdb/cockroach/pkg/jobs/jobspb" @@ -50,6 +51,10 @@ type TestState struct { backfiller scexec.Backfiller indexSpanSplitter scexec.IndexSpanSplitter backfillTracker scexec.BackfillTracker + + // approximateTimestamp is used to populate approximate timestamps in + // descriptors. + approximateTimestamp time.Time } // NewTestDependencies returns a TestState populated with the provided options. diff --git a/pkg/sql/schemachanger/scexec/BUILD.bazel b/pkg/sql/schemachanger/scexec/BUILD.bazel index e0daff70f0d1..5d511fc1c1f5 100644 --- a/pkg/sql/schemachanger/scexec/BUILD.bazel +++ b/pkg/sql/schemachanger/scexec/BUILD.bazel @@ -85,6 +85,7 @@ go_test( "//pkg/util/log", "//pkg/util/log/eventpb", "//pkg/util/randutil", + "//pkg/util/timeutil", "@com_github_golang_mock//gomock", "@com_github_stretchr_testify//require", ], diff --git a/pkg/sql/schemachanger/scexec/dependencies.go b/pkg/sql/schemachanger/scexec/dependencies.go index 9dccfc3c1a49..df50c7e0c305 100644 --- a/pkg/sql/schemachanger/scexec/dependencies.go +++ b/pkg/sql/schemachanger/scexec/dependencies.go @@ -31,6 +31,7 @@ import ( type Dependencies interface { Catalog() Catalog Partitioner() scmutationexec.Partitioner + Clock() scmutationexec.Clock TransactionalJobRegistry() TransactionalJobRegistry IndexBackfiller() Backfiller BackfillProgressTracker() BackfillTracker diff --git a/pkg/sql/schemachanger/scexec/exec_mutation.go b/pkg/sql/schemachanger/scexec/exec_mutation.go index bc6ec158f357..8381de829972 100644 --- a/pkg/sql/schemachanger/scexec/exec_mutation.go +++ b/pkg/sql/schemachanger/scexec/exec_mutation.go @@ -34,7 +34,7 @@ import ( func executeDescriptorMutationOps(ctx context.Context, deps Dependencies, ops []scop.Op) error { mvs := newMutationVisitorState(deps.Catalog()) - v := scmutationexec.NewMutationVisitor(deps.Catalog(), mvs, deps.Partitioner()) + v := scmutationexec.NewMutationVisitor(deps.Catalog(), mvs, deps.Partitioner(), deps.Clock()) for _, op := range ops { if err := op.(scop.MutationOp).Visit(ctx, v); err != nil { return err diff --git a/pkg/sql/schemachanger/scexec/executor_external_test.go b/pkg/sql/schemachanger/scexec/executor_external_test.go index 7c879859cc42..cb231d679f45 100644 --- a/pkg/sql/schemachanger/scexec/executor_external_test.go +++ b/pkg/sql/schemachanger/scexec/executor_external_test.go @@ -43,6 +43,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/testutils/testcluster" "github.com/cockroachdb/cockroach/pkg/util/leaktest" "github.com/cockroachdb/cockroach/pkg/util/log/eventpb" + "github.com/cockroachdb/cockroach/pkg/util/timeutil" "github.com/stretchr/testify/require" ) @@ -69,8 +70,9 @@ func (ti testInfra) newExecDeps( noopBackfiller{}, /* backfiller */ scdeps.NewNoOpBackfillTracker(ti.lm.Codec()), scdeps.NewNoopPeriodicProgressFlusher(), - noopIndexValidator{}, /* indexValidator */ - noopPartitioner{}, /* partitioner */ + noopIndexValidator{}, /* indexValidator */ + noopPartitioner{}, /* partitioner */ + scdeps.NewConstantClock(timeutil.Now()), noopMetadataUpdaterFactory{}, /* commentUpdaterFactory*/ noopEventLogger{}, /* eventLogger */ 1, /* schemaChangerJobID */ diff --git a/pkg/sql/schemachanger/scexec/mocks_generated_test.go b/pkg/sql/schemachanger/scexec/mocks_generated_test.go index 0a7e9f0acc46..da5e699d16e0 100644 --- a/pkg/sql/schemachanger/scexec/mocks_generated_test.go +++ b/pkg/sql/schemachanger/scexec/mocks_generated_test.go @@ -173,6 +173,20 @@ func (mr *MockDependenciesMockRecorder) Catalog() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Catalog", reflect.TypeOf((*MockDependencies)(nil).Catalog)) } +// Clock mocks base method. +func (m *MockDependencies) Clock() scmutationexec.Clock { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Clock") + ret0, _ := ret[0].(scmutationexec.Clock) + return ret0 +} + +// Clock indicates an expected call of Clock. +func (mr *MockDependenciesMockRecorder) Clock() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Clock", reflect.TypeOf((*MockDependencies)(nil).Clock)) +} + // DescriptorMetadataUpdater mocks base method. func (m *MockDependencies) DescriptorMetadataUpdater(arg0 context.Context) scexec.DescriptorMetadataUpdater { m.ctrl.T.Helper() diff --git a/pkg/sql/schemachanger/scexec/scmutationexec/scmutationexec.go b/pkg/sql/schemachanger/scexec/scmutationexec/scmutationexec.go index acaccacb76f1..147600460cec 100644 --- a/pkg/sql/schemachanger/scexec/scmutationexec/scmutationexec.go +++ b/pkg/sql/schemachanger/scexec/scmutationexec/scmutationexec.go @@ -13,6 +13,7 @@ package scmutationexec import ( "context" "sort" + "time" "github.com/cockroachdb/cockroach/pkg/jobs/jobspb" "github.com/cockroachdb/cockroach/pkg/keys" @@ -32,6 +33,15 @@ import ( "github.com/cockroachdb/redact" ) +// Clock is used to provide a timestamp to track loosely when something +// happened. It can be used for things like observability and telemetry and +// not for anything involving correctness. +type Clock interface { + + // ApproximateTime provides a present timestamp. + ApproximateTime() time.Time +} + // CatalogReader describes catalog read operations as required by the mutation // visitor. type CatalogReader interface { @@ -115,19 +125,21 @@ type MutationVisitorStateUpdater interface { // NewMutationVisitor creates a new scop.MutationVisitor. func NewMutationVisitor( - cr CatalogReader, s MutationVisitorStateUpdater, p Partitioner, + cr CatalogReader, s MutationVisitorStateUpdater, p Partitioner, clock Clock, ) scop.MutationVisitor { return &visitor{ - cr: cr, - s: s, - p: p, + cr: cr, + s: s, + p: p, + clock: clock, } } type visitor struct { - cr CatalogReader - s MutationVisitorStateUpdater - p Partitioner + clock Clock + cr CatalogReader + s MutationVisitorStateUpdater + p Partitioner } func (m *visitor) RemoveJobReference(ctx context.Context, reference scop.RemoveJobReference) error { diff --git a/pkg/sql/schemachanger/scpb/elements.proto b/pkg/sql/schemachanger/scpb/elements.proto index e51a4a5779b4..7edab78774be 100644 --- a/pkg/sql/schemachanger/scpb/elements.proto +++ b/pkg/sql/schemachanger/scpb/elements.proto @@ -92,9 +92,9 @@ message PrimaryIndex { uint32 index_id = 2 [(gogoproto.customname) = "IndexID", (gogoproto.casttype) = "github.com/cockroachdb/cockroach/pkg/sql/sem/catid.IndexID"]; bool unique = 3; repeated uint32 key_column_ids = 4 [(gogoproto.customname) = "KeyColumnIDs", (gogoproto.casttype) = "github.com/cockroachdb/cockroach/pkg/sql/sem/catid.ColumnID"]; - repeated Direction key_column_direction = 5 [(gogoproto.customname) = "KeyColumnDirections"]; + repeated Direction key_column_directions = 5; repeated uint32 key_suffix_column_ids = 6 [(gogoproto.customname) = "KeySuffixColumnIDs", (gogoproto.casttype) = "github.com/cockroachdb/cockroach/pkg/sql/sem/catid.ColumnID"]; - cockroach.sql.catalog.catpb.ShardedDescriptor sharded_descriptor = 7 [(gogoproto.customname) = "ShardedDescriptor"]; + cockroach.sql.catalog.catpb.ShardedDescriptor sharded_descriptor = 7; repeated uint32 storing_column_ids = 8 [(gogoproto.customname) = "StoringColumnIDs", (gogoproto.casttype) = "github.com/cockroachdb/cockroach/pkg/sql/sem/catid.ColumnID"]; repeated uint32 composite_column_ids = 9 [(gogoproto.customname) = "CompositeColumnIDs", (gogoproto.casttype) = "github.com/cockroachdb/cockroach/pkg/sql/sem/catid.ColumnID"]; bool inverted = 10; @@ -116,9 +116,9 @@ message SecondaryIndex { uint32 index_id = 2 [(gogoproto.customname) = "IndexID", (gogoproto.casttype) = "github.com/cockroachdb/cockroach/pkg/sql/sem/catid.IndexID"]; bool unique = 3; repeated uint32 key_column_ids = 4 [(gogoproto.customname) = "KeyColumnIDs", (gogoproto.casttype) = "github.com/cockroachdb/cockroach/pkg/sql/sem/catid.ColumnID"]; - repeated Direction key_column_direction = 5 [(gogoproto.customname) = "KeyColumnDirections"]; + repeated Direction key_column_directions = 5; repeated uint32 key_suffix_column_ids = 6 [(gogoproto.customname) = "KeySuffixColumnIDs", (gogoproto.casttype) = "github.com/cockroachdb/cockroach/pkg/sql/sem/catid.ColumnID"]; - cockroach.sql.catalog.catpb.ShardedDescriptor sharded_descriptor = 7 [(gogoproto.customname) = "ShardedDescriptor"]; + cockroach.sql.catalog.catpb.ShardedDescriptor sharded_descriptor = 7; repeated uint32 storing_column_ids = 8 [(gogoproto.customname) = "StoringColumnIDs", (gogoproto.casttype) = "github.com/cockroachdb/cockroach/pkg/sql/sem/catid.ColumnID"]; repeated uint32 composite_column_ids = 9 [(gogoproto.customname) = "CompositeColumnIDs", (gogoproto.casttype) = "github.com/cockroachdb/cockroach/pkg/sql/sem/catid.ColumnID"]; bool inverted = 10; diff --git a/pkg/sql/schemachanger/testdata/alter_table_add_column b/pkg/sql/schemachanger/testdata/alter_table_add_column index 6ec1ff32ad35..5481e66e5420 100644 --- a/pkg/sql/schemachanger/testdata/alter_table_add_column +++ b/pkg/sql/schemachanger/testdata/alter_table_add_column @@ -166,6 +166,7 @@ upsert descriptor #106 - constraintId: 2 - createdExplicitly: true + constraintId: 1 + + createdAtNanos: "1640995200000000000" encodingType: 1 foreignKey: {} geoConfig: {} @@ -190,6 +191,7 @@ upsert descriptor #106 parentId: 104 primaryIndex: - constraintId: 1 + - createdAtNanos: "1640995200000000000" + constraintId: 2 + createdExplicitly: true encodingType: 1 @@ -245,6 +247,7 @@ upsert descriptor #106 - - direction: DROP - index: - constraintId: 1 + - createdAtNanos: "1640995200000000000" - encodingType: 1 - foreignKey: {} - geoConfig: {} diff --git a/pkg/sql/show_create_clauses.go b/pkg/sql/show_create_clauses.go index 776326a127f0..35a188398e5f 100644 --- a/pkg/sql/show_create_clauses.go +++ b/pkg/sql/show_create_clauses.go @@ -22,6 +22,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/catalog/descpb" "github.com/cockroachdb/cockroach/pkg/sql/catalog/multiregion" "github.com/cockroachdb/cockroach/pkg/sql/catalog/schemaexpr" + "github.com/cockroachdb/cockroach/pkg/sql/catalog/tabledesc" "github.com/cockroachdb/cockroach/pkg/sql/parser" "github.com/cockroachdb/cockroach/pkg/sql/rowenc" "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" @@ -396,7 +397,13 @@ func ShowCreateSequence( // showFamilyClause creates the FAMILY clauses for a CREATE statement, writing them // to tree.FmtCtx f func showFamilyClause(desc catalog.TableDescriptor, f *tree.FmtCtx) { - for _, fam := range desc.GetFamilies() { + // Do not show family in SHOW CREATE TABLE if there is only one and + // it is named "primary". + families := desc.GetFamilies() + if len(families) == 1 && families[0].Name == tabledesc.FamilyPrimaryName { + return + } + for _, fam := range families { activeColumnNames := make([]string, 0, len(fam.ColumnNames)) for i, colID := range fam.ColumnIDs { if col, _ := desc.FindColumnWithID(colID); col != nil && col.Public() { diff --git a/pkg/sql/show_test.go b/pkg/sql/show_test.go index 432e738acb15..44cc38b200ac 100644 --- a/pkg/sql/show_test.go +++ b/pkg/sql/show_test.go @@ -108,8 +108,7 @@ func TestShowCreateTable(t *testing.T) { )`, Expect: `CREATE TABLE public.%[1]s ( i INT8 NOT NULL, - CONSTRAINT %[1]s_pkey PRIMARY KEY (i ASC), - FAMILY "primary" (i) + CONSTRAINT %[1]s_pkey PRIMARY KEY (i ASC) )`, }, { @@ -136,13 +135,11 @@ func TestShowCreateTable(t *testing.T) { { CreateStatement: `CREATE TABLE %s ( "te""st" INT8 NOT NULL, - CONSTRAINT "pri""mary" PRIMARY KEY ("te""st" ASC), - FAMILY "primary" ("te""st") + CONSTRAINT "pri""mary" PRIMARY KEY ("te""st" ASC) )`, Expect: `CREATE TABLE public.%[1]s ( "te""st" INT8 NOT NULL, - CONSTRAINT "pri""mary" PRIMARY KEY ("te""st" ASC), - FAMILY "primary" ("te""st") + CONSTRAINT "pri""mary" PRIMARY KEY ("te""st" ASC) )`, }, { @@ -156,8 +153,7 @@ func TestShowCreateTable(t *testing.T) { b INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), CONSTRAINT %[1]s_pkey PRIMARY KEY (rowid ASC), - INDEX c (a ASC, b DESC), - FAMILY "primary" (a, b, rowid) + INDEX c (a ASC, b DESC) )`, }, @@ -168,8 +164,7 @@ func TestShowCreateTable(t *testing.T) { Expect: `CREATE TABLE public.%[1]s ( pk INT8 NOT NULL, crdb_internal_expiration TIMESTAMPTZ NOT VISIBLE NOT NULL DEFAULT current_timestamp():::TIMESTAMPTZ + '00:10:00':::INTERVAL ON UPDATE current_timestamp():::TIMESTAMPTZ + '00:10:00':::INTERVAL, - CONSTRAINT %[1]s_pkey PRIMARY KEY (pk ASC), - FAMILY "primary" (pk, crdb_internal_expiration) + CONSTRAINT %[1]s_pkey PRIMARY KEY (pk ASC) ) WITH (ttl = 'on', ttl_automatic_column = 'on', ttl_expire_after = '00:10:00':::INTERVAL)`, }, // Check that FK dependencies inside the current database @@ -188,8 +183,7 @@ func TestShowCreateTable(t *testing.T) { rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), CONSTRAINT %[1]s_pkey PRIMARY KEY (rowid ASC), CONSTRAINT %[1]s_i_j_fkey FOREIGN KEY (i, j) REFERENCES public.items(a, b), - CONSTRAINT %[1]s_k_fkey FOREIGN KEY (k) REFERENCES public.items(c), - FAMILY "primary" (i, j, k, rowid) + CONSTRAINT %[1]s_k_fkey FOREIGN KEY (k) REFERENCES public.items(c) )`, }, // Check that FK dependencies using MATCH FULL on a non-composite key still @@ -208,8 +202,7 @@ func TestShowCreateTable(t *testing.T) { rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), CONSTRAINT %[1]s_pkey PRIMARY KEY (rowid ASC), CONSTRAINT %[1]s_i_j_fkey FOREIGN KEY (i, j) REFERENCES public.items(a, b) MATCH FULL, - CONSTRAINT %[1]s_k_fkey FOREIGN KEY (k) REFERENCES public.items(c) MATCH FULL, - FAMILY "primary" (i, j, k, rowid) + CONSTRAINT %[1]s_k_fkey FOREIGN KEY (k) REFERENCES public.items(c) MATCH FULL )`, }, // Check that FK dependencies outside of the current database @@ -223,8 +216,7 @@ func TestShowCreateTable(t *testing.T) { x INT8 NULL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), CONSTRAINT %[1]s_pkey PRIMARY KEY (rowid ASC), - CONSTRAINT fk_ref FOREIGN KEY (x) REFERENCES o.public.foo(x), - FAMILY "primary" (x, rowid) + CONSTRAINT fk_ref FOREIGN KEY (x) REFERENCES o.public.foo(x) )`, }, // Check that FK dependencies using SET NULL or SET DEFAULT @@ -243,8 +235,7 @@ func TestShowCreateTable(t *testing.T) { rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), CONSTRAINT %[1]s_pkey PRIMARY KEY (rowid ASC), CONSTRAINT %[1]s_i_j_fkey FOREIGN KEY (i, j) REFERENCES public.items(a, b) ON DELETE SET DEFAULT, - CONSTRAINT %[1]s_k_fkey FOREIGN KEY (k) REFERENCES public.items(c) ON DELETE SET NULL, - FAMILY "primary" (i, j, k, rowid) + CONSTRAINT %[1]s_k_fkey FOREIGN KEY (k) REFERENCES public.items(c) ON DELETE SET NULL )`, }, // Check that FK dependencies using MATCH FULL and MATCH SIMPLE are both @@ -266,8 +257,7 @@ func TestShowCreateTable(t *testing.T) { rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), CONSTRAINT %[1]s_pkey PRIMARY KEY (rowid ASC), CONSTRAINT %[1]s_i_j_fkey FOREIGN KEY (i, j) REFERENCES public.items(a, b) ON DELETE SET DEFAULT, - CONSTRAINT %[1]s_k_l_fkey FOREIGN KEY (k, l) REFERENCES public.items(a, b) MATCH FULL ON UPDATE CASCADE, - FAMILY "primary" (i, j, k, l, rowid) + CONSTRAINT %[1]s_k_l_fkey FOREIGN KEY (k, l) REFERENCES public.items(a, b) MATCH FULL ON UPDATE CASCADE )`, }, // Check hash sharded indexes are round trippable. @@ -281,8 +271,7 @@ func TestShowCreateTable(t *testing.T) { crdb_internal_a_shard_8 INT4 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(a)), 8:::INT8)) VIRTUAL, rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), CONSTRAINT %[1]s_pkey PRIMARY KEY (rowid ASC), - INDEX %[1]s_a_idx (a ASC) USING HASH WITH (bucket_count=8), - FAMILY "primary" (a, rowid) + INDEX %[1]s_a_idx (a ASC) USING HASH WITH (bucket_count=8) )`, }, } diff --git a/pkg/sql/tablewriter.go b/pkg/sql/tablewriter.go index a6b2e1b5e6ef..919476f6c019 100644 --- a/pkg/sql/tablewriter.go +++ b/pkg/sql/tablewriter.go @@ -191,19 +191,8 @@ func (tb *tableWriterBase) flushAndStartNewBatch(ctx context.Context) error { if err := tb.txn.Run(ctx, tb.b); err != nil { return row.ConvertBatchError(ctx, tb.desc, tb.b) } - // Do admission control for response processing. This is the shared write - // path for most SQL mutations. - responseAdmissionQ := tb.txn.DB().SQLKVResponseAdmissionQ - if responseAdmissionQ != nil { - requestAdmissionHeader := tb.txn.AdmissionHeader() - responseAdmission := admission.WorkInfo{ - TenantID: roachpb.SystemTenantID, - Priority: admission.WorkPriority(requestAdmissionHeader.Priority), - CreateTime: requestAdmissionHeader.CreateTime, - } - if _, err := responseAdmissionQ.Admit(ctx, responseAdmission); err != nil { - return err - } + if err := tb.tryDoResponseAdmission(ctx); err != nil { + return err } tb.initNewBatch() tb.rowsWritten += int64(tb.currentBatchSize) @@ -239,6 +228,24 @@ func (tb *tableWriterBase) finalize(ctx context.Context) (err error) { if err != nil { return row.ConvertBatchError(ctx, tb.desc, tb.b) } + return tb.tryDoResponseAdmission(ctx) +} + +func (tb *tableWriterBase) tryDoResponseAdmission(ctx context.Context) error { + // Do admission control for response processing. This is the shared write + // path for most SQL mutations. + responseAdmissionQ := tb.txn.DB().SQLKVResponseAdmissionQ + if responseAdmissionQ != nil { + requestAdmissionHeader := tb.txn.AdmissionHeader() + responseAdmission := admission.WorkInfo{ + TenantID: roachpb.SystemTenantID, + Priority: admission.WorkPriority(requestAdmissionHeader.Priority), + CreateTime: requestAdmissionHeader.CreateTime, + } + if _, err := responseAdmissionQ.Admit(ctx, responseAdmission); err != nil { + return err + } + } return nil }