MXS-1702: Move canonicalization test into core

Moved the test into the core where it belongs.
This commit is contained in:
Markus Mäkelä
2018-03-15 13:32:29 +02:00
parent 3e0b3db65e
commit cb170eb88e
15 changed files with 2 additions and 4 deletions

View File

@ -95,3 +95,4 @@ add_test(test_utils test_utils)
add_test(test_session_track test_session_track)
add_subdirectory(rest-api)
add_subdirectory(canonical_tests)

View File

@ -0,0 +1,37 @@
# This test no longer requires the query classifier for canonicalization
add_executable(canonizer canonizer.c)
target_link_libraries(canonizer maxscale-common)
add_test(NAME CanonicalQuery COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/canontest.sh
${CMAKE_CURRENT_BINARY_DIR}/test.log
${CMAKE_CURRENT_SOURCE_DIR}/input.sql
${CMAKE_CURRENT_BINARY_DIR}/output.sql
${CMAKE_CURRENT_SOURCE_DIR}/expected.sql
$<TARGET_FILE:canonizer>)
add_test(NAME CanonicalQuerySelect COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/canontest.sh
${CMAKE_CURRENT_BINARY_DIR}/test.log
${CMAKE_CURRENT_SOURCE_DIR}/select.sql
${CMAKE_CURRENT_BINARY_DIR}/select.output
${CMAKE_CURRENT_SOURCE_DIR}/select.expected
$<TARGET_FILE:canonizer>)
add_test(NAME CanonicalQueryAlter COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/canontest.sh
${CMAKE_CURRENT_BINARY_DIR}/test.log
${CMAKE_CURRENT_SOURCE_DIR}/alter.sql
${CMAKE_CURRENT_BINARY_DIR}/alter.output
${CMAKE_CURRENT_SOURCE_DIR}/alter.expected
$<TARGET_FILE:canonizer>)
add_test(NAME CanonicalQueryComment COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/canontest.sh
${CMAKE_CURRENT_BINARY_DIR}/test.log
${CMAKE_CURRENT_SOURCE_DIR}/comment.sql
${CMAKE_CURRENT_BINARY_DIR}/comment.output
${CMAKE_CURRENT_SOURCE_DIR}/comment.expected
$<TARGET_FILE:canonizer>)
add_test(NAME CanonicalQueryWhitespace COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/canontest.sh
${CMAKE_CURRENT_BINARY_DIR}/test.log
${CMAKE_CURRENT_SOURCE_DIR}/whitespace.sql
${CMAKE_CURRENT_BINARY_DIR}/whitespace.output
${CMAKE_CURRENT_SOURCE_DIR}/whitespace.expected
$<TARGET_FILE:canonizer>)

View File

@ -0,0 +1,19 @@
ALTER DATABASE `` DEFAULT CHARACTER SET latin2;
ALTER DATABASE `#mysql50#../` UPGRADE DATA DIRECTORY NAME;
ALTER DATABASE `#mysql50#../..` UPGRADE DATA DIRECTORY NAME;
ALTER DATABASE `#mysql51#not-yet` UPGRADE DATA DIRECTORY NAME;
ALTER DATABASE `test-database` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
ALTER DEFINER=root@? EVENT e1 ON SCHEDULE EVERY ? HOUR;
ALTER EVENT e1 COMMENT '?';
ALTER EVENT e1 DO SELECT ?;
ALTER EVENT e1 ON SCHEDULE AT '?' ON COMPLETION PRESERVE DISABLE;
ALTER TABLE `@0023sql1` RENAME `#sql-1`;
ALTER TABLE t1 ADD INDEX (c13) COMMENT '?';
ALTER TABLE t1 ADD PARTITION IF NOT EXISTS(PARTITION `p5` VALUES LESS THAN (?)COMMENT '?');
ALTER TABLE `t1` ADD PRIMARY KEY (`a`);
alter table t1 change a a enum('?','?','?','?','?','?','?','?') character set utf16;
alter table t1 change a a int `FKEY1`='?';
alter table t1i engine=innodb;
alter table t1 max_rows=?;
ALTER TABLE t2 PARTITION BY RANGE COLUMNS(c)(PARTITION p0 VALUES LESS THAN ('?'), PARTITION p1 VALUES LESS THAN (MAXVALUE));
alter table table_24562 order by table_24562.subsection ASC, table_24562.section DESC;

