@@ -715,22 +715,23 @@ attrelid relname attname atttypid attstattarget
715715110 t1 m 20 0 8 14 0 -1
716716110 t1 n 20 0 8 15 0 -1
7177173687884466 t1_pkey p 701 0 8 1 0 -1
718- 3687884465 t1_a_key a 20 0 8 2 0 -1
719- 3687884464 index_key b 20 0 8 3 0 -1
720- 3687884464 index_key c 20 0 8 4 0 -1
718+ 3687884465 t1_a_key a 20 0 8 1 0 -1
719+ 3687884464 index_key b 20 0 8 1 0 -1
720+ 3687884464 index_key c 20 0 8 2 0 -1
721721111 t1_m_seq value 20 0 8 1 0 -1
722722112 t1_n_seq value 20 0 8 1 0 -1
723723113 t2 t1_id 20 0 8 1 0 -1
724724113 t2 rowid 20 0 8 2 0 -1
725- 2955071325 t2_pkey rowid 20 0 8 2 0 -1
725+ 2955071325 t2_pkey rowid 20 0 8 1 0 -1
7267262955071326 t2_t1_id_idx t1_id 20 0 8 1 0 -1
727727114 t3 a 20 0 8 1 0 -1
728728114 t3 b 20 0 8 2 0 -1
729729114 t3 c 25 0 -1 3 0 -1
730730114 t3 rowid 20 0 8 4 0 -1
731- 2695335054 t3_pkey rowid 20 0 8 4 0 -1
731+ 2695335054 t3_pkey rowid 20 0 8 1 0 -1
7327322695335053 t3_a_b_idx a 20 0 8 1 0 -1
7337332695335053 t3_a_b_idx b 20 0 8 2 0 -1
734+ 2695335053 t3_a_b_idx c 25 0 -1 3 0 -1
734735115 v1 p 701 0 8 1 0 -1
735736115 v1 a 20 0 8 2 0 -1
736737115 v1 b 20 0 8 3 0 -1
@@ -739,26 +740,26 @@ attrelid relname attname atttypid attstattarget
739740116 t4 b 701 0 8 2 0 -1
740741116 t4 c 25 0 -1 3 0 -1
741742116 t4 rowid 20 0 8 4 0 -1
742- 3214807592 t4_pkey rowid 20 0 8 4 0 -1
743+ 3214807592 t4_pkey rowid 20 0 8 1 0 -1
743744117 t5 a 20 0 8 1 0 -1
744745117 t5 b 701 0 8 2 0 -1
745746117 t5 c 25 0 -1 3 0 -1
746747117 t5 rowid 20 0 8 4 0 -1
747- 1869730585 t5_pkey rowid 20 0 8 4 0 -1
748+ 1869730585 t5_pkey rowid 20 0 8 1 0 -1
748749120 t6 a 20 0 8 1 0 -1
749750120 t6 b 20 0 8 2 0 -1
750751120 t6 c 25 0 -1 3 0 -1
751752120 t6 m 100118 0 -1 4 0 -1
752753120 t6 rowid 20 0 8 6 0 -1
753- 2129466852 t6_pkey rowid 20 0 8 6 0 -1
754- 2129466855 t6_expr_idx crdb_internal_idx_expr 20 0 8 5 0 -1
755- 2129466854 t6_expr_expr1_idx crdb_internal_idx_expr_1 25 0 -1 7 0 -1
756- 2129466854 t6_expr_expr1_idx crdb_internal_idx_expr 20 0 8 5 0 -1
757- 2129466848 t6_expr_key crdb_internal_idx_expr_1 25 0 -1 7 0 -1
758- 2129466850 t6_expr_idx1 crdb_internal_idx_expr_2 16 0 1 8 0 -1
754+ 2129466852 t6_pkey rowid 20 0 8 1 0 -1
755+ 2129466855 t6_expr_idx crdb_internal_idx_expr 20 0 8 1 0 -1
756+ 2129466854 t6_expr_expr1_idx crdb_internal_idx_expr_1 25 0 -1 1 0 -1
757+ 2129466854 t6_expr_expr1_idx crdb_internal_idx_expr 20 0 8 2 0 -1
758+ 2129466848 t6_expr_key crdb_internal_idx_expr_1 25 0 -1 1 0 -1
759+ 2129466850 t6_expr_idx1 crdb_internal_idx_expr_2 16 0 1 1 0 -1
759760121 mv1 ?column? 20 0 8 1 0 -1
760761121 mv1 rowid 20 0 8 2 0 -1
761- 784389845 mv1_pkey rowid 20 0 8 2 0 -1
762+ 784389845 mv1_pkey rowid 20 0 8 1 0 -1
762763
763764query TTIBTTBBTT colnames,rowsort
764765SELECT c.relname, attname, atttypmod, attbyval, attstorage, attalign, attnotnull, atthasdef, attidentity, attgenerated
@@ -800,6 +801,7 @@ t3 rowid -1 NULL NULL NU
800801t3_pkey rowid -1 NULL NULL NULL true true · ·
801802t3_a_b_idx a -1 NULL NULL NULL false false · ·
802803t3_a_b_idx b -1 NULL NULL NULL false false · ·
804+ t3_a_b_idx c -1 NULL NULL NULL false true · ·
803805v1 p -1 NULL NULL NULL false false · ·
804806v1 a -1 NULL NULL NULL false false · ·
805807v1 b -1 NULL NULL NULL false false · ·
@@ -869,6 +871,7 @@ t3 rowid false true 0
869871t3_pkey rowid false true 0 NULL NULL NULL
870872t3_a_b_idx a false true 0 NULL NULL NULL
871873t3_a_b_idx b false true 0 NULL NULL NULL
874+ t3_a_b_idx c false true 0 NULL NULL NULL
872875v1 p false true 0 NULL NULL NULL
873876v1 a false true 0 NULL NULL NULL
874877v1 b false true 0 NULL NULL NULL
@@ -958,6 +961,7 @@ t6_expr_expr1_idx crdb_internal_idx_expr_1 text 3403232968 default
958961t6 c text 3403232968 default
959962t5 c text 3403232968 default
960963t4 c text 3403232968 default
964+ t3_a_b_idx c text 3403232968 default
961965t3 c text 3403232968 default
962966t1 j char 3403232968 default
963967t1 i _varchar 3403232968 default
@@ -6053,3 +6057,38 @@ COMMIT;
60536057
60546058statement ok
60556059DROP TABLE t;
6060+
6061+ ## Check key columns for indexes PG_Attribute
6062+ statement ok
6063+ CREATE TABLE t1(x int, y int primary key);
6064+
6065+ statement ok
6066+ CREATE TABLE t2(x int, y int);
6067+
6068+ statement ok
6069+ CREATE TABLE t3(x int, y int);
6070+
6071+ statement ok
6072+ CREATE INDEX t3idx ON t3(x) include(y);
6073+
6074+ query IT colnames
6075+ select attnum, attname from pg_attribute a join pg_class c on c.oid = a.attrelid where c.relname = 't1_pkey'
6076+ order by attnum;
6077+ ----
6078+ attnum attname
6079+ 1 y
6080+
6081+ query IT colnames
6082+ select attnum, attname from pg_attribute a join pg_class c on c.oid = a.attrelid where c.relname = 't2_pkey'
6083+ order by attnum;
6084+ ----
6085+ attnum attname
6086+ 1 rowid
6087+
6088+ query IT colnames
6089+ select attnum, attname from pg_attribute a join pg_class c on c.oid = a.attrelid where c.relname = 't3idx'
6090+ order by attnum;
6091+ ----
6092+ attnum attname
6093+ 1 x
6094+ 2 y
0 commit comments