summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorTom Lane2018-07-19 17:48:05 +0000
committerTom Lane2018-07-19 18:53:48 +0000
commit028e3da2949482fa56f3ffdbda840782f2953b0b (patch)
tree44322e3fc529acb235fa4b46cbaf80db5c6bf73a /src/test
parent1573995f55994ee04dd0d69481de17d662ad8e88 (diff)
Fix pg_get_indexdef()'s behavior for included index columns.
The multi-argument form of pg_get_indexdef() failed to print anything when asked to print a single index column that is an included column rather than a key column. This seems an unintentional result of someone having tried to take a short-cut and use the attrsOnly flag for two different purposes. To fix, split said flag into two flags, attrsOnly which suppresses non-attribute info, and keysOnly which suppresses included columns. Add a test case using psql's \d command, which relies on that function. (It's mighty tempting at this point to replace pg_get_indexdef_worker's mess of boolean flag arguments with a single bitmask-of-flags argument, which would allow making the call sites much more self-documenting. But I refrained for the moment.) Discussion: https://postgr.es/m/21724.1531943735@sss.pgh.pa.us
Diffstat (limited to 'src/test')
-rw-r--r--src/test/regress/expected/index_including.out10
-rw-r--r--src/test/regress/sql/index_including.sql1
2 files changed, 11 insertions, 0 deletions
diff --git a/src/test/regress/expected/index_including.out b/src/test/regress/expected/index_including.out
index 48bec3bf77a..e2596391b11 100644
--- a/src/test/regress/expected/index_including.out
+++ b/src/test/regress/expected/index_including.out
@@ -19,6 +19,16 @@ WHERE i.indrelid = 'tbl_include_reg'::regclass ORDER BY c.relname;
CREATE INDEX tbl_include_reg_idx ON public.tbl_include_reg USING btree (c1, c2) INCLUDE (c3, c4)
(2 rows)
+\d tbl_include_reg_idx
+Index "public.tbl_include_reg_idx"
+ Column | Type | Definition
+--------+---------+------------
+ c1 | integer | c1
+ c2 | integer | c2
+ c3 | integer | c3
+ c4 | box | c4
+btree, for table "public.tbl_include_reg"
+
-- Unique index and unique constraint
CREATE TABLE tbl_include_unique1 (c1 int, c2 int, c3 int, c4 box);
INSERT INTO tbl_include_unique1 SELECT x, 2*x, 3*x, box('4,4,4,4') FROM generate_series(1,10) AS x;
diff --git a/src/test/regress/sql/index_including.sql b/src/test/regress/sql/index_including.sql
index 2d833fc9f74..ee9d9f6bae1 100644
--- a/src/test/regress/sql/index_including.sql
+++ b/src/test/regress/sql/index_including.sql
@@ -14,6 +14,7 @@ CREATE INDEX ON tbl_include_reg (c1, c2) INCLUDE (c1, c3);
SELECT pg_get_indexdef(i.indexrelid)
FROM pg_index i JOIN pg_class c ON i.indexrelid = c.oid
WHERE i.indrelid = 'tbl_include_reg'::regclass ORDER BY c.relname;
+\d tbl_include_reg_idx
-- Unique index and unique constraint
CREATE TABLE tbl_include_unique1 (c1 int, c2 int, c3 int, c4 box);