mirror of
https://github.com/postgres/postgres.git
synced 2025-06-14 18:42:34 +03:00
Add a "provariadic" column to pg_proc to eliminate the remarkably expensive
need to deconstruct proargmodes for each pg_proc entry inspected by FuncnameGetCandidates(). Fixes function lookup performance regression caused by yesterday's variadic-functions patch. In passing, make pg_proc.probin be NULL, rather than a dummy value '-', in cases where it is not actually used for the particular type of function. This should buy back some of the space cost of the extra column.
This commit is contained in:
@ -10,7 +10,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.96 2008/07/16 01:30:22 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.97 2008/07/16 16:55:23 tgl Exp $
|
||||
*
|
||||
* DESCRIPTION
|
||||
* These routines take the parse tree and pick out the
|
||||
@ -590,7 +590,8 @@ compute_attributes_with_style(List *parameters, bool *isStrict_p, char *volatili
|
||||
* AS <object reference, or sql code>
|
||||
*/
|
||||
static void
|
||||
interpret_AS_clause(Oid languageOid, const char *languageName, List *as,
|
||||
interpret_AS_clause(Oid languageOid, const char *languageName,
|
||||
char *funcname, List *as,
|
||||
char **prosrc_str_p, char **probin_str_p)
|
||||
{
|
||||
Assert(as != NIL);
|
||||
@ -599,25 +600,47 @@ interpret_AS_clause(Oid languageOid, const char *languageName, List *as,
|
||||
{
|
||||
/*
|
||||
* For "C" language, store the file name in probin and, when given,
|
||||
* the link symbol name in prosrc.
|
||||
* the link symbol name in prosrc. If link symbol is omitted,
|
||||
* substitute procedure name. We also allow link symbol to be
|
||||
* specified as "-", since that was the habit in PG versions before
|
||||
* 8.4, and there might be dump files out there that don't translate
|
||||
* that back to "omitted".
|
||||
*/
|
||||
*probin_str_p = strVal(linitial(as));
|
||||
if (list_length(as) == 1)
|
||||
*prosrc_str_p = "-";
|
||||
*prosrc_str_p = funcname;
|
||||
else
|
||||
{
|
||||
*prosrc_str_p = strVal(lsecond(as));
|
||||
if (strcmp(*prosrc_str_p, "-") == 0)
|
||||
*prosrc_str_p = funcname;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Everything else wants the given string in prosrc. */
|
||||
*prosrc_str_p = strVal(linitial(as));
|
||||
*probin_str_p = "-";
|
||||
*probin_str_p = NULL;
|
||||
|
||||
if (list_length(as) != 1)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
|
||||
errmsg("only one AS item needed for language \"%s\"",
|
||||
languageName)));
|
||||
|
||||
if (languageOid == INTERNALlanguageId)
|
||||
{
|
||||
/*
|
||||
* In PostgreSQL versions before 6.5, the SQL name of the created
|
||||
* function could not be different from the internal name, and
|
||||
* "prosrc" wasn't used. So there is code out there that does
|
||||
* CREATE FUNCTION xyz AS '' LANGUAGE internal. To preserve some
|
||||
* modicum of backwards compatibility, accept an empty "prosrc"
|
||||
* value as meaning the supplied SQL function name.
|
||||
*/
|
||||
if (strlen(*prosrc_str_p) == 0)
|
||||
*prosrc_str_p = funcname;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -759,30 +782,9 @@ CreateFunction(CreateFunctionStmt *stmt)
|
||||
|
||||
compute_attributes_with_style(stmt->withClause, &isStrict, &volatility);
|
||||
|
||||
interpret_AS_clause(languageOid, languageName, as_clause,
|
||||
interpret_AS_clause(languageOid, languageName, funcname, as_clause,
|
||||
&prosrc_str, &probin_str);
|
||||
|
||||
if (languageOid == INTERNALlanguageId)
|
||||
{
|
||||
/*
|
||||
* In PostgreSQL versions before 6.5, the SQL name of the created
|
||||
* function could not be different from the internal name, and
|
||||
* "prosrc" wasn't used. So there is code out there that does CREATE
|
||||
* FUNCTION xyz AS '' LANGUAGE internal. To preserve some modicum of
|
||||
* backwards compatibility, accept an empty "prosrc" value as meaning
|
||||
* the supplied SQL function name.
|
||||
*/
|
||||
if (strlen(prosrc_str) == 0)
|
||||
prosrc_str = funcname;
|
||||
}
|
||||
|
||||
if (languageOid == ClanguageId)
|
||||
{
|
||||
/* If link symbol is specified as "-", substitute procedure name */
|
||||
if (strcmp(prosrc_str, "-") == 0)
|
||||
prosrc_str = funcname;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set default values for COST and ROWS depending on other parameters;
|
||||
* reject ROWS if it's not returnsSet. NB: pg_dump knows these default
|
||||
|
Reference in New Issue
Block a user