public inbox for [email protected]  
help / color / mirror / Atom feed
From: Laurenz Albe <[email protected]>
To: Igor Korot <[email protected]>
To: pgsql-generallists.postgresql.org <[email protected]>
Subject: Re: PQexecPrepared() question
Date: Sat, 20 Dec 2025 07:24:47 +0100
Message-ID: <[email protected]> (raw)
In-Reply-To: <CA+FnnTyYBNwbzFs5GqO+SMg3g60jPTsnmFwTV=_s_YboGo-68A@mail.gmail.com>
References: <CA+FnnTygjVvSmzTHnvteuL4KEC=0P_+mF8Kn84JtNGZWUGxpUA@mail.gmail.com>
	<[email protected]>
	<CA+FnnTxO6kam9=mRonvsnUA1OxJxdDdQsj+ubdgFNNb9b3WMPQ@mail.gmail.com>
	<[email protected]>
	<CA+FnnTzE34VJWR7xkymaKEwXiiQ8j3o03m0+qcQsRr2JkRQLwQ@mail.gmail.com>
	<[email protected]>
	<CA+FnnTz5tcJEL12ir1nxe9q75rxaAdfBtcFUNiD4R5gW_JR23A@mail.gmail.com>
	<CA+FnnTyYBNwbzFs5GqO+SMg3g60jPTsnmFwTV=_s_YboGo-68A@mail.gmail.com>

On Fri, 2025-12-19 at 20:10 -0800, Igor Korot wrote:
> > > > What is “clientencoding 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.

> But then I don’t 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.

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

Yours,
Laurenz Albe






view thread (19+ 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: PQexecPrepared() question
  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