Skip to content

Commit 20cfec8

Browse files
committed
reindexdb: Skip reindexing temporary tables and indexes.
Reindexing temp tables or indexes of other sessions is not allowed. However, reindexdb in parallel mode previously listed them as the objects to process, leading to failures. This commit ensures reindexdb in parallel mode skips temporary tables and indexes by adding a condition based on the relpersistence column in pg_class to the object listing queries, preventing these issues. Note that this commit does not affect reindexdb when temporary tables or indexes are explicitly specified using the -t or -j options; reindexdb in that case still does not skip them and can cause an error. Back-patch to v13 where parallel mode was introduced in reindexdb. Author: Fujii Masao Reviewed-by: Michael Paquier Discussion: https://postgr.es/m/[email protected]
1 parent 6fd5071 commit 20cfec8

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/bin/scripts/reindexdb.c

+4
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,8 @@ get_parallel_object_list(PGconn *conn, ReindexType type,
649649
" AND c.relkind IN ("
650650
CppAsString2(RELKIND_RELATION) ", "
651651
CppAsString2(RELKIND_MATVIEW) ")\n"
652+
" AND c.relpersistence != "
653+
CppAsString2(RELPERSISTENCE_TEMP) "\n"
652654
" ORDER BY c.relpages DESC;");
653655
break;
654656

@@ -671,6 +673,8 @@ get_parallel_object_list(PGconn *conn, ReindexType type,
671673
" WHERE c.relkind IN ("
672674
CppAsString2(RELKIND_RELATION) ", "
673675
CppAsString2(RELKIND_MATVIEW) ")\n"
676+
" AND c.relpersistence != "
677+
CppAsString2(RELPERSISTENCE_TEMP) "\n"
674678
" AND ns.nspname IN (");
675679

676680
for (cell = user_list->head; cell; cell = cell->next)

0 commit comments

Comments
 (0)