I need to find a way to dump key/value pairs of PL/pgSQL function input parameters:
CREATE OR REPLACE FUNCTION _test(A text, B text)
...
raise info 'Params dump: %', _x;
...
when executed:
select _text('HELLO', 'WORLD');
the function raises info as follows:
'A = HELLO, B = WORLD'
Is there a way to dump input parameter key/value pairs into a variable?
It’s possible if you can make the function
VARIADICwith uniform argument types, and can print the array. You don’t get argument names, since they don’t have names, but you do get argument positions.Otherwise no, it is not possible in PL/PgSQL, though it should be in other PLs like PL/Perl, PL/Python, etc.
It’d be quite nice to be able to get a
RECORDwith all the function arguments in it, so you could print it, feed it to thehstoreextension, etc, but this isn’t currently possible.