return syntax error when order by or limit before union in mysql mode

This commit is contained in:
obdev
2023-09-01 07:10:52 +00:00
committed by ob-robot
parent bf0272041a
commit 6d8fedae8b
11 changed files with 25 additions and 40 deletions

View File

@ -956,7 +956,7 @@ Outputs & filters:
access([t2.x], [t2.y], [t2.z]), partitions(p0)
is_index_back=false, is_global_index=false,
range_key([t2.x], [t2.y], [t2.z], [t2.pk2]), range(MIN,MIN,MIN,MIN ; MAX,MAX,MAX,MAX)always true
explain select a, b, c from t1 order by c, b, a union select x, y, z from t2;
explain (select a, b, c from t1 order by c, b, a )union select x, y, z from t2;
Query Plan
=============================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
@ -2707,7 +2707,7 @@ Outputs & filters:
is_index_back=false, is_global_index=false,
range_key([t6.b], [t6.a], [t6.c], [t6.pk]), range(1,2,MAX,MAX ; 1,MAX,MAX,MAX),
range_cond([t6.b = 1], [t6.a > 2])
explain select c from t6 where b = 1 limit 9 union select pk from tmp;
explain (select c from t6 where b = 1 limit 9) union select pk from tmp;
Query Plan
===========================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
@ -2728,7 +2728,7 @@ Outputs & filters:
access([tmp.pk]), partitions(p0)
is_index_back=false, is_global_index=false,
range_key([tmp.pk]), range(MIN ; MAX)always true
explain select /*+index(t6 idx_b_c)*/ c from t6 where b = 1 limit 9 union select pk from tmp;
explain (select /*+index(t6 idx_b_c)*/ c from t6 where b = 1 limit 9) union select pk from tmp;
Query Plan
===========================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
@ -2749,7 +2749,7 @@ Outputs & filters:
access([tmp.pk]), partitions(p0)
is_index_back=false, is_global_index=false,
range_key([tmp.pk]), range(MIN ; MAX)always true
explain select /*+index(t6 idx_b_a_c)*/ c from t6 where b = 1 limit 9 union select pk from tmp;
explain (select /*+index(t6 idx_b_a_c)*/ c from t6 where b = 1 limit 9) union select pk from tmp;
Query Plan
=============================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|

View File

@ -1467,7 +1467,7 @@ Outputs & filters:
access([other.c2], [other.c3]), partitions(p0)
is_index_back=false, is_global_index=false,
range_key([other.c2], [other.c3], [other.c1]), range(MIN,MIN,MIN ; MAX,MAX,MAX)always true
explain select v3, v4 from skyline_int order by v3, v4 union select distinct c2, c3 from other order by v3, v4;
explain (select v3, v4 from skyline_int order by v3, v4) union select distinct c2, c3 from other order by v3, v4;
Query Plan
=========================================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|

View File

@ -150,7 +150,7 @@ explain select a, b, c from t2 left join t1 on t1.b = t2.x order by b, c;
##set
explain select a, b, c from t1 union select x, y, z from t2;
explain select a, b, c from t1 order by c, b, a union select x, y, z from t2;
explain (select a, b, c from t1 order by c, b, a )union select x, y, z from t2;
explain select b, c, a from t1 where b > 100 union select x, y, z from t2 where x > 100;
explain select b, c, a from t1 where b > 100 and b < 200 union select x, y, z from t2 where x > 100 and x < 200;
@ -296,9 +296,9 @@ explain select /*+index(t6 idx_b_e_d_c_a)*/ distinct b, d, a from t6 where e =
explain select distinct c from t6 where b = 1 and a > 2;
## union
explain select c from t6 where b = 1 limit 9 union select pk from tmp;
explain select /*+index(t6 idx_b_c)*/ c from t6 where b = 1 limit 9 union select pk from tmp;
explain select /*+index(t6 idx_b_a_c)*/ c from t6 where b = 1 limit 9 union select pk from tmp;
explain (select c from t6 where b = 1 limit 9) union select pk from tmp;
explain (select /*+index(t6 idx_b_c)*/ c from t6 where b = 1 limit 9) union select pk from tmp;
explain (select /*+index(t6 idx_b_a_c)*/ c from t6 where b = 1 limit 9) union select pk from tmp;
explain select b, c from t6 where a = 1 union select c1, c2 from tmp;
explain select /*+index(t6 idx_b_c)*/ b, c from t6 where a = 1 union select c1, c2 from tmp;

View File

@ -199,7 +199,7 @@ explain select distinct v3, v4, v5 from skyline_int order by v3, v4, v5, v6;
explain select distinct v3, v4 from skyline_int union select distinct c2, c3 from other;
## order by会消除或者能被union所用
explain select v3, v4 from skyline_int order by v3, v4 union select distinct c2, c3 from other order by v3, v4;
explain (select v3, v4 from skyline_int order by v3, v4) union select distinct c2, c3 from other order by v3, v4;
explain (select v3, v4 from skyline_int order by v3, v4) union (select distinct c2, c3 from other order by c2, c3) order by 1,2;
## 强制走 nestloop,保左表的序,group by的序能被用