Disallow DuckDB execution inside functions #764
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
pg_duckdb changes result types of queries at the planning stage. This is needed for pg_duckdb to function correctly. However, Postgres code is sometimes not written with this in mind. One such case is sql functions, as reported in #749. There it causes a crash, because Postgres expects a different type to be returned by the function than what is actually returned.
As far as I can tell there is no easy way of fixing this, apart from changing Postgres to learn how to deal with this. I'll open issue/patch to Postgres for this at some point in the near future.
For now, we simply start disallowing all DuckDB execution inside functions. That is quite a shame because using DuckDB execution in functions works fine in many other cases. Sadly, I cannot think of a way to only disallow the crashing cases. Since a very important part of pg_duckdb 1.0 is stability, it seems better to err on the side of caution and disable this feature for now and stabilize it in a future release.
Fixes #749