Content-Length: 416808 | pFad | http://github.com/postgrespro/postgres/commit/a07bd32f2b130a67bf285f8ef5f1fe4ebcc3a5b8

F8 Fix documentation for libpq's PQfn(). · postgrespro/postgres@a07bd32 · GitHub
Skip to content

Commit a07bd32

Browse files
committed
Fix documentation for libpq's PQfn().
The SGML docs claimed that 1-byte integers could be sent or received with the "isint" options, but no such behavior has ever been implemented in pqGetInt() or pqPutInt(). The in-code documentation header for PQfn() was even less in tune with reality, and the code itself used parameter names matching neither the SGML docs nor its libpq-fe.h declaration. Do a bit of additional wordsmithing on the SGML docs while at it. Since the business about 1-byte integers is a clear documentation bug, back-patch to all supported branches.
1 parent 71b8e8e commit a07bd32

File tree

2 files changed

+25
-20
lines changed

2 files changed

+25
-20
lines changed

doc/src/sgml/libpq.sgml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4134,22 +4134,29 @@ typedef struct
41344134
parameters to be passed to the function; they must match the declared
41354135
function argument list. When the <parameter>isint</> field of a
41364136
parameter structure is true, the <parameter>u.integer</> value is sent
4137-
to the server as an integer of the indicated length (this must be 1,
4138-
2, or 4 bytes); proper byte-swapping occurs. When <parameter>isint</>
4137+
to the server as an integer of the indicated length (this must be
4138+
2 or 4 bytes); proper byte-swapping occurs. When <parameter>isint</>
41394139
is false, the indicated number of bytes at <parameter>*u.ptr</> are
41404140
sent with no processing; the data must be in the format expected by
41414141
the server for binary transmission of the function's argument data
4142-
type. <parameter>result_buf</parameter> is the buffer in which to
4143-
place the return value. The caller must have allocated sufficient
4142+
type. (The declaration of <parameter>u.ptr</> as being of
4143+
type <type>int *</> is historical; it would be better to consider
4144+
it <type>void *</>.)
4145+
<parameter>result_buf</parameter> points to the buffer in which to place
4146+
the function's return value. The caller must have allocated sufficient
41444147
space to store the return value. (There is no check!) The actual result
4145-
length will be returned in the integer pointed to by
4146-
<parameter>result_len</parameter>. If a 1, 2, or 4-byte integer result
4148+
length in bytes will be returned in the integer pointed to by
4149+
<parameter>result_len</parameter>. If a 2- or 4-byte integer result
41474150
is expected, set <parameter>result_is_int</parameter> to 1, otherwise
41484151
set it to 0. Setting <parameter>result_is_int</parameter> to 1 causes
41494152
<application>libpq</> to byte-swap the value if necessary, so that it
4150-
is delivered as a proper <type>int</type> value for the client machine.
4153+
is delivered as a proper <type>int</type> value for the client machine;
4154+
note that a 4-byte integer is delivered into <parameter>*result_buf</>
4155+
for either allowed result size.
41514156
When <parameter>result_is_int</> is 0, the binary-format byte string
4152-
sent by the server is returned unmodified.
4157+
sent by the server is returned unmodified. (In this case it's better
4158+
to consider <parameter>result_buf</parameter> as being of
4159+
type <type>void *</>.)
41534160
</para>
41544161

41554162
<para>

src/interfaces/libpq/fe-exec.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2322,20 +2322,18 @@ PQendcopy(PGconn *conn)
23222322
* PQfn - Send a function call to the POSTGRES backend.
23232323
*
23242324
* conn : backend connection
2325-
* fnid : function id
2326-
* result_buf : pointer to result buffer (&int if integer)
2327-
* result_len : length of return value.
2328-
* actual_result_len: actual length returned. (differs from result_len
2329-
* for varlena structures.)
2330-
* result_type : If the result is an integer, this must be 1,
2325+
* fnid : OID of function to be called
2326+
* result_buf : pointer to result buffer
2327+
* result_len : actual length of result is returned here
2328+
* result_is_int : If the result is an integer, this must be 1,
23312329
* otherwise this should be 0
2332-
* args : pointer to an array of function arguments.
2330+
* args : pointer to an array of function arguments
23332331
* (each has length, if integer, and value/pointer)
23342332
* nargs : # of arguments in args array.
23352333
*
23362334
* RETURNS
23372335
* PGresult with status = PGRES_COMMAND_OK if successful.
2338-
* *actual_result_len is > 0 if there is a return value, 0 if not.
2336+
* *result_len is > 0 if there is a return value, 0 if not.
23392337
* PGresult with status = PGRES_FATAL_ERROR if backend returns an error.
23402338
* NULL on communications failure. conn->errorMessage will be set.
23412339
* ----------------
@@ -2345,12 +2343,12 @@ PGresult *
23452343
PQfn(PGconn *conn,
23462344
int fnid,
23472345
int *result_buf,
2348-
int *actual_result_len,
2346+
int *result_len,
23492347
int result_is_int,
23502348
const PQArgBlock *args,
23512349
int nargs)
23522350
{
2353-
*actual_result_len = 0;
2351+
*result_len = 0;
23542352

23552353
if (!conn)
23562354
return NULL;
@@ -2368,12 +2366,12 @@ PQfn(PGconn *conn,
23682366

23692367
if (PG_PROTOCOL_MAJOR(conn->pversion) >= 3)
23702368
return pqFunctionCall3(conn, fnid,
2371-
result_buf, actual_result_len,
2369+
result_buf, result_len,
23722370
result_is_int,
23732371
args, nargs);
23742372
else
23752373
return pqFunctionCall2(conn, fnid,
2376-
result_buf, actual_result_len,
2374+
result_buf, result_len,
23772375
result_is_int,
23782376
args, nargs);
23792377
}

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres/commit/a07bd32f2b130a67bf285f8ef5f1fe4ebcc3a5b8

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy