summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Momjian2008-06-23 21:10:49 +0000
committerBruce Momjian2008-06-23 21:10:49 +0000
commit804afb833eb2f9678d21e9ccc06435e40c062ba3 (patch)
treed6697f099c186b05a0d706ea0a6952b5fe449787
parente97356acf4a8275f3684d4c2317d6588f46bb41f (diff)
Add libpq comment about how to determine the format used for passing
binary values. Add comments to libpq C function for parameter passing.
-rw-r--r--doc/src/sgml/libpq.sgml8
-rw-r--r--src/interfaces/libpq/fe-exec.c4
2 files changed, 11 insertions, 1 deletions
diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml
index a052150520..5c2db0ef81 100644
--- a/doc/src/sgml/libpq.sgml
+++ b/doc/src/sgml/libpq.sgml
@@ -1397,6 +1397,14 @@ PGresult *PQexecParams(PGconn *conn,
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>
diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c
index 97bfcf990f..37f3f9946e 100644
--- a/src/interfaces/libpq/fe-exec.c
+++ b/src/interfaces/libpq/fe-exec.c
@@ -976,12 +976,13 @@ PQsendQueryGuts(PGconn *conn,
goto sendFailed;
}
- /* construct the Bind message */
+ /* 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,6 +1002,7 @@ PQsendQueryGuts(PGconn *conn,
if (pqPutInt(nParams, 2, conn) < 0)
goto sendFailed;
+ /* Send parameters */
for (i = 0; i < nParams; i++)
{
if (paramValues && paramValues[i])