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/proclang.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/proclang.c')
-rw-r--r-- | src/backend/commands/proclang.c | 46 |
1 files changed, 38 insertions, 8 deletions
diff --git a/src/backend/commands/proclang.c b/src/backend/commands/proclang.c index 158927067f1..56dc320e2ef 100644 --- a/src/backend/commands/proclang.c +++ b/src/backend/commands/proclang.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/proclang.c,v 1.34 2002/06/20 20:29:27 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/proclang.c,v 1.35 2002/07/12 18:43:16 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -17,6 +17,7 @@ #include "access/heapam.h" #include "catalog/catname.h" +#include "catalog/dependency.h" #include "catalog/indexing.h" #include "catalog/namespace.h" #include "catalog/pg_language.h" @@ -140,7 +141,7 @@ DropProceduralLanguage(DropPLangStmt *stmt) { char languageName[NAMEDATALEN]; HeapTuple langTup; - Relation rel; + ObjectAddress object; /* * Check permission @@ -155,11 +156,9 @@ DropProceduralLanguage(DropPLangStmt *stmt) */ case_translate_language_name(stmt->plname, languageName); - rel = heap_openr(LanguageRelationName, RowExclusiveLock); - - langTup = SearchSysCacheCopy(LANGNAME, - PointerGetDatum(languageName), - 0, 0, 0); + langTup = SearchSysCache(LANGNAME, + CStringGetDatum(languageName), + 0, 0, 0); if (!HeapTupleIsValid(langTup)) elog(ERROR, "Language %s doesn't exist", languageName); @@ -167,8 +166,39 @@ DropProceduralLanguage(DropPLangStmt *stmt) elog(ERROR, "Language %s isn't a created procedural language", languageName); + object.classId = get_system_catalog_relid(LanguageRelationName); + object.objectId = langTup->t_data->t_oid; + object.objectSubId = 0; + + ReleaseSysCache(langTup); + + /* + * Do the deletion + */ + performDeletion(&object, stmt->behavior); +} + +/* + * Guts of language dropping. + */ +void +DropProceduralLanguageById(Oid langOid) +{ + Relation rel; + HeapTuple langTup; + + rel = heap_openr(LanguageRelationName, RowExclusiveLock); + + langTup = SearchSysCache(LANGOID, + ObjectIdGetDatum(langOid), + 0, 0, 0); + if (!HeapTupleIsValid(langTup)) + elog(ERROR, "DropProceduralLanguageById: language %u not found", + langOid); + simple_heap_delete(rel, &langTup->t_self); - heap_freetuple(langTup); + ReleaseSysCache(langTup); + heap_close(rel, RowExclusiveLock); } |