-
Notifications
You must be signed in to change notification settings - Fork 129
Don't crash when query doesn't contain FROM #757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/pgduckdb_hooks.cpp
Outdated
@@ -185,7 +185,7 @@ IsAllowedStatement(Query *query, bool throw_error) { | |||
} | |||
|
|||
/* We don't support modifying statements on Postgres tables yet */ | |||
if (query->commandType != CMD_SELECT) { | |||
if (ContainsFromClause(query) && query->commandType != CMD_SELECT) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems a a weird place to add this check. It seem to have anything to do with checking whether the postgres table is a modifying statement or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, though the line below uses list_nth_node
with query->rtable
which could be NULL
without this check, thus failing the Assert(list != NIL)
in list_nth_cell
Do you prefer to just explicitly check for query->rtable != NIL
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though re-reading now with fresh eyes it was indeed pretty weird. Reworked here: 2ed8ee4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, checking for rtable == NULL instead of using ContainsFromClause
would be be a bit clearer too imo. Because rtable
only corresponds to FROM for SELECT queries, and in this block we're explicitely not talking about SELECT queries due to the != CMD_SELECT
check.
e.g. INSERT INTO abc VALUES (1)
will have abc
in the rtable.
Fixes #748