public inbox for [email protected]  
help / color / mirror / Atom feed
From: Igor Korot <[email protected]>
To: pgsql-generallists.postgresql.org <[email protected]>
Subject: Why that query fails?
Date: Sun, 26 Apr 2026 15:15:26 -0500
Message-ID: <CA+FnnTy3D3Zo0XxNe37w5FnmGftvv_jWuLVMdS0Y3qPanx2seA@mail.gmail.com> (raw)

Hi, ALL,
[quote]
Thread 1 "dbhandler" hit Breakpoint 1,
PostgresDatabase::CreateDatabase (this=0x616000180c80,
    name=L"test", opts=std::shared_ptr<CreateDBOptions> (use count 1,
weak count 0) = {...},
    errorMsg=std::vector of length 0, capacity 0) at
../../libpostgres/database_postgres.cpp:46
46        int result = 0;
(gdb) n
47        auto exists = false;
(gdb)
48        std::vector<std::wstring> dbList;
(gdb)
49        std::wstring qry0, qry1, qry2;
(gdb)
50        qry0 = L"SELECT 1 FROM pg_database WHERE datname = $1";
(gdb)
51        if( opts->m_exist )
(gdb)
54            values[0] = NULL;
(gdb)
55            values[0] = new char[name.length() * sizeof( wchar_t ) + 1];
(gdb)
56            memset( values[0], '\0', name.length() * sizeof( wchar_t ) + 1 );
(gdb)
57            strcpy( values[0], m_pimpl->m_myconv.to_bytes(
name.c_str() ).c_str() );
(gdb)
58            int len1 = (int) name.length() * sizeof( wchar_t );
(gdb)
59            int length[1] = { len1 };
(gdb)
60            int formats[1] = { 1 };
(gdb)
61            auto res = PQexecParams( m_db,
m_pimpl->m_myconv.to_bytes( qry0.c_str() ).c_str(), 1, NULL, values,
length, formats, 0 );
(gdb)
62            auto status = PQresultStatus( res );
(gdb)
63            if( status != PGRES_TUPLES_OK )
(gdb) p status
$1 = PGRES_FATAL_ERROR
(gdb) n
65                std::wstring err = m_pimpl->m_myconv.from_bytes(
PQerrorMessage( m_db ) );
(gdb)
66                errorMsg.push_back( L"Error executing query: " + err );
(gdb) p err
$2 = L"ERROR:  invalid byte sequence for encoding \"UTF8\":
0x00\nCONTEXT:  unnamed portal parameter $1\n"
(gdb)
[/quote]

What am I doing wrong?

Thank you.






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]
  Subject: Re: Why that query fails?
  In-Reply-To: <CA+FnnTy3D3Zo0XxNe37w5FnmGftvv_jWuLVMdS0Y3qPanx2seA@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