View File

@ -0,0 +1,19 @@
ALTER DATABASE `` DEFAULT CHARACTER SET latin2;
ALTER DATABASE `#mysql50#../` UPGRADE DATA DIRECTORY NAME;
ALTER DATABASE `#mysql50#../..` UPGRADE DATA DIRECTORY NAME; # a comment
ALTER DATABASE `#mysql51#not-yet` UPGRADE DATA DIRECTORY NAME; # a comment with backticks `this should work`
ALTER DATABASE `test-database` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
ALTER DEFINER=root@localhost EVENT e1 ON SCHEDULE EVERY 1 HOUR;
ALTER EVENT e1 COMMENT 'comment';
ALTER EVENT e1 DO SELECT 2;
ALTER EVENT e1 ON SCHEDULE AT '2000-01-02 00:00:00' ON COMPLETION PRESERVE DISABLE;
ALTER TABLE `@0023sql1` RENAME `#sql-1`;
ALTER TABLE t1 ADD INDEX (c13) COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd';
ALTER TABLE t1 ADD PARTITION IF NOT EXISTS(PARTITION `p5` VALUES LESS THAN (2010)COMMENT 'APSTART \' APEND');
ALTER TABLE `t1` ADD PRIMARY KEY (`a`);
alter table t1 change a a enum('x','y','z','d','e','ä','ö','ü') character set utf16;
alter table t1 change a a int `FKEY1`='v1';
alter table t1i engine=innodb;
alter table t1 max_rows=100000000000;
ALTER TABLE t2 PARTITION BY RANGE COLUMNS(c)(PARTITION p0 VALUES LESS THAN ('2000-01-01 00:00:00'), PARTITION p1 VALUES LESS THAN (MAXVALUE));
alter table table_24562 order by table_24562.subsection ASC, table_24562.section DESC;

View File

@ -0,0 +1,89 @@
/*
* Copyright (c) 2016 MariaDB Corporation Ab
*
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file and at www.mariadb.com/bsl11.
*
* Change Date: 2020-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2 or later of the General
* Public License.
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <maxscale/query_classifier.h>
#include <maxscale/buffer.h>
#include <maxscale/paths.h>
#include <maxscale/utils.h>
int main(int argc, char** argv)
{
unsigned int psize;
GWBUF* qbuff;
char *tok;
char readbuff[4092];
FILE* infile;
FILE* outfile;
if (argc != 3)
{
printf("Usage: canonizer <input file> <output file>\n");
return 1;
}
if (!utils_init())
{
printf("Utils library init failed.\n");
return 1;
}
set_libdir(strdup("../../../../query_classifier/qc_sqlite/"));
set_datadir(strdup("/tmp"));
set_langdir(strdup("."));
set_process_datadir(strdup("/tmp"));
qc_setup("qc_sqlite", QC_SQL_MODE_DEFAULT, NULL);
qc_process_init(QC_INIT_BOTH);
qc_thread_init(QC_INIT_BOTH);
infile = fopen(argv[1], "rb");
outfile = fopen(argv[2], "wb");
if (infile == NULL || outfile == NULL)
{
printf("Opening files failed.\n");
return 1;
}
while (!feof(infile) && fgets(readbuff, 4092, infile))
{
char* nl = strchr(readbuff, '\n');
if (nl)
{
*nl = '\0';
}
if (strlen(readbuff) > 0)
{
psize = strlen(readbuff) + 1;
qbuff = gwbuf_alloc(psize + 4);
*(qbuff->sbuf->data + 0) = (unsigned char) psize;
*(qbuff->sbuf->data + 1) = (unsigned char) (psize >> 8);
*(qbuff->sbuf->data + 2) = (unsigned char) (psize >> 16);
*(qbuff->sbuf->data + 3) = 0x00;
*(qbuff->sbuf->data + 4) = 0x03;
memcpy(qbuff->start + 5, readbuff, psize - 1);
tok = qc_get_canonical(qbuff);
fprintf(outfile, "%s\n", tok);
free(tok);
gwbuf_free(qbuff);
}
}
fclose(infile);
fclose(outfile);
qc_process_end(QC_INIT_BOTH);
return 0;
}

View File

@ -0,0 +1,37 @@
#! /bin/sh
if [ $# -lt 4 ]
then
echo "Usage: canontest.sh <logfile name> <input file> <output file> <expected output>"
exit 0
fi
TESTLOG=$1
INPUT=$2
OUTPUT=$3
EXPECTED=$4
DIFFLOG=diff.out
if [ $# -eq 5 ]
then
EXECUTABLE=$5
else
EXECUTABLE=$PWD/canonizer
fi
$EXECUTABLE $INPUT $OUTPUT
diff $OUTPUT $EXPECTED > $DIFFLOG
if [ $? -eq 0 ]
then
echo "PASSED" >> $TESTLOG
exval=0
else
echo "FAILED" >> $TESTLOG
echo "Diff output: " >> $TESTLOG
cat $DIFFLOG >> $TESTLOG
exval=1
fi
if [ $# -eq 5 ]
then
cat $TESTLOG
exit $exval
fi

View File

@ -0,0 +1,11 @@
select ?;
select ?;
select ?;
select /*! ? + */ ?;
select /*!? ? + */ ?;
select /*!? ? + */ ?;
SELECT ? ;
SELECT ? /*! +? */;
SELECT ? /*!? +? */;
SELECT ? /*M! +? */;
SELECT ? /*M!? +? */;

