aboutsummaryrefslogtreecommitdiff
path: root/src/bin/scripts
diff options
context:
space:
mode:
authorFujii Masao <fujii@postgresql.org>2024-09-30 11:13:55 +0900
committerFujii Masao <fujii@postgresql.org>2024-09-30 11:13:55 +0900
commit20cfec896c6a20ca436f634b0ffa3582d7b9425c (patch)
tree5414a49be7d54b1666894fb14618f6e20507912d /src/bin/scripts
parent6fd5071909a2886c499871e61127f815fd9bb6a2 (diff)
downloadpostgresql-20cfec896c6a20ca436f634b0ffa3582d7b9425c.tar.gz
postgresql-20cfec896c6a20ca436f634b0ffa3582d7b9425c.zip
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
Diffstat (limited to 'src/bin/scripts')
-rw-r--r--src/bin/scripts/reindexdb.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/bin/scripts/reindexdb.c b/src/bin/scripts/reindexdb.c
index 904c196fbba..af0738d9334 100644
--- a/src/bin/scripts/reindexdb.c
+++ b/src/bin/scripts/reindexdb.c
@@ -649,6 +649,8 @@ get_parallel_object_list(PGconn *conn, ReindexType type,
" AND c.relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ")\n"
+ " AND c.relpersistence != "
+ CppAsString2(RELPERSISTENCE_TEMP) "\n"
" ORDER BY c.relpages DESC;");
break;
@@ -671,6 +673,8 @@ get_parallel_object_list(PGconn *conn, ReindexType type,
" WHERE c.relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ")\n"
+ " AND c.relpersistence != "
+ CppAsString2(RELPERSISTENCE_TEMP) "\n"
" AND ns.nspname IN (");
for (cell = user_list->head; cell; cell = cell->next)