You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Select with tx.query works fine.
With tx.stream code compiles but I get this exception:
ERROR: bind message supplies 1 parameters, but prepared statement "" requires 0
I took a peek at your source code and both methods internally calls exec(sql,params) with one difference: stream wraps sql query in copy to stdout.
So I tried tx.query("copy (select ... =$1) to stdout", params{key) and this time I got the same exception as with tx.stream.
I quess prepared statements with "copy" are not supported either in libpq or the server.
The text was updated successfully, but these errors were encountered:
The error message suggests to me that the implementation of parameterised statements in libpq uses a prepared statement. (The empty name has a special meaning — basically that's the single-use prepared statement.)
Streaming a parameterised statement ought to work, from libpqxx's perspective. But apparently the frontend/backend protocol prevents it! I guess I never thought to write a test for this because it's so simple and regular, API-wise, that I didn't think of it as a separate test case.
It's a bit painful — you'll have to insert the parameters into the query string yourself. Just always remember to quote and escape any string values using the connection's quote() function.
Hello,
Is it possible to simply replace "query" with "stream" in this construct ?
for (auto[...] : tx.query<...>("select ... =$1", params{key}) { ... }
=> for (auto[...] : tx.stream<...>("select ... =$1", params{key}) { ... }
Select with tx.query works fine.
With tx.stream code compiles but I get this exception:
ERROR: bind message supplies 1 parameters, but prepared statement "" requires 0
I took a peek at your source code and both methods internally calls exec(sql,params) with one difference: stream wraps sql query in copy to stdout.
So I tried tx.query("copy (select ... =$1) to stdout", params{key) and this time I got the same exception as with tx.stream.
I quess prepared statements with "copy" are not supported either in libpq or the server.
The text was updated successfully, but these errors were encountered: