
The libpq param functions include printf-style functions, which allows
one to put multiple params at once.  There are 3 functions that allow for
variable arguments:

Format Functions:
  PQputf       - puts multiple params at once
  PQparamExecf - puts mulitple params and then calls PQparamExec
  PQparamSendf - puts mulitple params and then calls PQparamSend

Conversion Specifiers:

  %c   "char"      8-bit integer                       PQputchar

  %b   bool        8-bit integer                       PQputbool

  %s   short       16-bit integer (int2)               PQputint2

  %d   int         32-bit integer (int4)               PQputint4

  %l   long long   64-bit integer (int8)               PQputint8

  %f   float       32-bit float   (float4)             PQputfloat4

  %F   double      64-bit double  (float8)             PQputfloat8

  %a   bytea       Requires a 32-bit length followed   PQputbytea
                   by a byte array.  Example:
                      unsigned char *md5 = ...;
                      PQputf(conn, "%a", 16, md5);

  %A   byteaptr    Same requirements as '%a'           PQputbyteaptr

  %t   text        ptr to a NUL-terminated string      PQputtext

  %T   textptr     Same requirements as '%t'           PQputtextptr

  %p   point       ptr to a PGpoint                    PQputpoint

  %L   lseg        ptr to a PGlseg                     PQputlseg

  %B   box         ptr to a PGbox                      PQputbox

  %C   cicle       ptr to a PGcircle                   PQputcircle

  %P   path        ptr to a PGpath                     PQputpath

  %y   polygon     ptr to a PGpolygon                  PQputpolygon

  %i   inet        ptr to a PGinet                     PQputinet

  %m   macaddr     ptr to a PGmacaddr                  PQputmacaddr

  %S   string      ptr to a NUL-terminated string      PQputstr
                   Allows one to put the string
                   version of a pg_type.

  %n   NULL        no arguments, puts a SQL NULL       PQputnull


NOTES:
The format parser does no support $$ or $tag$ quoting.  However, it does
support escaped strings with or without the E notation: E'\x00\000'.  The
server may issue a warning if the E is not present: see
http://www.postgresql.org/docs/8.3/static/runtime-config-compatible.html#GUC-STANDARD-CONFORMING-STRINGS

When using PQputf, if an error occurs all params put prior to that error
are removed.  Any params put before calling the failed PQputf, will still
be there.

  PQputint4(conn, 10);
  PQputf(conn, "%d%d", 19, 34);

If the above PQputf fails, the connection will still have one int4 param
with a value of 10.

When using PQparamExecf or PQparamSendf, if an error occurs all params are
discarded.  This keeps things consistent with the other exec functions.

Examples:

PGresult *res;
int resultFormat = 1;
unsigned char bytea[] = {0x00, 0x01, 0x02, 0x03};

PQparamExecf(conn, resultFormat, &res,
  "SELECT * FROM myfunc($4, %c, %A, %T, %d, %l, E'\\146\\x75\\156')",
  'c', 4, bytea, "text", 100, 123456789123456LL);

This causes the below put functions to be called:

  PQputchar
  PQputbyteaptr
  PQputtextptr
  PQputint4
  PQputint8 -- WARNING: Argument must be a pointer to a 64-bit integer!

Then the generated query is exectued:

  PQparamExec(
    conn,
    "SELECT * FROM myfunc($4, $1, $2, $3, $4, $5, E'\146\x75\156')",
    resultFormat,
    res);

All conversion specifiers are replaced with $PARAM in the order they are seen
from left to right.  As you can see, you can include references to the same
params ... the example's $4 ... as long as there is a $4.


PQputf is very liberal in regards to its format string.  Unlike PQparamExecf
and PQparamSendf whose format strings include the query command, PQputf
only analyzes the conversion specifiers ... it doesn't construct a
paramatized command because it doesn't execute a query.

Valid PQputf format strings:

  "%d%a------%B" - puts 3 params: an int4, bytea and a PGbox

  "%t, %t, %d" - puts 3 params: a text, text and an int4



