diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2006-04-15 17:45:46 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2006-04-15 17:45:46 +0000 |
commit | 3651a3e6fb41121f2262577774382e84bf9a3177 (patch) | |
tree | e09fb8fcf6851e4625f4eb5595ede6f16367056f /src/backend/commands/functioncmds.c | |
parent | ebd5257d493ac8a6f20eea667409cf9b06ac3202 (diff) | |
download | postgresql-3651a3e6fb41121f2262577774382e84bf9a3177.tar.gz postgresql-3651a3e6fb41121f2262577774382e84bf9a3177.zip |
Support the syntax
CREATE AGGREGATE aggname (input_type) (parameter_list)
along with the old syntax where the input type was named in the parameter
list. This fits more naturally with the way that the aggregate is identified
in DROP AGGREGATE and other utility commands; furthermore it has a natural
extension to handle multiple-input aggregates, where the basetype-parameter
method would get ugly. In fact, this commit fixes the grammar and all the
utility commands to support multiple-input aggregates; but DefineAggregate
rejects it because the executor isn't fixed yet.
I didn't do anything about treating agg(*) as a zero-input aggregate instead
of artificially making it a one-input aggregate, but that should be considered
in combination with supporting multi-input aggregates.
Diffstat (limited to 'src/backend/commands/functioncmds.c')
-rw-r--r-- | src/backend/commands/functioncmds.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c index 1da1cf66cb3..96929a0d6c4 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.73 2006/03/14 22:48:18 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.74 2006/04/15 17:45:34 tgl Exp $ * * DESCRIPTION * These routines take the parse tree and pick out the @@ -678,7 +678,7 @@ CreateFunction(CreateFunctionStmt *stmt) void RemoveFunction(RemoveFuncStmt *stmt) { - List *functionName = stmt->funcname; + List *functionName = stmt->name; List *argTypes = stmt->args; /* list of TypeName nodes */ Oid funcOid; HeapTuple tup; @@ -1440,10 +1440,13 @@ DropCastById(Oid castOid) } /* - * Execute ALTER FUNCTION SET SCHEMA + * Execute ALTER FUNCTION/AGGREGATE SET SCHEMA + * + * These commands are identical except for the lookup procedure, so share code. */ void -AlterFunctionNamespace(List *name, List *argtypes, const char *newschema) +AlterFunctionNamespace(List *name, List *argtypes, bool isagg, + const char *newschema) { Oid procOid; Oid oldNspOid; @@ -1455,7 +1458,10 @@ AlterFunctionNamespace(List *name, List *argtypes, const char *newschema) procRel = heap_open(ProcedureRelationId, RowExclusiveLock); /* get function OID */ - procOid = LookupFuncNameTypeNames(name, argtypes, false); + if (isagg) + procOid = LookupAggNameTypeNames(name, argtypes, false); + else + procOid = LookupFuncNameTypeNames(name, argtypes, false); /* check permissions on function */ if (!pg_proc_ownercheck(procOid, GetUserId())) |