|
| 1 | +SET client_min_messages = warning; |
| 2 | +-- |
| 3 | +-- Tablespace features tests |
| 4 | +-- |
| 5 | +-- Note: in order to pass this test you must create a tablespace called 'testts' |
| 6 | +-- |
| 7 | +SELECT spcname FROM pg_tablespace WHERE spcname = 'testts'; |
| 8 | + spcname |
| 9 | +--------- |
| 10 | + testts |
| 11 | +(1 row) |
| 12 | + |
| 13 | +-- If the query above failed you must create the 'testts' tablespace; |
| 14 | +CREATE TABLE testts1 (id serial primary key, data text); |
| 15 | +INSERT INTO testts1 (data) values ('a'); |
| 16 | +INSERT INTO testts1 (data) values ('b'); |
| 17 | +INSERT INTO testts1 (data) values ('c'); |
| 18 | +-- can move the tablespace from default |
| 19 | +\! pg_repack --dbname=contrib_regression --no-order --table=testts1 --tablespace testts |
| 20 | +SELECT relname, spcname |
| 21 | +FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace |
| 22 | +WHERE relname ~ '^testts1'; |
| 23 | + relname | spcname |
| 24 | +---------+--------- |
| 25 | + testts1 | testts |
| 26 | +(1 row) |
| 27 | + |
| 28 | +SELECT * from testts1 order by id; |
| 29 | + id | data |
| 30 | +----+------ |
| 31 | + 1 | a |
| 32 | + 2 | b |
| 33 | + 3 | c |
| 34 | +(3 rows) |
| 35 | + |
| 36 | +-- tablespace stays where it is |
| 37 | +\! pg_repack --dbname=contrib_regression --no-order --table=testts1 |
| 38 | +SELECT relname, spcname |
| 39 | +FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace |
| 40 | +WHERE relname ~ '^testts1'; |
| 41 | + relname | spcname |
| 42 | +---------+--------- |
| 43 | + testts1 | testts |
| 44 | +(1 row) |
| 45 | + |
| 46 | +-- can move the ts back to default |
| 47 | +\! pg_repack --dbname=contrib_regression --no-order --table=testts1 -s pg_default |
| 48 | +SELECT relname, spcname |
| 49 | +FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace |
| 50 | +WHERE relname ~ '^testts1'; |
| 51 | + relname | spcname |
| 52 | +---------+--------- |
| 53 | +(0 rows) |
| 54 | + |
| 55 | +-- can move the table together with the indexes |
| 56 | +\! pg_repack --dbname=contrib_regression --no-order --table=testts1 --tablespace pg_default --moveidx |
| 57 | +SELECT relname, spcname |
| 58 | +FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace |
| 59 | +WHERE relname ~ '^testts1'; |
| 60 | + relname | spcname |
| 61 | +--------------+--------- |
| 62 | + testts1 | testts |
| 63 | + testts1_pkey | testts |
| 64 | +(2 rows) |
| 65 | + |
| 66 | +-- can't specify --moveidx without --tablespace |
| 67 | +\! pg_repack --dbname=contrib_regression --no-order --table=testts1 --moveidx |
| 68 | +ERROR: cannot specify --moveidx (-S) without --tablespace (-s) |
| 69 | +\! pg_repack --dbname=contrib_regression --no-order --table=testts1 -S |
| 70 | +ERROR: cannot specify --moveidx (-S) without --tablespace (-s) |
0 commit comments