Error with extended query protocol
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.
Basically all clients use the extended query protocol. So we should definitely fix this.
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.
@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);