Support "variadic" functions, which can accept a variable number of arguments

Tom Lane <tgl@sss.pgh.pa.us>

Commit: d89737d31c03d90a2b0412e63953493576a2a3d7
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2008-07-16T01:30:23Z
Releases: 8.4.0
Support "variadic" functions, which can accept a variable number of arguments
so long as all the trailing arguments are of the same (non-array) type.
The function receives them as a single array argument (which is why they
have to all be the same type).

It might be useful to extend this facility to aggregates, but this patch
doesn't do that.

This patch imposes a noticeable slowdown on function lookup --- a follow-on
patch will fix that by adding a redundant column to pg_proc.

Pavel Stehule

Files

PathChange+/−
doc/src/sgml/catalogs.sgml modified +10 −6
doc/src/sgml/extend.sgml modified +11 −1
doc/src/sgml/plpgsql.sgml modified +8 −1
doc/src/sgml/ref/alter_function.sgml modified +6 −5
doc/src/sgml/ref/comment.sgml modified +6 −5
doc/src/sgml/ref/create_function.sgml modified +4 −3
doc/src/sgml/ref/drop_function.sgml modified +6 −5
doc/src/sgml/typeconv.sgml modified +13 −1
doc/src/sgml/xfunc.sgml modified +131 −5
src/backend/catalog/information_schema.sql modified +2 −1
src/backend/catalog/namespace.c modified +153 −31
src/backend/catalog/pg_aggregate.c modified +4 −3
src/backend/commands/functioncmds.c modified +30 −3
src/backend/nodes/copyfuncs.c modified +2 −1
src/backend/nodes/equalfuncs.c modified +2 −1
src/backend/nodes/outfuncs.c modified +2 −1
src/backend/parser/gram.y modified +60 −7
src/backend/parser/keywords.c modified +2 −1
src/backend/parser/parse_expr.c modified +16 −20
src/backend/parser/parse_func.c modified +52 −23
src/backend/parser/parse_utilcmd.c modified +2 −1
src/backend/utils/adt/regproc.c modified +5 −4
src/backend/utils/adt/ruleutils.c modified +54 −11
src/backend/utils/fmgr/funcapi.c modified +5 −3
src/bin/pg_dump/pg_dump.c modified +7 −4
src/bin/psql/describe.c modified +3 −2
src/include/catalog/catversion.h modified +2 −2
src/include/catalog/namespace.h modified +4 −2
src/include/catalog/pg_proc.h modified +2 −1
src/include/nodes/parsenodes.h modified +4 −2
src/include/parser/parse_func.h modified +5 −5
src/interfaces/ecpg/preproc/preproc.y modified +4 −2
src/pl/plpgsql/src/pl_comp.c modified +6 −3
src/pl/plpython/plpython.c modified +4 −4
src/test/regress/expected/plpgsql.out modified +90 −0
src/test/regress/expected/polymorphism.out modified +108 −0
src/test/regress/sql/plpgsql.sql modified +47 −0
src/test/regress/sql/polymorphism.sql modified +43 −0