diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2008-07-16 16:55:24 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2008-07-16 16:55:24 +0000 |
commit | 6563e9e2e8b15350e4cb99b86f2f7dec54722155 (patch) | |
tree | 312342db5f13289768a09d3dca49fc1bf9c2b0da /src/backend/commands/functioncmds.c | |
parent | 895a4bccb6663ad04b02905fcbf128e64d30abd9 (diff) | |
download | postgresql-6563e9e2e8b15350e4cb99b86f2f7dec54722155.tar.gz postgresql-6563e9e2e8b15350e4cb99b86f2f7dec54722155.zip |
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.
Diffstat (limited to 'src/backend/commands/functioncmds.c')
-rw-r--r-- | src/backend/commands/functioncmds.c | 56 |
1 files changed, 29 insertions, 27 deletions
diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c index cb249d9c7d1..d03de8bff17 100644 --- a/src/backend/commands/functioncmds.c +++ b/src/backend/commands/functioncmds.c @@ -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 |