Closed onderkalaci closed 9 years ago
@jasonmp85 I think we can do a similar change for this line. In other words, instead of checking
!IsA(targetEntry->expr, Const)
We can do something like:
contain_mutable_functions((targetEntry->exp) ||
contain_volatile_functions((targetEntry->exp))
But, since the issue only considers QUALs, I didn't want to do that here.
@onderkalaci this looks good and after the small style changes (and removing the redundant call), it's a :shipit:.
Accidentally closed, sorry!
@onderkalaci on the topic of !IsA(targetEntry->expr, Const)
, we already know any function calls we see in the target list must be mutable. This is because we have already called the standard_planner
on the query. That in turn calls eval_const_expressions
, which eagerly replaces any immutable functions with their output (this also applies to the quals; for instance, doing an UPDATE … WHERE foo = (1 + 1)
becomes UPDATE … WHERE foo = 2
).
So for target lists, we only accept constants, but for quals, there might be a column reference (LHS), operator, and value (RHS). In that case, the standard planner may have collapsed the RHS to a constant (if, as above it's something like 1+1
), but the operator call is still there. But e.g. =
is IMMUTABLE
so it needs to make it through.
So I guess I'm saying the walker is overkill for the target list but is needed for the quals, so what we have here is now complete.
Added checklist up to. Fix and submit the changes and I'll merge tomorrow if all looks good.
@jasonmp85 all your comments make sense and I applied the changes.
Looks good. Merging.
This pull request prevents WHERE clause statements to have VOLATILE or MUTABLE functions.
Fixes #47
Review tasks
contain_volatile_functions
current_timestamp