Skip to content

Commit

Permalink
Fix failing tablespace tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziomello committed Oct 2, 2023
1 parent 6263dd5 commit b34e6de
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 24 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/regression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
Expand All @@ -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

44 changes: 25 additions & 19 deletions regress/expected/tablespace.out
Original file line number Diff line number Diff line change
Expand Up @@ -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
---------
Expand All @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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;
16 changes: 12 additions & 4 deletions regress/sql/tablespace.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;

0 comments on commit b34e6de

Please sign in to comment.