3

It's definitely possible to define such a function through the C API as can be witnessed by looking at json_build_array() for example:

enter image description here

Unfortunately trying to create a SQL or pl/pgSQL function like this fails

CREATE OR REPLACE FUNCTION my_function( VARIADIC _args anyelement[]) RETURNS ...

and this is no surprise as the PostgreSQL documentation mentions that 'VARIADIC' only works for arrays (and it seems there is no such thing as an anyelement[]). Does anybody know how to get this working without having to write a C function ?

1
  • Don't have time for full answer. I can point you at here. Search for polymorphic. That will also lead you to Polymorphic Types. Commented Oct 21, 2020 at 15:18

1 Answer 1

1

There is not possibility now. PLpgSQL and SQL languages are out of game, because there are not arrays with fields of different types. And PL/Perl or PL/Python just doesn't support, it what I know.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.