[MDEV-14820] System versioning is applied incorrectly to CTEs Created: 2017-12-30 Updated: 2018-05-29 Resolved: 2018-05-12 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Versioned Tables |
| Affects Version/s: | 10.3 |
| Fix Version/s: | 10.3.7 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Sergei Golubchik | Assignee: | Sergei Golubchik |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
FOR SYSTEM_TIME AS OF is (and must be) pushed down to individual tables. Prepare the test case:
1. It cannot work with recursive CTE, when it's used many times in a top level select with different system_time values, like in
This cannot work at all, because we cannot push two different WHERE clauses down into the same SELECT_LEX. Condition pushdown generally doesn't work for recursive CTEs 2. It can work for non-recursive CTE, because generally condition pushdown works for non-recursive CTEs — they're cloned as many times as they're used. But it doesn't:
As you can see, @ts_1 condition was only attached to the first instance of emp, not to both. 3. Similarly it can work with recursive CTE that is only used once in the top level select, but it doesn't:
The condition is not attached to emp at all, but only to the top level select. |
| Comments |
| Comment by Aleksey Midenkov [ 2018-03-14 ] | ||||||||||||||||
|
For Case 1 the query is prohibited when any of multiple CTE instances have SYSTEM_TIME clause:
even if SYSTEM_TIME is the same in all instances or absent in some instances:
| ||||||||||||||||
| Comment by Igor Babaev [ 2018-04-24 ] | ||||||||||||||||
|
Ok to push |