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 1vWJ1a-00Gnv8-2H for pgsql-general@arkaria.postgresql.org; Thu, 18 Dec 2025 18:46:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vWJ1Z-003aM2-2H for pgsql-general@arkaria.postgresql.org; Thu, 18 Dec 2025 18:46:54 +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.96) (envelope-from ) id 1vWJ1Z-003aLu-1F for pgsql-general@lists.postgresql.org; Thu, 18 Dec 2025 18:46:54 +0000 Received: from mail-yx1-xb12a.google.com ([2607:f8b0:4864:20::b12a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vWJ1X-001Sk4-2t for pgsql-general@lists.postgresql.org; Thu, 18 Dec 2025 18:46:53 +0000 Received: by mail-yx1-xb12a.google.com with SMTP id 956f58d0204a3-64472ea7d18so766896d50.2 for ; Thu, 18 Dec 2025 10:46:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766083609; x=1766688409; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=UhbjmzdU33/2pBp0gn+ov9wz0Teo1IaxtQQrXSndgls=; b=Qm+Xbaa9/UeEpxjpRuI5KPDWQFQ5nm3gVSH81Os5KyqvgoJHFvSbcr620gpqRY01W4 trPdPdNyBuvCndfD70+6fRoC1xjzm5ES60CL6a/Unc4kcoRgJnPKyCB50RxnXqoBAfgy t6Ys51hXLstUJRcIna+tzQr7iTpRZQvxZqgKJDSYqXN3TUSmc+i+qULh+pqrg1jpUFlR LcRhZw8tEBjOAdwmX6ij2z/G9XdTCHTOR4Hx9N400sCAwbDjy6dtWNpJiNHjfGxS0tsq JOdcFB4bdtMJcX53igHOLg8Bfgo1NRFhpyuhRGdbiF+nQPdeukVlODPhqgrQxTO5T+u2 0fBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766083609; x=1766688409; h=content-transfer-encoding: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=UhbjmzdU33/2pBp0gn+ov9wz0Teo1IaxtQQrXSndgls=; b=gOZQ4EqWh7M7q8SS7MKJf/M7jgexA6B2FE6YSFLQrmKRGSJbviHno8oq+cgPvIwggY CuQkiwKe1i6anYJnpFuKKthEW+g/CbFLMfkIiE5dek10qAb5YyWPgvIWPd4iRjCFTNcB 3TwTkAiaduPKsy2lRYXuaaE6OvjUyALRHNIW60RV61/yfkOfOLQDNJNwKtD7RkE3/SSx nQAtiqbzxQiJi2dDgc3S3Hl3r+wyuClm+rvnnRtipRynmPU+ZShOP5xRRn6+Yr0cxzYp 5oYYik0BYbeR7ROh91ag0reMRKl0MLBh1gfpo4/ynZjvuT673otQ3n1xKVph3dAhpNlL ez5g== X-Forwarded-Encrypted: i=1; AJvYcCWr8GK1wl+6wAJXUN6ls5X8FsAaD2o1hR0wzyvG9tE/CitmRvhb/FXLgbCSSUeTIe1Lu1fbBlh8inloNHuF@lists.postgresql.org X-Gm-Message-State: AOJu0YzW8gwXVM/7jwoNmM7vo62xIBYt9cr5oJI3IwohrERBeWnoBM3p 8Ut3v+cOLztPr7WcMBxYD8bWAx6cuCObQr2eI9jUkdT+NSraON/yQkivBziXHrMTBir2ICGpAPO 1wJhNckGNMdGhXUy/vifrKrw0b7yHQF8= X-Gm-Gg: AY/fxX5NcuD+Sc+m4FegCcUZBUj/V/Tj+qzEttjRMljF7DAroq8SDHtcrg+WSaqI9p0 eCvpNEPz5kavMfIFMJ3A5G1sVH2OKTn50zK8aLbdCS25ur0RpKvNhYf16emhc7oGspm6OW1bicJ HrMI+/GOOZjx/g4x3+nVQbDshlj8DVU6Zud/jl5Qb8Qg/ORlltdbj+8LSRFqDY5k+i3RSMy9Vvr mRTNI5jMhE24BelQPmc3A+5eSUm+RkBYxsZ7vJ37V30LU1oh0ScSBVEEl8qCjLjEnnw25s= X-Google-Smtp-Source: AGHT+IEmmnYxJXvfdFN0QohsC8g/HYH7V7Gsp5HeyWK7a+CcgvOJCV8qbzmZkpsFu25zJwtANHJy9U5XqzjndvYoz8o= X-Received: by 2002:a05:690e:2556:b0:644:53c0:299f with SMTP id 956f58d0204a3-6466a8bb4aemr209546d50.74.1766083609312; Thu, 18 Dec 2025 10:46:49 -0800 (PST) MIME-Version: 1.0 References: <2547700.1765940917@sss.pgh.pa.us> <9a0ce31a49f149d8d982d2b359095560655f781e.camel@cybertec.at> In-Reply-To: From: Igor Korot Date: Thu, 18 Dec 2025 18:10:45 -0600 X-Gm-Features: AQt7F2qHPDw6ZKXlgS9VK6q2j1GpJnGVsJHEeU5DCK1oULY-nUsybNS_sJlM4Ws Message-ID: Subject: Re: PQexecPrepared() question To: "David G. Johnston" Cc: 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, David, On Thu, Dec 18, 2025 at 7:41=E2=80=AFAM David G. Johnston wrote: > > On Thu, Dec 18, 2025 at 8:20=E2=80=AFAM Igor Korot w= rote: >> >> Imagine following scenario: >> >> I have 2 machines. One is running PG server on *nix. Second is my app on= Windows. >> >> An application starts for the first time. >> >> What is =E2=80=9Cclientencoding in this case? > > > This day in age, probably UTF-8; which is what most servers are initializ= ed using. If you aren't having issues with encoding I suggest you just tak= e for granted that the defaults work in 99% of the cases. If you are havin= g issues, share the details. My code: for( int i =3D 0; i < PQntuples( res ); i++ ) { std::wstring cat =3D m_pimpl->m_myconv.from_bytes( PQgetvalue( res, i, 0 ) ); std::wstring schema =3D m_pimpl->m_myconv.from_bytes( PQgetvalue( res, i, 1 ) ); std::wstring table =3D m_pimpl->m_myconv.from_bytes( PQgetvalue( res, i, 2 ) ); char *table_owner =3D PQgetvalue( res, i, 3 ); pimpl.m_tableDefinitions[cat].push_back( TableDefinition( cat, schema, table ) ); count++; paramValues =3D schema + L"." + table; params[0] =3D new char[paramValues.length() + 2]; memset( params[0], '\0', paramValues.length() + 2 ); std::wcstombs( params[0], paramValues.c_str(), paramValues.length() ); params[1] =3D new char[table.length() + 2]; memset( params[1], '\0', table.length() + 2 ); std::wcstombs( params[1], table.c_str(), table.length() ); params[2] =3D new char[schema.length() + 2]; memset( params[2], '\0', schema.length() + 2 ); std::wcstombs( params[2], schema.c_str(), schema.length() + 2 = ); paramFormat[0] =3D paramFormat[1] =3D paramFormat[2] =3D 0; paramLength[0] =3D paramValues.length(); paramLength[1] =3D table.length(); paramLength[2] =3D schema.length(); res8 =3D PQexecPrepared( m_db, "set_table_prop", 3, params, paramLength, paramFormat, 0 ); if( PQresultStatus( res8 ) !=3D PGRES_COMMAND_OK ) { std::wstring err =3D m_pimpl->m_myconv.from_bytes( PQerrorMessage( m_db ) ); errorMsg.push_back( L"Error executing query: " + err ); result =3D 1; } PQclear( res8 ); delete[] params[0]; params[0] =3D nullptr; delete[] params[1]; params[1] =3D nullptr; delete[] params[2]; params[2] =3D nullptr; } And ths s what I have n the DB: table_catalog | table_schema | table_name | table_type | self_referencing_column_name | reference_generation | user_defined_type_catalog | user_defined_type_schema | user_defined_type_name | is_insertable_into | is_typed | commit_action ---------------+--------------+------------+------------+------------------= ------------+----------------------+---------------------------+-----------= ---------------+- -----------------------+--------------------+----------+--------------- draft | public | abc=C3=9F | BASE TABLE | | | | | | YES | NO | Using my setup above and assumng my Win locale is en_US.UTF8 I can successfullly retreve that record but the insertion fails with Invalid byte sequence for parameter $1 in UTF8 Thank you. > > David J. >