Re: [DOCS] Creating variable argument user defined functions in C

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [DOCS] Creating variable argument user defined functions in C
Дата
Msg-id 8945.1505742118@sss.pgh.pa.us
обсуждение исходный текст
Ответ на [DOCS] Creating variable argument user defined functions in C  (athinivas <athinivas@gmail.com>)
Ответы Re: [DOCS] Creating variable argument user defined functions in C  (athinivas <athinivas@gmail.com>)
Список pgsql-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

В списке pgsql-docs по дате отправления:

Предыдущее
От: athinivas
Дата:
Сообщение: [DOCS] Creating variable argument user defined functions in C
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: [DOCS] Docbook 5.x