public inbox for [email protected]
help / color / mirror / Atom feedFrom: Igor Korot <[email protected]>
To: David G. Johnston <[email protected]>
Cc: Laurenz Albe <[email protected]>
Cc: pgsql-generallists.postgresql.org <[email protected]>
Subject: Re: PQexecPrepared() question
Date: Thu, 18 Dec 2025 18:10:45 -0600
Message-ID: <CA+FnnTwZUo-ZRZ4if_ngXXkYgtOCsmMp1uFpsMFkG5AOmRxX4Q@mail.gmail.com> (raw)
In-Reply-To: <CAKFQuwZaf2quGaqsGAj4+rVVCebOwU3JjbMUJPxxj6NeF_O_gA@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>
<CAKFQuwZaf2quGaqsGAj4+rVVCebOwU3JjbMUJPxxj6NeF_O_gA@mail.gmail.com>
Hi, David,
On Thu, Dec 18, 2025 at 7:41 AM David G. Johnston
<[email protected]> wrote:
>
> On Thu, Dec 18, 2025 at 8:20 AM Igor Korot <[email protected]> wrote:
>>
>> 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 “clientencoding in this case?
>
>
> This day in age, probably UTF-8; which is what most servers are initialized using. If you aren't having issues with encoding I suggest you just take for granted that the defaults work in 99% of the cases. If you are having issues, share the details.
My code:
for( int i = 0; i < PQntuples( res ); i++ )
{
std::wstring cat = m_pimpl->m_myconv.from_bytes(
PQgetvalue( res, i, 0 ) );
std::wstring schema = m_pimpl->m_myconv.from_bytes(
PQgetvalue( res, i, 1 ) );
std::wstring table = m_pimpl->m_myconv.from_bytes(
PQgetvalue( res, i, 2 ) );
char *table_owner = PQgetvalue( res, i, 3 );
pimpl.m_tableDefinitions[cat].push_back( TableDefinition(
cat, schema, table ) );
count++;
paramValues = schema + L"." + table;
params[0] = new char[paramValues.length() + 2];
memset( params[0], '\0', paramValues.length() + 2 );
std::wcstombs( params[0], paramValues.c_str(),
paramValues.length() );
params[1] = new char[table.length() + 2];
memset( params[1], '\0', table.length() + 2 );
std::wcstombs( params[1], table.c_str(), table.length() );
params[2] = new char[schema.length() + 2];
memset( params[2], '\0', schema.length() + 2 );
std::wcstombs( params[2], schema.c_str(), schema.length() + 2 );
paramFormat[0] = paramFormat[1] = paramFormat[2] = 0;
paramLength[0] = paramValues.length();
paramLength[1] = table.length();
paramLength[2] = schema.length();
res8 = PQexecPrepared( m_db, "set_table_prop", 3, params,
paramLength, paramFormat, 0 );
if( PQresultStatus( res8 ) != PGRES_COMMAND_OK )
{
std::wstring err = m_pimpl->m_myconv.from_bytes(
PQerrorMessage( m_db ) );
errorMsg.push_back( L"Error executing query: " + err );
result = 1;
}
PQclear( res8 );
delete[] params[0];
params[0] = nullptr;
delete[] params[1];
params[1] = nullptr;
delete[] params[2];
params[2] = 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ß | 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.
>
view thread (10+ 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], [email protected]
Subject: Re: PQexecPrepared() question
In-Reply-To: <CA+FnnTwZUo-ZRZ4if_ngXXkYgtOCsmMp1uFpsMFkG5AOmRxX4Q@mail.gmail.com>
* 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