Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 7c810bd

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 4d225ba commit 7c810bd

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
@@ -5155,15 +5155,35 @@ typedef struct
51555155

51565156
<para>
51575157
<function>PQfn</function> always returns a valid
5158-
<structname>PGresult</structname> pointer. The result status should be
5158+
<structname>PGresult</structname> pointer, with
5159+
status <literal>PGRES_COMMAND_OK</literal> for success
5160+
or <literal>PGRES_FATAL_ERROR</literal> if some problem was encountered.
5161+
The result status should be
51595162
checked before the result is used. The caller is responsible for
51605163
freeing the <structname>PGresult</structname> with
51615164
<xref linkend="libpq-PQclear"/> when it is no longer needed.
51625165
</para>
51635166

51645167
<para>
5165-
Note that it is not possible to handle null arguments, null results,
5166-
nor set-valued results when using this interface.
5168+
To pass a NULL argument to the function, set
5169+
the <parameter>len</parameter> field of that parameter structure
5170+
to <literal>-1</literal>; the <parameter>isint</parameter>
5171+
and <parameter>u</parameter> fields are then irrelevant.
5172+
(But this works only in protocol 3.0 and later connections.)
5173+
</para>
5174+
5175+
<para>
5176+
If the function returns NULL, <parameter>*result_len</parameter> is set
5177+
to <literal>-1</literal>, and <parameter>*result_buf</parameter> is not
5178+
modified. (This works only in protocol 3.0 and later connections; in
5179+
protocol 2.0, neither <parameter>*result_len</parameter>
5180+
nor <parameter>*result_buf</parameter> are modified.)
5181+
</para>
5182+
5183+
<para>
5184+
Note that it is not possible to handle set-valued results when using
5185+
this interface. Also, the function must be a plain function, not an
5186+
aggregate, window function, or procedure.
51675187
</para>
51685188

51695189
</sect1>

0 commit comments

Comments
 (0)