Added test to verify the attribute options are respected

This commit is contained in:
Daniele Varrazzo 2017-04-10 23:07:40 +01:00
parent cf6fe7d4cf
commit 6d7b1dbca4
3 changed files with 41 additions and 0 deletions

View File

@ -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
--

View File

@ -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
--

View File

@ -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
--