Skip to content

Commit

Permalink
opt: name primary indexes <table_name>_pkey in test catalog
Browse files Browse the repository at this point in the history
This commit updates the test catalog to name primary keys in the form
`<table_name>_pkey`. This makes primary index names consistent with the
real catalog and Postgres. See cockroachdb#70604.

Release note: None
  • Loading branch information
mgartner committed Oct 21, 2021
1 parent 83b0c98 commit 7778f73
Show file tree
Hide file tree
Showing 33 changed files with 183 additions and 183 deletions.
4 changes: 2 additions & 2 deletions pkg/sql/opt/memo/testdata/logprops/upsert
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ project
├── prune: (1-3)
└── insert abc
├── columns: a:1(int!null) b:2(int) c:3(int) rowid:4(int!null)
├── arbiter indexes: primary secondary secondary
├── arbiter indexes: abc_pkey secondary secondary
├── insert-mapping:
│ ├── x:7 => a:1
│ ├── y:8 => b:2
Expand Down Expand Up @@ -386,7 +386,7 @@ project
├── prune: (21)
├── upsert abc
│ ├── columns: a:1(int!null) b:2(int) c:3(int) rowid:4(int!null)
│ ├── arbiter indexes: primary
│ ├── arbiter indexes: abc_pkey
│ ├── canary column: rowid:14(int)
│ ├── fetch columns: a:11(int) b:12(int) c:13(int) rowid:14(int)
│ ├── insert-mapping:
Expand Down
10 changes: 5 additions & 5 deletions pkg/sql/opt/memo/testdata/stats/join
Original file line number Diff line number Diff line change
Expand Up @@ -1353,7 +1353,7 @@ ALTER TABLE def INJECT STATISTICS '[
expr format=show-all colstat=7 colstat=8 colstat=(7, 8) colstat=1 colstat=2 colstat=3 colstat=(1, 2, 3)
(MakeLookupJoin
(Scan [ (Table "abc") (Cols "a,b,c") ])
[ (JoinType "inner-join") (Table "def") (Index "def@primary") (KeyCols "a,b") (Cols "a,b,c,d,f,e") ]
[ (JoinType "inner-join") (Table "def") (Index "def@def_pkey") (KeyCols "a,b") (Cols "a,b,c,d,f,e") ]
[ ]
)
----
Expand Down Expand Up @@ -1381,7 +1381,7 @@ inner-join (lookup t.public.def)
expr format=show-all colstat=7 colstat=8 colstat=(7, 8) colstat=1 colstat=2 colstat=3 colstat=(1, 2, 3)
(MakeLookupJoin
(Scan [ (Table "abc") (Cols "a,b,c") ])
[ (JoinType "semi-join") (Table "def") (Index "def@primary") (KeyCols "a,b") (Cols "a,b,c,d,e") ]
[ (JoinType "semi-join") (Table "def") (Index "def@def_pkey") (KeyCols "a,b") (Cols "a,b,c,d,e") ]
[ ]
)
----
Expand All @@ -1406,7 +1406,7 @@ semi-join (lookup t.public.def)
expr format=show-all colstat=7 colstat=8 colstat=(7, 8) colstat=1 colstat=2 colstat=3 colstat=(1, 2, 3)
(MakeLookupJoin
(Scan [ (Table "abc") (Cols "a,b,c") ])
[ (JoinType "anti-join") (Table "def") (Index "def@primary") (KeyCols "a,b") (Cols "a,b,c,d,e") ]
[ (JoinType "anti-join") (Table "def") (Index "def@def_pkey") (KeyCols "a,b") (Cols "a,b,c,d,e") ]
[ ]
)
----
Expand All @@ -1431,7 +1431,7 @@ anti-join (lookup t.public.def)
expr format=show-all colstat=7 colstat=8 colstat=(7, 8) colstat=1 colstat=2 colstat=3 colstat=(1, 2, 3)
(MakeLookupJoin
(Scan [ (Table "abc") (Cols "a,b,c") ])
[ (JoinType "semi-join") (Table "def") (Index "def@primary") (KeyCols "a,b") (Cols "a,b,c,d,e") ]
[ (JoinType "semi-join") (Table "def") (Index "def@def_pkey") (KeyCols "a,b") (Cols "a,b,c,d,e") ]
[ (False) ]
)
----
Expand All @@ -1457,7 +1457,7 @@ semi-join (lookup t.public.def)
expr format=show-all colstat=7 colstat=8 colstat=(7, 8) colstat=1 colstat=2 colstat=3 colstat=(1, 2, 3)
(MakeLookupJoin
(Scan [ (Table "abc") (Cols "a,b,c") ])
[ (JoinType "anti-join") (Table "def") (Index "def@primary") (KeyCols "a,b") (Cols "a,b,c,d,e") ]
[ (JoinType "anti-join") (Table "def") (Index "def@def_pkey") (KeyCols "a,b") (Cols "a,b,c,d,e") ]
[ (False) ]
)
----
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/opt/memo/testdata/stats/upsert
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ with &1
├── fd: ()-->(23)
├── upsert xyz
│ ├── columns: xyz.x:1(string!null) xyz.y:2(int!null) xyz.z:3(float)
│ ├── arbiter indexes: primary
│ ├── arbiter indexes: xyz_pkey
│ ├── canary column: xyz.x:13(string)
│ ├── fetch columns: xyz.x:13(string) xyz.y:14(int) xyz.z:15(float)
│ ├── insert-mapping:
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/opt/norm/testdata/rules/decorrelate
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ RETURNING *
----
upsert xy
├── columns: x:1!null y:2
├── arbiter indexes: primary
├── arbiter indexes: xy_pkey
├── canary column: x:7
├── fetch columns: x:7 y:8
├── insert-mapping:
Expand Down
18 changes: 9 additions & 9 deletions pkg/sql/opt/norm/testdata/rules/groupby
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ ON CONFLICT (x) DO NOTHING
----
insert xy
├── columns: <none>
├── arbiter indexes: primary
├── arbiter indexes: xy_pkey
├── insert-mapping:
│ ├── y:6 => x:1
│ └── y_default:9 => y:2
Expand Down Expand Up @@ -986,7 +986,7 @@ ON CONFLICT (x) DO UPDATE SET y=1
----
upsert xy
├── columns: <none>
├── arbiter indexes: primary
├── arbiter indexes: xy_pkey
├── canary column: x:10
├── fetch columns: x:10 y:11
├── insert-mapping:
Expand Down Expand Up @@ -1042,7 +1042,7 @@ ON CONFLICT (x) DO NOTHING
----
insert xy
├── columns: <none>
├── arbiter indexes: primary
├── arbiter indexes: xy_pkey
├── insert-mapping:
│ ├── y:6 => x:1
│ └── y_default:9 => y:2
Expand Down Expand Up @@ -1085,7 +1085,7 @@ ON CONFLICT (x) DO UPDATE SET y=1
----
upsert xy
├── columns: <none>
├── arbiter indexes: primary
├── arbiter indexes: xy_pkey
├── canary column: x:10
├── fetch columns: x:10 y:11
├── insert-mapping:
Expand Down Expand Up @@ -1142,7 +1142,7 @@ ON CONFLICT (a, b, c) DO UPDATE SET a=1
----
upsert abc
├── columns: <none>
├── arbiter indexes: primary
├── arbiter indexes: abc_pkey
├── canary column: a:13
├── fetch columns: a:13 b:14 c:15
├── insert-mapping:
Expand Down Expand Up @@ -1193,7 +1193,7 @@ ON CONFLICT (a, b, c) DO UPDATE SET c=2
----
upsert abc
├── columns: <none>
├── arbiter indexes: primary
├── arbiter indexes: abc_pkey
├── canary column: a:12
├── fetch columns: a:12 b:13 c:14
├── insert-mapping:
Expand Down Expand Up @@ -2264,7 +2264,7 @@ ON CONFLICT DO NOTHING
----
insert a
├── columns: <none>
├── arbiter indexes: primary si_idx fi_idx
├── arbiter indexes: a_pkey si_idx fi_idx
├── insert-mapping:
│ ├── column1:8 => k:1
│ ├── column3:10 => i:2
Expand Down Expand Up @@ -2323,7 +2323,7 @@ ON CONFLICT DO NOTHING
----
insert a
├── columns: <none>
├── arbiter indexes: primary si_idx fi_idx
├── arbiter indexes: a_pkey si_idx fi_idx
├── insert-mapping:
│ ├── column1:8 => k:1
│ ├── i_default:11 => i:2
Expand Down Expand Up @@ -2410,7 +2410,7 @@ ON CONFLICT DO NOTHING
----
insert a
├── columns: <none>
├── arbiter indexes: primary si_idx fi_idx
├── arbiter indexes: a_pkey si_idx fi_idx
├── insert-mapping:
│ ├── column1:8 => k:1
│ ├── column3:10 => i:2
Expand Down
36 changes: 18 additions & 18 deletions pkg/sql/opt/norm/testdata/rules/prune_cols
Original file line number Diff line number Diff line change
Expand Up @@ -2245,7 +2245,7 @@ UPSERT INTO partial_indexes (a, d) VALUES (1, 2)
----
upsert partial_indexes
├── columns: <none>
├── arbiter indexes: primary
├── arbiter indexes: partial_indexes_pkey
├── canary column: a:11
├── fetch columns: a:11 d:14
├── insert-mapping:
Expand Down Expand Up @@ -2302,7 +2302,7 @@ UPSERT INTO partial_indexes (a, b, d) VALUES (1, 2, 3)
----
upsert partial_indexes
├── columns: <none>
├── arbiter indexes: primary
├── arbiter indexes: partial_indexes_pkey
├── canary column: a:11
├── fetch columns: a:11 b:12 c:13 d:14
├── insert-mapping:
Expand Down Expand Up @@ -2361,7 +2361,7 @@ INSERT INTO partial_indexes (a, d) VALUES (1, 2) ON CONFLICT (a) DO UPDATE SET d
----
upsert partial_indexes
├── columns: <none>
├── arbiter indexes: primary
├── arbiter indexes: partial_indexes_pkey
├── canary column: a:11
├── fetch columns: a:11 d:14
├── insert-mapping:
Expand Down Expand Up @@ -2419,7 +2419,7 @@ INSERT INTO partial_indexes (a, d) VALUES (1, 2) ON CONFLICT (a) DO UPDATE SET b
----
upsert partial_indexes
├── columns: <none>
├── arbiter indexes: primary
├── arbiter indexes: partial_indexes_pkey
├── canary column: a:11
├── fetch columns: a:11 b:12 c:13 d:14
├── insert-mapping:
Expand Down Expand Up @@ -2614,7 +2614,7 @@ UPSERT INTO virt_partial_idx (a, d) VALUES (1, 2)
----
upsert virt_partial_idx
├── columns: <none>
├── arbiter indexes: primary
├── arbiter indexes: virt_partial_idx_pkey
├── canary column: a:12
├── fetch columns: a:12 d:16
├── insert-mapping:
Expand Down Expand Up @@ -2685,7 +2685,7 @@ UPSERT INTO virt_partial_idx (a, b, d) VALUES (1, 2, 3)
----
upsert virt_partial_idx
├── columns: <none>
├── arbiter indexes: primary
├── arbiter indexes: virt_partial_idx_pkey
├── canary column: a:13
├── fetch columns: a:13 b:14 v:15 c:16 d:17
├── insert-mapping:
Expand Down Expand Up @@ -2759,7 +2759,7 @@ INSERT INTO virt_partial_idx (a, d) VALUES (1, 2) ON CONFLICT (a) DO UPDATE SET
----
upsert virt_partial_idx
├── columns: <none>
├── arbiter indexes: primary
├── arbiter indexes: virt_partial_idx_pkey
├── canary column: a:12
├── fetch columns: a:12 d:16
├── insert-mapping:
Expand Down Expand Up @@ -2831,7 +2831,7 @@ INSERT INTO virt_partial_idx (a, d) VALUES (1, 2) ON CONFLICT (a) DO UPDATE SET
----
upsert virt_partial_idx
├── columns: <none>
├── arbiter indexes: primary
├── arbiter indexes: virt_partial_idx_pkey
├── canary column: a:12
├── fetch columns: a:12 b:13 v:14 c:15 d:16
├── insert-mapping:
Expand Down Expand Up @@ -3104,7 +3104,7 @@ INSERT INTO a (k, s) VALUES (1, 'foo') ON CONFLICT (k) DO UPDATE SET i=a.i+1
----
upsert a
├── columns: <none>
├── arbiter indexes: primary
├── arbiter indexes: a_pkey
├── canary column: k:11
├── fetch columns: k:11 i:12 f:13 s:14
├── insert-mapping:
Expand Down Expand Up @@ -3156,7 +3156,7 @@ INSERT INTO a (k, s) VALUES (1, 'foo') ON CONFLICT (k) DO UPDATE SET i=a.i+1 RET
----
upsert a
├── columns: k:1!null i:2 f:3 s:4
├── arbiter indexes: primary
├── arbiter indexes: a_pkey
├── canary column: k:11
├── fetch columns: k:11 i:12 f:13 s:14
├── insert-mapping:
Expand Down Expand Up @@ -3217,7 +3217,7 @@ UPSERT INTO family (a, b) VALUES (1, 2)
----
upsert family
├── columns: <none>
├── arbiter indexes: primary
├── arbiter indexes: family_pkey
├── canary column: a:11
├── fetch columns: a:11 b:12
├── insert-mapping:
Expand Down Expand Up @@ -3266,7 +3266,7 @@ project
├── fd: ()-->(5)
└── upsert family
├── columns: a:1!null e:5
├── arbiter indexes: primary
├── arbiter indexes: family_pkey
├── canary column: a:13
├── fetch columns: a:13 c:15 d:16 e:17
├── insert-mapping:
Expand Down Expand Up @@ -3325,7 +3325,7 @@ INSERT INTO family VALUES (1, 2, 3, 4) ON CONFLICT (a) DO UPDATE SET d=10
----
upsert family
├── columns: <none>
├── arbiter indexes: primary
├── arbiter indexes: family_pkey
├── canary column: a:13
├── fetch columns: a:13 c:15 d:16
├── insert-mapping:
Expand Down Expand Up @@ -3376,7 +3376,7 @@ INSERT INTO mutation VALUES (1, 2, 3) ON CONFLICT (a) DO UPDATE SET b=10
----
upsert mutation
├── columns: <none>
├── arbiter indexes: primary
├── arbiter indexes: mutation_pkey
├── canary column: a:12
├── fetch columns: a:12 b:13 c:14 d:15 e:16
├── insert-mapping:
Expand Down Expand Up @@ -3533,7 +3533,7 @@ UPSERT INTO checks (a, c, d) VALUES (1, 3, 4)
----
upsert checks
├── columns: <none>
├── arbiter indexes: primary
├── arbiter indexes: checks_pkey
├── canary column: a:11
├── fetch columns: a:11 b:12 c:13 d:14
├── insert-mapping:
Expand Down Expand Up @@ -3757,7 +3757,7 @@ INSERT INTO uniq_fk_parent VALUES (2, 1) ON CONFLICT (k) DO UPDATE SET c = 1
----
upsert uniq_fk_parent
├── columns: <none>
├── arbiter indexes: primary
├── arbiter indexes: uniq_fk_parent_pkey
├── canary column: uniq_fk_parent.k:11
├── fetch columns: uniq_fk_parent.k:11 uniq_fk_parent.b:13 uniq_fk_parent.c:14
├── insert-mapping:
Expand Down Expand Up @@ -3869,7 +3869,7 @@ INSERT INTO uniq_fk_parent VALUES (1) ON CONFLICT (k) DO UPDATE SET d = 1
----
upsert uniq_fk_parent
├── columns: <none>
├── arbiter indexes: primary
├── arbiter indexes: uniq_fk_parent_pkey
├── canary column: uniq_fk_parent.k:10
├── fetch columns: uniq_fk_parent.k:10 uniq_fk_parent.d:14
├── insert-mapping:
Expand Down Expand Up @@ -4668,7 +4668,7 @@ project
├── fd: ()-->(1-4)
└── upsert returning_test
├── columns: a:1!null b:2!null c:3!null d:4 rowid:8!null
├── arbiter indexes: primary
├── arbiter indexes: returning_test_pkey
├── canary column: rowid:23
├── fetch columns: a:16 b:17 c:18 d:19 rowid:23
├── insert-mapping:
Expand Down
6 changes: 3 additions & 3 deletions pkg/sql/opt/optbuilder/testdata/create_view
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ create-view t.public.v1
└── ab@idx [columns: a]