View File

@ -0,0 +1,11 @@
select 1;-- comment after statement
select 1;# comment after statement
select /* inline comment */ 1;
select /*! 1 + */ 1;
select /*!300000 1 + */ 1;
select /*!300000 1 + */ 1;
SELECT 2 /* +1 */;
SELECT 1 /*! +1 */;
SELECT 1 /*!50101 +1 */;
SELECT 2 /*M! +1 */;
SELECT 2 /*M!50101 +1 */;

View File

@ -0,0 +1,92 @@
select md5("?") =?, sleep(?), rand(?);
select * from my1 where md5("?") =?;
select md5("?") =?;
select * from my1 where md5("?") =?;
select sleep(?);
select * from tst where lname='?';
select ?,?,?,?,?,? from tst;
select * from tst where fname like '?';
select * from tst where lname like '?' order by fname;
insert into tst values ("?","?"),("?",null),("?","?");
drop table if exists tst;
create table tst(fname varchar(?), lname varchar(?));
update tst set lname="?" where fname like '?' or lname like '?';
delete from tst where lname like '?' and fname like '?';
select ? from tst where fname='?' or lname like '?';
select ?,?,?,? from tst where name='?' or name='?' or name='?' or name='?';
select count(?),count(?),count(?),count(?),count (?),count(?) from tst;
begin;
BEGIN
BEGIN;
commit;
COMMIT;
COMMIT;
CREATE DATABASE FOO;
CREATE EVENT myevent
CREATE FUNCTION hello (s CHAR(?))
CREATE INDEX foo_t1 on T1 (id);
CREATE PROCEDURE simpleproc (OUT param1 INT)
CREATE TABLE myCity (a int, b char(?));
create table t1 (id integer);
create table t1(id integer);
CREATE TABLE T1 (id integer);
CREATE TABLE T1 (id integer);
CREATE TABLE T2 (id integer);
CREATE TEMPORARY TABLE T1 (id integer);
DELETE FROM myCity;
DELETE FROM myCity;
DELIMITER ;//
DELIMITER //;
DO
DROP DATABASE FOO;
DROP DATABASE If EXISTS FOO;
DROP EVENT IF EXISTS myevent;
DROP EVENT myevent;
DROP FUNCTION hello;
DROP FUNCTION IF EXISTS hello;
DROP PROCEDURE IF EXISTS simpleproc;
DROP PROCEDURE simpleproc;
DROP TABLE IF EXISTS myCity;
drop table if exists t1;
DROP TABLE IF EXISTS T1;
DROP TABLE IF EXISTS T2;
DROP TABLE myCity;
drop table t1;
DROP TABLE T1;
DROP TABLE T2;
END //
INSERT INTO myCity VALUES (?, '?');
INSERT INTO myCity VALUES (?, '?');
insert into t1 values(?);
insert into t1 values(?);
INSERT INTO T2 VALUES (@@?);
ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL ? HOUR
RETURN CONCAT('?',s,'?');
RETURNS CHAR(?) DETERMINISTIC
SELECT @?;
SELECT @?;
SELECT COUNT(*) FROM myCity;
select count(*) from t1;
select count(*) from t1;
select count(*) from user where user='?';
SELECT COUNT(*) INTO param1 FROM t;
SELECT IF(@? <> @?,'?','?') AS result;
SELECT IF(id <> @?,'?','?') AS result FROM T2;
SELECT IF(@@? <> @?,'?','?') AS result;
SELECT (@@?) INTO @?;
set autocommit=?;
SET autocommit=?;
SET autocommit = ?;
set autocommit=?;
SET autocommit=?;
SET AUTOCOMMIT=?;
set autocommit=OFF;
SET autocommit = oFf;
SET autocommit = Off;
SET AUTOCOMMIT=oN;
START TRANSACTION;
UPDATE t1 SET id = id + ?;
use mysql;
use test;
USE test;
USE test;

