2013-04-16 18:33:23 +01:00
|
|
|
SET client_min_messages = warning;
|
|
|
|
--
|
|
|
|
-- Tablespace features tests
|
|
|
|
--
|
|
|
|
-- Note: in order to pass this test you must create a tablespace called 'testts'
|
|
|
|
--
|
|
|
|
SELECT spcname FROM pg_tablespace WHERE spcname = 'testts';
|
|
|
|
spcname
|
|
|
|
---------
|
|
|
|
testts
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
-- If the query above failed you must create the 'testts' tablespace;
|
|
|
|
CREATE TABLE testts1 (id serial primary key, data text);
|
2013-04-16 23:23:26 +01:00
|
|
|
CREATE INDEX testts1_partial_idx on testts1 (id) where (id > 0);
|
2013-04-16 18:33:23 +01:00
|
|
|
INSERT INTO testts1 (data) values ('a');
|
|
|
|
INSERT INTO testts1 (data) values ('b');
|
|
|
|
INSERT INTO testts1 (data) values ('c');
|
|
|
|
-- can move the tablespace from default
|
|
|
|
\! pg_repack --dbname=contrib_regression --no-order --table=testts1 --tablespace testts
|
2013-04-17 17:48:05 +01:00
|
|
|
INFO: repacking table "testts1"
|
2013-04-16 18:33:23 +01:00
|
|
|
SELECT relname, spcname
|
|
|
|
FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace
|
2013-04-16 23:23:26 +01:00
|
|
|
WHERE relname ~ '^testts1'
|
|
|
|
ORDER BY relname;
|
2013-04-16 18:33:23 +01:00
|
|
|
relname | spcname
|
|
|
|
---------+---------
|
|
|
|
testts1 | testts
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT * from testts1 order by id;
|
|
|
|
id | data
|
|
|
|
----+------
|
|
|
|
1 | a
|
|
|
|
2 | b
|
|
|
|
3 | c
|
|
|
|
(3 rows)
|
|
|
|
|
|
|
|
-- tablespace stays where it is
|
|
|
|
\! pg_repack --dbname=contrib_regression --no-order --table=testts1
|
2013-04-17 17:48:05 +01:00
|
|
|
INFO: repacking table "testts1"
|
2013-04-16 18:33:23 +01:00
|
|
|
SELECT relname, spcname
|
|
|
|
FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace
|
2013-04-16 23:23:26 +01:00
|
|
|
WHERE relname ~ '^testts1'
|
|
|
|
ORDER BY relname;
|
2013-04-16 18:33:23 +01:00
|
|
|
relname | spcname
|
|
|
|
---------+---------
|
|
|
|
testts1 | testts
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
-- can move the ts back to default
|
|
|
|
\! pg_repack --dbname=contrib_regression --no-order --table=testts1 -s pg_default
|
2013-04-17 17:48:05 +01:00
|
|
|
INFO: repacking table "testts1"
|
2013-04-16 18:33:23 +01:00
|
|
|
SELECT relname, spcname
|
|
|
|
FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace
|
2013-04-16 23:23:26 +01:00
|
|
|
WHERE relname ~ '^testts1'
|
|
|
|
ORDER BY relname;
|
2013-04-16 18:33:23 +01:00
|
|
|
relname | spcname
|
|
|
|
---------+---------
|
|
|
|
(0 rows)
|
|
|
|
|
|
|
|
-- can move the table together with the indexes
|
2013-04-16 19:14:49 +01:00
|
|
|
\! pg_repack --dbname=contrib_regression --no-order --table=testts1 --tablespace testts --moveidx
|
2013-04-17 17:48:05 +01:00
|
|
|
INFO: repacking table "testts1"
|
2013-04-16 18:33:23 +01:00
|
|
|
SELECT relname, spcname
|
|
|
|
FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace
|
2013-04-16 23:23:26 +01:00
|
|
|
WHERE relname ~ '^testts1'
|
|
|
|
ORDER BY relname;
|
|
|
|
relname | spcname
|
|
|
|
---------------------+---------
|
|
|
|
testts1 | testts
|
|
|
|
testts1_partial_idx | testts
|
|
|
|
testts1_pkey | testts
|
|
|
|
(3 rows)
|
2013-04-16 18:33:23 +01:00
|
|
|
|
|
|
|
-- can't specify --moveidx without --tablespace
|
|
|
|
\! pg_repack --dbname=contrib_regression --no-order --table=testts1 --moveidx
|
|
|
|
ERROR: cannot specify --moveidx (-S) without --tablespace (-s)
|
|
|
|
\! pg_repack --dbname=contrib_regression --no-order --table=testts1 -S
|
|
|
|
ERROR: cannot specify --moveidx (-S) without --tablespace (-s)
|
2013-04-22 11:16:28 +01:00
|
|
|
-- not broken with order
|
|
|
|
\! pg_repack --dbname=contrib_regression -o id --table=testts1 --tablespace pg_default --moveidx
|
|
|
|
INFO: repacking table "testts1"
|