diff --git a/lib/repack.c b/lib/repack.c index 9788371..82e9212 100644 --- a/lib/repack.c +++ b/lib/repack.c @@ -663,9 +663,10 @@ repack_get_order_by(PG_FUNCTION_ARGS) * * repack_indexdef(index, table) * - * @param index Oid of target index. - * @param table Oid of table of the index. + * @param index Oid of target index. + * @param table Oid of table of the index. * @param tablespace Namespace for the index. If NULL keep the original. + * @param boolean Whether to use CONCURRENTLY when creating the index. * @retval Create index DDL for temp table. */ Datum @@ -690,7 +691,7 @@ repack_indexdef(PG_FUNCTION_ARGS) parse_indexdef(&stmt, index, table); initStringInfo(&str); - if(concurrent_index) + if (concurrent_index) appendStringInfo(&str, "%s CONCURRENTLY index_%u ON %s USING %s (%s)%s", stmt.create, index, stmt.table, stmt.type, stmt.columns, stmt.options); else diff --git a/regress/expected/tablespace.out b/regress/expected/tablespace.out index 2a51bc9..3e21219 100644 --- a/regress/expected/tablespace.out +++ b/regress/expected/tablespace.out @@ -19,7 +19,7 @@ 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), + repack.repack_indexdef(indexrelid, 'testts1'::regclass, NULL, false), '_[0-9]+', '_OID', 'g') FROM pg_index i join pg_class c ON c.oid = indexrelid WHERE indrelid = 'testts1'::regclass ORDER BY relname; @@ -31,7 +31,7 @@ WHERE indrelid = 'testts1'::regclass ORDER BY relname; (3 rows) SELECT regexp_replace( - repack.repack_indexdef(indexrelid, 'testts1'::regclass, 'foo'), + repack.repack_indexdef(indexrelid, 'testts1'::regclass, 'foo', false), '_[0-9]+', '_OID', 'g') FROM pg_index i join pg_class c ON c.oid = indexrelid WHERE indrelid = 'testts1'::regclass ORDER BY relname; diff --git a/regress/sql/tablespace.sql b/regress/sql/tablespace.sql index 60b9390..68a2fbd 100644 --- a/regress/sql/tablespace.sql +++ b/regress/sql/tablespace.sql @@ -18,13 +18,13 @@ INSERT INTO testts1 (data) values ('c'); -- check the indexes definitions SELECT regexp_replace( - repack.repack_indexdef(indexrelid, 'testts1'::regclass, NULL), + repack.repack_indexdef(indexrelid, 'testts1'::regclass, NULL, false), '_[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'), + repack.repack_indexdef(indexrelid, 'testts1'::regclass, 'foo', false), '_[0-9]+', '_OID', 'g') FROM pg_index i join pg_class c ON c.oid = indexrelid WHERE indrelid = 'testts1'::regclass ORDER BY relname;