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.96) (envelope-from ) id 1vWr0k-00AthT-0W for pgsql-general@arkaria.postgresql.org; Sat, 20 Dec 2025 07:04:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vWr0i-009rtf-2o for pgsql-general@arkaria.postgresql.org; Sat, 20 Dec 2025 07:04:17 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vWr0i-009rtX-1K for pgsql-general@lists.postgresql.org; Sat, 20 Dec 2025 07:04:17 +0000 Received: from mail-yx1-xb134.google.com ([2607:f8b0:4864:20::b134]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vWr0h-001cyc-0y for pgsql-general@lists.postgresql.org; Sat, 20 Dec 2025 07:04:15 +0000 Received: by mail-yx1-xb134.google.com with SMTP id 956f58d0204a3-6446c1a7a1cso2125094d50.3 for ; Fri, 19 Dec 2025 23:04:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766214254; x=1766819054; 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=aoWgVZ5k8LRzG6QBoNFezbsNQGQdv6OE2a1rS+gROxk=; b=bSf7oJRf9JiUtSyTpb7hybRtPP3UreCWCMkBT0RHhFJICl4d04G9OFEZ1YMxLMdI74 sVf0S7a5kBZ5gVZyD/fjd/VxS1fpSAxpw+MKB0uIzOCqdFFWVtsURDWhlEMRbmtRdM7s fi41XsXPimP0ATnuu7o/hbMIFMZNYbA/+KMcBNOfmPH7dzu9wpB3l7h0+7XflaG1XwGu bo5T5SQzIzfAdE3x5FijlPhOOBgWAjxcpSzY/e4WMpe2iUtBQ6ZMcPMCZXzQ4tzRh3xl JqlwBZis+OWfGF79nkeHggM7sSnKknC/F7bs2aGZIh1ErHqbqQfSPrRMe/LRXBRiKX4y rGPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766214254; x=1766819054; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=aoWgVZ5k8LRzG6QBoNFezbsNQGQdv6OE2a1rS+gROxk=; b=Fq4QUhDta0ilc8dHRtqcUjctRgtcZi/p0bDNevJRKArvzDwoxFyW3aU+Xse0qeDMtl rZQJe6V99SuyQJdz3z1Phvozv0Mu1NGmpmvui0kEyz2R7XKopOsWqX5cel/ftXGidNmA 9rS9GH6ndG8XUag7osGl94HfAyW3U02wO0g9/bAyl47k9Hr7uQAnb7pe2f93/2ilCMVE yJPiBtm7xVLSAqiw75Cs2btL/Uu7qDtTuQuw1lh89qExnGd2sLwZQmcp/jNBABK2iXGR zPRZnlmKYMd/Ny63ni/FDvlhyNzVuqewAlLJSAo27rWwgq6e/0P5qunjYenAi6BvV0RZ vfgQ== X-Gm-Message-State: AOJu0Yz7/O2+3ev6OtznTMfoAxn8bCITvZYpZpj70OzeInVPiiqXLTwd TJCrWn0SWm1TOXHnBD2HQbM68yJvzdstGEuOk4dEUUxYC6bBxuEM5GG5uD1l2GP9boxwvh/cKsN 5a3jiofaa3uOIi54aiEyHnjRRvXX6v7Va06du X-Gm-Gg: AY/fxX4aH5iQTJ4eeODV6Lp4MwLjTJnnuk0kx5ADRe9LtCWEImnJcaRb1EgsafqTlEq YWNr0934KpwHHKPWY49KXkZQZlI+xijw+aUARq+8FxzqDoABqIaZu6BiJqmqkPH9WdcTt3AcCA6 ZsWBSpKLn8re2b/wiwCNxfXHlAFSAZRJzm7WneLho+NeA01JU2dczsDl4kuAD06sPt/S5N14g5N bUuT039I9ywIp2BC/3xHgo/TcgsaD2umz1BA0jesjXVHoKIg+DovNnGFVdFKGwUsnmUfcmiG4dd NYcSM6r994zrXEtwyZAwbIXVDVu+ X-Google-Smtp-Source: AGHT+IFdvNcgT9BIg38IiBORaVxELaT5c/Yat/7VZ3b2HX61dFDHVX69kZlLPaiCpW/AYkZZmmfwk01yxV+8vI/k6OY= X-Received: by 2002:a53:b082:0:b0:645:5a2f:7d1c with SMTP id 956f58d0204a3-6466a8dd4b4mr3567609d50.74.1766214254066; Fri, 19 Dec 2025 23:04:14 -0800 (PST) MIME-Version: 1.0 References: <2547700.1765940917@sss.pgh.pa.us> <9a0ce31a49f149d8d982d2b359095560655f781e.camel@cybertec.at> <852dee881b6cc82b9d4b51d69d48c415e2a87b4d.camel@cybertec.at> In-Reply-To: <852dee881b6cc82b9d4b51d69d48c415e2a87b4d.camel@cybertec.at> From: Igor Korot Date: Fri, 19 Dec 2025 23:04:03 -0800 X-Gm-Features: AQt7F2ryZLtbwYgLvTmIqMg5iWM6nxs4-qfNNxu9H9TeWd9TiekHQDXhSzpmOOE Message-ID: Subject: Re: PQexecPrepared() question To: Laurenz Albe Cc: "pgsql-generallists.postgresql.org" Content-Type: multipart/alternative; boundary="00000000000035fe5606465ccdf3" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000035fe5606465ccdf3 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, Lauren=E2=80=99z, On Fri, Dec 19, 2025 at 10:24=E2=80=AFPM Laurenz Albe wrote: > On Fri, 2025-12-19 at 20:10 -0800, Igor Korot wrote: > > > > > What is =E2=80=9Cclientencoding in this case? > > > > > > > > - if PGCLIENTENCODING is set in the environment of the client > executable, that > > > > > > No it is not. > > > > > > > - otherwise, if "client_encoding" is set on the server, that > > > > I just checked the postgres.conf. > > > > This file does not have any client_encoding. > > > > > > - otherwise, SQL_ASCII > > > > Which means that this is an encoding that will be used. > > You can verify that with the SQL statement "SHOW client_encoding" > in your sample program. Thx, will check. > > > But then I don=E2=80=99t understand anything. > > > > The code I posted above worked fine on SELECT, but INSERT failed. > > > > If the SQL_ASCII is the encoding used both operations should fail. Or > both succeeds. > > > > Could someone explain what happened? > > SQL_ASCII as client encoding means that no conversion will take place. > > Still, the database encoding (I suspect UTF8) will govern what can be > stored > in the database. Anything that is not valid UTF-8 will be rejected. Rejected how? > > A SELECT will never cause an error - the client will just receive data > in UTF-8. And then what? I=E2=80=99ll check the encoding and report back.. Thank you. > > Yours, > Laurenz Albe > --00000000000035fe5606465ccdf3 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi, Lauren=E2=80=99z,


On Fri, Dec 19, 2025 at 10:24=E2=80=AFPM Laurenz Albe &l= t;laurenz.albe@cybertec.at&= gt; wrote:
On Fri, 2025-12-19 at 20= :10 -0800, Igor Korot wrote:
> > > > What is =E2=80=9Cclientencoding in this case?
> > >
> > > - if PGCLIENTENCODING is set in the environment of the clien= t executable, that
> >
> > No it is not.
> >
> > > - otherwise, if "client_encoding" is set on the se= rver, that
>
> I just checked the postgres.conf.
>
> This file does not have any client_encoding.
>
> > > - otherwise, SQL_ASCII
>
> Which means that this is an encoding that will be used.

You can verify that with the SQL statement "SHOW client_encoding"=
in your sample program.


Thx, will check.
=


> But then I don=E2=80=99t understand anything.
>
> The code I posted above worked fine on SELECT, but INSERT failed.
>
> If the SQL_ASCII is the encoding used both operations should fail. Or = both succeeds.
>
> Could someone explain what happened?

SQL_ASCII as client encoding means that no conversion will take place.

Still, the database encoding (I suspect UTF8) will govern what can be store= d
in the database.=C2=A0 Anything that is not valid UTF-8 will be rejected.

Rejected how?


A SELECT will never cause an error - the client will just receive data
in UTF-8.

And the= n what?

I=E2=80=99ll che= ck the encoding and report back..

Thank you.



Yours,
Laurenz Albe
--00000000000035fe5606465ccdf3--