From: Tom Lane <tgl@sss.pgh.pa.us>
To: athinivas <athinivas@gmail.com>
Cc: pgsql-docs@postgresql.org
Subject: Re: Creating variable argument user defined functions in C
Date: Mon, 18 Sep 2017 09:41:58 -0400
Message-ID: <8945.1505742118@sss.pgh.pa.us> (raw)
In-Reply-To: <1505721147356-0.post@n3.nabble.com>
References: <1505721147356-0.post@n3.nabble.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-docs>
athinivas <athinivas@gmail.com> writes:
> For my project, I need to create a variable argument function which accepts
> multiple strings & returns some transformed string. I've gone through the
> https://www.postgresql.org/docs/9.6/static/xfunc-c.html doc..But there's no
> clear documentation for variable args.
For ordinary array types the VARIADIC marking makes no difference so far
as the function is concerned; you just treat the last argument as a normal
array. If you want to do VARIADIC ANY then the rules are different, since
the arguments aren't necessarily all the same type and so can't be folded
into an array.
> I'able to understand we can have ArrayType as data type for same. But how to
> iterate & process it??? Kindly help.
There's plenty of examples in the core code. For the normal-array
case look at anything that takes an array, e.g. json_extract_path.
For VARIADIC ANY you might look at concat() or format().
regards, tom lane
--
Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-docs@postgresql.org
Cc: tgl@sss.pgh.pa.us, athinivas@gmail.com
Subject: Re: Creating variable argument user defined functions in C
In-Reply-To: <8945.1505742118@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox