diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2002-04-09 20:35:55 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2002-04-09 20:35:55 +0000 |
commit | f2d70d32ebd6c38d4fe93c1a684f5f29e5e76938 (patch) | |
tree | 5d041018177cdf6e9ca3ef0cc2eafac580a5bb0b /src/backend/commands/proclang.c | |
parent | c419c224142eb4bbf6e9a47d2d3626f212fda0fc (diff) | |
download | postgresql-f2d70d32ebd6c38d4fe93c1a684f5f29e5e76938.tar.gz postgresql-f2d70d32ebd6c38d4fe93c1a684f5f29e5e76938.zip |
Functions live in namespaces. Qualified function names work, eg
SELECT schema1.func2(...). Aggregate names can be qualified at the
syntactic level, but the qualification is ignored for the moment.
Diffstat (limited to 'src/backend/commands/proclang.c')
-rw-r--r-- | src/backend/commands/proclang.c | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/src/backend/commands/proclang.c b/src/backend/commands/proclang.c index d9cf0f0814a..4ef8d8f72a0 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.29 2002/02/18 23:11:11 petere Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/proclang.c,v 1.30 2002/04/09 20:35:48 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -18,12 +18,15 @@ #include "access/heapam.h" #include "catalog/catname.h" #include "catalog/indexing.h" +#include "catalog/namespace.h" #include "catalog/pg_language.h" #include "catalog/pg_proc.h" #include "commands/proclang.h" #include "fmgr.h" #include "miscadmin.h" +#include "parser/parse_func.h" #include "utils/builtins.h" +#include "utils/lsyscache.h" #include "utils/syscache.h" @@ -50,15 +53,13 @@ void CreateProceduralLanguage(CreatePLangStmt *stmt) { char languageName[NAMEDATALEN]; - HeapTuple procTup; - + Oid procOid; Oid typev[FUNC_MAX_ARGS]; char nulls[Natts_pg_language]; Datum values[Natts_pg_language]; Relation rel; HeapTuple tup; TupleDesc tupDesc; - int i; /* @@ -83,18 +84,14 @@ CreateProceduralLanguage(CreatePLangStmt *stmt) * Lookup the PL handler function and check that it is of return type * Opaque */ - memset(typev, 0, sizeof(typev)); - procTup = SearchSysCache(PROCNAME, - PointerGetDatum(stmt->plhandler), - Int32GetDatum(0), - PointerGetDatum(typev), - 0); - if (!HeapTupleIsValid(procTup)) + MemSet(typev, 0, sizeof(typev)); + procOid = LookupFuncName(stmt->plhandler, 0, typev); + if (!OidIsValid(procOid)) elog(ERROR, "PL handler function %s() doesn't exist", - stmt->plhandler); - if (((Form_pg_proc) GETSTRUCT(procTup))->prorettype != InvalidOid) + NameListToString(stmt->plhandler)); + if (get_func_rettype(procOid) != InvalidOid) elog(ERROR, "PL handler function %s() isn't of return type Opaque", - stmt->plhandler); + NameListToString(stmt->plhandler)); /* * Insert the new language into pg_language @@ -109,13 +106,11 @@ CreateProceduralLanguage(CreatePLangStmt *stmt) values[i++] = PointerGetDatum(languageName); values[i++] = BoolGetDatum(true); /* lanispl */ values[i++] = BoolGetDatum(stmt->pltrusted); - values[i++] = ObjectIdGetDatum(procTup->t_data->t_oid); + values[i++] = ObjectIdGetDatum(procOid); values[i++] = DirectFunctionCall1(textin, CStringGetDatum(stmt->plcompiler)); nulls[i] = 'n'; /* lanacl */ - ReleaseSysCache(procTup); - rel = heap_openr(LanguageRelationName, RowExclusiveLock); tupDesc = rel->rd_att; |