Hello, there is one implementation of variadic functions. The base premis is transformation type:
anyparams -> n x any anyelements -> n x anyelement Currently variadic functions can be only in C language. PL/pgSQL cannot access to array of params. I implented some JSON functions (based on Bauman's libraries for MySQL). With this extension we are able to write some sophistic libraries. What do you thing about this concept? Has any sense continue in this project? Regards Pavel Stehule postgres=# select json_members('aaa',1,'cccc',20); json_members ------------------- "aaa":1,"cccc":20 (1 row) postgres=# select json_members('aaa',1); json_members -------------- "aaa":1 (1 row) postgres=# select * from fog; a | b | c ---+------+------------ | ahoj | | ahoj | 2008-01-26 1 | | 2008-01-26 (3 rows) postgres=# select json_object(a,b,c as cc) from fog; json_object ---------------------------------- {a:NaN,b:"ahoj",cc:null} {a:NaN,b:"ahoj",cc:"2008-01-26"} {a:1,b:null,cc:"2008-01-26"} (3 rows) postgres=# select json_object('Pavel' as name, 'Stehule' as surname); json_object ---------------------------------- {name:"Pavel",surname:"Stehule"} (1 row) postgres=# select json_array(a,b,c) from fog; json_array --------------------------- [NaN,"ahoj",null] [NaN,"ahoj","2008-01-26"] [1,null,"2008-01-26"] (3 rows) CREATE OR REPLACE FUNCTION json_array(anyparams) RETURNS json AS 'MODULE_PATHNAME' LANGUAGE C IMMUTABLE; CREATE OR REPLACE FUNCTION json_object(anyparams) RETURNS json AS 'MODULE_PATHNAME' LANGUAGE C IMMUTABLE; CREATE OR REPLACE FUNCTION json_members(anyparams) RETURNS json AS 'MODULE_PATHNAME' LANGUAGE C IMMUTABLE;
variadic_functions.diff.gz
Description: GNU Zip compressed data
json.tgz
Description: GNU Zip compressed data
---------------------------(end of broadcast)--------------------------- TIP 6: explain analyze is your friend