Repository navigation
Conversation
…conjunctions ConjunctionSimplificationRule replaced `expr AND false` and `expr OR true` with the first child of the conjunction instead of the constant, so it was only correct when the constant happened to be the first child. For example, `select * from t where 1 = 2 and id = 1` returned the row with id = 1. - replace the conjunction with the boolean constant it short-circuits to - replace a conjunction whose children were all removed with `true` (AND) or `false` (OR); an empty conjunction always evaluated to true - set change_made whenever the expression is modified - continue from the iterator returned by vector::erase Fixes oceanbase#637
Author
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What problem were solved in this pull request?
Issue Number: close #637
Problem:
ConjunctionSimplificationRulefolds a conjunction that contains a boolean constant:x AND falseis alwaysfalseandx OR trueis alwaystrue. But instead of replacing the conjunction with that constant, it replaced it with the first child (child_exprs.front()), which is only correct when the constant happens to be the first child.This is reachable from plain SQL.
ComparisonSimplificationRulefolds1 = 2intofalse, and because the grammar rulecondition AND condition_listappends the first condition last, the constant ends up afterid = 1:Before (returns a row, and the scan is kept):
After (empty, and the predicate subtree is pruned):
where id = 1 and 1 = 2was already correct before this change, because there the constant happens to be the first child.What is changed and how it works?
In
ConjunctionSimplificationRule::rewrite:x AND false/x OR true: replace the conjunction withfalse/trueinstead of its first child.true AND true,false OR false), replace the conjunction withtrue(AND) orfalse(OR). Before, an empty conjunction was left behind, andConjunctionExpr::get_valuereturnstruefor an empty conjunction, sofalse OR falseevaluated totrue.change_madewhenever the expression is modified (also pointed out in the issue).vector::eraseinstead of reusing the invalidated one.New unit test
unittest/observer/conjunction_simplification_rule_test.cppcovers both short-circuit cases, the all-removed case, removingtruefrom AND /falsefrom OR, a single remaining child, and the no-op case. The first four tests fail onmain.Other information
change_madeand the iterator. The test from the issue description passes with this change.false/truewhen one of the children's expressions returnsfalse/trueinAND/ORdirectly in with the conjunction simplification rule #440 asks about the same code.python3 test/case/miniob_test.py --test-cases=basic.BplusTreeLog.concurrencyinbplus_tree_log_testaborts on my machine, but it aborts the same way on unmodifiedmain(looks like [BUG] bplus_tree_log_test failed occasionally. #520), so it is unrelated to this change.