there-is-no-try-v3.patch
application/octet-stream
Filename: there-is-no-try-v3.patch
Type: application/octet-stream
Part: 0
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index a48e057..59314ab 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -1004,7 +1004,7 @@ relation_openrv(const RangeVar *relation, LOCKMODE lockmode)
}
/* ----------------
- * try_relation_openrv - open any relation specified by a RangeVar
+ * relation_openrv_extended - open any relation specified by a RangeVar
*
* Same as relation_openrv, but return NULL instead of failing for
* relation-not-found. (Note that some other causes, such as
@@ -1012,7 +1012,8 @@ relation_openrv(const RangeVar *relation, LOCKMODE lockmode)
* ----------------
*/
Relation
-try_relation_openrv(const RangeVar *relation, LOCKMODE lockmode)
+relation_openrv_extended(const RangeVar *relation, LOCKMODE lockmode,
+ bool missing_ok)
{
Oid relOid;
@@ -1032,7 +1033,7 @@ try_relation_openrv(const RangeVar *relation, LOCKMODE lockmode)
AcceptInvalidationMessages();
/* Look up the appropriate relation using namespace search */
- relOid = RangeVarGetRelid(relation, true);
+ relOid = RangeVarGetRelid(relation, missing_ok);
/* Return NULL on not-found */
if (!OidIsValid(relOid))
@@ -1125,18 +1126,19 @@ heap_openrv(const RangeVar *relation, LOCKMODE lockmode)
}
/* ----------------
- * try_heap_openrv - open a heap relation specified
+ * heap_openrv_extended - open a heap relation specified
* by a RangeVar node
*
* As above, but return NULL instead of failing for relation-not-found.
* ----------------
*/
Relation
-try_heap_openrv(const RangeVar *relation, LOCKMODE lockmode)
+heap_openrv_extended(const RangeVar *relation, LOCKMODE lockmode,
+ bool missing_ok)
{
Relation r;
- r = try_relation_openrv(relation, lockmode);
+ r = relation_openrv_extended(relation, lockmode, missing_ok);
if (r)
{
diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c
index 5359e69..edfb1f1 100644
--- a/src/backend/parser/parse_relation.c
+++ b/src/backend/parser/parse_relation.c
@@ -826,7 +826,7 @@ parserOpenTable(ParseState *pstate, const RangeVar *relation, int lockmode)
ParseCallbackState pcbstate;
setup_parser_errposition_callback(&pcbstate, pstate, relation->location);
- rel = try_heap_openrv(relation, lockmode);
+ rel = heap_openrv_extended(relation, lockmode, true);
if (rel == NULL)
{
if (relation->schemaname)
diff --git a/src/include/access/heapam.h b/src/include/access/heapam.h
index ee474d6..56036a8 100644
--- a/src/include/access/heapam.h
+++ b/src/include/access/heapam.h
@@ -50,12 +50,14 @@ typedef enum
extern Relation relation_open(Oid relationId, LOCKMODE lockmode);
extern Relation try_relation_open(Oid relationId, LOCKMODE lockmode);
extern Relation relation_openrv(const RangeVar *relation, LOCKMODE lockmode);
-extern Relation try_relation_openrv(const RangeVar *relation, LOCKMODE lockmode);
+extern Relation relation_openrv_extended(const RangeVar *relation,
+ LOCKMODE lockmode, bool missing_ok);
extern void relation_close(Relation relation, LOCKMODE lockmode);
extern Relation heap_open(Oid relationId, LOCKMODE lockmode);
extern Relation heap_openrv(const RangeVar *relation, LOCKMODE lockmode);
-extern Relation try_heap_openrv(const RangeVar *relation, LOCKMODE lockmode);
+extern Relation heap_openrv_extended(const RangeVar *relation,
+ LOCKMODE lockmode, bool missing_ok);
#define heap_close(r,l) relation_close(r,l)
diff --git a/src/pl/tcl/pltcl.c b/src/pl/tcl/pltcl.c
index 7b952b2..f517144 100644
--- a/src/pl/tcl/pltcl.c
+++ b/src/pl/tcl/pltcl.c
@@ -493,8 +493,8 @@ pltcl_init_load_unknown(Tcl_Interp *interp)
* This is for backwards compatibility. To ensure that the table
* is trustworthy, we require it to be owned by a superuser.
************************************************************/
- pmrel = try_relation_openrv(makeRangeVar(NULL, "pltcl_modules", -1),
- AccessShareLock);
+ pmrel = relation_openrv_extended(makeRangeVar(NULL, "pltcl_modules", -1),
+ AccessShareLock, true);
if (pmrel == NULL)
return;
/* must be table or view, else ignore */