Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit089e5ab

Browse files
committed
Fix documentation for libpq's PQfn().
The SGML docs claimed that 1-byte integers could be sent or received withthe "isint" options, but no such behavior has ever been implemented inpqGetInt() or pqPutInt(). The in-code documentation header for PQfn() waseven less in tune with reality, and the code itself used parameter namesmatching neither the SGML docs nor its libpq-fe.h declaration. Do a bitof 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 parent629f861 commit089e5ab

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
@@ -4687,22 +4687,29 @@ typedef struct
46874687
parameters to be passed to the function; they must match the declared
46884688
function argument list. When the <parameter>isint</> field of a
46894689
parameter structure is true, the <parameter>u.integer</> value is sent
4690-
to the server as an integer of the indicated length (this must be 1,
4691-
2, or 4 bytes); proper byte-swapping occurs. When <parameter>isint</>
4690+
to the server as an integer of the indicated length (this must be
4691+
2 or 4 bytes); proper byte-swapping occurs. When <parameter>isint</>
46924692
is false, the indicated number of bytes at <parameter>*u.ptr</> are
46934693
sent with no processing; the data must be in the format expected by
46944694
the server for binary transmission of the function's argument data
4695-
type. <parameter>result_buf</parameter> is the buffer in which to
4696-
place the return value. The caller must have allocated sufficient
4695+
type. (The declaration of <parameter>u.ptr</> as being of
4696+
type <type>int *</> is historical; it would be better to consider
4697+
it <type>void *</>.)
4698+
<parameter>result_buf</parameter> points to the buffer in which to place
4699+
the function's return value. The caller must have allocated sufficient
46974700
space to store the return value. (There is no check!) The actual result
4698-
length will be returned in the integer pointed to by
4699-
<parameter>result_len</parameter>. If a1, 2, or 4-byte integer result
4701+
lengthin byteswill be returned in the integer pointed to by
4702+
<parameter>result_len</parameter>. If a2- or 4-byte integer result
47004703
is expected, set <parameter>result_is_int</parameter> to 1, otherwise
47014704
set it to 0. Setting <parameter>result_is_int</parameter> to 1 causes
47024705
<application>libpq</> to byte-swap the value if necessary, so that it
4703-
is delivered as a proper <type>int</type> value for the client machine.
4706+
is delivered as a proper <type>int</type> value for the client machine;
4707+
note that a 4-byte integer is delivered into <parameter>*result_buf</>
4708+
for either allowed result size.
47044709
When <parameter>result_is_int</> is 0, the binary-format byte string
4705-
sent by the server is returned unmodified.
4710+
sent by the server is returned unmodified. (In this case it's better
4711+
to consider <parameter>result_buf</parameter> as being of
4712+
type <type>void *</>.)
47064713
</para>
47074714

47084715
<para>

‎src/interfaces/libpq/fe-exec.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2513,20 +2513,18 @@ PQendcopy(PGconn *conn)
25132513
*PQfn -Send a function call to the POSTGRES backend.
25142514
*
25152515
*conn: backend connection
2516-
*fnid: function id
2517-
*result_buf: pointer to result buffer (&int if integer)
2518-
*result_len: length of return value.
2519-
*actual_result_len: actual length returned. (differs from result_len
2520-
* for varlena structures.)
2521-
*result_type: If the result is an integer, this must be 1,
2516+
*fnid: OID of function to be called
2517+
*result_buf: pointer to result buffer
2518+
*result_len: actual length of result is returned here
2519+
*result_is_int: If the result is an integer, this must be 1,
25222520
* otherwise this should be 0
2523-
*args: pointer to an array of function arguments.
2521+
*args: pointer to an array of function arguments
25242522
* (each has length, if integer, and value/pointer)
25252523
*nargs: # of arguments in args array.
25262524
*
25272525
* RETURNS
25282526
*PGresult with status = PGRES_COMMAND_OK if successful.
2529-
**actual_result_len is > 0 if there is a return value, 0 if not.
2527+
**result_len is > 0 if there is a return value, 0 if not.
25302528
*PGresult with status = PGRES_FATAL_ERROR if backend returns an error.
25312529
*NULL on communications failure. conn->errorMessage will be set.
25322530
* ----------------
@@ -2536,12 +2534,12 @@ PGresult *
25362534
PQfn(PGconn*conn,
25372535
intfnid,
25382536
int*result_buf,
2539-
int*actual_result_len,
2537+
int*result_len,
25402538
intresult_is_int,
25412539
constPQArgBlock*args,
25422540
intnargs)
25432541
{
2544-
*actual_result_len=0;
2542+
*result_len=0;
25452543

25462544
if (!conn)
25472545
returnNULL;
@@ -2559,12 +2557,12 @@ PQfn(PGconn *conn,
25592557

25602558
if (PG_PROTOCOL_MAJOR(conn->pversion) >=3)
25612559
returnpqFunctionCall3(conn,fnid,
2562-
result_buf,actual_result_len,
2560+
result_buf,result_len,
25632561
result_is_int,
25642562
args,nargs);
25652563
else
25662564
returnpqFunctionCall2(conn,fnid,
2567-
result_buf,actual_result_len,
2565+
result_buf,result_len,
25682566
result_is_int,
25692567
args,nargs);
25702568
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp