Skip to content

Commit 88e1153

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/5f37ee56-14fb-44fe-9150-9eb97e10538b@oss.nttdata.com
1 parent b9ee133 commit 88e1153

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/bin/scripts/reindexdb.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,8 @@ get_parallel_object_list(PGconn *conn, ReindexType type,
670670
" AND c.relkind IN ("
671671
CppAsString2(RELKIND_RELATION) ", "
672672
CppAsString2(RELKIND_MATVIEW) ")\n"
673+
" AND c.relpersistence != "
674+
CppAsString2(RELPERSISTENCE_TEMP) "\n"
673675
" ORDER BY c.relpages DESC;");
674676
break;
675677

@@ -692,6 +694,8 @@ get_parallel_object_list(PGconn *conn, ReindexType type,
692694
" WHERE c.relkind IN ("
693695
CppAsString2(RELKIND_RELATION) ", "
694696
CppAsString2(RELKIND_MATVIEW) ")\n"
697+
" AND c.relpersistence != "
698+
CppAsString2(RELPERSISTENCE_TEMP) "\n"
695699
" AND ns.nspname IN (");
696700

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

0 commit comments

Comments
 (0)