From 914537edc7827253ee2a1c4f317f6f2ceedb8ab2 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Tue, 20 Mar 2018 20:47:06 +0000 Subject: [PATCH 1/3] An attempt to restrict the search path to avoid injections An alternative way to fix #168 which is not as invasive as the changes in #171. This currently breaks the current behaviour of the program as the tables specified on command line are not found. --- bin/pgut/pgut-fe.c | 3 +++ bin/pgut/pgut.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/bin/pgut/pgut-fe.c b/bin/pgut/pgut-fe.c index 5ed4fed..2f3cba6 100644 --- a/bin/pgut/pgut-fe.c +++ b/bin/pgut/pgut-fe.c @@ -99,6 +99,9 @@ setup_workers(int num_workers) break; } + /* Hardcode a search path to avoid injections into public or pg_temp */ + pgut_command(conn, "SET search_path TO pg_catalog, pg_temp", 0, NULL); + /* Make sure each worker connection can work in non-blocking * mode. */ diff --git a/bin/pgut/pgut.c b/bin/pgut/pgut.c index 14ee762..40de8d1 100644 --- a/bin/pgut/pgut.c +++ b/bin/pgut/pgut.c @@ -504,6 +504,9 @@ pgut_connect(const char *info, YesNo prompt, int elevel) termStringInfo(&add_pass); free(passwd); + /* Hardcode a search path to avoid injections into public or pg_temp */ + pgut_command(conn, "SET search_path TO pg_catalog, pg_temp", 0, NULL); + return conn; } From 64cc2070ede65a9e64cbff8ec53682591481b962 Mon Sep 17 00:00:00 2001 From: Masahiko Sawada Date: Fri, 6 Apr 2018 14:47:53 +0900 Subject: [PATCH 2/3] Fix the broken behavior made by restricting the search path This commit doesn't include the change of regression test files. --- bin/pg_repack.c | 11 ++++++----- lib/pg_repack.sql.in | 6 ++++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/bin/pg_repack.c b/bin/pg_repack.c index 9a62a47..7793f61 100644 --- a/bin/pg_repack.c +++ b/bin/pg_repack.c @@ -1926,6 +1926,7 @@ repack_table_indexes(PGresult *index_details) params[1] = utoa(table, buffer[1]); params[2] = tablespace; schema_name = getstr(index_details, 0, 5); + /* table_name is schema-qualified */ table_name = getstr(index_details, 0, 4); /* Keep track of which of the table's indexes we have successfully @@ -1958,7 +1959,7 @@ repack_table_indexes(PGresult *index_details) "WHERE pgc.relname = 'index_%u' " "AND nsp.nspname = $1", index); params[0] = schema_name; - elog(INFO, "repacking index \"%s\".\"%s\"", schema_name, idx_name); + elog(INFO, "repacking index \"%s\"", idx_name); res = execute(sql.data, 1, params); if (PQresultStatus(res) != PGRES_TUPLES_OK) { @@ -1990,8 +1991,8 @@ repack_table_indexes(PGresult *index_details) if (PQntuples(res) < 1) { elog(WARNING, - "unable to generate SQL to CREATE work index for %s.%s", - schema_name, getstr(index_details, i, 0)); + "unable to generate SQL to CREATE work index for %s", + getstr(index_details, i, 0)); continue; } @@ -2121,7 +2122,7 @@ repack_all_indexes(char *errbuf, size_t errsize) if (r_index.head) { appendStringInfoString(&sql, - "SELECT i.relname, idx.indexrelid, idx.indisvalid, idx.indrelid, idx.indrelid::regclass, n.nspname" + "SELECT repack.oid2text(i.oid), idx.indexrelid, idx.indisvalid, idx.indrelid, repack.oid2text(idx.indrelid), n.nspname" " FROM pg_index idx JOIN pg_class i ON i.oid = idx.indexrelid" " JOIN pg_namespace n ON n.oid = i.relnamespace" " WHERE idx.indexrelid = $1::regclass ORDER BY indisvalid DESC, i.relname, n.nspname"); @@ -2131,7 +2132,7 @@ repack_all_indexes(char *errbuf, size_t errsize) else if (table_list.head || parent_table_list.head) { appendStringInfoString(&sql, - "SELECT i.relname, idx.indexrelid, idx.indisvalid, idx.indrelid, $1::text, n.nspname" + "SELECT repack.oid2text(i.oid), idx.indexrelid, idx.indisvalid, idx.indrelid, $1::text, n.nspname" " FROM pg_index idx JOIN pg_class i ON i.oid = idx.indexrelid" " JOIN pg_namespace n ON n.oid = i.relnamespace" " WHERE idx.indrelid = $1::regclass ORDER BY indisvalid DESC, i.relname, n.nspname"); diff --git a/lib/pg_repack.sql.in b/lib/pg_repack.sql.in index 249547c..99003b6 100644 --- a/lib/pg_repack.sql.in +++ b/lib/pg_repack.sql.in @@ -23,11 +23,13 @@ CREATE AGGREGATE repack.array_accum ( initcond = '{}' ); +-- Always specify search_path to 'pg_catalog' so that we +-- always can get schema-qualified relation name CREATE FUNCTION repack.oid2text(oid) RETURNS text AS $$ SELECT textin(regclassout($1)); $$ -LANGUAGE sql STABLE STRICT; +LANGUAGE sql STABLE STRICT SET search_path to 'pg_catalog'; CREATE FUNCTION repack.get_index_columns(oid, text) RETURNS text AS $$ @@ -235,7 +237,7 @@ CREATE VIEW repack.primary_keys AS GROUP BY indrelid; CREATE VIEW repack.tables AS - SELECT R.oid::regclass AS relname, + SELECT repack.oid2text(R.oid) AS relname, R.oid AS relid, R.reltoastrelid AS reltoastrelid, CASE WHEN R.reltoastrelid = 0 THEN 0 ELSE ( From 9c1da1bff14e9c5d5b74b99345d76c9763726f9d Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Sat, 19 May 2018 16:41:56 +0100 Subject: [PATCH 3/3] Fixed tests to match info messages including the public schema --- regress/expected/issue3.out | 10 ++--- regress/expected/nosuper.out | 2 +- regress/expected/nosuper_1.out | 2 +- regress/expected/repack-check.out | 70 +++++++++++++++---------------- regress/expected/repack-run.out | 24 +++++------ regress/expected/repack-run_1.out | 24 +++++------ regress/expected/tablespace.out | 38 ++++++++--------- regress/expected/tablespace_1.out | 38 ++++++++--------- regress/expected/tablespace_2.out | 38 ++++++++--------- regress/expected/tablespace_3.out | 38 ++++++++--------- 10 files changed, 142 insertions(+), 142 deletions(-) diff --git a/regress/expected/issue3.out b/regress/expected/issue3.out index ee3e9a7..edb2862 100644 --- a/regress/expected/issue3.out +++ b/regress/expected/issue3.out @@ -10,7 +10,7 @@ SELECT repack.get_order_by('issue3_1_idx'::regclass::oid, 'issue3_1'::regclass:: (1 row) \! pg_repack --dbname=contrib_regression --table=issue3_1 -INFO: repacking table "issue3_1" +INFO: repacking table "public.issue3_1" CREATE TABLE issue3_2 (col1 int NOT NULL, col2 text NOT NULL); CREATE UNIQUE INDEX issue3_2_idx ON issue3_2 (col1 DESC, col2 text_pattern_ops); SELECT repack.get_order_by('issue3_2_idx'::regclass::oid, 'issue3_2'::regclass::oid); @@ -20,7 +20,7 @@ SELECT repack.get_order_by('issue3_2_idx'::regclass::oid, 'issue3_2'::regclass:: (1 row) \! pg_repack --dbname=contrib_regression --table=issue3_2 -INFO: repacking table "issue3_2" +INFO: repacking table "public.issue3_2" CREATE TABLE issue3_3 (col1 int NOT NULL, col2 text NOT NULL); CREATE UNIQUE INDEX issue3_3_idx ON issue3_3 (col1 DESC, col2 DESC); SELECT repack.get_order_by('issue3_3_idx'::regclass::oid, 'issue3_3'::regclass::oid); @@ -30,7 +30,7 @@ SELECT repack.get_order_by('issue3_3_idx'::regclass::oid, 'issue3_3'::regclass:: (1 row) \! pg_repack --dbname=contrib_regression --table=issue3_3 -INFO: repacking table "issue3_3" +INFO: repacking table "public.issue3_3" CREATE TABLE issue3_4 (col1 int NOT NULL, col2 text NOT NULL); CREATE UNIQUE INDEX issue3_4_idx ON issue3_4 (col1 NULLS FIRST, col2 text_pattern_ops DESC NULLS LAST); SELECT repack.get_order_by('issue3_4_idx'::regclass::oid, 'issue3_4'::regclass::oid); @@ -40,7 +40,7 @@ SELECT repack.get_order_by('issue3_4_idx'::regclass::oid, 'issue3_4'::regclass:: (1 row) \! pg_repack --dbname=contrib_regression --table=issue3_4 -INFO: repacking table "issue3_4" +INFO: repacking table "public.issue3_4" CREATE TABLE issue3_5 (col1 int NOT NULL, col2 text NOT NULL); CREATE UNIQUE INDEX issue3_5_idx ON issue3_5 (col1 DESC NULLS FIRST, col2 COLLATE "POSIX" DESC); SELECT repack.get_order_by('issue3_5_idx'::regclass::oid, 'issue3_5'::regclass::oid); @@ -50,4 +50,4 @@ SELECT repack.get_order_by('issue3_5_idx'::regclass::oid, 'issue3_5'::regclass:: (1 row) \! pg_repack --dbname=contrib_regression --table=issue3_5 -INFO: repacking table "issue3_5" +INFO: repacking table "public.issue3_5" diff --git a/regress/expected/nosuper.out b/regress/expected/nosuper.out index b16f4b1..1d2fad2 100644 --- a/regress/expected/nosuper.out +++ b/regress/expected/nosuper.out @@ -7,7 +7,7 @@ SET client_min_messages = warning; CREATE ROLE nosuper WITH LOGIN; -- => OK \! pg_repack --dbname=contrib_regression --table=tbl_cluster --no-superuser-check -INFO: repacking table "tbl_cluster" +INFO: repacking table "public.tbl_cluster" -- => ERROR \! pg_repack --dbname=contrib_regression --table=tbl_cluster --username=nosuper ERROR: pg_repack failed with error: You must be a superuser to use pg_repack diff --git a/regress/expected/nosuper_1.out b/regress/expected/nosuper_1.out index d227516..973ab29 100644 --- a/regress/expected/nosuper_1.out +++ b/regress/expected/nosuper_1.out @@ -7,7 +7,7 @@ SET client_min_messages = warning; CREATE ROLE nosuper WITH LOGIN; -- => OK \! pg_repack --dbname=contrib_regression --table=tbl_cluster --no-superuser-check -INFO: repacking table "tbl_cluster" +INFO: repacking table "public.tbl_cluster" -- => ERROR \! pg_repack --dbname=contrib_regression --table=tbl_cluster --username=nosuper ERROR: pg_repack failed with error: You must be a superuser to use pg_repack diff --git a/regress/expected/repack-check.out b/regress/expected/repack-check.out index 010c920..0da1133 100644 --- a/regress/expected/repack-check.out +++ b/regress/expected/repack-check.out @@ -141,24 +141,24 @@ CREATE TABLE tbl_pk_uk (col1 int NOT NULL, col2 int NOT NULL, PRIMARY KEY(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 --table=tbl_nn -WARNING: relation "tbl_nn" must have a primary key or not-null unique keys +WARNING: relation "public.tbl_nn" must have a primary key or not-null unique keys -- => WARNING \! pg_repack --dbname=contrib_regression --table=tbl_uk -WARNING: relation "tbl_uk" must have a primary key or not-null unique keys +WARNING: relation "public.tbl_uk" must have a primary key or not-null unique keys -- => WARNING \! pg_repack --dbname=contrib_regression --table=tbl_nn_uk -INFO: repacking table "tbl_nn_uk" +INFO: repacking table "public.tbl_nn_uk" -- => OK \! pg_repack --dbname=contrib_regression --table=tbl_pk_uk -INFO: repacking table "tbl_pk_uk" +INFO: repacking table "public.tbl_pk_uk" -- => OK \! pg_repack --dbname=contrib_regression --table=tbl_pk_uk --only-indexes INFO: repacking indexes of "tbl_pk_uk" -INFO: repacking index "public"."tbl_pk_uk_col2_col1_key" -INFO: repacking index "public"."tbl_pk_uk_pkey" +INFO: repacking index "public.tbl_pk_uk_col2_col1_key" +INFO: repacking index "public.tbl_pk_uk_pkey" -- => OK \! pg_repack --dbname=contrib_regression --table=tbl_nn_puk -WARNING: relation "tbl_nn_puk" must have a primary key or not-null unique keys +WARNING: relation "public.tbl_nn_puk" must have a primary key or not-null unique keys -- => WARNING -- -- Triggers handling @@ -169,23 +169,23 @@ LANGUAGE plpgsql; CREATE TABLE trg1 (id integer PRIMARY KEY); CREATE TRIGGER repack_trigger_1 AFTER UPDATE ON trg1 FOR EACH ROW EXECUTE PROCEDURE trgtest(); \! pg_repack --dbname=contrib_regression --table=trg1 -INFO: repacking table "trg1" +INFO: repacking table "public.trg1" CREATE TABLE trg2 (id integer PRIMARY KEY); CREATE TRIGGER repack_trigger AFTER UPDATE ON trg2 FOR EACH ROW EXECUTE PROCEDURE trgtest(); \! pg_repack --dbname=contrib_regression --table=trg2 -INFO: repacking table "trg2" -WARNING: the table "trg2" already has a trigger called "repack_trigger" +INFO: repacking table "public.trg2" +WARNING: the table "public.trg2" already has a trigger called "repack_trigger" DETAIL: The trigger was probably installed during a previous attempt to run pg_repack on the table which was interrupted and for some reason failed to clean up the temporary objects. Please drop the trigger or drop and recreate the pg_repack extension altogether to remove all the temporary objects left over. CREATE TABLE trg3 (id integer PRIMARY KEY); CREATE TRIGGER repack_trigger_1 BEFORE UPDATE ON trg3 FOR EACH ROW EXECUTE PROCEDURE trgtest(); \! pg_repack --dbname=contrib_regression --table=trg3 -INFO: repacking table "trg3" +INFO: repacking table "public.trg3" -- -- Table re-organization using specific column -- -- reorganize table using cluster key. Sort in ascending order. \! pg_repack --dbname=contrib_regression --table=tbl_order -INFO: repacking table "tbl_order" +INFO: repacking table "public.tbl_order" SELECT ctid, c FROM tbl_order WHERE ctid <= '(0,10)'; ctid | c --------+---- @@ -203,7 +203,7 @@ SELECT ctid, c FROM tbl_order WHERE ctid <= '(0,10)'; -- reorganize table using specific column order. Sort in descending order. \! pg_repack --dbname=contrib_regression --table=tbl_order -o "c DESC" -INFO: repacking table "tbl_order" +INFO: repacking table "public.tbl_order" SELECT ctid, c FROM tbl_order WHERE ctid <= '(0,10)'; ctid | c --------+----- @@ -224,7 +224,7 @@ SELECT ctid, c FROM tbl_order WHERE ctid <= '(0,10)'; -- \! pg_repack --dbname=contrib_regression --table=tbl_cluster --dry-run INFO: Dry run enabled, not executing repack -INFO: repacking table "tbl_cluster" +INFO: repacking table "public.tbl_cluster" -- Test --schema -- CREATE SCHEMA test_schema1; @@ -253,7 +253,7 @@ ERROR: cannot repack specific schema(s) in all databases -- don't kill backend -- \! pg_repack --dbname=contrib_regression --table=tbl_cluster --no-kill-backend -INFO: repacking table "tbl_cluster" +INFO: repacking table "public.tbl_cluster" -- -- exclude extension check -- @@ -297,39 +297,39 @@ ERROR: cannot repack specific table(s) in schema, use schema.table notation inst ERROR: cannot repack specific table(s) in all databases -- => OK \! pg_repack --dbname=contrib_regression --table=parent_a --parent-table=parent_b -INFO: repacking table "parent_a" -INFO: repacking table "parent_b" -INFO: repacking table "child_b_1" -INFO: repacking table "child_b_2" +INFO: repacking table "public.child_b_1" +INFO: repacking table "public.child_b_2" +INFO: repacking table "public.parent_a" +INFO: repacking table "public.parent_b" -- => OK \! pg_repack --dbname=contrib_regression --parent-table=parent_a --parent-table=parent_b -INFO: repacking table "parent_a" -INFO: repacking table "child_a_1" -INFO: repacking table "child_a_2" -INFO: repacking table "parent_b" -INFO: repacking table "child_b_1" -INFO: repacking table "child_b_2" +INFO: repacking table "public.child_a_1" +INFO: repacking table "public.child_a_2" +INFO: repacking table "public.child_b_1" +INFO: repacking table "public.child_b_2" +INFO: repacking table "public.parent_a" +INFO: repacking table "public.parent_b" -- => OK \! pg_repack --dbname=contrib_regression --table=parent_a --parent-table=parent_b --only-indexes INFO: repacking indexes of "parent_a" -INFO: repacking index "public"."parent_a_pkey" +INFO: repacking index "public.parent_a_pkey" INFO: repacking indexes of "public.child_b_1" -INFO: repacking index "public"."child_b_1_pkey" +INFO: repacking index "public.child_b_1_pkey" INFO: repacking indexes of "public.child_b_2" -INFO: repacking index "public"."child_b_2_pkey" +INFO: repacking index "public.child_b_2_pkey" INFO: repacking indexes of "public.parent_b" -INFO: repacking index "public"."parent_b_pkey" +INFO: repacking index "public.parent_b_pkey" -- => OK \! pg_repack --dbname=contrib_regression --parent-table=parent_a --parent-table=parent_b --only-indexes INFO: repacking indexes of "public.child_a_1" -INFO: repacking index "public"."child_a_1_pkey" +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 index "public.child_a_2_pkey" INFO: repacking indexes of "public.parent_a" -INFO: repacking index "public"."parent_a_pkey" +INFO: repacking index "public.parent_a_pkey" INFO: repacking indexes of "public.child_b_1" -INFO: repacking index "public"."child_b_1_pkey" +INFO: repacking index "public.child_b_1_pkey" INFO: repacking indexes of "public.child_b_2" -INFO: repacking index "public"."child_b_2_pkey" +INFO: repacking index "public.child_b_2_pkey" INFO: repacking indexes of "public.parent_b" -INFO: repacking index "public"."parent_b_pkey" +INFO: repacking index "public.parent_b_pkey" diff --git a/regress/expected/repack-run.out b/regress/expected/repack-run.out index cd28202..032e47a 100644 --- a/regress/expected/repack-run.out +++ b/regress/expected/repack-run.out @@ -2,19 +2,19 @@ -- do repack -- \! pg_repack --dbname=contrib_regression --table=tbl_cluster -INFO: repacking table "tbl_cluster" +INFO: repacking table "public.tbl_cluster" \! pg_repack --dbname=contrib_regression --table=tbl_badindex -INFO: repacking table "tbl_badindex" +INFO: repacking table "public.tbl_badindex" WARNING: skipping invalid index: CREATE UNIQUE INDEX idx_badindex_n ON tbl_badindex USING btree (n) \! pg_repack --dbname=contrib_regression -INFO: repacking table "tbl_cluster" -INFO: repacking table "tbl_only_pkey" -INFO: repacking table "tbl_gistkey" -INFO: repacking table "tbl_with_dropped_column" -INFO: repacking table "tbl_with_dropped_toast" -INFO: repacking table "tbl_badindex" +INFO: repacking table "public.tbl_badindex" WARNING: skipping invalid index: CREATE UNIQUE INDEX idx_badindex_n ON tbl_badindex USING btree (n) -INFO: repacking table "tbl_idxopts" -INFO: repacking table "tbl_with_toast" -INFO: repacking table "tbl_with_mod_column_storage" -INFO: repacking table "tbl_order" +INFO: repacking table "public.tbl_cluster" +INFO: repacking table "public.tbl_gistkey" +INFO: repacking table "public.tbl_idxopts" +INFO: repacking table "public.tbl_only_pkey" +INFO: repacking table "public.tbl_order" +INFO: repacking table "public.tbl_with_dropped_column" +INFO: repacking table "public.tbl_with_dropped_toast" +INFO: repacking table "public.tbl_with_mod_column_storage" +INFO: repacking table "public.tbl_with_toast" diff --git a/regress/expected/repack-run_1.out b/regress/expected/repack-run_1.out index a15d6b0..54efc7b 100644 --- a/regress/expected/repack-run_1.out +++ b/regress/expected/repack-run_1.out @@ -2,19 +2,19 @@ -- do repack -- \! pg_repack --dbname=contrib_regression --table=tbl_cluster -INFO: repacking table "tbl_cluster" +INFO: repacking table "public.tbl_cluster" \! pg_repack --dbname=contrib_regression --table=tbl_badindex -INFO: repacking table "tbl_badindex" +INFO: repacking table "public.tbl_badindex" WARNING: skipping invalid index: CREATE UNIQUE INDEX idx_badindex_n ON public.tbl_badindex USING btree (n) \! pg_repack --dbname=contrib_regression -INFO: repacking table "tbl_cluster" -INFO: repacking table "tbl_only_pkey" -INFO: repacking table "tbl_gistkey" -INFO: repacking table "tbl_with_dropped_column" -INFO: repacking table "tbl_with_dropped_toast" -INFO: repacking table "tbl_badindex" +INFO: repacking table "public.tbl_badindex" WARNING: skipping invalid index: CREATE UNIQUE INDEX idx_badindex_n ON public.tbl_badindex USING btree (n) -INFO: repacking table "tbl_idxopts" -INFO: repacking table "tbl_with_toast" -INFO: repacking table "tbl_with_mod_column_storage" -INFO: repacking table "tbl_order" +INFO: repacking table "public.tbl_cluster" +INFO: repacking table "public.tbl_gistkey" +INFO: repacking table "public.tbl_idxopts" +INFO: repacking table "public.tbl_only_pkey" +INFO: repacking table "public.tbl_order" +INFO: repacking table "public.tbl_with_dropped_column" +INFO: repacking table "public.tbl_with_dropped_toast" +INFO: repacking table "public.tbl_with_mod_column_storage" +INFO: repacking table "public.tbl_with_toast" diff --git a/regress/expected/tablespace.out b/regress/expected/tablespace.out index d0e7e43..d41b31d 100644 --- a/regress/expected/tablespace.out +++ b/regress/expected/tablespace.out @@ -68,7 +68,7 @@ WHERE indrelid = 'testts1'::regclass ORDER BY relname; -- can move the tablespace from default \! pg_repack --dbname=contrib_regression --no-order --table=testts1 --tablespace testts -INFO: repacking table "testts1" +INFO: repacking table "public.testts1" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' @@ -88,7 +88,7 @@ SELECT * from testts1 order by id; -- tablespace stays where it is \! pg_repack --dbname=contrib_regression --no-order --table=testts1 -INFO: repacking table "testts1" +INFO: repacking table "public.testts1" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' @@ -100,7 +100,7 @@ ORDER BY relname; -- can move the ts back to default \! pg_repack --dbname=contrib_regression --no-order --table=testts1 -s pg_default -INFO: repacking table "testts1" +INFO: repacking table "public.testts1" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' @@ -111,7 +111,7 @@ ORDER BY relname; -- can move the table together with the indexes \! pg_repack --dbname=contrib_regression --no-order --table=testts1 --tablespace testts --moveidx -INFO: repacking table "testts1" +INFO: repacking table "public.testts1" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' @@ -131,13 +131,13 @@ ERROR: cannot specify --moveidx (-S) without --tablespace (-s) ERROR: cannot specify --moveidx (-S) without --tablespace (-s) -- not broken with order \! pg_repack --dbname=contrib_regression -o id --table=testts1 --tablespace pg_default --moveidx -INFO: repacking table "testts1" +INFO: repacking table "public.testts1" --move all indexes of the table to a tablespace \! pg_repack --dbname=contrib_regression --table=testts1 --only-indexes --tablespace=testts INFO: repacking indexes of "testts1" -INFO: repacking index "public"."testts1_partial_idx" -INFO: repacking index "public"."testts1_pkey" -INFO: repacking index "public"."testts1_with_idx" +INFO: repacking index "public.testts1_partial_idx" +INFO: repacking index "public.testts1_pkey" +INFO: repacking index "public.testts1_with_idx" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' @@ -152,9 +152,9 @@ ORDER BY relname; --all indexes of tablespace remain in same tablespace \! pg_repack --dbname=contrib_regression --table=testts1 --only-indexes INFO: repacking indexes of "testts1" -INFO: repacking index "public"."testts1_partial_idx" -INFO: repacking index "public"."testts1_pkey" -INFO: repacking index "public"."testts1_with_idx" +INFO: repacking index "public.testts1_partial_idx" +INFO: repacking index "public.testts1_pkey" +INFO: repacking index "public.testts1_with_idx" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' @@ -169,9 +169,9 @@ ORDER BY relname; --move all indexes of the table to pg_default \! pg_repack --dbname=contrib_regression --table=testts1 --only-indexes --tablespace=pg_default INFO: repacking indexes of "testts1" -INFO: repacking index "public"."testts1_partial_idx" -INFO: repacking index "public"."testts1_pkey" -INFO: repacking index "public"."testts1_with_idx" +INFO: repacking index "public.testts1_partial_idx" +INFO: repacking index "public.testts1_pkey" +INFO: repacking index "public.testts1_with_idx" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' @@ -182,7 +182,7 @@ ORDER BY relname; --move one index to a tablespace \! pg_repack --dbname=contrib_regression --index=testts1_pkey --tablespace=testts -INFO: repacking index "public"."testts1_pkey" +INFO: repacking index "public.testts1_pkey" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' @@ -194,7 +194,7 @@ ORDER BY relname; --index tablespace stays as is \! pg_repack --dbname=contrib_regression --index=testts1_pkey -INFO: repacking index "public"."testts1_pkey" +INFO: repacking index "public.testts1_pkey" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' @@ -206,7 +206,7 @@ ORDER BY relname; --move index to pg_default \! pg_repack --dbname=contrib_regression --index=testts1_pkey --tablespace=pg_default -INFO: repacking index "public"."testts1_pkey" +INFO: repacking index "public.testts1_pkey" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' @@ -217,8 +217,8 @@ ORDER BY relname; --using multiple --index option \! pg_repack --dbname=contrib_regression --index=testts1_pkey --index=testts1_with_idx --tablespace=testts -INFO: repacking index "public"."testts1_pkey" -INFO: repacking index "public"."testts1_with_idx" +INFO: repacking index "public.testts1_pkey" +INFO: repacking index "public.testts1_with_idx" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' diff --git a/regress/expected/tablespace_1.out b/regress/expected/tablespace_1.out index 4f7456a..0256183 100644 --- a/regress/expected/tablespace_1.out +++ b/regress/expected/tablespace_1.out @@ -68,7 +68,7 @@ WHERE indrelid = 'testts1'::regclass ORDER BY relname; -- can move the tablespace from default \! pg_repack --dbname=contrib_regression --no-order --table=testts1 --tablespace testts -INFO: repacking table "testts1" +INFO: repacking table "public.testts1" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' @@ -88,7 +88,7 @@ SELECT * from testts1 order by id; -- tablespace stays where it is \! pg_repack --dbname=contrib_regression --no-order --table=testts1 -INFO: repacking table "testts1" +INFO: repacking table "public.testts1" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' @@ -100,7 +100,7 @@ ORDER BY relname; -- can move the ts back to default \! pg_repack --dbname=contrib_regression --no-order --table=testts1 -s pg_default -INFO: repacking table "testts1" +INFO: repacking table "public.testts1" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' @@ -111,7 +111,7 @@ ORDER BY relname; -- can move the table together with the indexes \! pg_repack --dbname=contrib_regression --no-order --table=testts1 --tablespace testts --moveidx -INFO: repacking table "testts1" +INFO: repacking table "public.testts1" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' @@ -131,13 +131,13 @@ ERROR: cannot specify --moveidx (-S) without --tablespace (-s) ERROR: cannot specify --moveidx (-S) without --tablespace (-s) -- not broken with order \! pg_repack --dbname=contrib_regression -o id --table=testts1 --tablespace pg_default --moveidx -INFO: repacking table "testts1" +INFO: repacking table "public.testts1" --move all indexes of the table to a tablespace \! pg_repack --dbname=contrib_regression --table=testts1 --only-indexes --tablespace=testts INFO: repacking indexes of "testts1" -INFO: repacking index "public"."testts1_partial_idx" -INFO: repacking index "public"."testts1_pkey" -INFO: repacking index "public"."testts1_with_idx" +INFO: repacking index "public.testts1_partial_idx" +INFO: repacking index "public.testts1_pkey" +INFO: repacking index "public.testts1_with_idx" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' @@ -152,9 +152,9 @@ ORDER BY relname; --all indexes of tablespace remain in same tablespace \! pg_repack --dbname=contrib_regression --table=testts1 --only-indexes INFO: repacking indexes of "testts1" -INFO: repacking index "public"."testts1_partial_idx" -INFO: repacking index "public"."testts1_pkey" -INFO: repacking index "public"."testts1_with_idx" +INFO: repacking index "public.testts1_partial_idx" +INFO: repacking index "public.testts1_pkey" +INFO: repacking index "public.testts1_with_idx" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' @@ -169,9 +169,9 @@ ORDER BY relname; --move all indexes of the table to pg_default \! pg_repack --dbname=contrib_regression --table=testts1 --only-indexes --tablespace=pg_default INFO: repacking indexes of "testts1" -INFO: repacking index "public"."testts1_partial_idx" -INFO: repacking index "public"."testts1_pkey" -INFO: repacking index "public"."testts1_with_idx" +INFO: repacking index "public.testts1_partial_idx" +INFO: repacking index "public.testts1_pkey" +INFO: repacking index "public.testts1_with_idx" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' @@ -182,7 +182,7 @@ ORDER BY relname; --move one index to a tablespace \! pg_repack --dbname=contrib_regression --index=testts1_pkey --tablespace=testts -INFO: repacking index "public"."testts1_pkey" +INFO: repacking index "public.testts1_pkey" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' @@ -194,7 +194,7 @@ ORDER BY relname; --index tablespace stays as is \! pg_repack --dbname=contrib_regression --index=testts1_pkey -INFO: repacking index "public"."testts1_pkey" +INFO: repacking index "public.testts1_pkey" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' @@ -206,7 +206,7 @@ ORDER BY relname; --move index to pg_default \! pg_repack --dbname=contrib_regression --index=testts1_pkey --tablespace=pg_default -INFO: repacking index "public"."testts1_pkey" +INFO: repacking index "public.testts1_pkey" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' @@ -217,8 +217,8 @@ ORDER BY relname; --using multiple --index option \! pg_repack --dbname=contrib_regression --index=testts1_pkey --index=testts1_with_idx --tablespace=testts -INFO: repacking index "public"."testts1_pkey" -INFO: repacking index "public"."testts1_with_idx" +INFO: repacking index "public.testts1_pkey" +INFO: repacking index "public.testts1_with_idx" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' diff --git a/regress/expected/tablespace_2.out b/regress/expected/tablespace_2.out index dcc5542..e632960 100644 --- a/regress/expected/tablespace_2.out +++ b/regress/expected/tablespace_2.out @@ -68,7 +68,7 @@ WHERE indrelid = 'testts1'::regclass ORDER BY relname; -- can move the tablespace from default \! pg_repack --dbname=contrib_regression --no-order --table=testts1 --tablespace testts -INFO: repacking table "testts1" +INFO: repacking table "public.testts1" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' @@ -88,7 +88,7 @@ SELECT * from testts1 order by id; -- tablespace stays where it is \! pg_repack --dbname=contrib_regression --no-order --table=testts1 -INFO: repacking table "testts1" +INFO: repacking table "public.testts1" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' @@ -100,7 +100,7 @@ ORDER BY relname; -- can move the ts back to default \! pg_repack --dbname=contrib_regression --no-order --table=testts1 -s pg_default -INFO: repacking table "testts1" +INFO: repacking table "public.testts1" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' @@ -111,7 +111,7 @@ ORDER BY relname; -- can move the table together with the indexes \! pg_repack --dbname=contrib_regression --no-order --table=testts1 --tablespace testts --moveidx -INFO: repacking table "testts1" +INFO: repacking table "public.testts1" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' @@ -131,13 +131,13 @@ ERROR: cannot specify --moveidx (-S) without --tablespace (-s) ERROR: cannot specify --moveidx (-S) without --tablespace (-s) -- not broken with order \! pg_repack --dbname=contrib_regression -o id --table=testts1 --tablespace pg_default --moveidx -INFO: repacking table "testts1" +INFO: repacking table "public.testts1" --move all indexes of the table to a tablespace \! pg_repack --dbname=contrib_regression --table=testts1 --only-indexes --tablespace=testts INFO: repacking indexes of "testts1" -INFO: repacking index "public"."testts1_partial_idx" -INFO: repacking index "public"."testts1_pkey" -INFO: repacking index "public"."testts1_with_idx" +INFO: repacking index "public.testts1_partial_idx" +INFO: repacking index "public.testts1_pkey" +INFO: repacking index "public.testts1_with_idx" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' @@ -152,9 +152,9 @@ ORDER BY relname; --all indexes of tablespace remain in same tablespace \! pg_repack --dbname=contrib_regression --table=testts1 --only-indexes INFO: repacking indexes of "testts1" -INFO: repacking index "public"."testts1_partial_idx" -INFO: repacking index "public"."testts1_pkey" -INFO: repacking index "public"."testts1_with_idx" +INFO: repacking index "public.testts1_partial_idx" +INFO: repacking index "public.testts1_pkey" +INFO: repacking index "public.testts1_with_idx" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' @@ -169,9 +169,9 @@ ORDER BY relname; --move all indexes of the table to pg_default \! pg_repack --dbname=contrib_regression --table=testts1 --only-indexes --tablespace=pg_default INFO: repacking indexes of "testts1" -INFO: repacking index "public"."testts1_partial_idx" -INFO: repacking index "public"."testts1_pkey" -INFO: repacking index "public"."testts1_with_idx" +INFO: repacking index "public.testts1_partial_idx" +INFO: repacking index "public.testts1_pkey" +INFO: repacking index "public.testts1_with_idx" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' @@ -182,7 +182,7 @@ ORDER BY relname; --move one index to a tablespace \! pg_repack --dbname=contrib_regression --index=testts1_pkey --tablespace=testts -INFO: repacking index "public"."testts1_pkey" +INFO: repacking index "public.testts1_pkey" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' @@ -194,7 +194,7 @@ ORDER BY relname; --index tablespace stays as is \! pg_repack --dbname=contrib_regression --index=testts1_pkey -INFO: repacking index "public"."testts1_pkey" +INFO: repacking index "public.testts1_pkey" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' @@ -206,7 +206,7 @@ ORDER BY relname; --move index to pg_default \! pg_repack --dbname=contrib_regression --index=testts1_pkey --tablespace=pg_default -INFO: repacking index "public"."testts1_pkey" +INFO: repacking index "public.testts1_pkey" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' @@ -217,8 +217,8 @@ ORDER BY relname; --using multiple --index option \! pg_repack --dbname=contrib_regression --index=testts1_pkey --index=testts1_with_idx --tablespace=testts -INFO: repacking index "public"."testts1_pkey" -INFO: repacking index "public"."testts1_with_idx" +INFO: repacking index "public.testts1_pkey" +INFO: repacking index "public.testts1_with_idx" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' diff --git a/regress/expected/tablespace_3.out b/regress/expected/tablespace_3.out index ef0424e..bfb9d95 100644 --- a/regress/expected/tablespace_3.out +++ b/regress/expected/tablespace_3.out @@ -68,7 +68,7 @@ WHERE indrelid = 'testts1'::regclass ORDER BY relname; -- can move the tablespace from default \! pg_repack --dbname=contrib_regression --no-order --table=testts1 --tablespace testts -INFO: repacking table "testts1" +INFO: repacking table "public.testts1" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' @@ -88,7 +88,7 @@ SELECT * from testts1 order by id; -- tablespace stays where it is \! pg_repack --dbname=contrib_regression --no-order --table=testts1 -INFO: repacking table "testts1" +INFO: repacking table "public.testts1" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' @@ -100,7 +100,7 @@ ORDER BY relname; -- can move the ts back to default \! pg_repack --dbname=contrib_regression --no-order --table=testts1 -s pg_default -INFO: repacking table "testts1" +INFO: repacking table "public.testts1" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' @@ -111,7 +111,7 @@ ORDER BY relname; -- can move the table together with the indexes \! pg_repack --dbname=contrib_regression --no-order --table=testts1 --tablespace testts --moveidx -INFO: repacking table "testts1" +INFO: repacking table "public.testts1" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' @@ -131,13 +131,13 @@ ERROR: cannot specify --moveidx (-S) without --tablespace (-s) ERROR: cannot specify --moveidx (-S) without --tablespace (-s) -- not broken with order \! pg_repack --dbname=contrib_regression -o id --table=testts1 --tablespace pg_default --moveidx -INFO: repacking table "testts1" +INFO: repacking table "public.testts1" --move all indexes of the table to a tablespace \! pg_repack --dbname=contrib_regression --table=testts1 --only-indexes --tablespace=testts INFO: repacking indexes of "testts1" -INFO: repacking index "public"."testts1_partial_idx" -INFO: repacking index "public"."testts1_pkey" -INFO: repacking index "public"."testts1_with_idx" +INFO: repacking index "public.testts1_partial_idx" +INFO: repacking index "public.testts1_pkey" +INFO: repacking index "public.testts1_with_idx" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' @@ -152,9 +152,9 @@ ORDER BY relname; --all indexes of tablespace remain in same tablespace \! pg_repack --dbname=contrib_regression --table=testts1 --only-indexes INFO: repacking indexes of "testts1" -INFO: repacking index "public"."testts1_partial_idx" -INFO: repacking index "public"."testts1_pkey" -INFO: repacking index "public"."testts1_with_idx" +INFO: repacking index "public.testts1_partial_idx" +INFO: repacking index "public.testts1_pkey" +INFO: repacking index "public.testts1_with_idx" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' @@ -169,9 +169,9 @@ ORDER BY relname; --move all indexes of the table to pg_default \! pg_repack --dbname=contrib_regression --table=testts1 --only-indexes --tablespace=pg_default INFO: repacking indexes of "testts1" -INFO: repacking index "public"."testts1_partial_idx" -INFO: repacking index "public"."testts1_pkey" -INFO: repacking index "public"."testts1_with_idx" +INFO: repacking index "public.testts1_partial_idx" +INFO: repacking index "public.testts1_pkey" +INFO: repacking index "public.testts1_with_idx" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' @@ -182,7 +182,7 @@ ORDER BY relname; --move one index to a tablespace \! pg_repack --dbname=contrib_regression --index=testts1_pkey --tablespace=testts -INFO: repacking index "public"."testts1_pkey" +INFO: repacking index "public.testts1_pkey" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' @@ -194,7 +194,7 @@ ORDER BY relname; --index tablespace stays as is \! pg_repack --dbname=contrib_regression --index=testts1_pkey -INFO: repacking index "public"."testts1_pkey" +INFO: repacking index "public.testts1_pkey" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' @@ -206,7 +206,7 @@ ORDER BY relname; --move index to pg_default \! pg_repack --dbname=contrib_regression --index=testts1_pkey --tablespace=pg_default -INFO: repacking index "public"."testts1_pkey" +INFO: repacking index "public.testts1_pkey" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1' @@ -217,8 +217,8 @@ ORDER BY relname; --using multiple --index option \! pg_repack --dbname=contrib_regression --index=testts1_pkey --index=testts1_with_idx --tablespace=testts -INFO: repacking index "public"."testts1_pkey" -INFO: repacking index "public"."testts1_with_idx" +INFO: repacking index "public.testts1_pkey" +INFO: repacking index "public.testts1_with_idx" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace WHERE relname ~ '^testts1'