From b34e6debb994c49047f92d2257b1b843e6bb4e0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabr=C3=ADzio=20de=20Royes=20Mello?= Date: Mon, 31 Oct 2022 11:26:42 -0300 Subject: [PATCH] Fix failing tablespace tests. --- .github/workflows/regression.yml | 9 ++++++- regress/expected/tablespace.out | 44 ++++++++++++++++++-------------- regress/sql/tablespace.sql | 16 +++++++++--- 3 files changed, 45 insertions(+), 24 deletions(-) diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index 812c5a1e..116b58fe 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -33,7 +33,7 @@ jobs: run: echo "$PWD/bin" >> $GITHUB_PATH - name: Create testts directory - run: sudo -u postgres mkdir /tmp/testts + run: sudo -u postgres mkdir -p /tmp/testts && chmod 0700 /tmp/testts - name: Create testts tablespace run: sudo -u postgres psql -c "CREATE TABLESPACE testts LOCATION '/tmp/testts'" @@ -44,3 +44,10 @@ jobs: - name: Show regression.diffs if: ${{ failure() }} run: cat regress/regression.diffs + + - name: Remove tests tablespace + run: sudo -u postgres psql -c "DROP TABLESPACE testts" + + - name: Remove testts directory + run: sudo -u postgres rm -rf /tmp/testts + diff --git a/regress/expected/tablespace.out b/regress/expected/tablespace.out index d41b31d9..ac09e0d1 100644 --- a/regress/expected/tablespace.out +++ b/regress/expected/tablespace.out @@ -4,6 +4,10 @@ SET client_min_messages = warning; -- -- Note: in order to pass this test you must create a tablespace called 'testts' -- +-- Test tablespace creation example: +-- $ sudo -u postgres mkdir -p /tmp/testts && chmod 0700 /tmp/testts +-- $ sudo -u postgres psql -c "CREATE TABLESPACE testts LOCATION '/tmp/testts'" +-- SELECT spcname FROM pg_tablespace WHERE spcname = 'testts'; spcname --------- @@ -19,19 +23,19 @@ INSERT INTO testts1 (data) values ('b'); INSERT INTO testts1 (data) values ('c'); -- check the indexes definitions SELECT regexp_replace( - repack.repack_indexdef(indexrelid, 'testts1'::regclass, NULL, false), + replace(repack.repack_indexdef(indexrelid, 'testts1'::regclass, NULL, false), ' TABLESPACE pg_default', ''), '_[0-9]+', '_OID', 'g') FROM pg_index i join pg_class c ON c.oid = indexrelid WHERE indrelid = 'testts1'::regclass ORDER BY relname; - regexp_replace ----------------------------------------------------------------------------------------------------------- - CREATE INDEX index_OID ON repack.table_OID USING btree (id) TABLESPACE pg_default WHERE (id > 0) - CREATE UNIQUE INDEX index_OID ON repack.table_OID USING btree (id) TABLESPACE pg_default - CREATE INDEX index_OID ON repack.table_OID USING btree (id) WITH (fillfactor='80') TABLESPACE pg_default + regexp_replace +------------------------------------------------------------------------------------ + CREATE INDEX index_OID ON repack.table_OID USING btree (id) WHERE (id > 0) + CREATE UNIQUE INDEX index_OID ON repack.table_OID USING btree (id) + CREATE INDEX index_OID ON repack.table_OID USING btree (id) WITH (fillfactor='80') (3 rows) SELECT regexp_replace( - repack.repack_indexdef(indexrelid, 'testts1'::regclass, 'foo', false), + replace(repack.repack_indexdef(indexrelid, 'testts1'::regclass, 'foo', false), ' TABLESPACE pg_default', ''), '_[0-9]+', '_OID', 'g') FROM pg_index i join pg_class c ON c.oid = indexrelid WHERE indrelid = 'testts1'::regclass ORDER BY relname; @@ -43,27 +47,27 @@ WHERE indrelid = 'testts1'::regclass ORDER BY relname; (3 rows) SELECT regexp_replace( - repack.repack_indexdef(indexrelid, 'testts1'::regclass, NULL, true), + replace(repack.repack_indexdef(indexrelid, 'testts1'::regclass, NULL, true), ' TABLESPACE pg_default', ''), '_[0-9]+', '_OID', 'g') FROM pg_index i join pg_class c ON c.oid = indexrelid WHERE indrelid = 'testts1'::regclass ORDER BY relname; - regexp_replace --------------------------------------------------------------------------------------------------------------- - CREATE INDEX CONCURRENTLY index_OID ON testts1 USING btree (id) TABLESPACE pg_default WHERE (id > 0) - CREATE UNIQUE INDEX CONCURRENTLY index_OID ON testts1 USING btree (id) TABLESPACE pg_default - CREATE INDEX CONCURRENTLY index_OID ON testts1 USING btree (id) WITH (fillfactor='80') TABLESPACE pg_default + regexp_replace +----------------------------------------------------------------------------------------------- + CREATE INDEX CONCURRENTLY index_OID ON public.testts1 USING btree (id) WHERE (id > 0) + CREATE UNIQUE INDEX CONCURRENTLY index_OID ON public.testts1 USING btree (id) + CREATE INDEX CONCURRENTLY index_OID ON public.testts1 USING btree (id) WITH (fillfactor='80') (3 rows) SELECT regexp_replace( - repack.repack_indexdef(indexrelid, 'testts1'::regclass, 'foo', true), + replace(repack.repack_indexdef(indexrelid, 'testts1'::regclass, 'foo', true), ' TABLESPACE pg_default', ''), '_[0-9]+', '_OID', 'g') FROM pg_index i join pg_class c ON c.oid = indexrelid WHERE indrelid = 'testts1'::regclass ORDER BY relname; - regexp_replace -------------------------------------------------------------------------------------------------------- - CREATE INDEX CONCURRENTLY index_OID ON testts1 USING btree (id) TABLESPACE foo WHERE (id > 0) - CREATE UNIQUE INDEX CONCURRENTLY index_OID ON testts1 USING btree (id) TABLESPACE foo - CREATE INDEX CONCURRENTLY index_OID ON testts1 USING btree (id) WITH (fillfactor='80') TABLESPACE foo + regexp_replace +-------------------------------------------------------------------------------------------------------------- + CREATE INDEX CONCURRENTLY index_OID ON public.testts1 USING btree (id) TABLESPACE foo WHERE (id > 0) + CREATE UNIQUE INDEX CONCURRENTLY index_OID ON public.testts1 USING btree (id) TABLESPACE foo + CREATE INDEX CONCURRENTLY index_OID ON public.testts1 USING btree (id) WITH (fillfactor='80') TABLESPACE foo (3 rows) -- can move the tablespace from default @@ -232,3 +236,5 @@ 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) +-- cleanup +DROP TABLE testts1; diff --git a/regress/sql/tablespace.sql b/regress/sql/tablespace.sql index 916d1330..dbac5c0c 100644 --- a/regress/sql/tablespace.sql +++ b/regress/sql/tablespace.sql @@ -5,6 +5,10 @@ SET client_min_messages = warning; -- -- Note: in order to pass this test you must create a tablespace called 'testts' -- +-- Test tablespace creation example: +-- $ sudo -u postgres mkdir -p /tmp/testts && chmod 0700 /tmp/testts +-- $ sudo -u postgres psql -c "CREATE TABLESPACE testts LOCATION '/tmp/testts'" +-- SELECT spcname FROM pg_tablespace WHERE spcname = 'testts'; -- If the query above failed you must create the 'testts' tablespace; @@ -18,25 +22,25 @@ INSERT INTO testts1 (data) values ('c'); -- check the indexes definitions SELECT regexp_replace( - repack.repack_indexdef(indexrelid, 'testts1'::regclass, NULL, false), + replace(repack.repack_indexdef(indexrelid, 'testts1'::regclass, NULL, false), ' TABLESPACE pg_default', ''), '_[0-9]+', '_OID', 'g') FROM pg_index i join pg_class c ON c.oid = indexrelid WHERE indrelid = 'testts1'::regclass ORDER BY relname; SELECT regexp_replace( - repack.repack_indexdef(indexrelid, 'testts1'::regclass, 'foo', false), + replace(repack.repack_indexdef(indexrelid, 'testts1'::regclass, 'foo', false), ' TABLESPACE pg_default', ''), '_[0-9]+', '_OID', 'g') FROM pg_index i join pg_class c ON c.oid = indexrelid WHERE indrelid = 'testts1'::regclass ORDER BY relname; SELECT regexp_replace( - repack.repack_indexdef(indexrelid, 'testts1'::regclass, NULL, true), + replace(repack.repack_indexdef(indexrelid, 'testts1'::regclass, NULL, true), ' TABLESPACE pg_default', ''), '_[0-9]+', '_OID', 'g') FROM pg_index i join pg_class c ON c.oid = indexrelid WHERE indrelid = 'testts1'::regclass ORDER BY relname; SELECT regexp_replace( - repack.repack_indexdef(indexrelid, 'testts1'::regclass, 'foo', true), + replace(repack.repack_indexdef(indexrelid, 'testts1'::regclass, 'foo', true), ' TABLESPACE pg_default', ''), '_[0-9]+', '_OID', 'g') FROM pg_index i join pg_class c ON c.oid = indexrelid WHERE indrelid = 'testts1'::regclass ORDER BY relname; @@ -140,3 +144,7 @@ ORDER BY relname; --using --indexes-only and --index option together \! pg_repack --dbname=contrib_regression --table=testts1 --only-indexes --index=testts1_pkey + +-- cleanup +DROP TABLE testts1; +