Skip to content

Commit

Permalink
Adapt tests for Postgres 10
Browse files Browse the repository at this point in the history
  • Loading branch information
za-arthur committed May 16, 2024
1 parent a2109c0 commit 4221a11
Show file tree
Hide file tree
Showing 5 changed files with 460 additions and 23 deletions.
2 changes: 1 addition & 1 deletion bin/pg_repack.c
Original file line number Diff line number Diff line change
Expand Up @@ -2297,7 +2297,7 @@ repack_all_indexes(char *errbuf, size_t errsize)
res = execute_elevel("SELECT quote_ident(n.nspname) || '.' || quote_ident(c.relname)"
" FROM pg_class c JOIN pg_namespace n on n.oid = c.relnamespace"
" WHERE c.oid = ANY (repack.get_table_and_inheritors($1::regclass))"
" AND c.relkind != 'p'"
" AND c.relkind = 'r'"
" ORDER BY n.nspname, c.relname",
1, params, DEBUG2);

Expand Down
19 changes: 13 additions & 6 deletions regress/expected/repack-check.out
Original file line number Diff line number Diff line change
Expand Up @@ -353,20 +353,27 @@ INFO: repacking table "public.tbl_cluster"
--
-- partitioned table check
--
CREATE TABLE partitioned_a(val integer primary key) PARTITION BY RANGE (val);
CREATE TABLE partitioned_a(val integer NOT NULL) PARTITION BY RANGE (val);
CREATE TABLE partition_a_1 PARTITION OF partitioned_a FOR VALUES FROM (0) TO (1000);
CREATE TABLE partition_a_2 PARTITION OF partitioned_a FOR VALUES FROM (1000) TO (2000);
CREATE TABLE partition_a_default PARTITION OF partitioned_a DEFAULT
-- Create indexes separately to support Postgres 10 which doesn't support
-- indexes on a partitioned table itself
CREATE UNIQUE INDEX partition_a_1_val_idx ON partition_a_1 (val);
CREATE UNIQUE INDEX partition_a_2_val_idx ON partition_a_2 (val);
-- These statements will fail on Postgres 10
CREATE UNIQUE INDEX partitioned_a_val_idx ON ONLY partitioned_a (val);
ALTER INDEX partitioned_a_val_idx ATTACH PARTITION partition_a_1_val_idx;
ALTER INDEX partitioned_a_val_idx ATTACH PARTITION partition_a_2_val_idx;
-- => OK
\! pg_repack --dbname=contrib_regression --parent-table=partitioned_a
INFO: repacking table "public.partition_a_1"
INFO: repacking table "public.partition_a_2"
-- => OK
\! pg_repack --dbname=contrib_regression --parent-table=partitioned_a --only-indexes
INFO: repacking indexes of "public.partition_a_1"
INFO: repacking index "public.partition_a_1_pkey"
INFO: repacking index "public.partition_a_1_val_idx"
INFO: repacking indexes of "public.partition_a_2"
INFO: repacking index "public.partition_a_2_pkey"
INFO: repacking index "public.partition_a_2_val_idx"
-- => OK
\! pg_repack --dbname=contrib_regression --parent-table=partitioned_a --parent-table=parent_a
INFO: repacking table "public.child_a_1"
Expand All @@ -377,9 +384,9 @@ INFO: repacking table "public.partition_a_2"
-- => OK
\! pg_repack --dbname=contrib_regression --parent-table=partitioned_a --parent-table=parent_a --only-indexes
INFO: repacking indexes of "public.partition_a_1"
INFO: repacking index "public.partition_a_1_pkey"
INFO: repacking index "public.partition_a_1_val_idx"
INFO: repacking indexes of "public.partition_a_2"
INFO: repacking index "public.partition_a_2_pkey"
INFO: repacking index "public.partition_a_2_val_idx"
INFO: repacking indexes of "public.child_a_1"
INFO: repacking index "public.child_a_1_pkey"
INFO: repacking indexes of "public.child_a_2"
Expand Down
53 changes: 39 additions & 14 deletions regress/expected/repack-check_1.out
Original file line number Diff line number Diff line change
Expand Up @@ -353,27 +353,52 @@ INFO: repacking table "public.tbl_cluster"
--
-- partitioned table check
--
CREATE TABLE partitioned_a(val integer primary key) PARTITION BY RANGE (val);
ERROR: primary key constraints are not supported on partitioned tables
LINE 1: CREATE TABLE partitioned_a(val integer primary key) PARTITIO...
^
CREATE TABLE partitioned_a(val integer NOT NULL) PARTITION BY RANGE (val);
CREATE TABLE partition_a_1 PARTITION OF partitioned_a FOR VALUES FROM (0) TO (1000);
ERROR: relation "partitioned_a" does not exist
CREATE TABLE partition_a_2 PARTITION OF partitioned_a FOR VALUES FROM (1000) TO (2000);
ERROR: relation "partitioned_a" does not exist
CREATE TABLE partition_a_default PARTITION OF partitioned_a DEFAULT
-- Create indexes separately to support Postgres 10 which doesn't support
-- indexes on a partitioned table itself
CREATE UNIQUE INDEX partition_a_1_val_idx ON partition_a_1 (val);
CREATE UNIQUE INDEX partition_a_2_val_idx ON partition_a_2 (val);
-- These statements will fail on Postgres 10
CREATE UNIQUE INDEX partitioned_a_val_idx ON ONLY partitioned_a (val);
ERROR: syntax error at or near "ONLY"
LINE 1: CREATE UNIQUE INDEX partitioned_a_val_idx ON ONLY partitione...
^
ALTER INDEX partitioned_a_val_idx ATTACH PARTITION partition_a_1_val_idx;
ERROR: syntax error at or near "ATTACH"
LINE 1: ALTER INDEX partitioned_a_val_idx ATTACH PARTITION partition...
^
ALTER INDEX partitioned_a_val_idx ATTACH PARTITION partition_a_2_val_idx;
ERROR: syntax error at or near "ATTACH"
LINE 1: ALTER INDEX partitioned_a_val_idx ATTACH PARTITION partition...
^
-- => OK
\! pg_repack --dbname=contrib_regression --parent-table=partitioned_a
ERROR: pg_repack failed with error: ERROR: relation "partitioned_a" does not exist
INFO: repacking table "public.partition_a_1"
INFO: repacking table "public.partition_a_2"
-- => OK
\! pg_repack --dbname=contrib_regression --parent-table=partitioned_a --only-indexes
ERROR: ERROR: relation "partitioned_a" does not exist
INFO: repacking indexes of "public.partition_a_1"
INFO: repacking index "public.partition_a_1_val_idx"
INFO: repacking indexes of "public.partition_a_2"
INFO: repacking index "public.partition_a_2_val_idx"
-- => OK
\! pg_repack --dbname=contrib_regression --parent-table=partitioned_a --parent-table=parent_a
ERROR: pg_repack failed with error: ERROR: relation "partitioned_a" does not exist
INFO: repacking table "public.child_a_1"
INFO: repacking table "public.child_a_2"
INFO: repacking table "public.parent_a"
INFO: repacking table "public.partition_a_1"
INFO: repacking table "public.partition_a_2"
-- => OK
\! pg_repack --dbname=contrib_regression --parent-table=partitioned_a --parent-table=parent_a --only-indexes
ERROR: ERROR: relation "partitioned_a" does not exist
ERROR: syntax error at or near "DEFAULT"
LINE 1: ...TABLE partition_a_default PARTITION OF partitioned_a DEFAULT
^
INFO: repacking indexes of "public.partition_a_1"
INFO: repacking index "public.partition_a_1_val_idx"
INFO: repacking indexes of "public.partition_a_2"
INFO: repacking index "public.partition_a_2_val_idx"
INFO: repacking indexes of "public.child_a_1"
INFO: repacking index "public.child_a_1_pkey"
INFO: repacking indexes of "public.child_a_2"
INFO: repacking index "public.child_a_2_pkey"
INFO: repacking indexes of "public.parent_a"
INFO: repacking index "public.parent_a_pkey"
Loading

0 comments on commit 4221a11

Please sign in to comment.