From 145af63cb44932585f73172c68d0f28fb3dc26a0 Mon Sep 17 00:00:00 2001 From: ritwizsinha Date: Sun, 12 Sep 2021 23:58:00 +0530 Subject: [PATCH] Added union test cases from SQL SERVER Signed-off-by: ritwizsinha --- go/vt/sqlparser/parse_test.go | 40 +- go/vt/sqlparser/testdata/union_cases.txt | 1456 +++++++++++++++++++++- 2 files changed, 1470 insertions(+), 26 deletions(-) diff --git a/go/vt/sqlparser/parse_test.go b/go/vt/sqlparser/parse_test.go index a77df606902..d4637fed353 100644 --- a/go/vt/sqlparser/parse_test.go +++ b/go/vt/sqlparser/parse_test.go @@ -3523,26 +3523,27 @@ func testFile(t *testing.T, filename, tempDir string) { fail := false expected := strings.Builder{} for tcase := range iterateExecFile(filename) { + fmt.Println(tcase) t.Run(fmt.Sprintf("%d : %s", tcase.lineno, tcase.comments), func(t *testing.T) { if tcase.output == "" && tcase.errStr == "" { tcase.output = tcase.input } - expected.WriteString(fmt.Sprintf("%sINPUT\n%sEND\n", tcase.comments, escapeNewLines(tcase.input))) + expected.WriteString(fmt.Sprintf("%sINPUT\n%s\nEND\n", tcase.comments, escapeNewLines(tcase.input))) tree, err := Parse(tcase.input) if tcase.errStr != "" { - expected.WriteString(fmt.Sprintf("ERROR\n%sEND\n", escapeNewLines(err.Error()))) + expected.WriteString(fmt.Sprintf("ERROR\n%s\nEND\n", escapeNewLines(err.Error()))) if err == nil || tcase.errStr != err.Error() { fail = true t.Errorf("File: %s, Line: %d\nDiff:\n%s\n[%s] \n[%s]", filename, tcase.lineno, cmp.Diff(tcase.errStr, err.Error()), tcase.errStr, err.Error()) } } else { if err != nil { - expected.WriteString(fmt.Sprintf("ERROR\n%sEND\n", escapeNewLines(err.Error()))) + expected.WriteString(fmt.Sprintf("ERROR\n%s\nEND\n", escapeNewLines(err.Error()))) fail = true t.Errorf("File: %s, Line: %d\nDiff:\n%s\n[%s] \n[%s]", filename, tcase.lineno, cmp.Diff(tcase.errStr, err.Error()), tcase.errStr, err.Error()) } else { out := String(tree) - expected.WriteString(fmt.Sprintf("OUTPUT\n%sEND\n", escapeNewLines(out))) + expected.WriteString(fmt.Sprintf("OUTPUT\n%s\nEND\n", escapeNewLines(out))) if tcase.output != out { fail = true t.Errorf("Parsing failed. \nExpected/Got:\n%s\n%s", tcase.output, out) @@ -3566,6 +3567,7 @@ func iterateExecFile(name string) (testCaseIterator chan testCase) { if err != nil { panic(fmt.Sprintf("Could not open file %s", name)) } + testCaseIterator = make(chan testCase) var comments string go func() { @@ -3573,25 +3575,12 @@ func iterateExecFile(name string) (testCaseIterator chan testCase) { r := bufio.NewReader(fd) lineno := 0 - for { - binput, err := r.ReadBytes('\n') - if err != nil { - if err != io.EOF { - panic(fmt.Errorf("error reading file %s: line %d: %s", name, lineno, err.Error())) - } + for { + input, lineno, _ := parsePartial(r, []string{"INPUT"}, lineno, name) + if input == "" && lineno == 0 { break } - lineno++ - input := string(binput) - if input == "" || input == "\n" { - continue - } - if input[0] == '#' { - comments = comments + input - continue - } - input, lineno, _ = parsePartial(r, []string{"INPUT"}, lineno, name) - output, lineno, returnTypeNumber := parsePartial(r, []string{"OUTPUT, ERROR"}, lineno, name) + output, lineno, returnTypeNumber := parsePartial(r, []string{"OUTPUT", "ERROR"}, lineno, name) var errStr string if returnTypeNumber == 1 { errStr = output @@ -3613,27 +3602,30 @@ func iterateExecFile(name string) (testCaseIterator chan testCase) { } func parsePartial(r *bufio.Reader, readType []string, lineno int, fileName string) (string, int, int) { - var returnTypeNumber int + returnTypeNumber := -1 for { binput, err := r.ReadBytes('\n') if err != nil { if err != io.EOF { panic(fmt.Errorf("error reading file %s: line %d: %s", fileName, lineno, err.Error())) } - break + return "", 0, 0 } lineno++ input := string(binput) + input = strings.TrimSpace(input) if input == "" || input == "\n" { continue } - input = strings.TrimSpace(input) for i, str := range readType { if input == str { returnTypeNumber = i break } } + if returnTypeNumber != -1 { + break + } panic(fmt.Errorf("error reading file %s: line %d: %s - Expected keyword", fileName, lineno, err.Error())) } input := "" diff --git a/go/vt/sqlparser/testdata/union_cases.txt b/go/vt/sqlparser/testdata/union_cases.txt index 58222fde730..b288e09b393 100644 --- a/go/vt/sqlparser/testdata/union_cases.txt +++ b/go/vt/sqlparser/testdata/union_cases.txt @@ -1,6 +1,1458 @@ INPUT -select 1 from dual union select 2 from dual +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; END OUTPUT -select 1 from dual union select 2 from dual +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 +END +INPUT +SELECT i FROM t2 UNION SELECT c FROM t1; +END +OUTPUT +(select i from t2) union (select c from t1) +END +INPUT +select @arg00 FROM t1 where a=1 union distinct select 1 FROM t1 where a=1; +END +OUTPUT +(select @arg00 from t1 where a = 1) union (select 1 from t1 where a = 1) +END +INPUT +SELECT '1' UNION SELECT 'н1234567890'; +END +OUTPUT +(select '1' from dual) union (select 'н1234567890' from dual) +END +INPUT +select * from (select * from t1 union select * from t1) a; +END +OUTPUT +select * from ((select * from t1) union (select * from t1)) as a +END +INPUT +select concat(f1, 2) a from t1 union select 'x' a from t1; +END +OUTPUT +(select concat(f1, 2) as a from t1) union (select 'x' as a from t1) +END +INPUT +SELECT b FROM t2 UNION SELECT c FROM t1; +END +OUTPUT +(select b from t2) union (select c from t1) +END +INPUT +(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; +END +OUTPUT +(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 +END +INPUT +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; +END +OUTPUT +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 +END +INPUT +select ST_astext(st_union( st_intersection( multipoint(point(-1,-1)), point(1,-1) ), st_difference( multipoint(point(-1,1)), point(-1,-1) ))); +END +OUTPUT +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 +END +INPUT +(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); +END +OUTPUT +(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) +END +INPUT +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)')))); +END +OUTPUT +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 +END +INPUT +SELECT sleep(0.5) FROM t17059925 UNION ALL SELECT * FROM t17059925 WHERE a= 10 AND a= 20 UNION ALL SELECT * FROM t2; +END +OUTPUT +(select sleep(0.5) from t17059925) union all (select * from t17059925 where a = 10 and a = 20) union all (select * from t2) +END +INPUT +(SELECT * FROM t1 LIMIT 5) UNION SELECT * FROM t2 ORDER BY a LIMIT 8; +END +OUTPUT +(select * from t1 limit 5) union (select * from t2) order by a asc limit 8 +END +INPUT +select * from t1 where MATCH(a,b) AGAINST ("collections") UNION ALL select * from t1 where MATCH(a,b) AGAINST ("indexes"); +END +OUTPUT +(select * from t1 where match(a, b) against ('collections')) union all (select * from t1 where match(a, b) against ('indexes')) +END +INPUT +SELECT 1 as a FROM (SELECT a UNION SELECT 1) b; +END +OUTPUT +select 1 as a from ((select a from dual) union (select 1 from dual)) as b +END +INPUT +(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); +END +OUTPUT +(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) +END +INPUT +SELECT * FROM (SELECT t17059925_func1(1)) t WHERE 1= 0 UNION SELECT sleep(0.5); +END +OUTPUT +(select * from (select t17059925_func1(1) from dual) as t where 1 = 0) union (select sleep(0.5) from dual) +END +INPUT +SELECT '00' UNION SELECT '10' INTO OUTFILE 'tmpp2.txt' CHARACTER SET ucs2; +END +ERROR +syntax error at position 35 near 'INTO' +END +INPUT +SELECT a, SUM(a), SUM(a)+1 FROM (SELECT a FROM t1 UNION select 2) d GROUP BY a WITH ROLLUP; +END +ERROR +syntax error at position 86 near 'WITH' +END +INPUT +SELECT * FROM t1 UNION ALL SELECT * FROM t2 ORDER BY a LIMIT 5 OFFSET 6; +END +OUTPUT +(select * from t1) union all (select * from t2) order by a asc limit 6, 5 +END +INPUT +(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; +END +OUTPUT +(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 +END +INPUT +SELECT 'н1234567890' UNION SELECT _binary '1'; +END +OUTPUT +(select 'н1234567890' from dual) union (select _binary '1' from dual) +END +INPUT +select ST_AsText(a) from (select f2 as a from t1 union select f3 from t1) t; +END +OUTPUT +select ST_AsText(a) from ((select f2 as a from t1) union (select f3 from t1)) as t +END +INPUT +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)'))); +END +OUTPUT +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 +END +INPUT +(SELECT * FROM t1 LIMIT 5) UNION ALL (SELECT * FROM t2 LIMIT 4) LIMIT 7; +END +OUTPUT +(select * from t1 limit 5) union all (select * from t2 limit 4) limit 7 +END +INPUT +(SELECT * FROM t1 LIMIT 5 OFFSET 4) UNION (SELECT * FROM t2 LIMIT 4 OFFSET 2) LIMIT 7 OFFSET 1; +END +OUTPUT +(select * from t1 limit 4, 5) union (select * from t2 limit 2, 4) limit 1, 7 +END +INPUT +SELECT sleep(0.5) FROM t17059925 UNION ALL SELECT * FROM t2 UNION ALL SELECT * FROM t3; +END +OUTPUT +(select sleep(0.5) from t17059925) union all (select * from t2) union all (select * from t3) +END +INPUT +SELECT sleep(0.5) FROM t17059925 UNION SELECT * FROM t2 UNION SELECT * FROM t3; +END +OUTPUT +(select sleep(0.5) from t17059925) union (select * from t2) union (select * from t3) +END +INPUT +select "xyz" as name union select "abc" as name order by name desc; +END +OUTPUT +(select 'xyz' as `name` from dual) union (select 'abc' as `name` from dual) order by `name` desc +END +INPUT +(SELECT * FROM t1 LIMIT 5 OFFSET 4) UNION ALL SELECT * FROM t2 ORDER BY a LIMIT 8 OFFSET 1; +END +OUTPUT +(select * from t1 limit 4, 5) union all (select * from t2) order by a asc limit 1, 8 +END +INPUT +select 'a' union select concat('a', -0.0000); +END +OUTPUT +(select 'a' from dual) union (select concat('a', -0.0000) from dual) +END +INPUT +select * from ( select * from t1 union select * from t1) a,(select * from t1 union select * from t1) b; +END +OUTPUT +select * from ((select * from t1) union (select * from t1)) as a, ((select * from t1) union (select * from t1)) as b +END +INPUT +SELECT DISTINCT GREATEST(a, (SELECT b FROM t1 LIMIT 1)) FROM t1 UNION SELECT 1; +END +OUTPUT +(select distinct GREATEST(a, (select b from t1 limit 1)) from t1) union (select 1 from dual) +END +INPUT +SELECT DISTINCT LEAST(a, (SELECT b FROM t1 LIMIT 1)) FROM t1 UNION SELECT 1; +END +OUTPUT +(select distinct LEAST(a, (select b from t1 limit 1)) from t1) union (select 1 from dual) +END +INPUT +(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); +END +OUTPUT +(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) +END +INPUT +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; +END +OUTPUT +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 +END +INPUT +select 'a' union select concat('a', 4 - 5); +END +OUTPUT +(select 'a' from dual) union (select concat('a', 4 - 5) from dual) +END +INPUT +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)'))); +END +OUTPUT +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 +END +INPUT +SELECT 1 UNION SELECT 1 INTO @var FOR UPDATE; +END +ERROR +syntax error at position 29 near 'INTO' +END +INPUT +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)'))); +END +OUTPUT +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 +END +INPUT +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)'))); +END +OUTPUT +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 +END +INPUT +SELECT NULL as "my_col1",2 AS "my_col2" UNION SELECT NULL,1; +END +OUTPUT +(select null as my_col1, 2 as my_col2 from dual) union (select null, 1 from dual) +END +INPUT +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)'))); +END +OUTPUT +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 +END +INPUT +SELECT ST_AsText(ST_Union(ST_GEOMFROMTEXT( 'GEOMETRYCOLLECTION(LINESTRING(4 1, 6 1), LINESTRING(0 1, 4 1))'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION()'))) as result; +END +OUTPUT +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 +END +INPUT +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)))'))); +END +OUTPUT +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 +END +INPUT +(SELECT * FROM t1 LIMIT 5 OFFSET 4) UNION (SELECT * FROM t2 LIMIT 4 OFFSET 2) ORDER BY a LIMIT 7 OFFSET 1; +END +OUTPUT +(select * from t1 limit 4, 5) union (select * from t2 limit 2, 4) order by a asc limit 1, 7 +END +INPUT +(SELECT * FROM t1 LIMIT 5 OFFSET 4) UNION SELECT * FROM t2 LIMIT 8 OFFSET 1; +END +OUTPUT +(select * from t1 limit 4, 5) union (select * from t2) limit 1, 8 +END +INPUT +SELECT "Xyz" AS Name UNION SELECT "Abc" as Name ORDER BY Name DESC; +END +OUTPUT +(select 'Xyz' as `Name` from dual) union (select 'Abc' as `Name` from dual) order by `Name` desc +END +INPUT +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5) UNION (SELECT * FROM t2 ORDER BY a DESC LIMIT 4) LIMIT 7; +END +OUTPUT +(select * from t1 order by a desc limit 5) union (select * from t2 order by a desc limit 4) limit 7 +END +INPUT +select * from t1 union distinct select * from t2 union all select * from t3; +END +OUTPUT +(select * from t1) union (select * from t2) union all (select * from t3) +END +INPUT +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; +END +OUTPUT +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 +END +INPUT +select * from (select * from t1 union all select * from t1 limit 2) a; +END +OUTPUT +select * from ((select * from t1) union all (select * from t1) limit 2) as a +END +INPUT +(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 ); +END +OUTPUT +(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) +END +INPUT +SELECT c FROM t1 UNION SELECT i FROM t2; +END +OUTPUT +(select c from t1) union (select i from t2) +END +INPUT +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; +END +OUTPUT +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 +END +INPUT +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5) UNION SELECT * FROM t2 ORDER BY a LIMIT 8; +END +OUTPUT +(select * from t1 order by a desc limit 5) union (select * from t2) order by a asc limit 8 +END +INPUT +(SELECT a FROM t1 ORDER BY COUNT(*) LIMIT 1) UNION ALL SELECT a FROM t1; +END +OUTPUT +(select a from t1 order by COUNT(*) asc limit 1) union all (select a from t1) +END +INPUT +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; +END +OUTPUT +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 +END +INPUT +select 'a' union select concat('a', -concat('3',4)); +END +OUTPUT +(select 'a' from dual) union (select concat('a', -concat('3', 4)) from dual) +END +INPUT +SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a LIMIT 5 OFFSET 6; +END +OUTPUT +(select * from t1) union (select * from t2) order by a asc limit 6, 5 +END +INPUT +(SELECT * FROM t1 LIMIT 5) UNION (SELECT * FROM t2 LIMIT 4) ORDER BY a LIMIT 7; +END +OUTPUT +(select * from t1 limit 5) union (select * from t2 limit 4) order by a asc limit 7 +END +INPUT +SELECT 1 FOR UPDATE UNION SELECT 2; +END +OUTPUT +(select 1 from dual for update) union (select 2 from dual) +END +INPUT +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; +END +ERROR +syntax error at position 95 near 'WITH' +END +INPUT +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; +END +ERROR +syntax error at position 15 near 'with' +END +INPUT +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5) UNION ALL SELECT * FROM t2 ORDER BY a LIMIT 8; +END +OUTPUT +(select * from t1 order by a desc limit 5) union all (select * from t2) order by a asc limit 8 +END +INPUT +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)))'))); +END +OUTPUT +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 +END +INPUT +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)'))); +END +OUTPUT +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 +END +INPUT +(SELECT * FROM t1 LIMIT 5) UNION ALL SELECT * FROM t2 ORDER BY a LIMIT 8; +END +OUTPUT +(select * from t1 limit 5) union all (select * from t2) order by a asc limit 8 +END +INPUT +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))'))); +END +OUTPUT +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 +END +INPUT +(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; +END +OUTPUT +(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 +END +INPUT +(select b.id, b.betreff from t3 b) union (select b.id, b.betreff from t3 b) order by match(betreff) against ('+abc') desc; +END +OUTPUT +(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 +END +INPUT +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; +END +OUTPUT +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 +END +INPUT +select f1 from t1 union select f1 from t1; +END +OUTPUT +(select f1 from t1) union (select f1 from t1) +END +INPUT +select f1,'' from t1 union select f1,'' from t1; +END +OUTPUT +(select f1, '' from t1) union (select f1, '' from t1) +END +INPUT +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)'))); +END +OUTPUT +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 +END +INPUT +(SELECT a FROM t1 ORDER BY COUNT(*)) UNION ALL SELECT a FROM t1; +END +OUTPUT +(select a from t1 order by COUNT(*) asc) union all (select a from t1) +END +INPUT +(SELECT * FROM t1 LIMIT 5 OFFSET 4) UNION ALL (SELECT * FROM t2 LIMIT 4 OFFSET 2) LIMIT 7 OFFSET 1; +END +OUTPUT +(select * from t1 limit 4, 5) union all (select * from t2 limit 2, 4) limit 1, 7 +END +INPUT +SELECT * FROM t1 UNION ALL SELECT * FROM t2 LIMIT 5 OFFSET 6; +END +OUTPUT +(select * from t1) union all (select * from t2) limit 6, 5 +END +INPUT +select t1.id from t1 union select t2.id from t2; +END +OUTPUT +(select t1.id from t1) union (select t2.id from t2) +END +INPUT +select 'a' union select concat('a', -4); +END +OUTPUT +(select 'a' from dual) union (select concat('a', -4) from dual) +END +INPUT +select 'a' union select concat('a', -'3'); +END +OUTPUT +(select 'a' from dual) union (select concat('a', -'3') from dual) +END +INPUT +select 'a' union select concat('a', -0); +END +OUTPUT +(select 'a' from dual) union (select concat('a', -0) from dual) +END +INPUT +SELECT a, SUM(a), SUM(a)+1 FROM (SELECT 1 a UNION select 2) d GROUP BY a WITH ROLLUP; +END +ERROR +syntax error at position 80 near 'WITH' +END +INPUT +SELECT LOCATION FROM T1 WHERE EVENT_ID=2 UNION ALL SELECT LOCATION FROM T1 WHERE EVENT_ID=3; +END +OUTPUT +(select LOCATION from T1 where EVENT_ID = 2) union all (select LOCATION from T1 where EVENT_ID = 3) +END +INPUT +(SELECT * FROM t1 LIMIT 5 OFFSET 4) UNION SELECT * FROM t2 ORDER BY a LIMIT 8 OFFSET 1; +END +OUTPUT +(select * from t1 limit 4, 5) union (select * from t2) order by a asc limit 1, 8 +END +INPUT +(SELECT * FROM t1 LIMIT 5) UNION (SELECT * FROM t2 LIMIT 4) LIMIT 7; +END +OUTPUT +(select * from t1 limit 5) union (select * from t2 limit 4) limit 7 +END +INPUT +SELECT 1 UNION SELECT 2 LOCK IN SHARE MODE; +END +OUTPUT +(select 1 from dual) union (select 2 from dual) lock in share mode +END +INPUT +SELECT a FROM t1 UNION (SELECT a FROM t1 ORDER BY COUNT(*)); +END +OUTPUT +(select a from t1) union (select a from t1 order by COUNT(*) asc) +END +INPUT +select min(`col002`) from t1 union select `col002` from t1; +END +OUTPUT +(select min(col002) from t1) union (select col002 from t1) +END +INPUT +SELECT 'case+union+test' UNION SELECT CASE LOWER('1') WHEN LOWER('2') THEN 'BUG' ELSE 'nobug' END; +END +OUTPUT +(select 'case+union+test' from dual) union (select case LOWER('1') when LOWER('2') then 'BUG' else 'nobug' end from dual) +END +INPUT +SELECT sleep(0.5) FROM t17059925 UNION SELECT * FROM (SELECT t17059925_func1(1)) t WHERE 1= 0 UNION SELECT t17059925_func1(1); +END +OUTPUT +(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) +END +INPUT +(select 1 as a from t1) union all (select 1 from dual) limit 1; +END +OUTPUT +(select 1 as a from t1) union all (select 1 from dual) limit 1 +END +INPUT +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)'))); +END +OUTPUT +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 +END +INPUT +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'; +END +OUTPUT +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' +END +INPUT +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5) UNION ALL SELECT * FROM t2 LIMIT 8; +END +OUTPUT +(select * from t1 order by a desc limit 5) union all (select * from t2) limit 8 +END +INPUT +select repeat(_utf8'+',3) as h union select NULL; +END +OUTPUT +(select repeat(_utf8 '+', 3) as h from dual) union (select null from dual) +END +INPUT +SELECT * FROM t1 UNION SELECT /*+ MAX_EXECUTION_TIME(0) */ * FROM t1; +END +OUTPUT +(select * from t1) union (select /*+ MAX_EXECUTION_TIME(0) */ * from t1) +END +INPUT +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)))'))); +END +OUTPUT +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 +END +INPUT +select ST_astext(st_union(ST_GeomFromText('multipoint(2 2, 3 3)'), st_intersection(ST_GeomFromText('point(0 0)'), ST_GeomFromText('point(1 1)')))); +END +OUTPUT +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 +END +INPUT +select group_concat('x') UNION ALL select 1; +END +OUTPUT +(select group_concat('x') from dual) union all (select 1 from dual) +END +INPUT +(SELECT * FROM t1 LIMIT 5 OFFSET 4) UNION ALL SELECT * FROM t2 LIMIT 8 OFFSET 1; +END +OUTPUT +(select * from t1 limit 4, 5) union all (select * from t2) limit 1, 8 +END +INPUT +SELECT 1 FROM dual WHERE 1= 0 UNION SELECT sleep(0.5); +END +OUTPUT +(select 1 from dual where 1 = 0) union (select sleep(0.5) from dual) +END +INPUT +select * from (select 1 union select 1) aaa; +END +OUTPUT +select * from ((select 1 from dual) union (select 1 from dual)) as aaa +END +INPUT +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; +END +ERROR +syntax error at position 152 near 'WITH' +END +INPUT +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)'))); +END +OUTPUT +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 +END +INPUT +(SELECT * FROM t1 LIMIT 5 OFFSET 4) UNION ALL (SELECT * FROM t2 LIMIT 4 OFFSET 2) ORDER BY a LIMIT 7 OFFSET 1; +END +OUTPUT +(select * from t1 limit 4, 5) union all (select * from t2 limit 2, 4) order by a asc limit 1, 7 +END +INPUT +SELECT sleep(0.5) FROM t17059925 UNION SELECT * FROM t17059925 WHERE a= 10 AND a= 20 UNION SELECT * FROM t2; +END +OUTPUT +(select sleep(0.5) from t17059925) union (select * from t17059925 where a = 10 and a = 20) union (select * from t2) +END +INPUT +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))'))); +END +OUTPUT +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 +END +INPUT +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5) UNION ALL (SELECT * FROM t2 ORDER BY a DESC LIMIT 4) LIMIT 7; +END +OUTPUT +(select * from t1 order by a desc limit 5) union all (select * from t2 order by a desc limit 4) limit 7 +END +INPUT +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; +END +OUTPUT +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 +END +INPUT +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; +END +OUTPUT +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 +END +INPUT +SELECT '00' UNION SELECT '10' INTO OUTFILE 'tmpp.txt'; +END +ERROR +syntax error at position 35 near 'INTO' +END +INPUT +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; +END +OUTPUT +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 +END +INPUT +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; +END +OUTPUT +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 +END +INPUT +select ST_astext(ST_Union(ST_geometryfromtext('point(1 1)'), ST_geometryfromtext('polygon((0 0, 2 0, 1 2, 0 0))'))); +END +OUTPUT +select ST_astext(ST_Union(ST_geometryfromtext('point(1 1)'), ST_geometryfromtext('polygon((0 0, 2 0, 1 2, 0 0))'))) from dual +END +INPUT +SELECT 1 as a FROM (SELECT 1 UNION SELECT a) b; +END +OUTPUT +select 1 as a from ((select 1 from dual) union (select a from dual)) as b +END +INPUT +SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a LIMIT 5; +END +OUTPUT +(select * from t1) union (select * from t2) order by a asc limit 5 +END +INPUT +SELECT /*+ MAX_EXECUTION_TIME(0) */ * FROM t1 UNION SELECT /*+ MAX_EXECUTION_TIME(0) */ * FROM t1; +END +OUTPUT +(select /*+ MAX_EXECUTION_TIME(0) */ * from t1) union (select /*+ MAX_EXECUTION_TIME(0) */ * from t1) +END +INPUT +(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; +END +OUTPUT +(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 +END +INPUT +SELECT * FROM t1 WHERE (a, a) NOT IN (SELECT * FROM (SELECT 8, 4 UNION SELECT 2, 3) tt); +END +OUTPUT +select * from t1 where (a, a) not in (select * from ((select 8, 4 from dual) union (select 2, 3 from dual)) as tt) +END +INPUT +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)'))); +END +OUTPUT +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 +END +INPUT +(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; +END +OUTPUT +(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 +END +INPUT +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; +END +OUTPUT +(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) +END +INPUT +(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; +END +OUTPUT +(select * from t1 order by a desc limit 4, 5) union (select * from t2 order by a desc limit 2, 4) limit 1, 7 +END +INPUT +(SELECT a FROM t1 ORDER BY COUNT(*) LIMIT 1) UNION SELECT a FROM t1; +END +OUTPUT +(select a from t1 order by COUNT(*) asc limit 1) union (select a from t1) +END +INPUT +select * from t1 union select * from t2 order by 1 limit 1; +END +OUTPUT +(select * from t1) union (select * from t2) order by 1 asc limit 1 +END +INPUT +SELECT '2' as "3" UNION SELECT '1'; +END +OUTPUT +(select '2' as `3` from dual) union (select '1' from dual) +END +INPUT +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; +END +OUTPUT +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 +END +INPUT +SELECT 1 LOCK IN SHARE MODE UNION SELECT 2; +END +OUTPUT +(select 1 from dual lock in share mode) union (select 2 from dual) +END +INPUT +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; +END +OUTPUT +(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 +END +INPUT +SELECT 'н1234567890' UNION SELECT 1; +END +OUTPUT +(select 'н1234567890' from dual) union (select 1 from dual) +END +INPUT +SELECT t1.i FROM t1 WHERE FALSE AND t1.i > (SELECT MAX(a) FROM (SELECT 8 AS a UNION SELECT 3) AS tt); +END +OUTPUT +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) +END +INPUT +(SELECT a FROM t1 ORDER BY COUNT(*)) UNION SELECT a FROM t1; +END +OUTPUT +(select a from t1 order by COUNT(*) asc) union (select a from t1) +END +INPUT +select 1 union select 1; +END +OUTPUT +(select 1 from dual) union (select 1 from dual) +END +INPUT +SELECT 2 as "my_col1",NULL AS "my_col2" UNION SELECT 1,NULL; +END +OUTPUT +(select 2 as my_col1, null as my_col2 from dual) union (select 1, null from dual) +END +INPUT +(SELECT * FROM t1 LIMIT 5) UNION ALL SELECT * FROM t2 LIMIT 8; +END +OUTPUT +(select * from t1 limit 5) union all (select * from t2) limit 8 +END +INPUT +SELECT 1 UNION ALL SELECT f1_two_inserts(); +END +OUTPUT +(select 1 from dual) union all (select f1_two_inserts() from dual) +END +INPUT +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; +END +OUTPUT +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 +END +INPUT +SELECT (a DIV 254576881) FROM t1 UNION ALL SELECT (a DIV 254576881) FROM t1; +END +OUTPUT +(select a div 254576881 from t1) union all (select a div 254576881 from t1) +END +INPUT +SELECT a FROM t1 UNION (SELECT a FROM t1 ORDER BY COUNT(*) LIMIT 1 OFFSET 1); +END +OUTPUT +(select a from t1) union (select a from t1 order by COUNT(*) asc limit 1, 1) +END +INPUT +(SELECT * FROM t1 LIMIT 5) UNION SELECT * FROM t2 LIMIT 8; +END +OUTPUT +(select * from t1 limit 5) union (select * from t2) limit 8 +END +INPUT +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)'))); +END +OUTPUT +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 +END +INPUT +SELECT 1 UNION SELECT 2 FOR UPDATE; +END +OUTPUT +(select 1 from dual) union (select 2 from dual) for update +END +INPUT +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)'))); +END +OUTPUT +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 +END +INPUT +(SELECT MAX(f1) FROM t1) UNION (SELECT MAX(f1) FROM t1); +END +OUTPUT +(select MAX(f1) from t1) union (select MAX(f1) from t1) +END +INPUT +SELECT c FROM t1 UNION SELECT b FROM t2; +END +OUTPUT +(select c from t1) union (select b from t2) +END +INPUT +select * from t1 union all select * from t2; +END +OUTPUT +(select * from t1) union all (select * from t2) +END +INPUT +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)))'))); +END +OUTPUT +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 +END +INPUT +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; +END +ERROR +syntax error at position 154 near 'WITH' +END +INPUT +SELECT ST_ASTEXT(ST_UNION(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION())'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(GEOMETRYCOLLECTION())))'))) as geom; +END +OUTPUT +select ST_ASTEXT(ST_UNION(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION())'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(GEOMETRYCOLLECTION())))'))) as geom from dual +END +INPUT +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; +END +OUTPUT +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 +END +INPUT +(SELECT a FROM t1 ORDER BY COUNT(*) LIMIT 1) UNION (SELECT a FROM t1 ORDER BY COUNT(*) LIMIT 1 OFFSET 1); +END +OUTPUT +(select a from t1 order by COUNT(*) asc limit 1) union (select a from t1 order by COUNT(*) asc limit 1, 1) +END +INPUT +SELECT 2 as "my_col" UNION SELECT 1; +END +OUTPUT +(select 2 as my_col from dual) union (select 1 from dual) +END +INPUT +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; +END +ERROR +syntax error at position 15 near 'with' +END +INPUT +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; +END +OUTPUT +(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 +END +INPUT +SELECT 1 UNION SELECT 'н1234567890'; +END +OUTPUT +(select 1 from dual) union (select 'н1234567890' from dual) +END +INPUT +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5) UNION (SELECT * FROM t2 ORDER BY a DESC LIMIT 4) ORDER BY a LIMIT 7; +END +OUTPUT +(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 +END +INPUT +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)'))); +END +OUTPUT +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 +END +INPUT +SELECT ST_AsText(ST_Union(ST_GEOMFROMTEXT( 'GEOMETRYCOLLECTION(LINESTRING(3 1, 6 1), LINESTRING(0 1, 4 1))'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION()'))) as result; +END +OUTPUT +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 +END +INPUT +select * from (select * from t1 union all select * from t1) a; +END +OUTPUT +select * from ((select * from t1) union all (select * from t1)) as a +END +INPUT +SELECT sleep(0.5) FROM t17059925 UNION SELECT * FROM (SELECT * FROM t17059925 WHERE a= 10) t WHERE a = 10 UNION SELECT * from t2; +END +OUTPUT +(select sleep(0.5) from t17059925) union (select * from (select * from t17059925 where a = 10) as t where a = 10) union (select * from t2) +END +INPUT +(SELECT max(b), a FROM t1 GROUP BY a) UNION (SELECT max(b), a FROM t1 GROUP BY a); +END +OUTPUT +(select max(b), a from t1 group by a) union (select max(b), a from t1 group by a) +END +INPUT +SELECT a FROM t1 UNION ALL (SELECT a FROM t1 ORDER BY COUNT(*) LIMIT 1 OFFSET 1); +END +OUTPUT +(select a from t1) union all (select a from t1 order by COUNT(*) asc limit 1, 1) +END +INPUT +(SELECT p1 FROM v2 LEFT JOIN v1 ON b = a WHERE p2 = 1 GROUP BY p1 ORDER BY p1) UNION (SELECT NULL LIMIT 0); +END +OUTPUT +(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) +END +INPUT +SELECT * FROM t17059925 WHERE a= 10 UNION SELECT sleep(0.5); +END +OUTPUT +(select * from t17059925 where a = 10) union (select sleep(0.5) from dual) +END +INPUT +SELECT a, SUM(a), SUM(a)+1 FROM (SELECT 1 a UNION select 2) d GROUP BY a; +END +OUTPUT +select a, SUM(a), SUM(a) + 1 from ((select 1 as a from dual) union (select 2 from dual)) as d group by a +END +INPUT +SELECT 2, 3 UNION SELECT 4, 5; +END +OUTPUT +(select 2, 3 from dual) union (select 4, 5 from dual) +END +INPUT +SELECT 1 FOR SHARE UNION SELECT 2; +END +ERROR +syntax error at position 19 near 'SHARE' +END +INPUT +SELECT ST_AsText(ST_Union(shore, boundary)) FROM lakes, named_places WHERE lakes.name = 'Blue Lake' AND named_places.name = 'Goose Island'; +END +OUTPUT +select ST_AsText(ST_Union(shore, boundary)) from lakes, named_places where lakes.`name` = 'Blue Lake' and named_places.`name` = 'Goose Island' +END +INPUT +(SELECT max(b), a FROM t1 GROUP BY a) UNION (SELECT max(b), a FROM t1 GROUP BY a); +END +OUTPUT +(select max(b), a from t1 group by a) union (select max(b), a from t1 group by a) +END +INPUT +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; +END +OUTPUT +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 +END +INPUT +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5 OFFSET 4) UNION ALL SELECT * FROM t2 LIMIT 8 OFFSET 1; +END +OUTPUT +(select * from t1 order by a desc limit 4, 5) union all (select * from t2) limit 1, 8 +END +INPUT +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)))'))); +END +OUTPUT +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 +END +INPUT +select s1 from t1 where s1 in (select version from information_schema.tables) union select version from information_schema.tables; +END +OUTPUT +(select s1 from t1 where s1 in (select version from information_schema.`tables`)) union (select version from information_schema.`tables`) +END +INPUT +SELECT /*+ MAX_EXECUTION_TIME(0) */ * FROM t1 WHERE a IN (SELECT a FROM t1 UNION SELECT /*+ MAX_EXECUTION_TIME(0) */ a FROM t1); +END +OUTPUT +select /*+ MAX_EXECUTION_TIME(0) */ * from t1 where a in ((select a from t1) union (select /*+ MAX_EXECUTION_TIME(0) */ a from t1)) +END +INPUT +SELECT '2' as "my_col1",2 as "my_col2" UNION SELECT '1',1 from t2; +END +OUTPUT +(select '2' as my_col1, 2 as my_col2 from dual) union (select '1', 1 from t2) +END +INPUT +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; +END +OUTPUT +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 +END +INPUT +SELECT 'case+union+test' UNION SELECT CASE '1' WHEN '2' THEN 'BUG' ELSE 'nobug' END; +END +OUTPUT +(select 'case+union+test' from dual) union (select case '1' when '2' then 'BUG' else 'nobug' end from dual) +END +INPUT +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; +END +OUTPUT +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 +END +INPUT +SELECT 1 UNION SELECT 1 FOR UPDATE INTO @var; +END +ERROR +syntax error at position 40 near 'INTO' +END +INPUT +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; +END +OUTPUT +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 +END +INPUT +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); +END +ERROR +syntax error at position 154 near 'WITH' +END +INPUT +select 'a' union select concat('a', -0.0); +END +OUTPUT +(select 'a' from dual) union (select concat('a', -0.0) from dual) +END +INPUT +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)'))); +END +OUTPUT +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 +END +INPUT +(SELECT a FROM t1 ORDER BY COUNT(*) LIMIT 1) UNION ALL (SELECT a FROM t1 ORDER BY COUNT(*) LIMIT 1 OFFSET 1); +END +OUTPUT +(select a from t1 order by COUNT(*) asc limit 1) union all (select a from t1 order by COUNT(*) asc limit 1, 1) +END +INPUT +select 'a' union select concat('a', -(4 + 1)); +END +OUTPUT +(select 'a' from dual) union (select concat('a', -(4 + 1)) from dual) +END +INPUT +SELECT ST_AsText(ST_Union(ST_GeomFromText('MULTIPOINT(0 0,100 100)'), ST_GeomFromText('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(),GEOMETRYCOLLECTION())'))) as result; +END +OUTPUT +select ST_AsText(ST_Union(ST_GeomFromText('MULTIPOINT(0 0,100 100)'), ST_GeomFromText('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(),GEOMETRYCOLLECTION())'))) as result from dual +END +INPUT +SELECT * FROM t1 UNION ALL SELECT * FROM t2 ORDER BY a LIMIT 5; +END +OUTPUT +(select * from t1) union all (select * from t2) order by a asc limit 5 +END +INPUT +SELECT * FROM (SELECT * FROM t17059925 WHERE a= 10) t WHERE a = 10 UNION SELECT sleep(0.5); +END +OUTPUT +(select * from (select * from t17059925 where a = 10) as t where a = 10) union (select sleep(0.5) from dual) +END +INPUT +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)))'))); +END +OUTPUT +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 +END +INPUT +select 1 as a from t1 union all select 1 from dual limit 1; +END +OUTPUT +(select 1 as a from t1) union all (select 1 from dual) limit 1 +END +INPUT +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; +END +OUTPUT +(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) +END +INPUT +(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); +END +OUTPUT +(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) +END +INPUT +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)'))); +END +OUTPUT +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 +END +INPUT +SELECT ST_AsText(ST_Union(ST_GEOMFROMTEXT( 'GEOMETRYCOLLECTION(LINESTRING(3 1, 3 3), LINESTRING(0 1, 4 1))'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION()'))) as result; +END +OUTPUT +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 +END +INPUT +SELECT * FROM t1 UNION ALL SELECT * FROM t2 LIMIT 5; +END +OUTPUT +(select * from t1) union all (select * from t2) limit 5 +END +INPUT +SELECT * FROM t17059925 WHERE a= 10 AND a= 20 UNION SELECT sleep(0.5); +END +OUTPUT +(select * from t17059925 where a = 10 and a = 20) union (select sleep(0.5) from dual) +END +INPUT +SELECT TIME_FORMAT(SEC_TO_TIME(a),"%H:%i:%s") FROM (SELECT 3020399 AS a UNION SELECT 3020398 ) x GROUP BY 1; +END +OUTPUT +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 +END +INPUT +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5 OFFSET 4) UNION SELECT * FROM t2 LIMIT 8 OFFSET 1; +END +OUTPUT +(select * from t1 order by a desc limit 4, 5) union (select * from t2) limit 1, 8 +END +INPUT +SELECT ST_ASTEXT(ST_UNION(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION())'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(1 1), GEOMETRYCOLLECTION(GEOMETRYCOLLECTION())))'))) as geom; +END +OUTPUT +select ST_ASTEXT(ST_UNION(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION())'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(1 1), GEOMETRYCOLLECTION(GEOMETRYCOLLECTION())))'))) as geom from dual +END +INPUT +select 'a' union select concat('a', -4.5); +END +OUTPUT +(select 'a' from dual) union (select concat('a', -4.5) from dual) +END +INPUT +(SELECT a FROM t1 ORDER BY COUNT(*)) UNION ALL (SELECT a FROM t1 ORDER BY COUNT(*)); +END +OUTPUT +(select a from t1 order by COUNT(*) asc) union all (select a from t1 order by COUNT(*) asc) +END +INPUT +select 1 as a union all select 1 union all select 2 union select 1 union all select 2; +END +OUTPUT +(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) +END +INPUT +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'); +END +OUTPUT +select ST_aswkb(convert(st_union(multipoint(point(8, 6), point(1, -17679), point(-9, -9)), linestring(point(91, 12), point(-77, 49), point(53, -81))), char(18))) in ('1', '2') from dual +END +INPUT +select st_astext(st_union(cast(point(1,1)as char(15)),point(1,1))) as res; +END +OUTPUT +select st_astext(st_union(convert(point(1, 1), char(15)), point(1, 1))) as res from dual +END +INPUT +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)'))); +END +OUTPUT +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 +END +INPUT +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; +END +OUTPUT +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 +END +INPUT +SELECT * FROM t1 UNION SELECT * FROM t2 LIMIT 5 OFFSET 6; +END +OUTPUT +(select * from t1) union (select * from t2) limit 6, 5 +END +INPUT +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; +END +OUTPUT +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 +END +INPUT +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; +END +ERROR +syntax error at position 15 near 'with' +END +INPUT +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; +END +OUTPUT +(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 +END +INPUT +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; +END +OUTPUT +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 +END +INPUT +SELECT a DIV 2 FROM t1 UNION SELECT a DIV 2 FROM t1; +END +OUTPUT +(select a div 2 from t1) union (select a div 2 from t1) +END +INPUT +SELECT a FROM t1 UNION ALL (SELECT a FROM t1 ORDER BY COUNT(*)); +END +OUTPUT +(select a from t1) union all (select a from t1 order by COUNT(*) asc) +END +INPUT +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; +END +OUTPUT +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 +END +INPUT +(SELECT * FROM t1 LIMIT 5) UNION ALL (SELECT * FROM t2 LIMIT 4) ORDER BY a LIMIT 7; +END +OUTPUT +(select * from t1 limit 5) union all (select * from t2 limit 4) order by a asc limit 7 +END +INPUT +SELECT sleep(0.5) FROM t17059925 UNION SELECT 1 FROM dual WHERE 1= 0 UNION SELECT * FROM t2; +END +OUTPUT +(select sleep(0.5) from t17059925) union (select 1 from dual where 1 = 0) union (select * from t2) +END +INPUT +SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a, b, c; +END +OUTPUT +(select * from t1) union (select * from t2) order by a asc, b asc, c asc +END +INPUT +select repeat(_utf8mb4'+',3) as h union select NULL; +END +OUTPUT +(select repeat(_utf8mb4 '+', 3) as h from dual) union (select null from dual) +END +INPUT +select * from (select * from t1 union distinct select * from t2 union all select * from t3) X; +END +OUTPUT +select * from ((select * from t1) union (select * from t2) union all (select * from t3)) as X +END +INPUT +SELECT sleep(0.5) from t17059925 UNION SELECT t17059925_func1(1); +END +OUTPUT +(select sleep(0.5) from t17059925) union (select t17059925_func1(1) from dual) +END +INPUT +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; +END +OUTPUT +(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 +END +INPUT +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5) UNION SELECT * FROM t2 LIMIT 8; +END +OUTPUT +(select * from t1 order by a desc limit 5) union (select * from t2) limit 8 +END +INPUT +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; +END +OUTPUT +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 +END +INPUT +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)))'))); +END +OUTPUT +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 +END +INPUT +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)'))); +END +OUTPUT +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 +END +INPUT +SELECT ST_AsText(ST_Union(ST_GEOMFROMTEXT( 'GEOMETRYCOLLECTION(LINESTRING(3 0, 3 3), LINESTRING(0 1, 4 1))'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION()'))) as result; +END +OUTPUT +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 +END +INPUT +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5 OFFSET 4) UNION SELECT * FROM t2 ORDER BY a LIMIT 8 OFFSET 1; +END +OUTPUT +(select * from t1 order by a desc limit 4, 5) union (select * from t2) order by a asc limit 1, 8 +END +INPUT +SELECT * FROM t1 UNION SELECT * FROM t2 LIMIT 5; +END +OUTPUT +(select * from t1) union (select * from t2) limit 5 +END +INPUT +SELECT ST_Union('', ''), md5(1); +END +OUTPUT +select ST_Union('', ''), md5(1) from dual +END +INPUT +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)))); +END +OUTPUT +select st_union(convert(linestring(point(6, -68), point(-22, -4)), 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 +END +INPUT +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))'))); +END +OUTPUT +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 +END +INPUT +select * from t1 union select * from t2 order by 1, 2; +END +OUTPUT +(select * from t1) union (select * from t2) order by 1 asc, 2 asc +END +INPUT +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5 OFFSET 4) UNION ALL SELECT * FROM t2 ORDER BY a LIMIT 8 OFFSET 1; +END +OUTPUT +(select * from t1 order by a desc limit 4, 5) union all (select * from t2) order by a asc limit 1, 8 +END +INPUT +SELECT '1' as "my_col1",2 as "my_col2" UNION SELECT '2',1; +END +OUTPUT +(select '1' as my_col1, 2 as my_col2 from dual) union (select '2', 1 from dual) +END +INPUT +SELECT @a:= CAST(f1 AS SIGNED) FROM t1 UNION ALL SELECT CAST(f1 AS SIGNED) FROM t1; +END +ERROR +syntax error at position 11 near ':' +END +INPUT +(SELECT a FROM t1 ORDER BY COUNT(*)) UNION (SELECT a FROM t1 ORDER BY COUNT(*)); +END +OUTPUT +(select a from t1 order by COUNT(*) asc) union (select a from t1 order by COUNT(*) asc) +END +INPUT +SELECT GROUP_CONCAT(t.c) as c FROM t1 t UNION SELECT '' as c; +END +OUTPUT +(select group_concat(t.c) as c from t1 as t) union (select '' as c from dual) +END +INPUT +SELECT * FROM t1 WHERE a IN (SELECT a FROM t1 UNION SELECT /*+ MAX_EXECUTION_TIME(0) */ a FROM t1); +END +OUTPUT +select * from t1 where a in ((select a from t1) union (select /*+ MAX_EXECUTION_TIME(0) */ a from t1)) +END +INPUT +select * from t1 union distinct select * from t2; +END +OUTPUT +(select * from t1) union (select * from t2) +END +INPUT +SELECT * FROM (SELECT 1 UNION SELECT a) b; +END +OUTPUT +select * from ((select 1 from dual) union (select a from dual)) as b +END +INPUT +SELECT a, SUM(a), SUM(a)+1 FROM (SELECT a FROM t1 UNION select 2) d GROUP BY a; +END +OUTPUT +select a, SUM(a), SUM(a) + 1 from ((select a from t1) union (select 2 from dual)) as d group by a END