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 1vXC5a-003POS-2y for pgsql-general@arkaria.postgresql.org; Sun, 21 Dec 2025 05:34:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vXC4Z-00B8Kg-1k for pgsql-general@arkaria.postgresql.org; Sun, 21 Dec 2025 05:33:40 +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 1vXC4Z-00B8KX-0W for pgsql-general@lists.postgresql.org; Sun, 21 Dec 2025 05:33:39 +0000 Received: from mail-yw1-x1129.google.com ([2607:f8b0:4864:20::1129]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vXC4Y-001leQ-0N for pgsql-general@lists.postgresql.org; Sun, 21 Dec 2025 05:33:38 +0000 Received: by mail-yw1-x1129.google.com with SMTP id 00721157ae682-78fc0f33998so11793437b3.0 for ; Sat, 20 Dec 2025 21:33:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766295216; x=1766900016; darn=lists.postgresql.org; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=zV3YQdA7a/S2HCjwUssQezlu0PQdD2iBZTawFsuvHwE=; b=Y1MOS46VKrofBVnS9z4BGDZHpyEAu7RZJsCUtW8/Z8ZWHzd8xfdkvc1a8bIlXK9HsI DfE2zcSE+dC4a1LzAgw8Jby6FFv88OxuMvtQkDiZJZfnz0e3bVrWrcXmMiWA0RJG9YMR 60sq9Xm7NT+yEifCra/1kCHoh+h4pDSnH60lKXRYMlOIZyrOZfZv7dJ/yU6qWtTlyUvn 5djFIai+wwpNQTxsMzEhINt4auLMe87xmMS/5MWqoSAj97ParQetsB0hAIcUjdt1KMkg bJal+x7/TVpICC4gCO5zdkWbdHTwg00itBMAK4rHyzX4wtEnuW3kBQH69GtR7JgoAev8 5Wzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766295216; x=1766900016; h=content-transfer-encoding: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=zV3YQdA7a/S2HCjwUssQezlu0PQdD2iBZTawFsuvHwE=; b=GNG7ZWs6iGNUhnhIIat9eYwwrWYL+guHgm6joY0qLdMCTqOvKP5zgNSTTcqOzR0Faz wt9/6o20PCytls7oMmuNjYKmlo3iF60NmWlh5rSSZ3ehN+d/47K0s4q1vi6wPFcmhIj4 AHYFxXr/GsPvJSMFcNrXSZgJHM9JzCdFdYZCHg5urN87H9WO3BYKDXKxQ+ZYEMKIDSmx FvANR6FRiGz4LLJvJfz/MPUis0gtXchZ9A8u2d9a4u+Xu0Pj6e/JS1/PReLsP22dlQPQ kL9IoBmA9OtlUiavHCFfz+DFC8P55J9Z3i20hrFUnslmUq+nIVxSNFRmdWL3KRENmZio t4kA== X-Forwarded-Encrypted: i=1; AJvYcCWTAUER/xqClgPs5/JEvVq+KMqK350kuawMbSARKan1ALsmxdANsdWWXJigOdalrDvX9g5Z1HiK9ykRt4xZ@lists.postgresql.org X-Gm-Message-State: AOJu0YyGTYarQtnv8hdKMyDusi8BH4rcGkjYP7i4eBopEj1r0NsZJCaO MP8UCK9zwa1mEeg7Fk04J2OXI+K7uDG1dCdK2Yjfcc+wBKhu63Ie+J1UZzn146K2vg/jVeFC59v I4evzWnHiDCP3DcOnf8fCBcjLSrXPrLg= X-Gm-Gg: AY/fxX7jkUw/hXL6mE08VYs3CLcLl2TQRoKpksIRNAePPnSsiiSLj/6yUra8XeVG4qf KoE+XOgczMyWV4xE7UmcMNvP39t2ksPl+mBP4ZykiI4nH44wah88pRteKnxloksGpFRejrMT5If uwqqpzi1yDYYvl49XU9bn+1pIropcTYSyvUMKvn0Hf4fBiQ0ZJMCmSr3ZBvG06SAknJoeoPZKru sNlu+n1xn34giMQh/JmU/bXTPg5gAA8rfLlVAfNP7UnMTzM8wv7Sq+bsw9STl947pNclOFP7cYA TzLdRBGGKVatjvpd1P8d6Fn/4TQ= X-Google-Smtp-Source: AGHT+IFtHPCJorIG5j1mTjLvJiUYr6duDTajvnYL3/kWoIh7t5ZqWnG55OiEOFeah/gLwjtgDNozi379nsBj4l3xAm0= X-Received: by 2002:a05:690c:e3ee:b0:78f:c98e:1a42 with SMTP id 00721157ae682-78fc98e1c6emr43645267b3.69.1766295216463; Sat, 20 Dec 2025 21:33:36 -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: Sat, 20 Dec 2025 21:33:23 -0800 X-Gm-Features: AQt7F2ps2BwnhAZdfQIR7b5HOrybJ-7vquL-DM6OKazMWubtX0obGbE2pJ1FtPk Message-ID: Subject: Re: PQexecPrepared() question To: Laurenz Albe , "pgsql-generallists.postgresql.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, Laurenz, 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 execu= table, 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. I added the following code in my app: res =3D PQexec( m_db, "SHOW client_encoding" ); auto value =3D PQgetvalue( res, 0, 0 ); PQclear( res ); and the value of the "value" variable is "UTF8". > > > 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 b= oth 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 sto= red > 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. The exact error message is: ERROR: invalid byte sequence for encoding UTF8: 0xdf CONTEXT: unnamed portal parameter $1 on the INSERT. Thank you. > > Yours, > Laurenz Albe