diff --git a/bin/expected/repack.out b/bin/expected/repack.out index 96506c3..3a44f3a 100644 --- a/bin/expected/repack.out +++ b/bin/expected/repack.out @@ -299,6 +299,8 @@ CREATE TABLE tbl_nn (col1 int NOT NULL, col2 int NOT NULL); CREATE TABLE tbl_uk (col1 int NOT NULL, col2 int , UNIQUE(col1, col2)); CREATE TABLE tbl_nn_uk (col1 int NOT NULL, col2 int NOT NULL, UNIQUE(col1, col2)); CREATE TABLE tbl_pk_uk (col1 int NOT NULL, col2 int NOT NULL, PRIMARY KEY(col1, col2), UNIQUE(col2, col1)); +CREATE TABLE tbl_nn_puk (col1 int NOT NULL, col2 int NOT NULL); +CREATE UNIQUE INDEX tbl_nn_puk_pcol1_idx ON tbl_nn_puk(col1) WHERE col1 < 10; \! pg_repack --dbname=contrib_regression --no-order --table=tbl_nn ERROR: relation "tbl_nn" must have a primary key or not-null unique keys -- => ERROR @@ -309,3 +311,6 @@ ERROR: relation "tbl_uk" must have a primary key or not-null unique keys -- => OK \! pg_repack --dbname=contrib_regression --no-order --table=tbl_pk_uk -- => OK +\! 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 diff --git a/bin/sql/repack.sql b/bin/sql/repack.sql index 3b9797d..9d385dc 100644 --- a/bin/sql/repack.sql +++ b/bin/sql/repack.sql @@ -175,6 +175,8 @@ CREATE TABLE tbl_nn (col1 int NOT NULL, col2 int NOT NULL); CREATE TABLE tbl_uk (col1 int NOT NULL, col2 int , UNIQUE(col1, col2)); CREATE TABLE tbl_nn_uk (col1 int NOT NULL, col2 int NOT NULL, UNIQUE(col1, col2)); CREATE TABLE tbl_pk_uk (col1 int NOT NULL, col2 int NOT NULL, PRIMARY KEY(col1, col2), UNIQUE(col2, col1)); +CREATE TABLE tbl_nn_puk (col1 int NOT NULL, col2 int NOT NULL); +CREATE UNIQUE INDEX tbl_nn_puk_pcol1_idx ON tbl_nn_puk(col1) WHERE col1 < 10; \! pg_repack --dbname=contrib_regression --no-order --table=tbl_nn -- => ERROR \! pg_repack --dbname=contrib_regression --no-order --table=tbl_uk @@ -183,3 +185,5 @@ CREATE TABLE tbl_pk_uk (col1 int NOT NULL, col2 int NOT NULL, PRIMARY KEY(col1, -- => OK \! pg_repack --dbname=contrib_regression --no-order --table=tbl_pk_uk -- => OK +\! pg_repack --dbname=contrib_regression --no-order --table=tbl_nn_puk +-- => ERROR diff --git a/lib/pg_repack.sql.in b/lib/pg_repack.sql.in index 893ffb8..52514f2 100644 --- a/lib/pg_repack.sql.in +++ b/lib/pg_repack.sql.in @@ -154,6 +154,7 @@ CREATE VIEW repack.primary_keys AS FROM (SELECT indrelid, indexrelid FROM pg_index WHERE indisunique AND indisvalid + AND indpred IS NULL AND 0 <> ALL(indkey) AND NOT EXISTS( SELECT 1 FROM pg_attribute