Added support for DESC and NULLS FIRST/LAST to index keys

Fixes issue #3
This commit is contained in:
Daniele Varrazzo
2012-12-09 01:11:39 +00:00
parent 1a0a28d3f8
commit a47686a7ee
3 changed files with 85 additions and 4 deletions

View File

@ -314,3 +314,35 @@ ERROR: relation "tbl_uk" must have a primary key or not-null unique keys
\! pg_repack --dbname=contrib_regression --no-order --table=tbl_nn_puk
ERROR: relation "tbl_nn_puk" must have a primary key or not-null unique keys
-- => ERROR
--
-- pg_repack issue #3
--
CREATE TABLE issue3 (col1 int NOT NULL, col2 text NOT NULL);
CREATE UNIQUE INDEX issue3_idx1 ON issue3 (col1, col2 DESC);
CREATE UNIQUE INDEX issue3_idx2 ON issue3 (col1 DESC, col2 text_pattern_ops);
CREATE UNIQUE INDEX issue3_idx3 ON issue3 (col1 DESC, col2 DESC);
CREATE UNIQUE INDEX issue3_idx4 ON issue3 (col1 NULLS FIRST, col2 text_pattern_ops DESC NULLS LAST);
SELECT repack.get_index_keys('issue3_idx1'::regclass::oid, 'issue3'::regclass::oid);
get_index_keys
-----------------
col1, col2 DESC
(1 row)
SELECT repack.get_index_keys('issue3_idx2'::regclass::oid, 'issue3'::regclass::oid);
get_index_keys
---------------------------
col1 DESC, col2 USING ~<~
(1 row)
SELECT repack.get_index_keys('issue3_idx3'::regclass::oid, 'issue3'::regclass::oid);
get_index_keys
----------------------
col1 DESC, col2 DESC
(1 row)
SELECT repack.get_index_keys('issue3_idx4'::regclass::oid, 'issue3'::regclass::oid);
get_index_keys
--------------------------------------------------
col1 NULLS FIRST, col2 DESC USING ~<~ NULLS LAST
(1 row)

View File

@ -187,3 +187,17 @@ CREATE UNIQUE INDEX tbl_nn_puk_pcol1_idx ON tbl_nn_puk(col1) WHERE col1 < 10;
-- => OK
\! pg_repack --dbname=contrib_regression --no-order --table=tbl_nn_puk
-- => ERROR
--
-- pg_repack issue #3
--
CREATE TABLE issue3 (col1 int NOT NULL, col2 text NOT NULL);
CREATE UNIQUE INDEX issue3_idx1 ON issue3 (col1, col2 DESC);
CREATE UNIQUE INDEX issue3_idx2 ON issue3 (col1 DESC, col2 text_pattern_ops);
CREATE UNIQUE INDEX issue3_idx3 ON issue3 (col1 DESC, col2 DESC);
CREATE UNIQUE INDEX issue3_idx4 ON issue3 (col1 NULLS FIRST, col2 text_pattern_ops DESC NULLS LAST);
SELECT repack.get_index_keys('issue3_idx1'::regclass::oid, 'issue3'::regclass::oid);
SELECT repack.get_index_keys('issue3_idx2'::regclass::oid, 'issue3'::regclass::oid);
SELECT repack.get_index_keys('issue3_idx3'::regclass::oid, 'issue3'::regclass::oid);
SELECT repack.get_index_keys('issue3_idx4'::regclass::oid, 'issue3'::regclass::oid);