pgsql-general
❮
POprepare fails
- Jump to comment-1Igor Korot<ikorot01@gmail.com>Mar 12, 2026, 7:53 PM UTCHi, ALL,
646 if( !result )
(gdb)
648 res1 = PQprepare( mdb, "getpk_prop",
mpimpl->mmyconv.tobytes( query8 ).cstr(), 3, nullptr );
(gdb)
649 auto status = PQresultStatus( res1 );
(gdb)
650 if( status != PGRESCOMMANDOK && status != PGRESTUPLESOK )
(gdb)
652 std::wstring err = mpimpl->mmyconv.from_bytes(
PQerrorMessage( m_db ) );
(gdb) p query8
$1 = L"SELECT c.relname AS name, ixs.tablespace AS tbspace, am.amname
draft=# SELECT c.relname AS name, ixs.tablespace AS tbspace, am.amnameAS type, ARRAY(SELECT a.attname FROM pg_attribute a WHERE a.attrelid = idx.indrelid AND a.attnum = ANY(idx.indkey) AND a.attnum > 0 ORDER"... (gdb) n 653 errorMsg.push_back( err ); (gdb) p err $2 = L"ERROR: syntax error at or near \"AND\"\nLINE 1: ...lnamespace AND idx.indisprimary AND n.nspname = ? AND t.reln...\n", ' ' <repeats 61 times>, "^\n"
draft=#AS type, ARRAY(SELECT a.attname FROM pg_attribute a WHERE a.attrelid = idx.indrelid AND a.attnum = ANY(idx.indkey) AND a.attnum > 0 ORDER BY array_position(idx.indkey, a.attnum) OFFSET idx.indnkeyatts) AS included, c.reloptions AS storage FROM pg_am am, pg_index idx, pg_class c, pg_namespace n, pg_class t, pg_indexes ixs WHERE am.oid = c.relam AND ixs.indexname = c.relname AND c.oid = idx.indexrelid AND t.oid = idx.indrelid AN D n.oid = c.relnamespace AND idx.indisprimary AND n.nspname = 'public' AND t.relname = 'leagues_new'; name | tbspace | type | included | storage ------------------+---------+-------+-------------------------+--------------------------------------- leagues_new_pkey | | btree | {drafttype,scoringtype} | {fillfactor=50,deduplicate_items=off} (1 row)
What is going on?
Thank you.- Jump to comment-1Laurenz Albe<laurenz.albe@cybertec.at>Mar 12, 2026, 8:04 PM UTCOn Thu, 2026-03-12 at 20:16 -0500, Igor Korot wrote:
ERROR: syntax error at or near \"AND\"\n
You used the question mark as a parameter placeholder, but you are using
LINE 1: ...lnamespace AND idx.indisprimary AND n.nspname = ? AND t.reln...
What is going on?
the C API, not JDBC. The placeholders are $1, $2 and so on.
Yours,
Laurenz Albe- Jump to comment-1Igor Korot<ikorot01@gmail.com>Mar 12, 2026, 8:16 PM UTCThx, Lauren’s.
On Thu, Mar 12, 2026 at 1:04 PM Laurenz Albe <laurenz.albe@cybertec.at>
wrote:On Thu, 2026-03-12 at 20:16 -0500, Igor Korot wrote:
ERROR: syntax error at or near \"AND\"\n
LINE 1: ...lnamespace AND idx.indisprimary AND n.nspname = ? ANDt.reln...
What is going on?
You used the question mark as a parameter placeholder, but you are using
the C API, not JDBC. The placeholders are $1, $2 and so on.
Yours,
Laurenz Albe