specifying multiple result format codes with libpq

Поиск
Список
Период
Сортировка
От Abhijit Menon-Sen
Тема specifying multiple result format codes with libpq
Дата
Msg-id 20040618203245.A13980@lustre.dyn.wiw.org
обсуждение исходный текст
Ответы Re: specifying multiple result format codes with libpq  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
The documentation for PQexecPrepared says:
   (There is not currently a provision to obtain different result   columns in different formats, although that is
possiblein 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,
constchar *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


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: SPI equivalent for libpq PQftable & PQFtablecolumn
Следующее
От: Tom Lane
Дата:
Сообщение: Re: korean encoding, but sort order bad