diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index 003ae00c..5fb62544 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -34,11 +34,8 @@ jobs: - name: Put pg_repack on PATH run: echo "$PWD/bin" >> $GITHUB_PATH - - name: Create testts directory - run: sudo -u postgres mkdir /tmp/testts - - - name: Create testts tablespace - run: sudo -u postgres psql -c "CREATE TABLESPACE testts LOCATION '/tmp/testts'" + - name: Create tablespaces + run: bash regress/create_tablespaces.sh - name: Test on PostgreSQL ${{ matrix.pg }} run: pg-build-test diff --git a/bin/pg_repack.c b/bin/pg_repack.c index 37b6ae7e..6feae8d7 100644 --- a/bin/pg_repack.c +++ b/bin/pg_repack.c @@ -783,7 +783,7 @@ repack_one_database(const char *orderby, char *errbuf, size_t errsize) "SELECT t.*," " coalesce(v.tablespace, t.tablespace_orig) as tablespace_dest" " FROM repack.tables t, " - " (VALUES (quote_ident($1::text))) as v (tablespace)" + " (VALUES ($1::text)) as v (tablespace)" " WHERE "); params[iparam++] = tablespace; diff --git a/regress/create_tablespaces.sh b/regress/create_tablespaces.sh new file mode 100755 index 00000000..e9e64e34 --- /dev/null +++ b/regress/create_tablespaces.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +sudo -u postgres mkdir /tmp/testts /tmp/1testts /tmp/test\ ts /tmp/test\"ts + +sudo -u postgres psql -c "CREATE TABLESPACE testts LOCATION '/tmp/testts'" +sudo -u postgres psql -c "CREATE TABLESPACE \"1testts\" LOCATION '/tmp/1testts'" +sudo -u postgres psql -c "CREATE TABLESPACE \"test ts\" LOCATION '/tmp/test ts'" +sudo -u postgres psql -c "CREATE TABLESPACE \"test\"\"ts\" LOCATION '/tmp/test\"ts'" diff --git a/regress/expected/tablespace.out b/regress/expected/tablespace.out index 11c7e106..164c6f37 100644 --- a/regress/expected/tablespace.out +++ b/regress/expected/tablespace.out @@ -245,3 +245,48 @@ ORDER BY relname; --using --indexes-only and --index option together \! pg_repack --dbname=contrib_regression --table=testts1 --only-indexes --index=testts1_pkey ERROR: cannot specify --index (-i) and --table (-t) +--check quote_ident() with 1testts tablespace +\! pg_repack --dbname=contrib_regression --table=testts1 --tablespace=1testts --moveidx +INFO: repacking table "public.testts1" +SELECT relname, spcname +FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace +WHERE relname ~ '^testts1' +ORDER BY relname; + relname | spcname +---------------------+--------- + testts1 | 1testts + testts1_partial_idx | 1testts + testts1_pkey | 1testts + testts1_with_idx | 1testts +(4 rows) + +--check quote_ident() with "test ts" tablespace +\! pg_repack --dbname=contrib_regression --table=testts1 --tablespace="test ts" --moveidx +INFO: repacking table "public.testts1" +SELECT relname, spcname +FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace +WHERE relname ~ '^testts1' +ORDER BY relname; + relname | spcname +---------------------+--------- + testts1 | test ts + testts1_partial_idx | test ts + testts1_pkey | test ts + testts1_with_idx | test ts +(4 rows) + +--check quote_ident() with "test""ts" tablespace +\! pg_repack --dbname=contrib_regression --table=testts1 --tablespace="test\"ts" --moveidx +INFO: repacking table "public.testts1" +SELECT relname, spcname +FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace +WHERE relname ~ '^testts1' +ORDER BY relname; + relname | spcname +---------------------+--------- + testts1 | test"ts + testts1_partial_idx | test"ts + testts1_pkey | test"ts + testts1_with_idx | test"ts +(4 rows) + diff --git a/regress/expected/tablespace_1.out b/regress/expected/tablespace_1.out index 4ef2d04a..007dac4f 100644 --- a/regress/expected/tablespace_1.out +++ b/regress/expected/tablespace_1.out @@ -245,3 +245,48 @@ ORDER BY relname; --using --indexes-only and --index option together \! pg_repack --dbname=contrib_regression --table=testts1 --only-indexes --index=testts1_pkey ERROR: cannot specify --index (-i) and --table (-t) +--check quote_ident() with 1testts tablespace +\! pg_repack --dbname=contrib_regression --table=testts1 --tablespace=1testts --moveidx +INFO: repacking table "public.testts1" +SELECT relname, spcname +FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace +WHERE relname ~ '^testts1' +ORDER BY relname; + relname | spcname +---------------------+--------- + testts1 | 1testts + testts1_partial_idx | 1testts + testts1_pkey | 1testts + testts1_with_idx | 1testts +(4 rows) + +--check quote_ident() with "test ts" tablespace +\! pg_repack --dbname=contrib_regression --table=testts1 --tablespace="test ts" --moveidx +INFO: repacking table "public.testts1" +SELECT relname, spcname +FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace +WHERE relname ~ '^testts1' +ORDER BY relname; + relname | spcname +---------------------+--------- + testts1 | test ts + testts1_partial_idx | test ts + testts1_pkey | test ts + testts1_with_idx | test ts +(4 rows) + +--check quote_ident() with "test""ts" tablespace +\! pg_repack --dbname=contrib_regression --table=testts1 --tablespace="test\"ts" --moveidx +INFO: repacking table "public.testts1" +SELECT relname, spcname +FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace +WHERE relname ~ '^testts1' +ORDER BY relname; + relname | spcname +---------------------+--------- + testts1 | test"ts + testts1_partial_idx | test"ts + testts1_pkey | test"ts + testts1_with_idx | test"ts +(4 rows) + diff --git a/regress/expected/tablespace_2.out b/regress/expected/tablespace_2.out index 521f82a6..f5a56a72 100644 --- a/regress/expected/tablespace_2.out +++ b/regress/expected/tablespace_2.out @@ -245,3 +245,48 @@ ORDER BY relname; --using --indexes-only and --index option together \! pg_repack --dbname=contrib_regression --table=testts1 --only-indexes --index=testts1_pkey ERROR: cannot specify --index (-i) and --table (-t) +--check quote_ident() with 1testts tablespace +\! pg_repack --dbname=contrib_regression --table=testts1 --tablespace=1testts --moveidx +INFO: repacking table "public.testts1" +SELECT relname, spcname +FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace +WHERE relname ~ '^testts1' +ORDER BY relname; + relname | spcname +---------------------+--------- + testts1 | 1testts + testts1_partial_idx | 1testts + testts1_pkey | 1testts + testts1_with_idx | 1testts +(4 rows) + +--check quote_ident() with "test ts" tablespace +\! pg_repack --dbname=contrib_regression --table=testts1 --tablespace="test ts" --moveidx +INFO: repacking table "public.testts1" +SELECT relname, spcname +FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace +WHERE relname ~ '^testts1' +ORDER BY relname; + relname | spcname +---------------------+--------- + testts1 | test ts + testts1_partial_idx | test ts + testts1_pkey | test ts + testts1_with_idx | test ts +(4 rows) + +--check quote_ident() with "test""ts" tablespace +\! pg_repack --dbname=contrib_regression --table=testts1 --tablespace="test\"ts" --moveidx +INFO: repacking table "public.testts1" +SELECT relname, spcname +FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace +WHERE relname ~ '^testts1' +ORDER BY relname; + relname | spcname +---------------------+--------- + testts1 | test"ts + testts1_partial_idx | test"ts + testts1_pkey | test"ts + testts1_with_idx | test"ts +(4 rows) + diff --git a/regress/expected/tablespace_3.out b/regress/expected/tablespace_3.out index a3d023c6..4ff1bc43 100644 --- a/regress/expected/tablespace_3.out +++ b/regress/expected/tablespace_3.out @@ -245,3 +245,48 @@ ORDER BY relname; --using --indexes-only and --index option together \! pg_repack --dbname=contrib_regression --table=testts1 --only-indexes --index=testts1_pkey ERROR: cannot specify --index (-i) and --table (-t) +--check quote_ident() with 1testts tablespace +\! pg_repack --dbname=contrib_regression --table=testts1 --tablespace=1testts --moveidx +INFO: repacking table "public.testts1" +SELECT relname, spcname +FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace +WHERE relname ~ '^testts1' +ORDER BY relname; + relname | spcname +---------------------+--------- + testts1 | 1testts + testts1_partial_idx | 1testts + testts1_pkey | 1testts + testts1_with_idx | 1testts +(4 rows) + +--check quote_ident() with "test ts" tablespace +\! pg_repack --dbname=contrib_regression --table=testts1 --tablespace="test ts" --moveidx +INFO: repacking table "public.testts1" +SELECT relname, spcname +FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace +WHERE relname ~ '^testts1' +ORDER BY relname; + relname | spcname +---------------------+--------- + testts1 | test ts + testts1_partial_idx | test ts + testts1_pkey | test ts + testts1_with_idx | test ts +(4 rows) + +--check quote_ident() with "test""ts" tablespace +\! pg_repack --dbname=contrib_regression --table=testts1 --tablespace="test\"ts" --moveidx +INFO: repacking table "public.testts1" +SELECT relname, spcname +FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace +WHERE relname ~ '^testts1' +ORDER BY relname; + relname | spcname +---------------------+--------- + testts1 | test"ts + testts1_partial_idx | test"ts + testts1_pkey | test"ts + testts1_with_idx | test"ts +(4 rows) + diff --git a/regress/expected/tablespace_4.out b/regress/expected/tablespace_4.out index cc6495f8..d9970294 100644 --- a/regress/expected/tablespace_4.out +++ b/regress/expected/tablespace_4.out @@ -245,3 +245,48 @@ ORDER BY relname; --using --indexes-only and --index option together \! pg_repack --dbname=contrib_regression --table=testts1 --only-indexes --index=testts1_pkey ERROR: cannot specify --index (-i) and --table (-t) +--check quote_ident() with 1testts tablespace +\! pg_repack --dbname=contrib_regression --table=testts1 --tablespace=1testts --moveidx +INFO: repacking table "public.testts1" +SELECT relname, spcname +FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace +WHERE relname ~ '^testts1' +ORDER BY relname; + relname | spcname +---------------------+--------- + testts1 | 1testts + testts1_partial_idx | 1testts + testts1_pkey | 1testts + testts1_with_idx | 1testts +(4 rows) + +--check quote_ident() with "test ts" tablespace +\! pg_repack --dbname=contrib_regression --table=testts1 --tablespace="test ts" --moveidx +INFO: repacking table "public.testts1" +SELECT relname, spcname +FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace +WHERE relname ~ '^testts1' +ORDER BY relname; + relname | spcname +---------------------+--------- + testts1 | test ts + testts1_partial_idx | test ts + testts1_pkey | test ts + testts1_with_idx | test ts +(4 rows) + +--check quote_ident() with "test""ts" tablespace +\! pg_repack --dbname=contrib_regression --table=testts1 --tablespace="test\"ts" --moveidx +INFO: repacking table "public.testts1" +SELECT relname, spcname +FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace +WHERE relname ~ '^testts1' +ORDER BY relname; + relname | spcname +---------------------+--------- + testts1 | test"ts + testts1_partial_idx | test"ts + testts1_pkey | test"ts + testts1_with_idx | test"ts +(4 rows) + diff --git a/regress/sql/tablespace.sql b/regress/sql/tablespace.sql index 78790d87..8f770fdf 100644 --- a/regress/sql/tablespace.sql +++ b/regress/sql/tablespace.sql @@ -147,3 +147,27 @@ ORDER BY relname; --using --indexes-only and --index option together \! pg_repack --dbname=contrib_regression --table=testts1 --only-indexes --index=testts1_pkey + +--check quote_ident() with 1testts tablespace +\! pg_repack --dbname=contrib_regression --table=testts1 --tablespace=1testts --moveidx + +SELECT relname, spcname +FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace +WHERE relname ~ '^testts1' +ORDER BY relname; + +--check quote_ident() with "test ts" tablespace +\! pg_repack --dbname=contrib_regression --table=testts1 --tablespace="test ts" --moveidx + +SELECT relname, spcname +FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace +WHERE relname ~ '^testts1' +ORDER BY relname; + +--check quote_ident() with "test""ts" tablespace +\! pg_repack --dbname=contrib_regression --table=testts1 --tablespace="test\"ts" --moveidx + +SELECT relname, spcname +FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace +WHERE relname ~ '^testts1' +ORDER BY relname;