Re: PQexecPrepared() question

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Igor Korot <ikorot01@gmail.com>
Cc: Laurenz Albe <laurenz.albe@cybertec.at>, "pgsql-generallists.postgresql.org" <pgsql-general@lists.postgresql.org>
Date: 2025-12-21T05:39:23Z
Lists: pgsql-general
Igor Korot <ikorot01@gmail.com> writes:
> I added the following code in my app:
>     res = PQexec( m_db, "SHOW client_encoding" );
>     auto value = PQgetvalue( res, 0, 0 );
>     PQclear( res );
> and the value of the "value" variable is "UTF8".

Okay ...

> The exact error message is:
> ERROR: invalid byte sequence for encoding UTF8: 0xdf
> CONTEXT: unnamed portal parameter $1
> on the INSERT.

client_encoding governs both the encoding that the server will
send, and the encoding that it expects to receive.  You are
sending a parameter string that is not valid UTF8.

			regards, tom lane