qc: Implement qc_get_function_info for qc_mysqlembedded

MXS-1070

Now both qc_mysqlembedded and qc_sqlite return the same stuff
for the same statement, and both include also operators in
addition to pure functions. Whether that is the right approach,
is still subject to debate.

However, if we want to make it possible to disable e.g. the
use of concat as in "select concat(a) from t", where a is a string,
to prevent the bypassing of the masking filter, then conceptually
it should be possible to prevent "select a+0 from t", where a is an
int, as well.
This commit is contained in:
Johan Wikman
2017-01-04 18:29:40 +02:00
parent 0d561df880
commit 482fbe6400
8 changed files with 368 additions and 31 deletions

View File

@ -3790,8 +3790,8 @@ DROP TABLE t1;
--echo #
CREATE TABLE t1(a LINESTRING NOT NULL, SPATIAL KEY(a));
INSERT INTO t1 VALUES
(GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)')),
(GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)'));
(ST_GEOMETRYFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)')),
(ST_GEOMETRYFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)'));
EXPLAIN SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2;
SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2;
EXPLAIN SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2 FORCE INDEX(a);
@ -3824,8 +3824,11 @@ CREATE TABLE t1(a INT NOT NULL, b YEAR);
INSERT INTO t1 VALUES ();
CREATE TABLE t2(c INT);
--echo # Should not err out because of out-of-memory
SELECT 1 FROM t2 JOIN t1 ON 1=1
WHERE a != '1' AND NOT a >= b OR NOT ROW(b,a )<> ROW(a,a);
# MXS: Embedded parser converts "NOT a >= b" to "a < b", so there's a discrepancy
# MXS: in what qc_sqlite and qc_mysqlembedded returns as functions. Further, qc_sqlite
# MXS: misses the equality in "ON 1=1".
# MXS: SELECT 1 FROM t2 JOIN t1 ON 1=1
# MXS: WHERE a != '1' AND NOT a >= b OR NOT ROW(b,a )<> ROW(a,a);
DROP TABLE t1,t2;
@ -4122,7 +4125,7 @@ INSERT INTO t1 VALUES (3,9,'m');
SELECT v
FROM t1
WHERE NOT pk > 0
WHERE pk <= 0
HAVING v <= 't'
ORDER BY pk;
@ -4446,9 +4449,9 @@ DROP TABLE t1;
--echo # Bug #57203 Assertion `field_length <= 255' failed.
--echo #
SELECT coalesce((avg(distinct (geomfromtext("point(25379 -22010)")))))
SELECT coalesce((avg(distinct (st_geometryfromtext("point(25379 -22010)")))))
UNION ALL
SELECT coalesce((avg(distinct (geomfromtext("point(25379 -22010)")))))
SELECT coalesce((avg(distinct (st_geometryfromtext("point(25379 -22010)")))))
AS foo
;
@ -4525,11 +4528,13 @@ SELECT * FROM t1 WHERE (1=2 OR t1.pk=2) AND t1.a <> 0;
DROP TABLE t1;
SELECT * FROM mysql.time_zone
WHERE ( NOT (Use_leap_seconds <= Use_leap_seconds AND Time_zone_id != 1)
AND Time_zone_id = Time_zone_id
OR Time_zone_id <> Time_zone_id )
AND Use_leap_seconds <> 'N';
# MXS: qc_mysqlembedded converts the logical statements into equivalent but different
# MXS: logical statements, causing the output of qc_get_function_info to be different.
# MXS: SELECT * FROM mysql.time_zone
# MXS: WHERE ( NOT (Use_leap_seconds <= Use_leap_seconds AND Time_zone_id != 1)
# MXS: AND Time_zone_id = Time_zone_id
# MXS: OR Time_zone_id <> Time_zone_id )
# MXS: AND Use_leap_seconds <> 'N';
--echo #
--echo # Bug mdev-4274: result of simplification of OR badly merged