build
CREATE VIEW v1 AS SELECT a FROM ab@primary
CREATE VIEW v1 AS SELECT a FROM ab@ab_pkey
----
create-view t.public.v1
├── SELECT a FROM t.public.ab@primary
├── SELECT a FROM t.public.ab@ab_pkey
├── columns: a:1
└── dependencies
└── ab@primary [columns: a]
└── ab@ab_pkey [columns: a]

# Test dependency on view.
exec-ddl
Expand Down
4 changes: 2 additions & 2 deletions pkg/sql/opt/optbuilder/testdata/delete
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,14 @@ CREATE TABLE xyzw (
----

build
DELETE FROM xyzw@primary
DELETE FROM xyzw@xyzw_pkey
----
delete xyzw
├── columns: <none>
├── fetch columns: x:7 y:8 z:9 w:10
└── scan xyzw
├── columns: x:7!null y:8 z:9 w:10 crdb_internal_mvcc_timestamp:11 tableoid:12
└── flags: force-index=primary
└── flags: force-index=xyzw_pkey

build
DELETE FROM xyzw@foo
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/opt/optbuilder/testdata/fk-checks-insert
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ INSERT INTO child VALUES (100, 1), (200, 1) ON CONFLICT DO NOTHING
----
insert child
├── columns: <none>
├── arbiter indexes: primary
├── arbiter indexes: child_pkey
├── insert-mapping:
│ ├── column1:5 => c:1
│ └── column2:6 => child.p:2
Expand Down
Loading

0 comments on commit 7778f73

Please sign in to comment.