Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 386: Do not call quote_ident() within repack_one_database() #387

Merged
merged 3 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .github/workflows/regression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bin/pg_repack.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions regress/create_tablespaces.sh
Original file line number Diff line number Diff line change
@@ -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'"
45 changes: 45 additions & 0 deletions regress/expected/tablespace.out
Original file line number Diff line number Diff line change
Expand Up @@ -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)

45 changes: 45 additions & 0 deletions regress/expected/tablespace_1.out
Original file line number Diff line number Diff line change
Expand Up @@ -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)

45 changes: 45 additions & 0 deletions regress/expected/tablespace_2.out
Original file line number Diff line number Diff line change
Expand Up @@ -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)

45 changes: 45 additions & 0 deletions regress/expected/tablespace_3.out
Original file line number Diff line number Diff line change
Expand Up @@ -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)

45 changes: 45 additions & 0 deletions regress/expected/tablespace_4.out
Original file line number Diff line number Diff line change
Expand Up @@ -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)

24 changes: 24 additions & 0 deletions regress/sql/tablespace.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Loading