Added tests for the namespace change feature
Currently not passing as --moveidx not implemented yet.
This commit is contained in:
parent
6488ecabd2
commit
c542bf2641
@ -8,7 +8,7 @@
|
|||||||
SRCS = pg_repack.c pgut/pgut.c pgut/pgut-fe.c
|
SRCS = pg_repack.c pgut/pgut.c pgut/pgut-fe.c
|
||||||
OBJS = $(SRCS:.c=.o)
|
OBJS = $(SRCS:.c=.o)
|
||||||
PROGRAM = pg_repack
|
PROGRAM = pg_repack
|
||||||
REGRESS = init repack
|
REGRESS = init repack tablespace
|
||||||
|
|
||||||
EXTRA_CLEAN = sql/init-$(MAJORVERSION).sql sql/init.sql
|
EXTRA_CLEAN = sql/init-$(MAJORVERSION).sql sql/init.sql
|
||||||
|
|
||||||
|
70
bin/expected/tablespace.out
Normal file
70
bin/expected/tablespace.out
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
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);
|
||||||
|
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
|
||||||
|
SELECT relname, spcname
|
||||||
|
FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace
|
||||||
|
WHERE relname ~ '^testts1';
|
||||||
|
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
|
||||||
|
SELECT relname, spcname
|
||||||
|
FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace
|
||||||
|
WHERE relname ~ '^testts1';
|
||||||
|
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
|
||||||
|
SELECT relname, spcname
|
||||||
|
FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace
|
||||||
|
WHERE relname ~ '^testts1';
|
||||||
|
relname | spcname
|
||||||
|
---------+---------
|
||||||
|
(0 rows)
|
||||||
|
|
||||||
|
-- can move the table together with the indexes
|
||||||
|
\! pg_repack --dbname=contrib_regression --no-order --table=testts1 --tablespace pg_default --moveidx
|
||||||
|
SELECT relname, spcname
|
||||||
|
FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace
|
||||||
|
WHERE relname ~ '^testts1';
|
||||||
|
relname | spcname
|
||||||
|
--------------+---------
|
||||||
|
testts1 | testts
|
||||||
|
testts1_pkey | testts
|
||||||
|
(2 rows)
|
||||||
|
|
||||||
|
-- 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)
|
50
bin/sql/tablespace.sql
Normal file
50
bin/sql/tablespace.sql
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
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';
|
||||||
|
-- If the query above failed you must create the 'testts' tablespace;
|
||||||
|
|
||||||
|
CREATE TABLE testts1 (id serial primary key, data text);
|
||||||
|
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
|
||||||
|
|
||||||
|
SELECT relname, spcname
|
||||||
|
FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace
|
||||||
|
WHERE relname ~ '^testts1';
|
||||||
|
|
||||||
|
SELECT * from testts1 order by id;
|
||||||
|
|
||||||
|
-- tablespace stays where it is
|
||||||
|
\! pg_repack --dbname=contrib_regression --no-order --table=testts1
|
||||||
|
|
||||||
|
SELECT relname, spcname
|
||||||
|
FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace
|
||||||
|
WHERE relname ~ '^testts1';
|
||||||
|
|
||||||
|
-- can move the ts back to default
|
||||||
|
\! pg_repack --dbname=contrib_regression --no-order --table=testts1 -s pg_default
|
||||||
|
|
||||||
|
SELECT relname, spcname
|
||||||
|
FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace
|
||||||
|
WHERE relname ~ '^testts1';
|
||||||
|
|
||||||
|
-- can move the table together with the indexes
|
||||||
|
\! pg_repack --dbname=contrib_regression --no-order --table=testts1 --tablespace pg_default --moveidx
|
||||||
|
|
||||||
|
SELECT relname, spcname
|
||||||
|
FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace
|
||||||
|
WHERE relname ~ '^testts1';
|
||||||
|
|
||||||
|
-- can't specify --moveidx without --tablespace
|
||||||
|
\! pg_repack --dbname=contrib_regression --no-order --table=testts1 --moveidx
|
||||||
|
\! pg_repack --dbname=contrib_regression --no-order --table=testts1 -S
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user