Commit e4bfb6f1 authored by Sergei Golubchik's avatar Sergei Golubchik

pbxt suite is now a main-pbxt overlay

parent e293bdb2
...@@ -37,6 +37,7 @@ insert into t1 values('def',null); ...@@ -37,6 +37,7 @@ insert into t1 values('def',null);
insert into t1 values(null,null); insert into t1 values(null,null);
insert into t1 values('ghi','ghi['); insert into t1 values('ghi','ghi[');
--sorted_result
select HIGH_PRIORITY s1 regexp s2 from t1; select HIGH_PRIORITY s1 regexp s2 from t1;
drop table t1; drop table t1;
...@@ -70,6 +70,7 @@ INSERT INTO t1 VALUES(1)| ...@@ -70,6 +70,7 @@ INSERT INTO t1 VALUES(1)|
--echo --echo
--echo ---> Log: --echo ---> Log:
--sorted_result
SELECT msg FROM log| SELECT msg FROM log|
--echo --echo
...@@ -91,6 +92,7 @@ INSERT INTO mysqltest2.t1 VALUES(1)| ...@@ -91,6 +92,7 @@ INSERT INTO mysqltest2.t1 VALUES(1)|
--echo --echo
--echo ---> Log: --echo ---> Log:
--sorted_result
SELECT msg FROM mysqltest2.log| SELECT msg FROM mysqltest2.log|
--echo --echo
......
if (!`SELECT count(*) FROM information_schema.engines WHERE
(support = 'YES' OR support = 'DEFAULT') AND
engine = 'pbxt'`){
skip Need PBXT engine;
}
...@@ -3,8 +3,8 @@ CREATE TABLE t1 (a int, unique (a), b int not null, unique(b), c int not null, i ...@@ -3,8 +3,8 @@ CREATE TABLE t1 (a int, unique (a), b int not null, unique(b), c int not null, i
replace into t1 values (1,1,1),(2,2,2),(3,1,3); replace into t1 values (1,1,1),(2,2,2),(3,1,3);
select * from t1; select * from t1;
a b c a b c
3 1 3
2 2 2 2 2 2
3 1 3
check table t1; check table t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 check status OK test.t1 check status OK
......
...@@ -310,7 +310,7 @@ create table t1 (,b int); ...@@ -310,7 +310,7 @@ create table t1 (,b int);
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'b int)' at line 1 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'b int)' at line 1
create table t1 (a int, key(a)); create table t1 (a int, key(a));
create table t2 (b int, foreign key(b) references t1(a), key(b)); create table t2 (b int, foreign key(b) references t1(a), key(b));
drop table if exists t1,t2; drop table if exists t2,t1;
create table t1(id int not null, name char(20)); create table t1(id int not null, name char(20));
insert into t1 values(10,'mysql'),(20,'monty- the creator'); insert into t1 values(10,'mysql'),(20,'monty- the creator');
create table t2(id int not null); create table t2(id int not null);
......
...@@ -2973,6 +2973,9 @@ insert into t1 values(null,null); ...@@ -2973,6 +2973,9 @@ insert into t1 values(null,null);
insert into t1 values('ghi','ghi['); insert into t1 values('ghi','ghi[');
select HIGH_PRIORITY s1 regexp s2 from t1; select HIGH_PRIORITY s1 regexp s2 from t1;
s1 regexp s2 s1 regexp s2
0
0
0
1 1
1 1
1 1
...@@ -2980,9 +2983,6 @@ s1 regexp s2 ...@@ -2980,9 +2983,6 @@ s1 regexp s2
1 1
1 1
1 1
0
0
0
NULL NULL
NULL NULL
NULL NULL
......
...@@ -1158,6 +1158,9 @@ insert into t1 values(null,null); ...@@ -1158,6 +1158,9 @@ insert into t1 values(null,null);
insert into t1 values('ghi','ghi['); insert into t1 values('ghi','ghi[');
select HIGH_PRIORITY s1 regexp s2 from t1; select HIGH_PRIORITY s1 regexp s2 from t1;
s1 regexp s2 s1 regexp s2
0
0
0
1 1
1 1
1 1
...@@ -1165,9 +1168,6 @@ s1 regexp s2 ...@@ -1165,9 +1168,6 @@ s1 regexp s2
1 1
1 1
1 1
0
0
0
NULL NULL
NULL NULL
NULL NULL
......
...@@ -1005,6 +1005,9 @@ insert into t1 values(null,null); ...@@ -1005,6 +1005,9 @@ insert into t1 values(null,null);
insert into t1 values('ghi','ghi['); insert into t1 values('ghi','ghi[');
select HIGH_PRIORITY s1 regexp s2 from t1; select HIGH_PRIORITY s1 regexp s2 from t1;
s1 regexp s2 s1 regexp s2
0
0
0
1 1
1 1
1 1
...@@ -1012,9 +1015,6 @@ s1 regexp s2 ...@@ -1012,9 +1015,6 @@ s1 regexp s2
1 1
1 1
1 1
0
0
0
NULL NULL
NULL NULL
NULL NULL
......
...@@ -2353,6 +2353,9 @@ insert into t1 values(null,null); ...@@ -2353,6 +2353,9 @@ insert into t1 values(null,null);
insert into t1 values('ghi','ghi['); insert into t1 values('ghi','ghi[');
select HIGH_PRIORITY s1 regexp s2 from t1; select HIGH_PRIORITY s1 regexp s2 from t1;
s1 regexp s2 s1 regexp s2
0
0
0
1 1
1 1
1 1
...@@ -2360,9 +2363,6 @@ s1 regexp s2 ...@@ -2360,9 +2363,6 @@ s1 regexp s2
1 1
1 1
1 1
0
0
0
NULL NULL
NULL NULL
NULL NULL
......
...@@ -1012,6 +1012,9 @@ insert into t1 values(null,null); ...@@ -1012,6 +1012,9 @@ insert into t1 values(null,null);
insert into t1 values('ghi','ghi['); insert into t1 values('ghi','ghi[');
select HIGH_PRIORITY s1 regexp s2 from t1; select HIGH_PRIORITY s1 regexp s2 from t1;
s1 regexp s2 s1 regexp s2
0
0
0
1 1
1 1
1 1
...@@ -1019,9 +1022,6 @@ s1 regexp s2 ...@@ -1019,9 +1022,6 @@ s1 regexp s2
1 1
1 1
1 1
0
0
0
NULL NULL
NULL NULL
NULL NULL
......
...@@ -2353,6 +2353,9 @@ insert into t1 values(null,null); ...@@ -2353,6 +2353,9 @@ insert into t1 values(null,null);
insert into t1 values('ghi','ghi['); insert into t1 values('ghi','ghi[');
select HIGH_PRIORITY s1 regexp s2 from t1; select HIGH_PRIORITY s1 regexp s2 from t1;
s1 regexp s2 s1 regexp s2
0
0
0
1 1
1 1
1 1
...@@ -2360,9 +2363,6 @@ s1 regexp s2 ...@@ -2360,9 +2363,6 @@ s1 regexp s2
1 1
1 1
1 1
0
0
0
NULL NULL
NULL NULL
NULL NULL
......
...@@ -299,6 +299,9 @@ insert into t1 values(null,null); ...@@ -299,6 +299,9 @@ insert into t1 values(null,null);
insert into t1 values('ghi','ghi['); insert into t1 values('ghi','ghi[');
select HIGH_PRIORITY s1 regexp s2 from t1; select HIGH_PRIORITY s1 regexp s2 from t1;
s1 regexp s2 s1 regexp s2
0
0
0
1 1
1 1
1 1
...@@ -306,9 +309,6 @@ s1 regexp s2 ...@@ -306,9 +309,6 @@ s1 regexp s2
1 1
1 1
1 1
0
0
0
NULL NULL
NULL NULL
NULL NULL
......
...@@ -299,6 +299,9 @@ insert into t1 values(null,null); ...@@ -299,6 +299,9 @@ insert into t1 values(null,null);
insert into t1 values('ghi','ghi['); insert into t1 values('ghi','ghi[');
select HIGH_PRIORITY s1 regexp s2 from t1; select HIGH_PRIORITY s1 regexp s2 from t1;
s1 regexp s2 s1 regexp s2
0
0
0
1 1
1 1
1 1
...@@ -306,9 +309,6 @@ s1 regexp s2 ...@@ -306,9 +309,6 @@ s1 regexp s2
1 1
1 1
1 1
0
0
0
NULL NULL
NULL NULL
NULL NULL
......
...@@ -289,6 +289,9 @@ insert into t1 values(null,null); ...@@ -289,6 +289,9 @@ insert into t1 values(null,null);
insert into t1 values('ghi','ghi['); insert into t1 values('ghi','ghi[');
select HIGH_PRIORITY s1 regexp s2 from t1; select HIGH_PRIORITY s1 regexp s2 from t1;
s1 regexp s2 s1 regexp s2
0
0
0
1 1
1 1
1 1
...@@ -296,9 +299,6 @@ s1 regexp s2 ...@@ -296,9 +299,6 @@ s1 regexp s2
1 1
1 1
1 1
0
0
0
NULL NULL
NULL NULL
NULL NULL
......
...@@ -299,6 +299,9 @@ insert into t1 values(null,null); ...@@ -299,6 +299,9 @@ insert into t1 values(null,null);
insert into t1 values('ghi','ghi['); insert into t1 values('ghi','ghi[');
select HIGH_PRIORITY s1 regexp s2 from t1; select HIGH_PRIORITY s1 regexp s2 from t1;
s1 regexp s2 s1 regexp s2
0
0
0
1 1
1 1
1 1
...@@ -306,9 +309,6 @@ s1 regexp s2 ...@@ -306,9 +309,6 @@ s1 regexp s2
1 1
1 1
1 1
0
0
0
NULL NULL
NULL NULL
NULL NULL
......
...@@ -299,6 +299,9 @@ insert into t1 values(null,null); ...@@ -299,6 +299,9 @@ insert into t1 values(null,null);
insert into t1 values('ghi','ghi['); insert into t1 values('ghi','ghi[');
select HIGH_PRIORITY s1 regexp s2 from t1; select HIGH_PRIORITY s1 regexp s2 from t1;
s1 regexp s2 s1 regexp s2
0
0
0
1 1
1 1
1 1
...@@ -306,9 +309,6 @@ s1 regexp s2 ...@@ -306,9 +309,6 @@ s1 regexp s2
1 1
1 1
1 1
0
0
0
NULL NULL
NULL NULL
NULL NULL
......
...@@ -1395,18 +1395,18 @@ INSERT INTO t1 VALUES(1)| ...@@ -1395,18 +1395,18 @@ INSERT INTO t1 VALUES(1)|
---> Log: ---> Log:
SELECT msg FROM log| SELECT msg FROM log|
msg msg
utf8_unicode_ci koi8r
koi8r
koi8r_general_ci koi8r_general_ci
koi8r_general_ci koi8r_general_ci
utf8_general_ci
koi8r_general_ci koi8r_general_ci
koi8r
utf8_general_ci
koi8r_general_ci koi8r_general_ci
koi8r_general_ci koi8r_general_ci
utf8_general_ci
koi8r_general_ci koi8r_general_ci
koi8r utf8_general_ci
utf8_general_ci
utf8_general_ci
utf8_unicode_ci
SELECT SELECT
COLLATION(@a1) AS ca1, COLLATION(@a1) AS ca1,
...@@ -1426,18 +1426,18 @@ INSERT INTO mysqltest2.t1 VALUES(1)| ...@@ -1426,18 +1426,18 @@ INSERT INTO mysqltest2.t1 VALUES(1)|
---> Log: ---> Log:
SELECT msg FROM mysqltest2.log| SELECT msg FROM mysqltest2.log|
msg msg
utf8_unicode_ci koi8r
koi8r
koi8r_general_ci koi8r_general_ci
koi8r_general_ci koi8r_general_ci
utf8_general_ci
koi8r_general_ci koi8r_general_ci
koi8r
utf8_general_ci
koi8r_general_ci koi8r_general_ci
koi8r_general_ci koi8r_general_ci
utf8_general_ci
koi8r_general_ci koi8r_general_ci
koi8r utf8_general_ci
utf8_general_ci
utf8_general_ci
utf8_unicode_ci
SELECT SELECT
COLLATION(@a1) AS ca1, COLLATION(@a1) AS ca1,
...@@ -1668,18 +1668,18 @@ INSERT INTO t1 VALUES(1)| ...@@ -1668,18 +1668,18 @@ INSERT INTO t1 VALUES(1)|
---> Log: ---> Log:
SELECT msg FROM log| SELECT msg FROM log|
msg msg
utf8_unicode_ci koi8r
koi8r
koi8r_general_ci koi8r_general_ci
koi8r_general_ci koi8r_general_ci
utf8_general_ci
koi8r_general_ci koi8r_general_ci
koi8r
utf8_general_ci
koi8r_general_ci koi8r_general_ci
koi8r_general_ci koi8r_general_ci
utf8_general_ci
koi8r_general_ci koi8r_general_ci
koi8r utf8_general_ci
utf8_general_ci
utf8_general_ci
utf8_unicode_ci
SELECT SELECT
COLLATION(@a1) AS ca1, COLLATION(@a1) AS ca1,
...@@ -1699,18 +1699,18 @@ INSERT INTO mysqltest2.t1 VALUES(1)| ...@@ -1699,18 +1699,18 @@ INSERT INTO mysqltest2.t1 VALUES(1)|
---> Log: ---> Log:
SELECT msg FROM mysqltest2.log| SELECT msg FROM mysqltest2.log|
msg msg
utf8_unicode_ci koi8r
koi8r
koi8r_general_ci koi8r_general_ci
koi8r_general_ci koi8r_general_ci
utf8_general_ci
koi8r_general_ci koi8r_general_ci
koi8r
utf8_general_ci
koi8r_general_ci koi8r_general_ci
koi8r_general_ci koi8r_general_ci
utf8_general_ci
koi8r_general_ci koi8r_general_ci
koi8r utf8_general_ci
utf8_general_ci
utf8_general_ci
utf8_unicode_ci
SELECT SELECT
COLLATION(@a1) AS ca1, COLLATION(@a1) AS ca1,
...@@ -2103,18 +2103,18 @@ INSERT INTO t1 VALUES(1)| ...@@ -2103,18 +2103,18 @@ INSERT INTO t1 VALUES(1)|
---> Log: ---> Log:
SELECT msg FROM log| SELECT msg FROM log|
msg msg
utf8_unicode_ci koi8r
koi8r
koi8r_general_ci koi8r_general_ci
koi8r_general_ci koi8r_general_ci
utf8_general_ci
koi8r_general_ci koi8r_general_ci
koi8r
utf8_general_ci
koi8r_general_ci koi8r_general_ci
koi8r_general_ci koi8r_general_ci
utf8_general_ci
koi8r_general_ci koi8r_general_ci
koi8r utf8_general_ci
utf8_general_ci
utf8_general_ci
utf8_unicode_ci
SELECT SELECT
COLLATION(@a1) AS ca1, COLLATION(@a1) AS ca1,
...@@ -2134,18 +2134,18 @@ INSERT INTO mysqltest2.t1 VALUES(1)| ...@@ -2134,18 +2134,18 @@ INSERT INTO mysqltest2.t1 VALUES(1)|
---> Log: ---> Log:
SELECT msg FROM mysqltest2.log| SELECT msg FROM mysqltest2.log|
msg msg
utf8_unicode_ci koi8r
koi8r
koi8r_general_ci koi8r_general_ci
koi8r_general_ci koi8r_general_ci
utf8_general_ci
koi8r_general_ci koi8r_general_ci
koi8r
utf8_general_ci
koi8r_general_ci koi8r_general_ci
koi8r_general_ci koi8r_general_ci
utf8_general_ci
koi8r_general_ci koi8r_general_ci
koi8r utf8_general_ci
utf8_general_ci
utf8_general_ci
utf8_unicode_ci
SELECT SELECT
COLLATION(@a1) AS ca1, COLLATION(@a1) AS ca1,
......
...@@ -1395,18 +1395,18 @@ INSERT INTO t1 VALUES(1)| ...@@ -1395,18 +1395,18 @@ INSERT INTO t1 VALUES(1)|
---> Log: ---> Log:
SELECT msg FROM log| SELECT msg FROM log|
msg msg
utf8_unicode_ci koi8r_general_ci
koi8r_general_ci
utf8
utf8
utf8_general_ci utf8_general_ci
utf8_general_ci utf8_general_ci
koi8r_general_ci
utf8_general_ci utf8_general_ci
utf8
utf8_general_ci utf8_general_ci
utf8_general_ci utf8_general_ci
utf8_general_ci utf8_general_ci
koi8r_general_ci
utf8_general_ci utf8_general_ci
utf8 utf8_unicode_ci
SELECT SELECT
COLLATION(@a1) AS ca1, COLLATION(@a1) AS ca1,
...@@ -1426,18 +1426,18 @@ INSERT INTO mysqltest2.t1 VALUES(1)| ...@@ -1426,18 +1426,18 @@ INSERT INTO mysqltest2.t1 VALUES(1)|
---> Log: ---> Log:
SELECT msg FROM mysqltest2.log| SELECT msg FROM mysqltest2.log|
msg msg
utf8_unicode_ci koi8r_general_ci
koi8r_general_ci
utf8
utf8
utf8_general_ci utf8_general_ci
utf8_general_ci utf8_general_ci
koi8r_general_ci
utf8_general_ci utf8_general_ci
utf8
utf8_general_ci utf8_general_ci
utf8_general_ci utf8_general_ci
utf8_general_ci utf8_general_ci
koi8r_general_ci
utf8_general_ci utf8_general_ci
utf8 utf8_unicode_ci
SELECT SELECT
COLLATION(@a1) AS ca1, COLLATION(@a1) AS ca1,
...@@ -1668,18 +1668,18 @@ INSERT INTO t1 VALUES(1)| ...@@ -1668,18 +1668,18 @@ INSERT INTO t1 VALUES(1)|
---> Log: ---> Log:
SELECT msg FROM log| SELECT msg FROM log|
msg msg
utf8_unicode_ci koi8r_general_ci
koi8r_general_ci
utf8
utf8
utf8_general_ci utf8_general_ci
utf8_general_ci utf8_general_ci
koi8r_general_ci
utf8_general_ci utf8_general_ci
utf8
utf8_general_ci utf8_general_ci
utf8_general_ci utf8_general_ci
utf8_general_ci utf8_general_ci
koi8r_general_ci
utf8_general_ci utf8_general_ci
utf8 utf8_unicode_ci
SELECT SELECT
COLLATION(@a1) AS ca1, COLLATION(@a1) AS ca1,
...@@ -1699,18 +1699,18 @@ INSERT INTO mysqltest2.t1 VALUES(1)| ...@@ -1699,18 +1699,18 @@ INSERT INTO mysqltest2.t1 VALUES(1)|
---> Log: ---> Log:
SELECT msg FROM mysqltest2.log| SELECT msg FROM mysqltest2.log|
msg msg
utf8_unicode_ci koi8r_general_ci
koi8r_general_ci
utf8
utf8
utf8_general_ci utf8_general_ci
utf8_general_ci utf8_general_ci
koi8r_general_ci
utf8_general_ci utf8_general_ci
utf8
utf8_general_ci utf8_general_ci
utf8_general_ci utf8_general_ci
utf8_general_ci utf8_general_ci
koi8r_general_ci
utf8_general_ci utf8_general_ci
utf8 utf8_unicode_ci
SELECT SELECT
COLLATION(@a1) AS ca1, COLLATION(@a1) AS ca1,
...@@ -2103,18 +2103,18 @@ INSERT INTO t1 VALUES(1)| ...@@ -2103,18 +2103,18 @@ INSERT INTO t1 VALUES(1)|
---> Log: ---> Log:
SELECT msg FROM log| SELECT msg FROM log|
msg msg
utf8_unicode_ci koi8r_general_ci
koi8r_general_ci
utf8
utf8
utf8_general_ci utf8_general_ci
utf8_general_ci utf8_general_ci
koi8r_general_ci
utf8_general_ci utf8_general_ci
utf8
utf8_general_ci utf8_general_ci
utf8_general_ci utf8_general_ci
utf8_general_ci utf8_general_ci
koi8r_general_ci
utf8_general_ci utf8_general_ci
utf8 utf8_unicode_ci
SELECT SELECT
COLLATION(@a1) AS ca1, COLLATION(@a1) AS ca1,
...@@ -2134,18 +2134,18 @@ INSERT INTO mysqltest2.t1 VALUES(1)| ...@@ -2134,18 +2134,18 @@ INSERT INTO mysqltest2.t1 VALUES(1)|
---> Log: ---> Log:
SELECT msg FROM mysqltest2.log| SELECT msg FROM mysqltest2.log|
msg msg
utf8_unicode_ci koi8r_general_ci
koi8r_general_ci
utf8
utf8
utf8_general_ci utf8_general_ci
utf8_general_ci utf8_general_ci
koi8r_general_ci
utf8_general_ci utf8_general_ci
utf8
utf8_general_ci utf8_general_ci
utf8_general_ci utf8_general_ci
utf8_general_ci utf8_general_ci
koi8r_general_ci
utf8_general_ci utf8_general_ci
utf8 utf8_unicode_ci
SELECT SELECT
COLLATION(@a1) AS ca1, COLLATION(@a1) AS ca1,
......
...@@ -28,6 +28,9 @@ insert into t1 values(null,null); ...@@ -28,6 +28,9 @@ insert into t1 values(null,null);
insert into t1 values('ghi','ghi['); insert into t1 values('ghi','ghi[');
select HIGH_PRIORITY s1 regexp s2 from t1; select HIGH_PRIORITY s1 regexp s2 from t1;
s1 regexp s2 s1 regexp s2
0
0
0
1 1
1 1
1 1
...@@ -35,9 +38,6 @@ s1 regexp s2 ...@@ -35,9 +38,6 @@ s1 regexp s2
1 1
1 1
1 1
0
0
0
NULL NULL
NULL NULL
NULL NULL
......
...@@ -410,18 +410,18 @@ ID Name Country Population ...@@ -410,18 +410,18 @@ ID Name Country Population
SELECT * FROM City SELECT * FROM City
WHERE Name BETWEEN 'G' AND 'K' AND Population > 500000 AND Country LIKE 'C%'; WHERE Name BETWEEN 'G' AND 'K' AND Population > 500000 AND Country LIKE 'C%';
ID Name Country Population ID Name Country Population
1914 Guiyang CHN 1465200
1928 Handan CHN 840000
1905 Hangzhou CHN 2190500
1895 Harbin CHN 4289800 1895 Harbin CHN 4289800
1904 Jinan CHN 2278100
1905 Hangzhou CHN 2190500
1914 Guiyang CHN 1465200
1916 Hefei CHN 1369100 1916 Hefei CHN 1369100
1950 Hegang CHN 520000 1923 Jilin CHN 1040000
1927 Hohhot CHN 916700 1927 Hohhot CHN 916700
1928 Handan CHN 840000
1937 Huainan CHN 700000 1937 Huainan CHN 700000
1923 Jilin CHN 1040000
1904 Jinan CHN 2278100
1944 Jinzhou CHN 570000
1938 Jixi CHN 683885 1938 Jixi CHN 683885
1944 Jinzhou CHN 570000
1950 Hegang CHN 520000
SELECT COUNT(*) FROM City WHERE ID BETWEEN 501 AND 1000; SELECT COUNT(*) FROM City WHERE ID BETWEEN 501 AND 1000;
COUNT(*) COUNT(*)
500 500
...@@ -768,15 +768,15 @@ ID Name Country Population ...@@ -768,15 +768,15 @@ ID Name Country Population
SELECT * FROM City WHERE SELECT * FROM City WHERE
Name LIKE 'M%' AND Population > 1500000; Name LIKE 'M%' AND Population > 1500000;
ID Name Country Population ID Name Country Population
131 Melbourne AUS 2865329
653 Madrid ESP 2879052
766 Manila PHL 1581082
942 Medan IDN 1843919
1024 Mumbai (Bombay) IND 10500000 1024 Mumbai (Bombay) IND 10500000
131 Melbourne AUS 2865329
1381 Mashhad IRN 1887405 1381 Mashhad IRN 1887405
2259 Medellín COL 1861265 2259 Medellín COL 1861265
3520 Minsk BLR 1674000 3520 Minsk BLR 1674000
3580 Moscow RUS 8389200 3580 Moscow RUS 8389200
653 Madrid ESP 2879052
766 Manila PHL 1581082
942 Medan IDN 1843919
SELECT * FROM City SELECT * FROM City
WHERE Name BETWEEN 'G' AND 'J' AND Population > 700000 AND Country LIKE 'B%'; WHERE Name BETWEEN 'G' AND 'J' AND Population > 700000 AND Country LIKE 'B%';
ID Name Country Population ID Name Country Population
...@@ -785,14 +785,14 @@ ID Name Country Population ...@@ -785,14 +785,14 @@ ID Name Country Population
SELECT * FROM City SELECT * FROM City
WHERE Name BETWEEN 'G' AND 'J' AND Population > 500000 AND Country LIKE 'C%'; WHERE Name BETWEEN 'G' AND 'J' AND Population > 500000 AND Country LIKE 'C%';
ID Name Country Population ID Name Country Population
1914 Guiyang CHN 1465200
1928 Handan CHN 840000
1905 Hangzhou CHN 2190500
1895 Harbin CHN 4289800 1895 Harbin CHN 4289800
1905 Hangzhou CHN 2190500
1914 Guiyang CHN 1465200
1916 Hefei CHN 1369100 1916 Hefei CHN 1369100
1950 Hegang CHN 520000
1927 Hohhot CHN 916700 1927 Hohhot CHN 916700
1928 Handan CHN 840000
1937 Huainan CHN 700000 1937 Huainan CHN 700000
1950 Hegang CHN 520000
SELECT * FROM City SELECT * FROM City
WHERE ID BETWEEN 1 AND 500 AND Population > 1000000 AND Country LIKE 'A%'; WHERE ID BETWEEN 1 AND 500 AND Population > 1000000 AND Country LIKE 'A%';
ID Name Country Population ID Name Country Population
...@@ -1039,8 +1039,8 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -1039,8 +1039,8 @@ id select_type table type possible_keys key key_len ref rows Extra
SELECT * FROM t1 SELECT * FROM t1
WHERE (f1 < 535 OR f1 > 985) AND ( f4='r' OR f4 LIKE 'a%' ) ; WHERE (f1 < 535 OR f1 > 985) AND ( f4='r' OR f4 LIKE 'a%' ) ;
f1 f4 f5 f1 f4 f5
994 r 2
996 A 2 996 A 2
998 a 0 998 a 0
994 r 2
DROP TABLE t1; DROP TABLE t1;
SET SESSION optimizer_switch='index_merge_sort_intersection=on'; SET SESSION optimizer_switch='index_merge_sort_intersection=on';
...@@ -769,15 +769,15 @@ ID Name Country Population ...@@ -769,15 +769,15 @@ ID Name Country Population
SELECT * FROM City WHERE SELECT * FROM City WHERE
Name LIKE 'M%' AND Population > 1500000; Name LIKE 'M%' AND Population > 1500000;
ID Name Country Population ID Name Country Population
131 Melbourne AUS 2865329
653 Madrid ESP 2879052
766 Manila PHL 1581082
942 Medan IDN 1843919
1024 Mumbai (Bombay) IND 10500000 1024 Mumbai (Bombay) IND 10500000
131 Melbourne AUS 2865329
1381 Mashhad IRN 1887405 1381 Mashhad IRN 1887405
2259 Medellín COL 1861265 2259 Medellín COL 1861265
3520 Minsk BLR 1674000 3520 Minsk BLR 1674000
3580 Moscow RUS 8389200 3580 Moscow RUS 8389200
653 Madrid ESP 2879052
766 Manila PHL 1581082
942 Medan IDN 1843919
SELECT * FROM City SELECT * FROM City
WHERE Name BETWEEN 'G' AND 'J' AND Population > 700000 AND Country LIKE 'B%'; WHERE Name BETWEEN 'G' AND 'J' AND Population > 700000 AND Country LIKE 'B%';
ID Name Country Population ID Name Country Population
......
...@@ -571,8 +571,8 @@ replace into t1 select * from t2; ...@@ -571,8 +571,8 @@ replace into t1 select * from t2;
select * from t1; select * from t1;
a b a b
1 t1:1 1 t1:1
3 t2:3
2 t2:2 2 t2:2
3 t2:3
drop table t1,t2; drop table t1,t2;
CREATE TABLE t1 ( USID INTEGER UNSIGNED, ServerID TINYINT UNSIGNED, State ENUM ('unknown', 'Access-Granted', 'Session-Active', 'Session-Closed' ) NOT NULL DEFAULT 'unknown', SessionID CHAR(32), User CHAR(32) NOT NULL DEFAULT '<UNKNOWN>', NASAddr INTEGER UNSIGNED, NASPort INTEGER UNSIGNED, NASPortType INTEGER UNSIGNED, ConnectSpeed INTEGER UNSIGNED, CarrierType CHAR(32), CallingStationID CHAR(32), CalledStationID CHAR(32), AssignedAddr INTEGER UNSIGNED, SessionTime INTEGER UNSIGNED, PacketsIn INTEGER UNSIGNED, OctetsIn INTEGER UNSIGNED, PacketsOut INTEGER UNSIGNED, OctetsOut INTEGER UNSIGNED, TerminateCause INTEGER UNSIGNED, UnauthTime TINYINT UNSIGNED, AccessRequestTime DATETIME, AcctStartTime DATETIME, AcctLastTime DATETIME, LastModification TIMESTAMP NOT NULL); CREATE TABLE t1 ( USID INTEGER UNSIGNED, ServerID TINYINT UNSIGNED, State ENUM ('unknown', 'Access-Granted', 'Session-Active', 'Session-Closed' ) NOT NULL DEFAULT 'unknown', SessionID CHAR(32), User CHAR(32) NOT NULL DEFAULT '<UNKNOWN>', NASAddr INTEGER UNSIGNED, NASPort INTEGER UNSIGNED, NASPortType INTEGER UNSIGNED, ConnectSpeed INTEGER UNSIGNED, CarrierType CHAR(32), CallingStationID CHAR(32), CalledStationID CHAR(32), AssignedAddr INTEGER UNSIGNED, SessionTime INTEGER UNSIGNED, PacketsIn INTEGER UNSIGNED, OctetsIn INTEGER UNSIGNED, PacketsOut INTEGER UNSIGNED, OctetsOut INTEGER UNSIGNED, TerminateCause INTEGER UNSIGNED, UnauthTime TINYINT UNSIGNED, AccessRequestTime DATETIME, AcctStartTime DATETIME, AcctLastTime DATETIME, LastModification TIMESTAMP NOT NULL);
CREATE TABLE t2 ( USID INTEGER UNSIGNED AUTO_INCREMENT, ServerID TINYINT UNSIGNED, State ENUM ('unknown', 'Access-Granted', 'Session-Active', 'Session-Closed' ) NOT NULL DEFAULT 'unknown', SessionID CHAR(32), User TEXT NOT NULL, NASAddr INTEGER UNSIGNED, NASPort INTEGER UNSIGNED, NASPortType INTEGER UNSIGNED, ConnectSpeed INTEGER UNSIGNED, CarrierType CHAR(32), CallingStationID CHAR(32), CalledStationID CHAR(32), AssignedAddr INTEGER UNSIGNED, SessionTime INTEGER UNSIGNED, PacketsIn INTEGER UNSIGNED, OctetsIn INTEGER UNSIGNED, PacketsOut INTEGER UNSIGNED, OctetsOut INTEGER UNSIGNED, TerminateCause INTEGER UNSIGNED, UnauthTime TINYINT UNSIGNED, AccessRequestTime DATETIME, AcctStartTime DATETIME, AcctLastTime DATETIME, LastModification TIMESTAMP NOT NULL, INDEX(USID,ServerID,NASAddr,SessionID), INDEX(AssignedAddr)); CREATE TABLE t2 ( USID INTEGER UNSIGNED AUTO_INCREMENT, ServerID TINYINT UNSIGNED, State ENUM ('unknown', 'Access-Granted', 'Session-Active', 'Session-Closed' ) NOT NULL DEFAULT 'unknown', SessionID CHAR(32), User TEXT NOT NULL, NASAddr INTEGER UNSIGNED, NASPort INTEGER UNSIGNED, NASPortType INTEGER UNSIGNED, ConnectSpeed INTEGER UNSIGNED, CarrierType CHAR(32), CallingStationID CHAR(32), CalledStationID CHAR(32), AssignedAddr INTEGER UNSIGNED, SessionTime INTEGER UNSIGNED, PacketsIn INTEGER UNSIGNED, OctetsIn INTEGER UNSIGNED, PacketsOut INTEGER UNSIGNED, OctetsOut INTEGER UNSIGNED, TerminateCause INTEGER UNSIGNED, UnauthTime TINYINT UNSIGNED, AccessRequestTime DATETIME, AcctStartTime DATETIME, AcctLastTime DATETIME, LastModification TIMESTAMP NOT NULL, INDEX(USID,ServerID,NASAddr,SessionID), INDEX(AssignedAddr));
...@@ -763,9 +763,9 @@ SELECT f1, f1 FROM t2 src WHERE f1 < 2 ...@@ -763,9 +763,9 @@ SELECT f1, f1 FROM t2 src WHERE f1 < 2
ON DUPLICATE KEY UPDATE f1 = 100 + src.f1; ON DUPLICATE KEY UPDATE f1 = 100 + src.f1;
SELECT * FROM t2; SELECT * FROM t2;
f1 f2 f1 f2
10 10
101 1 101 1
2 2 2 2
10 10
DROP TABLE t1, t2; DROP TABLE t1, t2;
CREATE TABLE t1 ( a INT KEY, b INT ); CREATE TABLE t1 ( a INT KEY, b INT );
INSERT INTO t1 VALUES ( 0, 1 ); INSERT INTO t1 VALUES ( 0, 1 );
......
...@@ -1479,14 +1479,14 @@ SELECT @@GLOBAL.server_id; ...@@ -1479,14 +1479,14 @@ SELECT @@GLOBAL.server_id;
@@GLOBAL.server_id @@GLOBAL.server_id
0 0
SET GLOBAL server_id = @old_server_id; SET GLOBAL server_id = @old_server_id;
SELECT @@GLOBAL.INIT_FILE, @@GLOBAL.INIT_FILE IS NULL; SELECT @@GLOBAL.INIT_CONNECT, @@GLOBAL.INIT_CONNECT IS NULL;
@@GLOBAL.INIT_FILE @@GLOBAL.INIT_FILE IS NULL @@GLOBAL.INIT_CONNECT @@GLOBAL.INIT_CONNECT IS NULL
NULL 1 1
CREATE TABLE t1 (a INT); CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (); INSERT INTO t1 VALUES ();
SET @bug42778= @@sql_safe_updates; SET @bug42778= @@sql_safe_updates;
SET @@sql_safe_updates= 0; SET @@sql_safe_updates= 0;
DELETE FROM t1 ORDER BY (@@GLOBAL.INIT_FILE) ASC LIMIT 10; DELETE FROM t1 ORDER BY (@@GLOBAL.INIT_CONNECT) ASC LIMIT 10;
SET @@sql_safe_updates= @bug42778; SET @@sql_safe_updates= @bug42778;
DROP TABLE t1; DROP TABLE t1;
# #
......
# Use default setting for mysqld processes
!include include/default_mysqld.cnf
[mysqld.1]
pbxt
default-storage-engine=pbxt
[ENV]
MASTER_MYSOCK= @mysqld.1.socket
MASTER_MYPORT= @mysqld.1.port
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
cont_nr int(11) NOT NULL auto_increment,
ver_nr int(11) NOT NULL default '0',
aufnr int(11) NOT NULL default '0',
username varchar(50) NOT NULL default '',
hdl_nr int(11) NOT NULL default '0',
eintrag date NOT NULL default '0000-00-00',
st_klasse varchar(40) NOT NULL default '',
st_wert varchar(40) NOT NULL default '',
st_zusatz varchar(40) NOT NULL default '',
st_bemerkung varchar(255) NOT NULL default '',
kunden_art varchar(40) NOT NULL default '',
mcbs_knr int(11) default NULL,
mcbs_aufnr int(11) NOT NULL default '0',
schufa_status char(1) default '?',
bemerkung text,
wirknetz text,
wf_igz int(11) NOT NULL default '0',
tarifcode varchar(80) default NULL,
recycle char(1) default NULL,
sim varchar(30) default NULL,
mcbs_tpl varchar(30) default NULL,
emp_nr int(11) NOT NULL default '0',
laufzeit int(11) default NULL,
hdl_name varchar(30) default NULL,
prov_hdl_nr int(11) NOT NULL default '0',
auto_wirknetz varchar(50) default NULL,
auto_billing varchar(50) default NULL,
touch timestamp NOT NULL,
kategorie varchar(50) default NULL,
kundentyp varchar(20) NOT NULL default '',
sammel_rech_msisdn varchar(30) NOT NULL default '',
p_nr varchar(9) NOT NULL default '',
suffix char(3) NOT NULL default '',
PRIMARY KEY (cont_nr),
KEY idx_aufnr(aufnr),
KEY idx_hdl_nr(hdl_nr),
KEY idx_st_klasse(st_klasse),
KEY ver_nr(ver_nr),
KEY eintrag_idx(eintrag),
KEY emp_nr_idx(emp_nr),
KEY wf_igz(wf_igz),
KEY touch(touch),
KEY hdl_tag(eintrag,hdl_nr),
KEY prov_hdl_nr(prov_hdl_nr),
KEY mcbs_aufnr(mcbs_aufnr),
KEY kundentyp(kundentyp),
KEY p_nr(p_nr,suffix)
) ENGINE=MyISAM;
INSERT INTO t1 VALUES (3359356,405,3359356,'Mustermann Musterfrau',52500,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprft','','privat',1485525,2122316,'+','','N',1909160,'MobilComSuper92000D2',NULL,NULL,'MS9ND2',3,24,'MobilCom Shop Koeln',52500,NULL,'auto',20010202105916,'Mobilfunk','PP','','','');
INSERT INTO t1 VALUES (3359357,468,3359357,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprft','','privat',1503580,2139699,'+','','P',1909171,'MobilComSuper9D1T10SFreisprech(Akquise)',NULL,NULL,'MS9NS1',327,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','','');
INSERT INTO t1 VALUES (3359358,407,3359358,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprft','','privat',1501358,2137473,'N','','N',1909159,'MobilComSuper92000D2',NULL,NULL,'MS9ND2',325,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','','');
INSERT INTO t1 VALUES (3359359,468,3359359,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprft','','privat',1507831,2143894,'+','','P',1909162,'MobilComSuper9D1T10SFreisprech(Akquise)',NULL,NULL,'MS9NS1',327,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','','');
INSERT INTO t1 VALUES (3359360,0,0,'Mustermann Musterfrau',29674907,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprft','','privat',1900169997,2414578,'+',NULL,'N',1909148,'',NULL,NULL,'RV99066_2',20,NULL,'POS',29674907,NULL,NULL,20010202105916,'Mobilfunk','','','97317481','007');
INSERT INTO t1 VALUES (3359361,406,3359361,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag storniert','','(7001-84):Storno, Kd. mchte nicht mehr','privat',NULL,0,'+','','P',1909150,'MobilComSuper92000D1(Akquise)',NULL,NULL,'MS9ND1',325,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','','');
INSERT INTO t1 VALUES (3359362,406,3359362,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprft','','privat',1509984,2145874,'+','','P',1909154,'MobilComSuper92000D1(Akquise)',NULL,NULL,'MS9ND1',327,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','','');
SELECT ELT(FIELD(kundentyp,'PP','PPA','PG','PGA','FK','FKA','FP','FPA','K','KA','V','VA',''), 'Privat (Private Nutzung)','Privat (Private Nutzung) Sitz im Ausland','Privat (geschaeftliche Nutzung)','Privat (geschaeftliche Nutzung) Sitz im Ausland','Firma (Kapitalgesellschaft)','Firma (Kapitalgesellschaft) Sitz im Ausland','Firma (Personengesellschaft)','Firma (Personengesellschaft) Sitz im Ausland','oeff. rechtl. Koerperschaft','oeff. rechtl. Koerperschaft Sitz im Ausland','Eingetragener Verein','Eingetragener Verein Sitz im Ausland','Typ unbekannt') AS Kundentyp ,kategorie FROM t1 WHERE hdl_nr < 2000000 AND kategorie IN ('Prepaid','Mobilfunk') AND st_klasse = 'Workflow' GROUP BY kundentyp ORDER BY kategorie;
Kundentyp kategorie
Privat (Private Nutzung) Mobilfunk
Warnings:
Warning 1052 Column 'kundentyp' in group statement is ambiguous
drop table t1;
CREATE TABLE t1 (
AUFNR varchar(12) NOT NULL default '',
PLNFL varchar(6) NOT NULL default '',
VORNR varchar(4) NOT NULL default '',
xstatus_vor smallint(5) unsigned NOT NULL default '0'
);
INSERT INTO t1 VALUES ('40004712','000001','0010',9);
INSERT INTO t1 VALUES ('40004712','000001','0020',0);
UPDATE t1 SET t1.xstatus_vor = Greatest(t1.xstatus_vor,1) WHERE t1.aufnr =
"40004712" AND t1.plnfl = "000001" AND t1.vornr > "0010" ORDER BY t1.vornr
ASC LIMIT 1;
drop table t1;
This diff is collapsed.
create table t1 (a bigint);
lock tables t1 write;
insert into t1 values(0);
analyze table t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
unlock tables;
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
create table t1 (a bigint);
insert into t1 values(0);
lock tables t1 write;
delete from t1;
analyze table t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
unlock tables;
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
create table t1 (a bigint);
insert into t1 values(0);
analyze table t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
create table t1 (a mediumtext, fulltext key key1(a)) charset utf8 collate utf8_general_ci engine myisam;
insert into t1 values ('hello');
analyze table t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
analyze table t1;
Table Op Msg_type Msg_text
test.t1 analyze status Table is already up to date
drop table t1;
CREATE TABLE t1 (a int);
prepare stmt1 from "SELECT * FROM t1 PROCEDURE ANALYSE()";
execute stmt1;
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
test.t1.a NULL NULL 0 0 0 0 0.0 0.0 CHAR(0) NOT NULL
execute stmt1;
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
test.t1.a NULL NULL 0 0 0 0 0.0 0.0 CHAR(0) NOT NULL
deallocate prepare stmt1;
drop table t1;
create temporary table t1(a int, index(a));
insert into t1 values('1'),('2'),('3'),('4'),('5');
analyze table t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
show index from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 a 1 a A 5 NULL NULL YES BTREE
drop table t1;
drop table if exists t1;
set sql_mode="MySQL40";
select @@sql_mode;
@@sql_mode
MYSQL40,HIGH_NOT_PRECEDENCE
set @@sql_mode="ANSI";
select @@sql_mode;
@@sql_mode
REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI
SELECT 'A' || 'B';
'A' || 'B'
AB
CREATE TABLE t1 (id INT, id2 int);
SELECT id,NULL,1,1.1,'a' FROM t1 GROUP BY id;
id NULL 1 1.1 a
SELECT id FROM t1 GROUP BY id2;
id
drop table t1;
SET @@SQL_MODE="";
CREATE TABLE t1 (i int auto_increment NOT NULL, PRIMARY KEY (i));
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`i` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`i`)
) ENGINE=PBXT DEFAULT CHARSET=latin1
SET @@SQL_MODE="MYSQL323";
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`i` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`i`)
) TYPE=PBXT
SET @@SQL_MODE="MYSQL40";
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`i` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`i`)
) TYPE=PBXT
SET @@SQL_MODE="NO_FIELD_OPTIONS";
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`i` int(11) NOT NULL,
PRIMARY KEY (`i`)
) ENGINE=PBXT DEFAULT CHARSET=latin1
DROP TABLE t1;
This diff is collapsed.
drop table if exists t1;
create table t1(n int not null, key(n)) delay_key_write = 1;
select count(distinct n) from t1;
count(distinct n)
100
explain extended select count(distinct n) from t1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 range NULL n 4 NULL 201 99.50 Using index for group-by (scanning)
Warnings:
Note 1003 select count(distinct `test`.`t1`.`n`) AS `count(distinct n)` from `test`.`t1`
drop table t1;
This diff is collapsed.
drop table if exists t1,t2;
create table t1 (name char(20) not null, primary key (name));
create table t2 (name char(20) binary not null, primary key (name));
insert into t1 values ("");
insert into t1 values ("");
insert into t1 values ("");
insert into t2 select * from t1;
select * from t1 order by name;
name
select concat("*",name,"*") from t1 order by 1;
concat("*",name,"*")
**
**
**
select min(name),min(concat("*",name,"*")),max(name),max(concat("*",name,"*")) from t1;
min(name) min(concat("*",name,"*")) max(name) max(concat("*",name,"*"))
** **
select * from t2 order by name;
name
select concat("*",name,"*") from t2 order by 1;
concat("*",name,"*")
**
**
**
select min(name),min(concat("*",name,"*")),max(name),max(concat("*",name,"*")) from t2;
min(name) min(concat("*",name,"*")) max(name) max(concat("*",name,"*"))
** **
select name from t1 where name between '' and '';
name
select name from t2 where name between '' and '';
name
select name from t2 where name between '' and '';
name
drop table t1,t2;
create table t1 (a char(10) not null, b char(10) binary not null,key (a), key(b));
insert into t1 values ("hello ","hello "),("hello2 ","hello2 ");
select concat("-",a,"-",b,"-") from t1 where a="hello";
concat("-",a,"-",b,"-")
-hello-hello-
select concat("-",a,"-",b,"-") from t1 where a="hello ";
concat("-",a,"-",b,"-")
-hello-hello-
select concat("-",a,"-",b,"-") from t1 ignore index (a) where a="hello ";
concat("-",a,"-",b,"-")
-hello-hello-
select concat("-",a,"-",b,"-") from t1 where b="hello";
concat("-",a,"-",b,"-")
-hello-hello-
select concat("-",a,"-",b,"-") from t1 where b="hello ";
concat("-",a,"-",b,"-")
-hello-hello-
select concat("-",a,"-",b,"-") from t1 ignore index (b) where b="hello ";
concat("-",a,"-",b,"-")
-hello-hello-
alter table t1 modify b tinytext not null, drop key b, add key (b(100));
select concat("-",a,"-",b,"-") from t1;
concat("-",a,"-",b,"-")
-hello-hello-
-hello2-hello2-
select concat("-",a,"-",b,"-") from t1 where b="hello ";
concat("-",a,"-",b,"-")
-hello-hello-
select concat("-",a,"-",b,"-") from t1 ignore index (b) where b="hello ";
concat("-",a,"-",b,"-")
-hello-hello-
drop table t1;
create table t1 (b char(8));
insert into t1 values(NULL);
select b from t1 where binary b like '';
b
select b from t1 group by binary b like '';
b
NULL
select b from t1 having binary b like '';
b
drop table t1;
create table t1 (a char(3) binary, b binary(3));
insert into t1 values ('aaa','bbb'),('AAA','BBB');
select upper(a),upper(b) from t1;
upper(a) upper(b)
AAA bbb
AAA BBB
select lower(a),lower(b) from t1;
lower(a) lower(b)
aaa bbb
aaa BBB
select * from t1 where upper(a)='AAA';
a b
aaa bbb
AAA BBB
select * from t1 where lower(a)='aaa';
a b
aaa bbb
AAA BBB
select * from t1 where upper(b)='BBB';
a b
AAA BBB
select * from t1 where lower(b)='bbb';
a b
aaa bbb
select charset(a), charset(b), charset(binary 'ccc') from t1 limit 1;
charset(a) charset(b) charset(binary 'ccc')
latin1 binary binary
select collation(a), collation(b), collation(binary 'ccc') from t1 limit 1;
collation(a) collation(b) collation(binary 'ccc')
latin1_bin binary binary
drop table t1;
create table t1( firstname char(20), lastname char(20));
insert into t1 values ("john","doe"),("John","Doe");
select * from t1 where firstname='john' and firstname like binary 'john';
firstname lastname
john doe
select * from t1 where firstname='john' and binary 'john' = firstname;
firstname lastname
john doe
select * from t1 where firstname='john' and firstname = binary 'john';
firstname lastname
john doe
select * from t1 where firstname='John' and firstname like binary 'john';
firstname lastname
john doe
select * from t1 where firstname='john' and firstname like binary 'John';
firstname lastname
John Doe
drop table t1;
create table t1 (a binary);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` binary(1) DEFAULT NULL
) ENGINE=PBXT DEFAULT CHARSET=latin1
drop table t1;
create table t1 (col1 binary(4));
insert into t1 values ('a'),('a ');
select hex(col1) from t1;
hex(col1)
61000000
61200000
alter table t1 modify col1 binary(10);
select hex(col1) from t1;
hex(col1)
61000000000000000000
61200000000000000000
insert into t1 values ('b'),('b ');
select hex(col1) from t1;
hex(col1)
61000000000000000000
61200000000000000000
62000000000000000000
62200000000000000000
drop table t1;
DROP TABLE IF EXISTS t1;
SELECT IF(NULL AND 1, 1, 2), IF(1 AND NULL, 1, 2);
IF(NULL AND 1, 1, 2) IF(1 AND NULL, 1, 2)
2 2
SELECT NULL AND 1, 1 AND NULL, 0 AND NULL, NULL and 0;
NULL AND 1 1 AND NULL 0 AND NULL NULL and 0
NULL NULL 0 0
create table t1 (a int);
insert into t1 values (0),(1),(NULL);
SELECT * FROM t1 WHERE IF(a AND 1, 0, 1);
a
0
NULL
SELECT * FROM t1 WHERE IF(1 AND a, 0, 1);
a
0
NULL
SELECT * FROM t1 where NOT(a AND 1);
a
0
SELECT * FROM t1 where NOT(1 AND a);
a
0
SELECT * FROM t1 where (a AND 1)=0;
a
0
SELECT * FROM t1 where (1 AND a)=0;
a
0
SELECT * FROM t1 where (1 AND a)=1;
a
1
SELECT * FROM t1 where (1 AND a) IS NULL;
a
NULL
set sql_mode='high_not_precedence';
select * from t1 where not a between 2 and 3;
a
set sql_mode=default;
select * from t1 where not a between 2 and 3;
a
0
1
select a, a is false, a is true, a is unknown from t1;
a a is false a is true a is unknown
0 1 0 0
1 0 1 0
NULL 0 0 1
select a, a is not false, a is not true, a is not unknown from t1;
a a is not false a is not true a is not unknown
0 0 1 1
1 1 0 1
NULL 1 1 0
SET @a=0, @b=0;
SELECT * FROM t1 WHERE NULL AND (@a:=@a+1);
a
SELECT * FROM t1 WHERE NOT(a>=0 AND NULL AND (@b:=@b+1));
a
SELECT * FROM t1 WHERE a=2 OR (NULL AND (@a:=@a+1));
a
SELECT * FROM t1 WHERE NOT(a=2 OR (NULL AND (@b:=@b+1)));
a
DROP TABLE t1;
create table t1 (a int, b int);
insert into t1 values(null, null), (0, null), (1, null), (null, 0), (null, 1), (0, 0), (0, 1), (1, 0), (1, 1);
select ifnull(A, 'N') as A, ifnull(B, 'N') as B, ifnull(not A, 'N') as nA, ifnull(not B, 'N') as nB, ifnull(A and B, 'N') as AB, ifnull(not (A and B), 'N') as `n(AB)`, ifnull((not A or not B), 'N') as nAonB, ifnull(A or B, 'N') as AoB, ifnull(not(A or B), 'N') as `n(AoB)`, ifnull(not A and not B, 'N') as nAnB from t1;
A B nA nB AB n(AB) nAonB AoB n(AoB) nAnB
N N N N N N N N N N
0 N 1 N 0 1 1 N N N
1 N 0 N N N N 1 0 0
N 0 N 1 0 1 1 N N N
N 1 N 0 N N N 1 0 0
0 0 1 1 0 1 1 0 1 1
0 1 1 0 0 1 1 1 0 0
1 0 0 1 0 1 1 1 0 0
1 1 0 0 1 0 0 1 0 0
select ifnull(A=1, 'N') as A, ifnull(B=1, 'N') as B, ifnull(not (A=1), 'N') as nA, ifnull(not (B=1), 'N') as nB, ifnull((A=1) and (B=1), 'N') as AB, ifnull(not ((A=1) and (B=1)), 'N') as `n(AB)`, ifnull((not (A=1) or not (B=1)), 'N') as nAonB, ifnull((A=1) or (B=1), 'N') as AoB, ifnull(not((A=1) or (B=1)), 'N') as `n(AoB)`, ifnull(not (A=1) and not (B=1), 'N') as nAnB from t1;
A B nA nB AB n(AB) nAonB AoB n(AoB) nAnB
N N N N N N N N N N
0 N 1 N 0 1 1 N N N
1 N 0 N N N N 1 0 0
N 0 N 1 0 1 1 N N N
N 1 N 0 N N N 1 0 0
0 0 1 1 0 1 1 0 1 1
0 1 1 0 0 1 1 1 0 0
1 0 0 1 0 1 1 1 0 0
1 1 0 0 1 0 0 1 0 0
drop table t1;
drop table if exists t1;
CREATE TABLE t1 (a int, unique (a), b int not null, unique(b), c int not null, index(c));
replace into t1 values (1,1,1),(2,2,2),(3,1,3);
select * from t1 order by a;
a b c
2 2 2
3 1 3
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
drop table if exists t1,t2;
select CASE "b" when "a" then 1 when "b" then 2 END;
CASE "b" when "a" then 1 when "b" then 2 END
2
select CASE "c" when "a" then 1 when "b" then 2 END;
CASE "c" when "a" then 1 when "b" then 2 END
NULL
select CASE "c" when "a" then 1 when "b" then 2 ELSE 3 END;
CASE "c" when "a" then 1 when "b" then 2 ELSE 3 END
3
select CASE BINARY "b" when "a" then 1 when "B" then 2 WHEN "b" then "ok" END;
CASE BINARY "b" when "a" then 1 when "B" then 2 WHEN "b" then "ok" END
ok
select CASE "b" when "a" then 1 when binary "B" then 2 WHEN "b" then "ok" END;
CASE "b" when "a" then 1 when binary "B" then 2 WHEN "b" then "ok" END
ok
select CASE concat("a","b") when concat("ab","") then "a" when "b" then "b" end;
CASE concat("a","b") when concat("ab","") then "a" when "b" then "b" end
a
select CASE when 1=0 then "true" else "false" END;
CASE when 1=0 then "true" else "false" END
false
select CASE 1 when 1 then "one" WHEN 2 then "two" ELSE "more" END;
CASE 1 when 1 then "one" WHEN 2 then "two" ELSE "more" END
one
explain extended select CASE 1 when 1 then "one" WHEN 2 then "two" ELSE "more" END;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select (case 1 when 1 then 'one' when 2 then 'two' else 'more' end) AS `CASE 1 when 1 then "one" WHEN 2 then "two" ELSE "more" END`
select CASE 2.0 when 1 then "one" WHEN 2.0 then "two" ELSE "more" END;
CASE 2.0 when 1 then "one" WHEN 2.0 then "two" ELSE "more" END
two
select (CASE "two" when "one" then "1" WHEN "two" then "2" END) | 0;
(CASE "two" when "one" then "1" WHEN "two" then "2" END) | 0
2
select (CASE "two" when "one" then 1.00 WHEN "two" then 2.00 END) +0.0;
(CASE "two" when "one" then 1.00 WHEN "two" then 2.00 END) +0.0
2.00
select case 1/0 when "a" then "true" else "false" END;
case 1/0 when "a" then "true" else "false" END
false
select case 1/0 when "a" then "true" END;
case 1/0 when "a" then "true" END
NULL
select (case 1/0 when "a" then "true" END) | 0;
(case 1/0 when "a" then "true" END) | 0
NULL
select (case 1/0 when "a" then "true" END) + 0.0;
(case 1/0 when "a" then "true" END) + 0.0
NULL
select case when 1>0 then "TRUE" else "FALSE" END;
case when 1>0 then "TRUE" else "FALSE" END
TRUE
select case when 1<0 then "TRUE" else "FALSE" END;
case when 1<0 then "TRUE" else "FALSE" END
FALSE
create table t1 (a int);
insert into t1 values(1),(2),(3),(4);
select case a when 1 then 2 when 2 then 3 else 0 end as fcase, count(*) from t1 group by fcase;
fcase count(*)
0 2
2 1
3 1
explain extended select case a when 1 then 2 when 2 then 3 else 0 end as fcase, count(*) from t1 group by fcase;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 100.00 Using temporary; Using filesort
Warnings:
Note 1003 select (case `test`.`t1`.`a` when 1 then 2 when 2 then 3 else 0 end) AS `fcase`,count(0) AS `count(*)` from `test`.`t1` group by (case `test`.`t1`.`a` when 1 then 2 when 2 then 3 else 0 end)
select case a when 1 then "one" when 2 then "two" else "nothing" end as fcase, count(*) from t1 group by fcase;
fcase count(*)
nothing 2
one 1
two 1
drop table t1;
create table t1 (row int not null, col int not null, val varchar(255) not null);
insert into t1 values (1,1,'orange'),(1,2,'large'),(2,1,'yellow'),(2,2,'medium'),(3,1,'green'),(3,2,'small');
select max(case col when 1 then val else null end) as color from t1 group by row;
color
orange
yellow
green
drop table t1;
SET NAMES latin1;
CREATE TABLE t1 SELECT
CASE WHEN 1 THEN _latin1'a' COLLATE latin1_danish_ci ELSE _latin1'a' END AS c1,
CASE WHEN 1 THEN _latin1'a' ELSE _latin1'a' COLLATE latin1_danish_ci END AS c2,
CASE WHEN 1 THEN 'a' ELSE 1 END AS c3,
CASE WHEN 1 THEN 1 ELSE 'a' END AS c4,
CASE WHEN 1 THEN 'a' ELSE 1.0 END AS c5,
CASE WHEN 1 THEN 1.0 ELSE 'a' END AS c6,
CASE WHEN 1 THEN 1 ELSE 1.0 END AS c7,
CASE WHEN 1 THEN 1.0 ELSE 1 END AS c8,
CASE WHEN 1 THEN 1.0 END AS c9,
CASE WHEN 1 THEN 0.1e1 else 0.1 END AS c10,
CASE WHEN 1 THEN 0.1e1 else 1 END AS c11,
CASE WHEN 1 THEN 0.1e1 else '1' END AS c12
;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` varchar(1) CHARACTER SET latin1 COLLATE latin1_danish_ci NOT NULL DEFAULT '',
`c2` varchar(1) CHARACTER SET latin1 COLLATE latin1_danish_ci NOT NULL DEFAULT '',
`c3` varchar(1) NOT NULL DEFAULT '',
`c4` varchar(1) NOT NULL DEFAULT '',
`c5` varchar(4) NOT NULL DEFAULT '',
`c6` varchar(4) NOT NULL DEFAULT '',
`c7` decimal(2,1) NOT NULL DEFAULT '0.0',
`c8` decimal(2,1) NOT NULL DEFAULT '0.0',
`c9` decimal(2,1) DEFAULT NULL,
`c10` double NOT NULL DEFAULT '0',
`c11` double NOT NULL DEFAULT '0',
`c12` varchar(5) NOT NULL DEFAULT ''
) ENGINE=PBXT DEFAULT CHARSET=latin1
DROP TABLE t1;
SELECT CASE
WHEN 1
THEN _latin1'a' COLLATE latin1_danish_ci
ELSE _latin1'a' COLLATE latin1_swedish_ci
END;
ERROR HY000: Illegal mix of collations (latin1_danish_ci,EXPLICIT) and (latin1_swedish_ci,EXPLICIT) for operation 'case'
SELECT CASE _latin1'a' COLLATE latin1_general_ci
WHEN _latin1'a' COLLATE latin1_danish_ci THEN 1
WHEN _latin1'a' COLLATE latin1_swedish_ci THEN 2
END;
ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT), (latin1_danish_ci,EXPLICIT), (latin1_swedish_ci,EXPLICIT) for operation 'case'
SELECT
CASE _latin1'a' COLLATE latin1_general_ci WHEN _latin1'A' THEN '1' ELSE 2 END,
CASE _latin1'a' COLLATE latin1_bin WHEN _latin1'A' THEN '1' ELSE 2 END,
CASE _latin1'a' WHEN _latin1'A' COLLATE latin1_swedish_ci THEN '1' ELSE 2 END,
CASE _latin1'a' WHEN _latin1'A' COLLATE latin1_bin THEN '1' ELSE 2 END
;
CASE _latin1'a' COLLATE latin1_general_ci WHEN _latin1'A' THEN '1' ELSE 2 END CASE _latin1'a' COLLATE latin1_bin WHEN _latin1'A' THEN '1' ELSE 2 END CASE _latin1'a' WHEN _latin1'A' COLLATE latin1_swedish_ci THEN '1' ELSE 2 END CASE _latin1'a' WHEN _latin1'A' COLLATE latin1_bin THEN '1' ELSE 2 END
1 2 1 2
CREATE TABLE t1 SELECT COALESCE(_latin1'a',_latin2'a');
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation 'coalesce'
CREATE TABLE t1 SELECT COALESCE('a' COLLATE latin1_swedish_ci,'b' COLLATE latin1_bin);
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation 'coalesce'
CREATE TABLE t1 SELECT
COALESCE(1), COALESCE(1.0),COALESCE('a'),
COALESCE(1,1.0), COALESCE(1,'1'),COALESCE(1.1,'1'),
COALESCE('a' COLLATE latin1_bin,'b');
explain extended SELECT
COALESCE(1), COALESCE(1.0),COALESCE('a'),
COALESCE(1,1.0), COALESCE(1,'1'),COALESCE(1.1,'1'),
COALESCE('a' COLLATE latin1_bin,'b');
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select coalesce(1) AS `COALESCE(1)`,coalesce(1.0) AS `COALESCE(1.0)`,coalesce('a') AS `COALESCE('a')`,coalesce(1,1.0) AS `COALESCE(1,1.0)`,coalesce(1,'1') AS `COALESCE(1,'1')`,coalesce(1.1,'1') AS `COALESCE(1.1,'1')`,coalesce(('a' collate latin1_bin),'b') AS `COALESCE('a' COLLATE latin1_bin,'b')`
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`COALESCE(1)` int(1) NOT NULL DEFAULT '0',
`COALESCE(1.0)` decimal(2,1) NOT NULL DEFAULT '0.0',
`COALESCE('a')` varchar(1) NOT NULL DEFAULT '',
`COALESCE(1,1.0)` decimal(2,1) NOT NULL DEFAULT '0.0',
`COALESCE(1,'1')` varchar(1) NOT NULL DEFAULT '',
`COALESCE(1.1,'1')` varchar(4) NOT NULL DEFAULT '',
`COALESCE('a' COLLATE latin1_bin,'b')` varchar(1) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT ''
) ENGINE=PBXT DEFAULT CHARSET=latin1
DROP TABLE t1;
SELECT 'case+union+test'
UNION
SELECT CASE LOWER('1') WHEN LOWER('2') THEN 'BUG' ELSE 'nobug' END;
case+union+test
case+union+test
nobug
SELECT CASE LOWER('1') WHEN LOWER('2') THEN 'BUG' ELSE 'nobug' END;
CASE LOWER('1') WHEN LOWER('2') THEN 'BUG' ELSE 'nobug' END
nobug
SELECT 'case+union+test'
UNION
SELECT CASE '1' WHEN '2' THEN 'BUG' ELSE 'nobug' END;
case+union+test
case+union+test
nobug
create table t1(a float, b int default 3);
insert into t1 (a) values (2), (11), (8);
select min(a), min(case when 1=1 then a else NULL end),
min(case when 1!=1 then NULL else a end)
from t1 where b=3 group by b;
min(a) min(case when 1=1 then a else NULL end) min(case when 1!=1 then NULL else a end)
2 2 2
drop table t1;
CREATE TABLE t1 (EMPNUM INT);
INSERT INTO t1 VALUES (0), (2);
CREATE TABLE t2 (EMPNUM DECIMAL (4, 2));
INSERT INTO t2 VALUES (0.0), (9.0);
SELECT COALESCE(t2.EMPNUM,t1.EMPNUM) AS CEMPNUM,
t1.EMPNUM AS EMPMUM1, t2.EMPNUM AS EMPNUM2
FROM t1 LEFT JOIN t2 ON t1.EMPNUM=t2.EMPNUM;
CEMPNUM EMPMUM1 EMPNUM2
0.00 0 0.00
2.00 2 NULL
SELECT IFNULL(t2.EMPNUM,t1.EMPNUM) AS CEMPNUM,
t1.EMPNUM AS EMPMUM1, t2.EMPNUM AS EMPNUM2
FROM t1 LEFT JOIN t2 ON t1.EMPNUM=t2.EMPNUM;
CEMPNUM EMPMUM1 EMPNUM2
0.00 0 0.00
2.00 2 NULL
DROP TABLE t1,t2;
This diff is collapsed.
drop table if exists t1;
create table t1(n int not null, key(n), key(n), key(n), key(n));
check table t1 extended;
insert into t1 values (200000);
Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
Create table t1(f1 int);
Create table t2(f1 int);
Create view v1 as Select * from t1;
Check Table v1,t2;
Table Op Msg_type Msg_text
test.v1 check status OK
test.t2 check status OK
drop view v1;
drop table t1, t2;
create table t1 (
`a&b` int,
`a<b` int,
`a>b` text
);
insert into t1 values (1, 2, 'a&b a<b a>b');
<?xml version="1.0"?>
<resultset statement="select * from t1
" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<row>
<field name="a&amp;b">1</field>
<field name="a&lt;b">2</field>
<field name="a&gt;b">a&amp;b a&lt;b a&gt;b</field>
</row>
</resultset>
<?xml version="1.0"?>
<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<database name="test">
<table_structure name="t1">
<field Field="a&amp;b" Type="int(11)" Null="YES" Key="" Extra="" Comment="" />
<field Field="a&lt;b" Type="int(11)" Null="YES" Key="" Extra="" Comment="" />
<field Field="a&gt;b" Type="text" Null="YES" Key="" Extra="" Comment="" />
</table_structure>
<table_data name="t1">
<row>
<field name="a&amp;b">1</field>
<field name="a&lt;b">2</field>
<field name="a&gt;b">a&amp;b a&lt;b a&gt;b</field>
</row>
</table_data>
</database>
</mysqldump>
<?xml version="1.0"?>
<resultset statement="select count(*) from t1
" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<row>
<field name="count(*)">1</field>
</row>
</resultset>
<?xml version="1.0"?>
<resultset statement="select 1 &lt; 2 from dual
" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<row>
<field name="1 &lt; 2">1</field>
</row>
</resultset>
<?xml version="1.0"?>
<resultset statement="select 1 &gt; 2 from dual
" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<row>
<field name="1 &gt; 2">0</field>
</row>
</resultset>
<?xml version="1.0"?>
<resultset statement="select 1 &amp; 3 from dual
" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<row>
<field name="1 &amp; 3">1</field>
</row>
</resultset>
<?xml version="1.0"?>
<resultset statement="select null from dual
" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<row>
<field name="NULL" xsi:nil="true" />
</row>
</resultset>
drop table t1;
select 1+2/*hello*/+3;
1+2/*hello*/+3
6
select 1 /* long
multi line comment */;
1
1
;
ERROR 42000: Query was empty
select 1 /*!32301 +1 */;
1 +1
2
select 1 /*!52301 +1 */;
1
1
select 1--1;
1--1
2
select 1 --2
+1;
1 --2
+1
4
select 1 # The rest of the row will be ignored
;
1
1
/* line with only comment */;
drop table if exists t1;
CREATE TABLE t1 (id CHAR(12) not null, PRIMARY KEY (id));
insert into t1 values ('000000000001'),('000000000002');
explain select * from t1 where id=000000000001;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index PRIMARY PRIMARY 12 NULL 2 Using where; Using index
select * from t1 where id=000000000001;
id
000000000001
delete from t1 where id=000000000002;
select * from t1;
id
000000000001
drop table t1;
SELECT 'a' = 'a ';
'a' = 'a '
1
SELECT 'a\0' < 'a';
'a\0' < 'a'
1
SELECT 'a\0' < 'a ';
'a\0' < 'a '
1
SELECT 'a\t' < 'a';
'a\t' < 'a'
1
SELECT 'a\t' < 'a ';
'a\t' < 'a '
1
CREATE TABLE t1 (a char(10) not null);
INSERT INTO t1 VALUES ('a'),('a\0'),('a\t'),('a ');
SELECT hex(a),STRCMP(a,'a'), STRCMP(a,'a ') FROM t1;
hex(a) STRCMP(a,'a') STRCMP(a,'a ')
61 0 0
6100 -1 -1
6109 -1 -1
61 0 0
DROP TABLE t1;
SELECT CHAR(31) = '', '' = CHAR(31);
CHAR(31) = '' '' = CHAR(31)
0 0
SELECT CHAR(30) = '', '' = CHAR(30);
CHAR(30) = '' '' = CHAR(30)
0 0
create table t1 (a tinyint(1),b binary(1));
insert into t1 values (0x01,0x01);
select * from t1 where a=b;
a b
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: '\x01'
select * from t1 where a=b and b=0x01;
a b
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: '\x01'
drop table if exists t1;
drop table if exists t1,t2;
show tables;
Tables_in_mysql
columns_priv
db
event
func
general_log
help_category
help_keyword
help_relation
help_topic
host
ndb_binlog_index
plugin
proc
procs_priv
proxies_priv
servers
slow_log
tables_priv
time_zone
time_zone_leap_second
time_zone_name
time_zone_transition
time_zone_transition_type
user
show tables;
Tables_in_test
connect(localhost,root,z,test2,MASTER_PORT,MASTER_SOCKET);
ERROR 28000: Access denied for user 'root'@'localhost' (using password: YES)
connect(localhost,root,z,test,MASTER_PORT,MASTER_SOCKET);
ERROR 28000: Access denied for user 'root'@'localhost' (using password: YES)
grant ALL on *.* to test@localhost identified by "gambling";
grant ALL on *.* to test@127.0.0.1 identified by "gambling";
show tables;
Tables_in_mysql
columns_priv
db
event
func
general_log
help_category
help_keyword
help_relation
help_topic
host
ndb_binlog_index
plugin
proc
procs_priv
proxies_priv
servers
slow_log
tables_priv
time_zone
time_zone_leap_second
time_zone_name
time_zone_transition
time_zone_transition_type
user
show tables;
Tables_in_test
connect(localhost,test,,test2,MASTER_PORT,MASTER_SOCKET);
ERROR 28000: Access denied for user 'test'@'localhost' (using password: NO)
connect(localhost,,,,MASTER_PORT,MASTER_SOCKET);
ERROR 28000: Access denied for user ''@'localhost' (using password: NO)
connect(localhost,test,zorro,test2,MASTER_PORT,MASTER_SOCKET);
ERROR 28000: Access denied for user 'test'@'localhost' (using password: YES)
connect(localhost,test,zorro,test,MASTER_PORT,MASTER_SOCKET);
ERROR 28000: Access denied for user 'test'@'localhost' (using password: YES)
update mysql.user set password=old_password("gambling2") where user=_binary"test";
flush privileges;
set password="";
set password='gambling3';
ERROR HY000: Password hash should be a 41-digit hexadecimal number
set password=old_password('gambling3');
show tables;
Tables_in_mysql
columns_priv
db
event
func
general_log
help_category
help_keyword
help_relation
help_topic
host
ndb_binlog_index
plugin
proc
procs_priv
proxies_priv
servers
slow_log
tables_priv
time_zone
time_zone_leap_second
time_zone_name
time_zone_transition
time_zone_transition_type
user
show tables;
Tables_in_test
connect(localhost,test,,test2,MASTER_PORT,MASTER_SOCKET);
ERROR 28000: Access denied for user 'test'@'localhost' (using password: NO)
connect(localhost,test,,test,MASTER_PORT,MASTER_SOCKET);
ERROR 28000: Access denied for user 'test'@'localhost' (using password: NO)
connect(localhost,test,zorro,test2,MASTER_PORT,MASTER_SOCKET);
ERROR 28000: Access denied for user 'test'@'localhost' (using password: YES)
connect(localhost,test,zorro,test,MASTER_PORT,MASTER_SOCKET);
ERROR 28000: Access denied for user 'test'@'localhost' (using password: YES)
delete from mysql.user where user=_binary"test";
flush privileges;
create table t1 (id integer not null auto_increment primary key);
create temporary table t2(id integer not null auto_increment primary key);
set @id := 1;
delete from t1 where id like @id;
drop table t1;
drop table if exists t1;
create table t1 (a int);
insert t1 values (1);
drop table t1;
create table t1 (a int) engine=innodb;
start transaction with consistent snapshot;
insert into t1 values(1);
select * from t1;
a
commit;
delete from t1;
start transaction;
insert into t1 values(1);
select * from t1;
a
1
commit;
drop table t1;
drop database pbxt;
drop table if exists t1;
create table t1 (a int check (a>0));
insert into t1 values (1);
insert into t1 values (0);
drop table t1;
create table t1 (a int, b int, check (a>b));
insert into t1 values (1,0);
insert into t1 values (0,1);
drop table t1;
create table t1 (a int ,b int, constraint abc check (a>b));
insert into t1 values (1,0);
insert into t1 values (0,1);
drop table t1;
create table t1 (a int null);
insert into t1 values (1),(NULL);
drop table t1;
create table t1 (a int null);
alter table t1 add constraint constraint_1 unique (a);
alter table t1 add constraint unique key_1(a);
alter table t1 add constraint constraint_2 unique key_2(a);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
UNIQUE KEY `constraint_1` (`a`),
UNIQUE KEY `key_1` (`a`),
UNIQUE KEY `key_2` (`a`)
) ENGINE=PBXT DEFAULT CHARSET=latin1
drop table t1;
SHOW CONTRIBUTORS;
Name Location Comment
Ronald Bradford Brisbane, Australia EFF contribution for UC2006 Auction
Sheeri Kritzer Boston, Mass. USA EFF contribution for UC2006 Auction
Mark Shuttleworth London, UK. EFF contribution for UC2006 Auction
drop table if exists t1,t2,t3;
create table t1 (libname varchar(21) not null, city text, primary key (libname));
create table t2 (isbn varchar(21) not null, author text, title text, primary key (isbn));
create table t3 (isbn varchar(21) not null, libname varchar(21) not null, quantity int ,primary key (isbn,libname));
insert into t2 values ('001','Daffy','A duck''s life');
insert into t2 values ('002','Bugs','A rabbit\'s life');
insert into t2 values ('003','Cowboy','Life on the range');
insert into t2 values ('000','Anonymous','Wanna buy this book?');
insert into t2 values ('004','Best Seller','One Heckuva book');
insert into t2 values ('005','EveryoneBuys','This very book');
insert into t2 values ('006','San Fran','It is a san fran lifestyle');
insert into t2 values ('007','BerkAuthor','Cool.Berkley.the.book');
insert into t3 values('000','New York Public Libra','1');
insert into t3 values('001','New York Public Libra','2');
insert into t3 values('002','New York Public Libra','3');
insert into t3 values('003','New York Public Libra','4');
insert into t3 values('004','New York Public Libra','5');
insert into t3 values('005','New York Public Libra','6');
insert into t3 values('006','San Fransisco Public','5');
insert into t3 values('007','Berkeley Public1','3');
insert into t3 values('007','Berkeley Public2','3');
insert into t3 values('001','NYC Lib','8');
insert into t1 values ('New York Public Libra','New York');
insert into t1 values ('San Fransisco Public','San Fran');
insert into t1 values ('Berkeley Public1','Berkeley');
insert into t1 values ('Berkeley Public2','Berkeley');
insert into t1 values ('NYC Lib','New York');
select t2.isbn,city,t1.libname,count(t1.libname) as a from t3 left join t1 on t3.libname=t1.libname left join t2 on t3.isbn=t2.isbn group by city,t1.libname;
isbn city libname a
007 Berkeley Berkeley Public1 1
007 Berkeley Berkeley Public2 1
000 New York New York Public Libra 6
001 New York NYC Lib 1
006 San Fran San Fransisco Public 1
select t2.isbn,city,t1.libname,count(distinct t1.libname) as a from t3 left join t1 on t3.libname=t1.libname left join t2 on t3.isbn=t2.isbn group by city having count(distinct t1.libname) > 1;
isbn city libname a
007 Berkeley Berkeley Public1 2
000 New York New York Public Libra 2
select t2.isbn,city,t1.libname,count(distinct t1.libname) as a from t3 left join t1 on t3.libname=t1.libname left join t2 on t3.isbn=t2.isbn group by city having count(distinct concat(t1.libname,'a')) > 1;
isbn city libname a
007 Berkeley Berkeley Public1 2
000 New York New York Public Libra 2
drop table t1, t2, t3;
create table t1 (f1 int);
insert into t1 values (1);
create table t2 (f1 int,f2 int);
select t1.f1,count(distinct t2.f2),count(distinct 1,NULL) from t1 left join t2 on t1.f1=t2.f1 group by t1.f1;
f1 count(distinct t2.f2) count(distinct 1,NULL)
1 0 0
drop table t1,t2;
create table t1 (f int);
select count(distinct f) from t1;
count(distinct f)
0
drop table t1;
create table t1 (a char(3), b char(20), primary key (a, b));
insert into t1 values ('ABW', 'Dutch'), ('ABW', 'English');
select count(distinct a) from t1 group by b;
count(distinct a)
1
1
drop table t1;
create table t1 (f1 int, f2 int);
insert into t1 values (0,1),(1,2);
select count(distinct if(f1,3,f2)) from t1;
count(distinct if(f1,3,f2))
2
drop table t1;
drop table if exists t1;
create table t1(n1 int, n2 int, s char(20), vs varchar(20), t text);
insert into t1 values (1,11, 'one','eleven', 'eleven'),
(1,11, 'one','eleven', 'eleven'),
(2,11, 'two','eleven', 'eleven'),
(2,12, 'two','twevle', 'twelve'),
(2,13, 'two','thirteen', 'foo'),
(2,13, 'two','thirteen', 'foo'),
(2,13, 'two','thirteen', 'bar'),
(NULL,13, 'two','thirteen', 'bar'),
(2,NULL, 'two','thirteen', 'bar'),
(2,13, NULL,'thirteen', 'bar'),
(2,13, 'two',NULL, 'bar'),
(2,13, 'two','thirteen', NULL);
select distinct n1 from t1;
n1
1
2
NULL
select count(distinct n1) from t1;
count(distinct n1)
2
select distinct n2 from t1;
n2
11
12
13
NULL
select count(distinct n2) from t1;
count(distinct n2)
3
select distinct s from t1;
s
one
two
NULL
select count(distinct s) from t1;
count(distinct s)
2
select distinct vs from t1;
vs
eleven
twevle
thirteen
NULL
select count(distinct vs) from t1;
count(distinct vs)
3
select distinct t from t1;
t
eleven
twelve
foo
bar
NULL
select count(distinct t) from t1;
count(distinct t)
4
select distinct n1,n2 from t1;
n1 n2
1 11
2 11
2 12
2 13
NULL 13
2 NULL
select count(distinct n1,n2) from t1;
count(distinct n1,n2)
4
select distinct n1,s from t1;
n1 s
1 one
2 two
NULL two
2 NULL
select count(distinct n1,s) from t1;
count(distinct n1,s)
2
select distinct s,n1,vs from t1;
s n1 vs
one 1 eleven
two 2 eleven
two 2 twevle
two 2 thirteen
two NULL thirteen
NULL 2 thirteen
two 2 NULL
select count(distinct s,n1,vs) from t1;
count(distinct s,n1,vs)
4
select distinct s,t from t1;
s t
one eleven
two eleven
two twelve
two foo
two bar
NULL bar
two NULL
select count(distinct s,t) from t1;
count(distinct s,t)
5
select count(distinct n1), count(distinct n2) from t1;
count(distinct n1) count(distinct n2)
2 3
select count(distinct n2), n1 from t1 group by n1;
count(distinct n2) n1
1 NULL
1 1
3 2
drop table t1;
create table t1 (n int default NULL);
flush status;
select count(distinct n) from t1;
count(distinct n)
5000
show status like 'Created_tmp_disk_tables';
Variable_name Value
Created_tmp_disk_tables 0
drop table t1;
create table t1 (s text);
flush status;
select count(distinct s) from t1;
count(distinct s)
5000
show status like 'Created_tmp_disk_tables';
Variable_name Value
Created_tmp_disk_tables 1
drop table t1;
DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (id INTEGER, grp TINYINT, id_rev INTEGER);
SELECT COUNT(*) FROM t1;
COUNT(*)
4181000
SELECT COUNT(DISTINCT id) FROM t1 GROUP BY grp;
DROP TABLE t1;
set @@read_buffer_size=default;
This diff is collapsed.
This diff is collapsed.
drop table if exists t1,t2,t3,t4,t5,t6;
drop database if exists mysqltest;
CREATE TABLE t1 (a varchar(30) binary NOT NULL DEFAULT ' ',
b varchar(1) binary NOT NULL DEFAULT ' ',
c varchar(4) binary NOT NULL DEFAULT '0000',
d tinyblob NULL,
e tinyblob NULL,
f tinyblob NULL,
g tinyblob NULL,
h tinyblob NULL,
i tinyblob NULL,
j tinyblob NULL,
k tinyblob NULL,
l tinyblob NULL,
m tinyblob NULL,
n tinyblob NULL,
o tinyblob NULL,
p tinyblob NULL,
q varchar(30) binary NOT NULL DEFAULT ' ',
r varchar(30) binary NOT NULL DEFAULT ' ',
s tinyblob NULL,
t varchar(4) binary NOT NULL DEFAULT ' ',
u varchar(1) binary NOT NULL DEFAULT ' ',
v varchar(30) binary NOT NULL DEFAULT ' ',
w varchar(30) binary NOT NULL DEFAULT ' ',
x tinyblob NULL,
y varchar(5) binary NOT NULL DEFAULT ' ',
z varchar(20) binary NOT NULL DEFAULT ' ',
a1 varchar(30) binary NOT NULL DEFAULT ' ',
b1 tinyblob NULL)
ENGINE=InnoDB DEFAULT CHARACTER SET = latin1 COLLATE latin1_bin;
INSERT into t1 (b) values ('1');
SHOW WARNINGS;
Level Code Message
SELECT * from t1;
a b c d e f g h i j k l m n o p q r s t u v w x y z a1 b1
1 0000 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
CREATE TABLE t2 (a varchar(30) binary NOT NULL DEFAULT ' ',
b varchar(1) binary NOT NULL DEFAULT ' ',
c varchar(4) binary NOT NULL DEFAULT '0000',
d tinyblob NULL,
e tinyblob NULL,
f tinyblob NULL,
g tinyblob NULL,
h tinyblob NULL,
i tinyblob NULL,
j tinyblob NULL,
k tinyblob NULL,
l tinyblob NULL,
m tinyblob NULL,
n tinyblob NULL,
o tinyblob NULL,
p tinyblob NULL,
q varchar(30) binary NOT NULL DEFAULT ' ',
r varchar(30) binary NOT NULL DEFAULT ' ',
s tinyblob NULL,
t varchar(4) binary NOT NULL DEFAULT ' ',
u varchar(1) binary NOT NULL DEFAULT ' ',
v varchar(30) binary NOT NULL DEFAULT ' ',
w varchar(30) binary NOT NULL DEFAULT ' ',
x tinyblob NULL,
y varchar(5) binary NOT NULL DEFAULT ' ',
z varchar(20) binary NOT NULL DEFAULT ' ',
a1 varchar(30) binary NOT NULL DEFAULT ' ',
b1 tinyblob NULL)
ENGINE=MyISAM DEFAULT CHARACTER SET = latin1 COLLATE latin1_bin;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`a` varchar(30) COLLATE latin1_bin NOT NULL DEFAULT ' ',
`b` varchar(1) COLLATE latin1_bin NOT NULL DEFAULT ' ',
`c` varchar(4) COLLATE latin1_bin NOT NULL DEFAULT '0000',
`d` tinyblob,
`e` tinyblob,
`f` tinyblob,
`g` tinyblob,
`h` tinyblob,
`i` tinyblob,
`j` tinyblob,
`k` tinyblob,
`l` tinyblob,
`m` tinyblob,
`n` tinyblob,
`o` tinyblob,
`p` tinyblob,
`q` varchar(30) COLLATE latin1_bin NOT NULL DEFAULT ' ',
`r` varchar(30) COLLATE latin1_bin NOT NULL DEFAULT ' ',
`s` tinyblob,
`t` varchar(4) COLLATE latin1_bin NOT NULL DEFAULT ' ',
`u` varchar(1) COLLATE latin1_bin NOT NULL DEFAULT ' ',
`v` varchar(30) COLLATE latin1_bin NOT NULL DEFAULT ' ',
`w` varchar(30) COLLATE latin1_bin NOT NULL DEFAULT ' ',
`x` tinyblob,
`y` varchar(5) COLLATE latin1_bin NOT NULL DEFAULT ' ',
`z` varchar(20) COLLATE latin1_bin NOT NULL DEFAULT ' ',
`a1` varchar(30) COLLATE latin1_bin NOT NULL DEFAULT ' ',
`b1` tinyblob
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_bin
INSERT into t2 (b) values ('1');
SHOW WARNINGS;
Level Code Message
SELECT * from t2;
a b c d e f g h i j k l m n o p q r s t u v w x y z a1 b1
1 0000 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
drop table t1;
drop table t2;
create table bug20691 (i int, d datetime NOT NULL, dn datetime not null default '0000-00-00 00:00:00');
insert into bug20691 values (1, DEFAULT, DEFAULT), (1, '1975-07-10 07:10:03', '1978-01-13 14:08:51'), (1, DEFAULT, DEFAULT);
Warnings:
Warning 1364 Field 'd' doesn't have a default value
Warning 1364 Field 'd' doesn't have a default value
insert into bug20691 (i) values (2);
Warnings:
Warning 1364 Field 'd' doesn't have a default value
desc bug20691;
Field Type Null Key Default Extra
i int(11) YES NULL
d datetime NO NULL
dn datetime NO 0000-00-00 00:00:00
insert into bug20691 values (3, DEFAULT, DEFAULT), (3, '1975-07-10 07:10:03', '1978-01-13 14:08:51'), (3, DEFAULT, DEFAULT);
Warnings:
Warning 1364 Field 'd' doesn't have a default value
Warning 1364 Field 'd' doesn't have a default value
insert into bug20691 (i) values (4);
Warnings:
Warning 1364 Field 'd' doesn't have a default value
insert into bug20691 values (5, DEFAULT, DEFAULT), (5, '1975-07-10 07:10:03', '1978-01-13 14:08:51'), (5, DEFAULT, DEFAULT);
Warnings:
Warning 1364 Field 'd' doesn't have a default value
Warning 1364 Field 'd' doesn't have a default value
SET sql_mode = 'ALLOW_INVALID_DATES';
insert into bug20691 values (6, DEFAULT, DEFAULT), (6, '1975-07-10 07:10:03', '1978-01-13 14:08:51'), (6, DEFAULT, DEFAULT);
Warnings:
Warning 1364 Field 'd' doesn't have a default value
Warning 1364 Field 'd' doesn't have a default value
SET sql_mode = 'STRICT_ALL_TABLES';
insert into bug20691 values (7, DEFAULT, DEFAULT), (7, '1975-07-10 07:10:03', '1978-01-13 14:08:51'), (7, DEFAULT, DEFAULT);
ERROR HY000: Field 'd' doesn't have a default value
select * from bug20691 order by i asc;
i d dn
1 0000-00-00 00:00:00 0000-00-00 00:00:00
1 1975-07-10 07:10:03 1978-01-13 14:08:51
1 0000-00-00 00:00:00 0000-00-00 00:00:00
2 0000-00-00 00:00:00 0000-00-00 00:00:00
3 0000-00-00 00:00:00 0000-00-00 00:00:00
3 1975-07-10 07:10:03 1978-01-13 14:08:51
3 0000-00-00 00:00:00 0000-00-00 00:00:00
4 0000-00-00 00:00:00 0000-00-00 00:00:00
5 0000-00-00 00:00:00 0000-00-00 00:00:00
5 1975-07-10 07:10:03 1978-01-13 14:08:51
5 0000-00-00 00:00:00 0000-00-00 00:00:00
6 0000-00-00 00:00:00 0000-00-00 00:00:00
6 1975-07-10 07:10:03 1978-01-13 14:08:51
6 0000-00-00 00:00:00 0000-00-00 00:00:00
drop table bug20691;
SET sql_mode = '';
create table bug20691 (
a set('one', 'two', 'three') not null,
b enum('small', 'medium', 'large', 'enormous', 'ellisonego') not null,
c time not null,
d date not null,
e int not null,
f long not null,
g blob not null,
h datetime not null,
i decimal not null,
x int);
insert into bug20691 values (2, 3, 5, '0007-01-01', 11, 13, 17, '0019-01-01 00:00:00', 23, 1);
insert into bug20691 (x) values (2);
Warnings:
Warning 1364 Field 'a' doesn't have a default value
Warning 1364 Field 'c' doesn't have a default value
Warning 1364 Field 'd' doesn't have a default value
Warning 1364 Field 'e' doesn't have a default value
Warning 1364 Field 'f' doesn't have a default value
Warning 1364 Field 'g' doesn't have a default value
Warning 1364 Field 'h' doesn't have a default value
Warning 1364 Field 'i' doesn't have a default value
insert into bug20691 values (2, 3, 5, '0007-01-01', 11, 13, 17, '0019-01-01 00:00:00', 23, 3);
insert into bug20691 values (DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, 4);
Warnings:
Warning 1364 Field 'a' doesn't have a default value
Warning 1364 Field 'c' doesn't have a default value
Warning 1364 Field 'd' doesn't have a default value
Warning 1364 Field 'e' doesn't have a default value
Warning 1364 Field 'f' doesn't have a default value
Warning 1364 Field 'g' doesn't have a default value
Warning 1364 Field 'h' doesn't have a default value
Warning 1364 Field 'i' doesn't have a default value
select * from bug20691 order by x asc;
a b c d e f g h i x
two large 00:00:05 0007-01-01 11 13 17 0019-01-01 00:00:00 23 1
small 00:00:00 0000-00-00 0 0000-00-00 00:00:00 0 2
two large 00:00:05 0007-01-01 11 13 17 0019-01-01 00:00:00 23 3
small 00:00:00 0000-00-00 0 0000-00-00 00:00:00 0 4
drop table bug20691;
End of 5.0 tests.
drop table if exists t1,t2,t3,t11,t12;
CREATE TABLE t1 (a tinyint(3), b tinyint(5));
INSERT INTO t1 VALUES (1,1);
INSERT LOW_PRIORITY INTO t1 VALUES (1,2);
INSERT INTO t1 VALUES (1,3);
DELETE from t1 where a=1 limit 1;
DELETE LOW_PRIORITY from t1 where a=1;
INSERT INTO t1 VALUES (1,1);
DELETE from t1;
LOCK TABLE t1 write;
INSERT INTO t1 VALUES (1,2);
DELETE from t1;
UNLOCK TABLES;
INSERT INTO t1 VALUES (1,2);
SET AUTOCOMMIT=0;
DELETE from t1;
SET AUTOCOMMIT=1;
drop table t1;
create table t1 (
a bigint not null,
b bigint not null default 0,
c bigint not null default 0,
d bigint not null default 0,
e bigint not null default 0,
f bigint not null default 0,
g bigint not null default 0,
h bigint not null default 0,
i bigint not null default 0,
j bigint not null default 0,
primary key (a,b,c,d,e,f,g,h,i,j));
insert into t1 (a) values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(26),(23);
delete from t1 where a=26;
drop table t1;
create table t1 (
a bigint not null,
b bigint not null default 0,
c bigint not null default 0,
d bigint not null default 0,
e bigint not null default 0,
f bigint not null default 0,
g bigint not null default 0,
h bigint not null default 0,
i bigint not null default 0,
j bigint not null default 0,
primary key (a,b,c,d,e,f,g,h,i,j));
insert into t1 (a) values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(26),(23),(27);
delete from t1 where a=27;
drop table t1;
CREATE TABLE `t1` (
`i` int(10) NOT NULL default '0',
`i2` int(10) NOT NULL default '0',
PRIMARY KEY (`i`)
);
DELETE FROM t1 USING t1 WHERE post='1';
ERROR 42S22: Unknown column 'post' in 'where clause'
drop table t1;
CREATE TABLE t1 (
bool char(0) default NULL,
not_null varchar(20) binary NOT NULL default '',
misc integer not null,
PRIMARY KEY (not_null)
) ENGINE=MyISAM;
INSERT INTO t1 VALUES (NULL,'a',4), (NULL,'b',5), (NULL,'c',6), (NULL,'d',7);
select * from t1 where misc > 5 and bool is null;
bool not_null misc
NULL c 6
NULL d 7
delete from t1 where misc > 5 and bool is null;
select * from t1 where misc > 5 and bool is null;
bool not_null misc
select count(*) from t1;
count(*)
2
delete from t1 where 1 > 2;
select count(*) from t1;
count(*)
2
delete from t1 where 3 > 2;
select count(*) from t1;
count(*)
0
drop table t1;
create table t1 (a int not null auto_increment primary key, b char(32));
insert into t1 (b) values ('apple'), ('apple');
select * from t1;
a b
1 apple
2 apple
delete t1 from t1, t1 as t2 where t1.b = t2.b and t1.a > t2.a;
select * from t1;
a b
1 apple
drop table t1;
create table t11 (a int NOT NULL, b int, primary key (a));
create table t12 (a int NOT NULL, b int, primary key (a));
create table t2 (a int NOT NULL, b int, primary key (a));
insert into t11 values (0, 10),(1, 11),(2, 12);
insert into t12 values (33, 10),(0, 11),(2, 12);
insert into t2 values (1, 21),(2, 12),(3, 23);
select * from t11;
a b
0 10
1 11
2 12
select * from t12;
a b
33 10
0 11
2 12
select * from t2;
a b
1 21
2 12
3 23
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a);
ERROR 21000: Subquery returns more than 1 row
select * from t11;
a b
0 10
1 11
2 12
select * from t12;
a b
33 10
0 11
2 12
delete ignore t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a);
ERROR 21000: Subquery returns more than 1 row
select * from t11;
a b
0 10
1 11
2 12
select * from t12;
a b
33 10
0 11
2 12
insert into t11 values (2, 12);
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
delete from t11 where t11.b <> (select b from t2 where t11.a < t2.a);
ERROR 21000: Subquery returns more than 1 row
select * from t11;
a b
0 10
1 11
2 12
delete ignore from t11 where t11.b <> (select b from t2 where t11.a < t2.a);
ERROR 21000: Subquery returns more than 1 row
select * from t11;
a b
0 10
1 11
2 12
drop table t11, t12, t2;
create table t1 (a int, b int, unique key (a), key (b));
insert into t1 values (3, 3), (7, 7);
delete t1 from t1 where a = 3;
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
select * from t1;
a b
7 7
drop table t1;
CREATE TABLE t1 ( a int PRIMARY KEY );
DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a;
INSERT INTO t1 VALUES (0),(1),(2);
DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a LIMIT 1;
SELECT * FROM t1;
a
0
2
DROP TABLE t1;
create table t1 (a int);
delete `4.t1` from t1 as `4.t1` where `4.t1`.a = 5;
delete FROM `4.t1` USING t1 as `4.t1` where `4.t1`.a = 5;
drop table t1;
CREATE TABLE t1 (a int not null,b int not null);
CREATE TABLE t2 (a int not null, b int not null, primary key (a,b));
CREATE TABLE t3 (a int not null, b int not null, primary key (a,b));
insert into t1 values (1,1),(2,1),(1,3);
insert into t2 values (1,1),(2,2),(3,3);
insert into t3 values (1,1),(2,1),(1,3);
select * from t1,t2,t3 where t1.a=t2.a AND t2.b=t3.a and t1.b=t3.b;
a b a b a b
1 1 1 1 1 1
2 1 2 2 2 1
1 3 1 1 1 3
explain select * from t1,t2,t3 where t1.a=t2.a AND t2.b=t3.a and t1.b=t3.b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a 1 Using index
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 8 test.t2.b,test.t1.b 1 Using index
delete t2.*,t3.* from t1,t2,t3 where t1.a=t2.a AND t2.b=t3.a and t1.b=t3.b;
select * from t3;
a b
drop table t1,t2,t3;
create table t1(a date not null);
insert into t1 values (0);
select * from t1 where a is null;
a
0000-00-00
delete from t1 where a is null;
select count(*) from t1;
count(*)
0
drop table t1;
This diff is collapsed.
drop table if exists t1;
create table t1 (n int);
insert into t1 values (1),(2),(3);
select * from t1;
n
1
2
3
drop table t1;
This diff is collapsed.
This diff is collapsed.
drop table if exists t1;
create table t1 (nr int(5) not null auto_increment,b blob,str char(10), primary key (nr));
select count(*) from t1;
count(*)
0
select * from t1;
nr b str
select * from t1 limit 0;
nr b str
drop table t1;
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
drop table if exists t1;
create table t1 (kill_id int);
insert into t1 values(connection_id());
select kill_id-kill_id from t1;
kill_id-kill_id
0
flush tables with read lock;
select ((@id := kill_id) - kill_id) from t1;
((@id := kill_id) - kill_id)
0
kill connection @id;
drop table t1;
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
drop table if exists t1;
create table t1 (id int auto_increment primary key not null, mydate date not null);
insert into t1 values (0,"2002-05-01"),(0,"2002-05-01"),(0,"2002-05-01");
flush tables;
select * from t1 where isnull(to_days(mydate));
id mydate
drop table t1;
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment