mirror of
https://github.com/postgres/postgres.git
synced 2025-08-25 20:23:07 +03:00
Support use of function argument names to identify which actual arguments
match which function parameters. The syntax uses AS, for example funcname(value AS arg1, anothervalue AS arg2) Pavel Stehule
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/aggregatecmds.c,v 1.49 2009/06/11 14:48:55 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/aggregatecmds.c,v 1.50 2009/10/08 02:39:18 tgl Exp $
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The "DefineFoo" routines take the parse tree and pick out the
|
||||
@@ -297,6 +297,7 @@ RenameAggregate(List *name, List *args, const char *newname)
|
||||
errmsg("function %s already exists in schema \"%s\"",
|
||||
funcname_signature_string(newname,
|
||||
procForm->pronargs,
|
||||
NIL,
|
||||
procForm->proargtypes.values),
|
||||
get_namespace_name(namespaceOid))));
|
||||
|
||||
|
@@ -10,7 +10,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.111 2009/09/22 23:43:37 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.112 2009/10/08 02:39:19 tgl Exp $
|
||||
*
|
||||
* DESCRIPTION
|
||||
* These routines take the parse tree and pick out the
|
||||
@@ -285,6 +285,39 @@ examine_parameter_list(List *parameters, Oid languageOid,
|
||||
|
||||
if (fp->name && fp->name[0])
|
||||
{
|
||||
ListCell *px;
|
||||
|
||||
/*
|
||||
* As of Postgres 8.5 we disallow using the same name for two
|
||||
* input or two output function parameters. Depending on the
|
||||
* function's language, conflicting input and output names might
|
||||
* be bad too, but we leave it to the PL to complain if so.
|
||||
*/
|
||||
foreach(px, parameters)
|
||||
{
|
||||
FunctionParameter *prevfp = (FunctionParameter *) lfirst(px);
|
||||
|
||||
if (prevfp == fp)
|
||||
break;
|
||||
/* pure in doesn't conflict with pure out */
|
||||
if ((fp->mode == FUNC_PARAM_IN ||
|
||||
fp->mode == FUNC_PARAM_VARIADIC) &&
|
||||
(prevfp->mode == FUNC_PARAM_OUT ||
|
||||
prevfp->mode == FUNC_PARAM_TABLE))
|
||||
continue;
|
||||
if ((prevfp->mode == FUNC_PARAM_IN ||
|
||||
prevfp->mode == FUNC_PARAM_VARIADIC) &&
|
||||
(fp->mode == FUNC_PARAM_OUT ||
|
||||
fp->mode == FUNC_PARAM_TABLE))
|
||||
continue;
|
||||
if (prevfp->name && prevfp->name[0] &&
|
||||
strcmp(prevfp->name, fp->name) == 0)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
|
||||
errmsg("parameter name \"%s\" used more than once",
|
||||
fp->name)));
|
||||
}
|
||||
|
||||
paramNames[i] = CStringGetTextDatum(fp->name);
|
||||
have_names = true;
|
||||
}
|
||||
@@ -1097,6 +1130,7 @@ RenameFunction(List *name, List *argtypes, const char *newname)
|
||||
errmsg("function %s already exists in schema \"%s\"",
|
||||
funcname_signature_string(newname,
|
||||
procForm->pronargs,
|
||||
NIL,
|
||||
procForm->proargtypes.values),
|
||||
get_namespace_name(namespaceOid))));
|
||||
}
|
||||
|
@@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/tsearchcmds.c,v 1.17 2009/06/11 14:48:56 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/tsearchcmds.c,v 1.18 2009/10/08 02:39:19 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -107,7 +107,7 @@ get_ts_parser_func(DefElem *defel, int attnum)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
||||
errmsg("function %s should return type %s",
|
||||
func_signature_string(funcName, nargs, typeId),
|
||||
func_signature_string(funcName, nargs, NIL, typeId),
|
||||
format_type_be(retTypeId))));
|
||||
|
||||
return ObjectIdGetDatum(procOid);
|
||||
@@ -945,7 +945,7 @@ get_ts_template_func(DefElem *defel, int attnum)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
||||
errmsg("function %s should return type %s",
|
||||
func_signature_string(funcName, nargs, typeId),
|
||||
func_signature_string(funcName, nargs, NIL, typeId),
|
||||
format_type_be(retTypeId))));
|
||||
|
||||
return ObjectIdGetDatum(procOid);
|
||||
|
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.137 2009/07/30 02:45:36 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.138 2009/10/08 02:39:19 tgl Exp $
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The "DefineFoo" routines take the parse tree and pick out the
|
||||
@@ -1267,7 +1267,7 @@ findTypeInputFunction(List *procname, Oid typeOid)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_FUNCTION),
|
||||
errmsg("function %s does not exist",
|
||||
func_signature_string(procname, 1, argList))));
|
||||
func_signature_string(procname, 1, NIL, argList))));
|
||||
|
||||
return InvalidOid; /* keep compiler quiet */
|
||||
}
|
||||
@@ -1318,7 +1318,7 @@ findTypeOutputFunction(List *procname, Oid typeOid)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_FUNCTION),
|
||||
errmsg("function %s does not exist",
|
||||
func_signature_string(procname, 1, argList))));
|
||||
func_signature_string(procname, 1, NIL, argList))));
|
||||
|
||||
return InvalidOid; /* keep compiler quiet */
|
||||
}
|
||||
@@ -1349,7 +1349,7 @@ findTypeReceiveFunction(List *procname, Oid typeOid)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_FUNCTION),
|
||||
errmsg("function %s does not exist",
|
||||
func_signature_string(procname, 1, argList))));
|
||||
func_signature_string(procname, 1, NIL, argList))));
|
||||
|
||||
return InvalidOid; /* keep compiler quiet */
|
||||
}
|
||||
@@ -1372,7 +1372,7 @@ findTypeSendFunction(List *procname, Oid typeOid)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_FUNCTION),
|
||||
errmsg("function %s does not exist",
|
||||
func_signature_string(procname, 1, argList))));
|
||||
func_signature_string(procname, 1, NIL, argList))));
|
||||
|
||||
return InvalidOid; /* keep compiler quiet */
|
||||
}
|
||||
@@ -1393,7 +1393,7 @@ findTypeTypmodinFunction(List *procname)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_FUNCTION),
|
||||
errmsg("function %s does not exist",
|
||||
func_signature_string(procname, 1, argList))));
|
||||
func_signature_string(procname, 1, NIL, argList))));
|
||||
|
||||
if (get_func_rettype(procOid) != INT4OID)
|
||||
ereport(ERROR,
|
||||
@@ -1420,7 +1420,7 @@ findTypeTypmodoutFunction(List *procname)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_FUNCTION),
|
||||
errmsg("function %s does not exist",
|
||||
func_signature_string(procname, 1, argList))));
|
||||
func_signature_string(procname, 1, NIL, argList))));
|
||||
|
||||
if (get_func_rettype(procOid) != CSTRINGOID)
|
||||
ereport(ERROR,
|
||||
@@ -1447,7 +1447,7 @@ findTypeAnalyzeFunction(List *procname, Oid typeOid)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_FUNCTION),
|
||||
errmsg("function %s does not exist",
|
||||
func_signature_string(procname, 1, argList))));
|
||||
func_signature_string(procname, 1, NIL, argList))));
|
||||
|
||||
if (get_func_rettype(procOid) != BOOLOID)
|
||||
ereport(ERROR,
|
||||
|
Reference in New Issue
Block a user