public inbox for [email protected]  
help / color / mirror / Atom feed
From: Tom Lane <[email protected]>
To: Igor Korot <[email protected]>
Cc: pgsql-generallists.postgresql.org <[email protected]>
Subject: Re: Error on query execution
Date: Thu, 06 Mar 2025 12:00:16 -0500
Message-ID: <[email protected]> (raw)
In-Reply-To: <CA+FnnTwCMDVA4VHSsjv3OpFrrnjpyAhiMZyW0mu0X=fVmsfUpA@mail.gmail.com>
References: <CA+FnnTwkJtLq0AvY6UB7dUrdXsO28PGSqX-wBOy+LT6Ei1jD4A@mail.gmail.com>
	<[email protected]>
	<CA+FnnTwCMDVA4VHSsjv3OpFrrnjpyAhiMZyW0mu0X=fVmsfUpA@mail.gmail.com>

Igor Korot <[email protected]> writes:
> On Tue, Mar 4, 2025 at 8:37 PM Tom Lane <[email protected]> wrote:
>> ... 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.

> Changing the line above to read:

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

That just makes it explicit that the query is expecting an int16.
You're still passing an int32.  You need to either change the
parameter setup code to pass an int16, or make the query look
more like

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

			regards, tom lane






view thread (5+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: Error on query execution
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox