Skip to content

Commit d25997f

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 ebc2ff0 commit d25997f

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

doc/src/sgml/libpq.sgml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5221,15 +5221,35 @@ typedef struct
52215221

52225222
<para>
52235223
<function>PQfn</function> always returns a valid
5224-
<structname>PGresult</structname> pointer. The result status should be
5224+
<structname>PGresult</structname> pointer, with
5225+
status <literal>PGRES_COMMAND_OK</literal> for success
5226+
or <literal>PGRES_FATAL_ERROR</literal> if some problem was encountered.
5227+
The result status should be
52255228
checked before the result is used. The caller is responsible for
52265229
freeing the <structname>PGresult</structname> with
52275230
<function>PQclear</function> when it is no longer needed.
52285231
</para>
52295232

52305233
<para>
5231-
Note that it is not possible to handle null arguments, null results,
5232-
nor set-valued results when using this interface.
5234+
To pass a NULL argument to the function, set
5235+
the <parameter>len</parameter> field of that parameter structure
5236+
to <literal>-1</literal>; the <parameter>isint</parameter>
5237+
and <parameter>u</parameter> fields are then irrelevant.
5238+
(But this works only in protocol 3.0 and later connections.)
5239+
</para>
5240+
5241+
<para>
5242+
If the function returns NULL, <parameter>*result_len</parameter> is set
5243+
to <literal>-1</literal>, and <parameter>*result_buf</parameter> is not
5244+
modified. (This works only in protocol 3.0 and later connections; in
5245+
protocol 2.0, neither <parameter>*result_len</parameter>
5246+
nor <parameter>*result_buf</parameter> are modified.)
5247+
</para>
5248+
5249+
<para>
5250+
Note that it is not possible to handle set-valued results when using
5251+
this interface. Also, the function must be a plain function, not an
5252+
aggregate, window function, or procedure.
52335253
</para>
52345254

52355255
</sect1>

0 commit comments

Comments
 (0)