Aleksej Saushev wrote:
>
> The following bug has been logged online:
>
> Bug reference: 4053
> Logged by: Aleksej Saushev
> Email address: [EMAIL PROTECTED]
> PostgreSQL version: 8.3
> Operating system: NetBSD, but this does no matter
> Description: libpq documentation should express clearly, that
> integers are passed in network octet order
> Details:
>
> The documentation on PQexecParams is silent about the precise format,
> expected by server for binary parameters, it should be more explicit
> and note that integers are expected in network octet order.
I have added this libpq documentation paragraph about how to determine
how to pass binary values. I also added a few comments to the libpq C
code.
Thanks for the report; please let me know if I can improve it more.
--
Bruce Momjian <[EMAIL PROTECTED]> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ If your life is a hard drive, Christ can be your backup. +
Index: doc/src/sgml/libpq.sgml
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/libpq.sgml,v
retrieving revision 1.258
diff -c -c -r1.258 libpq.sgml
*** doc/src/sgml/libpq.sgml 1 Jun 2008 16:23:08 -0000 1.258
--- doc/src/sgml/libpq.sgml 23 Jun 2008 21:09:39 -0000
***************
*** 1397,1402 ****
--- 1397,1410 ----
If the array pointer is null then all parameters are presumed
to be text strings.
</para>
+ <para>
+ Values passed in binary format require knowlege of
+ the internal representation expected by the backend.
+ For example, integers must be passed in network byte
+ order. Passing <type>numeric</> values requires
+ knowledge of the server storage format, as implemented
+ in <filename>src/backend/utils/adt/numeric.c</>.
+ </para>
</listitem>
</varlistentry>
Index: src/interfaces/libpq/fe-exec.c
===================================================================
RCS file: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v
retrieving revision 1.195
diff -c -c -r1.195 fe-exec.c
*** src/interfaces/libpq/fe-exec.c 29 May 2008 22:02:44 -0000 1.195
--- src/interfaces/libpq/fe-exec.c 23 Jun 2008 21:09:39 -0000
***************
*** 976,987 ****
goto sendFailed;
}
! /* construct the Bind message */
if (pqPutMsgStart('B', false, conn) < 0 ||
pqPuts("", conn) < 0 ||
pqPuts(stmtName, conn) < 0)
goto sendFailed;
if (nParams > 0 && paramFormats)
{
if (pqPutInt(nParams, 2, conn) < 0)
--- 976,988 ----
goto sendFailed;
}
! /* Construct the Bind message */
if (pqPutMsgStart('B', false, conn) < 0 ||
pqPuts("", conn) < 0 ||
pqPuts(stmtName, conn) < 0)
goto sendFailed;
+ /* Send parameter formats */
if (nParams > 0 && paramFormats)
{
if (pqPutInt(nParams, 2, conn) < 0)
***************
*** 1001,1006 ****
--- 1002,1008 ----
if (pqPutInt(nParams, 2, conn) < 0)
goto sendFailed;
+ /* Send parameters */
for (i = 0; i < nParams; i++)
{
if (paramValues && paramValues[i])
--
Sent via pgsql-bugs mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs