diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2021-04-30 15:10:06 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2021-04-30 15:10:06 -0400 |
commit | 49172d88f9d03d063e680e45fc51dffea218add1 (patch) | |
tree | d4c24c62110d8b547b590208c88d8be992184d22 | |
parent | 0627f3630ce780e39aee0dc5881076a6148fcc18 (diff) | |
download | postgresql-49172d88f9d03d063e680e45fc51dffea218add1.tar.gz postgresql-49172d88f9d03d063e680e45fc51dffea218add1.zip |
Doc: update libpq's documentation for PQfn().
Mention specifically that you can't call aggregates, window functions,
or procedures this way (the inability to call SRFs was already
mentioned).
Also, the claim that PQfn doesn't support NULL arguments or results
has been a lie since we invented protocol 3.0. Not sure why this
text was never updated for that, but do it now.
Discussion: https://postgr.es/m/2039442.1615317309@sss.pgh.pa.us
-rw-r--r-- | doc/src/sgml/libpq.sgml | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml index 9905b2a2899..a955b1b55c4 100644 --- a/doc/src/sgml/libpq.sgml +++ b/doc/src/sgml/libpq.sgml @@ -5152,15 +5152,35 @@ typedef struct <para> <function>PQfn</function> always returns a valid - <structname>PGresult</structname> pointer. The result status should be + <structname>PGresult</structname> pointer, with + status <literal>PGRES_COMMAND_OK</literal> for success + or <literal>PGRES_FATAL_ERROR</literal> if some problem was encountered. + The result status should be checked before the result is used. The caller is responsible for freeing the <structname>PGresult</structname> with <function>PQclear</function> when it is no longer needed. </para> <para> - Note that it is not possible to handle null arguments, null results, - nor set-valued results when using this interface. + To pass a NULL argument to the function, set + the <parameter>len</parameter> field of that parameter structure + to <literal>-1</literal>; the <parameter>isint</parameter> + and <parameter>u</parameter> fields are then irrelevant. + (But this works only in protocol 3.0 and later connections.) + </para> + + <para> + If the function returns NULL, <parameter>*result_len</parameter> is set + to <literal>-1</literal>, and <parameter>*result_buf</parameter> is not + modified. (This works only in protocol 3.0 and later connections; in + protocol 2.0, neither <parameter>*result_len</parameter> + nor <parameter>*result_buf</parameter> are modified.) + </para> + + <para> + Note that it is not possible to handle set-valued results when using + this interface. Also, the function must be a plain function, not an + aggregate or window function. </para> </sect1> |