-
-
Notifications
You must be signed in to change notification settings - Fork 222
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
Do not consider non-deterministic expressions as invariants in pre-filters #7853
Conversation
src/jrd/SysFunction.cpp
Outdated
{ | ||
const MetaName funcName(name); | ||
|
||
return (funcName != "GEN_UUID" && |
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 think this should be defined in table at SysFunction::functions
.
Only 5.x is checked now. |
…lters (#7853) * Do not consider non-deterministic expressions as invariants in pre-filters * Follow Adriano's suggestion * Allow deterministic uncorrelated subqueries to be considered as invariants
Frontported to v6. |
QA note: removed upper bound for version after this feature was front-ported to 6.x. Checked on 6.0.0.532. |
Related to my prior commit for #1708. Even if the boolean does not access table fields it may still be non-deterministic, in this case it should not be treated as invariant and evaluated just once.
Example:
select count(*) from employee where rand() > 0.5
The condition is not correlated with any data but still produces a different result per every invocation. Prior to v5, it returned (approximately) half rows of the result set. In v5, it returns either zero rows or a half of them, depending on what was the result of
RAND()
during its first invocation.Tested with constant expressions,
RAND()
and SQL functions defined as deterministic and non-deterministic. This patch does not detect determinism too deeply (e.g. whether a field references stream from the current scope or the outer one), only to the level currently needed for the optimizer.