Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tpzWE-00FIZ9-1u for pgsql-general@arkaria.postgresql.org; Thu, 06 Mar 2025 00:55:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tpzWC-00B76I-F2 for pgsql-general@arkaria.postgresql.org; Thu, 06 Mar 2025 00:55:20 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tpzWC-00B75o-43 for pgsql-general@lists.postgresql.org; Thu, 06 Mar 2025 00:55:20 +0000 Received: from mail-yw1-x1130.google.com ([2607:f8b0:4864:20::1130]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tpzW8-001Cgf-2Z for pgsql-general@lists.postgresql.org; Thu, 06 Mar 2025 00:55:19 +0000 Received: by mail-yw1-x1130.google.com with SMTP id 00721157ae682-6fd4dcf2df7so1180277b3.0 for ; Wed, 05 Mar 2025 16:55:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741222517; x=1741827317; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=4Iil1CVVXVL/iOwpFOMwpnVB18JZYSwHH1678m728yo=; b=XHQ3wTxG7rM4FGHkyB2IOIEqna2KUoiD1tN0wNJUfn0yruVMgPHQNvsr82AS0UANsm 1XhcDE5TNZN0cBgKud3lpM2yOzdF17g3fQlFjdA+Gsvjy0Tzf1MiHyAEqlaRaf9bosDu sg6Mt1Uos6583oK1OlQoc9kHEQ2u3CNe2MtcpOE7rhFAEgitMJHuIn6/TivKVsEBDZ4O iicwwOPH4kIMFTGFgsANs1YR/UJpGU0oodo6B3WgoKKrw5emLaD6IuL/xc761Znb5+w4 0KJ/MiznyYEbZCIxcTmFYqb9+ajcL4K2lYQZhq4BdD1cAy515cyDxrGAl4GBNOIofF6m 03Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741222517; x=1741827317; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=4Iil1CVVXVL/iOwpFOMwpnVB18JZYSwHH1678m728yo=; b=NnusCwxRnCb1tOPy8Lkc1r1CJv3HjpViyxZAc/iZBZbTmu+24AxhaFQPXiDChEdeU6 FDto4zqRastlwwIA6t7qjN4BpWthkogklxMe1+W+5C1JWKGqcV+HGzg7BUhvYLX9ZWZp P0vrD1TQQi3nWvQQdmXPvRo/PEpmQKVBTMTQt2UUlbgThV4HZhry7L2eY7k7YcjHDNF/ 7ZHy+18rZGL+gRmq6hwoJXHR3sw386MgWuG72xNBAANDBHGviEWE+1kWPyrQGfhXDfYl K9SX0kuqxsJ29KsH6aqi5YF8gTymJlYfh9GaIw+SaIFp5w0zPJkbfC2nzdxUnoSgE1Vr GacQ== X-Gm-Message-State: AOJu0YyrBnz/8EzyM+7AKDmsMZTU81wwF+rC172/77JdvaPDUr6/BElw ymybshxNOI5tYm3KZVM05taIdA7rwiZF3QXYdviPwuUEeYGZlrg72lVtgy01goS6B4qS2ID3RUh 8gFq4YlIDi68RPfYCGQk5Sjtyq2gz0A== X-Gm-Gg: ASbGncvb85jyVonUYYZPMx3jjZR4fnt3NknZ+oVnLm6S8UOpnWOoDxk/a5/nrXZUYZS Y0LpupLKzAtdu5EufLV+WNq5Kyusp+ssXo4JCqDRme3ughr9AyoVgh4uMgDQA5HaXf2mKHS3BCw PgFVEx8nUpFVZiqM42GAwyeuSpPAWlzRhANTmTgCaQcEV/9Q5PirYOLG6FGYde X-Google-Smtp-Source: AGHT+IG1whrlBpG53V0lfRxmus0LbYEYCmkJcifaFPYi5+gppD38o7XhqwmnRJ1BJKtGBUGjVIc247c6MdTJvtWAMdY= X-Received: by 2002:a05:690c:7345:b0:6fb:b1dd:9ffe with SMTP id 00721157ae682-6fda31b5250mr83853987b3.35.1741222516547; Wed, 05 Mar 2025 16:55:16 -0800 (PST) MIME-Version: 1.0 References: <225733.1741142220@sss.pgh.pa.us> In-Reply-To: <225733.1741142220@sss.pgh.pa.us> From: Igor Korot Date: Wed, 5 Mar 2025 18:55:05 -0600 X-Gm-Features: AQ5f1JrTLGyMZXuN2WqNDhbe-WWMUuk1XCnNfK20hCvva80puLB2pDReIF4WbG4 Message-ID: Subject: Re: Error on query execution To: Tom Lane Cc: "pgsql-generallists.postgresql.org" Content-Type: multipart/alternative; boundary="00000000000092e7a6062fa1f5b6" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000092e7a6062fa1f5b6 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Tom, On Tue, Mar 4, 2025, 8:37=E2=80=AFPM Tom Lane wrote: > Igor Korot writes: > > binaryIntVal =3D htonl( (uint32_t) type ); > > paramValues[0] =3D (char *) &binaryIntVal; > > paramLengths[0] =3D sizeof( binaryIntVal ); > > paramFormats[0] =3D 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 =3D PQexecParams( m_db, "SELECT * FROM abcatfmt WHERE abf_type = =3D > > $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 > --00000000000092e7a6062fa1f5b6 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Tom,

On Tue, Mar 4, 2025, 8:37=E2= =80=AFPM Tom Lane <tgl@sss.pgh.pa.u= s> wrote:
Igor Korot <iko= rot01@gmail.com> writes:
>=C2=A0 =C2=A0 =C2=A0binaryIntVal =3D htonl( (uint32_t) type );
>=C2=A0 =C2=A0 =C2=A0paramValues[0] =3D (char *) &binaryIntVal;
>=C2=A0 =C2=A0 =C2=A0paramLengths[0] =3D sizeof( binaryIntVal );
>=C2=A0 =C2=A0 =C2=A0paramFormats[0] =3D 1;

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

I thought= only binary or text is allowed as parameters.

<= /div>
Guess I was wrong...

Thank you.


>=C2=A0 =C2=A0 =C2=A0res =3D PQexecParams( m_db, "SELECT * FROM abc= atfmt WHERE abf_type =3D
> $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.=C2=A0 Passing data in binary is not= at all
forgiving about getting the data type right.

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 regards, tom lane
--00000000000092e7a6062fa1f5b6--