View File

@ -0,0 +1,92 @@
select md5("200000foo") =10, sleep(2), rand(100);
select * from my1 where md5("110") =10;
select md5("100foo") =10;
select * from my1 where md5("100") =10;
select sleep(2);
select * from tst where lname='Doe';
select 1,2,3,4,5,6 from tst;
select * from tst where fname like '%a%';
select * from tst where lname like '%e%' order by fname;
insert into tst values ("John","Doe"),("Plato",null),("Nietzsche","");
drop table if exists tst;
create table tst(fname varchar(30), lname varchar(30));
update tst set lname="Human" where fname like '%a%' or lname like '%a%';
delete from tst where lname like '%man%' and fname like '%ard%';
select 100 from tst where fname='10' or lname like '%100%';
select 1,20,300,4000 from tst where name='1000' or name='200' or name='30' or name='4';
select count(1),count(10),count(100),count(2),count (20),count(200) from tst;
begin;
BEGIN
BEGIN;
commit;
COMMIT;
COMMIT;
CREATE DATABASE FOO;
CREATE EVENT myevent
CREATE FUNCTION hello (s CHAR(20))
CREATE INDEX foo_t1 on T1 (id);
CREATE PROCEDURE simpleproc (OUT param1 INT)
CREATE TABLE myCity (a int, b char(20));
create table t1 (id integer);
create table t1(id integer);
CREATE TABLE T1 (id integer);
CREATE TABLE T1 (id integer);
CREATE TABLE T2 (id integer);
CREATE TEMPORARY TABLE T1 (id integer);
DELETE FROM myCity;
DELETE FROM myCity;
DELIMITER ;//
DELIMITER //;
DO
DROP DATABASE FOO;
DROP DATABASE If EXISTS FOO;
DROP EVENT IF EXISTS myevent;
DROP EVENT myevent;
DROP FUNCTION hello;
DROP FUNCTION IF EXISTS hello;
DROP PROCEDURE IF EXISTS simpleproc;
DROP PROCEDURE simpleproc;
DROP TABLE IF EXISTS myCity;
drop table if exists t1;
DROP TABLE IF EXISTS T1;
DROP TABLE IF EXISTS T2;
DROP TABLE myCity;
drop table t1;
DROP TABLE T1;
DROP TABLE T2;
END //
INSERT INTO myCity VALUES (1, 'Milan');
INSERT INTO myCity VALUES (2, 'London');
insert into t1 values(1);
insert into t1 values(1);
INSERT INTO T2 VALUES (@@server_id);
ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR
RETURN CONCAT('Hello, ',s,'!');
RETURNS CHAR(50) DETERMINISTIC
SELECT @a;
SELECT @a;
SELECT COUNT(*) FROM myCity;
select count(*) from t1;
select count(*) from t1;
select count(*) from user where user='maxuser';
SELECT COUNT(*) INTO param1 FROM t;
SELECT IF(@a <> @TMASTER_ID,'OK (slave)','FAIL (master)') AS result;
SELECT IF(id <> @TMASTER_ID,'OK (slave)','FAIL (master)') AS result FROM T2;
SELECT IF(@@server_id <> @TMASTER_ID,'OK (slave)','FAIL (master)') AS result;
SELECT (@@server_id) INTO @a;
set autocommit=0;
SET autocommit=0;
SET autocommit = 0;
set autocommit=1;
SET autocommit=1;
SET AUTOCOMMIT=1;
set autocommit=OFF;
SET autocommit = oFf;
SET autocommit = Off;
SET AUTOCOMMIT=oN;
START TRANSACTION;
UPDATE t1 SET id = id + 1;
use mysql;
use test;
USE test;
USE test;

