Re: Error on query execution

Поиск
Список
Период
Сортировка
От Igor Korot
Тема Re: Error on query execution
Дата
Msg-id CA+FnnTw5k=0_WT1j1hDKRPQMaF8=Y449Z1NoP-iMiU1LTTqHkQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Error on query execution  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
Tom,

On Tue, Mar 4, 2025, 8:37 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Igor Korot <ikorot01@gmail.com> writes:
>     binaryIntVal = htonl( (uint32_t) type );
>     paramValues[0] = (char *) &binaryIntVal;
>     paramLengths[0] = sizeof( binaryIntVal );
>     paramFormats[0] = 1;

You're apparently trying to pass this parameter as an int4 ...

I thought only binary or text is allowed as parameters.

Guess I was wrong...

Thank you.


>     res = PQexecParams( m_db, "SELECT * FROM abcatfmt WHERE abf_type =
> $1", 1, nullptr, paramValues, paramLengths, paramFormats, 1 );

... but given that you didn't specify any data type, I think the
parser will fall back to assuming that $1 is the same type as
"abf_type", whatever that is.  Passing data in binary is not at all
forgiving about getting the data type right.

                        regards, tom lane

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