From 6d7b1dbca495d7a27a2d9f067ef5a500cf4c112d Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Mon, 10 Apr 2017 23:07:40 +0100 Subject: [PATCH] Added test to verify the attribute options are respected --- regress/expected/repack.out | 15 +++++++++++++++ regress/expected/repack_1.out | 15 +++++++++++++++ regress/sql/repack.sql | 11 +++++++++++ 3 files changed, 41 insertions(+) diff --git a/regress/expected/repack.out b/regress/expected/repack.out index 4539043..ef0ed4a 100644 --- a/regress/expected/repack.out +++ b/regress/expected/repack.out @@ -55,6 +55,9 @@ CREATE TABLE tbl_idxopts ( t text ); CREATE INDEX idxopts_t ON tbl_idxopts (t DESC NULLS LAST) WHERE (t != 'aaa'); +-- Use this table to play with attribute options too +ALTER TABLE tbl_idxopts ALTER i SET STATISTICS 1; +ALTER TABLE tbl_idxopts ALTER t SET (n_distinct = -0.5); -- -- insert data -- @@ -302,6 +305,18 @@ SELECT oid, relname -----+--------- (0 rows) +-- check columns options +SELECT attname, attstattarget, attoptions +FROM pg_attribute +WHERE attrelid = 'tbl_idxopts'::regclass +AND attnum > 0 +ORDER BY attnum; + attname | attstattarget | attoptions +---------+---------------+------------------- + i | 1 | + t | -1 | {n_distinct=-0.5} +(2 rows) + -- -- NOT NULL UNIQUE -- diff --git a/regress/expected/repack_1.out b/regress/expected/repack_1.out index f800f07..bc0333c 100644 --- a/regress/expected/repack_1.out +++ b/regress/expected/repack_1.out @@ -55,6 +55,9 @@ CREATE TABLE tbl_idxopts ( t text ); CREATE INDEX idxopts_t ON tbl_idxopts (t DESC NULLS LAST) WHERE (t != 'aaa'); +-- Use this table to play with attribute options too +ALTER TABLE tbl_idxopts ALTER i SET STATISTICS 1; +ALTER TABLE tbl_idxopts ALTER t SET (n_distinct = -0.5); -- -- insert data -- @@ -302,6 +305,18 @@ SELECT oid, relname -----+--------- (0 rows) +-- check columns options +SELECT attname, attstattarget, attoptions +FROM pg_attribute +WHERE attrelid = 'tbl_idxopts'::regclass +AND attnum > 0 +ORDER BY attnum; + attname | attstattarget | attoptions +---------+---------------+------------------- + i | 1 | + t | -1 | {n_distinct=-0.5} +(2 rows) + -- -- NOT NULL UNIQUE -- diff --git a/regress/sql/repack.sql b/regress/sql/repack.sql index d7baa7d..58b358f 100644 --- a/regress/sql/repack.sql +++ b/regress/sql/repack.sql @@ -66,6 +66,10 @@ CREATE TABLE tbl_idxopts ( ); CREATE INDEX idxopts_t ON tbl_idxopts (t DESC NULLS LAST) WHERE (t != 'aaa'); +-- Use this table to play with attribute options too +ALTER TABLE tbl_idxopts ALTER i SET STATISTICS 1; +ALTER TABLE tbl_idxopts ALTER t SET (n_distinct = -0.5); + -- -- insert data -- @@ -168,6 +172,13 @@ SELECT oid, relname AND reltoastrelid <> 0 AND reltoastrelid NOT IN (SELECT oid FROM pg_class WHERE relkind = 't'); +-- check columns options +SELECT attname, attstattarget, attoptions +FROM pg_attribute +WHERE attrelid = 'tbl_idxopts'::regclass +AND attnum > 0 +ORDER BY attnum; + -- -- NOT NULL UNIQUE --