diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2002-07-12 18:43:19 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2002-07-12 18:43:19 +0000 |
commit | 7c6df91dda27accab3097390ef0d21d93028c7a1 (patch) | |
tree | 5705b975e8de4edf82252e6df28e0bd57c83cb95 /src/backend/commands/operatorcmds.c | |
parent | 791a40f943e2a9353c5823fb4f2bd446ec623d38 (diff) |
Second phase of committing Rod Taylor's pg_depend/pg_constraint patch.
pg_relcheck is gone; CHECK, UNIQUE, PRIMARY KEY, and FOREIGN KEY
constraints all have real live entries in pg_constraint. pg_depend
exists, and RESTRICT/CASCADE options work on most kinds of DROP;
however, pg_depend is not yet very well populated with dependencies.
(Most of the ones that are present at this point just replace formerly
hardwired associations, such as the implicit drop of a relation's pg_type
entry when the relation is dropped.) Need to add more logic to create
dependency entries, improve pg_dump to dump constraints in place of
indexes and triggers, and add some regression tests.
Diffstat (limited to 'src/backend/commands/operatorcmds.c')
-rw-r--r-- | src/backend/commands/operatorcmds.c | 48 |
1 files changed, 37 insertions, 11 deletions
diff --git a/src/backend/commands/operatorcmds.c b/src/backend/commands/operatorcmds.c index fcf96c5e9c1..1c4e5f3bee3 100644 --- a/src/backend/commands/operatorcmds.c +++ b/src/backend/commands/operatorcmds.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/operatorcmds.c,v 1.4 2002/07/01 15:27:46 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/operatorcmds.c,v 1.5 2002/07/12 18:43:16 tgl Exp $ * * DESCRIPTION * The "DefineFoo" routines take the parse tree and pick out the @@ -36,9 +36,9 @@ #include "access/heapam.h" #include "catalog/catname.h" +#include "catalog/dependency.h" #include "catalog/namespace.h" #include "catalog/pg_operator.h" -#include "commands/comment.h" #include "commands/defrem.h" #include "miscadmin.h" #include "parser/parse_oper.h" @@ -217,17 +217,15 @@ RemoveOperator(RemoveOperStmt *stmt) TypeName *typeName1 = (TypeName *) lfirst(stmt->args); TypeName *typeName2 = (TypeName *) lsecond(stmt->args); Oid operOid; - Relation relation; HeapTuple tup; + ObjectAddress object; operOid = LookupOperNameTypeNames(operatorName, typeName1, typeName2, "RemoveOperator"); - relation = heap_openr(OperatorRelationName, RowExclusiveLock); - - tup = SearchSysCacheCopy(OPEROID, - ObjectIdGetDatum(operOid), - 0, 0, 0); + tup = SearchSysCache(OPEROID, + ObjectIdGetDatum(operOid), + 0, 0, 0); if (!HeapTupleIsValid(tup)) /* should not happen */ elog(ERROR, "RemoveOperator: failed to find tuple for operator '%s'", NameListToString(operatorName)); @@ -238,11 +236,39 @@ RemoveOperator(RemoveOperStmt *stmt) GetUserId())) aclcheck_error(ACLCHECK_NOT_OWNER, NameListToString(operatorName)); - /* Delete any comments associated with this operator */ - DeleteComments(operOid, RelationGetRelid(relation)); + ReleaseSysCache(tup); + + /* + * Do the deletion + */ + object.classId = get_system_catalog_relid(OperatorRelationName); + object.objectId = operOid; + object.objectSubId = 0; + + performDeletion(&object, stmt->behavior); +} + +/* + * Guts of operator deletion. + */ +void +RemoveOperatorById(Oid operOid) +{ + Relation relation; + HeapTuple tup; + + relation = heap_openr(OperatorRelationName, RowExclusiveLock); + + tup = SearchSysCache(OPEROID, + ObjectIdGetDatum(operOid), + 0, 0, 0); + if (!HeapTupleIsValid(tup)) /* should not happen */ + elog(ERROR, "RemoveOperatorById: failed to find tuple for operator %u", + operOid); simple_heap_delete(relation, &tup->t_self); - heap_freetuple(tup); + ReleaseSysCache(tup); + heap_close(relation, RowExclusiveLock); } |