summaryrefslogtreecommitdiffstats
path: root/src/backend/catalog/index.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/backend/catalog/index.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index db697a9..bab02e1 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -3621,7 +3621,24 @@ reindex_index(Oid indexId, bool skip_constraint_checks, char persistence,
* Open the target index relation and get an exclusive lock on it, to
* ensure that no one else is touching this particular index.
*/
- iRel = index_open(indexId, AccessExclusiveLock);
+ if ((params->options & REINDEXOPT_MISSING_OK) != 0)
+ iRel = try_index_open(indexId, AccessExclusiveLock);
+ else
+ iRel = index_open(indexId, AccessExclusiveLock);
+
+ /* if index relation is gone, leave */
+ if (!iRel)
+ {
+ /* Roll back any GUC changes */
+ AtEOXact_GUC(false, save_nestlevel);
+
+ /* Restore userid and security context */
+ SetUserIdAndSecContext(save_userid, save_sec_context);
+
+ /* Close parent heap relation, but keep locks */
+ table_close(heapRelation, NoLock);
+ return;
+ }
if (progress)
pgstat_progress_update_param(PROGRESS_CREATEIDX_ACCESS_METHOD_OID,