Skip to content

Commit

Permalink
Issue 386: Do not call quote_ident() within repack_one_database()
Browse files Browse the repository at this point in the history
  • Loading branch information
za-arthur committed Mar 11, 2024
1 parent 6a3c282 commit f0a6e5b
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/regression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,14 @@ jobs:
run: echo "$PWD/bin" >> $GITHUB_PATH

- name: Create testts directory
run: sudo -u postgres mkdir /tmp/testts
run: sudo -u postgres mkdir /tmp/testts /tmp/1testts

- name: Create testts tablespace
run: sudo -u postgres psql -c "CREATE TABLESPACE testts LOCATION '/tmp/testts'"

- name: Create 1testts tablespace
run: sudo -u postgres psql -c "CREATE TABLESPACE 1testts LOCATION '/tmp/1testts'"

- 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
15 changes: 15 additions & 0 deletions regress/expected/tablespace.out
Original file line number Diff line number Diff line change
Expand Up @@ -245,3 +245,18 @@ 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)

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

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

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

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

8 changes: 8 additions & 0 deletions regress/sql/tablespace.sql
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,11 @@ 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;

0 comments on commit f0a6e5b

Please sign in to comment.