View File

@ -0,0 +1,60 @@
select count(*) from t1 where id not in (?,?);
select count(*) from t1 where match a against ('?');
SELECT COUNT(*) FROM t1 WHERE MATCH(a) AGAINST("?" IN BOOLEAN MODE);
select count(*) from t1 where s1 < ? or s1 is null;
SELECT COUNT(*) FROM t1 WHERE s1 = ?;
select count(*) from t1 where x < ?;
select count(*) from t1 where x = ?;
select count(*) from t1 where x > ?;
select count(*) from t1 where x = ?;
select truncate(?,?);
select truncate(?,-?);
select v/?;
select uncompress("?");
SELECT UNHEX('?');
select unhex(hex("?")), hex(unhex("?")), unhex("?"), unhex(NULL);
select UpdateXML('?','?','?');
select UpdateXML(@?, '?', '?');
SELECT USER(),CURRENT_USER(),@@LOCAL.external_user;
SELECT user(),current_user(),@@?;
SELECT user, host FROM mysql.user where user = '?' order by ?,?;
select user, host, password, plugin, authentication_string from mysql.user where user = '?';
select userid,count(*) from t1 group by userid desc having ? IN (?,COUNT(*));
select userid,count(*) from t1 group by userid desc having (count(*)+?) IN (?,?);
SELECT user_id FROM t1 WHERE request_id=?;
SELECT UserId FROM t1 WHERE UserId=? group by Userid;
select userid,pmtotal,pmnew, (select count(rd) from t1 where toid=t2.userid) calc_total, (select count(rd) from t1 where rd=? and toid=t2.userid) calc_new from t2 where userid in (select distinct toid from t1);
select yearweek("?",?) as '?', yearweek("?",?) as '?', yearweek("?",?) as '?',yearweek("?",?) as '?', yearweek("?",?) as '?', yearweek("?",?) as '?', yearweek("?",?) as '?';
select user() like "?";
select user,password,plugin,authentication_string from mysql.user where user like '?';
select user, QUOTE(host) from mysql.user where user="?";
SELECT UTC_DATE();
select utext from t1 where utext like '?';
SELECT _utf32 0x10001=_utf32 0x10002;
select _utf32'?' collate utf32_general_ci = 0xfffd;
SELECT _utf8 0x7E, _utf8 X'?', _utf8 B'?';
select _utf8 0xD0B0D0B1D0B2 like concat(_utf8'?',_utf8 0xD0B1,_utf8 '?');
select _utf8'?' union select _latin1'?';
SELECT utf8_f,MIN(comment) FROM t1 GROUP BY ?;
SELECT _utf8mb3'?';
select _utf8mb4 0xD0B0D0B1D0B2 like concat(_utf8mb4'?',_utf8mb4 0xD0B1,_utf8mb4 '?');
select (_utf8mb4 X'?');
SELECT _utf8'?' COLLATE utf8_5624_2;
select (_utf8 X'?');
select uuid() into @?;
SELECT v1.a, v2? b FROM v1 LEFT OUTER JOIN v2 ON (v1.a=v2.b) AND (v1.a >= ?) GROUP BY v1.a;
SELECT v1.f4 FROM v1 WHERE f1<>? OR f2<>? AND f4='?' AND (f2<>? OR f3<>? AND f5<>? OR f4 LIKE '?');
select v1.r_object_id, v2.users_names from v1, v2where (v1.group_name='?') and v2.r_object_id=v1.r_object_idorder by users_names;
SELECT v2 FROM t1 WHERE v1 IN ('?', '?', '?', '?' ) AND i = ?;
select "?" as "?";
SELECT @@?;
select @? = CONVERT(@? USING ujis);
SELECT @?;
select @?, @?, @?=@?;
SELECT @?, @?;
SELECT @?, @?, @?, @?, @?, @?;
SELECT (@v:=a) <> (@v:=?) FROM t1;
select @?, coercibility(@?);
select @@?, @@?, @@?, @@?;
SELECT @?, @?, @?, @?;
SELECT user,host,password,insert_priv FROM user WHERE user=@? AND host=@?;

