pg_duckdb icon indicating copy to clipboard operation
pg_duckdb copied to clipboard

Error with extended query protocol

Open hlinnaka opened this issue 1 year ago • 2 comments

postgres=# create table tbl(i int4);
CREATE TABLE
postgres=# select * from tbl  \bind \g
ERROR:  unrecognized node type: 1189775888

See https://github.com/duckdb/pg_duckdb/blob/177b12b7a39fc14e9c0ffb136c8c9c957dc3f2d7/src/pgduckdb_planner.cpp#L91

The problem is that the type stored in custom_private is supposed to be a copyable Node type, which the duckdb connection and prepared query types are not.

hlinnaka avatar Aug 14 '24 08:08 hlinnaka

Basically all clients use the extended query protocol. So we should definitely fix this.

JelteF avatar Aug 19 '24 09:08 JelteF

Agree with @JelteF this should be fixed asap. Simplest, most straight forward solution would be to fix this once we would have one duckdb singleton wrapper object per process - than we would not need to pass this objects around for each query.

mkaruza avatar Aug 19 '24 10:08 mkaruza

@JelteF

		// FIXME: TextDatumGetCstring allocates so it needs a
		// guard, but it's a macro not a function, so our current gaurd
		// template does not handle it.

That is possible, it's just a bit uglier:

return duckdb::Value(PostgresFunctionGuard<char*>([](Datum val) { return TextDatumGetCString(val); }, value);

Tishj avatar Sep 23 '24 13:09 Tishj