aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/functioncmds.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-01-06 23:55:19 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-01-06 23:55:19 +0000
commita77e32d7c5615e302fbc87803086132f1dab99a9 (patch)
treeb03a6846d6909d6b1acb81c82a1e8fe3b98dbbb2 /src/backend/commands/functioncmds.c
parent488f2785d025a6cc04685cfee4ca3eac0086e2fd (diff)
downloadpostgresql-a77e32d7c5615e302fbc87803086132f1dab99a9.tar.gz
postgresql-a77e32d7c5615e302fbc87803086132f1dab99a9.zip
Apply the core parts of Dennis Bjorklund's patch to allow function
parameters to be declared with names. pg_proc has a column to store names, and CREATE FUNCTION can insert data into it, but that's all as yet. I need to do more work on the pg_dump and plpgsql portions of the patch before committing those, but I thought I'd get the bulky changes in before the tree drifts under me. initdb forced due to pg_proc change.
Diffstat (limited to 'src/backend/commands/functioncmds.c')
-rw-r--r--src/backend/commands/functioncmds.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c
index 05bc52d9de5..2eb4c100a2b 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.42 2003/11/29 19:51:47 pgsql Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.43 2004/01/06 23:55:18 tgl Exp $
*
* DESCRIPTION
* These routines take the parse tree and pick out the
@@ -130,19 +130,22 @@ compute_return_type(TypeName *returnType, Oid languageOid,
}
/*
- * Interpret the argument-types list of the CREATE FUNCTION statement.
+ * Interpret the parameter list of the CREATE FUNCTION statement.
*/
static int
-compute_parameter_types(List *argTypes, Oid languageOid,
- Oid *parameterTypes)
+examine_parameter_list(List *parameter, Oid languageOid,
+ Oid *parameterTypes, const char *parameterNames[])
{
int parameterCount = 0;
List *x;
MemSet(parameterTypes, 0, FUNC_MAX_ARGS * sizeof(Oid));
- foreach(x, argTypes)
+ MemSet(parameterNames, 0, FUNC_MAX_ARGS * sizeof(char *));
+
+ foreach(x, parameter)
{
- TypeName *t = (TypeName *) lfirst(x);
+ FunctionParameter *fp = (FunctionParameter *) lfirst(x);
+ TypeName *t = fp->argType;
Oid toid;
if (parameterCount >= FUNC_MAX_ARGS)
@@ -182,7 +185,11 @@ compute_parameter_types(List *argTypes, Oid languageOid,
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
errmsg("functions cannot accept set arguments")));
- parameterTypes[parameterCount++] = toid;
+ parameterTypes[parameterCount] = toid;
+
+ parameterNames[parameterCount] = fp->name;
+
+ parameterCount++;
}
return parameterCount;
@@ -402,6 +409,7 @@ CreateFunction(CreateFunctionStmt *stmt)
AclResult aclresult;
int parameterCount;
Oid parameterTypes[FUNC_MAX_ARGS];
+ const char *parameterNames[FUNC_MAX_ARGS];
bool isStrict,
security;
char volatility;
@@ -480,8 +488,8 @@ CreateFunction(CreateFunctionStmt *stmt)
compute_return_type(stmt->returnType, languageOid,
&prorettype, &returnsSet);
- parameterCount = compute_parameter_types(stmt->argTypes, languageOid,
- parameterTypes);
+ parameterCount = examine_parameter_list(stmt->parameters, languageOid,
+ parameterTypes, parameterNames);
compute_attributes_with_style(stmt->withClause, &isStrict, &volatility);
@@ -527,7 +535,8 @@ CreateFunction(CreateFunctionStmt *stmt)
isStrict,
volatility,
parameterCount,
- parameterTypes);
+ parameterTypes,
+ parameterNames);
}