View File

@ -0,0 +1,60 @@
select count(*) from t1 where id not in (1,2);
select count(*) from t1 where match a against ('000000');
SELECT COUNT(*) FROM t1 WHERE MATCH(a) AGAINST("+awrd bwrd* +cwrd*" IN BOOLEAN MODE);
select count(*) from t1 where s1 < 0 or s1 is null;
SELECT COUNT(*) FROM t1 WHERE s1 = 1001;
select count(*) from t1 where x < -16;
select count(*) from t1 where x = -16;
select count(*) from t1 where x > -16;
select count(*) from t1 where x = 18446744073709551601;
select truncate(5678.123451,6);
select truncate(99999999999999999999999999999999999999,-31);
select v/10;
select uncompress("");
SELECT UNHEX('G');
select unhex(hex("foobar")), hex(unhex("1234567890ABCDEF")), unhex("345678"), unhex(NULL);
select UpdateXML('<a>a1<b>b1<c>c1</c>b2</b>a2</a>','/a/b/c','+++++++++');
select UpdateXML(@xml, '/a/@aa1', '');
SELECT USER(),CURRENT_USER(),@@LOCAL.external_user;
SELECT user(),current_user(),@@proxy_user;
SELECT user, host FROM mysql.user where user = 'CUser' order by 1,2;
select user, host, password, plugin, authentication_string from mysql.user where user = 'u1';
select userid,count(*) from t1 group by userid desc having 3 IN (1,COUNT(*));
select userid,count(*) from t1 group by userid desc having (count(*)+1) IN (4,3);
SELECT user_id FROM t1 WHERE request_id=9999999999999;
SELECT UserId FROM t1 WHERE UserId=22 group by Userid;
select userid,pmtotal,pmnew, (select count(rd) from t1 where toid=t2.userid) calc_total, (select count(rd) from t1 where rd=0 and toid=t2.userid) calc_new from t2 where userid in (select distinct toid from t1);
select yearweek("2000-01-01",0) as '2000', yearweek("2001-01-01",0) as '2001', yearweek("2002-01-01",0) as '2002',yearweek("2003-01-01",0) as '2003', yearweek("2004-01-01",0) as '2004', yearweek("2005-01-01",0) as '2005', yearweek("2006-01-01",0) as '2006';
select user() like "%@%";
select user,password,plugin,authentication_string from mysql.user where user like 'foo%';
select user, QUOTE(host) from mysql.user where user="mysqltest_8";
SELECT UTC_DATE();
select utext from t1 where utext like '%%';
SELECT _utf32 0x10001=_utf32 0x10002;
select _utf32'a' collate utf32_general_ci = 0xfffd;
SELECT _utf8 0x7E, _utf8 X'7E', _utf8 B'01111110';
select _utf8 0xD0B0D0B1D0B2 like concat(_utf8'%',_utf8 0xD0B1,_utf8 '%');
select _utf8'12' union select _latin1'12345';
SELECT utf8_f,MIN(comment) FROM t1 GROUP BY 1;
SELECT _utf8mb3'test';
select _utf8mb4 0xD0B0D0B1D0B2 like concat(_utf8mb4'%',_utf8mb4 0xD0B1,_utf8mb4 '%');
select (_utf8mb4 X'616263FF');
SELECT _utf8'test' COLLATE utf8_5624_2;
select (_utf8 X'616263FF');
select uuid() into @my_uuid;
SELECT v1.a, v2. b FROM v1 LEFT OUTER JOIN v2 ON (v1.a=v2.b) AND (v1.a >= 3) GROUP BY v1.a;
SELECT v1.f4 FROM v1 WHERE f1<>0 OR f2<>0 AND f4='v' AND (f2<>0 OR f3<>0 AND f5<>0 OR f4 LIKE '%b%');
select v1.r_object_id, v2.users_names from v1, v2where (v1.group_name='tstgroup1') and v2.r_object_id=v1.r_object_idorder by users_names;
SELECT v2 FROM t1 WHERE v1 IN ('f', 'd', 'h', 'u' ) AND i = 2;
select "-- comment # followed by another comment" as "-- more comments";# this should be removed
SELECT @@tx_isolation;
select @ujis4 = CONVERT(@utf84 USING ujis);
SELECT @user_var;
select @v1def1, @v1def2, @v1def1=@v1def2;
SELECT @v1, @v2;
SELECT @v5, @v6, @v7, @v8, @v9, @v10;
SELECT (@v:=a) <> (@v:=1) FROM t1;
select @v, coercibility(@v);
select @@version, @@version_comment, @@version_compile_machine, @@version_compile_os;
SELECT @x_str_1, @x_int_1, @x_int_2, @x_int_3;
SELECT user,host,password,insert_priv FROM user WHERE user=@u AND host=@h;

