Parse tablespace/where in parse_indexdef
Makes injecting the target tablespace much easier and fixes interaction between tablespace and WITH/WHERE clauses. Added tests to check the correct indexes definition.
This commit is contained in:
@ -17,6 +17,31 @@ CREATE INDEX testts1_with_idx on testts1 (id) with (fillfactor=80);
|
||||
INSERT INTO testts1 (data) values ('a');
|
||||
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),
|
||||
'_[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) 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'),
|
||||
'_[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 foo WHERE (id > 0)
|
||||
CREATE UNIQUE INDEX index_OID ON repack.table_OID USING btree (id) TABLESPACE foo
|
||||
CREATE INDEX index_OID ON repack.table_OID USING btree (id) WITH (fillfactor=80) TABLESPACE foo
|
||||
(3 rows)
|
||||
|
||||
-- can move the tablespace from default
|
||||
\! pg_repack --dbname=contrib_regression --no-order --table=testts1 --tablespace testts
|
||||
INFO: repacking table "testts1"
|
||||
|
@ -16,6 +16,19 @@ INSERT INTO testts1 (data) values ('a');
|
||||
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),
|
||||
'_[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'),
|
||||
'_[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
|
||||
\! pg_repack --dbname=contrib_regression --no-order --table=testts1 --tablespace testts
|
||||
|
||||
|
Reference in New Issue
Block a user