summaryrefslogtreecommitdiff
path: root/src/backend/commands
diff options
context:
space:
mode:
authorTom Lane2000-08-03 19:19:38 +0000
committerTom Lane2000-08-03 19:19:38 +0000
commit61aca818c486dbe000ce94c77cb1dd1f379baf67 (patch)
tree6d266f3253db8cb2ea9d59bb63dff89f8f7a1c56 /src/backend/commands
parentc298d74d4957845bb03a67092c30b53e5e0d01c2 (diff)
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/commands')
-rw-r--r--src/backend/commands/command.c4
-rw-r--r--src/backend/commands/trigger.c9
2 files changed, 4 insertions, 9 deletions
diff --git a/src/backend/commands/command.c b/src/backend/commands/command.c
index 3deea360e0a..de2597bd266 100644
--- a/src/backend/commands/command.c
+++ b/src/backend/commands/command.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.92 2000/08/03 16:34:01 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.93 2000/08/03 19:19:18 tgl Exp $
*
* NOTES
* The PerformAddAttribute() code, like most of the relation
@@ -1614,8 +1614,6 @@ LockTableCommand(LockStmt *lockstmt)
int aclresult;
rel = heap_openr(lockstmt->relname, NoLock);
- if (!RelationIsValid(rel))
- elog(ERROR, "Relation '%s' does not exist", lockstmt->relname);
if (lockstmt->mode == AccessShareLock)
aclresult = pg_aclcheck(lockstmt->relname, GetPgUserName(), ACL_RD);
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c
index 17e61a379fb..a03f140b64f 100644
--- a/src/backend/commands/trigger.c
+++ b/src/backend/commands/trigger.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.74 2000/08/03 16:34:01 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.75 2000/08/03 19:19:18 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -92,9 +92,6 @@ CreateTrigger(CreateTrigStmt *stmt)
* interested in getting the relation's OID...
*/
rel = heap_openr(stmt->constrrelname, NoLock);
- if (rel == NULL)
- elog(ERROR, "table \"%s\" does not exist",
- stmt->constrrelname);
constrrelid = rel->rd_id;
heap_close(rel, NoLock);
}
@@ -440,12 +437,12 @@ RelationRemoveTriggers(Relation rel)
pg_trigger = (Form_pg_trigger) GETSTRUCT(tup);
refrel = heap_open(pg_trigger->tgrelid, NoLock);
-
stmt.relname = pstrdup(RelationGetRelationName(refrel));
+ heap_close(refrel, NoLock);
+
stmt.trigname = DatumGetCString(DirectFunctionCall1(nameout,
NameGetDatum(&pg_trigger->tgname)));
- heap_close(refrel, NoLock);
elog(NOTICE, "DROP TABLE implicitly drops referential integrity trigger from table \"%s\"", stmt.relname);