View File

@ -0,0 +1,18 @@
select md5("?") =?, sleep(?), rand(?);
select * from my1 where md5( "?" ) =?;
select md5( "?" ) =?;
select * from my1 where md5("?") =?;
select sleep (?);
select * from tst where lname='?';
select ? , ? , ? , ? , ? , ? from tst;
select * from tst where fname like '?';
select * from tst where lname like '?' order by fname;
insert into tst values ("?","?"),("?",null),("?","?");
drop table if exists tst;
create table tst(fname varchar(?), lname varchar(?));
update tst set lname ="?" where fname like '?' or lname like '?';
delete from tst where lname like '?' and fname like '?';
select ? from tst where fname='?' or lname like '?';
select ?,?,?,? from tst where name='?' or name='?' or name='?' or name='?';
select count(?), count(?), count(?), count(?), count (?),count( ? ) from tst ;

View File

@ -0,0 +1,18 @@
select md5("200000foo") =10, sleep(2), rand(100);
select * from my1 where md5( "110" ) =10;
select md5( "100foo" ) =10;
select * from my1 where md5("100") =10;
select sleep (2);
select * from tst where lname='Doe';
select 1 , 2 , 3 , 4 , 5 , 6 from tst;
select * from tst where fname like '%a%';
select * from tst where lname like '%e%' order by fname;
insert into tst values ("John","Doe"),("Plato",null),("Nietzsche","");
drop table if exists tst;
create table tst(fname varchar(30), lname varchar(30));
update tst set lname ="Human" where fname like '%a%' or lname like '%a%';
delete from tst where lname like '%man%' and fname like '%ard%';
select 100 from tst where fname='10' or lname like '%100%';
select 1,20,300,4000 from tst where name='1000' or name='200' or name='30' or name='4';
select count(1), count(10), count(100), count(2), count (20),count( 200 ) from tst ;