Regression tests for the new indexes-repacking features.
Patch from Beena Emerson.
This commit is contained in:
parent
3f7a05162f
commit
03015f8ee8
@ -42,6 +42,30 @@ WHERE indrelid = 'testts1'::regclass ORDER BY relname;
|
|||||||
CREATE INDEX index_OID ON repack.table_OID USING btree (id) WITH (fillfactor=80) TABLESPACE foo
|
CREATE INDEX index_OID ON repack.table_OID USING btree (id) WITH (fillfactor=80) TABLESPACE foo
|
||||||
(3 rows)
|
(3 rows)
|
||||||
|
|
||||||
|
SELECT regexp_replace(
|
||||||
|
repack.repack_indexdef(indexrelid, 'testts1'::regclass, NULL, true),
|
||||||
|
'_[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) WHERE (id > 0)
|
||||||
|
CREATE UNIQUE INDEX CONCURRENTLY index_OID ON testts1 USING btree (id)
|
||||||
|
CREATE INDEX CONCURRENTLY index_OID ON testts1 USING btree (id) WITH (fillfactor=80)
|
||||||
|
(3 rows)
|
||||||
|
|
||||||
|
SELECT regexp_replace(
|
||||||
|
repack.repack_indexdef(indexrelid, 'testts1'::regclass, 'foo', true),
|
||||||
|
'_[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
|
||||||
|
(3 rows)
|
||||||
|
|
||||||
-- can move the tablespace from default
|
-- can move the tablespace from default
|
||||||
\! pg_repack --dbname=contrib_regression --no-order --table=testts1 --tablespace testts
|
\! pg_repack --dbname=contrib_regression --no-order --table=testts1 --tablespace testts
|
||||||
INFO: repacking table "testts1"
|
INFO: repacking table "testts1"
|
||||||
@ -108,3 +132,94 @@ ERROR: cannot specify --moveidx (-S) without --tablespace (-s)
|
|||||||
-- not broken with order
|
-- not broken with order
|
||||||
\! pg_repack --dbname=contrib_regression -o id --table=testts1 --tablespace pg_default --moveidx
|
\! pg_repack --dbname=contrib_regression -o id --table=testts1 --tablespace pg_default --moveidx
|
||||||
INFO: repacking table "testts1"
|
INFO: repacking table "testts1"
|
||||||
|
--move all indexes of the table to a tablespace
|
||||||
|
\! pg_repack --dbname=contrib_regression --table=testts1 --only-indexes --tablespace=testts
|
||||||
|
INFO: repacking indexes of "testts1"
|
||||||
|
SELECT relname, spcname
|
||||||
|
FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace
|
||||||
|
WHERE relname ~ '^testts1'
|
||||||
|
ORDER BY relname;
|
||||||
|
relname | spcname
|
||||||
|
---------------------+---------
|
||||||
|
testts1_partial_idx | testts
|
||||||
|
testts1_pkey | testts
|
||||||
|
testts1_with_idx | testts
|
||||||
|
(3 rows)
|
||||||
|
|
||||||
|
--all indexes of tablespace remain in same tablespace
|
||||||
|
\! pg_repack --dbname=contrib_regression --table=testts1 --only-indexes
|
||||||
|
INFO: repacking indexes of "testts1"
|
||||||
|
SELECT relname, spcname
|
||||||
|
FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace
|
||||||
|
WHERE relname ~ '^testts1'
|
||||||
|
ORDER BY relname;
|
||||||
|
relname | spcname
|
||||||
|
---------------------+---------
|
||||||
|
testts1_partial_idx | testts
|
||||||
|
testts1_pkey | testts
|
||||||
|
testts1_with_idx | testts
|
||||||
|
(3 rows)
|
||||||
|
|
||||||
|
--move all indexes of the table to pg_default
|
||||||
|
\! pg_repack --dbname=contrib_regression --table=testts1 --only-indexes --tablespace=pg_default
|
||||||
|
INFO: repacking indexes of "testts1"
|
||||||
|
SELECT relname, spcname
|
||||||
|
FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace
|
||||||
|
WHERE relname ~ '^testts1'
|
||||||
|
ORDER BY relname;
|
||||||
|
relname | spcname
|
||||||
|
---------+---------
|
||||||
|
(0 rows)
|
||||||
|
|
||||||
|
--move one index to a tablespace
|
||||||
|
\! pg_repack --dbname=contrib_regression --index=testts1_pkey --tablespace=testts
|
||||||
|
INFO: repacking "testts1_pkey"
|
||||||
|
SELECT relname, spcname
|
||||||
|
FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace
|
||||||
|
WHERE relname ~ '^testts1'
|
||||||
|
ORDER BY relname;
|
||||||
|
relname | spcname
|
||||||
|
--------------+---------
|
||||||
|
testts1_pkey | testts
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
--index tablespace stays as is
|
||||||
|
\! pg_repack --dbname=contrib_regression --index=testts1_pkey
|
||||||
|
INFO: repacking "testts1_pkey"
|
||||||
|
SELECT relname, spcname
|
||||||
|
FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace
|
||||||
|
WHERE relname ~ '^testts1'
|
||||||
|
ORDER BY relname;
|
||||||
|
relname | spcname
|
||||||
|
--------------+---------
|
||||||
|
testts1_pkey | testts
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
--move index to pg_default
|
||||||
|
\! pg_repack --dbname=contrib_regression --index=testts1_pkey --tablespace=pg_default
|
||||||
|
INFO: repacking "testts1_pkey"
|
||||||
|
SELECT relname, spcname
|
||||||
|
FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace
|
||||||
|
WHERE relname ~ '^testts1'
|
||||||
|
ORDER BY relname;
|
||||||
|
relname | spcname
|
||||||
|
---------+---------
|
||||||
|
(0 rows)
|
||||||
|
|
||||||
|
--using multiple --index option
|
||||||
|
\! pg_repack --dbname=contrib_regression --index=testts1_pkey --index=testts1_with_idx --tablespace=testts
|
||||||
|
INFO: repacking "testts1_pkey"
|
||||||
|
INFO: repacking "testts1_with_idx"
|
||||||
|
SELECT relname, spcname
|
||||||
|
FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace
|
||||||
|
WHERE relname ~ '^testts1'
|
||||||
|
ORDER BY relname;
|
||||||
|
relname | spcname
|
||||||
|
------------------+---------
|
||||||
|
testts1_pkey | testts
|
||||||
|
testts1_with_idx | testts
|
||||||
|
(2 rows)
|
||||||
|
|
||||||
|
--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)
|
||||||
|
@ -29,6 +29,18 @@ SELECT regexp_replace(
|
|||||||
FROM pg_index i join pg_class c ON c.oid = indexrelid
|
FROM pg_index i join pg_class c ON c.oid = indexrelid
|
||||||
WHERE indrelid = 'testts1'::regclass ORDER BY relname;
|
WHERE indrelid = 'testts1'::regclass ORDER BY relname;
|
||||||
|
|
||||||
|
SELECT regexp_replace(
|
||||||
|
repack.repack_indexdef(indexrelid, 'testts1'::regclass, NULL, true),
|
||||||
|
'_[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),
|
||||||
|
'_[0-9]+', '_OID', 'g')
|
||||||
|
FROM pg_index i join pg_class c ON c.oid = indexrelid
|
||||||
|
WHERE indrelid = 'testts1'::regclass ORDER BY relname;
|
||||||
|
|
||||||
-- can move the tablespace from default
|
-- can move the tablespace from default
|
||||||
\! pg_repack --dbname=contrib_regression --no-order --table=testts1 --tablespace testts
|
\! pg_repack --dbname=contrib_regression --no-order --table=testts1 --tablespace testts
|
||||||
|
|
||||||
@ -69,3 +81,62 @@ ORDER BY relname;
|
|||||||
|
|
||||||
-- not broken with order
|
-- not broken with order
|
||||||
\! pg_repack --dbname=contrib_regression -o id --table=testts1 --tablespace pg_default --moveidx
|
\! pg_repack --dbname=contrib_regression -o id --table=testts1 --tablespace pg_default --moveidx
|
||||||
|
|
||||||
|
--move all indexes of the table to a tablespace
|
||||||
|
\! pg_repack --dbname=contrib_regression --table=testts1 --only-indexes --tablespace=testts
|
||||||
|
|
||||||
|
SELECT relname, spcname
|
||||||
|
FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace
|
||||||
|
WHERE relname ~ '^testts1'
|
||||||
|
ORDER BY relname;
|
||||||
|
|
||||||
|
--all indexes of tablespace remain in same tablespace
|
||||||
|
\! pg_repack --dbname=contrib_regression --table=testts1 --only-indexes
|
||||||
|
|
||||||
|
SELECT relname, spcname
|
||||||
|
FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace
|
||||||
|
WHERE relname ~ '^testts1'
|
||||||
|
ORDER BY relname;
|
||||||
|
|
||||||
|
--move all indexes of the table to pg_default
|
||||||
|
\! pg_repack --dbname=contrib_regression --table=testts1 --only-indexes --tablespace=pg_default
|
||||||
|
|
||||||
|
SELECT relname, spcname
|
||||||
|
FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace
|
||||||
|
WHERE relname ~ '^testts1'
|
||||||
|
ORDER BY relname;
|
||||||
|
|
||||||
|
--move one index to a tablespace
|
||||||
|
\! pg_repack --dbname=contrib_regression --index=testts1_pkey --tablespace=testts
|
||||||
|
|
||||||
|
SELECT relname, spcname
|
||||||
|
FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace
|
||||||
|
WHERE relname ~ '^testts1'
|
||||||
|
ORDER BY relname;
|
||||||
|
|
||||||
|
--index tablespace stays as is
|
||||||
|
\! pg_repack --dbname=contrib_regression --index=testts1_pkey
|
||||||
|
|
||||||
|
SELECT relname, spcname
|
||||||
|
FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace
|
||||||
|
WHERE relname ~ '^testts1'
|
||||||
|
ORDER BY relname;
|
||||||
|
|
||||||
|
--move index to pg_default
|
||||||
|
\! pg_repack --dbname=contrib_regression --index=testts1_pkey --tablespace=pg_default
|
||||||
|
|
||||||
|
SELECT relname, spcname
|
||||||
|
FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace
|
||||||
|
WHERE relname ~ '^testts1'
|
||||||
|
ORDER BY relname;
|
||||||
|
|
||||||
|
--using multiple --index option
|
||||||
|
\! pg_repack --dbname=contrib_regression --index=testts1_pkey --index=testts1_with_idx --tablespace=testts
|
||||||
|
|
||||||
|
SELECT relname, spcname
|
||||||
|
FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace
|
||||||
|
WHERE relname ~ '^testts1'
|
||||||
|
ORDER BY relname;
|
||||||
|
|
||||||
|
--using --indexes-only and --index option together
|
||||||
|
\! pg_repack --dbname=contrib_regression --table=testts1 --only-indexes --index=testts1_pkey
|
||||||
|
Loading…
x
Reference in New Issue
Block a user