Skip to content

Commit 2033d10

Browse files
committed
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
1 parent 73bad52 commit 2033d10

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

doc/src/sgml/libpq.sgml

+23-3
Original file line numberDiff line numberDiff line change
@@ -4922,15 +4922,35 @@ typedef struct
49224922

49234923
<para>
49244924
<function>PQfn</function> always returns a valid
4925-
<structname>PGresult</structname> pointer. The result status should be
4925+
<structname>PGresult</structname> pointer, with
4926+
status <literal>PGRES_COMMAND_OK</literal> for success
4927+
or <literal>PGRES_FATAL_ERROR</literal> if some problem was encountered.
4928+
The result status should be
49264929
checked before the result is used. The caller is responsible for
49274930
freeing the <structname>PGresult</structname> with
49284931
<function>PQclear</function> when it is no longer needed.
49294932
</para>
49304933

49314934
<para>
4932-
Note that it is not possible to handle null arguments, null results,
4933-
nor set-valued results when using this interface.
4935+
To pass a NULL argument to the function, set
4936+
the <parameter>len</parameter> field of that parameter structure
4937+
to <literal>-1</literal>; the <parameter>isint</parameter>
4938+
and <parameter>u</parameter> fields are then irrelevant.
4939+
(But this works only in protocol 3.0 and later connections.)
4940+
</para>
4941+
4942+
<para>
4943+
If the function returns NULL, <parameter>*result_len</parameter> is set
4944+
to <literal>-1</literal>, and <parameter>*result_buf</parameter> is not
4945+
modified. (This works only in protocol 3.0 and later connections; in
4946+
protocol 2.0, neither <parameter>*result_len</parameter>
4947+
nor <parameter>*result_buf</parameter> are modified.)
4948+
</para>
4949+
4950+
<para>
4951+
Note that it is not possible to handle set-valued results when using
4952+
this interface. Also, the function must be a plain function, not an
4953+
aggregate or window function.
49344954
</para>
49354955

49364956
</sect1>

0 commit comments

Comments
 (0)