diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2000-08-03 19:19:38 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2000-08-03 19:19:38 +0000 |
commit | 61aca818c486dbe000ce94c77cb1dd1f379baf67 (patch) | |
tree | 6d266f3253db8cb2ea9d59bb63dff89f8f7a1c56 /src/backend/parser/parse_func.c | |
parent | c298d74d4957845bb03a67092c30b53e5e0d01c2 (diff) | |
download | postgresql-61aca818c486dbe000ce94c77cb1dd1f379baf67.tar.gz postgresql-61aca818c486dbe000ce94c77cb1dd1f379baf67.zip |
Modify heap_open()/heap_openr() API per pghackers discussion of 11 July.
These two routines will now ALWAYS elog() on failure, whether you ask for
a lock or not. If you really want to get a NULL return on failure, call
the new routines heap_open_nofail()/heap_openr_nofail(). By my count there
are only about three places that actually want that behavior. There were
rather more than three places that were missing the check they needed to
make under the old convention :-(.
Diffstat (limited to 'src/backend/parser/parse_func.c')
-rw-r--r-- | src/backend/parser/parse_func.c | 37 |
1 files changed, 15 insertions, 22 deletions
diff --git a/src/backend/parser/parse_func.c b/src/backend/parser/parse_func.c index 1ff6b534447..d1a5e44f873 100644 --- a/src/backend/parser/parse_func.c +++ b/src/backend/parser/parse_func.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.85 2000/06/15 04:09:54 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.86 2000/08/03 19:19:34 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -382,7 +382,7 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs, if (attisset) { toid = exprType(first_arg); - rd = heap_openr(typeidTypeName(toid), NoLock); + rd = heap_openr_nofail(typeidTypeName(toid)); if (RelationIsValid(rd)) { relname = RelationGetRelationName(rd); @@ -1376,8 +1376,6 @@ find_inheritors(Oid relid, Oid **supervec) relid = lfirsti(elt); rd = heap_open(relid, NoLock); - if (!RelationIsValid(rd)) - elog(ERROR, "Relid %u does not exist", relid); trelid = typeTypeId(typenameType(RelationGetRelationName(rd))); heap_close(rd, NoLock); *relidvec++ = trelid; @@ -1627,7 +1625,7 @@ ParseComplexProjection(ParseState *pstate, */ /* add a tlist to the func node and return the Iter */ - rd = heap_openr(typeidTypeName(argtype), NoLock); + rd = heap_openr_nofail(typeidTypeName(argtype)); if (RelationIsValid(rd)) { relid = RelationGetRelid(rd); @@ -1679,29 +1677,24 @@ ParseComplexProjection(ParseState *pstate, (attnum = get_attnum(argrelid, funcname)) != InvalidAttrNumber) { + Expr *newexpr; /* add a tlist to the func node */ rd = heap_openr(typeidTypeName(argtype), NoLock); - if (RelationIsValid(rd)) - { - Expr *newexpr; - - relid = RelationGetRelid(rd); - funcnode->func_tlist = setup_tlist(funcname, argrelid); - funcnode->functype = attnumTypeId(rd, attnum); - newexpr = makeNode(Expr); - newexpr->typeOid = funcnode->functype; - newexpr->opType = FUNC_EXPR; - newexpr->oper = (Node *) funcnode; - newexpr->args = expr->args; + relid = RelationGetRelid(rd); + funcnode->func_tlist = setup_tlist(funcname, argrelid); + funcnode->functype = attnumTypeId(rd, attnum); - heap_close(rd, NoLock); + newexpr = makeNode(Expr); + newexpr->typeOid = funcnode->functype; + newexpr->opType = FUNC_EXPR; + newexpr->oper = (Node *) funcnode; + newexpr->args = expr->args; - return (Node *) newexpr; - } - /* XXX why not an error condition if it's not there? */ + heap_close(rd, NoLock); + return (Node *) newexpr; } break; @@ -1714,7 +1707,7 @@ ParseComplexProjection(ParseState *pstate, * If the Param is a complex type, this could be a * projection */ - rd = heap_openr(typeidTypeName(param->paramtype), NoLock); + rd = heap_openr_nofail(typeidTypeName(param->paramtype)); if (RelationIsValid(rd)) { relid = RelationGetRelid(rd); |