The documentation for PQexecPrepared says:

    (There is not currently a provision to obtain different result
    columns in different formats, although that is possible in the
    underlying protocol.)

Would anyone be interested in a patch to allow this?

I could, for example, change PQsendQueryGuts to do something like:

static int PQsendQueryGuts( PGconn *conn,
                            const char *command,
                            const char *stmtName,
                            int nParams,
                            const Oid *paramTypes,
                            const char *const *paramValues,
                            const int *paramLengths,
                            const int *paramFormats,
                            int resultFormat,
                            ... ) /* Add this last argument. */
{
    ...

    if ( resultFormat == -1 ) { /* or == nParams, perhaps? */
        va_list args;
        const int *resultFormats;

        va_start( args, resultFormat );
        resultFormats = va_arg( args, const int * );
        va_end( args );

        if ( pqPutInt( nParams, 2, conn ) < 0 )
            goto sendFailed;
        for ( i = 0; i < nParams; i++ )
            if ( pqPutInt( resultFormats[i], 2, conn ) < 0 )
                goto sendFailed;
    }
    /* This is what libpq does already. */
    else if ( pqPutInt( 1, 2, conn ) < 0 ||
              pqPutInt( resultFormat, 2, conn ) )
        goto sendFailed;

    ...
}

And then teach the other API functions (PQexecParams, PQsendQueryParams,
PQsendQueryPrepared) to accept and pass on the extra ... argument. That
wouldn't break existing code, and new users could set resultFormat to
invoke the new behaviour. It seems a bit ugly, but on the other hand,
it doesn't seem worthwhile to add a new interface for this behaviour.

Thoughts?

-- ams

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to [EMAIL PROTECTED] so that your
      message can get through to the mailing list cleanly

Reply via email to