From ebe124eacd7c3faa36ed358e7cc1d7c5b419e5f6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 4 May 2024 14:18:09 +0200 Subject: Merging upstream version 15.6. Signed-off-by: Daniel Baumann --- src/backend/catalog/aclchk.c | 4 ++-- src/backend/catalog/heap.c | 7 +++++-- src/backend/catalog/index.c | 19 ++++++++++++++++++- 3 files changed, 25 insertions(+), 5 deletions(-) (limited to 'src/backend/catalog') diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c index 95d85a7..567807b 100644 --- a/src/backend/catalog/aclchk.c +++ b/src/backend/catalog/aclchk.c @@ -6135,9 +6135,9 @@ recordExtObjInitPriv(Oid objoid, Oid classoid) ReleaseSysCache(tuple); } - /* pg_largeobject_metadata */ - else if (classoid == LargeObjectMetadataRelationId) + else if (classoid == LargeObjectRelationId) { + /* For large objects, we must consult pg_largeobject_metadata */ Datum aclDatum; bool isNull; HeapTuple tuple; diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c index a21de89..bd6b9c4 100644 --- a/src/backend/catalog/heap.c +++ b/src/backend/catalog/heap.c @@ -2328,7 +2328,8 @@ AddRelationNewConstraints(Relation rel, continue; /* If the DEFAULT is volatile we cannot use a missing value */ - if (colDef->missingMode && contain_volatile_functions((Node *) expr)) + if (colDef->missingMode && + contain_volatile_functions_after_planning((Expr *) expr)) colDef->missingMode = false; defOid = StoreAttrDefault(rel, colDef->attnum, expr, is_internal, @@ -2763,9 +2764,11 @@ cookDefault(ParseState *pstate, if (attgenerated) { + /* Disallow refs to other generated columns */ check_nested_generated(pstate, expr); - if (contain_mutable_functions(expr)) + /* Disallow mutable functions */ + if (contain_mutable_functions_after_planning((Expr *) expr)) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), errmsg("generation expression is not immutable"))); 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, -- cgit v1.2.3