github.com/vedadiyan/sqlparser@v1.0.0/pkg/sqlparser/testdata/union_cases.txt (about)

     1  INPUT
     2  SELECT ST_ASTEXT(ST_UNION(ST_ENVELOPE(ST_GEOMFROMTEXT('LINESTRING(5 9,-1 10,-2 -6,2 9,2 0,3 6,-3 3,9 -2,-3 -10,-7 -4,1 4)')),                        ST_UNION(ST_GEOMFROMTEXT('MULTILINESTRING((6 -8,10 -8,3 0,-6 1,0 8,-1 8,-3 -3,6 -6,0 6,1 -6,-1 7,8 3),(-9 -10,-4 0,0 1,-9 1,6 9,-8 7,-2 -6,2 10,-1 -5,3 -5,-1 -10))'),                                  ST_GEOMFROMTEXT('MULTILINESTRING((8 7,2 6,-6 -8,-2 10,4 1,9 7,5 9,4 1,8 2,-2 10,8 -5))')))) as result;
     3  END
     4  OUTPUT
     5  select ST_ASTEXT(ST_UNION(ST_ENVELOPE(ST_GEOMFROMTEXT('LINESTRING(5 9,-1 10,-2 -6,2 9,2 0,3 6,-3 3,9 -2,-3 -10,-7 -4,1 4)')), ST_UNION(ST_GEOMFROMTEXT('MULTILINESTRING((6 -8,10 -8,3 0,-6 1,0 8,-1 8,-3 -3,6 -6,0 6,1 -6,-1 7,8 3),(-9 -10,-4 0,0 1,-9 1,6 9,-8 7,-2 -6,2 10,-1 -5,3 -5,-1 -10))'), ST_GEOMFROMTEXT('MULTILINESTRING((8 7,2 6,-6 -8,-2 10,4 1,9 7,5 9,4 1,8 2,-2 10,8 -5))')))) as result from dual
     6  END
     7  INPUT
     8  SELECT i FROM t2 UNION SELECT c FROM t1;
     9  END
    10  OUTPUT
    11  select i from t2 union select c from t1
    12  END
    13  INPUT
    14  select @arg00 FROM t1 where a=1 union distinct select 1 FROM t1 where a=1;
    15  END
    16  OUTPUT
    17  select @arg00 from t1 where a = 1 union select 1 from t1 where a = 1
    18  END
    19  INPUT
    20  SELECT '1' UNION SELECT 'н1234567890';
    21  END
    22  OUTPUT
    23  select '1' from dual union select 'н1234567890' from dual
    24  END
    25  INPUT
    26  select * from (select * from t1 union select * from t1) a;
    27  END
    28  OUTPUT
    29  select * from (select * from t1 union select * from t1) as a
    30  END
    31  INPUT
    32  select concat(f1, 2) a from t1 union select 'x' a from t1;
    33  END
    34  OUTPUT
    35  select concat(f1, 2) as a from t1 union select 'x' as a from t1
    36  END
    37  INPUT
    38  SELECT b FROM t2 UNION SELECT c FROM t1;
    39  END
    40  OUTPUT
    41  select b from t2 union select c from t1
    42  END
    43  INPUT
    44  (SELECT * FROM t1 ORDER BY a DESC LIMIT 5) UNION ALL (SELECT * FROM t2 ORDER BY a DESC LIMIT 4) ORDER BY a LIMIT 7;
    45  END
    46  OUTPUT
    47  (select * from t1 order by a desc limit 5) union all (select * from t2 order by a desc limit 4) order by a asc limit 7
    48  END
    49  INPUT
    50  SELECT ST_AsText(ST_Union(ST_GEOMFROMTEXT(        'GEOMETRYCOLLECTION(POLYGON((0 0, 3 0, 3 3, 0 3, 0 0)),                            LINESTRING(0 1, 4 1))'),                           ST_GEOMFROMTEXT('GEOMETRYCOLLECTION()'))) as result;
    51  END
    52  OUTPUT
    53  select ST_AsText(ST_Union(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POLYGON((0 0, 3 0, 3 3, 0 3, 0 0)),                            LINESTRING(0 1, 4 1))'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION()'))) as result from dual
    54  END
    55  INPUT
    56  select ST_astext(st_union(              st_intersection(                                multipoint(point(-1,-1)),                                point(1,-1)                                   ),               st_difference(                               multipoint(point(-1,1)),                               point(-1,-1)                                  )));
    57  END
    58  OUTPUT
    59  select ST_astext(st_union(st_intersection(multipoint(point(-1, -1)), point(1, -1)), st_difference(multipoint(point(-1, 1)), point(-1, -1)))) from dual
    60  END
    61  INPUT
    62  (select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%H') As H) union (select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%H') As H);
    63  END
    64  OUTPUT
    65  select time_format(timediff(now(), DATE_SUB(now(), interval 5 HOUR)), '%H') as H from dual union select time_format(timediff(now(), DATE_SUB(now(), interval 5 HOUR)), '%H') as H from dual
    66  END
    67  INPUT
    68  select ST_astext(st_union(st_intersection(ST_GeomFromText('point(1 1)'), ST_GeomFromText('multipoint(2 2, 3 3)')),                         st_intersection(ST_GeomFromText('point(0 0)'), ST_GeomFromText('point(1 1)'))));
    69  END
    70  OUTPUT
    71  select ST_astext(st_union(st_intersection(ST_GeomFromText('point(1 1)'), ST_GeomFromText('multipoint(2 2, 3 3)')), st_intersection(ST_GeomFromText('point(0 0)'), ST_GeomFromText('point(1 1)')))) from dual
    72  END
    73  INPUT
    74  SELECT sleep(0.5) FROM t17059925 UNION ALL SELECT * FROM t17059925 WHERE a= 10 AND a= 20 UNION ALL SELECT * FROM t2;
    75  END
    76  OUTPUT
    77  select sleep(0.5) from t17059925 union all select * from t17059925 where a = 10 and a = 20 union all select * from t2
    78  END
    79  INPUT
    80  (SELECT * FROM t1 LIMIT 5) UNION SELECT * FROM t2 ORDER BY a LIMIT 8;
    81  END
    82  OUTPUT
    83  (select * from t1 limit 5) union select * from t2 order by a asc limit 8
    84  END
    85  INPUT
    86  select * from t1 where MATCH(a,b) AGAINST ("collections") UNION ALL select * from t1 where MATCH(a,b) AGAINST ("indexes");
    87  END
    88  OUTPUT
    89  select * from t1 where match(a, b) against ('collections') union all select * from t1 where match(a, b) against ('indexes')
    90  END
    91  INPUT
    92  SELECT 1 as a FROM (SELECT a UNION SELECT 1) b;
    93  END
    94  OUTPUT
    95  select 1 as a from (select a from dual union select 1 from dual) as b
    96  END
    97  INPUT
    98  (select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%k') As H) union (select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%k') As H);
    99  END
   100  OUTPUT
   101  select time_format(timediff(now(), DATE_SUB(now(), interval 5 DAY)), '%k') as H from dual union select time_format(timediff(now(), DATE_SUB(now(), interval 5 DAY)), '%k') as H from dual
   102  END
   103  INPUT
   104  SELECT * FROM (SELECT t17059925_func1(1)) t WHERE 1= 0 UNION SELECT sleep(0.5);
   105  END
   106  OUTPUT
   107  select * from (select t17059925_func1(1) from dual) as t where 1 = 0 union select sleep(0.5) from dual
   108  END
   109  INPUT
   110  SELECT a, SUM(a), SUM(a)+1 FROM (SELECT a FROM t1 UNION select 2) d   GROUP BY a WITH ROLLUP;
   111  END
   112  ERROR
   113  syntax error at position 86 near 'WITH'
   114  END
   115  INPUT
   116  SELECT * FROM t1 UNION ALL SELECT * FROM t2 ORDER BY a LIMIT 5 OFFSET 6;
   117  END
   118  OUTPUT
   119  select * from t1 union all select * from t2 order by a asc limit 6, 5
   120  END
   121  INPUT
   122  (SELECT * FROM t1 ORDER BY a DESC LIMIT 5 OFFSET 4) UNION (SELECT * FROM t2 ORDER BY a DESC LIMIT 4 OFFSET 2) ORDER BY a LIMIT 7 OFFSET 1;
   123  END
   124  OUTPUT
   125  (select * from t1 order by a desc limit 4, 5) union (select * from t2 order by a desc limit 2, 4) order by a asc limit 1, 7
   126  END
   127  INPUT
   128  SELECT 'н1234567890' UNION SELECT _binary '1';
   129  END
   130  OUTPUT
   131  select 'н1234567890' from dual union select _binary '1' from dual
   132  END
   133  INPUT
   134  select ST_AsText(a) from (select f2 as a from t1 union select f3 from t1) t;
   135  END
   136  OUTPUT
   137  select ST_AsText(a) from (select f2 as a from t1 union select f3 from t1) as t
   138  END
   139  INPUT
   140  select st_overlaps(st_intersection(ST_GeomFromText('point(1 1)'), ST_GeomFromText('multipoint(2 2, 3 3)')),                     st_union(ST_GeomFromText('point(0 0)'), ST_GeomFromText('point(1 1)')));
   141  END
   142  OUTPUT
   143  select st_overlaps(st_intersection(ST_GeomFromText('point(1 1)'), ST_GeomFromText('multipoint(2 2, 3 3)')), st_union(ST_GeomFromText('point(0 0)'), ST_GeomFromText('point(1 1)'))) from dual
   144  END
   145  INPUT
   146  (SELECT * FROM t1 LIMIT 5) UNION ALL (SELECT * FROM t2 LIMIT 4) LIMIT 7;
   147  END
   148  OUTPUT
   149  (select * from t1 limit 5) union all (select * from t2 limit 4) limit 7
   150  END
   151  INPUT
   152  (SELECT * FROM t1 LIMIT 5 OFFSET 4) UNION (SELECT * FROM t2 LIMIT 4 OFFSET 2) LIMIT 7 OFFSET 1;
   153  END
   154  OUTPUT
   155  (select * from t1 limit 4, 5) union (select * from t2 limit 2, 4) limit 1, 7
   156  END
   157  INPUT
   158  SELECT sleep(0.5) FROM t17059925 UNION ALL SELECT * FROM t2 UNION ALL SELECT * FROM t3;
   159  END
   160  OUTPUT
   161  select sleep(0.5) from t17059925 union all select * from t2 union all select * from t3
   162  END
   163  INPUT
   164  SELECT sleep(0.5) FROM t17059925 UNION SELECT * FROM t2 UNION SELECT * FROM t3;
   165  END
   166  OUTPUT
   167  select sleep(0.5) from t17059925 union select * from t2 union select * from t3
   168  END
   169  INPUT
   170  select "xyz" as name union select "abc" as name order by name desc;
   171  END
   172  OUTPUT
   173  select 'xyz' as `name` from dual union select 'abc' as `name` from dual order by `name` desc
   174  END
   175  INPUT
   176  (SELECT * FROM t1 LIMIT 5 OFFSET 4) UNION ALL SELECT * FROM t2 ORDER BY a LIMIT 8 OFFSET 1;
   177  END
   178  OUTPUT
   179  (select * from t1 limit 4, 5) union all select * from t2 order by a asc limit 1, 8
   180  END
   181  INPUT
   182  select 'a' union select concat('a', -0.0000);
   183  END
   184  OUTPUT
   185  select 'a' from dual union select concat('a', -0.0000) from dual
   186  END
   187  INPUT
   188  select * from ( select * from t1 union select * from t1) a,(select * from t1 union select * from t1) b;
   189  END
   190  OUTPUT
   191  select * from (select * from t1 union select * from t1) as a, (select * from t1 union select * from t1) as b
   192  END
   193  INPUT
   194  SELECT DISTINCT GREATEST(a, (SELECT b FROM t1 LIMIT 1)) FROM t1 UNION SELECT 1;
   195  END
   196  OUTPUT
   197  select distinct GREATEST(a, (select b from t1 limit 1)) from t1 union select 1 from dual
   198  END
   199  INPUT
   200  SELECT DISTINCT LEAST(a, (SELECT b FROM t1 LIMIT 1)) FROM t1 UNION SELECT 1;
   201  END
   202  OUTPUT
   203  select distinct LEAST(a, (select b from t1 limit 1)) from t1 union select 1 from dual
   204  END
   205  INPUT
   206  (select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%k') As H) union (select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%k') As H);
   207  END
   208  OUTPUT
   209  select time_format(timediff(now(), DATE_SUB(now(), interval 5 HOUR)), '%k') as H from dual union select time_format(timediff(now(), DATE_SUB(now(), interval 5 HOUR)), '%k') as H from dual
   210  END
   211  INPUT
   212  select concat((select x from (select 'a' as x) as t1 ),   (select y from (select 'b' as y) as t2 )) from (select 1 union select 2 )   as t3;
   213  END
   214  OUTPUT
   215  select concat((select x from (select 'a' as x from dual) as t1), (select y from (select 'b' as y from dual) as t2)) from (select 1 from dual union select 2 from dual) as t3
   216  END
   217  INPUT
   218  select 'a' union select concat('a', 4 - 5);
   219  END
   220  OUTPUT
   221  select 'a' from dual union select concat('a', 4 - 5) from dual
   222  END
   223  INPUT
   224  select st_touches(st_union(ST_GeomFromText('point(1 1)'), ST_GeomFromText('multipoint(2 2, 3 3)')),                    st_intersection(ST_GeomFromText('point(0 0)'), ST_GeomFromText('point(1 1)')));
   225  END
   226  OUTPUT
   227  select st_touches(st_union(ST_GeomFromText('point(1 1)'), ST_GeomFromText('multipoint(2 2, 3 3)')), st_intersection(ST_GeomFromText('point(0 0)'), ST_GeomFromText('point(1 1)'))) from dual
   228  END
   229  INPUT
   230  SELECT 1 UNION SELECT 1 INTO @var FOR UPDATE;
   231  END
   232  ERROR
   233  syntax error at position 34 near 'var'
   234  END
   235  INPUT
   236  select st_intersects(st_union(ST_GeomFromText('point(1 1)'), ST_GeomFromText('multipoint(2 2, 3 3)')),                       st_intersection(ST_GeomFromText('point(0 0)'), ST_GeomFromText('point(1 1)')));
   237  END
   238  OUTPUT
   239  select st_intersects(st_union(ST_GeomFromText('point(1 1)'), ST_GeomFromText('multipoint(2 2, 3 3)')), st_intersection(ST_GeomFromText('point(0 0)'), ST_GeomFromText('point(1 1)'))) from dual
   240  END
   241  INPUT
   242  select ST_astext(ST_UNION(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('LINESTRING(-10 -10, 200 200, 199 201, -11 -9)')));
   243  END
   244  OUTPUT
   245  select ST_astext(ST_UNION(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('LINESTRING(-10 -10, 200 200, 199 201, -11 -9)'))) from dual
   246  END
   247  INPUT
   248  SELECT NULL as "my_col1",2 AS "my_col2" UNION SELECT NULL,1;
   249  END
   250  OUTPUT
   251  select null as my_col1, 2 as my_col2 from dual union select null, 1 from dual
   252  END
   253  INPUT
   254  select st_contains(st_union(ST_GeomFromText('point(1 1)'), ST_GeomFromText('multipoint(2 2, 3 3)')),                     st_intersection(ST_GeomFromText('point(0 0)'), ST_GeomFromText('point(1 1)')));
   255  END
   256  OUTPUT
   257  select st_contains(st_union(ST_GeomFromText('point(1 1)'), ST_GeomFromText('multipoint(2 2, 3 3)')), st_intersection(ST_GeomFromText('point(0 0)'), ST_GeomFromText('point(1 1)'))) from dual
   258  END
   259  INPUT
   260  SELECT ST_AsText(ST_Union(ST_GEOMFROMTEXT(        'GEOMETRYCOLLECTION(LINESTRING(4 1, 6 1),                            LINESTRING(0 1, 4 1))'),                           ST_GEOMFROMTEXT('GEOMETRYCOLLECTION()'))) as result;
   261  END
   262  OUTPUT
   263  select ST_AsText(ST_Union(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(LINESTRING(4 1, 6 1),                            LINESTRING(0 1, 4 1))'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION()'))) as result from dual
   264  END
   265  INPUT
   266  SELECT ST_ISVALID(ST_UNION(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 40,40 40,40 0,0 0),(10 10,30 10,30 30,10 30,10 10)))'), ST_GEOMFROMTEXT('MULTIPOLYGON(((10 10,10 20,20 10,10 10)),((20 10,30 20,30 10,20 10)),((10 20,10 30,20 20,10 20)),((20 20,30 30,30 20,20 20)))')));
   267  END
   268  OUTPUT
   269  select ST_ISVALID(ST_UNION(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 40,40 40,40 0,0 0),(10 10,30 10,30 30,10 30,10 10)))'), ST_GEOMFROMTEXT('MULTIPOLYGON(((10 10,10 20,20 10,10 10)),((20 10,30 20,30 10,20 10)),((10 20,10 30,20 20,10 20)),((20 20,30 30,30 20,20 20)))'))) from dual
   270  END
   271  INPUT
   272  (SELECT * FROM t1 LIMIT 5 OFFSET 4) UNION (SELECT * FROM t2 LIMIT 4 OFFSET 2) ORDER BY a LIMIT 7 OFFSET 1;
   273  END
   274  OUTPUT
   275  (select * from t1 limit 4, 5) union (select * from t2 limit 2, 4) order by a asc limit 1, 7
   276  END
   277  INPUT
   278  (SELECT * FROM t1 LIMIT 5 OFFSET 4) UNION SELECT * FROM t2 LIMIT 8 OFFSET 1;
   279  END
   280  OUTPUT
   281  (select * from t1 limit 4, 5) union select * from t2 limit 1, 8
   282  END
   283  INPUT
   284  SELECT "Xyz" AS Name UNION SELECT "Abc" as Name ORDER BY Name DESC;
   285  END
   286  OUTPUT
   287  select 'Xyz' as `Name` from dual union select 'Abc' as `Name` from dual order by `Name` desc
   288  END
   289  INPUT
   290  (SELECT * FROM t1 ORDER BY a DESC LIMIT 5) UNION (SELECT * FROM t2 ORDER BY a DESC LIMIT 4) LIMIT 7;
   291  END
   292  OUTPUT
   293  (select * from t1 order by a desc limit 5) union (select * from t2 order by a desc limit 4) limit 7
   294  END
   295  INPUT
   296  select * from t1 union distinct select * from t2 union all select * from t3;
   297  END
   298  OUTPUT
   299  select * from t1 union select * from t2 union all select * from t3
   300  END
   301  INPUT
   302  SELECT ST_CONTAINS(ST_UNION(ST_INTERSECTION(ST_GEOMFROMTEXT('POINT(-3 3)'),                                             ST_GEOMFROMTEXT('POLYGON((8 3,-2 9,-10 2,-10 -9,7 -1,4 1,7 6,5 -10,5 3,2 1,-10 0, 8 3))')),                              ST_CONVEXHULL(ST_GEOMFROMTEXT('MULTIPOINT(8 -8,-7 5)'))),                     ST_UNION(ST_GEOMFROMTEXT('POINT(4 1)'),                              ST_GEOMFROMTEXT('MULTIPOINT(-10 -10,5 -2,-6 -7,1 5,-3 0)'))) as result;
   303  END
   304  OUTPUT
   305  select ST_CONTAINS(ST_UNION(ST_INTERSECTION(ST_GEOMFROMTEXT('POINT(-3 3)'), ST_GEOMFROMTEXT('POLYGON((8 3,-2 9,-10 2,-10 -9,7 -1,4 1,7 6,5 -10,5 3,2 1,-10 0, 8 3))')), ST_CONVEXHULL(ST_GEOMFROMTEXT('MULTIPOINT(8 -8,-7 5)'))), ST_UNION(ST_GEOMFROMTEXT('POINT(4 1)'), ST_GEOMFROMTEXT('MULTIPOINT(-10 -10,5 -2,-6 -7,1 5,-3 0)'))) as result from dual
   306  END
   307  INPUT
   308  select * from (select * from t1 union all select * from t1 limit 2) a;
   309  END
   310  OUTPUT
   311  select * from (select * from t1 union all select * from t1 limit 2) as a
   312  END
   313  INPUT
   314  (SELECT table3.col_varchar_10_latin1_key, table1.col_varchar_1024_latin1_key, table1.col_varchar_1024_latin1_key  FROM view_e AS table1  LEFT JOIN view_h AS table2  LEFT JOIN t1 AS table3 ON table2.col_int_key = table3.pk ON table1.col_varchar_1024_latin1_key = table3.col_varchar_10_utf8_key ) UNION DISTINCT (  SELECT table3.col_varchar_10_latin1_key, table1.col_varchar_1024_latin1_key, table1.col_varchar_1024_latin1_key  FROM view_e AS table1  LEFT JOIN view_h AS table2  LEFT JOIN t1 AS table3 ON table2.col_int_key = table3.pk ON table1.col_varchar_1024_latin1_key = table3.col_varchar_10_utf8_key );
   315  END
   316  OUTPUT
   317  select table3.col_varchar_10_latin1_key, table1.col_varchar_1024_latin1_key, table1.col_varchar_1024_latin1_key from view_e as table1 left join view_h as table2 left join t1 as table3 on table2.col_int_key = table3.pk on table1.col_varchar_1024_latin1_key = table3.col_varchar_10_utf8_key union select table3.col_varchar_10_latin1_key, table1.col_varchar_1024_latin1_key, table1.col_varchar_1024_latin1_key from view_e as table1 left join view_h as table2 left join t1 as table3 on table2.col_int_key = table3.pk on table1.col_varchar_1024_latin1_key = table3.col_varchar_10_utf8_key
   318  END
   319  INPUT
   320  SELECT c FROM t1 UNION SELECT i FROM t2;
   321  END
   322  OUTPUT
   323  select c from t1 union select i from t2
   324  END
   325  INPUT
   326  SELECT  * FROM (t1 RIGHT JOIN                 (SELECT * FROM t3 WHERE (DAYNAME('1995')))  AS table2 ON                 (( t1.f1 ,t1.pk) IN (SELECT 7,4 UNION SELECT 9,2))) WHERE (NOT EXISTS (SELECT t1.f1 FROM (t1 INNER JOIN t2 ON (t1.pk=t2.f1))              WHERE 0 IS NOT NULL)) AND t1.f1 >  50;
   327  END
   328  OUTPUT
   329  select * from (t1 right join (select * from t3 where DAYNAME('1995')) as table2 on (t1.f1, t1.pk) in (select 7, 4 from dual union select 9, 2 from dual)) where not exists (select t1.f1 from (t1 join t2 on t1.pk = t2.f1) where 0 is not null) and t1.f1 > 50
   330  END
   331  INPUT
   332  (SELECT * FROM t1 ORDER BY a DESC LIMIT 5) UNION SELECT * FROM t2 ORDER BY a LIMIT 8;
   333  END
   334  OUTPUT
   335  (select * from t1 order by a desc limit 5) union select * from t2 order by a asc limit 8
   336  END
   337  INPUT
   338  (SELECT a FROM t1 ORDER BY COUNT(*) LIMIT 1) UNION ALL SELECT a FROM t1;
   339  END
   340  OUTPUT
   341  (select a from t1 order by count(*) asc limit 1) union all select a from t1
   342  END
   343  INPUT
   344  SELECT ST_AsText(ST_Union(ST_GEOMFROMTEXT(        'GEOMETRYCOLLECTION(POLYGON((0 0, 3 0, 3 3, 0 3, 0 0)),                            LINESTRING(3 1, 4 1))'),                           ST_GEOMFROMTEXT('GEOMETRYCOLLECTION()'))) as result;
   345  END
   346  OUTPUT
   347  select ST_AsText(ST_Union(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POLYGON((0 0, 3 0, 3 3, 0 3, 0 0)),                            LINESTRING(3 1, 4 1))'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION()'))) as result from dual
   348  END
   349  INPUT
   350  select 'a' union select concat('a', -concat('3',4));
   351  END
   352  OUTPUT
   353  select 'a' from dual union select concat('a', -concat('3', 4)) from dual
   354  END
   355  INPUT
   356  SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a LIMIT 5 OFFSET 6;
   357  END
   358  OUTPUT
   359  select * from t1 union select * from t2 order by a asc limit 6, 5
   360  END
   361  INPUT
   362  (SELECT * FROM t1 LIMIT 5) UNION (SELECT * FROM t2 LIMIT 4) ORDER BY a LIMIT 7;
   363  END
   364  OUTPUT
   365  (select * from t1 limit 5) union (select * from t2 limit 4) order by a asc limit 7
   366  END
   367  INPUT
   368  SELECT 1 FOR UPDATE UNION SELECT 2;
   369  END
   370  ERROR
   371  syntax error at position 26 near 'UNION'
   372  END
   373  INPUT
   374  SELECT product, country_id , year, SUM(profit) FROM t1 GROUP BY product, country_id, year WITH CUBE UNION ALL SELECT product, country_id , year, SUM(profit) FROM t1 GROUP BY product, country_id, year WITH ROLLUP;
   375  END
   376  ERROR
   377  syntax error at position 95 near 'WITH'
   378  END
   379  INPUT
   380  select   (with recursive dt as     (select t1.a as a union select a+1 from dt where a<10)    select dt1.a from dt dt1 where dt1.a=t1.a   ) as subq from t1;
   381  END
   382  OUTPUT
   383  select (with recursive dt as (select t1.a as a from dual union select a + 1 from dt where a < 10) select dt1.a from dt as dt1 where dt1.a = t1.a) as subq from t1
   384  END
   385  INPUT
   386  (SELECT * FROM t1 ORDER BY a DESC LIMIT 5) UNION ALL SELECT * FROM t2 ORDER BY a LIMIT 8;
   387  END
   388  OUTPUT
   389  (select * from t1 order by a desc limit 5) union all select * from t2 order by a asc limit 8
   390  END
   391  INPUT
   392  select st_astext(st_union(ST_GeometryFromText('geometrycollection(polygon((0 0, 2 0, 2 1, 0 1, 0 0)))'), ST_GeometryFromText('geometrycollection(polygon((1 0, 3 0, 3 1, 1 1, 1 0)))')));
   393  END
   394  OUTPUT
   395  select st_astext(st_union(ST_GeometryFromText('geometrycollection(polygon((0 0, 2 0, 2 1, 0 1, 0 0)))'), ST_GeometryFromText('geometrycollection(polygon((1 0, 3 0, 3 1, 1 1, 1 0)))'))) from dual
   396  END
   397  INPUT
   398  select st_equals(st_intersection(ST_GeomFromText('point(1 1)'), ST_GeomFromText('multipoint(2 2, 3 3)')),                   st_union(ST_GeomFromText('point(0 0)'), ST_GeomFromText('point(1 1)')));
   399  END
   400  OUTPUT
   401  select st_equals(st_intersection(ST_GeomFromText('point(1 1)'), ST_GeomFromText('multipoint(2 2, 3 3)')), st_union(ST_GeomFromText('point(0 0)'), ST_GeomFromText('point(1 1)'))) from dual
   402  END
   403  INPUT
   404  (SELECT * FROM t1 LIMIT 5) UNION ALL SELECT * FROM t2 ORDER BY a LIMIT 8;
   405  END
   406  OUTPUT
   407  (select * from t1 limit 5) union all select * from t2 order by a asc limit 8
   408  END
   409  INPUT
   410  SELECT ST_ISVALID(ST_UNION(ST_GEOMFROMTEXT('POLYGON((0 6,-11 -6,6 0,0 6),(3 1,5 0,-2 0,3 1))'), ST_GEOMFROMTEXT('POLYGON((5 4,6 0,9 12,-7 -12,5 -19,5 4))')));
   411  END
   412  OUTPUT
   413  select ST_ISVALID(ST_UNION(ST_GEOMFROMTEXT('POLYGON((0 6,-11 -6,6 0,0 6),(3 1,5 0,-2 0,3 1))'), ST_GEOMFROMTEXT('POLYGON((5 4,6 0,9 12,-7 -12,5 -19,5 4))'))) from dual
   414  END
   415  INPUT
   416  (SELECT * FROM t1 ORDER BY a DESC LIMIT 5 OFFSET 4) UNION ALL (SELECT * FROM t2 ORDER BY a DESC LIMIT 4 OFFSET 2) LIMIT 7 OFFSET 1;
   417  END
   418  OUTPUT
   419  (select * from t1 order by a desc limit 4, 5) union all (select * from t2 order by a desc limit 2, 4) limit 1, 7
   420  END
   421  INPUT
   422  (select b.id, b.betreff from t3 b) union  (select b.id, b.betreff from t3 b)  order by match(betreff) against ('+abc') desc;
   423  END
   424  OUTPUT
   425  select b.id, b.betreff from t3 as b union select b.id, b.betreff from t3 as b order by match(betreff) against ('+abc') desc
   426  END
   427  INPUT
   428  SELECT ST_AsText(ST_Union(ST_GEOMFROMTEXT(        'GEOMETRYCOLLECTION(POLYGON((0 0, 5 0, 5 5, 0 5,0 0)),                            POLYGON((5 0,10 0, 10 3,5 3,5 0)))'),                           ST_GEOMFROMTEXT('GEOMETRYCOLLECTION()'))) as result;
   429  END
   430  OUTPUT
   431  select ST_AsText(ST_Union(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POLYGON((0 0, 5 0, 5 5, 0 5,0 0)),                            POLYGON((5 0,10 0, 10 3,5 3,5 0)))'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION()'))) as result from dual
   432  END
   433  INPUT
   434  select f1 from t1 union select f1 from t1;
   435  END
   436  OUTPUT
   437  select f1 from t1 union select f1 from t1
   438  END
   439  INPUT
   440  select f1,'' from t1 union select f1,'' from t1;
   441  END
   442  OUTPUT
   443  select f1, '' from t1 union select f1, '' from t1
   444  END
   445  INPUT
   446  select st_intersects(st_intersection(ST_GeomFromText('point(1 1)'), ST_GeomFromText('multipoint(2 2, 3 3)')),                       st_union(ST_GeomFromText('point(0 0)'), ST_GeomFromText('point(1 1)')));
   447  END
   448  OUTPUT
   449  select st_intersects(st_intersection(ST_GeomFromText('point(1 1)'), ST_GeomFromText('multipoint(2 2, 3 3)')), st_union(ST_GeomFromText('point(0 0)'), ST_GeomFromText('point(1 1)'))) from dual
   450  END
   451  INPUT
   452  (SELECT a FROM t1 ORDER BY COUNT(*)) UNION ALL SELECT a FROM t1;
   453  END
   454  OUTPUT
   455  (select a from t1 order by count(*) asc) union all select a from t1
   456  END
   457  INPUT
   458  (SELECT * FROM t1 LIMIT 5 OFFSET 4) UNION ALL (SELECT * FROM t2 LIMIT 4 OFFSET 2) LIMIT 7 OFFSET 1;
   459  END
   460  OUTPUT
   461  (select * from t1 limit 4, 5) union all (select * from t2 limit 2, 4) limit 1, 7
   462  END
   463  INPUT
   464  SELECT * FROM t1 UNION ALL SELECT * FROM t2 LIMIT 5 OFFSET 6;
   465  END
   466  OUTPUT
   467  select * from t1 union all select * from t2 limit 6, 5
   468  END
   469  INPUT
   470  select t1.id from t1 union select t2.id from t2;
   471  END
   472  OUTPUT
   473  select t1.id from t1 union select t2.id from t2
   474  END
   475  INPUT
   476  select 'a' union select concat('a', -4);
   477  END
   478  OUTPUT
   479  select 'a' from dual union select concat('a', -4) from dual
   480  END
   481  INPUT
   482  select 'a' union select concat('a', -'3');
   483  END
   484  OUTPUT
   485  select 'a' from dual union select concat('a', -'3') from dual
   486  END
   487  INPUT
   488  select 'a' union select concat('a', -0);
   489  END
   490  OUTPUT
   491  select 'a' from dual union select concat('a', -0) from dual
   492  END
   493  INPUT
   494  SELECT a, SUM(a), SUM(a)+1 FROM (SELECT 1 a UNION select 2) d   GROUP BY a WITH ROLLUP;
   495  END
   496  ERROR
   497  syntax error at position 80 near 'WITH'
   498  END
   499  INPUT
   500  SELECT LOCATION FROM T1 WHERE EVENT_ID=2 UNION ALL  SELECT LOCATION FROM T1 WHERE EVENT_ID=3;
   501  END
   502  OUTPUT
   503  select LOCATION from T1 where EVENT_ID = 2 union all select LOCATION from T1 where EVENT_ID = 3
   504  END
   505  INPUT
   506  (SELECT * FROM t1 LIMIT 5 OFFSET 4) UNION SELECT * FROM t2 ORDER BY a LIMIT 8 OFFSET 1;
   507  END
   508  OUTPUT
   509  (select * from t1 limit 4, 5) union select * from t2 order by a asc limit 1, 8
   510  END
   511  INPUT
   512  (SELECT * FROM t1 LIMIT 5) UNION (SELECT * FROM t2 LIMIT 4) LIMIT 7;
   513  END
   514  OUTPUT
   515  (select * from t1 limit 5) union (select * from t2 limit 4) limit 7
   516  END
   517  INPUT
   518  SELECT 1 UNION SELECT 2 LOCK IN SHARE MODE;
   519  END
   520  OUTPUT
   521  select 1 from dual union select 2 from dual lock in share mode
   522  END
   523  INPUT
   524  SELECT a FROM t1 UNION (SELECT a FROM t1 ORDER BY COUNT(*));
   525  END
   526  OUTPUT
   527  select a from t1 union (select a from t1 order by count(*) asc)
   528  END
   529  INPUT
   530  select min(`col002`) from t1 union select `col002` from t1;
   531  END
   532  OUTPUT
   533  select min(col002) from t1 union select col002 from t1
   534  END
   535  INPUT
   536  SELECT 'case+union+test' UNION  SELECT CASE LOWER('1') WHEN LOWER('2') THEN 'BUG' ELSE 'nobug' END;
   537  END
   538  OUTPUT
   539  select 'case+union+test' from dual union select case LOWER('1') when LOWER('2') then 'BUG' else 'nobug' end from dual
   540  END
   541  INPUT
   542  SELECT sleep(0.5) FROM t17059925 UNION SELECT * FROM (SELECT t17059925_func1(1)) t WHERE 1= 0 UNION SELECT t17059925_func1(1);
   543  END
   544  OUTPUT
   545  select sleep(0.5) from t17059925 union select * from (select t17059925_func1(1) from dual) as t where 1 = 0 union select t17059925_func1(1) from dual
   546  END
   547  INPUT
   548  (select 1 as a from t1) union all (select 1 from dual) limit 1;
   549  END
   550  OUTPUT
   551  select 1 as a from t1 union all select 1 from dual limit 1
   552  END
   553  INPUT
   554  select st_disjoint(st_union(ST_GeomFromText('point(1 1)'), ST_GeomFromText('multipoint(2 2, 3 3)')),                     st_intersection(ST_GeomFromText('point(0 0)'), ST_GeomFromText('point(1 1)')));
   555  END
   556  OUTPUT
   557  select st_disjoint(st_union(ST_GeomFromText('point(1 1)'), ST_GeomFromText('multipoint(2 2, 3 3)')), st_intersection(ST_GeomFromText('point(0 0)'), ST_GeomFromText('point(1 1)'))) from dual
   558  END
   559  INPUT
   560  SELECT alias2 . `col_int_nokey` AS field1 FROM ( CC AS alias1 INNER JOIN ( ( BB AS alias2 INNER JOIN        (  SELECT   SQ1_alias1 . * FROM C AS SQ1_alias1  ) AS alias3          ON (alias3 . `col_int_key` = alias2 . `col_int_nokey`  ) ) )        ON (alias3 . `col_varchar_nokey` = alias2 . `col_varchar_key`  ) ) WHERE (  ( alias2 . `pk` , alias3 . `col_int_nokey` ) IN   ( SELECT 4 , 7  UNION  SELECT 137, 6 ) )     AND alias1 . `pk` > 149 AND alias1 . `pk` < ( 149 + 7 )     OR alias3 . `col_varchar_key` < 'o';
   561  END
   562  OUTPUT
   563  select alias2.col_int_nokey as field1 from (CC as alias1 join ((BB as alias2 join (select SQ1_alias1.* from C as SQ1_alias1) as alias3 on alias3.col_int_key = alias2.col_int_nokey)) on alias3.col_varchar_nokey = alias2.col_varchar_key) where (alias2.pk, alias3.col_int_nokey) in (select 4, 7 from dual union select 137, 6 from dual) and alias1.pk > 149 and alias1.pk < 149 + 7 or alias3.col_varchar_key < 'o'
   564  END
   565  INPUT
   566  (SELECT * FROM t1 ORDER BY a DESC LIMIT 5) UNION ALL SELECT * FROM t2 LIMIT 8;
   567  END
   568  OUTPUT
   569  (select * from t1 order by a desc limit 5) union all select * from t2 limit 8
   570  END
   571  INPUT
   572  select repeat(_utf8'+',3) as h union select NULL;
   573  END
   574  OUTPUT
   575  select repeat(_utf8 '+', 3) as h from dual union select null from dual
   576  END
   577  INPUT
   578  SELECT * FROM t1 UNION SELECT /*+ MAX_EXECUTION_TIME(0) */ * FROM t1;
   579  END
   580  OUTPUT
   581  select * from t1 union select /*+ MAX_EXECUTION_TIME(0) */ * from t1
   582  END
   583  INPUT
   584  SELECT ST_AsText(st_union(ST_GeomFromText('GeometryCollection(GeometryCollection(Point(1 1)), GeometryCollection(linestring(1 1, 2 2)))'),                        ST_GeomFromText('GeometryCollection(GeometryCollection(Point(1 1)))')));
   585  END
   586  OUTPUT
   587  select ST_AsText(st_union(ST_GeomFromText('GeometryCollection(GeometryCollection(Point(1 1)), GeometryCollection(linestring(1 1, 2 2)))'), ST_GeomFromText('GeometryCollection(GeometryCollection(Point(1 1)))'))) from dual
   588  END
   589  INPUT
   590  select ST_astext(st_union(ST_GeomFromText('multipoint(2 2, 3 3)'), st_intersection(ST_GeomFromText('point(0 0)'), ST_GeomFromText('point(1 1)'))));
   591  END
   592  OUTPUT
   593  select ST_astext(st_union(ST_GeomFromText('multipoint(2 2, 3 3)'), st_intersection(ST_GeomFromText('point(0 0)'), ST_GeomFromText('point(1 1)')))) from dual
   594  END
   595  INPUT
   596  select group_concat('x') UNION ALL select 1;
   597  END
   598  OUTPUT
   599  select group_concat('x') from dual union all select 1 from dual
   600  END
   601  INPUT
   602  (SELECT * FROM t1 LIMIT 5 OFFSET 4) UNION ALL SELECT * FROM t2 LIMIT 8 OFFSET 1;
   603  END
   604  OUTPUT
   605  (select * from t1 limit 4, 5) union all select * from t2 limit 1, 8
   606  END
   607  INPUT
   608  SELECT 1 FROM dual WHERE 1= 0 UNION SELECT sleep(0.5);
   609  END
   610  OUTPUT
   611  select 1 from dual where 1 = 0 union select sleep(0.5) from dual
   612  END
   613  INPUT
   614  select * from (select 1 union select 1) aaa;
   615  END
   616  OUTPUT
   617  select * from (select 1 from dual union select 1 from dual) as aaa
   618  END
   619  INPUT
   620  SELECT a, SUM(a), SUM(a)+1, CONCAT(SUM(a),'x'), SUM(a)+SUM(a), SUM(a)   FROM (SELECT 1 a, 2 b UNION SELECT 2,3 UNION SELECT 5,6 ) d     GROUP BY a WITH ROLLUP;
   621  END
   622  ERROR
   623  syntax error at position 152 near 'WITH'
   624  END
   625  INPUT
   626  select st_equals(st_union(ST_GeomFromText('point(1 1)'), ST_GeomFromText('multipoint(2 2, 3 3)')),                   st_intersection(ST_GeomFromText('point(0 0)'), ST_GeomFromText('point(1 1)')));
   627  END
   628  OUTPUT
   629  select st_equals(st_union(ST_GeomFromText('point(1 1)'), ST_GeomFromText('multipoint(2 2, 3 3)')), st_intersection(ST_GeomFromText('point(0 0)'), ST_GeomFromText('point(1 1)'))) from dual
   630  END
   631  INPUT
   632  (SELECT * FROM t1 LIMIT 5 OFFSET 4) UNION ALL (SELECT * FROM t2 LIMIT 4 OFFSET 2) ORDER BY a LIMIT 7 OFFSET 1;
   633  END
   634  OUTPUT
   635  (select * from t1 limit 4, 5) union all (select * from t2 limit 2, 4) order by a asc limit 1, 7
   636  END
   637  INPUT
   638  SELECT sleep(0.5) FROM t17059925 UNION SELECT * FROM t17059925 WHERE a= 10 AND a= 20 UNION SELECT * FROM t2;
   639  END
   640  OUTPUT
   641  select sleep(0.5) from t17059925 union select * from t17059925 where a = 10 and a = 20 union select * from t2
   642  END
   643  INPUT
   644  SELECT ST_ISVALID(ST_UNION(ST_GEOMFROMTEXT('POLYGON((0 0,0 40,40 40,40 0,0 0),(10 10,30 10,30 30,10 30,10 10))'), ST_GEOMFROMTEXT('POLYGON((5 15,5 30,30 15,5 15))')));
   645  END
   646  OUTPUT
   647  select ST_ISVALID(ST_UNION(ST_GEOMFROMTEXT('POLYGON((0 0,0 40,40 40,40 0,0 0),(10 10,30 10,30 30,10 30,10 10))'), ST_GEOMFROMTEXT('POLYGON((5 15,5 30,30 15,5 15))'))) from dual
   648  END
   649  INPUT
   650  (SELECT * FROM t1 ORDER BY a DESC LIMIT 5) UNION ALL (SELECT * FROM t2 ORDER BY a DESC LIMIT 4) LIMIT 7;
   651  END
   652  OUTPUT
   653  (select * from t1 order by a desc limit 5) union all (select * from t2 order by a desc limit 4) limit 7
   654  END
   655  INPUT
   656  select * from (select * from t1 where t1.a=(select t2.a from t2 where t2.a=t1.a) union select t1.a, t1.b from t1) a;
   657  END
   658  OUTPUT
   659  select * from (select * from t1 where t1.a = (select t2.a from t2 where t2.a = t1.a) union select t1.a, t1.b from t1) as a
   660  END
   661  INPUT
   662  SELECT id, CHAR_LENGTH(GROUP_CONCAT(body)) AS l FROM (SELECT 'a' AS id, REPEAT('foo bar', 100) AS body UNION ALL SELECT 'a' AS id, REPEAT('bla bla', 100) AS body) t1 GROUP BY id ORDER BY l DESC;
   663  END
   664  OUTPUT
   665  select id, CHAR_LENGTH(group_concat(body)) as l from (select 'a' as id, REPEAT('foo bar', 100) as body from dual union all select 'a' as id, REPEAT('bla bla', 100) as body from dual) as t1 group by id order by l desc
   666  END
   667  INPUT
   668  SELECT '00' UNION SELECT '10' INTO OUTFILE 'tmpp.txt';
   669  END
   670  OUTPUT
   671  select '00' from dual union (select '10' from dual into outfile 'tmpp.txt')
   672  END
   673  INPUT
   674  select ST_ASTEXT(ST_UNION(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(MULTILINESTRING((0 -14,13 -8),(-5 -3,8 7),(-6 18,17 -11,-12 19,19 5),(16 11,9 -5),(17 -5,5 10),(-4 17,6 4),(-12 15,17 13,-18 11,15 10),(7 0,2 -16,-18 13,-6 4),(-17 -6,-6 -7,1 4,-18 0)),GEOMETRYCOLLECTION(MULTIPOINT(0 14,-9 -11),MULTILINESTRING((-11 -2,17 -14),(18 -12,18 -8),(-13 -16,9 16,9 -10,-7 20),(-14 -5,10 -9,4 1,17 -8),(-9 -4,-2 -12,9 -13,-5 4),(15 17,13 20))),MULTIPOINT(16 1,-9 -17,-16 6,-17 3),POINT(-18 13))'),                           ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POINT(7 0),MULTILINESTRING((-13 -18,-16 0),(17 11,-1 11,-18 -19,-4 -18),(-8 -8,-15 -13,3 -18,6 8)),LINESTRING(5 16,0 -9,-6 4,-15 17),MULTIPOINT(-9 -5,5 15,12 -11,12 11))'))) as result;
   675  END
   676  OUTPUT
   677  select ST_ASTEXT(ST_UNION(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(MULTILINESTRING((0 -14,13 -8),(-5 -3,8 7),(-6 18,17 -11,-12 19,19 5),(16 11,9 -5),(17 -5,5 10),(-4 17,6 4),(-12 15,17 13,-18 11,15 10),(7 0,2 -16,-18 13,-6 4),(-17 -6,-6 -7,1 4,-18 0)),GEOMETRYCOLLECTION(MULTIPOINT(0 14,-9 -11),MULTILINESTRING((-11 -2,17 -14),(18 -12,18 -8),(-13 -16,9 16,9 -10,-7 20),(-14 -5,10 -9,4 1,17 -8),(-9 -4,-2 -12,9 -13,-5 4),(15 17,13 20))),MULTIPOINT(16 1,-9 -17,-16 6,-17 3),POINT(-18 13))'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POINT(7 0),MULTILINESTRING((-13 -18,-16 0),(17 11,-1 11,-18 -19,-4 -18),(-8 -8,-15 -13,3 -18,6 8)),LINESTRING(5 16,0 -9,-6 4,-15 17),MULTIPOINT(-9 -5,5 15,12 -11,12 11))'))) as result from dual
   678  END
   679  INPUT
   680  SELECT ST_ISVALID(   ST_UNION(     ST_GEOMFROMTEXT('       LINESTRING(-9 -17,17 -11)     '),     ST_GEOMFROMTEXT('       GEOMETRYCOLLECTION(         LINESTRING(8 16,-8 -3),         POLYGON((2 3,-9 -7,12 -13,2 3)),         MULTILINESTRING((-2 2,11 -10),(6 0,-15 0,16 0))       )     ')   ) ) AS valid;
   681  END
   682  OUTPUT
   683  select ST_ISVALID(ST_UNION(ST_GEOMFROMTEXT('       LINESTRING(-9 -17,17 -11)     '), ST_GEOMFROMTEXT('       GEOMETRYCOLLECTION(         LINESTRING(8 16,-8 -3),         POLYGON((2 3,-9 -7,12 -13,2 3)),         MULTILINESTRING((-2 2,11 -10),(6 0,-15 0,16 0))       )     '))) as valid from dual
   684  END
   685  INPUT
   686  select ST_astext(ST_Union(ST_geometryfromtext('point(1 1)'), ST_geometryfromtext('polygon((0 0, 2 0, 1 2, 0 0))')));
   687  END
   688  OUTPUT
   689  select ST_astext(ST_Union(ST_geometryfromtext('point(1 1)'), ST_geometryfromtext('polygon((0 0, 2 0, 1 2, 0 0))'))) from dual
   690  END
   691  INPUT
   692  SELECT 1 as a FROM (SELECT 1 UNION SELECT a) b;
   693  END
   694  OUTPUT
   695  select 1 as a from (select 1 from dual union select a from dual) as b
   696  END
   697  INPUT
   698  SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a LIMIT 5;
   699  END
   700  OUTPUT
   701  select * from t1 union select * from t2 order by a asc limit 5
   702  END
   703  INPUT
   704  SELECT /*+ MAX_EXECUTION_TIME(0) */ * FROM t1   UNION SELECT /*+ MAX_EXECUTION_TIME(0) */ * FROM t1;
   705  END
   706  OUTPUT
   707  select /*+ MAX_EXECUTION_TIME(0) */ * from t1 union select /*+ MAX_EXECUTION_TIME(0) */ * from t1
   708  END
   709  INPUT
   710  (select b.id, b.betreff from t3 b) union  (select b.id, b.betreff from t3 b)  order by match(betreff) against ('+abc' in boolean mode) desc;
   711  END
   712  OUTPUT
   713  select b.id, b.betreff from t3 as b union select b.id, b.betreff from t3 as b order by match(betreff) against ('+abc' in boolean mode) desc
   714  END
   715  INPUT
   716  SELECT * FROM t1 WHERE (a, a) NOT IN   (SELECT * FROM (SELECT 8, 4 UNION SELECT 2, 3) tt);
   717  END
   718  OUTPUT
   719  select * from t1 where (a, a) not in (select * from (select 8, 4 from dual union select 2, 3 from dual) as tt)
   720  END
   721  INPUT
   722  select st_touches(st_intersection(ST_GeomFromText('point(1 1)'), ST_GeomFromText('multipoint(2 2, 3 3)')),                    st_union(ST_GeomFromText('point(0 0)'), ST_GeomFromText('point(1 1)')));
   723  END
   724  OUTPUT
   725  select st_touches(st_intersection(ST_GeomFromText('point(1 1)'), ST_GeomFromText('multipoint(2 2, 3 3)')), st_union(ST_GeomFromText('point(0 0)'), ST_GeomFromText('point(1 1)'))) from dual
   726  END
   727  INPUT
   728  (SELECT * FROM t1 ORDER BY a DESC LIMIT 5 OFFSET 4) UNION ALL (SELECT * FROM t2 ORDER BY a DESC LIMIT 4 OFFSET 2) ORDER BY a LIMIT 7 OFFSET 1;
   729  END
   730  OUTPUT
   731  (select * from t1 order by a desc limit 4, 5) union all (select * from t2 order by a desc limit 2, 4) order by a asc limit 1, 7
   732  END
   733  INPUT
   734  SELECT * FROM a LEFT JOIN vmerge AS v ON a.id = v.id UNION ALL SELECT * FROM a LEFT JOIN vmerge AS v ON a.id = v.id;
   735  END
   736  OUTPUT
   737  select * from a left join vmerge as v on a.id = v.id union all select * from a left join vmerge as v on a.id = v.id
   738  END
   739  INPUT
   740  (SELECT * FROM t1 ORDER BY a DESC LIMIT 5 OFFSET 4) UNION (SELECT * FROM t2 ORDER BY a DESC LIMIT 4 OFFSET 2) LIMIT 7 OFFSET 1;
   741  END
   742  OUTPUT
   743  (select * from t1 order by a desc limit 4, 5) union (select * from t2 order by a desc limit 2, 4) limit 1, 7
   744  END
   745  INPUT
   746  (SELECT a FROM t1 ORDER BY COUNT(*) LIMIT 1) UNION SELECT a FROM t1;
   747  END
   748  OUTPUT
   749  (select a from t1 order by count(*) asc limit 1) union select a from t1
   750  END
   751  INPUT
   752  select * from t1 union select * from t2 order by 1 limit 1;
   753  END
   754  OUTPUT
   755  select * from t1 union select * from t2 order by 1 asc limit 1
   756  END
   757  INPUT
   758  SELECT '2' as "3" UNION SELECT '1';
   759  END
   760  OUTPUT
   761  select '2' as `3` from dual union select '1' from dual
   762  END
   763  INPUT
   764  select ST_ASTEXT(ST_UNION(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(MULTILINESTRING((0 -14,13 -8),(-5 -3,8 7),(-6 18,17 -11,-12 19,19 5),(16 11,9 -5),(17 -5,5 10),(-4 17,6 4),(-12 15,17 13,-18 11,15 10),(7 0,2 -16,-18 13,-6 4),(-17 -6,-6 -7,1 4,-18 0)),MULTILINESTRING((-11 -2,17 -14),(18 -12,18 -8),(-13 -16,9 16,9 -10,-7 20),(-14 -5,10 -9,4 1,17 -8),(-9 -4,-2 -12,9 -13,-5 4),(15 17,13 20)))'),                          ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(MULTILINESTRING((-13 -18,-16 0),(17 11,-1 11,-18 -19,-4 -18),(-8 -8,-15 -13,3 -18,6 8)),LINESTRING(5 16,0 -9,-6 4,-15 17))'))) as result;
   765  END
   766  OUTPUT
   767  select ST_ASTEXT(ST_UNION(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(MULTILINESTRING((0 -14,13 -8),(-5 -3,8 7),(-6 18,17 -11,-12 19,19 5),(16 11,9 -5),(17 -5,5 10),(-4 17,6 4),(-12 15,17 13,-18 11,15 10),(7 0,2 -16,-18 13,-6 4),(-17 -6,-6 -7,1 4,-18 0)),MULTILINESTRING((-11 -2,17 -14),(18 -12,18 -8),(-13 -16,9 16,9 -10,-7 20),(-14 -5,10 -9,4 1,17 -8),(-9 -4,-2 -12,9 -13,-5 4),(15 17,13 20)))'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(MULTILINESTRING((-13 -18,-16 0),(17 11,-1 11,-18 -19,-4 -18),(-8 -8,-15 -13,3 -18,6 8)),LINESTRING(5 16,0 -9,-6 4,-15 17))'))) as result from dual
   768  END
   769  INPUT
   770  SELECT 1 LOCK IN SHARE MODE UNION SELECT 2;
   771  END
   772  ERROR
   773  syntax error at position 34 near 'UNION'
   774  END
   775  INPUT
   776  select a.text, b.id, b.betreff from    t2 a inner join t3 b on a.id = b.forum inner join   t1 c on b.id = c.thread where    match(b.betreff) against ('+abc' in boolean mode) group by a.text, b.id, b.betreff union select a.text, b.id, b.betreff from    t2 a inner join t3 b on a.id = b.forum inner join   t1 c on b.id = c.thread where    match(c.beitrag) against ('+abc' in boolean mode) group by    a.text, b.id, b.betreff order by    match(b.betreff) against ('+abc' in boolean mode) desc;
   777  END
   778  OUTPUT
   779  select a.`text`, b.id, b.betreff from t2 as a join t3 as b on a.id = b.forum join t1 as c on b.id = c.thread where match(b.betreff) against ('+abc' in boolean mode) group by a.`text`, b.id, b.betreff union select a.`text`, b.id, b.betreff from t2 as a join t3 as b on a.id = b.forum join t1 as c on b.id = c.thread where match(c.beitrag) against ('+abc' in boolean mode) group by a.`text`, b.id, b.betreff order by match(b.betreff) against ('+abc' in boolean mode) desc
   780  END
   781  INPUT
   782  SELECT 'н1234567890' UNION SELECT 1;
   783  END
   784  OUTPUT
   785  select 'н1234567890' from dual union select 1 from dual
   786  END
   787  INPUT
   788  SELECT t1.i FROM t1 WHERE FALSE AND       t1.i > (SELECT MAX(a)               FROM (SELECT 8 AS a UNION SELECT 3) AS tt);
   789  END
   790  OUTPUT
   791  select t1.i from t1 where false and t1.i > (select max(a) from (select 8 as a from dual union select 3 from dual) as tt)
   792  END
   793  INPUT
   794  (SELECT a FROM t1 ORDER BY COUNT(*)) UNION SELECT a FROM t1;
   795  END
   796  OUTPUT
   797  (select a from t1 order by count(*) asc) union select a from t1
   798  END
   799  INPUT
   800  select 1 union select 1;
   801  END
   802  OUTPUT
   803  select 1 from dual union select 1 from dual
   804  END
   805  INPUT
   806  SELECT 2 as "my_col1",NULL AS "my_col2" UNION SELECT 1,NULL;
   807  END
   808  OUTPUT
   809  select 2 as my_col1, null as my_col2 from dual union select 1, null from dual
   810  END
   811  INPUT
   812  (SELECT * FROM t1 LIMIT 5) UNION ALL SELECT * FROM t2 LIMIT 8;
   813  END
   814  OUTPUT
   815  (select * from t1 limit 5) union all select * from t2 limit 8
   816  END
   817  INPUT
   818  SELECT 1 UNION ALL SELECT f1_two_inserts();
   819  END
   820  OUTPUT
   821  select 1 from dual union all select f1_two_inserts() from dual
   822  END
   823  INPUT
   824  SELECT ST_AsText(ST_Union(ST_GeomFromText('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(MULTIPOINT(0 0,100 100), MULTIPOINT(1 1, 2 2)))'),                        ST_GeomFromText('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(),GEOMETRYCOLLECTION())'))) as result;
   825  END
   826  OUTPUT
   827  select ST_AsText(ST_Union(ST_GeomFromText('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(MULTIPOINT(0 0,100 100), MULTIPOINT(1 1, 2 2)))'), ST_GeomFromText('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(),GEOMETRYCOLLECTION())'))) as result from dual
   828  END
   829  INPUT
   830  SELECT (a DIV 254576881) FROM t1 UNION ALL    SELECT (a DIV 254576881) FROM t1;
   831  END
   832  OUTPUT
   833  select a div 254576881 from t1 union all select a div 254576881 from t1
   834  END
   835  INPUT
   836  SELECT a FROM t1 UNION (SELECT a FROM t1 ORDER BY COUNT(*) LIMIT 1 OFFSET 1);
   837  END
   838  OUTPUT
   839  select a from t1 union (select a from t1 order by count(*) asc limit 1, 1)
   840  END
   841  INPUT
   842  (SELECT * FROM t1 LIMIT 5) UNION SELECT * FROM t2 LIMIT 8;
   843  END
   844  OUTPUT
   845  (select * from t1 limit 5) union select * from t2 limit 8
   846  END
   847  INPUT
   848  select st_crosses(st_union(ST_GeomFromText('point(1 1)'), ST_GeomFromText('multipoint(2 2, 3 3)')),                    st_intersection(ST_GeomFromText('point(0 0)'), ST_GeomFromText('point(1 1)')));
   849  END
   850  OUTPUT
   851  select st_crosses(st_union(ST_GeomFromText('point(1 1)'), ST_GeomFromText('multipoint(2 2, 3 3)')), st_intersection(ST_GeomFromText('point(0 0)'), ST_GeomFromText('point(1 1)'))) from dual
   852  END
   853  INPUT
   854  SELECT 1 UNION SELECT 2 FOR UPDATE;
   855  END
   856  OUTPUT
   857  select 1 from dual union select 2 from dual for update
   858  END
   859  INPUT
   860  select st_disjoint(st_intersection(ST_GeomFromText('point(1 1)'), ST_GeomFromText('multipoint(2 2, 3 3)')),                     st_union(ST_GeomFromText('point(0 0)'), ST_GeomFromText('point(1 1)')));
   861  END
   862  OUTPUT
   863  select st_disjoint(st_intersection(ST_GeomFromText('point(1 1)'), ST_GeomFromText('multipoint(2 2, 3 3)')), st_union(ST_GeomFromText('point(0 0)'), ST_GeomFromText('point(1 1)'))) from dual
   864  END
   865  INPUT
   866  (SELECT MAX(f1) FROM t1) UNION (SELECT MAX(f1) FROM t1);
   867  END
   868  OUTPUT
   869  select max(f1) from t1 union select max(f1) from t1
   870  END
   871  INPUT
   872  SELECT c FROM t1 UNION SELECT b FROM t2;
   873  END
   874  OUTPUT
   875  select c from t1 union select b from t2
   876  END
   877  INPUT
   878  select * from t1 union all select * from t2;
   879  END
   880  OUTPUT
   881  select * from t1 union all select * from t2
   882  END
   883  INPUT
   884  SELECT ST_ISVALID(ST_UNION(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 40,40 40,40 0,0 0),(10 10,30 10,30 30,10 30,10 10)))'), ST_GEOMFROMTEXT('MULTIPOLYGON(((15 10,10 15,10 17,15 10)),((15 10,10 20,10 22,15 10)),((15 10,10 25,10 27,15 10)),((25 10,30 17,30 15,25 10)),((25 10,30 22,30 20,25 10)),((25 10,30 27,30 25,25 10)),((18 10,20 30,19 10,18 10)),((21 10,20 30,22 10,21 10)))')));
   885  END
   886  OUTPUT
   887  select ST_ISVALID(ST_UNION(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 40,40 40,40 0,0 0),(10 10,30 10,30 30,10 30,10 10)))'), ST_GEOMFROMTEXT('MULTIPOLYGON(((15 10,10 15,10 17,15 10)),((15 10,10 20,10 22,15 10)),((15 10,10 25,10 27,15 10)),((25 10,30 17,30 15,25 10)),((25 10,30 22,30 20,25 10)),((25 10,30 27,30 25,25 10)),((18 10,20 30,19 10,18 10)),((21 10,20 30,22 10,21 10)))'))) from dual
   888  END
   889  INPUT
   890  SELECT a, SUM(a), SUM(a)+1, CONCAT(SUM(a),'x'), SUM(a)+SUM(a), SUM(a)   FROM (SELECT 1 a, 2 b UNION SELECT 2,3 UNION SELECT 5,6 ) d       GROUP BY a WITH ROLLUP ORDER BY GROUPING(a),a;
   891  END
   892  ERROR
   893  syntax error at position 154 near 'WITH'
   894  END
   895  INPUT
   896  SELECT ST_ASTEXT(ST_UNION(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION())'),                           ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(GEOMETRYCOLLECTION())))'))) as geom;
   897  END
   898  OUTPUT
   899  select ST_ASTEXT(ST_UNION(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION())'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(GEOMETRYCOLLECTION())))'))) as geom from dual
   900  END
   901  INPUT
   902  SELECT ST_AsText(ST_Union(ST_GeomFromText('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(linestring(0 0,100 100), MULTIPOINT(1 1, 2 2)))'),                        ST_GeomFromText('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(),GEOMETRYCOLLECTION())'))) as result;
   903  END
   904  OUTPUT
   905  select ST_AsText(ST_Union(ST_GeomFromText('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(linestring(0 0,100 100), MULTIPOINT(1 1, 2 2)))'), ST_GeomFromText('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(),GEOMETRYCOLLECTION())'))) as result from dual
   906  END
   907  INPUT
   908  (SELECT a FROM t1 ORDER BY COUNT(*) LIMIT 1) UNION (SELECT a FROM t1 ORDER BY COUNT(*) LIMIT 1 OFFSET 1);
   909  END
   910  OUTPUT
   911  (select a from t1 order by count(*) asc limit 1) union (select a from t1 order by count(*) asc limit 1, 1)
   912  END
   913  INPUT
   914  SELECT 2 as "my_col" UNION SELECT 1;
   915  END
   916  OUTPUT
   917  select 2 as my_col from dual union select 1 from dual
   918  END
   919  INPUT
   920  select   (with recursive dt as     (select t1.a as a union select a+1 from dt where a<10)    select concat(count(*), ' - ', avg(dt.a)) from dt   ) as subq from t1;
   921  END
   922  OUTPUT
   923  select (with recursive dt as (select t1.a as a from dual union select a + 1 from dt where a < 10) select concat(count(*), ' - ', avg(dt.a)) from dt) as subq from t1
   924  END
   925  INPUT
   926  SELECT 'before' AS t, id, val1, hex(val1) FROM t1 UNION  SELECT 'after' AS t, id, val1, hex(val1) FROM t2 ORDER BY id,t DESC;
   927  END
   928  OUTPUT
   929  select 'before' as t, id, val1, hex(val1) from t1 union select 'after' as t, id, val1, hex(val1) from t2 order by id asc, t desc
   930  END
   931  INPUT
   932  SELECT 1 UNION SELECT 'н1234567890';
   933  END
   934  OUTPUT
   935  select 1 from dual union select 'н1234567890' from dual
   936  END
   937  INPUT
   938  (SELECT * FROM t1 ORDER BY a DESC LIMIT 5) UNION (SELECT * FROM t2 ORDER BY a DESC LIMIT 4) ORDER BY a LIMIT 7;
   939  END
   940  OUTPUT
   941  (select * from t1 order by a desc limit 5) union (select * from t2 order by a desc limit 4) order by a asc limit 7
   942  END
   943  INPUT
   944  select st_contains(st_intersection(ST_GeomFromText('point(1 1)'), ST_GeomFromText('multipoint(2 2, 3 3)')),                     st_union(ST_GeomFromText('point(0 0)'), ST_GeomFromText('point(1 1)')));
   945  END
   946  OUTPUT
   947  select st_contains(st_intersection(ST_GeomFromText('point(1 1)'), ST_GeomFromText('multipoint(2 2, 3 3)')), st_union(ST_GeomFromText('point(0 0)'), ST_GeomFromText('point(1 1)'))) from dual
   948  END
   949  INPUT
   950  SELECT ST_AsText(ST_Union(ST_GEOMFROMTEXT(        'GEOMETRYCOLLECTION(LINESTRING(3 1, 6 1),                            LINESTRING(0 1, 4 1))'),                           ST_GEOMFROMTEXT('GEOMETRYCOLLECTION()'))) as result;
   951  END
   952  OUTPUT
   953  select ST_AsText(ST_Union(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(LINESTRING(3 1, 6 1),                            LINESTRING(0 1, 4 1))'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION()'))) as result from dual
   954  END
   955  INPUT
   956  select * from (select * from t1 union all select * from t1) a;
   957  END
   958  OUTPUT
   959  select * from (select * from t1 union all select * from t1) as a
   960  END
   961  INPUT
   962  SELECT sleep(0.5) FROM t17059925 UNION SELECT * FROM (SELECT * FROM t17059925 WHERE a= 10) t WHERE a = 10 UNION SELECT * from t2;
   963  END
   964  OUTPUT
   965  select sleep(0.5) from t17059925 union select * from (select * from t17059925 where a = 10) as t where a = 10 union select * from t2
   966  END
   967  INPUT
   968  (SELECT max(b), a FROM t1 GROUP BY a) UNION  (SELECT max(b), a FROM t1 GROUP BY a);
   969  END
   970  OUTPUT
   971  select max(b), a from t1 group by a union select max(b), a from t1 group by a
   972  END
   973  INPUT
   974  SELECT a FROM t1 UNION ALL (SELECT a FROM t1 ORDER BY COUNT(*) LIMIT 1 OFFSET 1);
   975  END
   976  OUTPUT
   977  select a from t1 union all (select a from t1 order by count(*) asc limit 1, 1)
   978  END
   979  INPUT
   980  (SELECT p1 FROM v2 LEFT JOIN v1 ON b = a WHERE p2 = 1 GROUP BY p1 ORDER BY p1) UNION (SELECT NULL LIMIT 0);
   981  END
   982  OUTPUT
   983  (select p1 from v2 left join v1 on b = a where p2 = 1 group by p1 order by p1 asc) union (select null from dual limit 0)
   984  END
   985  INPUT
   986  SELECT * FROM t17059925 WHERE a= 10 UNION SELECT sleep(0.5);
   987  END
   988  OUTPUT
   989  select * from t17059925 where a = 10 union select sleep(0.5) from dual
   990  END
   991  INPUT
   992  SELECT a, SUM(a), SUM(a)+1 FROM (SELECT 1 a UNION select 2) d   GROUP BY a;
   993  END
   994  OUTPUT
   995  select a, sum(a), sum(a) + 1 from (select 1 as a from dual union select 2 from dual) as d group by a
   996  END
   997  INPUT
   998  SELECT 2, 3 UNION SELECT 4, 5;
   999  END
  1000  OUTPUT
  1001  select 2, 3 from dual union select 4, 5 from dual
  1002  END
  1003  INPUT
  1004  SELECT 1 FOR SHARE UNION SELECT 2;
  1005  END
  1006  ERROR
  1007  syntax error at position 19 near 'SHARE'
  1008  END
  1009  INPUT
  1010  SELECT ST_AsText(ST_Union(shore, boundary))  FROM lakes, named_places  WHERE lakes.name = 'Blue Lake'  AND named_places.name = 'Goose Island';
  1011  END
  1012  OUTPUT
  1013  select ST_AsText(ST_Union(shore, boundary)) from lakes, named_places where lakes.`name` = 'Blue Lake' and named_places.`name` = 'Goose Island'
  1014  END
  1015  INPUT
  1016  (SELECT max(b), a FROM t1 GROUP BY a) UNION   (SELECT max(b), a FROM t1 GROUP BY a);
  1017  END
  1018  OUTPUT
  1019  select max(b), a from t1 group by a union select max(b), a from t1 group by a
  1020  END
  1021  INPUT
  1022  SELECT ST_AsText(ST_Union(ST_GeomFromText('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(polygon((0 0,10 0, 10 10, 0 10, 0 0)), MULTIPOINT(1 1, 2 2)))'),                        ST_GeomFromText('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(),GEOMETRYCOLLECTION())'))) as result;
  1023  END
  1024  OUTPUT
  1025  select ST_AsText(ST_Union(ST_GeomFromText('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(polygon((0 0,10 0, 10 10, 0 10, 0 0)), MULTIPOINT(1 1, 2 2)))'), ST_GeomFromText('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(),GEOMETRYCOLLECTION())'))) as result from dual
  1026  END
  1027  INPUT
  1028  (SELECT * FROM t1 ORDER BY a DESC LIMIT 5 OFFSET 4) UNION ALL SELECT * FROM t2 LIMIT 8 OFFSET 1;
  1029  END
  1030  OUTPUT
  1031  (select * from t1 order by a desc limit 4, 5) union all select * from t2 limit 1, 8
  1032  END
  1033  INPUT
  1034  SELECT ST_ISVALID(ST_UNION(ST_GEOMFROMTEXT('LINESTRING(12 6,9 4,-9 1,-4 -6,12 -9,-9 -17,17 -11,-16 17,19 -19,0 -16,6 -5,15 3,14 -5,18 13,-9 10,-11 8)'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(MULTILINESTRING((-18 2,1 7),(-19 -3,-16 -12),(10 0,3 8,12 19,8 -15)),MULTILINESTRING((8 16,-8 -3),(18 3,8 12),(-19 4,20 14)),POLYGON((2 3,-9 -7,12 -13,2 3)),MULTILINESTRING((16 -7,-2 2,11 -10,-1 8),(6 0,-15 0,16 0,-6 -14)))')));
  1035  END
  1036  OUTPUT
  1037  select ST_ISVALID(ST_UNION(ST_GEOMFROMTEXT('LINESTRING(12 6,9 4,-9 1,-4 -6,12 -9,-9 -17,17 -11,-16 17,19 -19,0 -16,6 -5,15 3,14 -5,18 13,-9 10,-11 8)'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(MULTILINESTRING((-18 2,1 7),(-19 -3,-16 -12),(10 0,3 8,12 19,8 -15)),MULTILINESTRING((8 16,-8 -3),(18 3,8 12),(-19 4,20 14)),POLYGON((2 3,-9 -7,12 -13,2 3)),MULTILINESTRING((16 -7,-2 2,11 -10,-1 8),(6 0,-15 0,16 0,-6 -14)))'))) from dual
  1038  END
  1039  INPUT
  1040  select s1 from t1 where s1 in (select version from information_schema.tables) union select version from information_schema.tables;
  1041  END
  1042  OUTPUT
  1043  select s1 from t1 where s1 in (select version from information_schema.`tables`) union select version from information_schema.`tables`
  1044  END
  1045  INPUT
  1046  SELECT /*+ MAX_EXECUTION_TIME(0) */ * FROM t1   WHERE a IN (SELECT a FROM t1 UNION SELECT /*+ MAX_EXECUTION_TIME(0) */ a FROM t1);
  1047  END
  1048  OUTPUT
  1049  select /*+ MAX_EXECUTION_TIME(0) */ * from t1 where a in (select a from t1 union select /*+ MAX_EXECUTION_TIME(0) */ a from t1)
  1050  END
  1051  INPUT
  1052  SELECT '2' as "my_col1",2 as "my_col2" UNION SELECT '1',1 from t2;
  1053  END
  1054  OUTPUT
  1055  select '2' as my_col1, 2 as my_col2 from dual union select '1', 1 from t2
  1056  END
  1057  INPUT
  1058  SELECT ST_AsText(ST_Union(ST_GeomFromText('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(MULTIPOINT(0 0,100 100), linestring(1 1, 2 2)))'),                        ST_GeomFromText('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(),GEOMETRYCOLLECTION())'))) as result;
  1059  END
  1060  OUTPUT
  1061  select ST_AsText(ST_Union(ST_GeomFromText('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(MULTIPOINT(0 0,100 100), linestring(1 1, 2 2)))'), ST_GeomFromText('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(),GEOMETRYCOLLECTION())'))) as result from dual
  1062  END
  1063  INPUT
  1064  SELECT 'case+union+test' UNION  SELECT CASE '1' WHEN '2' THEN 'BUG' ELSE 'nobug' END;
  1065  END
  1066  OUTPUT
  1067  select 'case+union+test' from dual union select case '1' when '2' then 'BUG' else 'nobug' end from dual
  1068  END
  1069  INPUT
  1070  SELECT ST_AsText(ST_Union(ST_GEOMFROMTEXT(        'GEOMETRYCOLLECTION(POLYGON((0 0, 3 0, 3 3, 0 3, 0 0)),                            LINESTRING(3 0, 3 1, 4 2))'),                           ST_GEOMFROMTEXT('GEOMETRYCOLLECTION()'))) as result;
  1071  END
  1072  OUTPUT
  1073  select ST_AsText(ST_Union(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POLYGON((0 0, 3 0, 3 3, 0 3, 0 0)),                            LINESTRING(3 0, 3 1, 4 2))'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION()'))) as result from dual
  1074  END
  1075  INPUT
  1076  SELECT 1 UNION SELECT 1 FOR UPDATE INTO @var;
  1077  END
  1078  ERROR
  1079  syntax error at position 45 near 'var'
  1080  END
  1081  INPUT
  1082  SELECT ST_ASTEXT(ST_VALIDATE(ST_UNION(ST_GEOMFROMTEXT('MULTIPOLYGON(((-7 -9,-3 7,0 -10,-6 5,10 10,-3 -4,7 9,2 -9)),((1 -10,-3 10,-2 5)))'),                                       ST_GEOMFROMTEXT('POLYGON((6 10,-7 10,-1 -6,0 5,5 4,1 -9,1 3,-10 -7,-10 8))')))) as result;
  1083  END
  1084  OUTPUT
  1085  select ST_ASTEXT(ST_VALIDATE(ST_UNION(ST_GEOMFROMTEXT('MULTIPOLYGON(((-7 -9,-3 7,0 -10,-6 5,10 10,-3 -4,7 9,2 -9)),((1 -10,-3 10,-2 5)))'), ST_GEOMFROMTEXT('POLYGON((6 10,-7 10,-1 -6,0 5,5 4,1 -9,1 3,-10 -7,-10 8))')))) as result from dual
  1086  END
  1087  INPUT
  1088  SELECT a, SUM(a), SUM(a)+1, CONCAT(SUM(a),'x'), SUM(a)+SUM(a), SUM(a)   FROM (SELECT 1 a, 2 b UNION SELECT 2,3 UNION SELECT 5,6 ) d       GROUP BY a WITH ROLLUP ORDER BY SUM(a);
  1089  END
  1090  ERROR
  1091  syntax error at position 154 near 'WITH'
  1092  END
  1093  INPUT
  1094  select 'a' union select concat('a', -0.0);
  1095  END
  1096  OUTPUT
  1097  select 'a' from dual union select concat('a', -0.0) from dual
  1098  END
  1099  INPUT
  1100  select st_within(st_union(ST_GeomFromText('point(1 1)'), ST_GeomFromText('multipoint(2 2, 3 3)')),                   st_intersection(ST_GeomFromText('point(0 0)'), ST_GeomFromText('point(1 1)')));
  1101  END
  1102  OUTPUT
  1103  select st_within(st_union(ST_GeomFromText('point(1 1)'), ST_GeomFromText('multipoint(2 2, 3 3)')), st_intersection(ST_GeomFromText('point(0 0)'), ST_GeomFromText('point(1 1)'))) from dual
  1104  END
  1105  INPUT
  1106  (SELECT a FROM t1 ORDER BY COUNT(*) LIMIT 1) UNION ALL (SELECT a FROM t1 ORDER BY COUNT(*) LIMIT 1 OFFSET 1);
  1107  END
  1108  OUTPUT
  1109  (select a from t1 order by count(*) asc limit 1) union all (select a from t1 order by count(*) asc limit 1, 1)
  1110  END
  1111  INPUT
  1112  select 'a' union select concat('a', -(4 + 1));
  1113  END
  1114  OUTPUT
  1115  select 'a' from dual union select concat('a', -(4 + 1)) from dual
  1116  END
  1117  INPUT
  1118  SELECT ST_AsText(ST_Union(ST_GeomFromText('MULTIPOINT(0 0,100 100)'),                        ST_GeomFromText('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(),GEOMETRYCOLLECTION())'))) as result;
  1119  END
  1120  OUTPUT
  1121  select ST_AsText(ST_Union(ST_GeomFromText('MULTIPOINT(0 0,100 100)'), ST_GeomFromText('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(),GEOMETRYCOLLECTION())'))) as result from dual
  1122  END
  1123  INPUT
  1124  SELECT * FROM t1 UNION ALL SELECT * FROM t2 ORDER BY a LIMIT 5;
  1125  END
  1126  OUTPUT
  1127  select * from t1 union all select * from t2 order by a asc limit 5
  1128  END
  1129  INPUT
  1130  SELECT * FROM (SELECT * FROM t17059925 WHERE a= 10) t WHERE a = 10 UNION SELECT sleep(0.5);
  1131  END
  1132  OUTPUT
  1133  select * from (select * from t17059925 where a = 10) as t where a = 10 union select sleep(0.5) from dual
  1134  END
  1135  INPUT
  1136  SELECT ST_ISVALID(ST_UNION(ST_GEOMFROMTEXT('POLYGON((4 5,12 11,-12 -3,4 5))'), ST_GEOMFROMTEXT('MULTIPOLYGON(((5 4,-14 0,1 0,5 4)),((1 6,13 0,10 12,1 6)))')));
  1137  END
  1138  OUTPUT
  1139  select ST_ISVALID(ST_UNION(ST_GEOMFROMTEXT('POLYGON((4 5,12 11,-12 -3,4 5))'), ST_GEOMFROMTEXT('MULTIPOLYGON(((5 4,-14 0,1 0,5 4)),((1 6,13 0,10 12,1 6)))'))) from dual
  1140  END
  1141  INPUT
  1142  select 1 as a from t1 union all select 1 from dual limit 1;
  1143  END
  1144  OUTPUT
  1145  select 1 as a from t1 union all select 1 from dual limit 1
  1146  END
  1147  INPUT
  1148  SELECT * FROM a LEFT JOIN vmerge AS v ON a.id = v.id UNION DISTINCT SELECT * FROM a LEFT JOIN vmerge AS v ON a.id = v.id;
  1149  END
  1150  OUTPUT
  1151  select * from a left join vmerge as v on a.id = v.id union select * from a left join vmerge as v on a.id = v.id
  1152  END
  1153  INPUT
  1154  (select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%H') As H) union (select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%H') As H);
  1155  END
  1156  OUTPUT
  1157  select time_format(timediff(now(), DATE_SUB(now(), interval 5 DAY)), '%H') as H from dual union select time_format(timediff(now(), DATE_SUB(now(), interval 5 DAY)), '%H') as H from dual
  1158  END
  1159  INPUT
  1160  select st_overlaps(st_union(ST_GeomFromText('point(1 1)'), ST_GeomFromText('multipoint(2 2, 3 3)')),                     st_intersection(ST_GeomFromText('point(0 0)'), ST_GeomFromText('point(1 1)')));
  1161  END
  1162  OUTPUT
  1163  select st_overlaps(st_union(ST_GeomFromText('point(1 1)'), ST_GeomFromText('multipoint(2 2, 3 3)')), st_intersection(ST_GeomFromText('point(0 0)'), ST_GeomFromText('point(1 1)'))) from dual
  1164  END
  1165  INPUT
  1166  SELECT ST_AsText(ST_Union(ST_GEOMFROMTEXT(        'GEOMETRYCOLLECTION(LINESTRING(3 1, 3 3),                            LINESTRING(0 1, 4 1))'),                           ST_GEOMFROMTEXT('GEOMETRYCOLLECTION()'))) as result;
  1167  END
  1168  OUTPUT
  1169  select ST_AsText(ST_Union(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(LINESTRING(3 1, 3 3),                            LINESTRING(0 1, 4 1))'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION()'))) as result from dual
  1170  END
  1171  INPUT
  1172  SELECT * FROM t1 UNION ALL SELECT * FROM t2 LIMIT 5;
  1173  END
  1174  OUTPUT
  1175  select * from t1 union all select * from t2 limit 5
  1176  END
  1177  INPUT
  1178  SELECT * FROM t17059925 WHERE a= 10 AND a= 20 UNION SELECT sleep(0.5);
  1179  END
  1180  OUTPUT
  1181  select * from t17059925 where a = 10 and a = 20 union select sleep(0.5) from dual
  1182  END
  1183  INPUT
  1184  SELECT TIME_FORMAT(SEC_TO_TIME(a),"%H:%i:%s") FROM (SELECT 3020399 AS a UNION SELECT 3020398 ) x GROUP BY 1;
  1185  END
  1186  OUTPUT
  1187  select TIME_FORMAT(SEC_TO_TIME(a), '%H:%i:%s') from (select 3020399 as a from dual union select 3020398 from dual) as x group by 1
  1188  END
  1189  INPUT
  1190  (SELECT * FROM t1 ORDER BY a DESC LIMIT 5 OFFSET 4) UNION SELECT * FROM t2 LIMIT 8 OFFSET 1;
  1191  END
  1192  OUTPUT
  1193  (select * from t1 order by a desc limit 4, 5) union select * from t2 limit 1, 8
  1194  END
  1195  INPUT
  1196  SELECT ST_ASTEXT(ST_UNION(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION())'),                           ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(1 1), GEOMETRYCOLLECTION(GEOMETRYCOLLECTION())))'))) as geom;
  1197  END
  1198  OUTPUT
  1199  select ST_ASTEXT(ST_UNION(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION())'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(1 1), GEOMETRYCOLLECTION(GEOMETRYCOLLECTION())))'))) as geom from dual
  1200  END
  1201  INPUT
  1202  select 'a' union select concat('a', -4.5);
  1203  END
  1204  OUTPUT
  1205  select 'a' from dual union select concat('a', -4.5) from dual
  1206  END
  1207  INPUT
  1208  (SELECT a FROM t1 ORDER BY COUNT(*)) UNION ALL (SELECT a FROM t1 ORDER BY COUNT(*));
  1209  END
  1210  OUTPUT
  1211  (select a from t1 order by count(*) asc) union all (select a from t1 order by count(*) asc)
  1212  END
  1213  INPUT
  1214  select 1 as a union all select 1 union all select 2 union select 1 union all select 2;
  1215  END
  1216  OUTPUT
  1217  select 1 as a from dual union all select 1 from dual union all select 2 from dual union select 1 from dual union all select 2 from dual
  1218  END
  1219  INPUT
  1220  select (ST_aswkb(cast(st_union(multipoint(                                        point(8,6), point(1,-17679),                                        point(-9,-9)),                             linestring(point(91,12), point(-77,49),                                        point(53,-81)))as char(18)))) in  ('1','2');
  1221  END
  1222  OUTPUT
  1223  select ST_aswkb(cast(st_union(multipoint(point(8, 6), point(1, -17679), point(-9, -9)), linestring(point(91, 12), point(-77, 49), point(53, -81))) as char(18))) in ('1', '2') from dual
  1224  END
  1225  INPUT
  1226  select st_astext(st_union(cast(point(1,1)as char(15)),point(1,1))) as res;
  1227  END
  1228  OUTPUT
  1229  select st_astext(st_union(cast(point(1, 1) as char(15)), point(1, 1))) as res from dual
  1230  END
  1231  INPUT
  1232  select st_crosses(st_intersection(ST_GeomFromText('point(1 1)'), ST_GeomFromText('multipoint(2 2, 3 3)')),                    st_union(ST_GeomFromText('point(0 0)'), ST_GeomFromText('point(1 1)')));
  1233  END
  1234  OUTPUT
  1235  select st_crosses(st_intersection(ST_GeomFromText('point(1 1)'), ST_GeomFromText('multipoint(2 2, 3 3)')), st_union(ST_GeomFromText('point(0 0)'), ST_GeomFromText('point(1 1)'))) from dual
  1236  END
  1237  INPUT
  1238  select ST_ASTEXT(ST_UNION(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(MULTILINESTRING((0 -14,13 -8),(-5 -3,8 7),(-6 18,17 -11,-12 19,19 5),(16 11,9 -5),(17 -5,5 10),(-4 17,6 4),(-12 15,17 13,-18 11,15 10),(7 0,2 -16,-18 13,-6 4),(-17 -6,-6 -7,1 4,-18 0)),MULTIPOINT(0 14,-9 -11),MULTILINESTRING((-11 -2,17 -14),(18 -12,18 -8),(-13 -16,9 16,9 -10,-7 20),(-14 -5,10 -9,4 1,17 -8),(-9 -4,-2 -12,9 -13,-5 4),(15 17,13 20)),MULTIPOINT(16 1,-9 -17,-16 6,-17 3),POINT(-18 13))'),                           ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POINT(7 0),MULTILINESTRING((-13 -18,-16 0),(17 11,-1 11,-18 -19,-4 -18),(-8 -8,-15 -13,3 -18,6 8)),LINESTRING(5 16,0 -9,-6 4,-15 17),MULTIPOINT(-9 -5,5 15,12 -11,12 11))'))) as result;
  1239  END
  1240  OUTPUT
  1241  select ST_ASTEXT(ST_UNION(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(MULTILINESTRING((0 -14,13 -8),(-5 -3,8 7),(-6 18,17 -11,-12 19,19 5),(16 11,9 -5),(17 -5,5 10),(-4 17,6 4),(-12 15,17 13,-18 11,15 10),(7 0,2 -16,-18 13,-6 4),(-17 -6,-6 -7,1 4,-18 0)),MULTIPOINT(0 14,-9 -11),MULTILINESTRING((-11 -2,17 -14),(18 -12,18 -8),(-13 -16,9 16,9 -10,-7 20),(-14 -5,10 -9,4 1,17 -8),(-9 -4,-2 -12,9 -13,-5 4),(15 17,13 20)),MULTIPOINT(16 1,-9 -17,-16 6,-17 3),POINT(-18 13))'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POINT(7 0),MULTILINESTRING((-13 -18,-16 0),(17 11,-1 11,-18 -19,-4 -18),(-8 -8,-15 -13,3 -18,6 8)),LINESTRING(5 16,0 -9,-6 4,-15 17),MULTIPOINT(-9 -5,5 15,12 -11,12 11))'))) as result from dual
  1242  END
  1243  INPUT
  1244  SELECT * FROM t1 UNION SELECT * FROM t2 LIMIT 5 OFFSET 6;
  1245  END
  1246  OUTPUT
  1247  select * from t1 union select * from t2 limit 6, 5
  1248  END
  1249  INPUT
  1250  SELECT 1 FROM   t1 AS alias1   JOIN t2 AS alias2 ON alias1.col_int = alias2.col_int   JOIN t1 AS alias3 ON 1   WHERE     ( SELECT 1 UNION SELECT MAX(alias1.pk) ) = alias3.pk;
  1251  END
  1252  OUTPUT
  1253  select 1 from t1 as alias1 join t2 as alias2 on alias1.col_int = alias2.col_int join t1 as alias3 on 1 where (select 1 from dual union select max(alias1.pk) from dual) = alias3.pk
  1254  END
  1255  INPUT
  1256  select   (with recursive dt as     (select t1.a as a union all select a+1 from dt where a<10)    select concat(count(*), ' - ', avg(dt.a)) from dt   ) as subq from t1;
  1257  END
  1258  OUTPUT
  1259  select (with recursive dt as (select t1.a as a from dual union all select a + 1 from dt where a < 10) select concat(count(*), ' - ', avg(dt.a)) from dt) as subq from t1
  1260  END
  1261  INPUT
  1262  select a.text, b.id, b.betreff from    t2 a inner join t3 b on a.id = b.forum inner join   t1 c on b.id = c.thread where    match(b.betreff) against ('+abc' in boolean mode) union select a.text, b.id, b.betreff from    t2 a inner join t3 b on a.id = b.forum inner join   t1 c on b.id = c.thread where    match(c.beitrag) against ('+abc' in boolean mode) order by    match(b.betreff) against ('+abc' in boolean mode) desc;
  1263  END
  1264  OUTPUT
  1265  select a.`text`, b.id, b.betreff from t2 as a join t3 as b on a.id = b.forum join t1 as c on b.id = c.thread where match(b.betreff) against ('+abc' in boolean mode) union select a.`text`, b.id, b.betreff from t2 as a join t3 as b on a.id = b.forum join t1 as c on b.id = c.thread where match(c.beitrag) against ('+abc' in boolean mode) order by match(b.betreff) against ('+abc' in boolean mode) desc
  1266  END
  1267  INPUT
  1268  SELECT ST_AsText(ST_Union(ST_GEOMFROMTEXT(        'GEOMETRYCOLLECTION(POLYGON((5 0,0 10,10 10,5 0)),                            POLYGON((5 0,0 -10,10 -10,5 0)))'),                           ST_GEOMFROMTEXT('GEOMETRYCOLLECTION()'))) as result;
  1269  END
  1270  OUTPUT
  1271  select ST_AsText(ST_Union(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POLYGON((5 0,0 10,10 10,5 0)),                            POLYGON((5 0,0 -10,10 -10,5 0)))'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION()'))) as result from dual
  1272  END
  1273  INPUT
  1274  SELECT a DIV 2 FROM t1 UNION SELECT a DIV 2 FROM t1;
  1275  END
  1276  OUTPUT
  1277  select a div 2 from t1 union select a div 2 from t1
  1278  END
  1279  INPUT
  1280  SELECT a FROM t1 UNION ALL (SELECT a FROM t1 ORDER BY COUNT(*));
  1281  END
  1282  OUTPUT
  1283  select a from t1 union all (select a from t1 order by count(*) asc)
  1284  END
  1285  INPUT
  1286  SELECT ST_ASTEXT(ST_UNION(ST_GEOMFROMTEXT('MULTIPOLYGON(((-7 -9,-3 7,0 -10,-6 5,10 10,-3 -4,7 9,2 -9)),((1 -10,-3 10,-2 5)))'),                           ST_GEOMFROMTEXT('POLYGON((6 10,-7 10,-1 -6,0 5,5 4,1 -9,1 3,-10 -7,-10 8))'))) as result;
  1287  END
  1288  OUTPUT
  1289  select ST_ASTEXT(ST_UNION(ST_GEOMFROMTEXT('MULTIPOLYGON(((-7 -9,-3 7,0 -10,-6 5,10 10,-3 -4,7 9,2 -9)),((1 -10,-3 10,-2 5)))'), ST_GEOMFROMTEXT('POLYGON((6 10,-7 10,-1 -6,0 5,5 4,1 -9,1 3,-10 -7,-10 8))'))) as result from dual
  1290  END
  1291  INPUT
  1292  (SELECT * FROM t1 LIMIT 5) UNION ALL (SELECT * FROM t2 LIMIT 4) ORDER BY a LIMIT 7;
  1293  END
  1294  OUTPUT
  1295  (select * from t1 limit 5) union all (select * from t2 limit 4) order by a asc limit 7
  1296  END
  1297  INPUT
  1298  SELECT sleep(0.5) FROM t17059925 UNION SELECT 1 FROM dual WHERE 1= 0 UNION SELECT * FROM t2;
  1299  END
  1300  OUTPUT
  1301  select sleep(0.5) from t17059925 union select 1 from dual where 1 = 0 union select * from t2
  1302  END
  1303  INPUT
  1304  SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a, b, c;
  1305  END
  1306  OUTPUT
  1307  select * from t1 union select * from t2 order by a asc, b asc, c asc
  1308  END
  1309  INPUT
  1310  select repeat(_utf8mb4'+',3) as h union select NULL;
  1311  END
  1312  OUTPUT
  1313  select repeat(_utf8mb4 '+', 3) as h from dual union select null from dual
  1314  END
  1315  INPUT
  1316  select * from (select * from t1 union distinct select * from t2 union all select * from t3) X;
  1317  END
  1318  OUTPUT
  1319  select * from (select * from t1 union select * from t2 union all select * from t3) as X
  1320  END
  1321  INPUT
  1322  SELECT sleep(0.5) from t17059925 UNION SELECT t17059925_func1(1);
  1323  END
  1324  OUTPUT
  1325  select sleep(0.5) from t17059925 union select t17059925_func1(1) from dual
  1326  END
  1327  INPUT
  1328  select a.text, b.id, b.betreff from    t2 a inner join t3 b on a.id = b.forum inner join   t1 c on b.id = c.thread where    match(b.betreff) against ('+abc' in boolean mode) union select a.text, b.id, b.betreff from    t2 a inner join t3 b on a.id = b.forum inner join   t1 c on b.id = c.thread where    match(c.beitrag) against ('+abc' in boolean mode) order by    match(betreff) against ('+abc' in boolean mode) desc;
  1329  END
  1330  OUTPUT
  1331  select a.`text`, b.id, b.betreff from t2 as a join t3 as b on a.id = b.forum join t1 as c on b.id = c.thread where match(b.betreff) against ('+abc' in boolean mode) union select a.`text`, b.id, b.betreff from t2 as a join t3 as b on a.id = b.forum join t1 as c on b.id = c.thread where match(c.beitrag) against ('+abc' in boolean mode) order by match(betreff) against ('+abc' in boolean mode) desc
  1332  END
  1333  INPUT
  1334  (SELECT * FROM t1 ORDER BY a DESC LIMIT 5) UNION SELECT * FROM t2 LIMIT 8;
  1335  END
  1336  OUTPUT
  1337  (select * from t1 order by a desc limit 5) union select * from t2 limit 8
  1338  END
  1339  INPUT
  1340  SELECT ST_AsText(ST_Union(ST_GeomFromText('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(polygon((0 0,10 0, 10 10, 0 10, 0 0)), polygon((0 0, 1 0, 1 1, 0 1, 0 0))))'),                        ST_GeomFromText('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(),GEOMETRYCOLLECTION())'))) as result;
  1341  END
  1342  OUTPUT
  1343  select ST_AsText(ST_Union(ST_GeomFromText('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(polygon((0 0,10 0, 10 10, 0 10, 0 0)), polygon((0 0, 1 0, 1 1, 0 1, 0 0))))'), ST_GeomFromText('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(),GEOMETRYCOLLECTION())'))) as result from dual
  1344  END
  1345  INPUT
  1346  select st_astext(st_union(ST_GeometryFromText('geometrycollection(polygon((0 0, 1 0, 1 1, 0 1, 0 0)))'), ST_GeometryFromText('geometrycollection(polygon((1 0, 2 0, 2 1, 1 1, 1 0)))')));
  1347  END
  1348  OUTPUT
  1349  select st_astext(st_union(ST_GeometryFromText('geometrycollection(polygon((0 0, 1 0, 1 1, 0 1, 0 0)))'), ST_GeometryFromText('geometrycollection(polygon((1 0, 2 0, 2 1, 1 1, 1 0)))'))) from dual
  1350  END
  1351  INPUT
  1352  select st_within(st_intersection(ST_GeomFromText('point(1 1)'), ST_GeomFromText('multipoint(2 2, 3 3)')),                   st_union(ST_GeomFromText('point(0 0)'), ST_GeomFromText('point(1 1)')));
  1353  END
  1354  OUTPUT
  1355  select st_within(st_intersection(ST_GeomFromText('point(1 1)'), ST_GeomFromText('multipoint(2 2, 3 3)')), st_union(ST_GeomFromText('point(0 0)'), ST_GeomFromText('point(1 1)'))) from dual
  1356  END
  1357  INPUT
  1358  SELECT ST_AsText(ST_Union(ST_GEOMFROMTEXT(        'GEOMETRYCOLLECTION(LINESTRING(3 0, 3 3),                            LINESTRING(0 1, 4 1))'),                           ST_GEOMFROMTEXT('GEOMETRYCOLLECTION()'))) as result;
  1359  END
  1360  OUTPUT
  1361  select ST_AsText(ST_Union(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(LINESTRING(3 0, 3 3),                            LINESTRING(0 1, 4 1))'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION()'))) as result from dual
  1362  END
  1363  INPUT
  1364  (SELECT * FROM t1 ORDER BY a DESC LIMIT 5 OFFSET 4) UNION SELECT * FROM t2 ORDER BY a LIMIT 8 OFFSET 1;
  1365  END
  1366  OUTPUT
  1367  (select * from t1 order by a desc limit 4, 5) union select * from t2 order by a asc limit 1, 8
  1368  END
  1369  INPUT
  1370  SELECT * FROM t1 UNION SELECT * FROM t2 LIMIT 5;
  1371  END
  1372  OUTPUT
  1373  select * from t1 union select * from t2 limit 5
  1374  END
  1375  INPUT
  1376  SELECT ST_Union('', ''), md5(1);
  1377  END
  1378  OUTPUT
  1379  select ST_Union('', ''), md5(1) from dual
  1380  END
  1381  INPUT
  1382  select st_union((cast(linestring(point(6,-68), point(-22,-4)) as binary(13))),                 st_intersection(point(6,8),multipoint(point(3,1),point(-4,-6),point(1,6),point(-3,-5),point(5,4))));
  1383  END
  1384  OUTPUT
  1385  select st_union(cast(linestring(point(6, -68), point(-22, -4)) as binary(13)), st_intersection(point(6, 8), multipoint(point(3, 1), point(-4, -6), point(1, 6), point(-3, -5), point(5, 4)))) from dual
  1386  END
  1387  INPUT
  1388  SELECT ST_ISVALID(ST_UNION(ST_GEOMFROMTEXT('POLYGON((0 0,10 10,20 0,0 0))'), ST_GEOMFROMTEXT('POLYGON((10 5,20 7,10 10,30 10,20 0,20 5,10 5))')));
  1389  END
  1390  OUTPUT
  1391  select ST_ISVALID(ST_UNION(ST_GEOMFROMTEXT('POLYGON((0 0,10 10,20 0,0 0))'), ST_GEOMFROMTEXT('POLYGON((10 5,20 7,10 10,30 10,20 0,20 5,10 5))'))) from dual
  1392  END
  1393  INPUT
  1394  select * from t1 union select * from t2 order by 1, 2;
  1395  END
  1396  OUTPUT
  1397  select * from t1 union select * from t2 order by 1 asc, 2 asc
  1398  END
  1399  INPUT
  1400  (SELECT * FROM t1 ORDER BY a DESC LIMIT 5 OFFSET 4) UNION ALL SELECT * FROM t2 ORDER BY a LIMIT 8 OFFSET 1;
  1401  END
  1402  OUTPUT
  1403  (select * from t1 order by a desc limit 4, 5) union all select * from t2 order by a asc limit 1, 8
  1404  END
  1405  INPUT
  1406  SELECT '1' as "my_col1",2 as "my_col2" UNION SELECT '2',1;
  1407  END
  1408  OUTPUT
  1409  select '1' as my_col1, 2 as my_col2 from dual union select '2', 1 from dual
  1410  END
  1411  INPUT
  1412  SELECT @a:= CAST(f1 AS SIGNED) FROM t1 UNION ALL SELECT CAST(f1 AS SIGNED) FROM t1;
  1413  END
  1414  ERROR
  1415  syntax error at position 11 near ':'
  1416  END
  1417  INPUT
  1418  (SELECT a FROM t1 ORDER BY COUNT(*)) UNION (SELECT a FROM t1 ORDER BY COUNT(*));
  1419  END
  1420  OUTPUT
  1421  (select a from t1 order by count(*) asc) union (select a from t1 order by count(*) asc)
  1422  END
  1423  INPUT
  1424  SELECT GROUP_CONCAT(t.c) as c FROM t1 t UNION SELECT '' as c;
  1425  END
  1426  OUTPUT
  1427  select group_concat(t.c) as c from t1 as t union select '' as c from dual
  1428  END
  1429  INPUT
  1430  SELECT * FROM t1   WHERE a IN (SELECT a FROM t1 UNION SELECT /*+ MAX_EXECUTION_TIME(0) */ a FROM t1);
  1431  END
  1432  OUTPUT
  1433  select * from t1 where a in (select a from t1 union select /*+ MAX_EXECUTION_TIME(0) */ a from t1)
  1434  END
  1435  INPUT
  1436  select * from t1 union distinct select * from t2;
  1437  END
  1438  OUTPUT
  1439  select * from t1 union select * from t2
  1440  END
  1441  INPUT
  1442  SELECT * FROM (SELECT 1 UNION SELECT a) b;
  1443  END
  1444  OUTPUT
  1445  select * from (select 1 from dual union select a from dual) as b
  1446  END
  1447  INPUT
  1448  SELECT a, SUM(a), SUM(a)+1 FROM (SELECT a FROM t1 UNION select 2) d   GROUP BY a;
  1449  END
  1450  OUTPUT
  1451  select a, sum(a), sum(a) + 1 from (select a from t1 union select 2 from dual) as d group by a
  1452  END