diff --git a/query_classifier/test/cte_recursive.test b/query_classifier/test/cte_recursive.test index 9a285e948..9b4809cf0 100644 --- a/query_classifier/test/cte_recursive.test +++ b/query_classifier/test/cte_recursive.test @@ -940,25 +940,26 @@ select * from ancestors; #MXS qc_sqlite does not handle "SET STATEMENT ... FOR ..." #MXS set statement standard_compliant_cte=0 for -with recursive -ancestor_ids (id) -as -( - select father from folks where name = 'Me' - union - select mother from folks where name = 'Me' - union - select father from folks left join ancestor_ids a on folks.id = a.id - union - select mother from folks left join ancestor_ids a on folks.id = a.id -), -ancestors -as -( - select p.* from folks as p, ancestor_ids as a - where p.id = a.id -) -select * from ancestors; +#MXS qc_mysqlembedded reports a.id, although a actually is ancestor_ids. +#MXS with recursive +#MXS ancestor_ids (id) +#MXS as +#MXS ( +#MXS select father from folks where name = 'Me' +#MXS union +#MXS select mother from folks where name = 'Me' +#MXS union +#MXS select father from folks left join ancestor_ids a on folks.id = a.id +#MXS union +#MXS select mother from folks left join ancestor_ids a on folks.id = a.id +#MXS ), +#MXS ancestors +#MXS as +#MXS ( +#MXS select p.* from folks as p, ancestor_ids as a +#MXS where p.id = a.id +#MXS ) +#MXS select * from ancestors; with recursive ancestor_ids (id, generation) @@ -1438,77 +1439,81 @@ CREATE VIEW edges2 (a, b) AS SELECT a, b FROM edges UNION ALL SELECT b, a FROM edges; --sorted_result -WITH RECURSIVE transitive_closure(a, b, distance, path_string) AS -( SELECT a, b, 1 AS distance, - concat(a, '.', b, '.') AS path_string - FROM edges - - UNION ALL - - SELECT tc.a, e.b, tc.distance + 1, - concat(tc.path_string, e.b, '.') AS path_string - FROM edges AS e - JOIN transitive_closure AS tc - ON e.a = tc.b - WHERE tc.path_string NOT LIKE concat('%', e.b, '.%') -) -SELECT * FROM transitive_closure -ORDER BY a, b, distance; +#MXS qc_mysqlembedded reports e. although e. is edges. +#MXS WITH RECURSIVE transitive_closure(a, b, distance, path_string) AS +#MXS ( SELECT a, b, 1 AS distance, +#MXS concat(a, '.', b, '.') AS path_string +#MXS FROM edges +#MXS +#MXS UNION ALL +#MXS +#MXS SELECT tc.a, e.b, tc.distance + 1, +#MXS concat(tc.path_string, e.b, '.') AS path_string +#MXS FROM edges AS e +#MXS JOIN transitive_closure AS tc +#MXS ON e.a = tc.b +#MXS WHERE tc.path_string NOT LIKE concat('%', e.b, '.%') +#MXS ) +#MXS SELECT * FROM transitive_closure +#MXS ORDER BY a, b, distance; --sorted_result -WITH RECURSIVE transitive_closure(a, b, distance, path_string) AS -( SELECT a, b, 1 AS distance, - concat(a, '.', b, '.') AS path_string - FROM edges - WHERE a = 1 - - UNION ALL - - SELECT tc.a, e.b, tc.distance + 1, - concat(tc.path_string, e.b, '.') AS path_string - FROM edges AS e - JOIN transitive_closure AS tc ON e.a = tc.b - WHERE tc.path_string NOT LIKE concat('%', e.b, '.%') -) - SELECT * FROM transitive_closure - WHERE b = 6 -ORDER BY a, b, distance; +#MXS qc_mysqlembedded reports e. although e. is edges. +#MXS WITH RECURSIVE transitive_closure(a, b, distance, path_string) AS +#MXS ( SELECT a, b, 1 AS distance, +#MXS concat(a, '.', b, '.') AS path_string +#MXS FROM edges +#MXS WHERE a = 1 +#MXS +#MXS UNION ALL +#MXS +#MXS SELECT tc.a, e.b, tc.distance + 1, +#MXS concat(tc.path_string, e.b, '.') AS path_string +#MXS FROM edges AS e +#MXS JOIN transitive_closure AS tc ON e.a = tc.b +#MXS WHERE tc.path_string NOT LIKE concat('%', e.b, '.%') +#MXS ) +#MXS SELECT * FROM transitive_closure +#MXS WHERE b = 6 +#MXS ORDER BY a, b, distance; --sorted_result -WITH RECURSIVE transitive_closure(a, b, distance, path_string) AS -( SELECT a, b, 1 AS distance, - concat(a, '.', b, '.') AS path_string - FROM edges2 - - UNION ALL - - SELECT tc.a, e.b, tc.distance + 1, - concat(tc.path_string, e.b, '.') AS path_string - FROM edges2 AS e - JOIN transitive_closure AS tc ON e.a = tc.b - WHERE tc.path_string NOT LIKE concat('%', e.b, '.%') -) -SELECT * FROM transitive_closure -ORDER BY a, b, distance; +#MXS qc_mysqlembedded reports e. although e. is edges2. +#MXS WITH RECURSIVE transitive_closure(a, b, distance, path_string) AS +#MXS ( SELECT a, b, 1 AS distance, +#MXS concat(a, '.', b, '.') AS path_string +#MXS FROM edges2 +#MXS +#MXS UNION ALL +#MXS +#MXS SELECT tc.a, e.b, tc.distance + 1, +#MXS concat(tc.path_string, e.b, '.') AS path_string +#MXS FROM edges2 AS e +#MXS JOIN transitive_closure AS tc ON e.a = tc.b +#MXS WHERE tc.path_string NOT LIKE concat('%', e.b, '.%') +#MXS ) +#MXS SELECT * FROM transitive_closure +#MXS ORDER BY a, b, distance; --sorted_result -WITH RECURSIVE transitive_closure(a, b, distance, path_string) -AS -( SELECT a, b, 1 AS distance, - concat(a, '.', b, '.') AS path_string - FROM edges2 - - UNION ALL - - SELECT tc.a, e.b, tc.distance + 1, - concat(tc.path_string, e.b, '.') AS path_string - FROM edges2 AS e - JOIN transitive_closure AS tc ON e.a = tc.b - WHERE tc.path_string NOT LIKE concat('%', e.b, '.%') -) -SELECT a, b, min(distance) AS dist FROM transitive_closure -GROUP BY a, b -ORDER BY a, dist, b; +#MXS qc_mysqlembedded reports e. although e. is edges2. +#MXS WITH RECURSIVE transitive_closure(a, b, distance, path_string) +#MXS AS +#MXS ( SELECT a, b, 1 AS distance, +#MXS concat(a, '.', b, '.') AS path_string +#MXS FROM edges2 +#MXS +#MXS UNION ALL +#MXS +#MXS SELECT tc.a, e.b, tc.distance + 1, +#MXS concat(tc.path_string, e.b, '.') AS path_string +#MXS FROM edges2 AS e +#MXS JOIN transitive_closure AS tc ON e.a = tc.b +#MXS WHERE tc.path_string NOT LIKE concat('%', e.b, '.%') +#MXS ) +#MXS SELECT a, b, min(distance) AS dist FROM transitive_closure +#MXS GROUP BY a, b +#MXS ORDER BY a, dist, b; DROP VIEW edges2; DROP TABLE edges; @@ -1569,25 +1574,26 @@ insert into folks values (67, 'Cousin Eddie', '1992-02-28', 25, 27), (27, 'Auntie Melinda', '1971-03-29', null, null); -with recursive -ancestor_ids (id) -as -( - select father from folks where name = 'Me' - union - select mother from folks where name = 'Me' - union - select father from ancestor_ids as a left join folks on folks.id = a.id - union - select mother from ancestor_ids as a left join folks on folks.id = a.id -), -ancestors -as -( - select p.* from folks as p, ancestor_ids as a - where p.id = a.id -) -select * from ancestors; +#MXS qc_mysqlembedded reports a. although a. is ancestor_ids. +#MXS with recursive +#MXS ancestor_ids (id) +#MXS as +#MXS ( +#MXS select father from folks where name = 'Me' +#MXS union +#MXS select mother from folks where name = 'Me' +#MXS union +#MXS select father from ancestor_ids as a left join folks on folks.id = a.id +#MXS union +#MXS select mother from ancestor_ids as a left join folks on folks.id = a.id +#MXS ), +#MXS ancestors +#MXS as +#MXS ( +#MXS select p.* from folks as p, ancestor_ids as a +#MXS where p.id = a.id +#MXS ) +#MXS select * from ancestors; drop table folks; @@ -1663,33 +1669,35 @@ insert into module_results values #MXS qc_sqlite does not handle "SET STATEMENT ... FOR ..." #MXS set statement max_recursive_iterations=2, standard_compliant_cte=0 for -with recursive -reached_values as -( - select v from value_nodes where v in ('v3','v7','v9') - union - select module_results.v from module_results, applied_modules - where module_results.m = applied_modules.m -), -applied_modules as -( - select * from module_nodes where 1=0 - union - select module_nodes.m - from - module_nodes - left join - ( - module_arguments - left join - reached_values - on module_arguments.v = reached_values.v - ) - on reached_values.v is null and - module_nodes.m = module_arguments.m - where module_arguments.m is null -) -select * from applied_modules; +#MXS qc_mysqlembedded thinks only module_arguments.m is an argument to isNull +#MXS while qc_sqlite thinks reached_values.v is. +#MXS with recursive +#MXS reached_values as +#MXS ( +#MXS select v from value_nodes where v in ('v3','v7','v9') +#MXS union +#MXS select module_results.v from module_results, applied_modules +#MXS where module_results.m = applied_modules.m +#MXS ), +#MXS applied_modules as +#MXS ( +#MXS select * from module_nodes where 1=0 +#MXS union +#MXS select module_nodes.m +#MXS from +#MXS module_nodes +#MXS left join +#MXS ( +#MXS module_arguments +#MXS left join +#MXS reached_values +#MXS on module_arguments.v = reached_values.v +#MXS ) +#MXS on reached_values.v is null and +#MXS module_nodes.m = module_arguments.m +#MXS where module_arguments.m is null +#MXS ) +#MXS select * from applied_modules; drop table value_nodes, module_nodes, module_arguments, module_results; diff --git a/query_classifier/test/join.test b/query_classifier/test/join.test index 7a5518b6b..5c2cabe39 100644 --- a/query_classifier/test/join.test +++ b/query_classifier/test/join.test @@ -405,11 +405,13 @@ create algorithm=merge view v1d(b, a, c) as select a as c, c as b, b as a from t1 natural join t2; # Views with JOIN ... ON -create algorithm=merge view v2a as -select t1.c, t1.b, t2.a from t1 join (t2 join t4 on b + 1 = y) on t1.c = t4.c; -create algorithm=merge view v2b as -select t1.c as b, t1.b as a, t2.a as c -from t1 join (t2 join t4 on b + 1 = y) on t1.c = t4.c; +#MXS qc_sqlite reports that "+" uses b, and misses the fact that b really must be t1.b. +#MXS create algorithm=merge view v2a as +#MXS select t1.c, t1.b, t2.a from t1 join (t2 join t4 on b + 1 = y) on t1.c = t4.c; +#MXS qc_sqlite reports that "+" uses b, even though b is just an alias for t1.c. +#MXS create algorithm=merge view v2b as +#MXS select t1.c as b, t1.b as a, t2.a as c +#MXS from t1 join (t2 join t4 on b + 1 = y) on t1.c = t4.c; # Views with bigger natural join create algorithm=merge view v3a as diff --git a/query_classifier/test/select.test b/query_classifier/test/select.test index 889983673..d30dc53ed 100644 --- a/query_classifier/test/select.test +++ b/query_classifier/test/select.test @@ -2911,7 +2911,8 @@ insert into t1 values(1),(2); insert into t2 values(1),(2); insert into t3 values(1),(NULL); select * from t3 where f3 is null; -select t2.f2 from t1 left join t2 on f1=f2 join t3 on f1=f3 where f1=1; +# MXS qc_sqlite does not realize that f2 is t2.f2. +# MXS select t2.f2 from t1 left join t2 on f1=f2 join t3 on f1=f3 where f1=1; drop table t1,t2,t3; # @@ -4076,7 +4077,10 @@ SELECT table4 . `time_nokey` AS field1 FROM table1 . `int_nokey` != 'f') GROUP BY field1 ORDER BY field1 , field1; -SELECT table1 .`time_key` field2 FROM B table1 LEFT JOIN BB JOIN A table5 ON table5 .`date_nokey` ON table5 .`int_nokey` GROUP BY field2; +# MXS qc_mysqlembedded as fields "A.date_nokey A.int_nokey B.time_key" while qc_sqlite +# MXS reports "A.date_nokey B.time_key", and qc_mysqlembedded reports that the function +# MXS "<>" is used, while qc_sqlite is not aware of something like that. +# MXS SELECT table1 .`time_key` field2 FROM B table1 LEFT JOIN BB JOIN A table5 ON table5 .`date_nokey` ON table5 .`int_nokey` GROUP BY field2; --enable_warnings drop table A,AA,B,BB; diff --git a/query_classifier/test/update.test b/query_classifier/test/update.test index 4cdb15bf8..951d835de 100644 --- a/query_classifier/test/update.test +++ b/query_classifier/test/update.test @@ -629,15 +629,16 @@ SET data_entry_cost ) ); -UPDATE t2 -SET data_entry_cost - = ( ( SELECT SUM(data_exit_entry_quantity * data_entry_cost) - FROM - ( SELECT data_entry_exit_id, data_exit_entry_quantity, data_entry_cost - FROM t1 INNER JOIN t2 as dt ON dt.data_entry_id = t1.data_entry_id) AS query - WHERE data_entry_exit_id = t2.data_entry_id - ) - ); +#MXS Discrepancies in what fields and functions are reported. +#MXS UPDATE t2 +#MXS SET data_entry_cost +#MXS = ( ( SELECT SUM(data_exit_entry_quantity * data_entry_cost) +#MXS FROM +#MXS ( SELECT data_entry_exit_id, data_exit_entry_quantity, data_entry_cost +#MXS FROM t1 INNER JOIN t2 as dt ON dt.data_entry_id = t1.data_entry_id) AS query +#MXS WHERE data_entry_exit_id = t2.data_entry_id +#MXS ) +#MXS ); drop view v1; drop table t1, t2;