1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-07 19:06:32 +03:00

Revise handling of oldstyle/newstyle functions per recent discussions

in pghackers list.  Support for oldstyle internal functions is gone
(no longer needed, since conversion is complete) and pg_language entry
'internal' now implies newstyle call convention.  pg_language entry
'newC' is gone; both old and newstyle dynamically loaded C functions
are now called language 'C'.  A newstyle function must be identified
by an associated info routine.  See src/backend/utils/fmgr/README.
This commit is contained in:
Tom Lane
2000-11-20 20:36:57 +00:00
parent 99198ac6b8
commit 5bb2300b59
52 changed files with 571 additions and 328 deletions

View File

@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.48 2000/11/16 22:30:18 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.49 2000/11/20 20:36:47 tgl Exp $
*
* DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the
@@ -66,7 +66,7 @@ case_translate_language_name(const char *input, char *output)
{
/*-------------------------------------------------------------------------
Translate the input language name to lower case, except if it's "C",
translate to upper case, or "newC", translate to that spelling.
translate to upper case.
--------------------------------------------------------------------------*/
int i;
@@ -77,8 +77,6 @@ case_translate_language_name(const char *input, char *output)
if (strcmp(output, "c") == 0)
output[0] = 'C';
else if (strcmp(output, "newc") == 0)
output[3] = 'C';
}
@@ -183,8 +181,7 @@ interpret_AS_clause(const char *languageName, const List *as,
{
Assert(as != NIL);
if (strcmp(languageName, "C") == 0 ||
strcmp(languageName, "newC") == 0)
if (strcmp(languageName, "C") == 0)
{
/*
@@ -230,8 +227,8 @@ CreateFunction(ProcedureStmt *stmt, CommandDest dest)
char languageName[NAMEDATALEN];
/*
* name of language of function, with case adjusted: "C", "newC",
* "internal", "newinternal", "sql", etc.
* name of language of function, with case adjusted: "C",
* "internal", "sql", etc.
*/
bool returnsSet;
@@ -255,9 +252,7 @@ CreateFunction(ProcedureStmt *stmt, CommandDest dest)
* Apply appropriate security checks depending on language.
*/
if (strcmp(languageName, "C") == 0 ||
strcmp(languageName, "newC") == 0 ||
strcmp(languageName, "internal") == 0 ||
strcmp(languageName, "newinternal") == 0)
strcmp(languageName, "internal") == 0)
{
if (!superuser())
elog(ERROR,
@@ -283,8 +278,8 @@ CreateFunction(ProcedureStmt *stmt, CommandDest dest)
if (!HeapTupleIsValid(languageTuple))
elog(ERROR,
"Unrecognized language specified in a CREATE FUNCTION: "
"'%s'.\n\tRecognized languages are sql, C, newC, "
"internal, newinternal, and created procedural languages.",
"'%s'.\n\tRecognized languages are sql, C, "
"internal, and created procedural languages.",
languageName);
/* Check that this language is a PL */

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.55 2000/11/16 22:30:18 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.56 2000/11/20 20:36:47 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -344,8 +344,7 @@ RemoveFunction(char *functionName, /* function name to be removed */
if (!HeapTupleIsValid(tup))
func_error("RemoveFunction", functionName, nargs, argList, NULL);
if (((Form_pg_proc) GETSTRUCT(tup))->prolang == INTERNALlanguageId ||
((Form_pg_proc) GETSTRUCT(tup))->prolang == NEWINTERNALlanguageId)
if (((Form_pg_proc) GETSTRUCT(tup))->prolang == INTERNALlanguageId)
{
/* "Helpful" notice when removing a builtin function ... */
elog(NOTICE, "Removing built-in function \"%s\"", functionName);

View File

@@ -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.80 2000/11/16 22:30:18 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.81 2000/11/20 20:36:47 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -169,10 +169,7 @@ CreateTrigger(CreateTrigStmt *stmt)
funclang = ((Form_pg_proc) GETSTRUCT(tuple))->prolang;
ReleaseSysCache(tuple);
if (funclang != ClanguageId &&
funclang != NEWClanguageId &&
funclang != INTERNALlanguageId &&
funclang != NEWINTERNALlanguageId)
if (funclang != ClanguageId && funclang != INTERNALlanguageId)
{
HeapTuple langTup;
@@ -180,10 +177,10 @@ CreateTrigger(CreateTrigStmt *stmt)
ObjectIdGetDatum(funclang),
0, 0, 0);
if (!HeapTupleIsValid(langTup))
elog(ERROR, "CreateTrigger: cache lookup for PL %u failed",
elog(ERROR, "CreateTrigger: cache lookup for language %u failed",
funclang);
if (((Form_pg_language) GETSTRUCT(langTup))->lanispl == false)
elog(ERROR, "CreateTrigger: only builtin, C and PL functions are supported");
elog(ERROR, "CreateTrigger: only internal, C and PL functions are supported");
ReleaseSysCache(langTup);
}