Commit 63c6d7e5 authored by Rich Prohaska's avatar Rich Prohaska

#4621 move tokudb.type mysql tests to common mysql test dir refs[t:4621]

git-svn-id: file:///svn/mysql/tests/mysql-test@40917 c7de825b-a66e-492c-adef-691d508d4ae1
parent 61a312ef
set STORAGE_ENGINE='tokudb';
set names ascii;
select 'e'='`';
'e'='`'
0
select 'y'='~';
'y'='~'
0
create table t1 (a char(1) character set ascii);
insert into t1 (a) values (' '), ('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'), ('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'), ('!'), ('@'), ('#'), ('$'), ('%'), ('^'), ('&'), ('*'), ('('), (')'), ('_'), ('+'), ('`'), ('~'), ('1'), ('2'), ('3'), ('4'), ('5'), ('6'), ('7'), ('8'), ('9'), ('0'), ('['), (']'), ('\\'), ('|'), ('}'), ('{'), ('"'), (':'), (''''), (';'), ('/'), ('.'), (','), ('?'), ('>'), ('<'), ('\n'), ('\t'), ('\a'), ('\f'), ('\v');
select t1a.a, t1b.a from t1 as t1a, t1 as t1b where t1a.a=t1b.a order by binary t1a.a, binary t1b.a;
a a
! !
" "
# #
$ $
% %
& &
' '
( (
) )
* *
+ +
, ,
. .
/ /
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
: :
; ;
< <
> >
? ?
@ @
A A
A a
A a
B B
B b
C C
C c
D D
D d
E E
E e
F F
F f
F f
G G
G g
H H
H h
I I
I i
J J
J j
K K
K k
L L
L l
M M
M m
N N
N n
O O
O o
P P
P p
Q Q
Q q
R R
R r
S S
S s
T T
T t
U U
U u
V V
V v
V v
W W
W w
X X
X x
Y Y
Y y
Z Z
Z z
[ [
\ \
] ]
^ ^
_ _
` `
a A
a A
a a
a a
a a
a a
b B
b b
c C
c c
d D
d d
e E
e e
f F
f F
f f
f f
f f
f f
g G
g g
h H
h h
i I
i i
j J
j j
k K
k k
l L
l l
m M
m m
n N
n n
o O
o o
p P
p p
q Q
q q
r R
r r
s S
s s
t T
t t
u U
u u
v V
v V
v v
v v
v v
v v
w W
w w
x X
x x
y Y
y y
z Z
z z
{ {
| |
} }
~ ~
drop table t1;
End of 5.0 tests.
set STORAGE_ENGINE='tokudb';
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1 (
latin1_f CHAR(32) CHARACTER SET latin1 NOT NULL
);
CREATE TABLE t2 (
latin1_f CHAR(32) CHARACTER SET latin1 COLLATE koi8r_general_ci NOT NULL
);
ERROR 42000: COLLATION 'koi8r_general_ci' is not valid for CHARACTER SET 'latin1'
CREATE TABLE t2 (
latin1_f CHAR(32) CHARACTER SET latin1 COLLATE some_non_existing_col NOT NULL
);
ERROR HY000: Unknown collation: 'some_non_existing_col'
INSERT INTO t1 (latin1_f) VALUES (_latin1'A');
INSERT INTO t1 (latin1_f) VALUES (_latin1'a');
INSERT INTO t1 (latin1_f) VALUES (_latin1'AD');
INSERT INTO t1 (latin1_f) VALUES (_latin1'ad');
INSERT INTO t1 (latin1_f) VALUES (_latin1'AE');
INSERT INTO t1 (latin1_f) VALUES (_latin1'ae');
INSERT INTO t1 (latin1_f) VALUES (_latin1'AF');
INSERT INTO t1 (latin1_f) VALUES (_latin1'af');
INSERT INTO t1 (latin1_f) VALUES (_latin1'');
INSERT INTO t1 (latin1_f) VALUES (_latin1'');
INSERT INTO t1 (latin1_f) VALUES (_latin1'');
INSERT INTO t1 (latin1_f) VALUES (_latin1'');
INSERT INTO t1 (latin1_f) VALUES (_latin1'B');
INSERT INTO t1 (latin1_f) VALUES (_latin1'b');
INSERT INTO t1 (latin1_f) VALUES (_latin1'U');
INSERT INTO t1 (latin1_f) VALUES (_latin1'u');
INSERT INTO t1 (latin1_f) VALUES (_latin1'UE');
INSERT INTO t1 (latin1_f) VALUES (_latin1'ue');
INSERT INTO t1 (latin1_f) VALUES (_latin1'');
INSERT INTO t1 (latin1_f) VALUES (_latin1'');
INSERT INTO t1 (latin1_f) VALUES (_latin1'SS');
INSERT INTO t1 (latin1_f) VALUES (_latin1'ss');
INSERT INTO t1 (latin1_f) VALUES (_latin1'');
INSERT INTO t1 (latin1_f) VALUES (_latin1'Y');
INSERT INTO t1 (latin1_f) VALUES (_latin1'y');
INSERT INTO t1 (latin1_f) VALUES (_latin1'Z');
INSERT INTO t1 (latin1_f) VALUES (_latin1'z');
SELECT latin1_f FROM t1 ORDER BY latin1_f;
latin1_f
A
a
AD
ad
ae
AE
AF
af
b
B
SS
ss
u
U
UE
ue
Y
y
Z
z
SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_swedish_ci;
latin1_f
A
a
AD
ad
ae
AE
AF
af
b
B
SS
ss
u
U
UE
ue
Y
y
Z
z
SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_german2_ci;
latin1_f
A
a
AD
ad
ae
AE
af
AF
b
B
ss
SS
U
u
ue
UE
Y
y
Z
z
SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_general_ci;
latin1_f
A
a
AD
ad
AE
ae
af
AF
b
B
ss
SS
U
u
UE
ue
Y
y
Z
z
SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_bin;
latin1_f
A
AD
AE
AF
B
SS
U
UE
Y
Z
a
ad
ae
af
b
ss
u
ue
y
z
SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE koi8r_general_ci;
ERROR 42000: COLLATION 'koi8r_general_ci' is not valid for CHARACTER SET 'latin1'
SELECT latin1_f COLLATE latin1_swedish_ci AS latin1_f_as FROM t1 ORDER BY latin1_f_as;
latin1_f_as
A
a
AD
ad
ae
AE
AF
af
b
B
SS
ss
u
U
UE
ue
Y
y
Z
z
SELECT latin1_f COLLATE latin1_german2_ci AS latin1_f_as FROM t1 ORDER BY latin1_f_as;
latin1_f_as
A
a
AD
ad
ae
AE
af
AF
b
B
ss
SS
U
u
ue
UE
Y
y
Z
z
SELECT latin1_f COLLATE latin1_general_ci AS latin1_f_as FROM t1 ORDER BY latin1_f_as;
latin1_f_as
A
a
AD
ad
AE
ae
af
AF
b
B
ss
SS
U
u
UE
ue
Y
y
Z
z
SELECT latin1_f COLLATE latin1_bin AS latin1_f_as FROM t1 ORDER BY latin1_f_as;
latin1_f_as
A
AD
AE
AF
B
SS
U
UE
Y
Z
a
ad
ae
af
b
ss
u
ue
y
z
SELECT latin1_f COLLATE koi8r_general_ci AS latin1_f_as FROM t1 ORDER BY latin1_f_as;
ERROR 42000: COLLATION 'koi8r_general_ci' is not valid for CHARACTER SET 'latin1'
SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f;
latin1_f count(*)
A 2
AD 2
AE 2
AF 2
B 2
SS 2
U 2
UE 2
4
Z 2
2
2
1
SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_swedish_ci;
latin1_f count(*)
A 2
AD 2
AE 2
AF 2
B 2
SS 2
U 2
UE 2
4
Z 2
2
2
1
SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_german2_ci;
latin1_f count(*)
A 4
AD 2
AE 4
AF 2
B 2
SS 3
U 2
UE 4
Y 2
Z 2
SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_general_ci;
latin1_f count(*)
A 2
AD 2
AE 2
AF 2
2
2
B 2
SS 2
1
U 2
UE 2
2
Y 2
Z 2
SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_bin;
latin1_f count(*)
A 1
AD 1
AE 1
AF 1
B 1
SS 1
U 1
UE 1
Y 1
Z 1
a 1
ad 1
ae 1
af 1
b 1
ss 1
u 1
ue 1
y 1
z 1
1
1
1
1
1
1
1
SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE koi8r_general_ci;
ERROR 42000: COLLATION 'koi8r_general_ci' is not valid for CHARACTER SET 'latin1'
SELECT DISTINCT latin1_f FROM t1;
latin1_f
A
AD
AE
AF
B
U
UE
SS
Z
SELECT DISTINCT latin1_f COLLATE latin1_swedish_ci FROM t1;
latin1_f COLLATE latin1_swedish_ci
A
AD
AE
AF
B
U
UE
SS
Z
SELECT DISTINCT latin1_f COLLATE latin1_german2_ci FROM t1;
latin1_f COLLATE latin1_german2_ci
A
AD
AE
AF
B
U
UE
SS
Y
Z
SELECT DISTINCT latin1_f COLLATE latin1_general_ci FROM t1;
latin1_f COLLATE latin1_general_ci
A
AD
AE
AF
B
U
UE
SS
Y
Z
SELECT DISTINCT latin1_f COLLATE latin1_bin FROM t1;
latin1_f COLLATE latin1_bin
A
a
AD
ad
AE
ae
AF
af
B
b
U
u
UE
ue
SS
ss
Y
y
Z
z
SELECT DISTINCT latin1_f COLLATE koi8r FROM t1;
ERROR HY000: Unknown collation: 'koi8r'
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`latin1_f` char(32) NOT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
SHOW FIELDS FROM t1;
Field Type Null Key Default Extra
latin1_f char(32) NO NULL
ALTER TABLE t1 CHANGE latin1_f
latin1_f CHAR(32) CHARACTER SET latin1 COLLATE latin1_bin;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`latin1_f` char(32) CHARACTER SET latin1 COLLATE latin1_bin DEFAULT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
SHOW FIELDS FROM t1;
Field Type Null Key Default Extra
latin1_f char(32) YES NULL
ALTER TABLE t1 CHARACTER SET latin1 COLLATE latin1_bin;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`latin1_f` char(32) COLLATE latin1_bin DEFAULT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin
SHOW FIELDS FROM t1;
Field Type Null Key Default Extra
latin1_f char(32) YES NULL
SET CHARACTER SET 'latin1';
SHOW VARIABLES LIKE 'character_set_client';
Variable_name Value
character_set_client latin1
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
charset('a') collation('a') coercibility('a') 'a'='A'
latin1 latin1_swedish_ci 4 1
explain extended SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
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 charset('a') AS `charset('a')`,collation('a') AS `collation('a')`,coercibility('a') AS `coercibility('a')`,('a' = 'A') AS `'a'='A'`
SET CHARACTER SET koi8r;
SHOW VARIABLES LIKE 'collation_client';
Variable_name Value
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
charset('a') collation('a') coercibility('a') 'a'='A'
latin1 latin1_swedish_ci 4 1
SET CHARACTER SET 'DEFAULT';
ERROR 42000: Unknown character set: 'DEFAULT'
DROP TABLE t1;
CREATE TABLE t1
(s1 CHAR(5) COLLATE latin1_german1_ci,
s2 CHAR(5) COLLATE latin1_swedish_ci);
SELECT * FROM t1 WHERE s1 = s2;
ERROR HY000: Illegal mix of collations (latin1_german1_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation '='
DROP TABLE t1;
CREATE TABLE t1
(s1 CHAR(5) COLLATE latin1_german1_ci,
s2 CHAR(5) COLLATE latin1_swedish_ci,
s3 CHAR(5) COLLATE latin1_bin);
INSERT INTO t1 VALUES ('a','A','A');
SELECT * FROM t1 WHERE s1 = s2;
ERROR HY000: Illegal mix of collations (latin1_german1_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation '='
SELECT * FROM t1 WHERE s1 = s3;
s1 s2 s3
SELECT * FROM t1 WHERE s2 = s3;
s1 s2 s3
a A A
DROP TABLE t1;
SET NAMES latin1;
CREATE TABLE t1
(s1 char(10) COLLATE latin1_german1_ci,
s2 char(10) COLLATE latin1_swedish_ci,
KEY(s1),
KEY(s2));
INSERT INTO t1 VALUES ('a','a');
INSERT INTO t1 VALUES ('b','b');
INSERT INTO t1 VALUES ('c','c');
INSERT INTO t1 VALUES ('d','d');
INSERT INTO t1 VALUES ('e','e');
INSERT INTO t1 VALUES ('f','f');
INSERT INTO t1 VALUES ('g','g');
INSERT INTO t1 VALUES ('h','h');
INSERT INTO t1 VALUES ('i','i');
INSERT INTO t1 VALUES ('j','j');
EXPLAIN SELECT * FROM t1 WHERE s1='a';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref s1 s1 11 const 1 Using where
EXPLAIN SELECT * FROM t1 WHERE s2='a';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref s2 s2 11 const 1 Using where
EXPLAIN SELECT * FROM t1 WHERE s1='a' COLLATE latin1_german1_ci;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref s1 s1 11 const 1 Using where
EXPLAIN SELECT * FROM t1 WHERE s2='a' COLLATE latin1_german1_ci;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL s2 NULL NULL NULL 10 Using where
EXPLAIN SELECT * FROM t1 WHERE s1 BETWEEN 'a' AND 'b' COLLATE latin1_german1_ci;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range s1 s1 11 NULL 2 Using where
EXPLAIN SELECT * FROM t1 WHERE s2 BETWEEN 'a' AND 'b' COLLATE latin1_german1_ci;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL s2 NULL NULL NULL 10 Using where
EXPLAIN SELECT * FROM t1 WHERE s1 IN ('a','b' COLLATE latin1_german1_ci);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range s1 s1 11 NULL 2 Using where
EXPLAIN SELECT * FROM t1 WHERE s2 IN ('a','b' COLLATE latin1_german1_ci);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL s2 NULL NULL NULL 10 Using where
EXPLAIN SELECT * FROM t1 WHERE s1 LIKE 'a' COLLATE latin1_german1_ci;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range s1 s1 11 NULL 1 Using where
EXPLAIN SELECT * FROM t1 WHERE s2 LIKE 'a' COLLATE latin1_german1_ci;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL s2 NULL NULL NULL 10 Using where
DROP TABLE t1;
create table t1(f1 varchar(10) character set latin2 collate latin2_hungarian_ci, key(f1));
insert into t1 set f1=0x3F3F9DC73F;
insert into t1 set f1=0x3F3F1E563F;
insert into t1 set f1=0x3F3F;
drop table t1;
create table t1 (a varchar(2) character set latin7 collate latin7_general_ci,key(a));
insert into t1 set a=0x4c20;
insert into t1 set a=0x6c;
insert into t1 set a=0x4c98;
drop table t1;
SET STORAGE_ENGINE='tokudb';
drop table if exists t1;
DROP TABLE IF EXISTS t1;
SHOW COLLATION LIKE 'cp1250_czech_cs';
Collation Charset Id Default Compiled Sortlen
cp1250_czech_cs cp1250 34 Yes 2
SET @test_character_set= 'cp1250';
SET @test_collation= 'cp1250_general_ci';
SET @safe_character_set_server= @@character_set_server;
SET @safe_collation_server= @@collation_server;
SET @safe_character_set_client= @@character_set_client;
SET @safe_character_set_results= @@character_set_results;
SET character_set_server= @test_character_set;
SET collation_server= @test_collation;
CREATE DATABASE d1;
USE d1;
CREATE TABLE t1 (c CHAR(10), KEY(c));
SHOW FULL COLUMNS FROM t1;
Field Type Collation Null Key Default Extra Privileges Comment
c char(10) cp1250_general_ci YES MUL NULL
INSERT INTO t1 VALUES ('aaa'),('aaaa'),('aaaaa');
SELECT c as want3results FROM t1 WHERE c LIKE 'aaa%';
want3results
aaa
aaaa
aaaaa
DROP TABLE t1;
CREATE TABLE t1 (c1 varchar(15), KEY c1 (c1(2)));
SHOW FULL COLUMNS FROM t1;
Field Type Collation Null Key Default Extra Privileges Comment
c1 varchar(15) cp1250_general_ci YES MUL NULL
INSERT INTO t1 VALUES ('location'),('loberge'),('lotre'),('boabab');
SELECT c1 as want3results from t1 where c1 like 'l%';
want3results
location
loberge
lotre
SELECT c1 as want3results from t1 where c1 like 'lo%';
want3results
location
loberge
lotre
SELECT c1 as want1result from t1 where c1 like 'loc%';
want1result
location
SELECT c1 as want1result from t1 where c1 like 'loca%';
want1result
location
SELECT c1 as want1result from t1 where c1 like 'locat%';
want1result
location
SELECT c1 as want1result from t1 where c1 like 'locati%';
want1result
location
SELECT c1 as want1result from t1 where c1 like 'locatio%';
want1result
location
SELECT c1 as want1result from t1 where c1 like 'location%';
want1result
location
DROP TABLE t1;
create table t1 (a set('a') not null);
insert into t1 values (),();
Warnings:
Warning 1364 Field 'a' doesn't have a default value
select cast(a as char(1)) from t1;
cast(a as char(1))
select a sounds like a from t1;
a sounds like a
1
1
select 1 from t1 order by cast(a as char(1));
1
1
1
drop table t1;
set names utf8;
create table t1 (
name varchar(10),
level smallint unsigned);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`name` varchar(10) DEFAULT NULL,
`level` smallint(5) unsigned DEFAULT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=cp1250
insert into t1 values ('string',1);
select concat(name,space(level)), concat(name, repeat(' ',level)) from t1;
concat(name,space(level)) concat(name, repeat(' ',level))
string string
drop table t1;
DROP DATABASE d1;
USE test;
SET character_set_server= @safe_character_set_server;
SET collation_server= @safe_collation_server;
SET character_set_client= @safe_character_set_client;
SET character_set_results= @safe_character_set_results;
SET @test_character_set= 'cp1250';
SET @test_collation= 'cp1250_czech_cs';
SET @safe_character_set_server= @@character_set_server;
SET @safe_collation_server= @@collation_server;
SET @safe_character_set_client= @@character_set_client;
SET @safe_character_set_results= @@character_set_results;
SET character_set_server= @test_character_set;
SET collation_server= @test_collation;
CREATE DATABASE d1;
USE d1;
CREATE TABLE t1 (c CHAR(10), KEY(c));
SHOW FULL COLUMNS FROM t1;
Field Type Collation Null Key Default Extra Privileges Comment
c char(10) cp1250_czech_cs YES MUL NULL
INSERT INTO t1 VALUES ('aaa'),('aaaa'),('aaaaa');
SELECT c as want3results FROM t1 WHERE c LIKE 'aaa%';
want3results
aaa
aaaa
aaaaa
DROP TABLE t1;
CREATE TABLE t1 (c1 varchar(15), KEY c1 (c1(2)));
SHOW FULL COLUMNS FROM t1;
Field Type Collation Null Key Default Extra Privileges Comment
c1 varchar(15) cp1250_czech_cs YES MUL NULL
INSERT INTO t1 VALUES ('location'),('loberge'),('lotre'),('boabab');
SELECT c1 as want3results from t1 where c1 like 'l%';
want3results
location
loberge
lotre
SELECT c1 as want3results from t1 where c1 like 'lo%';
want3results
location
loberge
lotre
SELECT c1 as want1result from t1 where c1 like 'loc%';
want1result
location
SELECT c1 as want1result from t1 where c1 like 'loca%';
want1result
location
SELECT c1 as want1result from t1 where c1 like 'locat%';
want1result
location
SELECT c1 as want1result from t1 where c1 like 'locati%';
want1result
location
SELECT c1 as want1result from t1 where c1 like 'locatio%';
want1result
location
SELECT c1 as want1result from t1 where c1 like 'location%';
want1result
location
DROP TABLE t1;
create table t1 (a set('a') not null);
insert into t1 values (),();
Warnings:
Warning 1364 Field 'a' doesn't have a default value
select cast(a as char(1)) from t1;
cast(a as char(1))
select a sounds like a from t1;
a sounds like a
1
1
select 1 from t1 order by cast(a as char(1));
1
1
1
drop table t1;
set names utf8;
create table t1 (
name varchar(10),
level smallint unsigned);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`name` varchar(10) COLLATE cp1250_czech_cs DEFAULT NULL,
`level` smallint(5) unsigned DEFAULT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs
insert into t1 values ('string',1);
select concat(name,space(level)), concat(name, repeat(' ',level)) from t1;
concat(name,space(level)) concat(name, repeat(' ',level))
string string
drop table t1;
DROP DATABASE d1;
USE test;
SET character_set_server= @safe_character_set_server;
SET collation_server= @safe_collation_server;
SET character_set_client= @safe_character_set_client;
SET character_set_results= @safe_character_set_results;
CREATE TABLE t1 (a char(16)) character set cp1250 collate cp1250_czech_cs;
INSERT INTO t1 VALUES ('');
SELECT a, length(a), a='', a=' ', a=' ' FROM t1;
a length(a) a='' a=' ' a=' '
0 1 1 1
DROP TABLE t1;
CREATE TABLE t1 (
popisek varchar(30) collate cp1250_general_ci NOT NULL default '',
PRIMARY KEY (`popisek`)
);
INSERT INTO t1 VALUES ('2005-01-1');
SELECT * FROM t1 WHERE popisek = '2005-01-1';
popisek
2005-01-1
SELECT * FROM t1 WHERE popisek LIKE '2005-01-1';
popisek
2005-01-1
drop table t1;
set names cp1250;
CREATE TABLE t1
(
id INT AUTO_INCREMENT PRIMARY KEY,
str VARCHAR(32) CHARACTER SET cp1250 COLLATE cp1250_czech_cs NOT NULL default '',
UNIQUE KEY (str)
);
INSERT INTO t1 VALUES (NULL, 'a');
INSERT INTO t1 VALUES (NULL, 'aa');
INSERT INTO t1 VALUES (NULL, 'aaa');
INSERT INTO t1 VALUES (NULL, 'aaaa');
INSERT INTO t1 VALUES (NULL, 'aaaaa');
INSERT INTO t1 VALUES (NULL, 'aaaaaa');
INSERT INTO t1 VALUES (NULL, 'aaaaaaa');
select * from t1 where str like 'aa%';
id str
2 aa
3 aaa
4 aaaa
5 aaaaa
6 aaaaaa
7 aaaaaaa
drop table t1;
set names cp1250;
create table t1 (a varchar(15) collate cp1250_czech_cs NOT NULL, primary key(a));
insert into t1 values("abcdefgh");
insert into t1 values("");
select a from t1 where a like "abcdefgh";
a
abcdefgh
drop table t1;
SET STORAGE_ENGINE='tokudb';
drop table if exists t1;
SET NAMES cp1251;
create table t1 (a varchar(10) not null) character set cp1251;
insert into t1 values ("a"),("ab"),("abc");
select * from t1;
a
a
ab
abc
select a, left(a,1) as b from t1;
a b
a a
ab a
abc a
select a, left(a,1) as b from t1 group by a;
a b
a a
ab a
abc a
SELECT DISTINCT RIGHT(a,1) from t1;
RIGHT(a,1)
a
b
c
drop table t1;
create table t1 (a char(3) binary, b binary(3)) character set cp1251;
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')
cp1251 binary binary
select collation(a), collation(b), collation(binary 'ccc') from t1 limit 1;
collation(a) collation(b) collation(binary 'ccc')
cp1251_bin binary binary
drop table t1;
create table t1 (
a varchar(16) character set cp1251 collate cp1251_bin not null,
b int(10) default null,
primary key(a)
) charset=cp1251;
insert into t1 (a) values ('air'),
('we'),('g'),('we_toshko'), ('s0urce'),('we_ivo'),('we_iliyan'),
('we_martin'),('vw_grado'),('vw_vasko'),('tn_vili'),('tn_kalina'),
('tn_fakira'),('vw_silvia'),('vw_starshi'),('vw_geo'),('vw_b0x1');
select * from t1 where a like 'we_%';
a b
we_iliyan NULL
we_ivo NULL
we_martin NULL
we_toshko NULL
drop table t1;
SET STORAGE_ENGINE='tokudb';
drop table if exists t1;
create table t1 (s1 binary(3));
insert into t1 values (0x61), (0x6120), (0x612020);
select hex(s1) from t1;
hex(s1)
610000
612000
612020
drop table t1;
create table t1 (s1 binary(2), s2 varbinary(2));
insert into t1 values (0x4100,0x4100);
select length(concat('*',s1,'*',s2,'*')) from t1;
length(concat('*',s1,'*',s2,'*'))
7
delete from t1;
insert into t1 values (0x4120,0x4120);
select length(concat('*',s1,'*',s2,'*')) from t1;
length(concat('*',s1,'*',s2,'*'))
7
drop table t1;
create table t1 (s1 varbinary(20), s2 varbinary(20));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`s1` varbinary(20) DEFAULT NULL,
`s2` varbinary(20) DEFAULT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
insert into t1 values (0x41,0x4100),(0x41,0x4120),(0x4100,0x4120);
select hex(s1), hex(s2) from t1;
hex(s1) hex(s2)
41 4100
41 4120
4100 4120
select count(*) from t1 where s1 < s2;
count(*)
3
drop table t1;
create table t1 (s1 varbinary(2), s2 varchar(1));
insert into t1 values (0x41,'a'), (0x4100,'b'), (0x41,'c'), (0x4100,'d');
select hex(s1),s2 from t1 order by s1,s2;
hex(s1) s2
41 a
41 c
4100 b
4100 d
drop table t1;
create table t1 (s1 binary(2) primary key);
insert into t1 values (0x01);
insert into t1 values (0x0120);
insert into t1 values (0x0100);
ERROR 23000: Duplicate entry '' for key 'PRIMARY'
select hex(s1) from t1 order by s1;
hex(s1)
0100
0120
select hex(s1) from t1 where s1=0x01;
hex(s1)
select hex(s1) from t1 where s1=0x0120;
hex(s1)
0120
select hex(s1) from t1 where s1=0x0100;
hex(s1)
0100
select count(distinct s1) from t1;
count(distinct s1)
2
alter table t1 drop primary key;
select hex(s1) from t1 where s1=0x01;
hex(s1)
select hex(s1) from t1 where s1=0x0120;
hex(s1)
0120
select hex(s1) from t1 where s1=0x0100;
hex(s1)
0100
select count(distinct s1) from t1;
count(distinct s1)
2
drop table t1;
create table t1 (s1 varbinary(2) primary key);
insert into t1 values (0x01);
insert into t1 values (0x0120);
insert into t1 values (0x0100);
select hex(s1) from t1 order by s1;
hex(s1)
01
0100
0120
select hex(s1) from t1 where s1=0x01;
hex(s1)
01
select hex(s1) from t1 where s1=0x0120;
hex(s1)
0120
select hex(s1) from t1 where s1=0x0100;
hex(s1)
0100
select count(distinct s1) from t1;
count(distinct s1)
3
alter table t1 drop primary key;
select hex(s1) from t1 where s1=0x01;
hex(s1)
01
select hex(s1) from t1 where s1=0x0120;
hex(s1)
0120
select hex(s1) from t1 where s1=0x0100;
hex(s1)
0100
select count(distinct s1) from t1;
count(distinct s1)
3
drop table t1;
select hex(cast(0x10 as binary(2)));
hex(cast(0x10 as binary(2)))
1000
create table t1 (b binary(2), vb varbinary(2));
insert into t1 values(0x4120, 0x4120);
insert into t1 values(0x412020, 0x412020);
Warnings:
Warning 1265 Data truncated for column 'b' at row 1
Warning 1265 Data truncated for column 'vb' at row 1
drop table t1;
create table t1 (c char(2), vc varchar(2));
insert into t1 values(0x4120, 0x4120);
insert into t1 values(0x412020, 0x412020);
Warnings:
Note 1265 Data truncated for column 'vc' at row 1
drop table t1;
set @old_sql_mode= @@sql_mode, sql_mode= 'traditional';
create table t1 (b binary(2), vb varbinary(2));
insert into t1 values(0x4120, 0x4120);
insert into t1 values(0x412020, NULL);
ERROR 22001: Data too long for column 'b' at row 1
insert into t1 values(NULL, 0x412020);
ERROR 22001: Data too long for column 'vb' at row 1
drop table t1;
set @@sql_mode= @old_sql_mode;
create table t1(f1 int, f2 binary(2) not null, f3 char(2) not null);
insert into t1 set f1=1;
Warnings:
Warning 1364 Field 'f2' doesn't have a default value
Warning 1364 Field 'f3' doesn't have a default value
select hex(f2), hex(f3) from t1;
hex(f2) hex(f3)
0000
drop table t1;
End of 5.0 tests
SET STORAGE_ENGINE='tokudb';
select 0 + b'1';
0 + b'1'
1
select 0 + b'0';
0 + b'0'
0
select 0 + b'000001';
0 + b'000001'
1
select 0 + b'000011';
0 + b'000011'
3
select 0 + b'000101';
0 + b'000101'
5
select 0 + b'000000';
0 + b'000000'
0
select 0 + b'10000000';
0 + b'10000000'
128
select 0 + b'11111111';
0 + b'11111111'
255
select 0 + b'10000001';
0 + b'10000001'
129
select 0 + b'1000000000000000';
0 + b'1000000000000000'
32768
select 0 + b'1111111111111111';
0 + b'1111111111111111'
65535
select 0 + b'1000000000000001';
0 + b'1000000000000001'
32769
drop table if exists t1,t2;
create table t1 (a bit(65));
ERROR 42000: Display width out of range for column 'a' (max = 64)
create table t1 (a bit(0));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` bit(1) DEFAULT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
drop table t1;
create table t1 (a bit(64));
insert into t1 values
(b'1111111111111111111111111111111111111111111111111111111111111111'),
(b'1000000000000000000000000000000000000000000000000000000000000000'),
(b'0000000000000000000000000000000000000000000000000000000000000001'),
(b'1010101010101010101010101010101010101010101010101010101010101010'),
(b'0101010101010101010101010101010101010101010101010101010101010101');
select hex(a) from t1;
hex(a)
FFFFFFFFFFFFFFFF
8000000000000000
1
AAAAAAAAAAAAAAAA
5555555555555555
drop table t1;
create table t1 (a bit);
insert into t1 values (b'0'), (b'1'), (b'000'), (b'100'), (b'001');
Warnings:
Warning 1264 Out of range value for column 'a' at row 4
select hex(a) from t1;
hex(a)
0
1
0
1
1
alter table t1 add unique (a);
ERROR 23000: Can't write; duplicate key in table 't1'
drop table t1;
create table t1 (a bit(2));
insert into t1 values (b'00'), (b'01'), (b'10'), (b'100');
Warnings:
Warning 1264 Out of range value for column 'a' at row 4
select a+0 from t1;
a+0
0
1
2
3
alter table t1 add key (a);
explain select a+0 from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL a 2 NULL 4 Using index
select a+0 from t1;
a+0
0
1
2
3
drop table t1;
create table t1 (a bit(7), b bit(9), key(a, b));
insert into t1 values
(94, 46), (31, 438), (61, 152), (78, 123), (88, 411), (122, 118), (0, 177),
(75, 42), (108, 67), (79, 349), (59, 188), (68, 206), (49, 345), (118, 380),
(111, 368), (94, 468), (56, 379), (77, 133), (29, 399), (9, 363), (23, 36),
(116, 390), (119, 368), (87, 351), (123, 411), (24, 398), (34, 202), (28, 499),
(30, 83), (5, 178), (60, 343), (4, 245), (104, 280), (106, 446), (127, 403),
(44, 307), (68, 454), (57, 135);
explain select a+0 from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL a 5 NULL 38 Using index
select a+0 from t1;
a+0
0
4
5
9
23
24
28
29
30
31
34
44
49
56
57
59
60
61
68
68
75
77
78
79
87
88
94
94
104
106
108
111
116
118
119
122
123
127
explain select b+0 from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL a 5 NULL 38 Using index
select b+0 from t1;
b+0
177
245
178
363
36
398
499
399
83
438
202
307
345
379
135
188
343
152
206
454
42
133
123
349
351
411
46
468
280
446
67
368
390
380
368
118
411
403
explain select a+0, b+0 from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL a 5 NULL 38 Using index
select a+0, b+0 from t1;
a+0 b+0
0 177
4 245
5 178
9 363
23 36
24 398
28 499
29 399
30 83
31 438
34 202
44 307
49 345
56 379
57 135
59 188
60 343
61 152
68 206
68 454
75 42
77 133
78 123
79 349
87 351
88 411
94 46
94 468
104 280
106 446
108 67
111 368
116 390
118 380
119 368
122 118
123 411
127 403
explain select a+0, b+0 from t1 where a > 40 and b > 200 order by 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 2 NULL 27 Using where; Using index; Using filesort
select a+0, b+0 from t1 where a > 40 and b > 200 order by 1;
a+0 b+0
44 307
49 345
56 379
60 343
68 206
68 454
79 349
87 351
88 411
94 468
104 280
106 446
111 368
116 390
118 380
119 368
123 411
127 403
explain select a+0, b+0 from t1 where a > 40 and a < 70 order by 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 2 NULL 9 Using where; Using index; Using filesort
select a+0, b+0 from t1 where a > 40 and a < 70 order by 2;
a+0 b+0
57 135
61 152
59 188
68 206
44 307
60 343
49 345
56 379
68 454
set @@max_length_for_sort_data=0;
Warnings:
Warning 1292 Truncated incorrect max_length_for_sort_data value: '0'
select a+0, b+0 from t1 where a > 40 and a < 70 order by 2;
a+0 b+0
57 135
61 152
59 188
68 206
44 307
60 343
49 345
56 379
68 454
select hex(min(a)) from t1;
hex(min(a))
0
select hex(min(b)) from t1;
hex(min(b))
24
select hex(min(a)), hex(max(a)), hex(min(b)), hex(max(b)) from t1;
hex(min(a)) hex(max(a)) hex(min(b)) hex(max(b))
0 7F 24 1F3
drop table t1;
create table t1 (a int not null, b bit, c bit(9), key(a, b, c));
insert into t1 values
(4, NULL, 1), (4, 0, 3), (2, 1, 4), (1, 1, 100), (4, 0, 23), (4, 0, 54),
(56, 0, 22), (4, 1, 100), (23, 0, 1), (4, 0, 34);
select a+0, b+0, c+0 from t1;
a+0 b+0 c+0
1 1 100
2 1 4
4 NULL 1
4 0 3
4 0 23
4 0 34
4 0 54
4 1 100
23 0 1
56 0 22
select hex(min(b)) from t1 where a = 4;
hex(min(b))
0
select hex(min(c)) from t1 where a = 4 and b = 0;
hex(min(c))
3
select hex(max(b)) from t1;
hex(max(b))
1
select a+0, b+0, c+0 from t1 where a = 4 and b = 0 limit 2;
a+0 b+0 c+0
4 0 3
4 0 23
select a+0, b+0, c+0 from t1 where a = 4 and b = 1;
a+0 b+0 c+0
4 1 100
select a+0, b+0, c+0 from t1 where a = 4 and b = 1 and c=100;
a+0 b+0 c+0
4 1 100
select a+0, b+0, c+0 from t1 order by b desc;
a+0 b+0 c+0
2 1 4
1 1 100
4 1 100
4 0 3
4 0 23
4 0 54
56 0 22
23 0 1
4 0 34
4 NULL 1
select a+0, b+0, c+0 from t1 order by c;
a+0 b+0 c+0
4 NULL 1
23 0 1
4 0 3
2 1 4
56 0 22
4 0 23
4 0 34
4 0 54
1 1 100
4 1 100
drop table t1;
create table t1(a bit(2), b bit(2));
insert into t1 (a) values (0x01), (0x03), (0x02);
update t1 set b= concat(a);
select a+0, b+0 from t1;
a+0 b+0
1 1
3 3
2 2
drop table t1;
create table t1 (a bit(7), key(a));
insert into t1 values (44), (57);
select a+0 from t1;
a+0
44
57
drop table t1;
create table t1 (a bit(3), b bit(12));
insert into t1 values (7,(1<<12)-2), (0x01,0x01ff);
select hex(a),hex(b) from t1;
hex(a) hex(b)
7 FFE
1 1FF
select hex(concat(a)),hex(concat(b)) from t1;
hex(concat(a)) hex(concat(b))
07 0FFE
01 01FF
drop table t1;
create table t1(a int, b bit not null);
alter table t1 add primary key (a);
drop table t1;
create table t1 (a bit(19), b bit(5));
insert into t1 values (1000, 10), (3, 8), (200, 6), (2303, 2), (12345, 4), (1, 0);
select a+0, b+0 from t1;
a+0 b+0
1000 10
3 8
200 6
2303 2
12345 4
1 0
alter table t1 engine=heap;
select a+0, b+0 from t1;
a+0 b+0
1000 10
3 8
200 6
2303 2
12345 4
1 0
alter table t1 add key(a, b);
select a+0, b+0 from t1;
a+0 b+0
1000 10
3 8
200 6
2303 2
12345 4
1 0
alter table t1 engine=myisam;
select a+0, b+0 from t1;
a+0 b+0
1 0
3 8
200 6
1000 10
2303 2
12345 4
create table t2 engine=heap select * from t1;
select a+0, b+0 from t2;
a+0 b+0
1 0
3 8
200 6
1000 10
2303 2
12345 4
drop table t1;
create table t1 select * from t2;
select a+0, b+0 from t1;
a+0 b+0
1 0
3 8
200 6
1000 10
2303 2
12345 4
drop table t1, t2;
create table t1 (a int, b time, c tinyint, d bool, e char(10), f bit(1),
g bit(1) NOT NULL default 1, h char(1) default 'a');
insert into t1 set a=1;
select hex(g), h from t1;
hex(g) h
1 a
drop table t1;
create table t1 (a int, b time, c tinyint, d bool, e char(10), f bit(1),
g bit(1) NOT NULL default 1);
insert into t1 set a=1;
select hex(g) from t1;
hex(g)
1
drop table t1;
create table t1 (a int, b time, c tinyint, d bool, e char(10), f bit(1),
h char(1) default 'a') engine=myisam;
insert into t1 set a=1;
select h from t1;
h
a
drop table t1;
create table t1 (a bit(8)) engine=heap;
insert into t1 values ('1111100000');
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
select a+0 from t1;
a+0
255
drop table t1;
create table t1 (a bit(7));
insert into t1 values (120), (0), (111);
select a+0 from t1 union select a+0 from t1;
a+0
120
0
111
select a+0 from t1 union select NULL;
a+0
120
0
111
NULL
select NULL union select a+0 from t1;
NULL
NULL
120
0
111
create table t2 select a from t1 union select a from t1;
select a+0 from t2;
a+0
120
0
111
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`a` bit(7) DEFAULT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
drop table t1, t2;
create table t1 (id1 int(11), b1 bit(1));
create table t2 (id2 int(11), b2 bit(1));
insert into t1 values (1, 1), (2, 0), (3, 1);
insert into t2 values (2, 1), (3, 0), (4, 0);
create algorithm=undefined view v1 as
select b1+0, b2+0 from t1, t2 where id1 = id2 and b1 = 0
union
select b1+0, b2+0 from t1, t2 where id1 = id2 and b2 = 1;
select * from v1;
b1+0 b2+0
0 1
drop table t1, t2;
drop view v1;
create table t1(a bit(4));
insert into t1(a) values (1), (2), (5), (4), (3);
insert into t1 select * from t1;
select a+0 from t1;
a+0
1
2
5
4
3
1
2
5
4
3
drop table t1;
create table t1 (a1 int(11), b1 bit(2));
create table t2 (a2 int(11), b2 bit(2));
insert into t1 values (1, 1), (2, 0), (3, 1), (4, 2);
insert into t2 values (2, 1), (3, 0), (4, 1), (5, 2);
select a1, a2, b1+0, b2+0 from t1 join t2 on a1 = a2;
a1 a2 b1+0 b2+0
2 2 0 1
3 3 1 0
4 4 2 1
select a1, a2, b1+0, b2+0 from t1 join t2 on a1 = a2 order by a1;
a1 a2 b1+0 b2+0
2 2 0 1
3 3 1 0
4 4 2 1
select a1, a2, b1+0, b2+0 from t1 join t2 on b1 = b2;
a1 a2 b1+0 b2+0
1 2 1 1
3 2 1 1
2 3 0 0
1 4 1 1
3 4 1 1
4 5 2 2
select sum(a1), b1+0, b2+0 from t1 join t2 on b1 = b2 group by b1 order by 1;
sum(a1) b1+0 b2+0
2 0 0
4 2 2
8 1 1
select 1 from t1 join t2 on b1 = b2 group by b1 order by 1;
1
1
1
1
select b1+0,sum(b1), sum(b2) from t1 join t2 on b1 = b2 group by b1 order by 1;
b1+0 sum(b1) sum(b2)
0 0 0
1 4 4
2 2 2
drop table t1, t2;
create table t1 (a bit(7));
insert into t1 values (0x60);
select * from t1;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def test t1 t1 a a 16 7 1 Y 32 0 63
a
`
drop table t1;
create table bug15583(b BIT(8), n INT);
insert into bug15583 values(128, 128);
insert into bug15583 values(null, null);
insert into bug15583 values(0, 0);
insert into bug15583 values(255, 255);
select hex(b), bin(b), oct(b), hex(n), bin(n), oct(n) from bug15583;
hex(b) bin(b) oct(b) hex(n) bin(n) oct(n)
80 10000000 200 80 10000000 200
NULL NULL NULL NULL NULL NULL
0 0 0 0 0 0
FF 11111111 377 FF 11111111 377
select hex(b)=hex(n) as should_be_onetrue, bin(b)=bin(n) as should_be_onetrue, oct(b)=oct(n) as should_be_onetrue from bug15583;
should_be_onetrue should_be_onetrue should_be_onetrue
1 1 1
NULL NULL NULL
1 1 1
1 1 1
select hex(b + 0), bin(b + 0), oct(b + 0), hex(n), bin(n), oct(n) from bug15583;
hex(b + 0) bin(b + 0) oct(b + 0) hex(n) bin(n) oct(n)
80 10000000 200 80 10000000 200
NULL NULL NULL NULL NULL NULL
0 0 0 0 0 0
FF 11111111 377 FF 11111111 377
select conv(b, 10, 2), conv(b + 0, 10, 2) from bug15583;
conv(b, 10, 2) conv(b + 0, 10, 2)
10000000 10000000
NULL NULL
0 0
11111111 11111111
drop table bug15583;
create table t1(a bit(1), b smallint unsigned);
insert into t1 (b, a) values ('2', '1');
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
select hex(a), b from t1;
hex(a) b
1 2
drop table t1;
CREATE TABLE t1 (b BIT(2), a VARCHAR(5));
INSERT INTO t1 (b, a) VALUES (1, "x"), (3, "zz"), (0, "y"), (3, "z");
SELECT b+0, COUNT(DISTINCT a) FROM t1 GROUP BY b;
b+0 COUNT(DISTINCT a)
0 1
1 1
3 2
DROP TABLE t1;
CREATE TABLE t1 (a CHAR(5), b BIT(2));
INSERT INTO t1 (b, a) VALUES (1, "x"), (3, "zz"), (0, "y"), (3, "z");
SELECT b+0, COUNT(DISTINCT a) FROM t1 GROUP BY b;
b+0 COUNT(DISTINCT a)
0 1
1 1
3 2
DROP TABLE t1;
CREATE TABLE t1 (a INT, b BIT(2));
INSERT INTO t1 (b, a) VALUES (1, 1), (3, 2), (0, 3), (3, 4);
SELECT b+0, COUNT(DISTINCT a) FROM t1 GROUP BY b;
b+0 COUNT(DISTINCT a)
0 1
1 1
3 2
DROP TABLE t1;
CREATE TABLE t1 (b BIT);
INSERT INTO t1 (b) VALUES (1), (0);
SELECT DISTINCT b FROM t1;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def test t1 t1 b b 16 1 1 Y 32 0 63
b
#
#
SELECT b FROM t1 GROUP BY b;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def test t1 t1 b b 16 1 1 Y 32 0 63
b
#
#
DROP TABLE t1;
CREATE TABLE t1 (a int, b bit(2));
INSERT INTO t1 VALUES (3, 2), (2, 3), (2, 0), (3, 2), (3, 1);
SELECT COUNT(DISTINCT b) FROM t1 GROUP BY a;
COUNT(DISTINCT b)
2
2
DROP TABLE t1;
create table t2 (a int, b bit(2), c char(10));
INSERT INTO t2 VALUES (3, 2, 'two'), (2, 3, 'three'), (2, 0, 'zero'),
(3, 2, 'two'), (3, 1, 'one');
SELECT COUNT(DISTINCT b,c) FROM t2 GROUP BY a;
COUNT(DISTINCT b,c)
2
2
DROP TABLE t2;
CREATE TABLE t1(a BIT(13), KEY(a));
INSERT INTO t1(a) VALUES
(65535),(65525),(65535),(65535),(65535),(65535),(65535),(65535),(65535),(65535);
EXPLAIN SELECT 1 FROM t1 GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL a 3 NULL 6 Using index for group-by
SELECT 1 FROM t1 GROUP BY a;
1
1
DROP TABLE t1;
End of 5.0 tests
create table t1(a bit(7));
insert into t1 values(0x40);
alter table t1 modify column a bit(8);
select hex(a) from t1;
hex(a)
40
insert into t1 values(0x80);
select hex(a) from t1;
hex(a)
40
80
create index a on t1(a);
insert into t1 values(0x81);
select hex(a) from t1;
hex(a)
40
80
81
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` bit(8) DEFAULT NULL,
KEY `a` (`a`)
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
drop table t1;
End of 5.1 tests
set storage_engine='tokudb';
drop table if exists t,t1,t2,t3,t4,t5,t6,t7;
CREATE TABLE t1 (a blob, b text, c blob(250), d text(70000), e text(70000000));
show columns from t1;
Field Type Null Key Default Extra
a blob YES NULL
b text YES NULL
c tinyblob YES NULL
d mediumtext YES NULL
e longtext YES NULL
CREATE TABLE t2 (a char(255), b varbinary(70000), c varchar(70000000));
Warnings:
Note 1246 Converting column 'b' from VARBINARY to BLOB
Note 1246 Converting column 'c' from VARCHAR to TEXT
CREATE TABLE t4 (c varchar(65530) character set utf8 not null);
Warnings:
Note 1246 Converting column 'c' from VARCHAR to TEXT
show columns from t2;
Field Type Null Key Default Extra
a char(255) YES NULL
b mediumblob YES NULL
c longtext YES NULL
create table t3 (a long, b long byte);
show create TABLE t3;
Table Create Table
t3 CREATE TABLE `t3` (
`a` mediumtext,
`b` mediumblob
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
show create TABLE t4;
Table Create Table
t4 CREATE TABLE `t4` (
`c` mediumtext CHARACTER SET utf8 NOT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
drop table t1,t2,t3,t4;
CREATE TABLE t1 (a char(257) default "hello");
ERROR 42000: Column length too big for column 'a' (max = 255); use BLOB or TEXT instead
CREATE TABLE t2 (a char(256));
ERROR 42000: Column length too big for column 'a' (max = 255); use BLOB or TEXT instead
CREATE TABLE t1 (a varchar(70000) default "hello");
ERROR 42000: Column length too big for column 'a' (max = 65535); use BLOB or TEXT instead
CREATE TABLE t2 (a blob default "hello");
ERROR 42000: BLOB/TEXT column 'a' can't have a default value
drop table if exists t1,t2;
create table t1 (nr int(5) not null auto_increment,b blob,str char(10), primary key (nr));
insert into t1 values (null,"a","A");
insert into t1 values (null,"bbb","BBB");
insert into t1 values (null,"ccc","CCC");
select last_insert_id();
last_insert_id()
3
select * from t1,t1 as t2;
nr b str nr b str
1 a A 1 a A
2 bbb BBB 1 a A
3 ccc CCC 1 a A
1 a A 2 bbb BBB
2 bbb BBB 2 bbb BBB
3 ccc CCC 2 bbb BBB
1 a A 3 ccc CCC
2 bbb BBB 3 ccc CCC
3 ccc CCC 3 ccc CCC
drop table t1;
create table t1 (a text);
insert into t1 values ('where');
update t1 set a='Where';
select * from t1;
a
Where
drop table t1;
create table t1 (t text,c char(10),b blob, d varbinary(10));
insert into t1 values (NULL,NULL,NULL,NULL);
insert into t1 values ("","","","");
insert into t1 values ("hello","hello","hello","hello");
insert into t1 values ("HELLO","HELLO","HELLO","HELLO");
insert into t1 values ("HELLO MY","HELLO MY","HELLO MY","HELLO MY");
insert into t1 values ("a","a","a","a");
insert into t1 values (1,1,1,1);
insert into t1 values (NULL,NULL,NULL,NULL);
update t1 set c="",b=null where c="1";
lock tables t1 READ;
show full fields from t1;
Field Type Collation Null Key Default Extra Privileges Comment
t text latin1_swedish_ci YES NULL #
c char(10) latin1_swedish_ci YES NULL #
b blob NULL YES NULL #
d varbinary(10) NULL YES NULL #
lock tables t1 WRITE;
show full fields from t1;
Field Type Collation Null Key Default Extra Privileges Comment
t text latin1_swedish_ci YES NULL #
c char(10) latin1_swedish_ci YES NULL #
b blob NULL YES NULL #
d varbinary(10) NULL YES NULL #
unlock tables;
select t from t1 where t like "hello";
t
hello
HELLO
select c from t1 where c like "hello";
c
hello
HELLO
select b from t1 where b like "hello";
b
hello
select d from t1 where d like "hello";
d
hello
select c from t1 having c like "hello";
c
hello
HELLO
select d from t1 having d like "hello";
d
hello
select t from t1 where t like "%HELLO%";
t
hello
HELLO
HELLO MY
select c from t1 where c like "%HELLO%";
c
hello
HELLO
HELLO MY
select b from t1 where b like "%HELLO%";
b
HELLO
HELLO MY
select d from t1 where d like "%HELLO%";
d
HELLO
HELLO MY
select c from t1 having c like "%HELLO%";
c
hello
HELLO
HELLO MY
select d from t1 having d like "%HELLO%";
d
HELLO
HELLO MY
select d from t1 having d like "%HE%LLO%";
d
HELLO
HELLO MY
select t from t1 order by t;
t
NULL
NULL
1
a
hello
HELLO
HELLO MY
select c from t1 order by c;
c
NULL
NULL
a
hello
HELLO
HELLO MY
select b from t1 order by b;
b
NULL
NULL
NULL
HELLO
HELLO MY
a
hello
select d from t1 order by d;
d
NULL
NULL
1
HELLO
HELLO MY
a
hello
select distinct t from t1;
t
NULL
hello
HELLO MY
a
1
select distinct b from t1;
b
NULL
hello
HELLO
HELLO MY
a
select distinct t from t1 order by t;
t
NULL
1
a
hello
HELLO MY
select distinct b from t1 order by b;
b
NULL
HELLO
HELLO MY
a
hello
select t from t1 group by t;
t
NULL
1
a
hello
HELLO MY
select b from t1 group by b;
b
NULL
HELLO
HELLO MY
a
hello
set option sql_big_tables=1;
select distinct t from t1;
t
NULL
hello
HELLO MY
a
1
select distinct b from t1;
b
NULL
hello
HELLO
HELLO MY
a
select distinct t from t1 order by t;
t
NULL
1
a
hello
HELLO MY
select distinct b from t1 order by b;
b
NULL
HELLO
HELLO MY
a
hello
select distinct c from t1;
c
NULL
hello
HELLO MY
a
select distinct d from t1;
d
NULL
hello
HELLO
HELLO MY
a
1
select distinct c from t1 order by c;
c
NULL
a
hello
HELLO MY
select distinct d from t1 order by d;
d
NULL
1
HELLO
HELLO MY
a
hello
select c from t1 group by c;
c
NULL
a
hello
HELLO MY
select d from t1 group by d;
d
NULL
1
HELLO
HELLO MY
a
hello
set option sql_big_tables=0;
select distinct * from t1;
t c b d
NULL NULL NULL NULL
hello hello hello hello
HELLO HELLO HELLO HELLO
HELLO MY HELLO MY HELLO MY HELLO MY
a a a a
1 NULL 1
select t,count(*) from t1 group by t;
t count(*)
NULL 2
1
1 1
a 1
hello 2
HELLO MY 1
select b,count(*) from t1 group by b;
b count(*)
NULL 3
1
HELLO 1
HELLO MY 1
a 1
hello 1
select c,count(*) from t1 group by c;
c count(*)
NULL 2
2
a 1
hello 2
HELLO MY 1
select d,count(*) from t1 group by d;
d count(*)
NULL 2
1
1 1
HELLO 1
HELLO MY 1
a 1
hello 1
drop table t1;
create table t1 (a text, unique (a(2100)));
drop table t1;
create table t1 (a text, key (a(2100)));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text,
KEY `a` (`a`(2100))
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
drop table t1;
CREATE TABLE t1 (
t1_id bigint(21) NOT NULL auto_increment,
_field_72 varchar(128) DEFAULT '' NOT NULL,
_field_95 varchar(32),
_field_115 tinyint(4) DEFAULT '0' NOT NULL,
_field_122 tinyint(4) DEFAULT '0' NOT NULL,
_field_126 tinyint(4),
_field_134 tinyint(4),
PRIMARY KEY (t1_id),
UNIQUE _field_72 (_field_72),
KEY _field_115 (_field_115),
KEY _field_122 (_field_122)
);
INSERT INTO t1 VALUES (1,'admin','21232f297a57a5a743894a0e4a801fc3',0,1,NULL,NULL);
INSERT INTO t1 VALUES (2,'hroberts','7415275a8c95952901e42b13a6b78566',0,1,NULL,NULL);
INSERT INTO t1 VALUES (3,'guest','d41d8cd98f00b204e9800998ecf8427e',1,0,NULL,NULL);
CREATE TABLE t2 (
seq_0_id bigint(21) DEFAULT '0' NOT NULL,
seq_1_id bigint(21) DEFAULT '0' NOT NULL,
PRIMARY KEY (seq_0_id,seq_1_id)
);
INSERT INTO t2 VALUES (1,1);
INSERT INTO t2 VALUES (2,1);
INSERT INTO t2 VALUES (2,2);
CREATE TABLE t3 (
t3_id bigint(21) NOT NULL auto_increment,
_field_131 varchar(128),
_field_133 tinyint(4) DEFAULT '0' NOT NULL,
_field_135 datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
_field_137 tinyint(4),
_field_139 datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
_field_140 blob,
_field_142 tinyint(4) DEFAULT '0' NOT NULL,
_field_145 tinyint(4) DEFAULT '0' NOT NULL,
_field_148 tinyint(4) DEFAULT '0' NOT NULL,
PRIMARY KEY (t3_id),
KEY _field_133 (_field_133),
KEY _field_135 (_field_135),
KEY _field_139 (_field_139),
KEY _field_142 (_field_142),
KEY _field_145 (_field_145),
KEY _field_148 (_field_148)
);
INSERT INTO t3 VALUES (1,'test job 1',0,'0000-00-00 00:00:00',0,'1999-02-25 22:43:32','test\r\njob\r\n1',0,0,0);
INSERT INTO t3 VALUES (2,'test job 2',0,'0000-00-00 00:00:00',0,'1999-02-26 21:08:04','',0,0,0);
CREATE TABLE t4 (
seq_0_id bigint(21) DEFAULT '0' NOT NULL,
seq_1_id bigint(21) DEFAULT '0' NOT NULL,
PRIMARY KEY (seq_0_id,seq_1_id)
);
INSERT INTO t4 VALUES (1,1);
INSERT INTO t4 VALUES (2,1);
CREATE TABLE t5 (
t5_id bigint(21) NOT NULL auto_increment,
_field_149 tinyint(4),
_field_156 varchar(128) DEFAULT '' NOT NULL,
_field_157 varchar(128) DEFAULT '' NOT NULL,
_field_158 varchar(128) DEFAULT '' NOT NULL,
_field_159 varchar(128) DEFAULT '' NOT NULL,
_field_160 varchar(128) DEFAULT '' NOT NULL,
_field_161 varchar(128) DEFAULT '' NOT NULL,
PRIMARY KEY (t5_id),
KEY _field_156 (_field_156),
KEY _field_157 (_field_157),
KEY _field_158 (_field_158),
KEY _field_159 (_field_159),
KEY _field_160 (_field_160),
KEY _field_161 (_field_161)
);
INSERT INTO t5 VALUES (1,0,'tomato','','','','','');
INSERT INTO t5 VALUES (2,0,'cilantro','','','','','');
CREATE TABLE t6 (
seq_0_id bigint(21) DEFAULT '0' NOT NULL,
seq_1_id bigint(21) DEFAULT '0' NOT NULL,
PRIMARY KEY (seq_0_id,seq_1_id)
);
INSERT INTO t6 VALUES (1,1);
INSERT INTO t6 VALUES (1,2);
INSERT INTO t6 VALUES (2,2);
CREATE TABLE t7 (
t7_id bigint(21) NOT NULL auto_increment,
_field_143 tinyint(4),
_field_165 varchar(32),
_field_166 smallint(6) DEFAULT '0' NOT NULL,
PRIMARY KEY (t7_id),
KEY _field_166 (_field_166)
);
INSERT INTO t7 VALUES (1,0,'High',1);
INSERT INTO t7 VALUES (2,0,'Medium',2);
INSERT INTO t7 VALUES (3,0,'Low',3);
select replace(t3._field_140, "\r","^M"),t3_id,min(t3._field_131), min(t3._field_135), min(t3._field_139), min(t3._field_137), min(link_alias_142._field_165), min(link_alias_133._field_72), min(t3._field_145), min(link_alias_148._field_156), replace(min(t3._field_140), "\r","^M"),t3.t3_id from t3 left join t4 on t4.seq_0_id = t3.t3_id left join t7 link_alias_142 on t4.seq_1_id = link_alias_142.t7_id left join t6 on t6.seq_0_id = t3.t3_id left join t1 link_alias_133 on t6.seq_1_id = link_alias_133.t1_id left join t2 on t2.seq_0_id = t3.t3_id left join t5 link_alias_148 on t2.seq_1_id = link_alias_148.t5_id where t3.t3_id in (1) group by t3.t3_id order by link_alias_142._field_166, _field_139, link_alias_133._field_72, _field_135, link_alias_148._field_156;
replace(t3._field_140, "\r","^M") t3_id min(t3._field_131) min(t3._field_135) min(t3._field_139) min(t3._field_137) min(link_alias_142._field_165) min(link_alias_133._field_72) min(t3._field_145) min(link_alias_148._field_156) replace(min(t3._field_140), "\r","^M") t3_id
test^M
job^M
1 1 test job 1 0000-00-00 00:00:00 1999-02-25 22:43:32 0 High admin 0 tomato test^M
job^M
1 1
drop table t1,t2,t3,t4,t5,t6,t7;
create table t1 (a blob);
insert into t1 values ("empty"),("");
select a,reverse(a) from t1;
a reverse(a)
empty ytpme
drop table t1;
create table t1 (a blob, key (a(10)));
insert into t1 values ("bye"),("hello"),("hello"),("hello word");
select * from t1 where a like "hello%";
a
hello
hello
hello word
drop table t1;
CREATE TABLE t1 (
f1 int(11) DEFAULT '0' NOT NULL,
f2 varchar(16) DEFAULT '' NOT NULL,
f5 text,
KEY index_name (f1,f2,f5(16))
);
INSERT INTO t1 VALUES (0,'traktor','1111111111111');
INSERT INTO t1 VALUES (1,'traktor','1111111111111111111111111');
select count(*) from t1 where f2='traktor';
count(*)
2
drop table t1;
create table t1 (foobar tinyblob not null, boggle smallint not null, key (foobar(32), boggle));
insert into t1 values ('fish', 10),('bear', 20);
select foobar, boggle from t1 where foobar = 'fish';
foobar boggle
fish 10
select foobar, boggle from t1 where foobar = 'fish' and boggle = 10;
foobar boggle
fish 10
drop table t1;
create table t1 (id integer primary key auto_increment, txt text not null, unique index txt_index (txt (20)));
insert into t1 (txt) values ('Chevy'), ('Chevy ');
ERROR 23000: Duplicate entry 'Chevy' for key 'txt_index'
insert into t1 (txt) values ('Chevy'), ('CHEVY');
ERROR 23000: Duplicate entry 'Chevy' for key 'txt_index'
insert into t1 (txt) values ('Chevy ');
select * from t1 where txt='Chevy';
id txt
5 Chevy
select * from t1 where txt='Chevy ';
id txt
5 Chevy
select * from t1 where txt='Chevy ' or txt='Chevy';
id txt
5 Chevy
select * from t1 where txt='Chevy' or txt='Chevy ';
id txt
5 Chevy
select * from t1 where id='1' or id='2';
id txt
insert into t1 (txt) values('Ford');
select * from t1 where txt='Chevy' or txt='Chevy ' or txt='Ford';
id txt
5 Chevy
6 Ford
select * from t1 where txt='Chevy' or txt='Chevy ';
id txt
5 Chevy
select * from t1 where txt='Chevy' or txt='Chevy ' or txt=' Chevy';
id txt
5 Chevy
select * from t1 where txt in ('Chevy ','Chevy');
id txt
5 Chevy
select * from t1 where txt in ('Chevy');
id txt
5 Chevy
select * from t1 where txt between 'Chevy' and 'Chevy';
id txt
5 Chevy
select * from t1 where txt between 'Chevy' and 'Chevy' or txt='Chevy ';
id txt
5 Chevy
select * from t1 where txt between 'Chevy' and 'Chevy ';
id txt
5 Chevy
select * from t1 where txt < 'Chevy ';
id txt
select * from t1 where txt <= 'Chevy';
id txt
5 Chevy
select * from t1 where txt > 'Chevy';
id txt
6 Ford
select * from t1 where txt >= 'Chevy';
id txt
5 Chevy
6 Ford
drop table t1;
create table t1 (id integer primary key auto_increment, txt text, index txt_index (txt (20)));
insert into t1 (txt) values ('Chevy'), ('Chevy '), (NULL);
select * from t1 where txt='Chevy' or txt is NULL;
id txt
1 Chevy
2 Chevy
3 NULL
explain select * from t1 where txt='Chevy' or txt is NULL;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL txt_index NULL NULL NULL 3 Using where
select * from t1 where txt='Chevy ';
id txt
1 Chevy
2 Chevy
select * from t1 where txt='Chevy ' or txt='Chevy';
id txt
1 Chevy
2 Chevy
select * from t1 where txt='Chevy' or txt='Chevy ';
id txt
1 Chevy
2 Chevy
select * from t1 where id='1' or id='2';
id txt
1 Chevy
2 Chevy
insert into t1 (txt) values('Ford');
select * from t1 where txt='Chevy' or txt='Chevy ' or txt='Ford';
id txt
1 Chevy
2 Chevy
4 Ford
select * from t1 where txt='Chevy' or txt='Chevy ';
id txt
1 Chevy
2 Chevy
select * from t1 where txt='Chevy' or txt='Chevy ' or txt=' Chevy';
id txt
1 Chevy
2 Chevy
select * from t1 where txt in ('Chevy ','Chevy');
id txt
1 Chevy
2 Chevy
select * from t1 where txt in ('Chevy');
id txt
1 Chevy
2 Chevy
select * from t1 where txt between 'Chevy' and 'Chevy';
id txt
1 Chevy
2 Chevy
select * from t1 where txt between 'Chevy' and 'Chevy' or txt='Chevy ';
id txt
1 Chevy
2 Chevy
select * from t1 where txt between 'Chevy' and 'Chevy ';
id txt
1 Chevy
2 Chevy
select * from t1 where txt < 'Chevy ';
id txt
select * from t1 where txt < 'Chevy ' or txt is NULL;
id txt
3 NULL
select * from t1 where txt <= 'Chevy';
id txt
1 Chevy
2 Chevy
select * from t1 where txt > 'Chevy';
id txt
4 Ford
select * from t1 where txt >= 'Chevy';
id txt
1 Chevy
2 Chevy
4 Ford
alter table t1 modify column txt blob;
explain select * from t1 where txt='Chevy' or txt is NULL;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL txt_index NULL NULL NULL 4 Using where
select * from t1 where txt='Chevy' or txt is NULL;
id txt
1 Chevy
3 NULL
explain select * from t1 where txt='Chevy' or txt is NULL order by txt;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL txt_index NULL NULL NULL 4 Using where; Using filesort
select * from t1 where txt='Chevy' or txt is NULL order by txt;
id txt
3 NULL
1 Chevy
drop table t1;
CREATE TABLE t1 ( i int(11) NOT NULL default '0', c text NOT NULL, d varchar(1) NOT NULL DEFAULT ' ', PRIMARY KEY (i), KEY (c(1),d));
INSERT t1 (i, c) VALUES (1,''),(2,''),(3,'asdfh'),(4,'');
select max(i) from t1 where c = '';
max(i)
4
drop table t1;
create table t1 (a int, b int, c tinyblob, d int, e int);
alter table t1 add primary key (a,b,c(255),d);
alter table t1 add key (a,b,d,e);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL DEFAULT '0',
`b` int(11) NOT NULL DEFAULT '0',
`c` tinyblob NOT NULL,
`d` int(11) NOT NULL DEFAULT '0',
`e` int(11) DEFAULT NULL,
PRIMARY KEY (`a`,`b`,`c`(255),`d`),
KEY `a` (`a`,`b`,`d`,`e`)
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
drop table t1;
CREATE table t1 (a blob);
insert into t1 values ('b'),('a\0'),('a'),('a '),('aa'),(NULL);
select hex(a) from t1 order by a;
hex(a)
NULL
61
6100
6120
6161
62
select hex(concat(a,'\0')) as b from t1 order by concat(a,'\0');
b
NULL
6100
610000
612000
616100
6200
alter table t1 modify a varbinary(5);
select hex(a) from t1 order by a;
hex(a)
NULL
61
6100
6120
6161
62
select hex(concat(a,'\0')) as b from t1 order by concat(a,'\0');
b
NULL
6100
610000
612000
616100
6200
alter table t1 modify a char(5);
select hex(a) from t1 order by a;
hex(a)
NULL
6100
61
61
6161
62
select hex(concat(a,'\0')) as b from t1 order by concat(a,'\0');
b
NULL
610000
6100
6100
616100
6200
alter table t1 modify a binary(5);
select hex(a) from t1 order by a;
hex(a)
NULL
6100000000
6100000000
6100000000
6161000000
6200000000
select hex(concat(a,'\0')) as b from t1 order by concat(a,'\0');
b
NULL
610000000000
610000000000
610000000000
616100000000
620000000000
drop table t1;
create table t1 (a text default '');
Warnings:
Warning 1101 BLOB/TEXT column 'a' can't have a default value
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
insert into t1 values (default);
select * from t1;
a
NULL
drop table t1;
set @@sql_mode='TRADITIONAL';
create table t1 (a text default '');
ERROR 42000: BLOB/TEXT column 'a' can't have a default value
set @@sql_mode='';
CREATE TABLE t (c TEXT CHARSET ASCII);
INSERT INTO t (c) VALUES (REPEAT('1',65537));
Warnings:
Warning 1265 Data truncated for column 'c' at row 1
INSERT INTO t (c) VALUES (REPEAT('2',65536));
Warnings:
Warning 1265 Data truncated for column 'c' at row 1
INSERT INTO t (c) VALUES (REPEAT('3',65535));
SELECT LENGTH(c), CHAR_LENGTH(c) FROM t;
LENGTH(c) CHAR_LENGTH(c)
65535 65535
65535 65535
65535 65535
DROP TABLE t;
drop table if exists b15776;
create table b15776 (data blob(2147483647));
drop table b15776;
create table b15776 (data blob(-1));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1))' at line 1
create table b15776 (data blob(2147483648));
drop table b15776;
create table b15776 (data blob(4294967294));
drop table b15776;
create table b15776 (data blob(4294967295));
drop table b15776;
create table b15776 (data blob(4294967296));
ERROR 42000: Display width out of range for column 'data' (max = 4294967295)
CREATE TABLE b15776 (a blob(2147483647), b blob(2147483648), c blob(4294967295), a1 text(2147483647), b1 text(2147483648), c1 text(4294967295) );
show columns from b15776;
Field Type Null Key Default Extra
a longblob YES NULL
b longblob YES NULL
c longblob YES NULL
a1 longtext YES NULL
b1 longtext YES NULL
c1 longtext YES NULL
drop table b15776;
CREATE TABLE b15776 (a blob(4294967296));
ERROR 42000: Display width out of range for column 'a' (max = 4294967295)
CREATE TABLE b15776 (a text(4294967296));
ERROR 42000: Display width out of range for column 'a' (max = 4294967295)
CREATE TABLE b15776 (a blob(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
ERROR 42000: Display width out of range for column 'a' (max = 4294967295)
CREATE TABLE b15776 (a text(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
ERROR 42000: Display width out of range for column 'a' (max = 4294967295)
CREATE TABLE b15776 (a int(0));
INSERT INTO b15776 values (NULL), (1), (42), (654);
SELECT * from b15776 ORDER BY a;
a
NULL
1
42
654
DROP TABLE b15776;
CREATE TABLE b15776 (a int(-1));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1))' at line 1
CREATE TABLE b15776 (a int(255));
DROP TABLE b15776;
CREATE TABLE b15776 (a int(256));
ERROR 42000: Display width out of range for column 'a' (max = 255)
CREATE TABLE b15776 (data blob(-1));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1))' at line 1
CREATE TABLE b15776 (a char(2147483647));
ERROR 42000: Column length too big for column 'a' (max = 255); use BLOB or TEXT instead
CREATE TABLE b15776 (a char(2147483648));
ERROR 42000: Column length too big for column 'a' (max = 255); use BLOB or TEXT instead
CREATE TABLE b15776 (a char(4294967295));
ERROR 42000: Column length too big for column 'a' (max = 255); use BLOB or TEXT instead
CREATE TABLE b15776 (a char(4294967296));
ERROR 42000: Display width out of range for column 'a' (max = 4294967295)
CREATE TABLE b15776 (a year(4294967295));
INSERT INTO b15776 VALUES (42);
SELECT * FROM b15776;
a
2042
DROP TABLE b15776;
CREATE TABLE b15776 (a year(4294967296));
ERROR 42000: Display width out of range for column 'a' (max = 4294967295)
CREATE TABLE b15776 (a year(0));
DROP TABLE b15776;
CREATE TABLE b15776 (a year(-2));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-2))' at line 1
CREATE TABLE b15776 (a timestamp(4294967294));
Warnings:
Warning 1287 'TIMESTAMP(4294967294)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead
DROP TABLE b15776;
CREATE TABLE b15776 (a timestamp(4294967295));
Warnings:
Warning 1287 'TIMESTAMP(4294967295)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead
DROP TABLE b15776;
CREATE TABLE b15776 (a timestamp(4294967296));
ERROR 42000: Display width out of range for column 'a' (max = 4294967295)
CREATE TABLE b15776 (a timestamp(-1));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1))' at line 1
CREATE TABLE b15776 (a timestamp(-2));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-2))' at line 1
CREATE TABLE b15776 (a int(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
ERROR 42000: Display width out of range for column 'a' (max = 4294967295)
CREATE TABLE b15776 (a char(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
ERROR 42000: Display width out of range for column 'a' (max = 4294967295)
CREATE TABLE b15776 (a year(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
ERROR 42000: Display width out of range for column 'a' (max = 4294967295)
CREATE TABLE b15776 (a timestamp(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
ERROR 42000: Display width out of range for column 'a' (max = 4294967295)
CREATE TABLE b15776 select cast(null as char(4294967295));
show columns from b15776;
Field Type Null Key Default Extra
cast(null as char(4294967295)) char(0) YES NULL
drop table b15776;
CREATE TABLE b15776 select cast(null as nchar(4294967295));
show columns from b15776;
Field Type Null Key Default Extra
cast(null as nchar(4294967295)) char(0) YES NULL
drop table b15776;
CREATE TABLE b15776 select cast(null as binary(4294967295));
show columns from b15776;
Field Type Null Key Default Extra
cast(null as binary(4294967295)) binary(0) YES NULL
drop table b15776;
explain select cast(1 as char(4294967295));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
explain select cast(1 as nchar(4294967295));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
explain select cast(1 as binary(4294967295));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
explain select cast(1 as char(4294967296));
ERROR 42000: Display width out of range for column 'cast as char' (max = 4294967295)
explain select cast(1 as nchar(4294967296));
ERROR 42000: Display width out of range for column 'cast as char' (max = 4294967295)
explain select cast(1 as binary(4294967296));
ERROR 42000: Display width out of range for column 'cast as char' (max = 4294967295)
explain select cast(1 as decimal(-1));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1))' at line 1
explain select cast(1 as decimal(64, 30));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
explain select cast(1 as decimal(64, 999999999999999999999999999999));
Got one of the listed errors
explain select cast(1 as decimal(4294967296));
Got one of the listed errors
explain select cast(1 as decimal(999999999999999999999999999999999999));
Got one of the listed errors
explain select convert(1, char(4294967295));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
explain select convert(1, char(4294967296));
ERROR 42000: Display width out of range for column 'cast as char' (max = 4294967295)
explain select convert(1, char(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
ERROR 42000: Display width out of range for column 'cast as char' (max = 4294967295)
explain select convert(1, nchar(4294967295));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
explain select convert(1, nchar(4294967296));
ERROR 42000: Display width out of range for column 'cast as char' (max = 4294967295)
explain select convert(1, nchar(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
ERROR 42000: Display width out of range for column 'cast as char' (max = 4294967295)
explain select convert(1, binary(4294967295));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
explain select convert(1, binary(4294967296));
ERROR 42000: Display width out of range for column 'cast as char' (max = 4294967295)
explain select convert(1, binary(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
ERROR 42000: Display width out of range for column 'cast as char' (max = 4294967295)
End of 5.0 tests
SET STORAGE_ENGINE='tokudb';
drop table if exists t1,t2;
create table t1 (a char(16), b date, c datetime);
insert into t1 SET a='test 2000-01-01', b='2000-01-01', c='2000-01-01';
select * from t1 where c = '2000-01-01';
a b c
test 2000-01-01 2000-01-01 2000-01-01 00:00:00
select * from t1 where b = '2000-01-01';
a b c
test 2000-01-01 2000-01-01 2000-01-01 00:00:00
drop table t1;
CREATE TABLE t1 (name char(6),cdate date);
INSERT INTO t1 VALUES ('name1','1998-01-01');
INSERT INTO t1 VALUES ('name2','1998-01-01');
INSERT INTO t1 VALUES ('name1','1998-01-02');
INSERT INTO t1 VALUES ('name2','1998-01-02');
CREATE TABLE t2 (cdate date, note char(6));
INSERT INTO t2 VALUES ('1998-01-01','note01');
INSERT INTO t2 VALUES ('1998-01-02','note02');
select name,t1.cdate,note from t1,t2 where t1.cdate=t2.cdate and t1.cdate='1998-01-01';
name cdate note
name1 1998-01-01 note01
name2 1998-01-01 note01
drop table t1,t2;
CREATE TABLE t1 ( datum DATE );
INSERT INTO t1 VALUES ( "2000-1-1" );
INSERT INTO t1 VALUES ( "2000-1-2" );
INSERT INTO t1 VALUES ( "2000-1-3" );
INSERT INTO t1 VALUES ( "2000-1-4" );
INSERT INTO t1 VALUES ( "2000-1-5" );
SELECT * FROM t1 WHERE datum BETWEEN cast("2000-1-2" as date) AND cast("2000-1-4" as date);
datum
2000-01-02
2000-01-03
2000-01-04
SELECT * FROM t1 WHERE datum BETWEEN cast("2000-1-2" as date) AND datum - INTERVAL 100 DAY;
datum
DROP TABLE t1;
CREATE TABLE t1 (
user_id char(10),
summa int(11),
rdate date
);
INSERT INTO t1 VALUES ('aaa',100,'1998-01-01');
INSERT INTO t1 VALUES ('aaa',200,'1998-01-03');
INSERT INTO t1 VALUES ('bbb',50,'1998-01-02');
INSERT INTO t1 VALUES ('bbb',200,'1998-01-04');
select max(rdate) as s from t1 where rdate < '1998-01-03' having s> "1998-01-01";
s
1998-01-02
select max(rdate) as s from t1 having s="1998-01-04";
s
1998-01-04
select max(rdate+0) as s from t1 having s="19980104";
s
19980104
drop table t1;
create table t1 (date date);
insert into t1 values ("2000-08-10"),("2000-08-11");
select date_add(date,INTERVAL 1 DAY),date_add(date,INTERVAL 1 SECOND) from t1;
date_add(date,INTERVAL 1 DAY) date_add(date,INTERVAL 1 SECOND)
2000-08-11 2000-08-10 00:00:01
2000-08-12 2000-08-11 00:00:01
drop table t1;
CREATE TABLE t1(AFIELD INT);
INSERT INTO t1 VALUES(1);
CREATE TABLE t2(GMT VARCHAR(32));
INSERT INTO t2 VALUES('GMT-0800');
SELECT DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ' , t2.GMT)) FROM t1, t2 GROUP BY t1.AFIELD;
DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ' , t2.GMT))
Wed, 06 March 2002 10:11:12 GMT-0800
INSERT INTO t1 VALUES(1);
SELECT DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ' , t2.GMT)), DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ' , t2.GMT)) FROM t1,t2 GROUP BY t1.AFIELD;
DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ' , t2.GMT)) DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ' , t2.GMT))
Wed, 06 March 2002 10:11:12 GMT-0800 Wed, 06 March 2002 10:11:12 GMT-0800
drop table t1,t2;
CREATE TABLE t1 (f1 time default NULL, f2 time default NULL);
INSERT INTO t1 (f1, f2) VALUES ('09:00', '12:00');
SELECT DATE_FORMAT(f1, "%l.%i %p") , DATE_FORMAT(f2, "%l.%i %p") FROM t1;
DATE_FORMAT(f1, "%l.%i %p") DATE_FORMAT(f2, "%l.%i %p")
9.00 AM 12.00 PM
DROP TABLE t1;
CREATE TABLE t1 (f1 DATE);
CREATE TABLE t2 (f2 VARCHAR(8));
CREATE TABLE t3 (f2 CHAR(8));
INSERT INTO t1 VALUES ('1978-11-26');
INSERT INTO t2 SELECT f1+0 FROM t1;
INSERT INTO t2 SELECT f1+0 FROM t1 UNION SELECT f1+0 FROM t1;
INSERT INTO t3 SELECT f1+0 FROM t1;
INSERT INTO t3 SELECT f1+0 FROM t1 UNION SELECT f1+0 FROM t1;
SELECT * FROM t2;
f2
19781126
19781126
SELECT * FROM t3;
f2
19781126
19781126
DROP TABLE t1, t2, t3;
CREATE TABLE t1 (y YEAR);
INSERT INTO t1 VALUES ('abc');
Warnings:
Warning 1366 Incorrect integer value: 'abc' for column 'y' at row 1
SELECT * FROM t1;
y
0000
DROP TABLE t1;
create table t1(start_date date, end_date date);
insert into t1 values ('2000-01-01','2000-01-02');
select 1 from t1 where cast('2000-01-01 12:01:01' as datetime) between start_date and end_date;
1
1
drop table t1;
select @d:=1111;
@d:=1111
1111
select year(@d), month(@d), day(@d), cast(@d as date);
year(@d) month(@d) day(@d) cast(@d as date)
2000 11 11 2000-11-11
select @d:=011111;
@d:=011111
11111
select year(@d), month(@d), day(@d), cast(@d as date);
year(@d) month(@d) day(@d) cast(@d as date)
2001 11 11 2001-11-11
select @d:=1311;
@d:=1311
1311
select year(@d), month(@d), day(@d), cast(@d as date);
year(@d) month(@d) day(@d) cast(@d as date)
NULL NULL NULL NULL
Warnings:
Warning 1292 Incorrect datetime value: '1311'
Warning 1292 Incorrect datetime value: '1311'
Warning 1292 Incorrect datetime value: '1311'
Warning 1292 Incorrect datetime value: '1311'
create table t1 (d date , dt datetime , ts timestamp);
insert into t1 values (9912101,9912101,9912101);
Warnings:
Warning 1264 Out of range value for column 'd' at row 1
Warning 1264 Out of range value for column 'dt' at row 1
Warning 1265 Data truncated for column 'ts' at row 1
insert into t1 values (11111,11111,11111);
select * from t1;
d dt ts
0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00
2001-11-11 2001-11-11 00:00:00 2001-11-11 00:00:00
drop table t1;
CREATE TABLE t1 (
a INT
);
INSERT INTO t1 VALUES (1);
INSERT INTO t1 VALUES (NULL);
SELECT str_to_date( '', a ) FROM t1;
str_to_date( '', a )
0000-00-00 00:00:00
NULL
DROP TABLE t1;
CREATE TABLE t1 (a DATE, b int, PRIMARY KEY (a,b));
INSERT INTO t1 VALUES (DATE(NOW()), 1);
SELECT COUNT(*) FROM t1 WHERE a = NOW();
COUNT(*)
0
EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW();
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
INSERT INTO t1 VALUES (DATE(NOW()), 2);
SELECT COUNT(*) FROM t1 WHERE a = NOW();
COUNT(*)
0
EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW();
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
SELECT COUNT(*) FROM t1 WHERE a = NOW() AND b = 1;
COUNT(*)
0
EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW() AND b = 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
ALTER TABLE t1 DROP PRIMARY KEY;
SELECT COUNT(*) FROM t1 WHERE a = NOW();
COUNT(*)
0
EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW();
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
DROP TABLE t1;
CREATE TABLE t1 (a DATE);
CREATE TABLE t2 (a DATE);
CREATE INDEX i ON t1 (a);
INSERT INTO t1 VALUES ('0000-00-00'),('0000-00-00');
INSERT INTO t2 VALUES ('0000-00-00'),('0000-00-00');
SELECT * FROM t1 WHERE a = '0000-00-00';
a
0000-00-00
0000-00-00
SELECT * FROM t2 WHERE a = '0000-00-00';
a
0000-00-00
0000-00-00
SET SQL_MODE=TRADITIONAL;
EXPLAIN SELECT * FROM t1 WHERE a = '0000-00-00';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref i i 4 const 2 Using where; Using index
Warnings:
Warning 1292 Incorrect date value: '0000-00-00' for column 'a' at row 1
Warning 1292 Incorrect date value: '0000-00-00' for column 'a' at row 1
SELECT * FROM t1 WHERE a = '0000-00-00';
a
0000-00-00
0000-00-00
Warnings:
Warning 1292 Incorrect date value: '0000-00-00' for column 'a' at row 1
Warning 1292 Incorrect date value: '0000-00-00' for column 'a' at row 1
SELECT * FROM t2 WHERE a = '0000-00-00';
a
0000-00-00
0000-00-00
Warnings:
Warning 1292 Incorrect date value: '0000-00-00' for column 'a' at row 1
Warning 1292 Incorrect date value: '0000-00-00' for column 'a' at row 1
INSERT INTO t1 VALUES ('0000-00-00');
ERROR 22007: Incorrect date value: '0000-00-00' for column 'a' at row 1
SET SQL_MODE=DEFAULT;
DROP TABLE t1,t2;
CREATE TABLE t1 (a DATE);
CREATE TABLE t2 (a DATE);
CREATE INDEX i ON t1 (a);
INSERT INTO t1 VALUES ('1000-00-00'),('1000-00-00');
INSERT INTO t2 VALUES ('1000-00-00'),('1000-00-00');
SELECT * FROM t1 WHERE a = '1000-00-00';
a
1000-00-00
1000-00-00
SELECT * FROM t2 WHERE a = '1000-00-00';
a
1000-00-00
1000-00-00
SET SQL_MODE=TRADITIONAL;
EXPLAIN SELECT * FROM t1 WHERE a = '1000-00-00';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref i i 4 const 2 Using where; Using index
Warnings:
Warning 1292 Incorrect date value: '1000-00-00' for column 'a' at row 1
Warning 1292 Incorrect date value: '1000-00-00' for column 'a' at row 1
SELECT * FROM t1 WHERE a = '1000-00-00';
a
1000-00-00
1000-00-00
Warnings:
Warning 1292 Incorrect date value: '1000-00-00' for column 'a' at row 1
Warning 1292 Incorrect date value: '1000-00-00' for column 'a' at row 1
SELECT * FROM t2 WHERE a = '1000-00-00';
a
1000-00-00
1000-00-00
Warnings:
Warning 1292 Incorrect date value: '1000-00-00' for column 'a' at row 1
Warning 1292 Incorrect date value: '1000-00-00' for column 'a' at row 1
INSERT INTO t1 VALUES ('1000-00-00');
ERROR 22007: Incorrect date value: '1000-00-00' for column 'a' at row 1
SET SQL_MODE=DEFAULT;
DROP TABLE t1,t2;
CREATE TABLE t1 SELECT curdate() AS f1;
SELECT hour(f1), minute(f1), second(f1) FROM t1;
hour(f1) minute(f1) second(f1)
0 0 0
DROP TABLE t1;
End of 5.0 tests
create table t1 (a date, primary key (a))engine=memory;
insert into t1 values ('0000-01-01'), ('0000-00-01'), ('0001-01-01');
select * from t1 where a between '0000-00-01' and '0000-00-02';
a
0000-00-01
drop table t1;
End of 5.1 tests
SET STORAGE_ENGINE='tokudb';
drop table if exists t1;
create table t1 (t datetime);
insert into t1 values (101),(691231),(700101),(991231),(10000101),(99991231),(101000000),(691231000000),(700101000000),(991231235959),(10000101000000),(99991231235959),(20030100000000),(20030000000000);
select * from t1;
t
2000-01-01 00:00:00
2069-12-31 00:00:00
1970-01-01 00:00:00
1999-12-31 00:00:00
1000-01-01 00:00:00
9999-12-31 00:00:00
2000-01-01 00:00:00
2069-12-31 00:00:00
1970-01-01 00:00:00
1999-12-31 23:59:59
1000-01-01 00:00:00
9999-12-31 23:59:59
2003-01-00 00:00:00
2003-00-00 00:00:00
delete from t1 where t > 0;
optimize table t1;
Table Op Msg_type Msg_text
test.t1 optimize status OK
check table t1;
Table Op Msg_type Msg_text
test.t1 check info ./test/t1 primary=0 num=1
test.t1 check info ./test/t1 key=primary 0
test.t1 check info ./test/t1 key=primary 0 result=0
test.t1 check status OK
delete from t1;
insert into t1 values("000101"),("691231"),("700101"),("991231"),("00000101"),("00010101"),("99991231"),("00101000000"),("691231000000"),("700101000000"),("991231235959"),("10000101000000"),("99991231235959"),("20030100000000"),("20030000000000");
insert into t1 values ("2003-003-03");
insert into t1 values ("20030102T131415"),("2001-01-01T01:01:01"), ("2001-1-1T1:01:01");
select * from t1;
t
2000-01-01 00:00:00
2069-12-31 00:00:00
1970-01-01 00:00:00
1999-12-31 00:00:00
0000-01-01 00:00:00
0001-01-01 00:00:00
9999-12-31 00:00:00
2000-10-10 00:00:00
2069-12-31 00:00:00
1970-01-01 00:00:00
1999-12-31 23:59:59
1000-01-01 00:00:00
9999-12-31 23:59:59
2003-01-00 00:00:00
2003-00-00 00:00:00
2003-03-03 00:00:00
2003-01-02 13:14:15
2001-01-01 01:01:01
2001-01-01 01:01:01
truncate table t1;
insert into t1 values("2003-0303 12:13:14");
Warnings:
Warning 1264 Out of range value for column 't' at row 1
select * from t1;
t
0000-00-00 00:00:00
drop table t1;
CREATE TABLE t1 (a timestamp, b date, c time, d datetime);
insert into t1 (b,c,d) values(now(),curtime(),now());
Warnings:
Note 1265 Data truncated for column 'b' at row 1
select date_format(a,"%Y-%m-%d")=b,right(a+0,6)=c+0,a=d+0 from t1;
date_format(a,"%Y-%m-%d")=b right(a+0,6)=c+0 a=d+0
1 1 1
drop table t1;
CREATE TABLE t1 (a datetime not null);
insert into t1 values (0);
select * from t1 where a is null;
a
0000-00-00 00:00:00
drop table t1;
create table t1 (id int, dt datetime);
insert into t1 values (1,"2001-08-14 00:00:00"),(2,"2001-08-15 00:00:00"),(3,"2001-08-16 00:00:00"),(4,"2003-09-15 01:20:30");
select * from t1 where dt='2001-08-14 00:00:00' and dt = if(id=1,'2001-08-14 00:00:00','1999-08-15');
id dt
1 2001-08-14 00:00:00
create index dt on t1 (dt);
select * from t1 where dt > 20021020;
id dt
4 2003-09-15 01:20:30
select * from t1 ignore index (dt) where dt > 20021020;
id dt
4 2003-09-15 01:20:30
drop table t1;
CREATE TABLE `t1` (
`date` datetime NOT NULL default '0000-00-00 00:00:00',
`numfacture` int(6) unsigned NOT NULL default '0',
`expedition` datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`numfacture`),
KEY `date` (`date`),
KEY `expedition` (`expedition`)
) ENGINE=tokudb;
INSERT INTO t1 (expedition) VALUES ('0001-00-00 00:00:00');
SELECT * FROM t1 WHERE expedition='0001-00-00 00:00:00';
date numfacture expedition
0000-00-00 00:00:00 0 0001-00-00 00:00:00
INSERT INTO t1 (numfacture,expedition) VALUES ('1212','0001-00-00 00:00:00');
SELECT * FROM t1 WHERE expedition='0001-00-00 00:00:00';
date numfacture expedition
0000-00-00 00:00:00 0 0001-00-00 00:00:00
0000-00-00 00:00:00 1212 0001-00-00 00:00:00
EXPLAIN SELECT * FROM t1 WHERE expedition='0001-00-00 00:00:00';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL expedition NULL NULL NULL 2 Using where
drop table t1;
create table t1 (a datetime not null, b datetime not null);
insert into t1 values (now(), now());
insert into t1 values (now(), now());
select * from t1 where a is null or b is null;
a b
drop table t1;
create table t1 (t datetime);
insert into t1 values (20030102030460),(20030102036301),(20030102240401),
(20030132030401),(20031302030401),(100001202030401);
Warnings:
Warning 1264 Out of range value for column 't' at row 1
Warning 1264 Out of range value for column 't' at row 2
Warning 1264 Out of range value for column 't' at row 3
Warning 1264 Out of range value for column 't' at row 4
Warning 1264 Out of range value for column 't' at row 5
Warning 1264 Out of range value for column 't' at row 6
select * from t1;
t
0000-00-00 00:00:00
0000-00-00 00:00:00
0000-00-00 00:00:00
0000-00-00 00:00:00
0000-00-00 00:00:00
0000-00-00 00:00:00
delete from t1;
insert into t1 values
("2003-01-02 03:04:60"),("2003-01-02 03:63:01"),("2003-01-02 24:04:01"),
("2003-01-32 03:04:01"),("2003-13-02 03:04:01"), ("10000-12-02 03:04:00");
Warnings:
Warning 1264 Out of range value for column 't' at row 1
Warning 1264 Out of range value for column 't' at row 2
Warning 1264 Out of range value for column 't' at row 3
Warning 1264 Out of range value for column 't' at row 4
Warning 1264 Out of range value for column 't' at row 5
Warning 1264 Out of range value for column 't' at row 6
select * from t1;
t
0000-00-00 00:00:00
0000-00-00 00:00:00
0000-00-00 00:00:00
0000-00-00 00:00:00
0000-00-00 00:00:00
0000-00-00 00:00:00
delete from t1;
insert into t1 values ("0000-00-00 00:00:00 some trailer"),("2003-01-01 00:00:00 some trailer");
Warnings:
Warning 1264 Out of range value for column 't' at row 1
Warning 1264 Out of range value for column 't' at row 2
select * from t1 order by t;
t
0000-00-00 00:00:00
2003-01-01 00:00:00
drop table t1;
create table t1 (dt datetime);
insert into t1 values ("12-00-00"), ("00-00-00 01:00:00");
insert into t1 values ("00-00-00"), ("00-00-00 00:00:00");
select * from t1;
dt
2012-00-00 00:00:00
2000-00-00 01:00:00
0000-00-00 00:00:00
0000-00-00 00:00:00
drop table t1;
select cast('2006-12-05 22:10:10' as datetime) + 0;
cast('2006-12-05 22:10:10' as datetime) + 0
20061205221010.000000
CREATE TABLE t1(a DATETIME NOT NULL);
INSERT INTO t1 VALUES ('20060606155555');
SELECT a FROM t1 WHERE a=(SELECT MAX(a) FROM t1) AND (a="20060606155555");
a
2006-06-06 15:55:55
PREPARE s FROM 'SELECT a FROM t1 WHERE a=(SELECT MAX(a) FROM t1) AND (a="20060606155555")';
EXECUTE s;
a
2006-06-06 15:55:55
DROP PREPARE s;
DROP TABLE t1;
SELECT CAST(CAST('2006-08-10' AS DATE) AS DECIMAL(20,6));
CAST(CAST('2006-08-10' AS DATE) AS DECIMAL(20,6))
20060810.000000
SELECT CAST(CAST('2006-08-10 10:11:12' AS DATETIME) AS DECIMAL(20,6));
CAST(CAST('2006-08-10 10:11:12' AS DATETIME) AS DECIMAL(20,6))
20060810101112.000000
SELECT CAST(CAST('2006-08-10 10:11:12' AS DATETIME) + INTERVAL 14 MICROSECOND AS DECIMAL(20,6));
CAST(CAST('2006-08-10 10:11:12' AS DATETIME) + INTERVAL 14 MICROSECOND AS DECIMAL(20,6))
20060810101112.000014
SELECT CAST(CAST('10:11:12.098700' AS TIME) AS DECIMAL(20,6));
CAST(CAST('10:11:12.098700' AS TIME) AS DECIMAL(20,6))
101112.098700
set @org_mode=@@sql_mode;
create table t1 (da date default '1962-03-03 23:33:34', dt datetime default '1962-03-03');
Warnings:
Note 1265 Data truncated for column 'da' at row 1
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`da` date DEFAULT '1962-03-03',
`dt` datetime DEFAULT '1962-03-03 00:00:00'
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
insert into t1 values ();
insert into t1 values ('2007-03-23 13:49:38','2007-03-23 13:49:38');
Warnings:
Note 1265 Data truncated for column 'da' at row 1
set @@sql_mode='ansi,traditional';
insert into t1 values ('2007-03-23 13:49:38','2007-03-23 13:49:38');
Warnings:
Note 1265 Data truncated for column 'da' at row 1
insert into t1 set dt='2007-03-23 13:49:38',da=dt;
Warnings:
Note 1265 Data truncated for column 'da' at row 1
insert into t1 values ('2007-03-32','2007-03-23 13:49:38');
ERROR 22007: Incorrect date value: '2007-03-32' for column 'da' at row 1
select * from t1;
da dt
1962-03-03 1962-03-03 00:00:00
2007-03-23 2007-03-23 13:49:38
2007-03-23 2007-03-23 13:49:38
2007-03-23 2007-03-23 13:49:38
drop table t1;
create table t1 (da date default '1962-03-32 23:33:34', dt datetime default '1962-03-03');
ERROR 42000: Invalid default value for 'da'
create table t1 (t time default '916:00:00 a');
ERROR 42000: Invalid default value for 't'
set @@sql_mode= @org_mode;
create table t1 (f1 date, f2 datetime, f3 timestamp);
insert into t1(f1) values(curdate());
select curdate() < now(), f1 < now(), cast(f1 as date) < now() from t1;
curdate() < now() f1 < now() cast(f1 as date) < now()
1 1 1
delete from t1;
insert into t1 values('2001-01-01','2001-01-01 01:01:01','2001-01-01 01:01:01');
insert into t1 values('2001-02-05','2001-02-05 00:00:00','2001-02-05 01:01:01');
insert into t1 values('2001-03-10','2001-03-09 01:01:01','2001-03-10 01:01:01');
insert into t1 values('2001-04-15','2001-04-15 00:00:00','2001-04-15 00:00:00');
insert into t1 values('2001-05-20','2001-05-20 01:01:01','2001-05-20 01:01:01');
select f1, f3 from t1 where f1 >= '2001-02-05 00:00:00' and f3 <= '2001-04-15';
f1 f3
2001-02-05 2001-02-05 01:01:01
2001-03-10 2001-03-10 01:01:01
2001-04-15 2001-04-15 00:00:00
select f1, f3 from t1 where f1 >= '2001-2-5 0:0:0' and f2 <= '2001-4-15';
f1 f3
2001-02-05 2001-02-05 01:01:01
2001-03-10 2001-03-10 01:01:01
2001-04-15 2001-04-15 00:00:00
select f1, f2 from t1 where if(1, f1, 0) >= f2;
f1 f2
2001-02-05 2001-02-05 00:00:00
2001-03-10 2001-03-09 01:01:01
2001-04-15 2001-04-15 00:00:00
select 1 from dual where cast('2001-1-1 2:3:4' as date) = cast('2001-01-01' as datetime);
1
1
select f1, f2, f1 > f2, f1 = f2, f1 < f2 from t1;
f1 f2 f1 > f2 f1 = f2 f1 < f2
2001-01-01 2001-01-01 01:01:01 0 0 1
2001-02-05 2001-02-05 00:00:00 0 1 0
2001-03-10 2001-03-09 01:01:01 1 0 0
2001-04-15 2001-04-15 00:00:00 0 1 0
2001-05-20 2001-05-20 01:01:01 0 0 1
drop table t1;
create table t1 (f1 date, f2 datetime, f3 timestamp);
insert into t1 values('2001-01-01','2001-01-01 01:01:01','2001-01-01 01:01:01');
insert into t1 values('2001-02-05','2001-02-05 00:00:00','2001-02-05 01:01:01');
insert into t1 values('2001-03-10','2001-03-09 01:01:01','2001-03-10 01:01:01');
insert into t1 values('2001-04-15','2001-04-15 00:00:00','2001-04-15 00:00:00');
insert into t1 values('2001-05-20','2001-05-20 01:01:01','2001-05-20 01:01:01');
select f2 from t1 where f2 between '2001-2-5' and '01-04-14';
f2
2001-02-05 00:00:00
2001-03-09 01:01:01
select f1, f2, f3 from t1 where f1 between f2 and f3;
f1 f2 f3
2001-02-05 2001-02-05 00:00:00 2001-02-05 01:01:01
2001-03-10 2001-03-09 01:01:01 2001-03-10 01:01:01
2001-04-15 2001-04-15 00:00:00 2001-04-15 00:00:00
select f1, f2, f3 from t1 where cast(f1 as datetime) between f2 and
cast(f3 as date);
f1 f2 f3
2001-02-05 2001-02-05 00:00:00 2001-02-05 01:01:01
2001-03-10 2001-03-09 01:01:01 2001-03-10 01:01:01
2001-04-15 2001-04-15 00:00:00 2001-04-15 00:00:00
select f2 from t1 where '2001-04-10 12:34:56' between f2 and '01-05-01';
f2
2001-01-01 01:01:01
2001-02-05 00:00:00
2001-03-09 01:01:01
select f2, f3 from t1 where '01-03-10' between f2 and f3;
f2 f3
2001-03-09 01:01:01 2001-03-10 01:01:01
select f2 from t1 where DATE(f2) between "2001-4-15" AND "01-4-15";
f2
2001-04-15 00:00:00
SELECT 1 from dual where NOW() BETWEEN CURRENT_DATE() - INTERVAL 1 DAY AND CURRENT_DATE();
1
drop table t1;
create table t1 (f1 date);
insert into t1 values('01-01-01'),('01-01-02'),('01-01-03');
select * from t1 where f1 in ('01-01-01','2001-01-02','2001-01-03 00:00:00');
f1
2001-01-01
2001-01-02
2001-01-03
create table t2(f2 datetime);
insert into t2 values('01-01-01 00:00:00'),('01-02-03 12:34:56'),('02-04-06 11:22:33');
select * from t2 where f2 in ('01-01-01','01-02-03 12:34:56','01-02-03');
f2
2001-01-01 00:00:00
2001-02-03 12:34:56
select * from t1,t2 where '01-01-02' in (f1, cast(f2 as date));
f1 f2
2001-01-02 2001-01-01 00:00:00
2001-01-02 2001-02-03 12:34:56
2001-01-02 2002-04-06 11:22:33
select * from t1,t2 where '01-01-01' in (f1, '01-02-03');
f1 f2
2001-01-01 2001-01-01 00:00:00
2001-01-01 2001-02-03 12:34:56
2001-01-01 2002-04-06 11:22:33
select * from t1,t2 where if(1,'01-02-03 12:34:56','') in (f1, f2);
f1 f2
2001-01-01 2001-02-03 12:34:56
2001-01-02 2001-02-03 12:34:56
2001-01-03 2001-02-03 12:34:56
create table t3(f3 varchar(20));
insert into t3 select * from t2;
select * from t2,t3 where f2 in (f3,'03-04-05');
f2 f3
2001-01-01 00:00:00 2001-01-01 00:00:00
2001-02-03 12:34:56 2001-02-03 12:34:56
2002-04-06 11:22:33 2002-04-06 11:22:33
select f1,f2,f3 from t1,t2,t3 where (f1,'1') in ((f2,'1'),(f3,'1'));
f1 f2 f3
2001-01-01 2001-01-01 00:00:00 2001-01-01 00:00:00
2001-01-01 2001-02-03 12:34:56 2001-01-01 00:00:00
2001-01-01 2002-04-06 11:22:33 2001-01-01 00:00:00
2001-01-01 2001-01-01 00:00:00 2001-02-03 12:34:56
2001-01-01 2001-01-01 00:00:00 2002-04-06 11:22:33
select f1 from t1 where ('1',f1) in (('1','01-01-01'),('1','2001-1-1 0:0:0'),('1','02-02-02'));
f1
2001-01-01
drop table t1,t2,t3;
select least(cast('01-01-01' as date), '01-01-02');
least(cast('01-01-01' as date), '01-01-02')
2001-01-01
select greatest(cast('01-01-01' as date), '01-01-02');
greatest(cast('01-01-01' as date), '01-01-02')
01-01-02
select least(cast('01-01-01' as date), '01-01-02') + 0;
least(cast('01-01-01' as date), '01-01-02') + 0
20010101
select greatest(cast('01-01-01' as date), '01-01-02') + 0;
greatest(cast('01-01-01' as date), '01-01-02') + 0
20010102
select least(cast('01-01-01' as datetime), '01-01-02') + 0;
least(cast('01-01-01' as datetime), '01-01-02') + 0
20010101000000
select cast(least(cast('01-01-01' as datetime), '01-01-02') as signed);
cast(least(cast('01-01-01' as datetime), '01-01-02') as signed)
20010101000000
select cast(least(cast('01-01-01' as datetime), '01-01-02') as decimal(16,2));
cast(least(cast('01-01-01' as datetime), '01-01-02') as decimal(16,2))
20010101000000.00
DROP PROCEDURE IF EXISTS test27759 ;
CREATE PROCEDURE test27759()
BEGIN
declare v_a date default '2007-4-10';
declare v_b date default '2007-4-11';
declare v_c datetime default '2004-4-9 0:0:0';
select v_a as a,v_b as b,
least( v_a, v_b ) as a_then_b,
least( v_b, v_a ) as b_then_a,
least( v_c, v_a ) as c_then_a;
END;|
call test27759();
a b a_then_b b_then_a c_then_a
2007-04-10 2007-04-11 2007-04-10 2007-04-10 2004-04-09 00:00:00
drop procedure test27759;
create table t1 (f1 date);
insert into t1 values (curdate());
select left(f1,10) = curdate() from t1;
left(f1,10) = curdate()
1
drop table t1;
create table t1(f1 date);
insert into t1 values('01-01-01'),('02-02-02'),('01-01-01'),('02-02-02');
set @bug28261='';
select if(@bug28261 = f1, '', @bug28261:= f1) from t1;
if(@bug28261 = f1, '', @bug28261:= f1)
2001-01-01
2002-02-02
2001-01-01
2002-02-02
Warnings:
Warning 1292 Incorrect date value: '' for column 'f1' at row 1
select if(@bug28261 = f1, '', @bug28261:= f1) from t1;
if(@bug28261 = f1, '', @bug28261:= f1)
2001-01-01
2002-02-02
2001-01-01
2002-02-02
select if(@bug28261 = f1, '', @bug28261:= f1) from t1;
if(@bug28261 = f1, '', @bug28261:= f1)
2001-01-01
2002-02-02
2001-01-01
2002-02-02
drop table t1;
create table t1(f1 datetime);
insert into t1 values('2001-01-01'),('2002-02-02');
select * from t1 where f1 between 20020101 and 20070101000000;
f1
2002-02-02 00:00:00
select * from t1 where f1 between 2002010 and 20070101000000;
f1
2001-01-01 00:00:00
2002-02-02 00:00:00
Warnings:
Warning 1292 Incorrect datetime value: '2002010' for column 'f1' at row 1
select * from t1 where f1 between 20020101 and 2007010100000;
f1
Warnings:
Warning 1292 Incorrect datetime value: '2007010100000' for column 'f1' at row 1
drop table t1;
#
# Bug#27216: functions with parameters of different date types may
# return wrong type of the result.
#
create table t1 (f1 date, f2 datetime, f3 varchar(20));
create table t2 as select coalesce(f1,f1) as f4 from t1;
desc t2;
Field Type Null Key Default Extra
f4 date YES NULL
create table t3 as select coalesce(f1,f2) as f4 from t1;
desc t3;
Field Type Null Key Default Extra
f4 datetime YES NULL
create table t4 as select coalesce(f2,f2) as f4 from t1;
desc t4;
Field Type Null Key Default Extra
f4 datetime YES NULL
create table t5 as select coalesce(f1,f3) as f4 from t1;
desc t5;
Field Type Null Key Default Extra
f4 varbinary(20) YES NULL
create table t6 as select coalesce(f2,f3) as f4 from t1;
desc t6;
Field Type Null Key Default Extra
f4 varbinary(20) YES NULL
create table t7 as select coalesce(makedate(1997,1),f2) as f4 from t1;
desc t7;
Field Type Null Key Default Extra
f4 datetime YES NULL
create table t8 as select coalesce(cast('01-01-01' as datetime),f2) as f4
from t1;
desc t8;
Field Type Null Key Default Extra
f4 datetime YES NULL
create table t9 as select case when 1 then cast('01-01-01' as date)
when 0 then cast('01-01-01' as date) end as f4 from t1;
desc t9;
Field Type Null Key Default Extra
f4 date YES NULL
create table t10 as select case when 1 then cast('01-01-01' as datetime)
when 0 then cast('01-01-01' as datetime) end as f4 from t1;
desc t10;
Field Type Null Key Default Extra
f4 datetime YES NULL
create table t11 as select if(1, cast('01-01-01' as datetime),
cast('01-01-01' as date)) as f4 from t1;
desc t11;
Field Type Null Key Default Extra
f4 datetime YES NULL
create table t12 as select least(cast('01-01-01' as datetime),
cast('01-01-01' as date)) as f4 from t1;
desc t12;
Field Type Null Key Default Extra
f4 datetime YES NULL
create table t13 as select ifnull(cast('01-01-01' as datetime),
cast('01-01-01' as date)) as f4 from t1;
desc t13;
Field Type Null Key Default Extra
f4 datetime YES NULL
drop tables t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13;
###################################################################
create table t1 (f1 time);
insert into t1 set f1 = '45:44:44';
insert into t1 set f1 = '15:44:44';
select * from t1 where (convert(f1,datetime)) != 1;
f1
15:44:44
Warnings:
Warning 1292 Incorrect datetime value: '0000-00-00 45:44:44'
drop table t1;
create table t1 (a tinyint);
insert into t1 values (), (), ();
select sum(a) from t1 group by convert(a, datetime);
sum(a)
NULL
drop table t1;
create table t1 (id int(10) not null, cur_date datetime not null);
create table t2 (id int(10) not null, cur_date date not null);
insert into t1 (id, cur_date) values (1, '2007-04-25 18:30:22');
insert into t2 (id, cur_date) values (1, '2007-04-25');
explain extended
select * from t1
where id in (select id from t1 as x1 where (t1.cur_date is null));
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 1 100.00 Using where
2 DEPENDENT SUBQUERY x1 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
Note 1276 Field or reference 'test.t1.cur_date' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`cur_date` AS `cur_date` from `test`.`t1` where <in_optimizer>(`test`.`t1`.`id`,<exists>(select 1 from `test`.`t1` `x1` where ((`test`.`t1`.`cur_date` = 0) and (<cache>(`test`.`t1`.`id`) = `test`.`x1`.`id`))))
select * from t1
where id in (select id from t1 as x1 where (t1.cur_date is null));
id cur_date
explain extended
select * from t2
where id in (select id from t2 as x1 where (t2.cur_date is null));
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 1 100.00 Using where
2 DEPENDENT SUBQUERY x1 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
Note 1276 Field or reference 'test.t2.cur_date' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`t2`.`id` AS `id`,`test`.`t2`.`cur_date` AS `cur_date` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`id`,<exists>(select 1 from `test`.`t2` `x1` where ((`test`.`t2`.`cur_date` = 0) and (<cache>(`test`.`t2`.`id`) = `test`.`x1`.`id`))))
select * from t2
where id in (select id from t2 as x1 where (t2.cur_date is null));
id cur_date
insert into t1 (id, cur_date) values (2, '2007-04-26 18:30:22');
insert into t2 (id, cur_date) values (2, '2007-04-26');
explain extended
select * from t1
where id in (select id from t1 as x1 where (t1.cur_date is null));
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where
2 DEPENDENT SUBQUERY x1 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
Note 1276 Field or reference 'test.t1.cur_date' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`cur_date` AS `cur_date` from `test`.`t1` where <in_optimizer>(`test`.`t1`.`id`,<exists>(select 1 from `test`.`t1` `x1` where ((`test`.`t1`.`cur_date` = 0) and (<cache>(`test`.`t1`.`id`) = `test`.`x1`.`id`))))
select * from t1
where id in (select id from t1 as x1 where (t1.cur_date is null));
id cur_date
explain extended
select * from t2
where id in (select id from t2 as x1 where (t2.cur_date is null));
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where
2 DEPENDENT SUBQUERY x1 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
Note 1276 Field or reference 'test.t2.cur_date' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`t2`.`id` AS `id`,`test`.`t2`.`cur_date` AS `cur_date` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`id`,<exists>(select 1 from `test`.`t2` `x1` where ((`test`.`t2`.`cur_date` = 0) and (<cache>(`test`.`t2`.`id`) = `test`.`x1`.`id`))))
select * from t2
where id in (select id from t2 as x1 where (t2.cur_date is null));
id cur_date
drop table t1,t2;
End of 5.0 tests
set @org_mode=@@sql_mode;
create table t1 (da date default '1962-03-03 23:33:34', dt datetime default '1962-03-03');
Warnings:
Note 1265 Data truncated for column 'da' at row 1
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`da` date DEFAULT '1962-03-03',
`dt` datetime DEFAULT '1962-03-03 00:00:00'
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
insert into t1 values ();
insert into t1 values ('2007-03-23 13:49:38','2007-03-23 13:49:38');
Warnings:
Note 1265 Data truncated for column 'da' at row 1
set @@sql_mode='ansi,traditional';
insert into t1 values ('2007-03-23 13:49:38','2007-03-23 13:49:38');
Warnings:
Note 1265 Data truncated for column 'da' at row 1
insert into t1 set dt='2007-03-23 13:49:38',da=dt;
Warnings:
Note 1265 Data truncated for column 'da' at row 1
insert into t1 values ('2007-03-32','2007-03-23 13:49:38');
ERROR 22007: Incorrect date value: '2007-03-32' for column 'da' at row 1
select * from t1;
da dt
1962-03-03 1962-03-03 00:00:00
2007-03-23 2007-03-23 13:49:38
2007-03-23 2007-03-23 13:49:38
2007-03-23 2007-03-23 13:49:38
drop table t1;
create table t1 (da date default '1962-03-32 23:33:34', dt datetime default '1962-03-03');
ERROR 42000: Invalid default value for 'da'
create table t1 (t time default '916:00:00 a');
ERROR 42000: Invalid default value for 't'
set @@sql_mode= @org_mode;
SET STORAGE_ENGINE='tokudb';
DROP TABLE IF EXISTS t1, t2;
SET SQL_WARNINGS=1;
CREATE TABLE t1 (
id int(11) NOT NULL auto_increment,
datatype_id int(11) DEFAULT '0' NOT NULL,
minvalue decimal(20,10) DEFAULT '0.0000000000' NOT NULL,
maxvalue decimal(20,10) DEFAULT '0.0000000000' NOT NULL,
valuename varchar(20),
forecolor int(11),
backcolor int(11),
PRIMARY KEY (id),
UNIQUE datatype_id (datatype_id, minvalue, maxvalue)
);
INSERT INTO t1 VALUES ( '1', '4', '0.0000000000', '0.0000000000', 'Ei saja', '0', '16776960');
INSERT INTO t1 VALUES ( '2', '4', '1.0000000000', '1.0000000000', 'Sajab', '16777215', '255');
INSERT INTO t1 VALUES ( '3', '1', '2.0000000000', '49.0000000000', '', '0', '16777215');
INSERT INTO t1 VALUES ( '60', '11', '0.0000000000', '0.0000000000', 'Rikkis', '16777215', '16711680');
INSERT INTO t1 VALUES ( '4', '12', '1.0000000000', '1.0000000000', 'nork sadu', '65280', '14474460');
INSERT INTO t1 VALUES ( '5', '12', '2.0000000000', '2.0000000000', 'keskmine sadu', '255', '14474460');
INSERT INTO t1 VALUES ( '6', '12', '3.0000000000', '3.0000000000', 'tugev sadu', '127', '14474460');
INSERT INTO t1 VALUES ( '43', '39', '6.0000000000', '6.0000000000', 'lobjakas', '13107327', '16763080');
INSERT INTO t1 VALUES ( '40', '39', '2.0000000000', '2.0000000000', 'vihm', '8355839', '16777215');
INSERT INTO t1 VALUES ( '53', '1', '-35.0000000000', '-5.0000000000', '', '0', '16777215');
INSERT INTO t1 VALUES ( '41', '39', '3.0000000000', '3.0000000000', 'klm vihm', '120', '16763080');
INSERT INTO t1 VALUES ( '12', '21', '21.0000000000', '21.0000000000', 'Kuiv', '13158600', '16777215');
INSERT INTO t1 VALUES ( '13', '21', '13.0000000000', '13.0000000000', 'Mrg', '5263615', '16777215');
INSERT INTO t1 VALUES ( '14', '21', '22.0000000000', '22.0000000000', 'Niiske', '9869055', '16777215');
INSERT INTO t1 VALUES ( '19', '21', '33.0000000000', '33.0000000000', 'Mrg', '5263615', '16777215');
INSERT INTO t1 VALUES ( '15', '21', '23.0000000000', '23.0000000000', 'Mrg', '5263615', '16777215');
INSERT INTO t1 VALUES ( '16', '21', '31.0000000000', '31.0000000000', 'Kuiv', '13158600', '16777215');
INSERT INTO t1 VALUES ( '17', '21', '12.0000000000', '12.0000000000', 'Niiske', '9869055', '16777215');
INSERT INTO t1 VALUES ( '18', '21', '32.0000000000', '32.0000000000', 'Niiske', '9869055', '16777215');
INSERT INTO t1 VALUES ( '20', '21', '331.0000000000', '331.0000000000', 'Hrmatise hoiatus!', '14448840', '13158600');
INSERT INTO t1 VALUES ( '21', '21', '11.0000000000', '11.0000000000', 'Kuiv', '13158600', '16777215');
INSERT INTO t1 VALUES ( '22', '33', '21.0000000000', '21.0000000000', 'Pilves, kuiv', '8355711', '12632256');
INSERT INTO t1 VALUES ( '23', '33', '13.0000000000', '13.0000000000', 'Sajab, mrg', '0', '8355839');
INSERT INTO t1 VALUES ( '24', '33', '22.0000000000', '22.0000000000', 'Pilves, niiske', '8355711', '12632319');
INSERT INTO t1 VALUES ( '29', '33', '33.0000000000', '33.0000000000', 'Selge, mrg', '16777215', '8355839');
INSERT INTO t1 VALUES ( '25', '33', '23.0000000000', '23.0000000000', 'Pilves, mrg', '8355711', '8355839');
INSERT INTO t1 VALUES ( '26', '33', '31.0000000000', '31.0000000000', 'Selge, kuiv', '16777215', '12632256');
INSERT INTO t1 VALUES ( '27', '33', '12.0000000000', '12.0000000000', 'Sajab, niiske', '0', '12632319');
INSERT INTO t1 VALUES ( '28', '33', '32.0000000000', '32.0000000000', 'Selge, niiske', '16777215', '12632319');
INSERT INTO t1 VALUES ( '30', '33', '331.0000000000', '331.0000000000', 'Hrmatis! selge,kuiv', '16711680', '12632256');
INSERT INTO t1 VALUES ( '31', '33', '11.0000000000', '11.0000000000', 'Sajab, kuiv', '0', '12632256');
INSERT INTO t1 VALUES ( '32', '11', '1.0000000000', '1.0000000000', 'Korras', '16777215', '49152');
INSERT INTO t1 VALUES ( '33', '21', '335.0000000000', '335.0000000000', 'Hrmatis!', '14448840', '11842740');
INSERT INTO t1 VALUES ( '34', '21', '134.0000000000', '134.0000000000', 'Hoiatus, M+S!', '255', '13158600');
INSERT INTO t1 VALUES ( '35', '21', '133.0000000000', '133.0000000000', 'Hoiatus, mrg!', '5263615', '13158600');
INSERT INTO t1 VALUES ( '36', '21', '135.0000000000', '135.0000000000', 'Hrmatis!', '14448840', '11842740');
INSERT INTO t1 VALUES ( '37', '21', '334.0000000000', '334.0000000000', 'Hrmatise hoiatus!', '14448840', '13158600');
INSERT INTO t1 VALUES ( '38', '21', '132.0000000000', '132.0000000000', 'Hoiatus, niiske!', '9869055', '13158600');
INSERT INTO t1 VALUES ( '39', '39', '1.0000000000', '1.0000000000', 'ei saja', '11206570', '16777215');
INSERT INTO t1 VALUES ( '44', '39', '4.0000000000', '5.0000000000', 'lumi', '16711680', '16763080');
INSERT INTO t1 VALUES ( '45', '12', '0.0000000000', '0.0000000000', '', '16777215', '14474460');
INSERT INTO t1 VALUES ( '46', '39', '8.0000000000', '8.0000000000', 'rahe', '9830400', '16763080');
INSERT INTO t1 VALUES ( '47', '39', '9.0000000000', '9.0000000000', 'tp ebaselge', '12582912', '16777215');
INSERT INTO t1 VALUES ( '48', '39', '7.0000000000', '7.0000000000', 'lumetuisk', '7209070', '16763080');
INSERT INTO t1 VALUES ( '142', '15', '2.0000000000', '49.0000000000', '', '0', '16777215');
INSERT INTO t1 VALUES ( '52', '1', '-4.9000000000', '-0.1000000000', '', '0', '15774720');
INSERT INTO t1 VALUES ( '141', '15', '-4.9000000000', '-0.1000000000', '', '0', '15774720');
INSERT INTO t1 VALUES ( '55', '8', '0.0000000000', '0.0000000000', '', '0', '16777215');
INSERT INTO t1 VALUES ( '56', '8', '0.0100000000', '0.1000000000', '', '0', '16770560');
INSERT INTO t1 VALUES ( '57', '8', '0.1100000000', '25.0000000000', '', '0', '15774720');
INSERT INTO t1 VALUES ( '58', '2', '90.0000000000', '94.9000000000', '', NULL, '16770560');
INSERT INTO t1 VALUES ( '59', '6', '0.0000000000', '360.0000000000', '', NULL, '16777215');
INSERT INTO t1 VALUES ( '61', '21', '38.0000000000', '38.0000000000', 'Niiske', '9869055', '16777215');
INSERT INTO t1 VALUES ( '62', '38', '500.0000000000', '999.0000000000', '', '0', '16770560');
INSERT INTO t1 VALUES ( '63', '38', '1000.0000000000', '2000.0000000000', '', '0', '16777215');
INSERT INTO t1 VALUES ( '64', '17', '0.0000000000', '0.0000000000', '', NULL, '16777215');
INSERT INTO t1 VALUES ( '65', '17', '0.1000000000', '10.0000000000', '', NULL, '16770560');
INSERT INTO t1 VALUES ( '67', '21', '412.0000000000', '412.0000000000', 'Niiske', '9869055', '16777215');
INSERT INTO t1 VALUES ( '68', '21', '413.0000000000', '413.0000000000', 'Mrg', '5263615', '16777215');
INSERT INTO t1 VALUES ( '69', '21', '113.0000000000', '113.0000000000', 'Mrg', '5263615', '16777215');
INSERT INTO t1 VALUES ( '70', '21', '416.0000000000', '416.0000000000', 'Lumine!', '16711680', '11842740');
INSERT INTO t1 VALUES ( '71', '38', '0.0000000000', '499.0000000000', '', NULL, '16711680');
INSERT INTO t1 VALUES ( '72', '22', '-49.0000000000', '49.0000000000', '', NULL, '16777215');
INSERT INTO t1 VALUES ( '73', '13', '0.0000000000', '9.9000000000', '', NULL, '16777215');
INSERT INTO t1 VALUES ( '74', '13', '10.0000000000', '14.9000000000', '', NULL, '16770560');
INSERT INTO t1 VALUES ( '75', '7', '0.0000000000', '50.0000000000', '', NULL, '16777215');
INSERT INTO t1 VALUES ( '76', '18', '0.0000000000', '0.0000000000', '', NULL, '16777215');
INSERT INTO t1 VALUES ( '77', '18', '0.1000000000', '10.0000000000', '', NULL, '16770560');
INSERT INTO t1 VALUES ( '78', '19', '300.0000000000', '400.0000000000', '', NULL, '16777215');
INSERT INTO t1 VALUES ( '79', '19', '0.0000000000', '299.0000000000', '', NULL, '16770560');
INSERT INTO t1 VALUES ( '80', '23', '0.0000000000', '100.0000000000', '', NULL, '16777215');
INSERT INTO t1 VALUES ( '81', '24', '0.0000000000', '200.0000000000', '', NULL, '16777215');
INSERT INTO t1 VALUES ( '82', '26', '0.0000000000', '0.0000000000', '', NULL, '16777215');
INSERT INTO t1 VALUES ( '83', '26', '0.1000000000', '5.0000000000', '', NULL, '16776960');
INSERT INTO t1 VALUES ( '84', '21', '422.0000000000', '422.0000000000', 'Niiske', '9869055', '16777215');
INSERT INTO t1 VALUES ( '85', '21', '411.0000000000', '411.0000000000', 'Saju hoiat.,kuiv!', '16777215', '13158600');
INSERT INTO t1 VALUES ( '86', '21', '423.0000000000', '423.0000000000', 'Mrg', '5263615', '16777215');
INSERT INTO t1 VALUES ( '144', '16', '-49.0000000000', '-5.0000000000', '', NULL, '16777215');
INSERT INTO t1 VALUES ( '88', '16', '2.0000000000', '49.0000000000', '', NULL, '16777215');
INSERT INTO t1 VALUES ( '89', '21', '338.0000000000', '338.0000000000', 'Hrm.hoiatus, N+S!', '16744319', '13158600');
INSERT INTO t1 VALUES ( '90', '21', '332.0000000000', '332.0000000000', 'Hrm.hoiat., niiske!', '16744319', '13158600');
INSERT INTO t1 VALUES ( '91', '21', '114.0000000000', '114.0000000000', 'Hoiatus, M+S!', '255', '13158600');
INSERT INTO t1 VALUES ( '92', '21', '117.0000000000', '117.0000000000', 'Hoiatus, J!', '14448840', '16711680');
INSERT INTO t1 VALUES ( '93', '21', '116.0000000000', '116.0000000000', 'Lumine!', '16711680', '11842740');
INSERT INTO t1 VALUES ( '94', '21', '414.0000000000', '414.0000000000', 'Hoiatus, M+S!', '255', '13158600');
INSERT INTO t1 VALUES ( '95', '21', '325.0000000000', '325.0000000000', 'Hrmatis!', '14448840', '11842740');
INSERT INTO t1 VALUES ( '96', '21', '321.0000000000', '321.0000000000', 'Hrmatise hoiatus!', '14448840', '13158600');
INSERT INTO t1 VALUES ( '97', '21', '328.0000000000', '328.0000000000', 'Hrm.hoiatus, N+S!', '16744319', '13158600');
INSERT INTO t1 VALUES ( '98', '21', '28.0000000000', '28.0000000000', 'Niiske ja sool', '9869055', '16777215');
INSERT INTO t1 VALUES ( '99', '21', '118.0000000000', '118.0000000000', 'Hoiatus, N+S!', '9869055', '13158600');
INSERT INTO t1 VALUES ( '100', '21', '418.0000000000', '418.0000000000', 'Hoiatus, N+S!', '9869055', '13158600');
INSERT INTO t1 VALUES ( '101', '21', '322.0000000000', '322.0000000000', 'Hrm.hoiat., niiske!', '16744319', '13158600');
INSERT INTO t1 VALUES ( '102', '21', '428.0000000000', '428.0000000000', 'Hoiatus, N+S!', '9869055', '13158600');
INSERT INTO t1 VALUES ( '103', '21', '432.0000000000', '432.0000000000', 'Hoiatus, niiske!', '7895240', '13158600');
INSERT INTO t1 VALUES ( '104', '21', '421.0000000000', '421.0000000000', 'Saju hoiat.,kuiv!', '16777215', '13158600');
INSERT INTO t1 VALUES ( '105', '21', '24.0000000000', '24.0000000000', 'Mrg ja sool', '255', '16777215');
INSERT INTO t1 VALUES ( '106', '21', '438.0000000000', '438.0000000000', 'Hoiatus, N+S!', '9869055', '13158600');
INSERT INTO t1 VALUES ( '107', '21', '112.0000000000', '112.0000000000', 'Hoiatus, niiske!', '9869055', '13158600');
INSERT INTO t1 VALUES ( '108', '21', '34.0000000000', '34.0000000000', 'Mrg ja sool', '255', '16777215');
INSERT INTO t1 VALUES ( '109', '21', '434.0000000000', '434.0000000000', 'Hoiatus, M+S!', '255', '13158600');
INSERT INTO t1 VALUES ( '110', '21', '124.0000000000', '124.0000000000', 'Hoiatus, M+S!', '255', '13158600');
INSERT INTO t1 VALUES ( '111', '21', '424.0000000000', '424.0000000000', 'Hoiatus, M+S!', '255', '13158600');
INSERT INTO t1 VALUES ( '112', '21', '123.0000000000', '123.0000000000', 'Hoiatus, mrg!', '5263615', '13158600');
INSERT INTO t1 VALUES ( '140', '15', '-49.0000000000', '-5.0000000000', '', '0', '16777215');
INSERT INTO t1 VALUES ( '114', '21', '18.0000000000', '18.0000000000', 'Niiske ja sool', '9869055', '16777215');
INSERT INTO t1 VALUES ( '115', '21', '122.0000000000', '122.0000000000', 'Hoiatus, niiske!', '9869055', '13158600');
INSERT INTO t1 VALUES ( '116', '21', '14.0000000000', '14.0000000000', 'Mrg ja sool', '255', '16777215');
INSERT INTO t1 VALUES ( '117', '21', '311.0000000000', '311.0000000000', 'Hrmatise hoiatus!', '14448840', '13158600');
INSERT INTO t1 VALUES ( '121', '2', '95.0000000000', '100.0000000000', '', NULL, '15774720');
INSERT INTO t1 VALUES ( '118', '2', '0.0000000000', '89.9000000000', '', NULL, '16777215');
INSERT INTO t1 VALUES ( '119', '21', '16.0000000000', '16.0000000000', 'Lumine!', '16711680', '11842740');
INSERT INTO t1 VALUES ( '120', '21', '26.0000000000', '26.0000000000', 'Lumine!', '16711680', '11842740');
INSERT INTO t1 VALUES ( '122', '13', '15.0000000000', '50.0000000000', '', NULL, '15774720');
INSERT INTO t1 VALUES ( '123', '5', '0.0000000000', '9.9000000000', '', NULL, '16777215');
INSERT INTO t1 VALUES ( '124', '5', '10.0000000000', '14.9000000000', '', NULL, '16770560');
INSERT INTO t1 VALUES ( '125', '5', '15.0000000000', '50.0000000000', '', NULL, '15774720');
INSERT INTO t1 VALUES ( '126', '21', '128.0000000000', '128.0000000000', 'Hoiatus, N+S!', '9869055', '13158600');
INSERT INTO t1 VALUES ( '127', '21', '318.0000000000', '318.0000000000', 'Hrm.hoiatus, N+S!', '16744319', '13158600');
INSERT INTO t1 VALUES ( '128', '21', '312.0000000000', '312.0000000000', 'Hrm.hoiat., niiske!', '16744319', '13158600');
INSERT INTO t1 VALUES ( '129', '21', '126.0000000000', '126.0000000000', 'Lumine!', '16711680', '11842740');
INSERT INTO t1 VALUES ( '130', '21', '324.0000000000', '324.0000000000', 'Hrmatise hoiatus!', '14448840', '13158600');
INSERT INTO t1 VALUES ( '131', '21', '316.0000000000', '316.0000000000', 'Lumine!', '16711680', '11842740');
INSERT INTO t1 VALUES ( '132', '1', '0.0000000000', '1.9000000000', '', NULL, '16769024');
INSERT INTO t1 VALUES ( '134', '3', '-50.0000000000', '50.0000000000', '', NULL, '16777215');
INSERT INTO t1 VALUES ( '135', '8', '26.0000000000', '2000.0000000000', '', '9868950', '15774720');
INSERT INTO t1 VALUES ( '136', '21', '426.0000000000', '426.0000000000', 'Lumine!', '16711680', '11842740');
INSERT INTO t1 VALUES ( '137', '21', '127.0000000000', '127.0000000000', 'Hoiatus, J!', '14448840', '16711680');
INSERT INTO t1 VALUES ( '138', '21', '121.0000000000', '121.0000000000', 'Kuiv', '13158600', '16777215');
INSERT INTO t1 VALUES ( '139', '21', '326.0000000000', '326.0000000000', 'Lumine!', '16711680', '11842740');
INSERT INTO t1 VALUES ( '143', '16', '-4.9000000000', '-0.1000000000', '', NULL, '15774720');
INSERT INTO t1 VALUES ( '145', '15', '0.0000000000', '1.9000000000', '', '0', '16769024');
INSERT INTO t1 VALUES ( '146', '16', '0.0000000000', '1.9000000000', '', '0', '16769024');
select * from t1 where minvalue<=1 and maxvalue>=-1 and datatype_id=16;
id datatype_id minvalue maxvalue valuename forecolor backcolor
143 16 -4.9000000000 -0.1000000000 NULL 15774720
146 16 0.0000000000 1.9000000000 0 16769024
select * from t1 where minvalue<=-1 and maxvalue>=-1 and datatype_id=16;
id datatype_id minvalue maxvalue valuename forecolor backcolor
143 16 -4.9000000000 -0.1000000000 NULL 15774720
drop table t1;
create table t1 (a decimal(10,2));
insert into t1 values ("0.0"),("-0.0"),("+0.0"),("01.0"),("+01.0"),("-01.0");
insert into t1 values ("-.1"),("+.1"),(".1");
insert into t1 values ("00000000000001"),("+0000000000001"),("-0000000000001");
insert into t1 values ("+111111111.11"),("111111111.11"),("-11111111.11");
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
Warning 1264 Out of range value for column 'a' at row 2
insert into t1 values ("-111111111.11"),("+1111111111.11"),("1111111111.11");
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
Warning 1264 Out of range value for column 'a' at row 2
Warning 1264 Out of range value for column 'a' at row 3
insert into t1 values ("1e+1000"),("1e-1000"),("-1e+1000");
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
Note 1265 Data truncated for column 'a' at row 2
Warning 1264 Out of range value for column 'a' at row 3
insert into t1 values ("1e+4294967296"),("1e-4294967296");
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
Note 1265 Data truncated for column 'a' at row 2
insert into t1 values ("1e+18446744073709551615"),("1e+18446744073709551616"),("1e-9223372036854775807"),("1e-9223372036854775809");
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
Warning 1366 Incorrect decimal value: '1e+18446744073709551616' for column 'a' at row 2
Note 1265 Data truncated for column 'a' at row 3
Warning 1366 Incorrect decimal value: '1e-9223372036854775809' for column 'a' at row 4
insert into t1 values ("123.4e"),("123.4e+2"),("123.4e-2"),("123e1"),("123e+0");
Warnings:
Note 1265 Data truncated for column 'a' at row 1
Note 1265 Data truncated for column 'a' at row 3
select * from t1;
a
0.00
0.00
0.00
1.00
1.00
-1.00
-0.10
0.10
0.10
1.00
1.00
-1.00
99999999.99
99999999.99
-11111111.11
-99999999.99
99999999.99
99999999.99
99999999.99
0.00
-99999999.99
99999999.99
0.00
99999999.99
0.00
0.00
0.00
123.40
12340.00
1.23
1230.00
123.00
drop table t1;
create table t1 (a decimal(10,2) unsigned);
insert into t1 values ("0.0"),("-0.0"),("+0.0"),("01.0"),("+01.0"),("-01.0");
Warnings:
Warning 1264 Out of range value for column 'a' at row 2
Warning 1264 Out of range value for column 'a' at row 6
insert into t1 values ("-.1"),("+.1"),(".1");
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
insert into t1 values ("00000000000001"),("+0000000000001"),("-0000000000001");
Warnings:
Warning 1264 Out of range value for column 'a' at row 3
insert into t1 values ("+111111111.11"),("111111111.11"),("-11111111.11");
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
Warning 1264 Out of range value for column 'a' at row 2
Warning 1264 Out of range value for column 'a' at row 3
insert into t1 values ("-111111111.11"),("+1111111111.11"),("1111111111.11");
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
Warning 1264 Out of range value for column 'a' at row 2
Warning 1264 Out of range value for column 'a' at row 3
insert into t1 values ("1e+1000"),("1e-1000"),("-1e+1000");
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
Note 1265 Data truncated for column 'a' at row 2
Warning 1264 Out of range value for column 'a' at row 3
insert into t1 values ("123.4e"),("123.4e+2"),("123.4e-2"),("123e1"),("123e+0");
Warnings:
Note 1265 Data truncated for column 'a' at row 1
Note 1265 Data truncated for column 'a' at row 3
select * from t1;
a
0.00
0.00
0.00
1.00
1.00
0.00
0.00
0.10
0.10
1.00
1.00
0.00
99999999.99
99999999.99
0.00
0.00
99999999.99
99999999.99
99999999.99
0.00
0.00
123.40
12340.00
1.23
1230.00
123.00
drop table t1;
create table t1 (a decimal(10,2) zerofill);
insert into t1 values ("0.0"),("-0.0"),("+0.0"),("01.0"),("+01.0"),("-01.0");
Warnings:
Warning 1264 Out of range value for column 'a' at row 2
Warning 1264 Out of range value for column 'a' at row 6
insert into t1 values ("-.1"),("+.1"),(".1");
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
insert into t1 values ("00000000000001"),("+0000000000001"),("-0000000000001");
Warnings:
Warning 1264 Out of range value for column 'a' at row 3
insert into t1 values ("+111111111.11"),("111111111.11"),("-11111111.11");
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
Warning 1264 Out of range value for column 'a' at row 2
Warning 1264 Out of range value for column 'a' at row 3
insert into t1 values ("-111111111.11"),("+1111111111.11"),("1111111111.11");
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
Warning 1264 Out of range value for column 'a' at row 2
Warning 1264 Out of range value for column 'a' at row 3
insert into t1 values ("1e+1000"),("1e-1000"),("-1e+1000");
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
Note 1265 Data truncated for column 'a' at row 2
Warning 1264 Out of range value for column 'a' at row 3
insert into t1 values ("123.4e"),("123.4e+2"),("123.4e-2"),("123e1"),("123e+0");
Warnings:
Note 1265 Data truncated for column 'a' at row 1
Note 1265 Data truncated for column 'a' at row 3
select * from t1;
a
00000000.00
00000000.00
00000000.00
00000001.00
00000001.00
00000000.00
00000000.00
00000000.10
00000000.10
00000001.00
00000001.00
00000000.00
99999999.99
99999999.99
00000000.00
00000000.00
99999999.99
99999999.99
99999999.99
00000000.00
00000000.00
00000123.40
00012340.00
00000001.23
00001230.00
00000123.00
drop table t1;
create table t1 (a decimal(10,2));
insert into t1 values (0.0),("-0.0"),(+0.0),(01.0),(+01.0),(-01.0);
insert into t1 values (-.1),(+.1),(.1);
insert into t1 values (00000000000001),(+0000000000001),(-0000000000001);
insert into t1 values (+111111111.11),(111111111.11),(-11111111.11);
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
Warning 1264 Out of range value for column 'a' at row 2
insert into t1 values (-111111111.11),(+1111111111.11),(1111111111.11);
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
Warning 1264 Out of range value for column 'a' at row 2
Warning 1264 Out of range value for column 'a' at row 3
insert into t1 values (1e+100),(1e-100),(-1e+100);
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
Note 1265 Data truncated for column 'a' at row 2
Warning 1264 Out of range value for column 'a' at row 3
insert into t1 values (123.4e0),(123.4e+2),(123.4e-2),(123e1),(123e+0);
Warnings:
Note 1265 Data truncated for column 'a' at row 3
insert into t1 values (MID("987",1,2)),("987 "),("987.6e+2 ");
select * from t1;
a
0.00
0.00
0.00
1.00
1.00
-1.00
-0.10
0.10
0.10
1.00
1.00
-1.00
99999999.99
99999999.99
-11111111.11
-99999999.99
99999999.99
99999999.99
99999999.99
0.00
-99999999.99
123.40
12340.00
1.23
1230.00
123.00
98.00
987.00
98760.00
drop table t1;
create table t1 (a decimal);
insert into t1 values (-99999999999999),(-1),('+1'),('01'),('+00000000000001'),('+12345678901'),(99999999999999);
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
Warning 1264 Out of range value for column 'a' at row 6
Warning 1264 Out of range value for column 'a' at row 7
select * from t1;
a
-9999999999
-1
1
1
1
9999999999
9999999999
drop table t1;
create table t1 (a decimal unsigned);
insert into t1 values (-99999999999999),(-1),('+1'),('01'),('+00000000000001'),('+1234567890'),(99999999999999);
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
Warning 1264 Out of range value for column 'a' at row 2
Warning 1264 Out of range value for column 'a' at row 7
select * from t1;
a
0
0
1
1
1
1234567890
9999999999
drop table t1;
create table t1 (a decimal zerofill);
insert into t1 values (-99999999999999),(-1),('+1'),('01'),('+00000000000001'),('+1234567890'),(99999999999999);
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
Warning 1264 Out of range value for column 'a' at row 2
Warning 1264 Out of range value for column 'a' at row 7
select * from t1;
a
0000000000
0000000000
0000000001
0000000001
0000000001
1234567890
9999999999
drop table t1;
create table t1 (a decimal unsigned zerofill);
insert into t1 values (-99999999999999),(-1),('+1'),('01'),('+00000000000001'),('+1234567890'),(99999999999999);
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
Warning 1264 Out of range value for column 'a' at row 2
Warning 1264 Out of range value for column 'a' at row 7
select * from t1;
a
0000000000
0000000000
0000000001
0000000001
0000000001
1234567890
9999999999
drop table t1;
create table t1(a decimal(10,0));
insert into t1 values ("1e4294967295");
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
select * from t1;
a
9999999999
delete from t1;
insert into t1 values("1e4294967297");
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
select * from t1;
a
9999999999
drop table t1;
CREATE TABLE t1 (a_dec DECIMAL(-1,0));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1,0))' at line 1
CREATE TABLE t1 (a_dec DECIMAL(-2,1));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-2,1))' at line 1
CREATE TABLE t1 (a_dec DECIMAL(-1,1));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1,1))' at line 1
CREATE TABLE t1 (a_dec DECIMAL(0,11));
ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column 'a_dec').
create table t1(a decimal(7,3));
insert into t1 values ('1'),('+1'),('-1'),('0000000001'),('+0000000001'),('-0000000001'),('10'),('+10'),('-10'),('0000000010'),('+0000000010'),('-0000000010'),('100'),('+100'),('-100'),('0000000100'),('+0000000100'),('-0000000100'),('1000'),('+1000'),('-1000'),('0000001000'),('+0000001000'),('-0000001000'),('10000'),('+10000'),('-10000'),('0000010000'),('+0000010000'),('-0000010000'),('100000'),('+100000'),('-100000'),('0000100000'),('+0000100000'),('-0000100000'),('1000000'),('+1000000'),('-1000000'),('0001000000'),('+0001000000'),('-0001000000'),('10000000'),('+10000000'),('-10000000'),('0010000000'),('+0010000000'),('-0010000000'),('100000000'),('+100000000'),('-100000000'),('0100000000'),('+0100000000'),('-0100000000'),('1000000000'),('+1000000000'),('-1000000000'),('1000000000'),('+1000000000'),('-1000000000');
select * from t1;
a
1.000
1.000
-1.000
1.000
1.000
-1.000
10.000
10.000
-10.000
10.000
10.000
-10.000
100.000
100.000
-100.000
100.000
100.000
-100.000
1000.000
1000.000
-1000.000
1000.000
1000.000
-1000.000
9999.999
9999.999
-9999.999
9999.999
9999.999
-9999.999
9999.999
9999.999
-9999.999
9999.999
9999.999
-9999.999
9999.999
9999.999
-9999.999
9999.999
9999.999
-9999.999
9999.999
9999.999
-9999.999
9999.999
9999.999
-9999.999
9999.999
9999.999
-9999.999
9999.999
9999.999
-9999.999
9999.999
9999.999
-9999.999
9999.999
9999.999
-9999.999
drop table t1;
create table t1(a decimal(7,3) unsigned);
insert into t1 values ('1'),('+1'),('-1'),('0000000001'),('+0000000001'),('-0000000001'),('10'),('+10'),('-10'),('0000000010'),('+0000000010'),('-0000000010'),('100'),('+100'),('-100'),('0000000100'),('+0000000100'),('-0000000100'),('1000'),('+1000'),('-1000'),('0000001000'),('+0000001000'),('-0000001000'),('10000'),('+10000'),('-10000'),('0000010000'),('+0000010000'),('-0000010000'),('100000'),('+100000'),('-100000'),('0000100000'),('+0000100000'),('-0000100000'),('1000000'),('+1000000'),('-1000000'),('0001000000'),('+0001000000'),('-0001000000'),('10000000'),('+10000000'),('-10000000'),('0010000000'),('+0010000000'),('-0010000000'),('100000000'),('+100000000'),('-100000000'),('0100000000'),('+0100000000'),('-0100000000'),('1000000000'),('+1000000000'),('-1000000000'),('1000000000'),('+1000000000'),('-1000000000');
select * from t1;
a
1.000
1.000
0.000
1.000
1.000
0.000
10.000
10.000
0.000
10.000
10.000
0.000
100.000
100.000
0.000
100.000
100.000
0.000
1000.000
1000.000
0.000
1000.000
1000.000
0.000
9999.999
9999.999
0.000
9999.999
9999.999
0.000
9999.999
9999.999
0.000
9999.999
9999.999
0.000
9999.999
9999.999
0.000
9999.999
9999.999
0.000
9999.999
9999.999
0.000
9999.999
9999.999
0.000
9999.999
9999.999
0.000
9999.999
9999.999
0.000
9999.999
9999.999
0.000
9999.999
9999.999
0.000
drop table t1;
create table t1(a decimal(7,3) zerofill);
insert into t1 values ('1'),('+1'),('-1'),('0000000001'),('+0000000001'),('-0000000001'),('10'),('+10'),('-10'),('0000000010'),('+0000000010'),('-0000000010'),('100'),('+100'),('-100'),('0000000100'),('+0000000100'),('-0000000100'),('1000'),('+1000'),('-1000'),('0000001000'),('+0000001000'),('-0000001000'),('10000'),('+10000'),('-10000'),('0000010000'),('+0000010000'),('-0000010000'),('100000'),('+100000'),('-100000'),('0000100000'),('+0000100000'),('-0000100000'),('1000000'),('+1000000'),('-1000000'),('0001000000'),('+0001000000'),('-0001000000'),('10000000'),('+10000000'),('-10000000'),('0010000000'),('+0010000000'),('-0010000000'),('100000000'),('+100000000'),('-100000000'),('0100000000'),('+0100000000'),('-0100000000'),('1000000000'),('+1000000000'),('-1000000000'),('1000000000'),('+1000000000'),('-1000000000');
select * from t1;
a
0001.000
0001.000
0000.000
0001.000
0001.000
0000.000
0010.000
0010.000
0000.000
0010.000
0010.000
0000.000
0100.000
0100.000
0000.000
0100.000
0100.000
0000.000
1000.000
1000.000
0000.000
1000.000
1000.000
0000.000
9999.999
9999.999
0000.000
9999.999
9999.999
0000.000
9999.999
9999.999
0000.000
9999.999
9999.999
0000.000
9999.999
9999.999
0000.000
9999.999
9999.999
0000.000
9999.999
9999.999
0000.000
9999.999
9999.999
0000.000
9999.999
9999.999
0000.000
9999.999
9999.999
0000.000
9999.999
9999.999
0000.000
9999.999
9999.999
0000.000
drop table t1;
create table t1(a decimal(10,5), b decimal(10,1));
insert into t1 values(123.12345, 123.12345);
Warnings:
Note 1265 Data truncated for column 'b' at row 1
update t1 set b=a;
Warnings:
Note 1265 Data truncated for column 'b' at row 1
select * from t1;
a b
123.12345 123.1
drop table t1;
End of 4.1 tests
CREATE TABLE t1
(EMPNUM CHAR(3) NOT NULL,
HOURS DECIMAL(5));
CREATE TABLE t2
(EMPNUM CHAR(3) NOT NULL,
HOURS BIGINT);
INSERT INTO t1 VALUES ('E1',40);
INSERT INTO t1 VALUES ('E8',NULL);
INSERT INTO t2 VALUES ('E1',40);
SELECT EMPNUM FROM t1 WHERE HOURS IN (SELECT HOURS FROM t2);
EMPNUM
E1
SELECT EMPNUM FROM t1 WHERE HOURS IN (SELECT HOURS FROM t1);
EMPNUM
E1
DROP TABLE t1,t2;
create table t1 (d decimal(64,0));
insert into t1 values (1);
select * from t1;
d
1
drop table t1;
create table t1 (d decimal(5));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`d` decimal(5,0) DEFAULT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
drop table t1;
create table t1 (d decimal);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`d` decimal(10,0) DEFAULT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
drop table t1;
create table t1 (d decimal(66,0));
ERROR 42000: Too big precision 66 specified for column 'd'. Maximum is 65.
CREATE TABLE t1 (i INT, d1 DECIMAL(9,2), d2 DECIMAL(9,2));
INSERT INTO t1 VALUES (1, 101.40, 21.40), (1, -80.00, 0.00),
(2, 0.00, 0.00), (2, -13.20, 0.00), (2, 59.60, 46.40),
(2, 30.40, 30.40), (3, 37.00, 7.40), (3, -29.60, 0.00),
(4, 60.00, 15.40), (4, -10.60, 0.00), (4, -34.00, 0.00),
(5, 33.00, 0.00), (5, -25.80, 0.00), (5, 0.00, 7.20),
(6, 0.00, 0.00), (6, -51.40, 0.00);
SELECT i, SUM(d1) AS a, SUM(d2) AS b FROM t1 GROUP BY i HAVING a <> b;
i a b
6 -51.40 0.00
SELECT i, ROUND(SUM(d1), 2) AS a, ROUND(SUM(d2), 2) AS b FROM t1 GROUP BY i
HAVING a <> b;
i a b
6 -51.40 0.00
drop table t1;
create table t1 (c1 varchar(100), c2 longtext);
insert into t1 set c1= 'non PS, 1.0 as constant', c2=1.0;
prepare stmt from "insert into t1 set c1='PS, 1.0 as constant ', c2=1.0";
execute stmt;
set @a=1.0;
insert into t1 set c1='non PS, 1.0 in parameter', c2=@a;
prepare stmt from "insert into t1 set c1='PS, 1.0 in parameter ', c2=?";
execute stmt using @a;
select * from t1;
c1 c2
non PS, 1.0 as constant 1.0
PS, 1.0 as constant 1.0
non PS, 1.0 in parameter 1.0
PS, 1.0 in parameter 1.0
deallocate prepare stmt;
drop table t1;
create table t1 (
strippedproductid char(15) not null default '',
zlevelprice decimal(10,2) default null,
primary key (strippedproductid)
);
create table t2 (
productid char(15) not null default '',
zlevelprice char(21) default null,
primary key (productid)
);
insert into t1 values ('002trans','49.99');
insert into t1 values ('003trans','39.98');
insert into t1 values ('004trans','31.18');
insert INTO t2 SELECT * FROM t1;
select * from t2;
productid zlevelprice
002trans 49.99
003trans 39.98
004trans 31.18
drop table t1, t2;
create table t1 (f1 decimal(5));
insert into t1 values (40);
flush tables;
select f1 from t1 where f1 in (select f1 from t1);
f1
40
drop table t1;
create table t1 as
select from_days(s) as date,t
from (select 1 as s,'t' as t union select null, null ) as sub1;
select group_concat(t) from t1 group by week(date)/10;
group_concat(t)
t
drop table t1;
CREATE TABLE t1 (
qty decimal(16,6) default NULL,
dps tinyint(3) unsigned default NULL
);
INSERT INTO t1 VALUES (1.1325,3);
SELECT ROUND(qty,3), dps, ROUND(qty,dps) FROM t1;
ROUND(qty,3) dps ROUND(qty,dps)
1.133 3 1.133000
DROP TABLE t1;
SELECT 1 % .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS '%';
%
0.012345687012345687012345687012345687012345687012345687012345687012345687000000000
SELECT MOD(1, .123456789123456789123456789123456789123456789123456789123456789123456789123456789) AS 'MOD()';
MOD()
0.012345687012345687012345687012345687012345687012345687012345687012345687000000000
create table t1 (f1 decimal(6,6),f2 decimal(6,6) zerofill);
insert into t1 values (-0.123456,0.123456);
select group_concat(f1),group_concat(f2) from t1;
group_concat(f1) group_concat(f2)
-0.123456 0.123456
drop table t1;
create table t1 (
ua_id decimal(22,0) not null,
ua_invited_by_id decimal(22,0) default NULL,
primary key(ua_id)
);
insert into t1 values (123, NULL), (456, NULL);
this must not produce error 1048:
select * from t1 where ua_invited_by_id not in (select ua_id from t1);
ua_id ua_invited_by_id
drop table t1;
DROP TABLE IF EXISTS t3;
DROP TABLE IF EXISTS t4;
CREATE TABLE t1( a NUMERIC, b INT );
INSERT INTO t1 VALUES (123456, 40), (123456, 40);
SELECT TRUNCATE( a, b ) AS c FROM t1 ORDER BY c;
c
123456
123456
SELECT ROUND( a, b ) AS c FROM t1 ORDER BY c;
c
123456
123456
SELECT ROUND( a, 100 ) AS c FROM t1 ORDER BY c;
c
123456.000000000000000000000000000000
123456.000000000000000000000000000000
CREATE TABLE t2( a NUMERIC, b INT );
INSERT INTO t2 VALUES (123456, 100);
SELECT TRUNCATE( a, b ) AS c FROM t2 ORDER BY c;
c
123456
SELECT ROUND( a, b ) AS c FROM t2 ORDER BY c;
c
123456
CREATE TABLE t3( a DECIMAL, b INT );
INSERT INTO t3 VALUES (123456, 40), (123456, 40);
SELECT TRUNCATE( a, b ) AS c FROM t3 ORDER BY c;
c
123456
123456
SELECT ROUND( a, b ) AS c FROM t3 ORDER BY c;
c
123456
123456
SELECT ROUND( a, 100 ) AS c FROM t3 ORDER BY c;
c
123456.000000000000000000000000000000
123456.000000000000000000000000000000
CREATE TABLE t4( a DECIMAL, b INT );
INSERT INTO t4 VALUES (123456, 40), (123456, 40);
SELECT TRUNCATE( a, b ) AS c FROM t4 ORDER BY c;
c
123456
123456
SELECT ROUND( a, b ) AS c FROM t4 ORDER BY c;
c
123456
123456
SELECT ROUND( a, 100 ) AS c FROM t4 ORDER BY c;
c
123456.000000000000000000000000000000
123456.000000000000000000000000000000
delete from t1;
INSERT INTO t1 VALUES (1234567890, 20), (999.99, 5);
Warnings:
Note 1265 Data truncated for column 'a' at row 2
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` decimal(10,0) DEFAULT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
select round(a,b) as c from t1 order by c;
c
1000
1234567890
DROP TABLE t1, t2, t3, t4;
End of 5.0 tests
This source diff could not be displayed because it is too large. You can view the blob instead.
SET STORAGE_ENGINE='tokudb';
drop table if exists t1,t2;
SELECT 10,10.0,10.,.1e+2,100.0e-1;
10 10.0 10. .1e+2 100.0e-1
10 10.0 10 10 10
SELECT 6e-05, -6e-05, --6e-05, -6e-05+1.000000;
6e-05 -6e-05 --6e-05 -6e-05+1.000000
6e-05 -6e-05 6e-05 0.99994
SELECT 1e1,1.e1,1.0e1,1e+1,1.e+1,1.0e+1,1e-1,1.e-1,1.0e-1;
1e1 1.e1 1.0e1 1e+1 1.e+1 1.0e+1 1e-1 1.e-1 1.0e-1
10 10 10 10 10 10 0.1 0.1 0.1
SELECT 0.001e+1,0.001e-1, -0.001e+01,-0.001e-01;
0.001e+1 0.001e-1 -0.001e+01 -0.001e-01
0.01 0.0001 -0.01 -0.0001
SELECT 123.23E+02,-123.23E-02,"123.23E+02"+0.0,"-123.23E-02"+0.0;
123.23E+02 -123.23E-02 "123.23E+02"+0.0 "-123.23E-02"+0.0
12323 -1.2323 12323 -1.2323
SELECT 2147483647E+02,21474836.47E+06;
2147483647E+02 21474836.47E+06
214748364700 21474836470000
create table t1 (f1 float(24),f2 float(52));
show full columns from t1;
Field Type Collation Null Key Default Extra Privileges Comment
f1 float NULL YES NULL #
f2 double NULL YES NULL #
insert into t1 values(10,10),(1e+5,1e+5),(1234567890,1234567890),(1e+10,1e+10),(1e+15,1e+15),(1e+20,1e+20),(1e+50,1e+50),(1e+150,1e+150);
Warnings:
Warning 1264 Out of range value for column 'f1' at row 7
Warning 1264 Out of range value for column 'f1' at row 8
insert into t1 values(-10,-10),(1e-5,1e-5),(1e-10,1e-10),(1e-15,1e-15),(1e-20,1e-20),(1e-50,1e-50),(1e-150,1e-150);
select * from t1;
f1 f2
10 10
100000 100000
1.23457e+09 1234567890
1e+10 10000000000
1e+15 1e+15
1e+20 1e+20
3.40282e+38 1e+50
3.40282e+38 1e+150
-10 -10
1e-05 1e-05
1e-10 1e-10
1e-15 1e-15
1e-20 1e-20
0 1e-50
0 1e-150
drop table t1;
create table t1 (datum double);
insert into t1 values (0.5),(1.0),(1.5),(2.0),(2.5);
select * from t1;
datum
0.5
1
1.5
2
2.5
select * from t1 where datum < 1.5;
datum
0.5
1
select * from t1 where datum > 1.5;
datum
2
2.5
select * from t1 where datum = 1.5;
datum
1.5
drop table t1;
create table t1 (a decimal(7,3) not null, key (a));
insert into t1 values ("0"),("-0.00"),("-0.01"),("-0.002"),("1");
select a from t1 order by a;
a
-0.010
-0.002
0.000
0.000
1.000
select min(a) from t1;
min(a)
-0.010
drop table t1;
create table t1 (c1 double, c2 varchar(20));
insert t1 values (121,"16");
select c1 + c1 * (c2 / 100) as col from t1;
col
140.36
create table t2 select c1 + c1 * (c2 / 100) as col1, round(c1, 5) as col2, round(c1, 35) as col3, sqrt(c1*1e-15) col4 from t1;
select * from t2;
col1 col2 col3 col4
140.36 121.00000 121 3.47850542618522e-07
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`col1` double DEFAULT NULL,
`col2` double(22,5) DEFAULT NULL,
`col3` double DEFAULT NULL,
`col4` double DEFAULT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
drop table t1,t2;
create table t1 (a float);
insert into t1 values (1);
select max(a),min(a),avg(a) from t1;
max(a) min(a) avg(a)
1 1 1
drop table t1;
create table t1 (f float, f2 float(24), f3 float(6,2), d double, d2 float(53), d3 double(10,3), de decimal, de2 decimal(6), de3 decimal(5,2), n numeric, n2 numeric(8), n3 numeric(7,6));
show full columns from t1;
Field Type Collation Null Key Default Extra Privileges Comment
f float NULL YES NULL #
f2 float NULL YES NULL #
f3 float(6,2) NULL YES NULL #
d double NULL YES NULL #
d2 double NULL YES NULL #
d3 double(10,3) NULL YES NULL #
de decimal(10,0) NULL YES NULL #
de2 decimal(6,0) NULL YES NULL #
de3 decimal(5,2) NULL YES NULL #
n decimal(10,0) NULL YES NULL #
n2 decimal(8,0) NULL YES NULL #
n3 decimal(7,6) NULL YES NULL #
drop table t1;
create table t1 (a decimal(7,3) not null, key (a));
insert into t1 values ("0"),("-0.00"),("-0.01"),("-0.002"),("1");
select a from t1 order by a;
a
-0.010
-0.002
0.000
0.000
1.000
select min(a) from t1;
min(a)
-0.010
drop table t1;
create table t1 (a float(200,100), b double(200,100));
ERROR 42000: Too big scale 100 specified for column 'a'. Maximum is 30.
create table t1 (c20 char);
insert into t1 values (5000.0);
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
insert into t1 values (0.5e4);
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
drop table t1;
create table t1 (f float(54));
ERROR 42000: Incorrect column specifier for column 'f'
drop table if exists t1;
create table t1 (d1 double, d2 double unsigned);
insert into t1 set d1 = -1.0;
update t1 set d2 = d1;
Warnings:
Warning 1264 Out of range value for column 'd2' at row 1
select * from t1;
d1 d2
-1 0
drop table t1;
create table t1 (f float(4,3));
insert into t1 values (-11.0),(-11),("-11"),(11.0),(11),("11");
Warnings:
Warning 1264 Out of range value for column 'f' at row 1
Warning 1264 Out of range value for column 'f' at row 2
Warning 1264 Out of range value for column 'f' at row 3
Warning 1264 Out of range value for column 'f' at row 4
Warning 1264 Out of range value for column 'f' at row 5
Warning 1264 Out of range value for column 'f' at row 6
select * from t1;
f
-9.999
-9.999
-9.999
9.999
9.999
9.999
drop table if exists t1;
create table t1 (f double(4,3));
insert into t1 values (-11.0),(-11),("-11"),(11.0),(11),("11");
Warnings:
Warning 1264 Out of range value for column 'f' at row 1
Warning 1264 Out of range value for column 'f' at row 2
Warning 1264 Out of range value for column 'f' at row 3
Warning 1264 Out of range value for column 'f' at row 4
Warning 1264 Out of range value for column 'f' at row 5
Warning 1264 Out of range value for column 'f' at row 6
select * from t1;
f
-9.999
-9.999
-9.999
9.999
9.999
9.999
drop table if exists t1;
create table t1 (c char(20));
insert into t1 values (5e-28);
select * from t1;
c
5e-28
drop table t1;
create table t1 (c char(6));
insert into t1 values (2e5),(2e6),(2e-4),(2e-5);
select * from t1;
c
200000
2e+06
0.0002
2e-05
drop table t1;
CREATE TABLE t1 (
reckey int unsigned NOT NULL,
recdesc varchar(50) NOT NULL,
PRIMARY KEY (reckey)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO t1 VALUES (108, 'Has 108 as key');
INSERT INTO t1 VALUES (109, 'Has 109 as key');
select * from t1 where reckey=108;
reckey recdesc
108 Has 108 as key
select * from t1 where reckey=1.08E2;
reckey recdesc
108 Has 108 as key
select * from t1 where reckey=109;
reckey recdesc
109 Has 109 as key
select * from t1 where reckey=1.09E2;
reckey recdesc
109 Has 109 as key
drop table t1;
create table t1 (d double(10,1));
create table t2 (d double(10,9));
insert into t1 values ("100000000.0");
insert into t2 values ("1.23456780");
create table t3 select * from t2 union select * from t1;
select * from t3;
d
1.2345678
100000000
show create table t3;
Table Create Table
t3 CREATE TABLE `t3` (
`d` double DEFAULT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
drop table t1, t2, t3;
create table t1 select 105213674794682365.00 + 0.0 x;
show warnings;
Level Code Message
desc t1;
Field Type Null Key Default Extra
x decimal(21,2) NO 0.00
drop table t1;
create table t1 select 0.0 x;
desc t1;
Field Type Null Key Default Extra
x decimal(2,1) NO 0.0
create table t2 select 105213674794682365.00 y;
desc t2;
Field Type Null Key Default Extra
y decimal(20,2) NO 0.00
create table t3 select x+y a from t1,t2;
show warnings;
Level Code Message
desc t3;
Field Type Null Key Default Extra
a decimal(21,2) NO 0.00
drop table t1,t2,t3;
select 1e-308, 1.00000001e-300, 100000000e-300;
1e-308 1.00000001e-300 100000000e-300
1e-308 1.00000001e-300 1e-292
select 10e307;
10e307
1e+308
create table t1(a int, b double(8, 2));
insert into t1 values
(1, 28.50), (1, 121.85), (1, 157.23), (1, 1351.00), (1, -1965.35), (1, 81.75),
(1, 217.08), (1, 7.94), (4, 96.07), (4, 6404.65), (4, -6500.72), (2, 100.00),
(5, 5.00), (5, -2104.80), (5, 2033.80), (5, 0.07), (5, 65.93),
(3, -4986.24), (3, 5.00), (3, 4857.34), (3, 123.74), (3, 0.16),
(6, -1695.31), (6, 1003.77), (6, 499.72), (6, 191.82);
explain select sum(b) s from t1 group by a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 26 Using temporary; Using filesort
select sum(b) s from t1 group by a;
s
0.00
100.00
0.00
-0.00
-0.00
0.00
select sum(b) s from t1 group by a having s <> 0;
s
100.00
select sum(b) s from t1 group by a having s <> 0 order by s;
s
100.00
select sum(b) s from t1 group by a having s <=> 0;
s
0.00
0.00
-0.00
-0.00
0.00
select sum(b) s from t1 group by a having s <=> 0 order by s;
s
-0.00
-0.00
0.00
0.00
0.00
alter table t1 add key (a, b);
explain select sum(b) s from t1 group by a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL a 14 NULL 26 Using index
select sum(b) s from t1 group by a;
s
0.00
100.00
0.00
-0.00
0.00
0.00
select sum(b) s from t1 group by a having s <> 0;
s
100.00
select sum(b) s from t1 group by a having s <> 0 order by s;
s
100.00
select sum(b) s from t1 group by a having s <=> 0;
s
0.00
0.00
-0.00
0.00
0.00
select sum(b) s from t1 group by a having s <=> 0 order by s;
s
-0.00
0.00
0.00
0.00
0.00
drop table t1;
End of 4.1 tests
create table t1 (s1 float(0,2));
ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column 's1').
create table t1 (s1 float(1,2));
ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column 's1').
CREATE TABLE t1 (
f1 real zerofill,
f2 double zerofill,
f3 float zerofill);
INSERT INTO t1 VALUES ( 0.314152e+1, 0.314152e+1, 0.314152e+1);
PREPARE stmt1 FROM 'select f1, f2, f3 FROM t1';
select f1, f2, f3 FROM t1;
f1 f2 f3
0000000000000003.14152 0000000000000003.14152 000003.14152
select f1, f2, f3 FROM t1;
f1 f2 f3
0000000000000003.14152 0000000000000003.14152 000003.14152
EXECUTE stmt1;
f1 f2 f3
0000000000000003.14152 0000000000000003.14152 000003.14152
DROP TABLE t1;
create table t1 (f1 double(200, 0));
insert into t1 values (1e199), (-1e199);
insert into t1 values (1e200), (-1e200);
insert into t1 values (2e200), (-2e200);
Warnings:
Warning 1264 Out of range value for column 'f1' at row 1
Warning 1264 Out of range value for column 'f1' at row 2
select f1 + 0e0 from t1;
f1 + 0e0
1e+199
-1e+199
1e+200
-1e+200
1e+200
-1e+200
drop table t1;
create table t1 (f1 float(30, 0));
insert into t1 values (1e29), (-1e29);
insert into t1 values (1e30), (-1e30);
insert into t1 values (2e30), (-2e30);
Warnings:
Warning 1264 Out of range value for column 'f1' at row 1
Warning 1264 Out of range value for column 'f1' at row 2
select f1 + 0e0 from t1;
f1 + 0e0
1.00000001504747e+29
-1.00000001504747e+29
1.00000001504747e+30
-1.00000001504747e+30
1.00000001504747e+30
-1.00000001504747e+30
drop table t1;
End of 5.0 tests
SET STORAGE_ENGINE='tokudb';
drop table if exists t1;
create table t1 (c nchar(10));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c` char(10) CHARACTER SET utf8 DEFAULT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
drop table t1;
create table t1 (c national char(10));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c` char(10) CHARACTER SET utf8 DEFAULT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
drop table t1;
create table t1 (c national varchar(10));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c` varchar(10) CHARACTER SET utf8 DEFAULT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
drop table t1;
create table t1 (c nvarchar(10));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c` varchar(10) CHARACTER SET utf8 DEFAULT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
drop table t1;
create table t1 (c nchar varchar(10));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c` varchar(10) CHARACTER SET utf8 DEFAULT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
drop table t1;
create table t1 (c national character varying(10));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c` varchar(10) CHARACTER SET utf8 DEFAULT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
drop table t1;
create table t1 (c nchar varying(10));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c` varchar(10) CHARACTER SET utf8 DEFAULT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
drop table t1;
SET STORAGE_ENGINE='tokudb';
drop table if exists t1;
select 1.1 IN (1.0, 1.2);
1.1 IN (1.0, 1.2)
0
select 1.1 IN (1.0, 1.2, 1.1, 1.4, 0.5);
1.1 IN (1.0, 1.2, 1.1, 1.4, 0.5)
1
select 1.1 IN (1.0, 1.2, NULL, 1.4, 0.5);
1.1 IN (1.0, 1.2, NULL, 1.4, 0.5)
NULL
select 0.5 IN (1.0, 1.2, NULL, 1.4, 0.5);
0.5 IN (1.0, 1.2, NULL, 1.4, 0.5)
1
select 1 IN (1.11, 1.2, 1.1, 1.4, 1, 0.5);
1 IN (1.11, 1.2, 1.1, 1.4, 1, 0.5)
1
select 1 IN (1.11, 1.2, 1.1, 1.4, NULL, 0.5);
1 IN (1.11, 1.2, 1.1, 1.4, NULL, 0.5)
NULL
select case 1.0 when 0.1 then "a" when 1.0 then "b" else "c" END;
case 1.0 when 0.1 then "a" when 1.0 then "b" else "c" END
b
select case 0.1 when 0.1 then "a" when 1.0 then "b" else "c" END;
case 0.1 when 0.1 then "a" when 1.0 then "b" else "c" END
a
select case 1 when 0.1 then "a" when 1.0 then "b" else "c" END;
case 1 when 0.1 then "a" when 1.0 then "b" else "c" END
b
select case 1.0 when 0.1 then "a" when 1 then "b" else "c" END;
case 1.0 when 0.1 then "a" when 1 then "b" else "c" END
b
select case 1.001 when 0.1 then "a" when 1 then "b" else "c" END;
case 1.001 when 0.1 then "a" when 1 then "b" else "c" END
c
create table t1 (a decimal(6,3));
insert into t1 values (1.0), (NULL), (0.1);
select * from t1;
a
1.000
NULL
0.100
select 0.1 in (1.0, 1.2, 1.1, a, 1.4, 0.5) from t1;
0.1 in (1.0, 1.2, 1.1, a, 1.4, 0.5)
0
NULL
1
drop table t1;
create table t1 select if(1, 1.1, 1.2), if(0, 1.1, 1.2), if(0.1, 1.1, 1.2), if(0, 1, 1.1), if(0, NULL, 1.2), if(1, 0.22e1, 1.1), if(1E0, 1.1, 1.2);
select * from t1;
if(1, 1.1, 1.2) if(0, 1.1, 1.2) if(0.1, 1.1, 1.2) if(0, 1, 1.1) if(0, NULL, 1.2) if(1, 0.22e1, 1.1) if(1E0, 1.1, 1.2)
1.1 1.2 1.1 1.1 1.2 2.2 1.1
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`if(1, 1.1, 1.2)` decimal(2,1) NOT NULL DEFAULT '0.0',
`if(0, 1.1, 1.2)` decimal(2,1) NOT NULL DEFAULT '0.0',
`if(0.1, 1.1, 1.2)` decimal(2,1) NOT NULL DEFAULT '0.0',
`if(0, 1, 1.1)` decimal(2,1) NOT NULL DEFAULT '0.0',
`if(0, NULL, 1.2)` decimal(2,1) DEFAULT NULL,
`if(1, 0.22e1, 1.1)` double NOT NULL DEFAULT '0',
`if(1E0, 1.1, 1.2)` decimal(2,1) NOT NULL DEFAULT '0.0'
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
drop table t1;
create table t1 select nullif(1.1, 1.1), nullif(1.1, 1.2), nullif(1.1, 0.11e1), nullif(1.0, 1), nullif(1, 1.0), nullif(1, 1.1);
select * from t1;
nullif(1.1, 1.1) nullif(1.1, 1.2) nullif(1.1, 0.11e1) nullif(1.0, 1) nullif(1, 1.0) nullif(1, 1.1)
NULL 1.1 NULL NULL NULL 1
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`nullif(1.1, 1.1)` decimal(2,1) DEFAULT NULL,
`nullif(1.1, 1.2)` decimal(2,1) DEFAULT NULL,
`nullif(1.1, 0.11e1)` decimal(2,1) DEFAULT NULL,
`nullif(1.0, 1)` decimal(2,1) DEFAULT NULL,
`nullif(1, 1.0)` int(1) DEFAULT NULL,
`nullif(1, 1.1)` int(1) DEFAULT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
drop table t1;
create table t1 (a decimal(4,2));
insert into t1 value (10000), (1.1e10), ("11111"), (100000.1);
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
Warning 1264 Out of range value for column 'a' at row 2
Warning 1264 Out of range value for column 'a' at row 3
Warning 1264 Out of range value for column 'a' at row 4
insert into t1 value (-10000), (-1.1e10), ("-11111"), (-100000.1);
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
Warning 1264 Out of range value for column 'a' at row 2
Warning 1264 Out of range value for column 'a' at row 3
Warning 1264 Out of range value for column 'a' at row 4
select a from t1;
a
99.99
99.99
99.99
99.99
-99.99
-99.99
-99.99
-99.99
drop table t1;
create table t1 (a decimal(4,2) unsigned);
insert into t1 value (10000), (1.1e10), ("11111"), (100000.1);
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
Warning 1264 Out of range value for column 'a' at row 2
Warning 1264 Out of range value for column 'a' at row 3
Warning 1264 Out of range value for column 'a' at row 4
insert into t1 value (-10000), (-1.1e10), ("-11111"), (-100000.1);
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
Warning 1264 Out of range value for column 'a' at row 2
Warning 1264 Out of range value for column 'a' at row 3
Warning 1264 Out of range value for column 'a' at row 4
select a from t1;
a
99.99
99.99
99.99
99.99
0.00
0.00
0.00
0.00
drop table t1;
create table t1 (a bigint);
insert into t1 values (18446744073709551615.0);
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
insert into t1 values (9223372036854775808.0);
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
insert into t1 values (-18446744073709551615.0);
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
select * from t1;
a
9223372036854775807
9223372036854775807
-9223372036854775808
drop table t1;
create table t1 (a bigint unsigned);
insert into t1 values (18446744073709551615.0);
insert into t1 values (9223372036854775808.0);
insert into t1 values (9999999999999999999999999.000);
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
insert into t1 values (-1.0);
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
select * from t1;
a
18446744073709551615
9223372036854775808
18446744073709551615
0
drop table t1;
create table t1 (a tinyint);
insert into t1 values (18446744073709551615.0);
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
Warning 1264 Out of range value for column 'a' at row 1
insert into t1 values (9223372036854775808.0);
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
Warning 1264 Out of range value for column 'a' at row 1
select * from t1;
a
127
127
drop table t1;
create table t1 select round(15.4,-1), truncate(-5678.123451,-3), abs(-1.1), -(-1.1);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`round(15.4,-1)` decimal(3,0) NOT NULL DEFAULT '0',
`truncate(-5678.123451,-3)` decimal(4,0) NOT NULL DEFAULT '0',
`abs(-1.1)` decimal(3,1) NOT NULL DEFAULT '0.0',
`-(-1.1)` decimal(2,1) NOT NULL DEFAULT '0.0'
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
drop table t1;
set session sql_mode='traditional';
select 1e10/0e0;
1e10/0e0
NULL
Warnings:
Error 1365 Division by 0
create table wl1612 (col1 int, col2 decimal(38,10), col3 numeric(38,10));
insert into wl1612 values(1,12345678901234567890.1234567890,12345678901234567890.1234567890);
select * from wl1612;
col1 col2 col3
1 12345678901234567890.1234567890 12345678901234567890.1234567890
insert into wl1612 values(2,01234567890123456789.0123456789,01234567890123456789.0123456789);
select * from wl1612 where col1=2;
col1 col2 col3
2 1234567890123456789.0123456789 1234567890123456789.0123456789
insert into wl1612 values(3,1234567890123456789012345678.0123456789,1234567890123456789012345678.0123456789);
select * from wl1612 where col1=3;
col1 col2 col3
3 1234567890123456789012345678.0123456789 1234567890123456789012345678.0123456789
select col1/0 from wl1612;
col1/0
NULL
NULL
NULL
Warnings:
Error 1365 Division by 0
Error 1365 Division by 0
Error 1365 Division by 0
select col2/0 from wl1612;
col2/0
NULL
NULL
NULL
Warnings:
Error 1365 Division by 0
Error 1365 Division by 0
Error 1365 Division by 0
select col3/0 from wl1612;
col3/0
NULL
NULL
NULL
Warnings:
Error 1365 Division by 0
Error 1365 Division by 0
Error 1365 Division by 0
insert into wl1612 values(5,5000.0005,5000.0005);
insert into wl1612 values(6,5000.0005,5000.0005);
select sum(col2),sum(col3) from wl1612;
sum(col2) sum(col3)
1234567903703703580370380357.1491481468 1234567903703703580370380357.1491481468
insert into wl1612 values(7,500000.000005,500000.000005);
insert into wl1612 values(8,500000.000005,500000.000005);
select sum(col2),sum(col3) from wl1612 where col1>4;
sum(col2) sum(col3)
1010000.0010100000 1010000.0010100000
insert into wl1612 (col1, col2) values(9,1.01234567891);
Warnings:
Note 1265 Data truncated for column 'col2' at row 1
insert into wl1612 (col1, col2) values(10,1.01234567894);
Warnings:
Note 1265 Data truncated for column 'col2' at row 1
insert into wl1612 (col1, col2) values(11,1.01234567895);
Warnings:
Note 1265 Data truncated for column 'col2' at row 1
insert into wl1612 (col1, col2) values(12,1.01234567896);
Warnings:
Note 1265 Data truncated for column 'col2' at row 1
select col1,col2 from wl1612 where col1>8;
col1 col2
9 1.0123456789
10 1.0123456789
11 1.0123456790
12 1.0123456790
insert into wl1612 (col1, col3) values(13,1.01234567891);
Warnings:
Note 1265 Data truncated for column 'col3' at row 1
insert into wl1612 (col1, col3) values(14,1.01234567894);
Warnings:
Note 1265 Data truncated for column 'col3' at row 1
insert into wl1612 (col1, col3) values(15,1.01234567895);
Warnings:
Note 1265 Data truncated for column 'col3' at row 1
insert into wl1612 (col1, col3) values(16,1.01234567896);
Warnings:
Note 1265 Data truncated for column 'col3' at row 1
select col1,col3 from wl1612 where col1>12;
col1 col3
13 1.0123456789
14 1.0123456789
15 1.0123456790
16 1.0123456790
select col1 from wl1612 where col1>4 and col2=1.01234567891;
col1
select col1 from wl1612 where col1>4 and col2=1.0123456789;
col1
9
10
select col1 from wl1612 where col1>4 and col2<>1.0123456789;
col1
5
6
7
8
11
12
select col1 from wl1612 where col1>4 and col2<1.0123456789;
col1
select col1 from wl1612 where col1>4 and col2<=1.0123456789;
col1
9
10
select col1 from wl1612 where col1>4 and col2>1.0123456789;
col1
5
6
7
8
11
12
select col1 from wl1612 where col1>4 and col2>=1.0123456789;
col1
5
6
7
8
9
10
11
12
select col1 from wl1612 where col1>4 and col2=1.012345679;
col1
11
12
select col1 from wl1612 where col1>4 and col2<>1.012345679;
col1
5
6
7
8
9
10
select col1 from wl1612 where col1>4 and col3=1.01234567891;
col1
select col1 from wl1612 where col1>4 and col3=1.0123456789;
col1
13
14
select col1 from wl1612 where col1>4 and col3<>1.0123456789;
col1
5
6
7
8
15
16
select col1 from wl1612 where col1>4 and col3<1.0123456789;
col1
select col1 from wl1612 where col1>4 and col3<=1.0123456789;
col1
13
14
select col1 from wl1612 where col1>4 and col3>1.0123456789;
col1
5
6
7
8
15
16
select col1 from wl1612 where col1>4 and col3>=1.0123456789;
col1
5
6
7
8
13
14
15
16
select col1 from wl1612 where col1>4 and col3=1.012345679;
col1
15
16
select col1 from wl1612 where col1>4 and col3<>1.012345679;
col1
5
6
7
8
13
14
drop table wl1612;
select 1/3;
1/3
0.3333
select 0.8=0.7+0.1;
0.8=0.7+0.1
1
select 0.7+0.1;
0.7+0.1
0.8
create table wl1612_1 (col1 int);
insert into wl1612_1 values(10);
select * from wl1612_1 where 0.8=0.7+0.1;
col1
10
select 0.07+0.07 from wl1612_1;
0.07+0.07
0.14
select 0.07-0.07 from wl1612_1;
0.07-0.07
0.00
select 0.07*0.07 from wl1612_1;
0.07*0.07
0.0049
select 0.07/0.07 from wl1612_1;
0.07/0.07
1.000000
drop table wl1612_1;
create table wl1612_2 (col1 decimal(10,2), col2 numeric(10,2));
insert into wl1612_2 values(1,1);
insert into wl1612_2 values(+1,+1);
insert into wl1612_2 values(+01,+01);
insert into wl1612_2 values(+001,+001);
select col1,count(*) from wl1612_2 group by col1;
col1 count(*)
1.00 4
select col2,count(*) from wl1612_2 group by col2;
col2 count(*)
1.00 4
drop table wl1612_2;
create table wl1612_3 (col1 decimal(10,2), col2 numeric(10,2));
insert into wl1612_3 values('1','1');
insert into wl1612_3 values('+1','+1');
insert into wl1612_3 values('+01','+01');
insert into wl1612_3 values('+001','+001');
select col1,count(*) from wl1612_3 group by col1;
col1 count(*)
1.00 4
select col2,count(*) from wl1612_3 group by col2;
col2 count(*)
1.00 4
drop table wl1612_3;
select mod(234,10) ;
mod(234,10)
4
select mod(234.567,10.555);
mod(234.567,10.555)
2.357
select mod(-234.567,10.555);
mod(-234.567,10.555)
-2.357
select mod(234.567,-10.555);
mod(234.567,-10.555)
2.357
select round(15.1);
round(15.1)
15
select round(15.4);
round(15.4)
15
select round(15.5);
round(15.5)
16
select round(15.6);
round(15.6)
16
select round(15.9);
round(15.9)
16
select round(-15.1);
round(-15.1)
-15
select round(-15.4);
round(-15.4)
-15
select round(-15.5);
round(-15.5)
-16
select round(-15.6);
round(-15.6)
-16
select round(-15.9);
round(-15.9)
-16
select round(15.1,1);
round(15.1,1)
15.1
select round(15.4,1);
round(15.4,1)
15.4
select round(15.5,1);
round(15.5,1)
15.5
select round(15.6,1);
round(15.6,1)
15.6
select round(15.9,1);
round(15.9,1)
15.9
select round(-15.1,1);
round(-15.1,1)
-15.1
select round(-15.4,1);
round(-15.4,1)
-15.4
select round(-15.5,1);
round(-15.5,1)
-15.5
select round(-15.6,1);
round(-15.6,1)
-15.6
select round(-15.9,1);
round(-15.9,1)
-15.9
select round(15.1,0);
round(15.1,0)
15
select round(15.4,0);
round(15.4,0)
15
select round(15.5,0);
round(15.5,0)
16
select round(15.6,0);
round(15.6,0)
16
select round(15.9,0);
round(15.9,0)
16
select round(-15.1,0);
round(-15.1,0)
-15
select round(-15.4,0);
round(-15.4,0)
-15
select round(-15.5,0);
round(-15.5,0)
-16
select round(-15.6,0);
round(-15.6,0)
-16
select round(-15.9,0);
round(-15.9,0)
-16
select round(15.1,-1);
round(15.1,-1)
20
select round(15.4,-1);
round(15.4,-1)
20
select round(15.5,-1);
round(15.5,-1)
20
select round(15.6,-1);
round(15.6,-1)
20
select round(15.9,-1);
round(15.9,-1)
20
select round(-15.1,-1);
round(-15.1,-1)
-20
select round(-15.4,-1);
round(-15.4,-1)
-20
select round(-15.5,-1);
round(-15.5,-1)
-20
select round(-15.6,-1);
round(-15.6,-1)
-20
select round(-15.91,-1);
round(-15.91,-1)
-20
select truncate(5678.123451,0);
truncate(5678.123451,0)
5678
select truncate(5678.123451,1);
truncate(5678.123451,1)
5678.1
select truncate(5678.123451,2);
truncate(5678.123451,2)
5678.12
select truncate(5678.123451,3);
truncate(5678.123451,3)
5678.123
select truncate(5678.123451,4);
truncate(5678.123451,4)
5678.1234
select truncate(5678.123451,5);
truncate(5678.123451,5)
5678.12345
select truncate(5678.123451,6);
truncate(5678.123451,6)
5678.123451
select truncate(5678.123451,-1);
truncate(5678.123451,-1)
5670
select truncate(5678.123451,-2);
truncate(5678.123451,-2)
5600
select truncate(5678.123451,-3);
truncate(5678.123451,-3)
5000
select truncate(5678.123451,-4);
truncate(5678.123451,-4)
0
select truncate(-5678.123451,0);
truncate(-5678.123451,0)
-5678
select truncate(-5678.123451,1);
truncate(-5678.123451,1)
-5678.1
select truncate(-5678.123451,2);
truncate(-5678.123451,2)
-5678.12
select truncate(-5678.123451,3);
truncate(-5678.123451,3)
-5678.123
select truncate(-5678.123451,4);
truncate(-5678.123451,4)
-5678.1234
select truncate(-5678.123451,5);
truncate(-5678.123451,5)
-5678.12345
select truncate(-5678.123451,6);
truncate(-5678.123451,6)
-5678.123451
select truncate(-5678.123451,-1);
truncate(-5678.123451,-1)
-5670
select truncate(-5678.123451,-2);
truncate(-5678.123451,-2)
-5600
select truncate(-5678.123451,-3);
truncate(-5678.123451,-3)
-5000
select truncate(-5678.123451,-4);
truncate(-5678.123451,-4)
0
create table wl1612_4 (col1 int, col2 decimal(30,25), col3 numeric(30,25));
insert into wl1612_4 values(1,0.0123456789012345678912345,0.0123456789012345678912345);
select col2/9999999999 from wl1612_4 where col1=1;
col2/9999999999
0.00000000000123456789024691358
select col3/9999999999 from wl1612_4 where col1=1;
col3/9999999999
0.00000000000123456789024691358
select 9999999999/col2 from wl1612_4 where col1=1;
9999999999/col2
810000007209.0001
select 9999999999/col3 from wl1612_4 where col1=1;
9999999999/col3
810000007209.0001
select col2*9999999999 from wl1612_4 where col1=1;
col2*9999999999
123456789.0000000000111104321087655
select col3*9999999999 from wl1612_4 where col1=1;
col3*9999999999
123456789.0000000000111104321087655
insert into wl1612_4 values(2,55555.0123456789012345678912345,55555.0123456789012345678912345);
select col2/9999999999 from wl1612_4 where col1=2;
col2/9999999999
0.00000555550123512344024696913
select col3/9999999999 from wl1612_4 where col1=2;
col3/9999999999
0.00000555550123512344024696913
select 9999999999/col2 from wl1612_4 where col1=2;
9999999999/col2
180001.7600
select 9999999999/col3 from wl1612_4 where col1=2;
9999999999/col3
180001.7600
select col2*9999999999 from wl1612_4 where col1=2;
col2*9999999999
555550123401234.0000000000111104321087655
select col3*9999999999 from wl1612_4 where col1=2;
col3*9999999999
555550123401234.0000000000111104321087655
drop table wl1612_4;
set sql_mode='';
select 23.4 + (-41.7), 23.4 - (41.7) = -18.3;
23.4 + (-41.7) 23.4 - (41.7) = -18.3
-18.3 1
select -18.3=-18.3;
-18.3=-18.3
1
select 18.3=18.3;
18.3=18.3
1
select -18.3=18.3;
-18.3=18.3
0
select 0.8 = 0.7 + 0.1;
0.8 = 0.7 + 0.1
1
drop table if exists t1;
Warnings:
Note 1051 Unknown table 't1'
create table t1 (col1 decimal(38));
insert into t1 values (12345678901234567890123456789012345678);
select * from t1;
col1
12345678901234567890123456789012345678
drop table t1;
create table t1 (col1 decimal(31,30));
insert into t1 values (0.00000000001);
select * from t1;
col1
0.000000000010000000000000000000
drop table t1;
select 7777777777777777777777777777777777777 * 10;
7777777777777777777777777777777777777 * 10
77777777777777777777777777777777777770
select .7777777777777777777777777777777777777 *
1000000000000000000;
.7777777777777777777777777777777777777 *
1000000000000000000
777777777777777777.777777777777777777700000000000
select .7777777777777777777777777777777777777 - 0.1;
.7777777777777777777777777777777777777 - 0.1
0.6777777777777777777777777777777777777
select .343434343434343434 + .343434343434343434;
.343434343434343434 + .343434343434343434
0.686868686868686868
select abs(9999999999999999999999);
abs(9999999999999999999999)
9999999999999999999999
select abs(-9999999999999999999999);
abs(-9999999999999999999999)
9999999999999999999999
select ceiling(999999999999999999);
ceiling(999999999999999999)
999999999999999999
select ceiling(99999999999999999999);
ceiling(99999999999999999999)
99999999999999999999
select ceiling(9.9999999999999999999);
ceiling(9.9999999999999999999)
10
select ceiling(-9.9999999999999999999);
ceiling(-9.9999999999999999999)
-9
select floor(999999999999999999);
floor(999999999999999999)
999999999999999999
select floor(9999999999999999999999);
floor(9999999999999999999999)
9999999999999999999999
select floor(9.999999999999999999999);
floor(9.999999999999999999999)
9
select floor(-9.999999999999999999999);
floor(-9.999999999999999999999)
-10
select floor(-999999999999999999999.999);
floor(-999999999999999999999.999)
-1000000000000000000000
select ceiling(999999999999999999999.999);
ceiling(999999999999999999999.999)
1000000000000000000000
select 99999999999999999999999999999999999999 mod 3;
99999999999999999999999999999999999999 mod 3
0
select round(99999999999999999.999);
round(99999999999999999.999)
100000000000000000
select round(-99999999999999999.999);
round(-99999999999999999.999)
-100000000000000000
select round(99999999999999999.999,3);
round(99999999999999999.999,3)
99999999999999999.999
select round(-99999999999999999.999,3);
round(-99999999999999999.999,3)
-99999999999999999.999
select truncate(99999999999999999999999999999999999999,31);
truncate(99999999999999999999999999999999999999,31)
99999999999999999999999999999999999999.000000000000000000000000000000
select truncate(99.999999999999999999999999999999999999,31);
truncate(99.999999999999999999999999999999999999,31)
99.999999999999999999999999999999
select truncate(99999999999999999999999999999999999999,-31);
truncate(99999999999999999999999999999999999999,-31)
99999990000000000000000000000000000000
create table t1 as select 0.5;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`0.5` decimal(2,1) NOT NULL DEFAULT '0.0'
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
drop table t1;
select round(1.5),round(2.5);
round(1.5) round(2.5)
2 3
select 0.07 * 0.07;
0.07 * 0.07
0.0049
set sql_mode='traditional';
select 1E-500 = 0;
1E-500 = 0
1
select 1 / 1E-500;
1 / 1E-500
NULL
Warnings:
Error 1365 Division by 0
select 1 / 0;
1 / 0
NULL
Warnings:
Error 1365 Division by 0
set sql_mode='ansi,traditional';
CREATE TABLE Sow6_2f (col1 NUMERIC(4,2));
INSERT INTO Sow6_2f VALUES (10.55);
INSERT INTO Sow6_2f VALUES (10.5555);
Warnings:
Note 1265 Data truncated for column 'col1' at row 1
INSERT INTO Sow6_2f VALUES (-10.55);
INSERT INTO Sow6_2f VALUES (-10.5555);
Warnings:
Note 1265 Data truncated for column 'col1' at row 1
INSERT INTO Sow6_2f VALUES (11);
INSERT INTO Sow6_2f VALUES (101.55);
ERROR 22003: Out of range value for column 'col1' at row 1
UPDATE Sow6_2f SET col1 = col1 * 50 WHERE col1 = 11;
ERROR 22003: Out of range value for column 'col1' at row 5
UPDATE Sow6_2f SET col1 = col1 / 0 WHERE col1 > 0;
ERROR 22012: Division by 0
SELECT MOD(col1,0) FROM Sow6_2f;
MOD(col1,0)
NULL
NULL
NULL
NULL
NULL
Warnings:
Error 1365 Division by 0
Error 1365 Division by 0
Error 1365 Division by 0
Error 1365 Division by 0
Error 1365 Division by 0
INSERT INTO Sow6_2f VALUES ('a59b');
ERROR HY000: Incorrect decimal value: 'a59b' for column 'col1' at row 1
drop table Sow6_2f;
select 10.3330000000000/12.34500000;
10.3330000000000/12.34500000
0.83701903604698258
set sql_mode='';
select 0/0;
0/0
NULL
select 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 as x;
x
99999999999999999999999999999999999999999999999999999999999999999
Warnings:
Error 1292 Truncated incorrect DECIMAL value: ''
select 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 + 1 as x;
x
100000000000000000000000000000000000000000000000000000000000000000
Warnings:
Error 1292 Truncated incorrect DECIMAL value: ''
select 0.190287977636363637 + 0.040372670 * 0 - 0;
0.190287977636363637 + 0.040372670 * 0 - 0
0.190287977636363637
select -0.123 * 0;
-0.123 * 0
0.000
CREATE TABLE t1 (f1 DECIMAL (12,9), f2 DECIMAL(2,2));
INSERT INTO t1 VALUES (10.5, 0);
UPDATE t1 SET f1 = 4.5;
SELECT * FROM t1;
f1 f2
4.500000000 0.00
DROP TABLE t1;
CREATE TABLE t1 (f1 DECIMAL (64,20), f2 DECIMAL(2,2));
INSERT INTO t1 VALUES (9999999999999999999999999999999999, 0);
SELECT * FROM t1;
f1 f2
9999999999999999999999999999999999.00000000000000000000 0.00
DROP TABLE t1;
select abs(10/0);
abs(10/0)
NULL
select abs(NULL);
abs(NULL)
NULL
set @@sql_mode='traditional';
create table t1( d1 decimal(18) unsigned, d2 decimal(20) unsigned, d3 decimal (22) unsigned);
insert into t1 values(1,-1,-1);
ERROR 22003: Out of range value for column 'd2' at row 1
drop table t1;
create table t1 (col1 decimal(5,2), col2 numeric(5,2));
insert into t1 values (999.999,999.999);
ERROR 22003: Out of range value for column 'col1' at row 1
insert into t1 values (-999.999,-999.999);
ERROR 22003: Out of range value for column 'col1' at row 1
select * from t1;
col1 col2
drop table t1;
set sql_mode='';
set @sav_dpi= @@div_precision_increment;
set @@div_precision_increment=15;
create table t1 (col1 int, col2 decimal(30,25), col3 numeric(30,25));
insert into t1 values (1,0.0123456789012345678912345,0.0123456789012345678912345);
select col2/9999999999 from t1 where col1=1;
col2/9999999999
0.000000000001234567890246913578
select 9999999999/col2 from t1 where col1=1;
9999999999/col2
810000007209.000065537105051
select 77777777/7777777;
77777777/7777777
10.000000900000090
drop table t1;
set div_precision_increment= @sav_dpi;
create table t1 (a decimal(4,2));
insert into t1 values (0.00);
select * from t1 where a > -0.00;
a
select * from t1 where a = -0.00;
a
0.00
drop table t1;
create table t1 (col1 bigint default -9223372036854775808);
insert into t1 values (default);
select * from t1;
col1
-9223372036854775808
drop table t1;
select cast('1.00000001335143196001808973960578441619873046875E-10' as decimal(30,15));
cast('1.00000001335143196001808973960578441619873046875E-10' as decimal(30,15))
0.000000000100000
select ln(14000) c1, convert(ln(14000),decimal(5,3)) c2, cast(ln(14000) as decimal(5,3)) c3;
c1 c2 c3
9.5468126085974 9.547 9.547
select convert(ln(14000),decimal(2,3)) c1;
ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column '').
select cast(ln(14000) as decimal(2,3)) c1;
ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column '').
create table t1 (sl decimal(70,30));
ERROR 42000: Too big precision 70 specified for column 'sl'. Maximum is 65.
create table t1 (sl decimal(32,31));
ERROR 42000: Too big scale 31 specified for column 'sl'. Maximum is 30.
create table t1 (sl decimal(0,38));
ERROR 42000: Too big scale 38 specified for column 'sl'. Maximum is 30.
create table t1 (sl decimal(0,30));
ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column 'sl').
create table t1 (sl decimal(5, 5));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`sl` decimal(5,5) DEFAULT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
drop table t1;
create table t1 (sl decimal(65, 30));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`sl` decimal(65,30) DEFAULT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
drop table t1;
create table t1 (
f1 decimal unsigned not null default 17.49,
f2 decimal unsigned not null default 17.68,
f3 decimal unsigned not null default 99.2,
f4 decimal unsigned not null default 99.7,
f5 decimal unsigned not null default 104.49,
f6 decimal unsigned not null default 199.91,
f7 decimal unsigned not null default 999.9,
f8 decimal unsigned not null default 9999.99);
Warnings:
Note 1265 Data truncated for column 'f1' at row 1
Note 1265 Data truncated for column 'f2' at row 1
Note 1265 Data truncated for column 'f3' at row 1
Note 1265 Data truncated for column 'f4' at row 1
Note 1265 Data truncated for column 'f5' at row 1
Note 1265 Data truncated for column 'f6' at row 1
Note 1265 Data truncated for column 'f7' at row 1
Note 1265 Data truncated for column 'f8' at row 1
insert into t1 (f1) values (1);
select * from t1;
f1 f2 f3 f4 f5 f6 f7 f8
1 18 99 100 104 200 1000 10000
drop table t1;
create table t1 (
f0 decimal (30,30) zerofill not null DEFAULT 0,
f1 decimal (0,0) zerofill not null default 0);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`f0` decimal(30,30) unsigned zerofill NOT NULL DEFAULT '0.000000000000000000000000000000',
`f1` decimal(10,0) unsigned zerofill NOT NULL DEFAULT '0000000000'
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
drop table t1;
drop procedure if exists wg2;
create procedure wg2()
begin
declare v int default 1;
declare tdec decimal(5) default 0;
while v <= 9 do set tdec =tdec * 10;
select v, tdec;
set v = v + 1;
end while;
end//
call wg2()//
v tdec
1 0
v tdec
2 0
v tdec
3 0
v tdec
4 0
v tdec
5 0
v tdec
6 0
v tdec
7 0
v tdec
8 0
v tdec
9 0
drop procedure wg2;
select cast(@non_existing_user_var/2 as DECIMAL);
cast(@non_existing_user_var/2 as DECIMAL)
NULL
create table t (d decimal(0,10));
ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column 'd').
CREATE TABLE t1 (
my_float FLOAT,
my_double DOUBLE,
my_varchar VARCHAR(50),
my_decimal DECIMAL(65,30)
);
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`my_float` float DEFAULT NULL,
`my_double` double DEFAULT NULL,
`my_varchar` varchar(50) DEFAULT NULL,
`my_decimal` decimal(65,30) DEFAULT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
INSERT INTO t1 SET my_float = 1.175494345e-32,
my_double = 1.175494345e-32,
my_varchar = '1.175494345e-32';
INSERT INTO t1 SET my_float = 1.175494345e-31,
my_double = 1.175494345e-31,
my_varchar = '1.175494345e-31';
INSERT INTO t1 SET my_float = 1.175494345e-30,
my_double = 1.175494345e-30,
my_varchar = '1.175494345e-30';
INSERT INTO t1 SET my_float = 1.175494345e-29,
my_double = 1.175494345e-29,
my_varchar = '1.175494345e-29';
INSERT INTO t1 SET my_float = 1.175494345e-28,
my_double = 1.175494345e-28,
my_varchar = '1.175494345e-28';
INSERT INTO t1 SET my_float = 1.175494345e-27,
my_double = 1.175494345e-27,
my_varchar = '1.175494345e-27';
INSERT INTO t1 SET my_float = 1.175494345e-26,
my_double = 1.175494345e-26,
my_varchar = '1.175494345e-26';
INSERT INTO t1 SET my_float = 1.175494345e-25,
my_double = 1.175494345e-25,
my_varchar = '1.175494345e-25';
INSERT INTO t1 SET my_float = 1.175494345e-24,
my_double = 1.175494345e-24,
my_varchar = '1.175494345e-24';
INSERT INTO t1 SET my_float = 1.175494345e-23,
my_double = 1.175494345e-23,
my_varchar = '1.175494345e-23';
INSERT INTO t1 SET my_float = 1.175494345e-22,
my_double = 1.175494345e-22,
my_varchar = '1.175494345e-22';
INSERT INTO t1 SET my_float = 1.175494345e-21,
my_double = 1.175494345e-21,
my_varchar = '1.175494345e-21';
INSERT INTO t1 SET my_float = 1.175494345e-20,
my_double = 1.175494345e-20,
my_varchar = '1.175494345e-20';
INSERT INTO t1 SET my_float = 1.175494345e-19,
my_double = 1.175494345e-19,
my_varchar = '1.175494345e-19';
INSERT INTO t1 SET my_float = 1.175494345e-18,
my_double = 1.175494345e-18,
my_varchar = '1.175494345e-18';
INSERT INTO t1 SET my_float = 1.175494345e-17,
my_double = 1.175494345e-17,
my_varchar = '1.175494345e-17';
INSERT INTO t1 SET my_float = 1.175494345e-16,
my_double = 1.175494345e-16,
my_varchar = '1.175494345e-16';
INSERT INTO t1 SET my_float = 1.175494345e-15,
my_double = 1.175494345e-15,
my_varchar = '1.175494345e-15';
INSERT INTO t1 SET my_float = 1.175494345e-14,
my_double = 1.175494345e-14,
my_varchar = '1.175494345e-14';
INSERT INTO t1 SET my_float = 1.175494345e-13,
my_double = 1.175494345e-13,
my_varchar = '1.175494345e-13';
INSERT INTO t1 SET my_float = 1.175494345e-12,
my_double = 1.175494345e-12,
my_varchar = '1.175494345e-12';
INSERT INTO t1 SET my_float = 1.175494345e-11,
my_double = 1.175494345e-11,
my_varchar = '1.175494345e-11';
INSERT INTO t1 SET my_float = 1.175494345e-10,
my_double = 1.175494345e-10,
my_varchar = '1.175494345e-10';
INSERT INTO t1 SET my_float = 1.175494345e-9,
my_double = 1.175494345e-9,
my_varchar = '1.175494345e-9';
INSERT INTO t1 SET my_float = 1.175494345e-8,
my_double = 1.175494345e-8,
my_varchar = '1.175494345e-8';
INSERT INTO t1 SET my_float = 1.175494345e-7,
my_double = 1.175494345e-7,
my_varchar = '1.175494345e-7';
INSERT INTO t1 SET my_float = 1.175494345e-6,
my_double = 1.175494345e-6,
my_varchar = '1.175494345e-6';
INSERT INTO t1 SET my_float = 1.175494345e-5,
my_double = 1.175494345e-5,
my_varchar = '1.175494345e-5';
INSERT INTO t1 SET my_float = 1.175494345e-4,
my_double = 1.175494345e-4,
my_varchar = '1.175494345e-4';
INSERT INTO t1 SET my_float = 1.175494345e-3,
my_double = 1.175494345e-3,
my_varchar = '1.175494345e-3';
INSERT INTO t1 SET my_float = 1.175494345e-2,
my_double = 1.175494345e-2,
my_varchar = '1.175494345e-2';
INSERT INTO t1 SET my_float = 1.175494345e-1,
my_double = 1.175494345e-1,
my_varchar = '1.175494345e-1';
SELECT my_float, my_double, my_varchar FROM t1;
my_float my_double my_varchar
1.17549e-32 1.175494345e-32 1.175494345e-32
1.17549e-31 1.175494345e-31 1.175494345e-31
1.17549e-30 1.175494345e-30 1.175494345e-30
1.17549e-29 1.175494345e-29 1.175494345e-29
1.17549e-28 1.175494345e-28 1.175494345e-28
1.17549e-27 1.175494345e-27 1.175494345e-27
1.17549e-26 1.175494345e-26 1.175494345e-26
1.17549e-25 1.175494345e-25 1.175494345e-25
1.17549e-24 1.175494345e-24 1.175494345e-24
1.17549e-23 1.175494345e-23 1.175494345e-23
1.17549e-22 1.175494345e-22 1.175494345e-22
1.17549e-21 1.175494345e-21 1.175494345e-21
1.17549e-20 1.175494345e-20 1.175494345e-20
1.17549e-19 1.175494345e-19 1.175494345e-19
1.17549e-18 1.175494345e-18 1.175494345e-18
1.17549e-17 1.175494345e-17 1.175494345e-17
1.17549e-16 1.175494345e-16 1.175494345e-16
1.17549e-15 1.175494345e-15 1.175494345e-15
1.17549e-14 1.175494345e-14 1.175494345e-14
1.17549e-13 1.175494345e-13 1.175494345e-13
1.17549e-12 1.175494345e-12 1.175494345e-12
1.17549e-11 1.175494345e-11 1.175494345e-11
1.17549e-10 1.175494345e-10 1.175494345e-10
1.17549e-09 1.175494345e-09 1.175494345e-9
1.17549e-08 1.175494345e-08 1.175494345e-8
1.17549e-07 1.175494345e-07 1.175494345e-7
1.17549e-06 1.175494345e-06 1.175494345e-6
1.17549e-05 1.175494345e-05 1.175494345e-5
0.000117549 0.0001175494345 1.175494345e-4
0.00117549 0.001175494345 1.175494345e-3
0.0117549 0.01175494345 1.175494345e-2
0.117549 0.1175494345 1.175494345e-1
SELECT CAST(my_float AS DECIMAL(65,30)), my_float FROM t1;
CAST(my_float AS DECIMAL(65,30)) my_float
0.000000000000000000000000000000 1.17549e-32
0.000000000000000000000000000000 1.17549e-31
0.000000000000000000000000000001 1.17549e-30
0.000000000000000000000000000012 1.17549e-29
0.000000000000000000000000000118 1.17549e-28
0.000000000000000000000000001175 1.17549e-27
0.000000000000000000000000011755 1.17549e-26
0.000000000000000000000000117549 1.17549e-25
0.000000000000000000000001175494 1.17549e-24
0.000000000000000000000011754943 1.17549e-23
0.000000000000000000000117549438 1.17549e-22
0.000000000000000000001175494332 1.17549e-21
0.000000000000000000011754943324 1.17549e-20
0.000000000000000000117549434853 1.17549e-19
0.000000000000000001175494374380 1.17549e-18
0.000000000000000011754943743802 1.17549e-17
0.000000000000000117549432474939 1.17549e-16
0.000000000000001175494324749389 1.17549e-15
0.000000000000011754943671010360 1.17549e-14
0.000000000000117549429933840000 1.17549e-13
0.000000000001175494380653563000 1.17549e-12
0.000000000011754943372854760000 1.17549e-11
0.000000000117549428524377200000 1.17549e-10
0.000000001175494368510499000000 1.17549e-09
0.000000011754943685104990000000 1.17549e-08
0.000000117549433298336200000000 1.17549e-07
0.000001175494389826781000000000 1.17549e-06
0.000011754943443520460000000000 1.17549e-05
0.000117549432616215200000000000 0.000117549
0.001175494398921728000000000000 0.00117549
0.011754943057894710000000000000 0.0117549
0.117549434304237400000000000000 0.117549
SELECT CAST(my_double AS DECIMAL(65,30)), my_double FROM t1;
CAST(my_double AS DECIMAL(65,30)) my_double
0.000000000000000000000000000000 1.175494345e-32
0.000000000000000000000000000000 1.175494345e-31
0.000000000000000000000000000001 1.175494345e-30
0.000000000000000000000000000012 1.175494345e-29
0.000000000000000000000000000118 1.175494345e-28
0.000000000000000000000000001175 1.175494345e-27
0.000000000000000000000000011755 1.175494345e-26
0.000000000000000000000000117549 1.175494345e-25
0.000000000000000000000001175494 1.175494345e-24
0.000000000000000000000011754943 1.175494345e-23
0.000000000000000000000117549435 1.175494345e-22
0.000000000000000000001175494345 1.175494345e-21
0.000000000000000000011754943450 1.175494345e-20
0.000000000000000000117549434500 1.175494345e-19
0.000000000000000001175494345000 1.175494345e-18
0.000000000000000011754943450000 1.175494345e-17
0.000000000000000117549434500000 1.175494345e-16
0.000000000000001175494345000000 1.175494345e-15
0.000000000000011754943450000000 1.175494345e-14
0.000000000000117549434500000000 1.175494345e-13
0.000000000001175494345000000000 1.175494345e-12
0.000000000011754943450000000000 1.175494345e-11
0.000000000117549434500000000000 1.175494345e-10
0.000000001175494345000000000000 1.175494345e-09
0.000000011754943450000000000000 1.175494345e-08
0.000000117549434500000000000000 1.175494345e-07
0.000001175494345000000000000000 1.175494345e-06
0.000011754943450000000000000000 1.175494345e-05
0.000117549434500000000000000000 0.0001175494345
0.001175494345000000000000000000 0.001175494345
0.011754943450000000000000000000 0.01175494345
0.117549434500000000000000000000 0.1175494345
SELECT CAST(my_varchar AS DECIMAL(65,30)), my_varchar FROM t1;
CAST(my_varchar AS DECIMAL(65,30)) my_varchar
0.000000000000000000000000000000 1.175494345e-32
0.000000000000000000000000000000 1.175494345e-31
0.000000000000000000000000000001 1.175494345e-30
0.000000000000000000000000000012 1.175494345e-29
0.000000000000000000000000000118 1.175494345e-28
0.000000000000000000000000001175 1.175494345e-27
0.000000000000000000000000011755 1.175494345e-26
0.000000000000000000000000117549 1.175494345e-25
0.000000000000000000000001175494 1.175494345e-24
0.000000000000000000000011754943 1.175494345e-23
0.000000000000000000000117549435 1.175494345e-22
0.000000000000000000001175494345 1.175494345e-21
0.000000000000000000011754943450 1.175494345e-20
0.000000000000000000117549434500 1.175494345e-19
0.000000000000000001175494345000 1.175494345e-18
0.000000000000000011754943450000 1.175494345e-17
0.000000000000000117549434500000 1.175494345e-16
0.000000000000001175494345000000 1.175494345e-15
0.000000000000011754943450000000 1.175494345e-14
0.000000000000117549434500000000 1.175494345e-13
0.000000000001175494345000000000 1.175494345e-12
0.000000000011754943450000000000 1.175494345e-11
0.000000000117549434500000000000 1.175494345e-10
0.000000001175494345000000000000 1.175494345e-9
0.000000011754943450000000000000 1.175494345e-8
0.000000117549434500000000000000 1.175494345e-7
0.000001175494345000000000000000 1.175494345e-6
0.000011754943450000000000000000 1.175494345e-5
0.000117549434500000000000000000 1.175494345e-4
0.001175494345000000000000000000 1.175494345e-3
0.011754943450000000000000000000 1.175494345e-2
0.117549434500000000000000000000 1.175494345e-1
UPDATE t1 SET my_decimal = my_float;
SELECT my_decimal, my_float FROM t1;
my_decimal my_float
0.000000000000000000000000000000 1.17549e-32
0.000000000000000000000000000000 1.17549e-31
0.000000000000000000000000000001 1.17549e-30
0.000000000000000000000000000012 1.17549e-29
0.000000000000000000000000000118 1.17549e-28
0.000000000000000000000000001175 1.17549e-27
0.000000000000000000000000011755 1.17549e-26
0.000000000000000000000000117549 1.17549e-25
0.000000000000000000000001175494 1.17549e-24
0.000000000000000000000011754943 1.17549e-23
0.000000000000000000000117549438 1.17549e-22
0.000000000000000000001175494332 1.17549e-21
0.000000000000000000011754943324 1.17549e-20
0.000000000000000000117549434853 1.17549e-19
0.000000000000000001175494374380 1.17549e-18
0.000000000000000011754943743802 1.17549e-17
0.000000000000000117549432474939 1.17549e-16
0.000000000000001175494324749389 1.17549e-15
0.000000000000011754943671010360 1.17549e-14
0.000000000000117549429933840000 1.17549e-13
0.000000000001175494380653563000 1.17549e-12
0.000000000011754943372854760000 1.17549e-11
0.000000000117549428524377200000 1.17549e-10
0.000000001175494368510499000000 1.17549e-09
0.000000011754943685104990000000 1.17549e-08
0.000000117549433298336200000000 1.17549e-07
0.000001175494389826781000000000 1.17549e-06
0.000011754943443520460000000000 1.17549e-05
0.000117549432616215200000000000 0.000117549
0.001175494398921728000000000000 0.00117549
0.011754943057894710000000000000 0.0117549
0.117549434304237400000000000000 0.117549
UPDATE t1 SET my_decimal = my_double;
SELECT my_decimal, my_double FROM t1;
my_decimal my_double
0.000000000000000000000000000000 1.175494345e-32
0.000000000000000000000000000000 1.175494345e-31
0.000000000000000000000000000001 1.175494345e-30
0.000000000000000000000000000012 1.175494345e-29
0.000000000000000000000000000118 1.175494345e-28
0.000000000000000000000000001175 1.175494345e-27
0.000000000000000000000000011755 1.175494345e-26
0.000000000000000000000000117549 1.175494345e-25
0.000000000000000000000001175494 1.175494345e-24
0.000000000000000000000011754943 1.175494345e-23
0.000000000000000000000117549435 1.175494345e-22
0.000000000000000000001175494345 1.175494345e-21
0.000000000000000000011754943450 1.175494345e-20
0.000000000000000000117549434500 1.175494345e-19
0.000000000000000001175494345000 1.175494345e-18
0.000000000000000011754943450000 1.175494345e-17
0.000000000000000117549434500000 1.175494345e-16
0.000000000000001175494345000000 1.175494345e-15
0.000000000000011754943450000000 1.175494345e-14
0.000000000000117549434500000000 1.175494345e-13
0.000000000001175494345000000000 1.175494345e-12
0.000000000011754943450000000000 1.175494345e-11
0.000000000117549434500000000000 1.175494345e-10
0.000000001175494345000000000000 1.175494345e-09
0.000000011754943450000000000000 1.175494345e-08
0.000000117549434500000000000000 1.175494345e-07
0.000001175494345000000000000000 1.175494345e-06
0.000011754943450000000000000000 1.175494345e-05
0.000117549434500000000000000000 0.0001175494345
0.001175494345000000000000000000 0.001175494345
0.011754943450000000000000000000 0.01175494345
0.117549434500000000000000000000 0.1175494345
UPDATE t1 SET my_decimal = my_varchar;
Warnings:
Note 1265 Data truncated for column 'my_decimal' at row 1
Note 1265 Data truncated for column 'my_decimal' at row 2
Note 1265 Data truncated for column 'my_decimal' at row 3
Note 1265 Data truncated for column 'my_decimal' at row 4
Note 1265 Data truncated for column 'my_decimal' at row 5
Note 1265 Data truncated for column 'my_decimal' at row 6
Note 1265 Data truncated for column 'my_decimal' at row 7
Note 1265 Data truncated for column 'my_decimal' at row 8
Note 1265 Data truncated for column 'my_decimal' at row 9
Note 1265 Data truncated for column 'my_decimal' at row 10
Note 1265 Data truncated for column 'my_decimal' at row 11
SELECT my_decimal, my_varchar FROM t1;
my_decimal my_varchar
0.000000000000000000000000000000 1.175494345e-32
0.000000000000000000000000000000 1.175494345e-31
0.000000000000000000000000000001 1.175494345e-30
0.000000000000000000000000000012 1.175494345e-29
0.000000000000000000000000000118 1.175494345e-28
0.000000000000000000000000001175 1.175494345e-27
0.000000000000000000000000011755 1.175494345e-26
0.000000000000000000000000117549 1.175494345e-25
0.000000000000000000000001175494 1.175494345e-24
0.000000000000000000000011754943 1.175494345e-23
0.000000000000000000000117549435 1.175494345e-22
0.000000000000000000001175494345 1.175494345e-21
0.000000000000000000011754943450 1.175494345e-20
0.000000000000000000117549434500 1.175494345e-19
0.000000000000000001175494345000 1.175494345e-18
0.000000000000000011754943450000 1.175494345e-17
0.000000000000000117549434500000 1.175494345e-16
0.000000000000001175494345000000 1.175494345e-15
0.000000000000011754943450000000 1.175494345e-14
0.000000000000117549434500000000 1.175494345e-13
0.000000000001175494345000000000 1.175494345e-12
0.000000000011754943450000000000 1.175494345e-11
0.000000000117549434500000000000 1.175494345e-10
0.000000001175494345000000000000 1.175494345e-9
0.000000011754943450000000000000 1.175494345e-8
0.000000117549434500000000000000 1.175494345e-7
0.000001175494345000000000000000 1.175494345e-6
0.000011754943450000000000000000 1.175494345e-5
0.000117549434500000000000000000 1.175494345e-4
0.001175494345000000000000000000 1.175494345e-3
0.011754943450000000000000000000 1.175494345e-2
0.117549434500000000000000000000 1.175494345e-1
DROP TABLE t1;
create table t1 (c1 decimal(64));
insert into t1 values(
89000000000000000000000000000000000000000000000000000000000000000000000000000000000000000);
Warnings:
Error 1292 Truncated incorrect DECIMAL value: ''
Warning 1264 Out of range value for column 'c1' at row 1
insert into t1 values(
99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 *
99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999);
Warnings:
Error 1292 Truncated incorrect DECIMAL value: ''
Error 1292 Truncated incorrect DECIMAL value: ''
Error 1292 Truncated incorrect DECIMAL value: ''
Warning 1264 Out of range value for column 'c1' at row 1
insert into t1 values(1e100);
Warnings:
Warning 1264 Out of range value for column 'c1' at row 1
select * from t1;
c1
9999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999
drop table t1;
create table t1(a decimal(7,2));
insert into t1 values(123.12);
select * from t1;
a
123.12
alter table t1 modify a decimal(10,2);
select * from t1;
a
123.12
drop table t1;
create table t1 (i int, j int);
insert into t1 values (1,1), (1,2), (2,3), (2,4);
select i, count(distinct j) from t1 group by i;
i count(distinct j)
1 2
2 2
select i+0.0 as i2, count(distinct j) from t1 group by i2;
i2 count(distinct j)
1.0 2
2.0 2
drop table t1;
create table t1(f1 decimal(20,6));
insert into t1 values (CAST('10:11:12' AS date) + interval 14 microsecond);
insert into t1 values (CAST('10:11:12' AS time));
select * from t1;
f1
20101112000000.000014
101112.000000
drop table t1;
select cast(19999999999999999999 as unsigned);
cast(19999999999999999999 as unsigned)
18446744073709551615
Warnings:
Error 1292 Truncated incorrect DECIMAL value: ''
create table t1(a decimal(18));
insert into t1 values(123456789012345678);
alter table t1 modify column a decimal(19);
select * from t1;
a
123456789012345678
drop table t1;
select cast(11.1234 as DECIMAL(3,2));
cast(11.1234 as DECIMAL(3,2))
9.99
Warnings:
Error 1264 Out of range value for column 'cast(11.1234 as DECIMAL(3,2))' at row 1
select * from (select cast(11.1234 as DECIMAL(3,2))) t;
cast(11.1234 as DECIMAL(3,2))
9.99
Warnings:
Error 1264 Out of range value for column 'cast(11.1234 as DECIMAL(3,2))' at row 1
select cast(a as DECIMAL(3,2))
from (select 11.1233 as a
UNION select 11.1234
UNION select 12.1234
) t;
cast(a as DECIMAL(3,2))
9.99
9.99
9.99
Warnings:
Error 1264 Out of range value for column 'cast(a as DECIMAL(3,2))' at row 1
Error 1264 Out of range value for column 'cast(a as DECIMAL(3,2))' at row 1
Error 1264 Out of range value for column 'cast(a as DECIMAL(3,2))' at row 1
select cast(a as DECIMAL(3,2)), count(*)
from (select 11.1233 as a
UNION select 11.1234
UNION select 12.1234
) t group by 1;
cast(a as DECIMAL(3,2)) count(*)
9.99 3
Warnings:
Error 1264 Out of range value for column 'cast(a as DECIMAL(3,2))' at row 1
Error 1264 Out of range value for column 'cast(a as DECIMAL(3,2))' at row 1
Error 1264 Out of range value for column 'cast(a as DECIMAL(3,2))' at row 1
Error 1264 Out of range value for column 'cast(a as DECIMAL(3,2))' at row 1
create table t1 (s varchar(100));
insert into t1 values (0.00000000010000000000000000364321973154977415791655470655996396089904010295867919921875);
drop table t1;
SELECT 1.000000000000 * 99.999999999998 / 100 a,1.000000000000 * (99.999999999998 / 100) b;
a b
0.9999999999999800000000000000 0.9999999999999800000000000000
SELECT CAST(1 AS decimal(65,10));
CAST(1 AS decimal(65,10))
1.0000000000
SELECT CAST(1 AS decimal(66,10));
ERROR 42000: Too big precision 66 specified for column '1'. Maximum is 65.
SELECT CAST(1 AS decimal(65,30));
CAST(1 AS decimal(65,30))
1.000000000000000000000000000000
SELECT CAST(1 AS decimal(65,31));
ERROR 42000: Too big scale 31 specified for column '1'. Maximum is 30.
CREATE TABLE t1 (a int DEFAULT NULL, b int DEFAULT NULL);
INSERT INTO t1 VALUES (3,30), (1,10), (2,10);
SELECT a+CAST(1 AS decimal(65,30)) AS aa, SUM(b) FROM t1 GROUP BY aa;
aa SUM(b)
2.000000000000000000000000000000 10
3.000000000000000000000000000000 10
4.000000000000000000000000000000 30
SELECT a+CAST(1 AS decimal(65,31)) AS aa, SUM(b) FROM t1 GROUP BY aa;
ERROR 42000: Too big scale 31 specified for column '1'. Maximum is 30.
DROP TABLE t1;
CREATE TABLE t1 (a int DEFAULT NULL, b int DEFAULT NULL);
INSERT INTO t1 VALUES (3,30), (1,10), (2,10);
SET @a= CAST(1 AS decimal);
SELECT 1 FROM t1 GROUP BY @b := @a, @b;
1
1
1
DROP TABLE t1;
CREATE TABLE t1 SELECT 0.123456789012345678901234567890123456 AS f1;
Warnings:
Note 1265 Data truncated for column 'f1' at row 1
DESC t1;
Field Type Null Key Default Extra
f1 decimal(31,30) NO 0.000000000000000000000000000000
SELECT f1 FROM t1;
f1
0.123456789012345678901234567890
DROP TABLE t1;
CREATE TABLE t1 SELECT 123451234512345123451234512345123451234512345.678906789067890678906789067890678906789067890 AS f1;
Warnings:
Warning 1264 Out of range value for column 'f1' at row 1
DESC t1;
Field Type Null Key Default Extra
f1 decimal(65,30) NO 0.000000000000000000000000000000
SELECT f1 FROM t1;
f1
99999999999999999999999999999999999.999999999999999999999999999999
DROP TABLE t1;
End of 5.0 tests
select cast(143.481 as decimal(4,1));
cast(143.481 as decimal(4,1))
143.5
select cast(143.481 as decimal(4,0));
cast(143.481 as decimal(4,0))
143
select cast(143.481 as decimal(2,1));
cast(143.481 as decimal(2,1))
9.9
Warnings:
Error 1264 Out of range value for column 'cast(143.481 as decimal(2,1))' at row 1
select cast(-3.4 as decimal(2,1));
cast(-3.4 as decimal(2,1))
-3.4
select cast(99.6 as decimal(2,0));
cast(99.6 as decimal(2,0))
99
Warnings:
Error 1264 Out of range value for column 'cast(99.6 as decimal(2,0))' at row 1
select cast(-13.4 as decimal(2,1));
cast(-13.4 as decimal(2,1))
-9.9
Warnings:
Error 1264 Out of range value for column 'cast(-13.4 as decimal(2,1))' at row 1
select cast(98.6 as decimal(2,0));
cast(98.6 as decimal(2,0))
99
SET STORAGE_ENGINE='tokudb';
drop table if exists t1;
create table t1 (a set (' ','a','b') not null);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` set('','a','b') NOT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
drop table t1;
create table t1 (a set (' ','a','b ') not null default 'b ');
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` set('','a','b') NOT NULL DEFAULT 'b'
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
drop table t1;
CREATE TABLE t1 ( user varchar(64) NOT NULL default '', path varchar(255) NOT NULL default '', privilege set('select','RESERVED30','RESERVED29','RESERVED28','RESERVED27','RESERVED26', 'RESERVED25','RESERVED24','data.delete','RESERVED22','RESERVED21', 'RESERVED20','data.insert.none','data.insert.approve', 'data.insert.delete','data.insert.move','data.insert.propose', 'data.insert.reject','RESERVED13','RESERVED12','RESERVED11','RESERVED10', 'RESERVED09','data.update','RESERVED07','RESERVED06','RESERVED05', 'RESERVED04','metadata.delete','metadata.put','RESERVED01','RESERVED00') NOT NULL default '', KEY user (user) ) ENGINE=MyISAM CHARSET=utf8;
DROP TABLE t1;
set names latin1;
create table t1 (s set ('a','A') character set latin1 collate latin1_bin);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`s` set('a','A') CHARACTER SET latin1 COLLATE latin1_bin DEFAULT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
insert into t1 values ('a'),('a,A'),('A,a'),('A');
select s from t1 order by s;
s
a
A
a,A
a,A
select s from t1 order by concat(s);
s
A
a
a,A
a,A
drop table t1;
CREATE TABLE t1 (c set('ae','oe','ue','ss') collate latin1_german2_ci);
INSERT INTO t1 VALUES (''),(''),(''),('');
INSERT INTO t1 VALUES ('ae'),('oe'),('ue'),('ss');
INSERT INTO t1 VALUES (',,,');
INSERT INTO t1 VALUES ('ae,oe,ue,ss');
SELECT c FROM t1 ORDER BY c;
c
ae
ae
oe
oe
ue
ue
ss
ss
ae,oe,ue,ss
ae,oe,ue,ss
SELECT c FROM t1 ORDER BY concat(c);
c
ae
ae
ae,oe,ue,ss
ae,oe,ue,ss
oe
oe
ss
ss
ue
ue
DROP TABLE t1;
create table t1(f1
set('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17',
'18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33',
'34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49',
'50','51','52','53','54','55','56','57','58','59','60','61','62','63','64','128'));
ERROR HY000: Too many strings for column f1 and SET
create table t1(f1
set('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17',
'18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33',
'34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49',
'50','51','52','53','54','55','56','57','58','59','60','61','62','63','64','1'));
Warnings:
Note 1291 Column 'f1' has duplicated value '1' in SET
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`f1` set('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50','51','52','53','54','55','56','57','58','59','60','61','62','63','64','1') DEFAULT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
drop table t1;
SET STORAGE_ENGINE='tokudb';
drop table if exists t1;
create table t1 (t time);
insert into t1 values("10:22:33"),("12:34:56.78"),(10),(1234),(123456.78),(1234559.99),("1"),("1:23"),("1:23:45"), ("10.22"), ("-10 1:22:33.45"),("20 10:22:33"),("1999-02-03 20:33:34");
insert t1 values (30),(1230),("1230"),("12:30"),("12:30:35"),("1 12:30:31.32");
select * from t1;
t
10:22:33
12:34:56
00:00:10
00:12:34
12:34:56
123:45:59
00:00:01
01:23:00
01:23:45
00:00:10
-241:22:33
490:22:33
20:33:34
00:00:30
00:12:30
00:12:30
12:30:00
12:30:35
36:30:31
insert into t1 values("10.22.22"),(1234567),(123456789),(123456789.10),("10 22:22"),("12.45a");
Warnings:
Warning 1265 Data truncated for column 't' at row 1
Warning 1264 Out of range value for column 't' at row 2
Warning 1264 Out of range value for column 't' at row 3
Warning 1264 Out of range value for column 't' at row 4
Warning 1265 Data truncated for column 't' at row 6
select * from t1;
t
10:22:33
12:34:56
00:00:10
00:12:34
12:34:56
123:45:59
00:00:01
01:23:00
01:23:45
00:00:10
-241:22:33
490:22:33
20:33:34
00:00:30
00:12:30
00:12:30
12:30:00
12:30:35
36:30:31
00:00:10
00:00:00
838:59:59
838:59:59
262:22:00
00:00:12
drop table t1;
create table t1 (t time);
insert into t1 values ('09:00:00'),('13:00:00'),('19:38:34'), ('13:00:00'),('09:00:00'),('09:00:00'),('13:00:00'),('13:00:00'),('13:00:00'),('09:00:00');
select t, time_to_sec(t),sec_to_time(time_to_sec(t)) from t1;
t time_to_sec(t) sec_to_time(time_to_sec(t))
09:00:00 32400 09:00:00
13:00:00 46800 13:00:00
19:38:34 70714 19:38:34
13:00:00 46800 13:00:00
09:00:00 32400 09:00:00
09:00:00 32400 09:00:00
13:00:00 46800 13:00:00
13:00:00 46800 13:00:00
13:00:00 46800 13:00:00
09:00:00 32400 09:00:00
select sec_to_time(time_to_sec(t)) from t1;
sec_to_time(time_to_sec(t))
09:00:00
13:00:00
19:38:34
13:00:00
09:00:00
09:00:00
13:00:00
13:00:00
13:00:00
09:00:00
drop table t1;
select cast('100:55:50' as time) < cast('24:00:00' as time);
cast('100:55:50' as time) < cast('24:00:00' as time)
0
select cast('100:55:50' as time) < cast('024:00:00' as time);
cast('100:55:50' as time) < cast('024:00:00' as time)
0
select cast('300:55:50' as time) < cast('240:00:00' as time);
cast('300:55:50' as time) < cast('240:00:00' as time)
0
select cast('100:55:50' as time) > cast('24:00:00' as time);
cast('100:55:50' as time) > cast('24:00:00' as time)
1
select cast('100:55:50' as time) > cast('024:00:00' as time);
cast('100:55:50' as time) > cast('024:00:00' as time)
1
select cast('300:55:50' as time) > cast('240:00:00' as time);
cast('300:55:50' as time) > cast('240:00:00' as time)
1
create table t1 (f1 time);
insert into t1 values ('24:00:00');
select cast('24:00:00' as time) = (select f1 from t1);
cast('24:00:00' as time) = (select f1 from t1)
1
drop table t1;
create table t1(f1 time, f2 time);
insert into t1 values('20:00:00','150:00:00');
select 1 from t1 where cast('100:00:00' as time) between f1 and f2;
1
1
drop table t1;
CREATE TABLE t1 (
f2 date NOT NULL,
f3 int(11) unsigned NOT NULL default '0',
PRIMARY KEY (f3, f2)
);
insert into t1 values('2007-07-01', 1);
insert into t1 values('2007-07-01', 2);
insert into t1 values('2007-07-02', 1);
insert into t1 values('2007-07-02', 2);
SELECT sum(f3) FROM t1 where f2='2007-07-01 00:00:00' group by f2;
sum(f3)
3
drop table t1;
SET STORAGE_ENGINE='tokudb';
drop table if exists t1,t2;
set time_zone="+03:00";
CREATE TABLE t1 (a int, t timestamp);
CREATE TABLE t2 (a int, t datetime);
SET TIMESTAMP=1234;
insert into t1 values(1,NULL);
insert into t1 values(2,"2002-03-03");
SET TIMESTAMP=1235;
insert into t1 values(3,NULL);
SET TIMESTAMP=1236;
insert into t1 (a) values(4);
insert into t2 values(5,"2002-03-04"),(6,NULL),(7,"2002-03-05"),(8,"00-00-00");
SET TIMESTAMP=1237;
insert into t1 select * from t2;
SET TIMESTAMP=1238;
insert into t1 (a) select a+1 from t2 where a=8;
select * from t1;
a t
1 1970-01-01 03:20:34
2 2002-03-03 00:00:00
3 1970-01-01 03:20:35
4 1970-01-01 03:20:36
5 2002-03-04 00:00:00
6 1970-01-01 03:20:37
7 2002-03-05 00:00:00
8 0000-00-00 00:00:00
9 1970-01-01 03:20:38
drop table t1,t2;
SET TIMESTAMP=1234;
CREATE TABLE t1 (value TEXT NOT NULL, id VARCHAR(32) NOT NULL, stamp timestamp, PRIMARY KEY (id));
INSERT INTO t1 VALUES ("my value", "myKey","1999-04-02 00:00:00");
SELECT stamp FROM t1 WHERE id="myKey";
stamp
1999-04-02 00:00:00
UPDATE t1 SET value="my value" WHERE id="myKey";
SELECT stamp FROM t1 WHERE id="myKey";
stamp
1999-04-02 00:00:00
UPDATE t1 SET id="myKey" WHERE value="my value";
SELECT stamp FROM t1 WHERE id="myKey";
stamp
1999-04-02 00:00:00
drop table t1;
create table t1 (a timestamp);
insert into t1 values (now());
select date_format(a,"%Y %y"),year(a),year(now()) from t1;
date_format(a,"%Y %y") year(a) year(now())
1970 70 1970 1970
drop table t1;
create table t1 (ix timestamp);
insert into t1 values (19991101000000),(19990102030405),(19990630232922),(19990601000000),(19990930232922),(19990531232922),(19990501000000),(19991101000000),(19990501000000);
select ix+0 from t1;
ix+0
19991101000000
19990102030405
19990630232922
19990601000000
19990930232922
19990531232922
19990501000000
19991101000000
19990501000000
truncate table t1;
insert into t1 values ("19991101000000"),("19990102030405"),("19990630232922"),("19990601000000");
select ix+0 from t1;
ix+0
19991101000000
19990102030405
19990630232922
19990601000000
drop table t1;
CREATE TABLE t1 (date date, date_time datetime, time_stamp timestamp);
INSERT INTO t1 VALUES ("1998-12-31","1998-12-31 23:59:59",19981231235959);
INSERT INTO t1 VALUES ("1999-01-01","1999-01-01 00:00:00",19990101000000);
INSERT INTO t1 VALUES ("1999-09-09","1999-09-09 23:59:59",19990909235959);
INSERT INTO t1 VALUES ("2000-01-01","2000-01-01 00:00:00",20000101000000);
INSERT INTO t1 VALUES ("2000-02-28","2000-02-28 00:00:00",20000228000000);
INSERT INTO t1 VALUES ("2000-02-29","2000-02-29 00:00:00",20000229000000);
INSERT INTO t1 VALUES ("2000-03-01","2000-03-01 00:00:00",20000301000000);
INSERT INTO t1 VALUES ("2000-12-31","2000-12-31 23:59:59",20001231235959);
INSERT INTO t1 VALUES ("2001-01-01","2001-01-01 00:00:00",20010101000000);
INSERT INTO t1 VALUES ("2004-12-31","2004-12-31 23:59:59",20041231235959);
INSERT INTO t1 VALUES ("2005-01-01","2005-01-01 00:00:00",20050101000000);
INSERT INTO t1 VALUES ("2030-01-01","2030-01-01 00:00:00",20300101000000);
SELECT * FROM t1;
date date_time time_stamp
1998-12-31 1998-12-31 23:59:59 1998-12-31 23:59:59
1999-01-01 1999-01-01 00:00:00 1999-01-01 00:00:00
1999-09-09 1999-09-09 23:59:59 1999-09-09 23:59:59
2000-01-01 2000-01-01 00:00:00 2000-01-01 00:00:00
2000-02-28 2000-02-28 00:00:00 2000-02-28 00:00:00
2000-02-29 2000-02-29 00:00:00 2000-02-29 00:00:00
2000-03-01 2000-03-01 00:00:00 2000-03-01 00:00:00
2000-12-31 2000-12-31 23:59:59 2000-12-31 23:59:59
2001-01-01 2001-01-01 00:00:00 2001-01-01 00:00:00
2004-12-31 2004-12-31 23:59:59 2004-12-31 23:59:59
2005-01-01 2005-01-01 00:00:00 2005-01-01 00:00:00
2030-01-01 2030-01-01 00:00:00 2030-01-01 00:00:00
drop table t1;
create table t1 (t2 timestamp(2), t4 timestamp(4), t6 timestamp(6),
t8 timestamp(8), t10 timestamp(10), t12 timestamp(12),
t14 timestamp(14));
Warnings:
Warning 1287 'TIMESTAMP(2)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead
Warning 1287 'TIMESTAMP(4)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead
Warning 1287 'TIMESTAMP(6)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead
Warning 1287 'TIMESTAMP(8)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead
Warning 1287 'TIMESTAMP(10)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead
Warning 1287 'TIMESTAMP(12)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead
Warning 1287 'TIMESTAMP(14)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead
insert t1 values (0,0,0,0,0,0,0),
("1997-12-31 23:47:59", "1997-12-31 23:47:59", "1997-12-31 23:47:59",
"1997-12-31 23:47:59", "1997-12-31 23:47:59", "1997-12-31 23:47:59",
"1997-12-31 23:47:59");
select * from t1;
t2 t4 t6 t8 t10 t12 t14
0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00
1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59
select * from t1;
t2 t4 t6 t8 t10 t12 t14
0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00
1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59
drop table t1;
create table t1 (ix timestamp);
insert into t1 values (0),(20030101010160),(20030101016001),(20030101240101),(20030132010101),(20031301010101),(20031200000000),(20030000000000);
Warnings:
Warning 1265 Data truncated for column 'ix' at row 2
Warning 1265 Data truncated for column 'ix' at row 3
Warning 1265 Data truncated for column 'ix' at row 4
Warning 1265 Data truncated for column 'ix' at row 5
Warning 1265 Data truncated for column 'ix' at row 6
Warning 1265 Data truncated for column 'ix' at row 7
Warning 1265 Data truncated for column 'ix' at row 8
select ix+0 from t1;
ix+0
0
0
0
0
0
0
0
0
truncate table t1;
insert into t1 values ("00000000000000"),("20030101010160"),("20030101016001"),("20030101240101"),("20030132010101"),("20031301010101"),("20031200000000"),("20030000000000");
Warnings:
Warning 1265 Data truncated for column 'ix' at row 2
Warning 1265 Data truncated for column 'ix' at row 3
Warning 1265 Data truncated for column 'ix' at row 4
Warning 1265 Data truncated for column 'ix' at row 5
Warning 1265 Data truncated for column 'ix' at row 6
Warning 1265 Data truncated for column 'ix' at row 7
Warning 1265 Data truncated for column 'ix' at row 8
select ix+0 from t1;
ix+0
0
0
0
0
0
0
0
0
truncate table t1;
insert into t1 values ("0000-00-00 00:00:00 some trailer"),("2003-01-01 00:00:00 some trailer");
Warnings:
Warning 1265 Data truncated for column 'ix' at row 1
Warning 1265 Data truncated for column 'ix' at row 2
select ix+0 from t1;
ix+0
0
20030101000000
drop table t1;
create table t1 (t1 timestamp, t2 timestamp default now());
ERROR HY000: Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause
create table t1 (t1 timestamp, t2 timestamp on update now());
ERROR HY000: Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause
create table t1 (t1 timestamp, t2 timestamp default now() on update now());
ERROR HY000: Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause
create table t1 (t1 timestamp default now(), t2 timestamp on update now());
ERROR HY000: Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause
create table t1 (t1 timestamp on update now(), t2 timestamp default now() on update now());
ERROR HY000: Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause
create table t1 (t1 timestamp default '2003-01-01 00:00:00', t2 datetime, t3 timestamp);
SET TIMESTAMP=1000000000;
insert into t1 values ();
SET TIMESTAMP=1000000001;
update t1 set t2=now();
SET TIMESTAMP=1000000002;
insert into t1 (t1,t3) values (default, default);
select * from t1;
t1 t2 t3
2003-01-01 00:00:00 2001-09-09 04:46:41 0000-00-00 00:00:00
2003-01-01 00:00:00 NULL 0000-00-00 00:00:00
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`t1` timestamp NOT NULL DEFAULT '2003-01-01 00:00:00',
`t2` datetime DEFAULT NULL,
`t3` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
show columns from t1;
Field Type Null Key Default Extra
t1 timestamp NO 2003-01-01 00:00:00
t2 datetime YES NULL
t3 timestamp NO 0000-00-00 00:00:00
drop table t1;
create table t1 (t1 timestamp default now(), t2 datetime, t3 timestamp);
SET TIMESTAMP=1000000002;
insert into t1 values ();
SET TIMESTAMP=1000000003;
update t1 set t2=now();
SET TIMESTAMP=1000000003;
insert into t1 (t1,t3) values (default, default);
select * from t1;
t1 t2 t3
2001-09-09 04:46:42 2001-09-09 04:46:43 0000-00-00 00:00:00
2001-09-09 04:46:43 NULL 0000-00-00 00:00:00
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`t1` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`t2` datetime DEFAULT NULL,
`t3` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
show columns from t1;
Field Type Null Key Default Extra
t1 timestamp NO CURRENT_TIMESTAMP
t2 datetime YES NULL
t3 timestamp NO 0000-00-00 00:00:00
drop table t1;
create table t1 (t1 timestamp default '2003-01-01 00:00:00' on update now(), t2 datetime);
SET TIMESTAMP=1000000004;
insert into t1 values ();
select * from t1;
t1 t2
2003-01-01 00:00:00 NULL
SET TIMESTAMP=1000000005;
update t1 set t2=now();
SET TIMESTAMP=1000000005;
insert into t1 (t1) values (default);
select * from t1;
t1 t2
2001-09-09 04:46:45 2001-09-09 04:46:45
2003-01-01 00:00:00 NULL
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`t1` timestamp NOT NULL DEFAULT '2003-01-01 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
`t2` datetime DEFAULT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
show columns from t1;
Field Type Null Key Default Extra
t1 timestamp NO 2003-01-01 00:00:00 on update CURRENT_TIMESTAMP
t2 datetime YES NULL
drop table t1;
create table t1 (t1 timestamp default now() on update now(), t2 datetime);
SET TIMESTAMP=1000000006;
insert into t1 values ();
select * from t1;
t1 t2
2001-09-09 04:46:46 NULL
SET TIMESTAMP=1000000007;
update t1 set t2=now();
SET TIMESTAMP=1000000007;
insert into t1 (t1) values (default);
select * from t1;
t1 t2
2001-09-09 04:46:47 2001-09-09 04:46:47
2001-09-09 04:46:47 NULL
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`t1` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`t2` datetime DEFAULT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
show columns from t1;
Field Type Null Key Default Extra
t1 timestamp NO CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP
t2 datetime YES NULL
drop table t1;
create table t1 (t1 timestamp, t2 datetime, t3 timestamp);
SET TIMESTAMP=1000000007;
insert into t1 values ();
select * from t1;
t1 t2 t3
2001-09-09 04:46:47 NULL 0000-00-00 00:00:00
SET TIMESTAMP=1000000008;
update t1 set t2=now();
SET TIMESTAMP=1000000008;
insert into t1 (t1,t3) values (default, default);
select * from t1;
t1 t2 t3
2001-09-09 04:46:48 2001-09-09 04:46:48 0000-00-00 00:00:00
2001-09-09 04:46:48 NULL 0000-00-00 00:00:00
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`t1` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`t2` datetime DEFAULT NULL,
`t3` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
show columns from t1;
Field Type Null Key Default Extra
t1 timestamp NO CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP
t2 datetime YES NULL
t3 timestamp NO 0000-00-00 00:00:00
drop table t1;
create table t1 (t1 timestamp default current_timestamp on update current_timestamp, t2 datetime);
SET TIMESTAMP=1000000009;
insert into t1 values ();
select * from t1;
t1 t2
2001-09-09 04:46:49 NULL
SET TIMESTAMP=1000000010;
update t1 set t2=now();
SET TIMESTAMP=1000000011;
insert into t1 (t1) values (default);
select * from t1;
t1 t2
2001-09-09 04:46:50 2001-09-09 04:46:50
2001-09-09 04:46:51 NULL
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`t1` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`t2` datetime DEFAULT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
show columns from t1;
Field Type Null Key Default Extra
t1 timestamp NO CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP
t2 datetime YES NULL
truncate table t1;
insert into t1 values ('2004-04-01 00:00:00', '2004-04-01 00:00:00');
SET TIMESTAMP=1000000012;
update t1 set t1= '2004-04-02 00:00:00';
select * from t1;
t1 t2
2004-04-02 00:00:00 2004-04-01 00:00:00
update t1 as ta, t1 as tb set tb.t1= '2004-04-03 00:00:00';
select * from t1;
t1 t2
2004-04-03 00:00:00 2004-04-01 00:00:00
drop table t1;
create table t1 (pk int primary key, t1 timestamp default current_timestamp on update current_timestamp, bulk int);
insert into t1 values (1, '2004-04-01 00:00:00', 10);
SET TIMESTAMP=1000000013;
replace into t1 set pk = 1, bulk= 20;
select * from t1;
pk t1 bulk
1 2001-09-09 04:46:53 20
drop table t1;
create table t1 (pk int primary key, t1 timestamp default '2003-01-01 00:00:00' on update current_timestamp, bulk int);
insert into t1 values (1, '2004-04-01 00:00:00', 10);
SET TIMESTAMP=1000000014;
replace into t1 set pk = 1, bulk= 20;
select * from t1;
pk t1 bulk
1 2003-01-01 00:00:00 20
drop table t1;
create table t1 (pk int primary key, t1 timestamp default current_timestamp, bulk int);
insert into t1 values (1, '2004-04-01 00:00:00', 10);
SET TIMESTAMP=1000000015;
replace into t1 set pk = 1, bulk= 20;
select * from t1;
pk t1 bulk
1 2001-09-09 04:46:55 20
drop table t1;
create table t1 (t1 timestamp default current_timestamp on update current_timestamp);
insert into t1 values ('2004-04-01 00:00:00');
SET TIMESTAMP=1000000016;
alter table t1 add i int default 10;
select * from t1;
t1 i
2004-04-01 00:00:00 10
drop table t1;
create table t1 (a timestamp null, b timestamp null);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` timestamp NULL DEFAULT NULL,
`b` timestamp NULL DEFAULT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
insert into t1 values (NULL, NULL);
SET TIMESTAMP=1000000017;
insert into t1 values ();
select * from t1;
a b
NULL NULL
NULL NULL
drop table t1;
create table t1 (a timestamp null default current_timestamp on update current_timestamp, b timestamp null);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`b` timestamp NULL DEFAULT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
insert into t1 values (NULL, NULL);
SET TIMESTAMP=1000000018;
insert into t1 values ();
select * from t1;
a b
NULL NULL
2001-09-09 04:46:58 NULL
drop table t1;
create table t1 (a timestamp null default null, b timestamp null default '2003-01-01 00:00:00');
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` timestamp NULL DEFAULT NULL,
`b` timestamp NULL DEFAULT '2003-01-01 00:00:00'
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
insert into t1 values (NULL, NULL);
insert into t1 values (DEFAULT, DEFAULT);
select * from t1;
a b
NULL NULL
NULL 2003-01-01 00:00:00
drop table t1;
create table t1 (a bigint, b bigint);
insert into t1 values (NULL, NULL), (20030101000000, 20030102000000);
set timestamp=1000000019;
alter table t1 modify a timestamp, modify b timestamp;
select * from t1;
a b
2001-09-09 04:46:59 2001-09-09 04:46:59
2003-01-01 00:00:00 2003-01-02 00:00:00
drop table t1;
create table t1 (a char(2), t timestamp);
insert into t1 values ('a', '2004-01-01 00:00:00'), ('a', '2004-01-01 01:00:00'),
('b', '2004-02-01 00:00:00');
select max(t) from t1 group by a;
max(t)
2004-01-01 01:00:00
2004-02-01 00:00:00
drop table t1;
set sql_mode='maxdb';
create table t1 (a timestamp, b timestamp(19));
show create table t1;
Table Create Table
t1 CREATE TABLE "t1" (
"a" datetime DEFAULT NULL,
"b" datetime DEFAULT NULL
)
set sql_mode='';
drop table t1;
create table t1 (a int auto_increment primary key, b int, c timestamp);
insert into t1 (a, b, c) values (1, 0, '2001-01-01 01:01:01'),
(2, 0, '2002-02-02 02:02:02'), (3, 0, '2003-03-03 03:03:03');
select * from t1;
a b c
1 0 2001-01-01 01:01:01
2 0 2002-02-02 02:02:02
3 0 2003-03-03 03:03:03
update t1 set b = 2, c = c where a = 2;
select * from t1;
a b c
1 0 2001-01-01 01:01:01
2 2 2002-02-02 02:02:02
3 0 2003-03-03 03:03:03
insert into t1 (a) values (4);
select * from t1;
a b c
1 0 2001-01-01 01:01:01
2 2 2002-02-02 02:02:02
3 0 2003-03-03 03:03:03
4 NULL 2001-09-09 04:46:59
update t1 set c = '2004-04-04 04:04:04' where a = 4;
select * from t1;
a b c
1 0 2001-01-01 01:01:01
2 2 2002-02-02 02:02:02
3 0 2003-03-03 03:03:03
4 NULL 2004-04-04 04:04:04
insert into t1 (a) values (3), (5) on duplicate key update b = 3, c = c;
select * from t1;
a b c
1 0 2001-01-01 01:01:01
2 2 2002-02-02 02:02:02
3 3 2003-03-03 03:03:03
4 NULL 2004-04-04 04:04:04
5 NULL 2001-09-09 04:46:59
insert into t1 (a, c) values (4, '2004-04-04 00:00:00'),
(6, '2006-06-06 06:06:06') on duplicate key update b = 4;
select * from t1;
a b c
1 0 2001-01-01 01:01:01
2 2 2002-02-02 02:02:02
3 3 2003-03-03 03:03:03
4 4 2001-09-09 04:46:59
5 NULL 2001-09-09 04:46:59
6 NULL 2006-06-06 06:06:06
drop table t1;
set time_zone= @@global.time_zone;
CREATE TABLE t1 (
`id` int(11) NOT NULL auto_increment,
`username` varchar(80) NOT NULL default '',
`posted_on` timestamp NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
show fields from t1;
Field Type Null Key Default Extra
id int(11) NO PRI NULL auto_increment
username varchar(80) NO
posted_on timestamp NO 0000-00-00 00:00:00
select is_nullable from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='t1' and COLUMN_NAME='posted_on';
is_nullable
NO
drop table t1;
SET STORAGE_ENGINE='tokudb';
drop table if exists t1;
SET SQL_WARNINGS=1;
create table t1 (this int unsigned);
insert into t1 values (1);
insert into t1 values (-1);
Warnings:
Warning 1264 Out of range value for column 'this' at row 1
insert into t1 values ('5000000000');
Warnings:
Warning 1264 Out of range value for column 'this' at row 1
select * from t1;
this
1
0
4294967295
drop table t1;
SET STORAGE_ENGINE='tokudb';
drop table if exists t1, t2, vchar;
set tokudb_load_save_space=1;
create table t1 (v varchar(30), c char(3), e enum('abc','def','ghi'), t text);
create table vchar (v varchar(30), c char(3), e enum('abc','def','ghi'), t text);
truncate table vchar;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`v` varchar(30) DEFAULT NULL,
`c` char(3) DEFAULT NULL,
`e` enum('abc','def','ghi') DEFAULT NULL,
`t` text
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
show create table vchar;
Table Create Table
vchar CREATE TABLE `vchar` (
`v` varchar(30) DEFAULT NULL,
`c` char(3) DEFAULT NULL,
`e` enum('abc','def','ghi') DEFAULT NULL,
`t` text
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
insert into t1 values ('abc', 'de', 'ghi', 'jkl');
insert into t1 values ('abc ', 'de ', 'ghi', 'jkl ');
insert into t1 values ('abc ', 'd ', 'ghi', 'jkl ');
insert into vchar values ('abc', 'de', 'ghi', 'jkl');
insert into vchar values ('abc ', 'de ', 'ghi', 'jkl ');
insert into vchar values ('abc ', 'd ', 'ghi', 'jkl ');
select length(v),length(c),length(e),length(t) from t1;
length(v) length(c) length(e) length(t)
3 2 3 3
4 2 3 4
7 1 3 7
select length(v),length(c),length(e),length(t) from vchar;
length(v) length(c) length(e) length(t)
3 2 3 3
4 2 3 4
7 1 3 7
alter table vchar add i int;
show create table vchar;
Table Create Table
vchar CREATE TABLE `vchar` (
`v` varchar(30) DEFAULT NULL,
`c` char(3) DEFAULT NULL,
`e` enum('abc','def','ghi') DEFAULT NULL,
`t` text,
`i` int(11) DEFAULT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
select length(v),length(c),length(e),length(t) from vchar;
length(v) length(c) length(e) length(t)
3 2 3 3
4 2 3 4
7 1 3 7
drop table t1, vchar;
create table t1 (v varchar(20));
insert into t1 values('a ');
select v='a' from t1;
v='a'
1
select binary v='a' from t1;
binary v='a'
0
select binary v='a ' from t1;
binary v='a '
1
insert into t1 values('a');
alter table t1 add primary key (v);
ERROR 23000: Duplicate entry 'a' for key 'PRIMARY'
drop table t1;
create table t1 (v varbinary(20));
insert into t1 values('a');
insert into t1 values('a ');
alter table t1 add primary key (v);
drop table t1;
create table t1 (v varchar(254), index (v));
insert into t1 values ("This is a test ");
insert into t1 values ("Some sample data");
insert into t1 values (" garbage ");
insert into t1 values (" This is a test ");
insert into t1 values ("This is a test");
insert into t1 values ("Hello world");
insert into t1 values ("Foo bar");
insert into t1 values ("This is a test");
insert into t1 values ("MySQL varchar test");
insert into t1 values ("test MySQL varchar");
insert into t1 values ("This is a long string to have some random length data included");
insert into t1 values ("Short string");
insert into t1 values ("VSS");
insert into t1 values ("Some samples");
insert into t1 values ("Bar foo");
insert into t1 values ("Bye");
select * from t1 where v like 'This is a test' order by v;
v
This is a test
This is a test
select * from t1 where v='This is a test' order by v;
v
This is a test
This is a test
This is a test
select * from t1 where v like 'S%' order by v;
v
Short string
Some sample data
Some samples
explain select * from t1 where v like 'This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 257 NULL 3 Using where; Using index
explain select * from t1 where v='This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 257 const 3 Using where; Using index
explain select * from t1 where v like 'S%' order by v;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 257 NULL 3 Using where; Using index
alter table t1 drop index v;
alter table t1 change v v varchar(255);
alter table t1 add index v(v);
select * from t1 where v like 'This is a test' order by v;
v
This is a test
This is a test
select * from t1 where v='This is a test' order by v;
v
This is a test
This is a test
This is a test
select * from t1 where v like 'S%' order by v;
v
Short string
Some sample data
Some samples
explain select * from t1 where v like 'This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 258 NULL 3 Using where; Using index
explain select * from t1 where v='This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 258 const 3 Using where; Using index
explain select * from t1 where v like 'S%' order by v;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 258 NULL 3 Using where; Using index
alter table t1 drop index v;
alter table t1 change v v varchar(256);
alter table t1 add index v(v);
select * from t1 where v like 'This is a test' order by v;
v
This is a test
This is a test
select * from t1 where v='This is a test' order by v;
v
This is a test
This is a test
This is a test
select * from t1 where v like 'S%' order by v;
v
Short string
Some sample data
Some samples
explain select * from t1 where v like 'This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 259 NULL 3 Using where; Using index
explain select * from t1 where v='This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 259 const 3 Using where; Using index
explain select * from t1 where v like 'S%' order by v;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 259 NULL 3 Using where; Using index
alter table t1 drop index v;
alter table t1 change v v varchar(257);
alter table t1 add index v(v);
select * from t1 where v like 'This is a test' order by v;
v
This is a test
This is a test
select * from t1 where v='This is a test' order by v;
v
This is a test
This is a test
This is a test
select * from t1 where v like 'S%' order by v;
v
Short string
Some sample data
Some samples
explain select * from t1 where v like 'This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 260 NULL 3 Using where; Using index
explain select * from t1 where v='This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 260 const 3 Using where; Using index
explain select * from t1 where v like 'S%' order by v;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 260 NULL 3 Using where; Using index
alter table t1 drop index v;
alter table t1 change v v varchar(258);
alter table t1 add index v(v);
select * from t1 where v like 'This is a test' order by v;
v
This is a test
This is a test
select * from t1 where v='This is a test' order by v;
v
This is a test
This is a test
This is a test
select * from t1 where v like 'S%' order by v;
v
Short string
Some sample data
Some samples
explain select * from t1 where v like 'This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 261 NULL 3 Using where; Using index
explain select * from t1 where v='This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 261 const 3 Using where; Using index
explain select * from t1 where v like 'S%' order by v;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 261 NULL 3 Using where; Using index
alter table t1 drop index v;
alter table t1 change v v varchar(259);
alter table t1 add index v(v);
select * from t1 where v like 'This is a test' order by v;
v
This is a test
This is a test
select * from t1 where v='This is a test' order by v;
v
This is a test
This is a test
This is a test
select * from t1 where v like 'S%' order by v;
v
Short string
Some sample data
Some samples
explain select * from t1 where v like 'This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 262 NULL 3 Using where; Using index
explain select * from t1 where v='This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 262 const 3 Using where; Using index
explain select * from t1 where v like 'S%' order by v;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 262 NULL 3 Using where; Using index
alter table t1 change v v varchar(258);
select * from t1 where v like 'This is a test' order by v;
v
This is a test
This is a test
select * from t1 where v='This is a test' order by v;
v
This is a test
This is a test
This is a test
select * from t1 where v like 'S%' order by v;
v
Short string
Some sample data
Some samples
explain select * from t1 where v like 'This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 261 NULL 3 Using where; Using index
explain select * from t1 where v='This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 261 const 3 Using where; Using index
explain select * from t1 where v like 'S%' order by v;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 261 NULL 3 Using where; Using index
alter table t1 change v v varchar(257);
select * from t1 where v like 'This is a test' order by v;
v
This is a test
This is a test
select * from t1 where v='This is a test' order by v;
v
This is a test
This is a test
This is a test
select * from t1 where v like 'S%' order by v;
v
Short string
Some sample data
Some samples
explain select * from t1 where v like 'This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 260 NULL 3 Using where; Using index
explain select * from t1 where v='This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 260 const 3 Using where; Using index
explain select * from t1 where v like 'S%' order by v;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 260 NULL 3 Using where; Using index
alter table t1 change v v varchar(256);
select * from t1 where v like 'This is a test' order by v;
v
This is a test
This is a test
select * from t1 where v='This is a test' order by v;
v
This is a test
This is a test
This is a test
select * from t1 where v like 'S%' order by v;
v
Short string
Some sample data
Some samples
explain select * from t1 where v like 'This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 259 NULL 3 Using where; Using index
explain select * from t1 where v='This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 259 const 3 Using where; Using index
explain select * from t1 where v like 'S%' order by v;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 259 NULL 3 Using where; Using index
alter table t1 change v v varchar(255);
select * from t1 where v like 'This is a test' order by v;
v
This is a test
This is a test
select * from t1 where v='This is a test' order by v;
v
This is a test
This is a test
This is a test
select * from t1 where v like 'S%' order by v;
v
Short string
Some sample data
Some samples
explain select * from t1 where v like 'This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 258 NULL 3 Using where; Using index
explain select * from t1 where v='This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 258 const 3 Using where; Using index
explain select * from t1 where v like 'S%' order by v;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 258 NULL 3 Using where; Using index
alter table t1 change v v varchar(254);
select * from t1 where v like 'This is a test' order by v;
v
This is a test
This is a test
select * from t1 where v='This is a test' order by v;
v
This is a test
This is a test
This is a test
select * from t1 where v like 'S%' order by v;
v
Short string
Some sample data
Some samples
explain select * from t1 where v like 'This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 257 NULL 3 Using where; Using index
explain select * from t1 where v='This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 257 const 3 Using where; Using index
explain select * from t1 where v like 'S%' order by v;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 257 NULL 3 Using where; Using index
alter table t1 change v v varchar(253);
alter table t1 change v v varchar(254), drop key v;
alter table t1 change v v varchar(300), add key (v(10));
select * from t1 where v like 'This is a test' order by v;
v
This is a test
This is a test
select * from t1 where v='This is a test' order by v;
v
This is a test
This is a test
This is a test
select * from t1 where v like 'S%' order by v;
v
Short string
Some sample data
Some samples
explain select * from t1 where v like 'This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 13 NULL 4 Using where; Using filesort
explain select * from t1 where v='This is a test' order by v;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 13 const 4 Using where
explain select * from t1 where v like 'S%' order by v;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 13 NULL 3 Using where; Using filesort
drop table t1;
create table t1 (pkcol varchar(16), othercol varchar(16), primary key (pkcol));
insert into t1 values ('test', 'something');
update t1 set othercol='somethingelse' where pkcol='test';
select * from t1;
pkcol othercol
test somethingelse
drop table t1;
create table t1 (a int, b varchar(12));
insert into t1 values (1, 'A'), (22, NULL);
create table t2 (a int);
insert into t2 values (22), (22);
select t1.a, t1.b, min(t1.b) from t1 inner join t2 ON t2.a = t1.a
group by t1.b, t1.a;
a b min(t1.b)
22 NULL NULL
drop table t1, t2;
create table t1 (f1 varchar(65500));
create index index1 on t1(f1(10));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`f1` varchar(65500) DEFAULT NULL,
KEY `index1` (`f1`(10))
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
alter table t1 modify f1 varchar(255);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`f1` varchar(255) DEFAULT NULL,
KEY `index1` (`f1`(10))
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
alter table t1 modify f1 tinytext;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`f1` tinytext,
KEY `index1` (`f1`(10))
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
drop table t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1(f1 VARCHAR(100) DEFAULT 'test');
INSERT INTO t1 VALUES(SUBSTR(f1, 1, 3));
DROP TABLE IF EXISTS t1;
CREATE TABLE t1(f1 CHAR(100) DEFAULT 'test');
INSERT INTO t1 VALUES(SUBSTR(f1, 1, 3));
DROP TABLE IF EXISTS t1;
drop table if exists t1, t2, t3;
create table t3 (
id int(11),
en varchar(255) character set utf8,
cz varchar(255) character set utf8
);
truncate table t3;
insert into t3 (id, en, cz) values
(1,'en string 1','cz string 1'),
(2,'en string 2','cz string 2'),
(3,'en string 3','cz string 3');
create table t1 (
id int(11),
name_id int(11)
);
insert into t1 (id, name_id) values (1,1), (2,3), (3,3);
create table t2 (id int(11));
insert into t2 (id) values (1), (2), (3);
select t1.*, t2.id, t3.en, t3.cz from t1 left join t2 on t1.id=t2.id
left join t3 on t1.id=t3.id order by t3.id;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def test t1 t1 id id 3 11 1 Y 32768 0 63
def test t1 t1 name_id name_id 3 11 1 Y 32768 0 63
def test t2 t2 id id 3 11 1 Y 32768 0 63
def test t3 t3 en en 253 255 11 Y 0 0 8
def test t3 t3 cz cz 253 255 11 Y 0 0 8
id name_id id en cz
1 1 1 en string 1 cz string 1
2 3 2 en string 2 cz string 2
3 3 3 en string 3 cz string 3
drop table t1, t2, t3;
CREATE TABLE t1 (a CHAR(2));
INSERT INTO t1 VALUES (10), (50), (30), ('1a'), (60), ('t');
SELECT a,(a + 0) FROM t1 ORDER BY a;
a (a + 0)
10 10
1a 1
30 30
50 50
60 60
t 0
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: '1a'
Warning 1292 Truncated incorrect DOUBLE value: 't '
SELECT a,(a DIV 2) FROM t1 ORDER BY a;
a (a DIV 2)
10 5
1a 0
30 15
50 25
60 30
t 0
Warnings:
Warning 1292 Truncated incorrect INTEGER value: '1a'
Warning 1292 Truncated incorrect INTEGER value: 't '
SELECT a,CAST(a AS SIGNED) FROM t1 ORDER BY a;
a CAST(a AS SIGNED)
10 10
1a 1
30 30
50 50
60 60
t 0
Warnings:
Warning 1292 Truncated incorrect INTEGER value: '1a'
Warning 1292 Truncated incorrect INTEGER value: 't'
DROP TABLE t1;
SET STORAGE_ENGINE='tokudb';
drop table if exists t1;
create table t1 (y year,y2 year(2));
insert into t1 values (0,0),(1999,1999),(2000,2000),(2001,2001),(70,70),(69,69);
select * from t1;
y y2
0000 00
1999 99
2000 00
2001 01
1970 70
2069 69
select * from t1 order by y;
y y2
0000 00
1970 70
1999 99
2000 00
2001 01
2069 69
select * from t1 order by y2;
y y2
1970 70
1999 99
0000 00
2000 00
2001 01
2069 69
drop table t1;
create table t1 (y year);
insert into t1 values (now());
Warnings:
Warning 1265 Data truncated for column 'y' at row 1
select if(y = now(), 1, 0) from t1;
if(y = now(), 1, 0)
1
drop table t1;
create table t1(a year);
insert into t1 values (2000.5), ('2000.5'), ('2001a'), ('2.001E3');
Warnings:
Warning 1265 Data truncated for column 'a' at row 3
select * from t1;
a
2001
2001
2001
2001
drop table t1;
End of 5.0 tests
set STORAGE_ENGINE='tokudb';
#
# Bug #27562: ascii.xml invalid?
#
set names ascii;
select 'e'='`';
select 'y'='~';
create table t1 (a char(1) character set ascii);
insert into t1 (a) values (' '), ('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'), ('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'), ('!'), ('@'), ('#'), ('$'), ('%'), ('^'), ('&'), ('*'), ('('), (')'), ('_'), ('+'), ('`'), ('~'), ('1'), ('2'), ('3'), ('4'), ('5'), ('6'), ('7'), ('8'), ('9'), ('0'), ('['), (']'), ('\\'), ('|'), ('}'), ('{'), ('"'), (':'), (''''), (';'), ('/'), ('.'), (','), ('?'), ('>'), ('<'), ('\n'), ('\t'), ('\a'), ('\f'), ('\v');
select t1a.a, t1b.a from t1 as t1a, t1 as t1b where t1a.a=t1b.a order by binary t1a.a, binary t1b.a;
drop table t1;
#
--echo End of 5.0 tests.
set STORAGE_ENGINE='tokudb';
--disable_warnings
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
--enable_warnings
CREATE TABLE t1 (
latin1_f CHAR(32) CHARACTER SET latin1 NOT NULL
);
--error 1253
CREATE TABLE t2 (
latin1_f CHAR(32) CHARACTER SET latin1 COLLATE koi8r_general_ci NOT NULL
);
--error 1273
CREATE TABLE t2 (
latin1_f CHAR(32) CHARACTER SET latin1 COLLATE some_non_existing_col NOT NULL
);
INSERT INTO t1 (latin1_f) VALUES (_latin1'A');
INSERT INTO t1 (latin1_f) VALUES (_latin1'a');
INSERT INTO t1 (latin1_f) VALUES (_latin1'AD');
INSERT INTO t1 (latin1_f) VALUES (_latin1'ad');
INSERT INTO t1 (latin1_f) VALUES (_latin1'AE');
INSERT INTO t1 (latin1_f) VALUES (_latin1'ae');
INSERT INTO t1 (latin1_f) VALUES (_latin1'AF');
INSERT INTO t1 (latin1_f) VALUES (_latin1'af');
INSERT INTO t1 (latin1_f) VALUES (_latin1'Ä');
INSERT INTO t1 (latin1_f) VALUES (_latin1'ä');
INSERT INTO t1 (latin1_f) VALUES (_latin1'Å');
INSERT INTO t1 (latin1_f) VALUES (_latin1'å');
INSERT INTO t1 (latin1_f) VALUES (_latin1'B');
INSERT INTO t1 (latin1_f) VALUES (_latin1'b');
INSERT INTO t1 (latin1_f) VALUES (_latin1'U');
INSERT INTO t1 (latin1_f) VALUES (_latin1'u');
INSERT INTO t1 (latin1_f) VALUES (_latin1'UE');
INSERT INTO t1 (latin1_f) VALUES (_latin1'ue');
INSERT INTO t1 (latin1_f) VALUES (_latin1'Ü');
INSERT INTO t1 (latin1_f) VALUES (_latin1'ü');
INSERT INTO t1 (latin1_f) VALUES (_latin1'SS');
INSERT INTO t1 (latin1_f) VALUES (_latin1'ss');
INSERT INTO t1 (latin1_f) VALUES (_latin1'ß');
INSERT INTO t1 (latin1_f) VALUES (_latin1'Y');
INSERT INTO t1 (latin1_f) VALUES (_latin1'y');
INSERT INTO t1 (latin1_f) VALUES (_latin1'Z');
INSERT INTO t1 (latin1_f) VALUES (_latin1'z');
# ORDER BY
SELECT latin1_f FROM t1 ORDER BY latin1_f;
SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_swedish_ci;
SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_german2_ci;
SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_general_ci;
SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_bin;
--error 1253
SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE koi8r_general_ci;
# SELECT latin1_f COLLATE koi8r FROM t1 ;
# AS + ORDER BY
SELECT latin1_f COLLATE latin1_swedish_ci AS latin1_f_as FROM t1 ORDER BY latin1_f_as;
SELECT latin1_f COLLATE latin1_german2_ci AS latin1_f_as FROM t1 ORDER BY latin1_f_as;
SELECT latin1_f COLLATE latin1_general_ci AS latin1_f_as FROM t1 ORDER BY latin1_f_as;
SELECT latin1_f COLLATE latin1_bin AS latin1_f_as FROM t1 ORDER BY latin1_f_as;
--error 1253
SELECT latin1_f COLLATE koi8r_general_ci AS latin1_f_as FROM t1 ORDER BY latin1_f_as;
# GROUP BY
SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f;
SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_swedish_ci;
SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_german2_ci;
SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_general_ci;
SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_bin;
--error 1253
SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE koi8r_general_ci;
# DISTINCT
SELECT DISTINCT latin1_f FROM t1;
SELECT DISTINCT latin1_f COLLATE latin1_swedish_ci FROM t1;
SELECT DISTINCT latin1_f COLLATE latin1_german2_ci FROM t1;
SELECT DISTINCT latin1_f COLLATE latin1_general_ci FROM t1;
SELECT DISTINCT latin1_f COLLATE latin1_bin FROM t1;
--error 1273
SELECT DISTINCT latin1_f COLLATE koi8r FROM t1;
# Aggregates
--disable_parsing
SELECT MAX(k COLLATE latin1_german2_ci)
FROM t1
WHERE
SELECT *
FROM t1
WHERE (_latin1'Mu"ller' COLLATE latin1_german2_ci) = k
HAVING
SELECT *
FROM t1
HAVING (_latin1'Mu"ller' COLLATE latin1_german2_ci) = k;
--enable_parsing
#
# Check that SHOW displays COLLATE clause
#
SHOW CREATE TABLE t1;
SHOW FIELDS FROM t1;
ALTER TABLE t1 CHANGE latin1_f
latin1_f CHAR(32) CHARACTER SET latin1 COLLATE latin1_bin;
SHOW CREATE TABLE t1;
SHOW FIELDS FROM t1;
ALTER TABLE t1 CHARACTER SET latin1 COLLATE latin1_bin;
SHOW CREATE TABLE t1;
SHOW FIELDS FROM t1;
#
# Check SET CHARACTER SET
#
SET CHARACTER SET 'latin1';
SHOW VARIABLES LIKE 'character_set_client';
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
explain extended SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
SET CHARACTER SET koi8r;
SHOW VARIABLES LIKE 'collation_client';
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
--error 1115
SET CHARACTER SET 'DEFAULT';
DROP TABLE t1;
CREATE TABLE t1
(s1 CHAR(5) COLLATE latin1_german1_ci,
s2 CHAR(5) COLLATE latin1_swedish_ci);
--error 1267
SELECT * FROM t1 WHERE s1 = s2;
DROP TABLE t1;
CREATE TABLE t1
(s1 CHAR(5) COLLATE latin1_german1_ci,
s2 CHAR(5) COLLATE latin1_swedish_ci,
s3 CHAR(5) COLLATE latin1_bin);
INSERT INTO t1 VALUES ('a','A','A');
--error 1267
SELECT * FROM t1 WHERE s1 = s2;
SELECT * FROM t1 WHERE s1 = s3;
SELECT * FROM t1 WHERE s2 = s3;
DROP TABLE t1;
#
# Test that optimizer doesn't use indexes with wrong collation
#
SET NAMES latin1;
CREATE TABLE t1
(s1 char(10) COLLATE latin1_german1_ci,
s2 char(10) COLLATE latin1_swedish_ci,
KEY(s1),
KEY(s2));
INSERT INTO t1 VALUES ('a','a');
INSERT INTO t1 VALUES ('b','b');
INSERT INTO t1 VALUES ('c','c');
INSERT INTO t1 VALUES ('d','d');
INSERT INTO t1 VALUES ('e','e');
INSERT INTO t1 VALUES ('f','f');
INSERT INTO t1 VALUES ('g','g');
INSERT INTO t1 VALUES ('h','h');
INSERT INTO t1 VALUES ('i','i');
INSERT INTO t1 VALUES ('j','j');
EXPLAIN SELECT * FROM t1 WHERE s1='a';
EXPLAIN SELECT * FROM t1 WHERE s2='a';
EXPLAIN SELECT * FROM t1 WHERE s1='a' COLLATE latin1_german1_ci;
EXPLAIN SELECT * FROM t1 WHERE s2='a' COLLATE latin1_german1_ci;
EXPLAIN SELECT * FROM t1 WHERE s1 BETWEEN 'a' AND 'b' COLLATE latin1_german1_ci;
EXPLAIN SELECT * FROM t1 WHERE s2 BETWEEN 'a' AND 'b' COLLATE latin1_german1_ci;
EXPLAIN SELECT * FROM t1 WHERE s1 IN ('a','b' COLLATE latin1_german1_ci);
EXPLAIN SELECT * FROM t1 WHERE s2 IN ('a','b' COLLATE latin1_german1_ci);
EXPLAIN SELECT * FROM t1 WHERE s1 LIKE 'a' COLLATE latin1_german1_ci;
EXPLAIN SELECT * FROM t1 WHERE s2 LIKE 'a' COLLATE latin1_german1_ci;
DROP TABLE t1;
# End of 4.1 tests
#
# Bug#29261: Sort order of the collation wasn't used when comparing trailing
# spaces.
#
create table t1(f1 varchar(10) character set latin2 collate latin2_hungarian_ci, key(f1));
insert into t1 set f1=0x3F3F9DC73F;
insert into t1 set f1=0x3F3F1E563F;
insert into t1 set f1=0x3F3F;
drop table t1;
#
# Bug#29461: Sort order of the collation wasn't used when comparing characters
# with the space character.
#
create table t1 (a varchar(2) character set latin7 collate latin7_general_ci,key(a));
insert into t1 set a=0x4c20;
insert into t1 set a=0x6c;
insert into t1 set a=0x4c98;
drop table t1;
SET STORAGE_ENGINE='tokudb';
-- source include/have_cp1250_ch.inc
--disable_warnings
drop table if exists t1;
--enable_warnings
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
SHOW COLLATION LIKE 'cp1250_czech_cs';
SET @test_character_set= 'cp1250';
SET @test_collation= 'cp1250_general_ci';
-- source include/ctype_common.inc
SET @test_character_set= 'cp1250';
SET @test_collation= 'cp1250_czech_cs';
-- source include/ctype_common.inc
#
# Bugs: #8840: Empty string comparison and character set 'cp1250'
#
CREATE TABLE t1 (a char(16)) character set cp1250 collate cp1250_czech_cs;
INSERT INTO t1 VALUES ('');
SELECT a, length(a), a='', a=' ', a=' ' FROM t1;
DROP TABLE t1;
#
# Bug#9759 Empty result with 'LIKE' and cp1250_czech_cs
#
CREATE TABLE t1 (
popisek varchar(30) collate cp1250_general_ci NOT NULL default '',
PRIMARY KEY (`popisek`)
);
INSERT INTO t1 VALUES ('2005-01-1');
SELECT * FROM t1 WHERE popisek = '2005-01-1';
SELECT * FROM t1 WHERE popisek LIKE '2005-01-1';
drop table t1;
#
# Bug#13347: empty result from query with like and cp1250 charset
#
set names cp1250;
CREATE TABLE t1
(
id INT AUTO_INCREMENT PRIMARY KEY,
str VARCHAR(32) CHARACTER SET cp1250 COLLATE cp1250_czech_cs NOT NULL default '',
UNIQUE KEY (str)
);
INSERT INTO t1 VALUES (NULL, 'a');
INSERT INTO t1 VALUES (NULL, 'aa');
INSERT INTO t1 VALUES (NULL, 'aaa');
INSERT INTO t1 VALUES (NULL, 'aaaa');
INSERT INTO t1 VALUES (NULL, 'aaaaa');
INSERT INTO t1 VALUES (NULL, 'aaaaaa');
INSERT INTO t1 VALUES (NULL, 'aaaaaaa');
select * from t1 where str like 'aa%';
drop table t1;
#
# Bug#19741 segfault with cp1250 charset + like + primary key + 64bit os
#
set names cp1250;
create table t1 (a varchar(15) collate cp1250_czech_cs NOT NULL, primary key(a));
insert into t1 values("abcdefgh");
insert into t1 values("");
select a from t1 where a like "abcdefgh";
drop table t1;
# End of 4.1 tests
# Test of charset cp1251
SET STORAGE_ENGINE='tokudb';
--disable_warnings
drop table if exists t1;
--enable_warnings
SET NAMES cp1251;
#
# Test problem with LEFT() (Bug #514)
#
create table t1 (a varchar(10) not null) character set cp1251;
insert into t1 values ("a"),("ab"),("abc");
select * from t1;
select a, left(a,1) as b from t1;
select a, left(a,1) as b from t1 group by a;
SELECT DISTINCT RIGHT(a,1) from t1;
drop table t1;
#
# Test of binary and upper/lower
#
create table t1 (a char(3) binary, b binary(3)) character set cp1251;
insert into t1 values ('aaa','bbb'),('AAA','BBB');
select upper(a),upper(b) from t1;
select lower(a),lower(b) from t1;
select * from t1 where upper(a)='AAA';
select * from t1 where lower(a)='aaa';
select * from t1 where upper(b)='BBB';
select * from t1 where lower(b)='bbb';
select charset(a), charset(b), charset(binary 'ccc') from t1 limit 1;
select collation(a), collation(b), collation(binary 'ccc') from t1 limit 1;
drop table t1;
# Test for BUG#8560
create table t1 (
a varchar(16) character set cp1251 collate cp1251_bin not null,
b int(10) default null,
primary key(a)
) charset=cp1251;
insert into t1 (a) values ('air'),
('we'),('g'),('we_toshko'), ('s0urce'),('we_ivo'),('we_iliyan'),
('we_martin'),('vw_grado'),('vw_vasko'),('tn_vili'),('tn_kalina'),
('tn_fakira'),('vw_silvia'),('vw_starshi'),('vw_geo'),('vw_b0x1');
select * from t1 where a like 'we_%';
drop table t1;
# End of 4.1 tests
SET STORAGE_ENGINE='tokudb';
--disable_warnings
drop table if exists t1;
--enable_warnings
# check 0x00 padding
create table t1 (s1 binary(3));
insert into t1 values (0x61), (0x6120), (0x612020);
select hex(s1) from t1;
drop table t1;
# check that 0x00 is not stripped in val_str
create table t1 (s1 binary(2), s2 varbinary(2));
insert into t1 values (0x4100,0x4100);
select length(concat('*',s1,'*',s2,'*')) from t1;
delete from t1;
insert into t1 values (0x4120,0x4120);
select length(concat('*',s1,'*',s2,'*')) from t1;
drop table t1;
# check that trailing 0x00 and 0x20 do matter on comparison
create table t1 (s1 varbinary(20), s2 varbinary(20));
show create table t1;
insert into t1 values (0x41,0x4100),(0x41,0x4120),(0x4100,0x4120);
select hex(s1), hex(s2) from t1;
select count(*) from t1 where s1 < s2;
drop table t1;
# check that trailing 0x00 do matter on filesort
create table t1 (s1 varbinary(2), s2 varchar(1));
insert into t1 values (0x41,'a'), (0x4100,'b'), (0x41,'c'), (0x4100,'d');
select hex(s1),s2 from t1 order by s1,s2;
drop table t1;
# check that 0x01 is padded to 0x0100 and thus we get a duplicate value
create table t1 (s1 binary(2) primary key);
insert into t1 values (0x01);
insert into t1 values (0x0120);
--error ER_DUP_ENTRY
insert into t1 values (0x0100);
select hex(s1) from t1 order by s1;
# check index search
select hex(s1) from t1 where s1=0x01;
select hex(s1) from t1 where s1=0x0120;
select hex(s1) from t1 where s1=0x0100;
select count(distinct s1) from t1;
alter table t1 drop primary key;
# check non-indexed search
select hex(s1) from t1 where s1=0x01;
select hex(s1) from t1 where s1=0x0120;
select hex(s1) from t1 where s1=0x0100;
select count(distinct s1) from t1;
drop table t1;
# check that 0x01 is not padded, and all three values are unique
create table t1 (s1 varbinary(2) primary key);
insert into t1 values (0x01);
insert into t1 values (0x0120);
insert into t1 values (0x0100);
select hex(s1) from t1 order by s1;
# check index search
select hex(s1) from t1 where s1=0x01;
select hex(s1) from t1 where s1=0x0120;
select hex(s1) from t1 where s1=0x0100;
select count(distinct s1) from t1;
alter table t1 drop primary key;
# check non-indexed search
select hex(s1) from t1 where s1=0x01;
select hex(s1) from t1 where s1=0x0120;
select hex(s1) from t1 where s1=0x0100;
select count(distinct s1) from t1;
drop table t1;
# check that cast appends trailing zeros
select hex(cast(0x10 as binary(2)));
#
# Bug #14299: BINARY space truncation should cause warning or error
#
create table t1 (b binary(2), vb varbinary(2));
insert into t1 values(0x4120, 0x4120);
insert into t1 values(0x412020, 0x412020);
drop table t1;
create table t1 (c char(2), vc varchar(2));
insert into t1 values(0x4120, 0x4120);
insert into t1 values(0x412020, 0x412020);
drop table t1;
set @old_sql_mode= @@sql_mode, sql_mode= 'traditional';
create table t1 (b binary(2), vb varbinary(2));
insert into t1 values(0x4120, 0x4120);
--error ER_DATA_TOO_LONG
insert into t1 values(0x412020, NULL);
--error ER_DATA_TOO_LONG
insert into t1 values(NULL, 0x412020);
drop table t1;
set @@sql_mode= @old_sql_mode;
#
# Bug#14171: Wrong default value for a BINARY field
#
create table t1(f1 int, f2 binary(2) not null, f3 char(2) not null);
insert into t1 set f1=1;
select hex(f2), hex(f3) from t1;
drop table t1;
--echo End of 5.0 tests
SET STORAGE_ENGINE='tokudb';
#
# testing of the BIT column type
#
select 0 + b'1';
select 0 + b'0';
select 0 + b'000001';
select 0 + b'000011';
select 0 + b'000101';
select 0 + b'000000';
select 0 + b'10000000';
select 0 + b'11111111';
select 0 + b'10000001';
select 0 + b'1000000000000000';
select 0 + b'1111111111111111';
select 0 + b'1000000000000001';
--disable_warnings
drop table if exists t1,t2;
--enable_warnings
--error 1439
create table t1 (a bit(65));
create table t1 (a bit(0));
show create table t1;
drop table t1;
create table t1 (a bit(64));
insert into t1 values
(b'1111111111111111111111111111111111111111111111111111111111111111'),
(b'1000000000000000000000000000000000000000000000000000000000000000'),
(b'0000000000000000000000000000000000000000000000000000000000000001'),
(b'1010101010101010101010101010101010101010101010101010101010101010'),
(b'0101010101010101010101010101010101010101010101010101010101010101');
select hex(a) from t1;
drop table t1;
create table t1 (a bit);
insert into t1 values (b'0'), (b'1'), (b'000'), (b'100'), (b'001');
select hex(a) from t1;
--error ER_DUP_KEY
alter table t1 add unique (a);
drop table t1;
create table t1 (a bit(2));
insert into t1 values (b'00'), (b'01'), (b'10'), (b'100');
select a+0 from t1;
alter table t1 add key (a);
explain select a+0 from t1;
select a+0 from t1;
drop table t1;
create table t1 (a bit(7), b bit(9), key(a, b));
insert into t1 values
(94, 46), (31, 438), (61, 152), (78, 123), (88, 411), (122, 118), (0, 177),
(75, 42), (108, 67), (79, 349), (59, 188), (68, 206), (49, 345), (118, 380),
(111, 368), (94, 468), (56, 379), (77, 133), (29, 399), (9, 363), (23, 36),
(116, 390), (119, 368), (87, 351), (123, 411), (24, 398), (34, 202), (28, 499),
(30, 83), (5, 178), (60, 343), (4, 245), (104, 280), (106, 446), (127, 403),
(44, 307), (68, 454), (57, 135);
explain select a+0 from t1;
select a+0 from t1;
explain select b+0 from t1;
select b+0 from t1;
explain select a+0, b+0 from t1;
select a+0, b+0 from t1;
explain select a+0, b+0 from t1 where a > 40 and b > 200 order by 1;
select a+0, b+0 from t1 where a > 40 and b > 200 order by 1;
explain select a+0, b+0 from t1 where a > 40 and a < 70 order by 2;
select a+0, b+0 from t1 where a > 40 and a < 70 order by 2;
set @@max_length_for_sort_data=0;
select a+0, b+0 from t1 where a > 40 and a < 70 order by 2;
select hex(min(a)) from t1;
select hex(min(b)) from t1;
select hex(min(a)), hex(max(a)), hex(min(b)), hex(max(b)) from t1;
drop table t1;
create table t1 (a int not null, b bit, c bit(9), key(a, b, c));
insert into t1 values
(4, NULL, 1), (4, 0, 3), (2, 1, 4), (1, 1, 100), (4, 0, 23), (4, 0, 54),
(56, 0, 22), (4, 1, 100), (23, 0, 1), (4, 0, 34);
select a+0, b+0, c+0 from t1;
select hex(min(b)) from t1 where a = 4;
select hex(min(c)) from t1 where a = 4 and b = 0;
select hex(max(b)) from t1;
select a+0, b+0, c+0 from t1 where a = 4 and b = 0 limit 2;
select a+0, b+0, c+0 from t1 where a = 4 and b = 1;
select a+0, b+0, c+0 from t1 where a = 4 and b = 1 and c=100;
select a+0, b+0, c+0 from t1 order by b desc;
select a+0, b+0, c+0 from t1 order by c;
drop table t1;
create table t1(a bit(2), b bit(2));
insert into t1 (a) values (0x01), (0x03), (0x02);
update t1 set b= concat(a);
select a+0, b+0 from t1;
drop table t1;
# Some magic numbers
create table t1 (a bit(7), key(a));
insert into t1 values (44), (57);
select a+0 from t1;
drop table t1;
#
# Test conversion to and from strings
#
create table t1 (a bit(3), b bit(12));
insert into t1 values (7,(1<<12)-2), (0x01,0x01ff);
select hex(a),hex(b) from t1;
select hex(concat(a)),hex(concat(b)) from t1;
drop table t1;
#
# Bug #9571: problem with primary key creation
#
create table t1(a int, b bit not null);
alter table t1 add primary key (a);
drop table t1;
#
# myisam <-> heap
#
create table t1 (a bit(19), b bit(5));
insert into t1 values (1000, 10), (3, 8), (200, 6), (2303, 2), (12345, 4), (1, 0);
select a+0, b+0 from t1;
alter table t1 engine=heap;
select a+0, b+0 from t1;
alter table t1 add key(a, b);
select a+0, b+0 from t1;
alter table t1 engine=myisam;
select a+0, b+0 from t1;
create table t2 engine=heap select * from t1;
select a+0, b+0 from t2;
drop table t1;
create table t1 select * from t2;
select a+0, b+0 from t1;
drop table t1, t2;
#
# Bug #10179: problem with NULLs and default values
#
create table t1 (a int, b time, c tinyint, d bool, e char(10), f bit(1),
g bit(1) NOT NULL default 1, h char(1) default 'a');
insert into t1 set a=1;
select hex(g), h from t1;
drop table t1;
create table t1 (a int, b time, c tinyint, d bool, e char(10), f bit(1),
g bit(1) NOT NULL default 1);
insert into t1 set a=1;
select hex(g) from t1;
drop table t1;
create table t1 (a int, b time, c tinyint, d bool, e char(10), f bit(1),
h char(1) default 'a') engine=myisam;
insert into t1 set a=1;
select h from t1;
drop table t1;
#
# Bug #10539
#
create table t1 (a bit(8)) engine=heap;
insert into t1 values ('1111100000');
select a+0 from t1;
drop table t1;
#
# Bug #11091: union
#
create table t1 (a bit(7));
insert into t1 values (120), (0), (111);
select a+0 from t1 union select a+0 from t1;
select a+0 from t1 union select NULL;
select NULL union select a+0 from t1;
create table t2 select a from t1 union select a from t1;
select a+0 from t2;
show create table t2;
drop table t1, t2;
#
# Bug #11572: view
#
create table t1 (id1 int(11), b1 bit(1));
create table t2 (id2 int(11), b2 bit(1));
insert into t1 values (1, 1), (2, 0), (3, 1);
insert into t2 values (2, 1), (3, 0), (4, 0);
create algorithm=undefined view v1 as
select b1+0, b2+0 from t1, t2 where id1 = id2 and b1 = 0
union
select b1+0, b2+0 from t1, t2 where id1 = id2 and b2 = 1;
select * from v1;
drop table t1, t2;
drop view v1;
#
# Bug #10617: bulk-insert
#
create table t1(a bit(4));
insert into t1(a) values (1), (2), (5), (4), (3);
insert into t1 select * from t1;
select a+0 from t1;
drop table t1;
#
# join
#
create table t1 (a1 int(11), b1 bit(2));
create table t2 (a2 int(11), b2 bit(2));
insert into t1 values (1, 1), (2, 0), (3, 1), (4, 2);
insert into t2 values (2, 1), (3, 0), (4, 1), (5, 2);
select a1, a2, b1+0, b2+0 from t1 join t2 on a1 = a2;
select a1, a2, b1+0, b2+0 from t1 join t2 on a1 = a2 order by a1;
select a1, a2, b1+0, b2+0 from t1 join t2 on b1 = b2;
select sum(a1), b1+0, b2+0 from t1 join t2 on b1 = b2 group by b1 order by 1;
select 1 from t1 join t2 on b1 = b2 group by b1 order by 1;
select b1+0,sum(b1), sum(b2) from t1 join t2 on b1 = b2 group by b1 order by 1;
drop table t1, t2;
#
# Bug #13601: Wrong field length reported for BIT fields
#
create table t1 (a bit(7));
insert into t1 values (0x60);
--enable_metadata
select * from t1;
--disable_metadata
drop table t1;
#
# Bug#15583: BIN()/OCT()/CONV() do not work with BIT values
#
create table bug15583(b BIT(8), n INT);
insert into bug15583 values(128, 128);
insert into bug15583 values(null, null);
insert into bug15583 values(0, 0);
insert into bug15583 values(255, 255);
select hex(b), bin(b), oct(b), hex(n), bin(n), oct(n) from bug15583;
select hex(b)=hex(n) as should_be_onetrue, bin(b)=bin(n) as should_be_onetrue, oct(b)=oct(n) as should_be_onetrue from bug15583;
select hex(b + 0), bin(b + 0), oct(b + 0), hex(n), bin(n), oct(n) from bug15583;
select conv(b, 10, 2), conv(b + 0, 10, 2) from bug15583;
drop table bug15583;
#
# Bug #22271: data casting may affect data stored in the next column(s?)
#
create table t1(a bit(1), b smallint unsigned);
insert into t1 (b, a) values ('2', '1');
select hex(a), b from t1;
drop table t1;
#
# Bug #30219: GROUP BY a column of the BIT type
#
CREATE TABLE t1 (b BIT(2), a VARCHAR(5));
INSERT INTO t1 (b, a) VALUES (1, "x"), (3, "zz"), (0, "y"), (3, "z");
SELECT b+0, COUNT(DISTINCT a) FROM t1 GROUP BY b;
DROP TABLE t1;
CREATE TABLE t1 (a CHAR(5), b BIT(2));
INSERT INTO t1 (b, a) VALUES (1, "x"), (3, "zz"), (0, "y"), (3, "z");
SELECT b+0, COUNT(DISTINCT a) FROM t1 GROUP BY b;
DROP TABLE t1;
CREATE TABLE t1 (a INT, b BIT(2));
INSERT INTO t1 (b, a) VALUES (1, 1), (3, 2), (0, 3), (3, 4);
SELECT b+0, COUNT(DISTINCT a) FROM t1 GROUP BY b;
DROP TABLE t1;
#
# Bug#30245: A wrong type of a BIT field is reported when grouped by it.
#
CREATE TABLE t1 (b BIT);
INSERT INTO t1 (b) VALUES (1), (0);
--enable_metadata
--replace_column 1 #
SELECT DISTINCT b FROM t1;
--replace_column 1 #
SELECT b FROM t1 GROUP BY b;
--disable_metadata
DROP TABLE t1;
#
# BUG#30324 Wrong query result for COUNT(DISTINCT(bit_column))
#
CREATE TABLE t1 (a int, b bit(2));
INSERT INTO t1 VALUES (3, 2), (2, 3), (2, 0), (3, 2), (3, 1);
SELECT COUNT(DISTINCT b) FROM t1 GROUP BY a;
DROP TABLE t1;
create table t2 (a int, b bit(2), c char(10));
INSERT INTO t2 VALUES (3, 2, 'two'), (2, 3, 'three'), (2, 0, 'zero'),
(3, 2, 'two'), (3, 1, 'one');
SELECT COUNT(DISTINCT b,c) FROM t2 GROUP BY a;
DROP TABLE t2;
#
# BUG#32556 assert in "using index for group-by" : is_last_prefix <= 0,
# file .\opt_range.cc
CREATE TABLE t1(a BIT(13), KEY(a));
--disable_warnings
INSERT INTO t1(a) VALUES
(65535),(65525),(65535),(65535),(65535),(65535),(65535),(65535),(65535),(65535);
--enable_warnings
EXPLAIN SELECT 1 FROM t1 GROUP BY a;
SELECT 1 FROM t1 GROUP BY a;
DROP TABLE t1;
--echo End of 5.0 tests
#
# Bug #28631: problem after alter
#
create table t1(a bit(7));
insert into t1 values(0x40);
alter table t1 modify column a bit(8);
select hex(a) from t1;
insert into t1 values(0x80);
select hex(a) from t1;
create index a on t1(a);
insert into t1 values(0x81);
select hex(a) from t1;
show create table t1;
drop table t1;
--echo End of 5.1 tests
# This test can't be run with running server (--extern) as this uses
# load_file() on a file in the tree.
#
set storage_engine='tokudb';
#
# Basic cleanup
#
--disable_warnings
drop table if exists t,t1,t2,t3,t4,t5,t6,t7;
--enable_warnings
#
# Check syntax for creating BLOB/TEXT
#
CREATE TABLE t1 (a blob, b text, c blob(250), d text(70000), e text(70000000));
show columns from t1;
# PS doesn't give errors on prepare yet
CREATE TABLE t2 (a char(255), b varbinary(70000), c varchar(70000000));
CREATE TABLE t4 (c varchar(65530) character set utf8 not null);
show columns from t2;
create table t3 (a long, b long byte);
show create TABLE t3;
show create TABLE t4;
drop table t1,t2,t3,t4;
#
# Check errors with blob
#
--error 1074
CREATE TABLE t1 (a char(257) default "hello");
--error 1074
CREATE TABLE t2 (a char(256));
--error 1074
CREATE TABLE t1 (a varchar(70000) default "hello");
--error 1101
CREATE TABLE t2 (a blob default "hello");
# Safety to be able to continue with other tests if above fails
--disable_warnings
drop table if exists t1,t2;
--enable_warnings
#
# test of full join with blob
#
create table t1 (nr int(5) not null auto_increment,b blob,str char(10), primary key (nr));
insert into t1 values (null,"a","A");
insert into t1 values (null,"bbb","BBB");
insert into t1 values (null,"ccc","CCC");
select last_insert_id();
select * from t1,t1 as t2;
drop table t1;
#
# Test of changing TEXT column
#
create table t1 (a text);
insert into t1 values ('where');
update t1 set a='Where';
select * from t1;
drop table t1;
#
# test of blob, text, char and varbinary
#
create table t1 (t text,c char(10),b blob, d varbinary(10));
insert into t1 values (NULL,NULL,NULL,NULL);
insert into t1 values ("","","","");
insert into t1 values ("hello","hello","hello","hello");
insert into t1 values ("HELLO","HELLO","HELLO","HELLO");
insert into t1 values ("HELLO MY","HELLO MY","HELLO MY","HELLO MY");
insert into t1 values ("a","a","a","a");
insert into t1 values (1,1,1,1);
insert into t1 values (NULL,NULL,NULL,NULL);
update t1 set c="",b=null where c="1";
lock tables t1 READ;
# We mask out the Privileges column because it differs for embedded server
--replace_column 8 #
show full fields from t1;
lock tables t1 WRITE;
--replace_column 8 #
show full fields from t1;
unlock tables;
select t from t1 where t like "hello";
select c from t1 where c like "hello";
select b from t1 where b like "hello";
select d from t1 where d like "hello";
select c from t1 having c like "hello";
select d from t1 having d like "hello";
select t from t1 where t like "%HELLO%";
select c from t1 where c like "%HELLO%";
select b from t1 where b like "%HELLO%";
select d from t1 where d like "%HELLO%";
select c from t1 having c like "%HELLO%";
select d from t1 having d like "%HELLO%";
select d from t1 having d like "%HE%LLO%";
select t from t1 order by t;
select c from t1 order by c;
select b from t1 order by b;
select d from t1 order by d;
select distinct t from t1;
select distinct b from t1;
select distinct t from t1 order by t;
select distinct b from t1 order by b;
select t from t1 group by t;
select b from t1 group by b;
set option sql_big_tables=1;
select distinct t from t1;
select distinct b from t1;
select distinct t from t1 order by t;
select distinct b from t1 order by b;
select distinct c from t1;
select distinct d from t1;
select distinct c from t1 order by c;
select distinct d from t1 order by d;
select c from t1 group by c;
select d from t1 group by d;
set option sql_big_tables=0;
select distinct * from t1;
select t,count(*) from t1 group by t;
select b,count(*) from t1 group by b;
select c,count(*) from t1 group by c;
select d,count(*) from t1 group by d;
drop table t1;
create table t1 (a text, unique (a(2100))); # should give an error
drop table t1;
create table t1 (a text, key (a(2100))); # key is auto-truncated
show create table t1;
drop table t1;
#
# Test of join with blobs and min
#
CREATE TABLE t1 (
t1_id bigint(21) NOT NULL auto_increment,
_field_72 varchar(128) DEFAULT '' NOT NULL,
_field_95 varchar(32),
_field_115 tinyint(4) DEFAULT '0' NOT NULL,
_field_122 tinyint(4) DEFAULT '0' NOT NULL,
_field_126 tinyint(4),
_field_134 tinyint(4),
PRIMARY KEY (t1_id),
UNIQUE _field_72 (_field_72),
KEY _field_115 (_field_115),
KEY _field_122 (_field_122)
);
INSERT INTO t1 VALUES (1,'admin','21232f297a57a5a743894a0e4a801fc3',0,1,NULL,NULL);
INSERT INTO t1 VALUES (2,'hroberts','7415275a8c95952901e42b13a6b78566',0,1,NULL,NULL);
INSERT INTO t1 VALUES (3,'guest','d41d8cd98f00b204e9800998ecf8427e',1,0,NULL,NULL);
CREATE TABLE t2 (
seq_0_id bigint(21) DEFAULT '0' NOT NULL,
seq_1_id bigint(21) DEFAULT '0' NOT NULL,
PRIMARY KEY (seq_0_id,seq_1_id)
);
INSERT INTO t2 VALUES (1,1);
INSERT INTO t2 VALUES (2,1);
INSERT INTO t2 VALUES (2,2);
CREATE TABLE t3 (
t3_id bigint(21) NOT NULL auto_increment,
_field_131 varchar(128),
_field_133 tinyint(4) DEFAULT '0' NOT NULL,
_field_135 datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
_field_137 tinyint(4),
_field_139 datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
_field_140 blob,
_field_142 tinyint(4) DEFAULT '0' NOT NULL,
_field_145 tinyint(4) DEFAULT '0' NOT NULL,
_field_148 tinyint(4) DEFAULT '0' NOT NULL,
PRIMARY KEY (t3_id),
KEY _field_133 (_field_133),
KEY _field_135 (_field_135),
KEY _field_139 (_field_139),
KEY _field_142 (_field_142),
KEY _field_145 (_field_145),
KEY _field_148 (_field_148)
);
INSERT INTO t3 VALUES (1,'test job 1',0,'0000-00-00 00:00:00',0,'1999-02-25 22:43:32','test\r\njob\r\n1',0,0,0);
INSERT INTO t3 VALUES (2,'test job 2',0,'0000-00-00 00:00:00',0,'1999-02-26 21:08:04','',0,0,0);
CREATE TABLE t4 (
seq_0_id bigint(21) DEFAULT '0' NOT NULL,
seq_1_id bigint(21) DEFAULT '0' NOT NULL,
PRIMARY KEY (seq_0_id,seq_1_id)
);
INSERT INTO t4 VALUES (1,1);
INSERT INTO t4 VALUES (2,1);
CREATE TABLE t5 (
t5_id bigint(21) NOT NULL auto_increment,
_field_149 tinyint(4),
_field_156 varchar(128) DEFAULT '' NOT NULL,
_field_157 varchar(128) DEFAULT '' NOT NULL,
_field_158 varchar(128) DEFAULT '' NOT NULL,
_field_159 varchar(128) DEFAULT '' NOT NULL,
_field_160 varchar(128) DEFAULT '' NOT NULL,
_field_161 varchar(128) DEFAULT '' NOT NULL,
PRIMARY KEY (t5_id),
KEY _field_156 (_field_156),
KEY _field_157 (_field_157),
KEY _field_158 (_field_158),
KEY _field_159 (_field_159),
KEY _field_160 (_field_160),
KEY _field_161 (_field_161)
);
INSERT INTO t5 VALUES (1,0,'tomato','','','','','');
INSERT INTO t5 VALUES (2,0,'cilantro','','','','','');
CREATE TABLE t6 (
seq_0_id bigint(21) DEFAULT '0' NOT NULL,
seq_1_id bigint(21) DEFAULT '0' NOT NULL,
PRIMARY KEY (seq_0_id,seq_1_id)
);
INSERT INTO t6 VALUES (1,1);
INSERT INTO t6 VALUES (1,2);
INSERT INTO t6 VALUES (2,2);
CREATE TABLE t7 (
t7_id bigint(21) NOT NULL auto_increment,
_field_143 tinyint(4),
_field_165 varchar(32),
_field_166 smallint(6) DEFAULT '0' NOT NULL,
PRIMARY KEY (t7_id),
KEY _field_166 (_field_166)
);
INSERT INTO t7 VALUES (1,0,'High',1);
INSERT INTO t7 VALUES (2,0,'Medium',2);
INSERT INTO t7 VALUES (3,0,'Low',3);
select replace(t3._field_140, "\r","^M"),t3_id,min(t3._field_131), min(t3._field_135), min(t3._field_139), min(t3._field_137), min(link_alias_142._field_165), min(link_alias_133._field_72), min(t3._field_145), min(link_alias_148._field_156), replace(min(t3._field_140), "\r","^M"),t3.t3_id from t3 left join t4 on t4.seq_0_id = t3.t3_id left join t7 link_alias_142 on t4.seq_1_id = link_alias_142.t7_id left join t6 on t6.seq_0_id = t3.t3_id left join t1 link_alias_133 on t6.seq_1_id = link_alias_133.t1_id left join t2 on t2.seq_0_id = t3.t3_id left join t5 link_alias_148 on t2.seq_1_id = link_alias_148.t5_id where t3.t3_id in (1) group by t3.t3_id order by link_alias_142._field_166, _field_139, link_alias_133._field_72, _field_135, link_alias_148._field_156;
drop table t1,t2,t3,t4,t5,t6,t7;
#
# Test of reverse with empty blob
#
create table t1 (a blob);
insert into t1 values ("empty"),("");
select a,reverse(a) from t1;
drop table t1;
#
# Test of BLOB:s with NULL keys.
#
create table t1 (a blob, key (a(10)));
insert into t1 values ("bye"),("hello"),("hello"),("hello word");
select * from t1 where a like "hello%";
drop table t1;
#
# Test of found bug in group on text key
#
CREATE TABLE t1 (
f1 int(11) DEFAULT '0' NOT NULL,
f2 varchar(16) DEFAULT '' NOT NULL,
f5 text,
KEY index_name (f1,f2,f5(16))
);
INSERT INTO t1 VALUES (0,'traktor','1111111111111');
INSERT INTO t1 VALUES (1,'traktor','1111111111111111111111111');
select count(*) from t1 where f2='traktor';
drop table t1;
#
# Test of found bug when blob is first key part
#
create table t1 (foobar tinyblob not null, boggle smallint not null, key (foobar(32), boggle));
insert into t1 values ('fish', 10),('bear', 20);
select foobar, boggle from t1 where foobar = 'fish';
select foobar, boggle from t1 where foobar = 'fish' and boggle = 10;
drop table t1;
#
# Test blob's with end space (Bug #1651)
# This is a bit changed since we now have true varchar
#
create table t1 (id integer primary key auto_increment, txt text not null, unique index txt_index (txt (20)));
--error ER_DUP_ENTRY
insert into t1 (txt) values ('Chevy'), ('Chevy ');
--error ER_DUP_ENTRY
insert into t1 (txt) values ('Chevy'), ('CHEVY');
#alter table t1 drop index txt_index, add index txt_index (txt(20));
insert into t1 (txt) values ('Chevy ');
select * from t1 where txt='Chevy';
select * from t1 where txt='Chevy ';
select * from t1 where txt='Chevy ' or txt='Chevy';
select * from t1 where txt='Chevy' or txt='Chevy ';
select * from t1 where id='1' or id='2';
insert into t1 (txt) values('Ford');
select * from t1 where txt='Chevy' or txt='Chevy ' or txt='Ford';
select * from t1 where txt='Chevy' or txt='Chevy ';
select * from t1 where txt='Chevy' or txt='Chevy ' or txt=' Chevy';
select * from t1 where txt in ('Chevy ','Chevy');
select * from t1 where txt in ('Chevy');
select * from t1 where txt between 'Chevy' and 'Chevy';
select * from t1 where txt between 'Chevy' and 'Chevy' or txt='Chevy ';
select * from t1 where txt between 'Chevy' and 'Chevy ';
select * from t1 where txt < 'Chevy ';
select * from t1 where txt <= 'Chevy';
select * from t1 where txt > 'Chevy';
select * from t1 where txt >= 'Chevy';
drop table t1;
create table t1 (id integer primary key auto_increment, txt text, index txt_index (txt (20)));
insert into t1 (txt) values ('Chevy'), ('Chevy '), (NULL);
select * from t1 where txt='Chevy' or txt is NULL;
explain select * from t1 where txt='Chevy' or txt is NULL;
select * from t1 where txt='Chevy ';
select * from t1 where txt='Chevy ' or txt='Chevy';
select * from t1 where txt='Chevy' or txt='Chevy ';
select * from t1 where id='1' or id='2';
insert into t1 (txt) values('Ford');
select * from t1 where txt='Chevy' or txt='Chevy ' or txt='Ford';
select * from t1 where txt='Chevy' or txt='Chevy ';
select * from t1 where txt='Chevy' or txt='Chevy ' or txt=' Chevy';
select * from t1 where txt in ('Chevy ','Chevy');
select * from t1 where txt in ('Chevy');
select * from t1 where txt between 'Chevy' and 'Chevy';
select * from t1 where txt between 'Chevy' and 'Chevy' or txt='Chevy ';
select * from t1 where txt between 'Chevy' and 'Chevy ';
select * from t1 where txt < 'Chevy ';
select * from t1 where txt < 'Chevy ' or txt is NULL;
select * from t1 where txt <= 'Chevy';
select * from t1 where txt > 'Chevy';
select * from t1 where txt >= 'Chevy';
alter table t1 modify column txt blob;
explain select * from t1 where txt='Chevy' or txt is NULL;
select * from t1 where txt='Chevy' or txt is NULL;
explain select * from t1 where txt='Chevy' or txt is NULL order by txt;
select * from t1 where txt='Chevy' or txt is NULL order by txt;
drop table t1;
CREATE TABLE t1 ( i int(11) NOT NULL default '0', c text NOT NULL, d varchar(1) NOT NULL DEFAULT ' ', PRIMARY KEY (i), KEY (c(1),d));
INSERT t1 (i, c) VALUES (1,''),(2,''),(3,'asdfh'),(4,'');
select max(i) from t1 where c = '';
drop table t1;
# End of 4.1 tests
#
# Bug#11657: Creation of secondary index fails
#
create table t1 (a int, b int, c tinyblob, d int, e int);
alter table t1 add primary key (a,b,c(255),d);
alter table t1 add key (a,b,d,e);
show create table t1;
drop table t1;
#
# Test that blob's and varbinary are sorted according to length
#
CREATE table t1 (a blob);
insert into t1 values ('b'),('a\0'),('a'),('a '),('aa'),(NULL);
select hex(a) from t1 order by a;
select hex(concat(a,'\0')) as b from t1 order by concat(a,'\0');
alter table t1 modify a varbinary(5);
select hex(a) from t1 order by a;
select hex(concat(a,'\0')) as b from t1 order by concat(a,'\0');
alter table t1 modify a char(5);
select hex(a) from t1 order by a;
select hex(concat(a,'\0')) as b from t1 order by concat(a,'\0');
alter table t1 modify a binary(5);
select hex(a) from t1 order by a;
select hex(concat(a,'\0')) as b from t1 order by concat(a,'\0');
drop table t1;
#
# Bug #19489: Inconsistent support for DEFAULT in TEXT columns
#
create table t1 (a text default '');
show create table t1;
insert into t1 values (default);
select * from t1;
drop table t1;
set @@sql_mode='TRADITIONAL';
--error ER_BLOB_CANT_HAVE_DEFAULT
create table t1 (a text default '');
set @@sql_mode='';
#
# Bug #32282: TEXT silently truncates when value is exactly 65536 bytes
#
CREATE TABLE t (c TEXT CHARSET ASCII);
INSERT INTO t (c) VALUES (REPEAT('1',65537));
INSERT INTO t (c) VALUES (REPEAT('2',65536));
INSERT INTO t (c) VALUES (REPEAT('3',65535));
SELECT LENGTH(c), CHAR_LENGTH(c) FROM t;
DROP TABLE t;
# Bug#15776: 32-bit signed int used for length of blob
# """LONGBLOB: A BLOB column with a maximum length of 4,294,967,295 or 4GB."""
#
# Conditions should be in this order:
# A size is not in the allowed bounds.
# If the type is char-ish AND size is within the max blob size:
# raise ER_TOO_BIG_FIELDLENGTH (suggest using BLOB)
# If size is too small:
# raise ER_PARSE_ERROR
# raise ER_TOO_BIG_DISPLAYWIDTH
# BLOB and TEXT types
--disable_warnings
drop table if exists b15776;
--enable_warnings
create table b15776 (data blob(2147483647));
drop table b15776;
--error ER_PARSE_ERROR
create table b15776 (data blob(-1));
create table b15776 (data blob(2147483648));
drop table b15776;
create table b15776 (data blob(4294967294));
drop table b15776;
create table b15776 (data blob(4294967295));
drop table b15776;
--error ER_TOO_BIG_DISPLAYWIDTH
create table b15776 (data blob(4294967296));
CREATE TABLE b15776 (a blob(2147483647), b blob(2147483648), c blob(4294967295), a1 text(2147483647), b1 text(2147483648), c1 text(4294967295) );
show columns from b15776;
drop table b15776;
--error ER_TOO_BIG_DISPLAYWIDTH
CREATE TABLE b15776 (a blob(4294967296));
--error ER_TOO_BIG_DISPLAYWIDTH
CREATE TABLE b15776 (a text(4294967296));
--error ER_TOO_BIG_DISPLAYWIDTH
CREATE TABLE b15776 (a blob(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
--error ER_TOO_BIG_DISPLAYWIDTH
CREATE TABLE b15776 (a text(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
# Int types
# "Another extension is supported by MySQL for optionally specifying the
# display width of integer data types in parentheses following the base keyword
# for the type (for example, INT(4)). This optional display width is used to
# display integer values having a width less than the width specified for the
# column by left-padding them with spaces." § Numeric Types
CREATE TABLE b15776 (a int(0)); # 0 is special case, means default size
INSERT INTO b15776 values (NULL), (1), (42), (654);
SELECT * from b15776 ORDER BY a;
DROP TABLE b15776;
--error ER_PARSE_ERROR
CREATE TABLE b15776 (a int(-1));
CREATE TABLE b15776 (a int(255));
DROP TABLE b15776;
--error ER_TOO_BIG_DISPLAYWIDTH
CREATE TABLE b15776 (a int(256));
--error ER_PARSE_ERROR
CREATE TABLE b15776 (data blob(-1));
# Char types
# Recommend BLOB
--error ER_TOO_BIG_FIELDLENGTH
CREATE TABLE b15776 (a char(2147483647));
--error ER_TOO_BIG_FIELDLENGTH
CREATE TABLE b15776 (a char(2147483648));
--error ER_TOO_BIG_FIELDLENGTH
CREATE TABLE b15776 (a char(4294967295));
# Even BLOB won't hold
--error ER_TOO_BIG_DISPLAYWIDTH
CREATE TABLE b15776 (a char(4294967296));
# Other numeric-ish types
## For year, widths not "2" or "4" are silently rewritten to "4". But
## When we complain about it, we say that the max is 255. We may be
## talking about different things. It's confusing.
CREATE TABLE b15776 (a year(4294967295));
INSERT INTO b15776 VALUES (42);
SELECT * FROM b15776;
DROP TABLE b15776;
--error ER_TOO_BIG_DISPLAYWIDTH
CREATE TABLE b15776 (a year(4294967296));
CREATE TABLE b15776 (a year(0)); # 0 is special case, means default size
DROP TABLE b15776;
--error ER_PARSE_ERROR
CREATE TABLE b15776 (a year(-2));
## For timestamp, we silently rewrite widths to 14 or 19.
CREATE TABLE b15776 (a timestamp(4294967294));
DROP TABLE b15776;
CREATE TABLE b15776 (a timestamp(4294967295));
DROP TABLE b15776;
--error ER_TOO_BIG_DISPLAYWIDTH
CREATE TABLE b15776 (a timestamp(4294967296));
--error ER_PARSE_ERROR
CREATE TABLE b15776 (a timestamp(-1));
--error ER_PARSE_ERROR
CREATE TABLE b15776 (a timestamp(-2));
# We've already tested the case, but this should visually show that
# widths that are too large to be interpreted cause DISPLAYWIDTH errors.
--error ER_TOO_BIG_DISPLAYWIDTH
CREATE TABLE b15776 (a int(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
--error ER_TOO_BIG_DISPLAYWIDTH
CREATE TABLE b15776 (a char(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
--error ER_TOO_BIG_DISPLAYWIDTH
CREATE TABLE b15776 (a year(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
--error ER_TOO_BIG_DISPLAYWIDTH
CREATE TABLE b15776 (a timestamp(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
## Do not select, too much memory needed.
CREATE TABLE b15776 select cast(null as char(4294967295));
show columns from b15776;
drop table b15776;
CREATE TABLE b15776 select cast(null as nchar(4294967295));
show columns from b15776;
drop table b15776;
CREATE TABLE b15776 select cast(null as binary(4294967295));
show columns from b15776;
drop table b15776;
explain select cast(1 as char(4294967295));
explain select cast(1 as nchar(4294967295));
explain select cast(1 as binary(4294967295));
--error ER_TOO_BIG_DISPLAYWIDTH
explain select cast(1 as char(4294967296));
--error ER_TOO_BIG_DISPLAYWIDTH
explain select cast(1 as nchar(4294967296));
--error ER_TOO_BIG_DISPLAYWIDTH
explain select cast(1 as binary(4294967296));
--error ER_PARSE_ERROR
explain select cast(1 as decimal(-1));
explain select cast(1 as decimal(64, 30));
# It's not as important which errors are raised for these, since the
# limit is nowhere near 2**32. We may fix these eventually to take
# 4294967295 and still reject it because it's greater than 64 or 30,
# but that's not a high priority and the parser needn't worry about
# such a weird case.
--error ER_TOO_BIG_SCALE,ER_PARSE_ERROR
explain select cast(1 as decimal(64, 999999999999999999999999999999));
--error ER_TOO_BIG_PRECISION,ER_PARSE_ERROR
explain select cast(1 as decimal(4294967296));
--error ER_TOO_BIG_PRECISION,ER_PARSE_ERROR
explain select cast(1 as decimal(999999999999999999999999999999999999));
explain select convert(1, char(4294967295));
--error ER_TOO_BIG_DISPLAYWIDTH
explain select convert(1, char(4294967296));
--error ER_TOO_BIG_DISPLAYWIDTH
explain select convert(1, char(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
explain select convert(1, nchar(4294967295));
--error ER_TOO_BIG_DISPLAYWIDTH
explain select convert(1, nchar(4294967296));
--error ER_TOO_BIG_DISPLAYWIDTH
explain select convert(1, nchar(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
explain select convert(1, binary(4294967295));
--error ER_TOO_BIG_DISPLAYWIDTH
explain select convert(1, binary(4294967296));
--error ER_TOO_BIG_DISPLAYWIDTH
explain select convert(1, binary(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
--echo End of 5.0 tests
SET STORAGE_ENGINE='tokudb';
#
# test of problem with date fields
#
--disable_warnings
drop table if exists t1,t2;
--enable_warnings
create table t1 (a char(16), b date, c datetime);
insert into t1 SET a='test 2000-01-01', b='2000-01-01', c='2000-01-01';
select * from t1 where c = '2000-01-01';
select * from t1 where b = '2000-01-01';
drop table t1;
#
# problem with date conversions
#
CREATE TABLE t1 (name char(6),cdate date);
INSERT INTO t1 VALUES ('name1','1998-01-01');
INSERT INTO t1 VALUES ('name2','1998-01-01');
INSERT INTO t1 VALUES ('name1','1998-01-02');
INSERT INTO t1 VALUES ('name2','1998-01-02');
CREATE TABLE t2 (cdate date, note char(6));
INSERT INTO t2 VALUES ('1998-01-01','note01');
INSERT INTO t2 VALUES ('1998-01-02','note02');
select name,t1.cdate,note from t1,t2 where t1.cdate=t2.cdate and t1.cdate='1998-01-01';
drop table t1,t2;
#
# Date and BETWEEN
#
CREATE TABLE t1 ( datum DATE );
INSERT INTO t1 VALUES ( "2000-1-1" );
INSERT INTO t1 VALUES ( "2000-1-2" );
INSERT INTO t1 VALUES ( "2000-1-3" );
INSERT INTO t1 VALUES ( "2000-1-4" );
INSERT INTO t1 VALUES ( "2000-1-5" );
SELECT * FROM t1 WHERE datum BETWEEN cast("2000-1-2" as date) AND cast("2000-1-4" as date);
SELECT * FROM t1 WHERE datum BETWEEN cast("2000-1-2" as date) AND datum - INTERVAL 100 DAY;
DROP TABLE t1;
#
# test of max(date) and having
#
CREATE TABLE t1 (
user_id char(10),
summa int(11),
rdate date
);
INSERT INTO t1 VALUES ('aaa',100,'1998-01-01');
INSERT INTO t1 VALUES ('aaa',200,'1998-01-03');
INSERT INTO t1 VALUES ('bbb',50,'1998-01-02');
INSERT INTO t1 VALUES ('bbb',200,'1998-01-04');
select max(rdate) as s from t1 where rdate < '1998-01-03' having s> "1998-01-01";
select max(rdate) as s from t1 having s="1998-01-04";
select max(rdate+0) as s from t1 having s="19980104";
drop table t1;
#
# Test of date and not null
#
create table t1 (date date);
insert into t1 values ("2000-08-10"),("2000-08-11");
select date_add(date,INTERVAL 1 DAY),date_add(date,INTERVAL 1 SECOND) from t1;
drop table t1;
#
# Test problem with DATE_FORMAT
#
CREATE TABLE t1(AFIELD INT);
INSERT INTO t1 VALUES(1);
CREATE TABLE t2(GMT VARCHAR(32));
INSERT INTO t2 VALUES('GMT-0800');
SELECT DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ' , t2.GMT)) FROM t1, t2 GROUP BY t1.AFIELD;
INSERT INTO t1 VALUES(1);
SELECT DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ' , t2.GMT)), DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ' , t2.GMT)) FROM t1,t2 GROUP BY t1.AFIELD;
drop table t1,t2;
#
# Multiple SELECT DATE_FORMAT gave incorrect results (Bug #4036)
#
CREATE TABLE t1 (f1 time default NULL, f2 time default NULL);
INSERT INTO t1 (f1, f2) VALUES ('09:00', '12:00');
SELECT DATE_FORMAT(f1, "%l.%i %p") , DATE_FORMAT(f2, "%l.%i %p") FROM t1;
DROP TABLE t1;
#
# Bug 4937: different date -> string conversion when using SELECT ... UNION
# and INSERT ... SELECT ... UNION
#
CREATE TABLE t1 (f1 DATE);
CREATE TABLE t2 (f2 VARCHAR(8));
CREATE TABLE t3 (f2 CHAR(8));
INSERT INTO t1 VALUES ('1978-11-26');
INSERT INTO t2 SELECT f1+0 FROM t1;
INSERT INTO t2 SELECT f1+0 FROM t1 UNION SELECT f1+0 FROM t1;
INSERT INTO t3 SELECT f1+0 FROM t1;
INSERT INTO t3 SELECT f1+0 FROM t1 UNION SELECT f1+0 FROM t1;
SELECT * FROM t2;
SELECT * FROM t3;
DROP TABLE t1, t2, t3;
# Test that setting YEAR to invalid string results in default value, not
# 2000. (Bug #6067)
CREATE TABLE t1 (y YEAR);
INSERT INTO t1 VALUES ('abc');
SELECT * FROM t1;
DROP TABLE t1;
#
# Bug#21677: Wrong result when comparing a DATE and a DATETIME in BETWEEN
#
create table t1(start_date date, end_date date);
insert into t1 values ('2000-01-01','2000-01-02');
select 1 from t1 where cast('2000-01-01 12:01:01' as datetime) between start_date and end_date;
drop table t1;
# End of 4.1 tests
#
# Bug #23093: Implicit conversion of 9912101 to date does not match
# cast(9912101 as date)
#
select @d:=1111;
select year(@d), month(@d), day(@d), cast(@d as date);
select @d:=011111;
select year(@d), month(@d), day(@d), cast(@d as date);
select @d:=1311;
select year(@d), month(@d), day(@d), cast(@d as date);
create table t1 (d date , dt datetime , ts timestamp);
insert into t1 values (9912101,9912101,9912101);
insert into t1 values (11111,11111,11111);
select * from t1;
drop table t1;
#
# Bug #30942: select str_to_date from derived table returns varying results
#
CREATE TABLE t1 (
a INT
);
INSERT INTO t1 VALUES (1);
INSERT INTO t1 VALUES (NULL);
SELECT str_to_date( '', a ) FROM t1;
DROP TABLE t1;
#
# Bug #31221: Optimizer incorrectly identifies impossible WHERE clause
#
CREATE TABLE t1 (a DATE, b int, PRIMARY KEY (a,b));
INSERT INTO t1 VALUES (DATE(NOW()), 1);
SELECT COUNT(*) FROM t1 WHERE a = NOW();
EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW();
INSERT INTO t1 VALUES (DATE(NOW()), 2);
SELECT COUNT(*) FROM t1 WHERE a = NOW();
EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW();
SELECT COUNT(*) FROM t1 WHERE a = NOW() AND b = 1;
EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW() AND b = 1;
ALTER TABLE t1 DROP PRIMARY KEY;
SELECT COUNT(*) FROM t1 WHERE a = NOW();
EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW();
DROP TABLE t1;
#
# Bug #28687: Search fails on '0000-00-00' date after sql_mode change
#
CREATE TABLE t1 (a DATE);
CREATE TABLE t2 (a DATE);
CREATE INDEX i ON t1 (a);
INSERT INTO t1 VALUES ('0000-00-00'),('0000-00-00');
INSERT INTO t2 VALUES ('0000-00-00'),('0000-00-00');
SELECT * FROM t1 WHERE a = '0000-00-00';
SELECT * FROM t2 WHERE a = '0000-00-00';
SET SQL_MODE=TRADITIONAL;
EXPLAIN SELECT * FROM t1 WHERE a = '0000-00-00';
SELECT * FROM t1 WHERE a = '0000-00-00';
SELECT * FROM t2 WHERE a = '0000-00-00';
--error ER_TRUNCATED_WRONG_VALUE
INSERT INTO t1 VALUES ('0000-00-00');
SET SQL_MODE=DEFAULT;
DROP TABLE t1,t2;
#
# Bug #31928: Search fails on '1000-00-00' date after sql_mode change
#
CREATE TABLE t1 (a DATE);
CREATE TABLE t2 (a DATE);
CREATE INDEX i ON t1 (a);
INSERT INTO t1 VALUES ('1000-00-00'),('1000-00-00');
INSERT INTO t2 VALUES ('1000-00-00'),('1000-00-00');
SELECT * FROM t1 WHERE a = '1000-00-00';
SELECT * FROM t2 WHERE a = '1000-00-00';
SET SQL_MODE=TRADITIONAL;
EXPLAIN SELECT * FROM t1 WHERE a = '1000-00-00';
SELECT * FROM t1 WHERE a = '1000-00-00';
SELECT * FROM t2 WHERE a = '1000-00-00';
--error ER_TRUNCATED_WRONG_VALUE
INSERT INTO t1 VALUES ('1000-00-00');
SET SQL_MODE=DEFAULT;
DROP TABLE t1,t2;
#
# Bug #31990: MINUTE() and SECOND() return bogus results when used on a DATE
#
CREATE TABLE t1 SELECT curdate() AS f1;
SELECT hour(f1), minute(f1), second(f1) FROM t1;
DROP TABLE t1;
--echo End of 5.0 tests
#
# Bug#32021: Using Date 000-00-01 in WHERE causes wrong result
#
create table t1 (a date, primary key (a))engine=memory;
insert into t1 values ('0000-01-01'), ('0000-00-01'), ('0001-01-01');
select * from t1 where a between '0000-00-01' and '0000-00-02';
drop table t1;
--echo End of 5.1 tests
SET STORAGE_ENGINE='tokudb';
#
# testing different DATETIME ranges
#
--disable_warnings
drop table if exists t1;
--enable_warnings
create table t1 (t datetime);
insert into t1 values (101),(691231),(700101),(991231),(10000101),(99991231),(101000000),(691231000000),(700101000000),(991231235959),(10000101000000),(99991231235959),(20030100000000),(20030000000000);
select * from t1;
delete from t1 where t > 0;
optimize table t1;
check table t1;
delete from t1;
insert into t1 values("000101"),("691231"),("700101"),("991231"),("00000101"),("00010101"),("99991231"),("00101000000"),("691231000000"),("700101000000"),("991231235959"),("10000101000000"),("99991231235959"),("20030100000000"),("20030000000000");
# Strange dates
insert into t1 values ("2003-003-03");
# Bug #7308: ISO-8601 date format not handled correctly
insert into t1 values ("20030102T131415"),("2001-01-01T01:01:01"), ("2001-1-1T1:01:01");
select * from t1;
# Test some wrong dates
truncate table t1;
insert into t1 values("2003-0303 12:13:14");
select * from t1;
drop table t1;
#
# Test insert of now() and curtime()
#
CREATE TABLE t1 (a timestamp, b date, c time, d datetime);
insert into t1 (b,c,d) values(now(),curtime(),now());
select date_format(a,"%Y-%m-%d")=b,right(a+0,6)=c+0,a=d+0 from t1;
drop table t1;
#
# Test of datetime and not null
#
CREATE TABLE t1 (a datetime not null);
insert into t1 values (0);
select * from t1 where a is null;
drop table t1;
#
# Test with bug when propagating DATETIME to integer and WHERE optimization
#
create table t1 (id int, dt datetime);
insert into t1 values (1,"2001-08-14 00:00:00"),(2,"2001-08-15 00:00:00"),(3,"2001-08-16 00:00:00"),(4,"2003-09-15 01:20:30");
select * from t1 where dt='2001-08-14 00:00:00' and dt = if(id=1,'2001-08-14 00:00:00','1999-08-15');
create index dt on t1 (dt);
select * from t1 where dt > 20021020;
select * from t1 ignore index (dt) where dt > 20021020;
drop table t1;
#
# Test of datetime optimization
#
CREATE TABLE `t1` (
`date` datetime NOT NULL default '0000-00-00 00:00:00',
`numfacture` int(6) unsigned NOT NULL default '0',
`expedition` datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`numfacture`),
KEY `date` (`date`),
KEY `expedition` (`expedition`)
) ENGINE=tokudb;
INSERT INTO t1 (expedition) VALUES ('0001-00-00 00:00:00');
SELECT * FROM t1 WHERE expedition='0001-00-00 00:00:00';
INSERT INTO t1 (numfacture,expedition) VALUES ('1212','0001-00-00 00:00:00');
SELECT * FROM t1 WHERE expedition='0001-00-00 00:00:00';
EXPLAIN SELECT * FROM t1 WHERE expedition='0001-00-00 00:00:00';
drop table t1;
create table t1 (a datetime not null, b datetime not null);
insert into t1 values (now(), now());
insert into t1 values (now(), now());
select * from t1 where a is null or b is null;
drop table t1;
#
# Let us check if we properly treat wrong datetimes and produce proper
# warnings (for both strings and numbers)
#
create table t1 (t datetime);
insert into t1 values (20030102030460),(20030102036301),(20030102240401),
(20030132030401),(20031302030401),(100001202030401);
select * from t1;
delete from t1;
insert into t1 values
("2003-01-02 03:04:60"),("2003-01-02 03:63:01"),("2003-01-02 24:04:01"),
("2003-01-32 03:04:01"),("2003-13-02 03:04:01"), ("10000-12-02 03:04:00");
select * from t1;
delete from t1;
insert into t1 values ("0000-00-00 00:00:00 some trailer"),("2003-01-01 00:00:00 some trailer");
select * from t1 order by t;
drop table t1;
#
# Test for bug #7297 "Two digit year should be interpreted correctly even
# with zero month and day"
#
create table t1 (dt datetime);
# These dates should be treated as dates in 21st century
insert into t1 values ("12-00-00"), ("00-00-00 01:00:00");
# Zero dates are still special :/
insert into t1 values ("00-00-00"), ("00-00-00 00:00:00");
select * from t1;
drop table t1;
#
# Bug #16546 DATETIME+0 not always coerced the same way
#
select cast('2006-12-05 22:10:10' as datetime) + 0;
# End of 4.1 tests
#
# Bug#21475: Wrongly applied constant propagation leads to a false comparison.
#
CREATE TABLE t1(a DATETIME NOT NULL);
INSERT INTO t1 VALUES ('20060606155555');
SELECT a FROM t1 WHERE a=(SELECT MAX(a) FROM t1) AND (a="20060606155555");
PREPARE s FROM 'SELECT a FROM t1 WHERE a=(SELECT MAX(a) FROM t1) AND (a="20060606155555")';
EXECUTE s;
DROP PREPARE s;
DROP TABLE t1;
#
# Bug 19491 (CAST DATE AS DECIMAL returns incorrect result
#
SELECT CAST(CAST('2006-08-10' AS DATE) AS DECIMAL(20,6));
SELECT CAST(CAST('2006-08-10 10:11:12' AS DATETIME) AS DECIMAL(20,6));
SELECT CAST(CAST('2006-08-10 10:11:12' AS DATETIME) + INTERVAL 14 MICROSECOND AS DECIMAL(20,6));
SELECT CAST(CAST('10:11:12.098700' AS TIME) AS DECIMAL(20,6));
#
# Test of storing datetime into date fields
#
set @org_mode=@@sql_mode;
create table t1 (da date default '1962-03-03 23:33:34', dt datetime default '1962-03-03');
show create table t1;
insert into t1 values ();
insert into t1 values ('2007-03-23 13:49:38','2007-03-23 13:49:38');
set @@sql_mode='ansi,traditional';
insert into t1 values ('2007-03-23 13:49:38','2007-03-23 13:49:38');
insert into t1 set dt='2007-03-23 13:49:38',da=dt;
# Test error handling
--error ER_TRUNCATED_WRONG_VALUE
insert into t1 values ('2007-03-32','2007-03-23 13:49:38');
select * from t1;
drop table t1;
--error ER_INVALID_DEFAULT
create table t1 (da date default '1962-03-32 23:33:34', dt datetime default '1962-03-03');
--error ER_INVALID_DEFAULT
create table t1 (t time default '916:00:00 a');
set @@sql_mode= @org_mode;
#
# Bug#27590: Wrong DATE/DATETIME comparison.
#
## The following sub test will fail (difference to expected result) if the
## select curdate() < now(), f1 < now(), cast(f1 as date) < now() from t1;
## runs exact at midnight ('00:00:00').
## ( Bug#29290 type_datetime.test failure in 5.1 )
## Therefore we sleep a bit if we are too close to midnight.
## The complete test itself needs around 1 second.
## Therefore a time_distance to midnight of 5 seconds should be sufficient.
if (`SELECT CURTIME() > SEC_TO_TIME(24 * 3600 - 5)`)
{
# We are here when CURTIME() is between '23:59:56' and '23:59:59'.
# So a sleep time of 5 seconds brings us between '00:00:01' and '00:00:04'.
--real_sleep 5
}
create table t1 (f1 date, f2 datetime, f3 timestamp);
insert into t1(f1) values(curdate());
select curdate() < now(), f1 < now(), cast(f1 as date) < now() from t1;
delete from t1;
insert into t1 values('2001-01-01','2001-01-01 01:01:01','2001-01-01 01:01:01');
insert into t1 values('2001-02-05','2001-02-05 00:00:00','2001-02-05 01:01:01');
insert into t1 values('2001-03-10','2001-03-09 01:01:01','2001-03-10 01:01:01');
insert into t1 values('2001-04-15','2001-04-15 00:00:00','2001-04-15 00:00:00');
insert into t1 values('2001-05-20','2001-05-20 01:01:01','2001-05-20 01:01:01');
select f1, f3 from t1 where f1 >= '2001-02-05 00:00:00' and f3 <= '2001-04-15';
select f1, f3 from t1 where f1 >= '2001-2-5 0:0:0' and f2 <= '2001-4-15';
select f1, f2 from t1 where if(1, f1, 0) >= f2;
select 1 from dual where cast('2001-1-1 2:3:4' as date) = cast('2001-01-01' as datetime);
select f1, f2, f1 > f2, f1 = f2, f1 < f2 from t1;
drop table t1;
#
# Bug#16377: Wrong DATE/DATETIME comparison in BETWEEN function.
#
create table t1 (f1 date, f2 datetime, f3 timestamp);
insert into t1 values('2001-01-01','2001-01-01 01:01:01','2001-01-01 01:01:01');
insert into t1 values('2001-02-05','2001-02-05 00:00:00','2001-02-05 01:01:01');
insert into t1 values('2001-03-10','2001-03-09 01:01:01','2001-03-10 01:01:01');
insert into t1 values('2001-04-15','2001-04-15 00:00:00','2001-04-15 00:00:00');
insert into t1 values('2001-05-20','2001-05-20 01:01:01','2001-05-20 01:01:01');
select f2 from t1 where f2 between '2001-2-5' and '01-04-14';
select f1, f2, f3 from t1 where f1 between f2 and f3;
select f1, f2, f3 from t1 where cast(f1 as datetime) between f2 and
cast(f3 as date);
select f2 from t1 where '2001-04-10 12:34:56' between f2 and '01-05-01';
select f2, f3 from t1 where '01-03-10' between f2 and f3;
select f2 from t1 where DATE(f2) between "2001-4-15" AND "01-4-15";
SELECT 1 from dual where NOW() BETWEEN CURRENT_DATE() - INTERVAL 1 DAY AND CURRENT_DATE();
drop table t1;
#
# Bug#28133: Wrong DATE/DATETIME comparison in IN() function.
#
create table t1 (f1 date);
insert into t1 values('01-01-01'),('01-01-02'),('01-01-03');
select * from t1 where f1 in ('01-01-01','2001-01-02','2001-01-03 00:00:00');
create table t2(f2 datetime);
insert into t2 values('01-01-01 00:00:00'),('01-02-03 12:34:56'),('02-04-06 11:22:33');
select * from t2 where f2 in ('01-01-01','01-02-03 12:34:56','01-02-03');
select * from t1,t2 where '01-01-02' in (f1, cast(f2 as date));
select * from t1,t2 where '01-01-01' in (f1, '01-02-03');
select * from t1,t2 where if(1,'01-02-03 12:34:56','') in (f1, f2);
create table t3(f3 varchar(20));
insert into t3 select * from t2;
select * from t2,t3 where f2 in (f3,'03-04-05');
select f1,f2,f3 from t1,t2,t3 where (f1,'1') in ((f2,'1'),(f3,'1'));
select f1 from t1 where ('1',f1) in (('1','01-01-01'),('1','2001-1-1 0:0:0'),('1','02-02-02'));
drop table t1,t2,t3;
#
# Bug#27759: Wrong DATE/DATETIME comparison in LEAST()/GREATEST() functions.
#
select least(cast('01-01-01' as date), '01-01-02');
select greatest(cast('01-01-01' as date), '01-01-02');
select least(cast('01-01-01' as date), '01-01-02') + 0;
select greatest(cast('01-01-01' as date), '01-01-02') + 0;
select least(cast('01-01-01' as datetime), '01-01-02') + 0;
select cast(least(cast('01-01-01' as datetime), '01-01-02') as signed);
select cast(least(cast('01-01-01' as datetime), '01-01-02') as decimal(16,2));
--disable_warnings
DROP PROCEDURE IF EXISTS test27759 ;
--enable_warnings
DELIMITER |;
CREATE PROCEDURE test27759()
BEGIN
declare v_a date default '2007-4-10';
declare v_b date default '2007-4-11';
declare v_c datetime default '2004-4-9 0:0:0';
select v_a as a,v_b as b,
least( v_a, v_b ) as a_then_b,
least( v_b, v_a ) as b_then_a,
least( v_c, v_a ) as c_then_a;
END;|
DELIMITER ;|
call test27759();
drop procedure test27759;
#
# Bug#28208: Wrong result of a non-const STRING function with a const
# DATETIME function.
#
create table t1 (f1 date);
insert into t1 values (curdate());
select left(f1,10) = curdate() from t1;
drop table t1;
#
# Bug#28261: Wrong DATETIME comparison result when the GET_USER_VAR function
# is involved.
#
create table t1(f1 date);
insert into t1 values('01-01-01'),('02-02-02'),('01-01-01'),('02-02-02');
set @bug28261='';
select if(@bug28261 = f1, '', @bug28261:= f1) from t1;
select if(@bug28261 = f1, '', @bug28261:= f1) from t1;
select if(@bug28261 = f1, '', @bug28261:= f1) from t1;
drop table t1;
#
# Bug#28778: Wrong result of BETWEEN when comparing a DATETIME field with an
# integer constants.
#
create table t1(f1 datetime);
insert into t1 values('2001-01-01'),('2002-02-02');
select * from t1 where f1 between 20020101 and 20070101000000;
select * from t1 where f1 between 2002010 and 20070101000000;
select * from t1 where f1 between 20020101 and 2007010100000;
drop table t1;
--echo #
--echo # Bug#27216: functions with parameters of different date types may
--echo # return wrong type of the result.
--echo #
create table t1 (f1 date, f2 datetime, f3 varchar(20));
create table t2 as select coalesce(f1,f1) as f4 from t1;
desc t2;
create table t3 as select coalesce(f1,f2) as f4 from t1;
desc t3;
create table t4 as select coalesce(f2,f2) as f4 from t1;
desc t4;
create table t5 as select coalesce(f1,f3) as f4 from t1;
desc t5;
create table t6 as select coalesce(f2,f3) as f4 from t1;
desc t6;
create table t7 as select coalesce(makedate(1997,1),f2) as f4 from t1;
desc t7;
create table t8 as select coalesce(cast('01-01-01' as datetime),f2) as f4
from t1;
desc t8;
create table t9 as select case when 1 then cast('01-01-01' as date)
when 0 then cast('01-01-01' as date) end as f4 from t1;
desc t9;
create table t10 as select case when 1 then cast('01-01-01' as datetime)
when 0 then cast('01-01-01' as datetime) end as f4 from t1;
desc t10;
create table t11 as select if(1, cast('01-01-01' as datetime),
cast('01-01-01' as date)) as f4 from t1;
desc t11;
create table t12 as select least(cast('01-01-01' as datetime),
cast('01-01-01' as date)) as f4 from t1;
desc t12;
create table t13 as select ifnull(cast('01-01-01' as datetime),
cast('01-01-01' as date)) as f4 from t1;
desc t13;
drop tables t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13;
--echo ###################################################################
#
# Bug #31253: crash comparing datetime to double
# Should return 1st row only. Crashes if NULL propagation fails.
#
create table t1 (f1 time);
insert into t1 set f1 = '45:44:44';
insert into t1 set f1 = '15:44:44';
select * from t1 where (convert(f1,datetime)) != 1;
drop table t1;
#
# Bug #31249: problem with convert(..., datetime)
#
create table t1 (a tinyint);
insert into t1 values (), (), ();
select sum(a) from t1 group by convert(a, datetime);
drop table t1;
#
# Bug #32694: NOT NULL table field in a subquery produces invalid results
#
create table t1 (id int(10) not null, cur_date datetime not null);
create table t2 (id int(10) not null, cur_date date not null);
insert into t1 (id, cur_date) values (1, '2007-04-25 18:30:22');
insert into t2 (id, cur_date) values (1, '2007-04-25');
explain extended
select * from t1
where id in (select id from t1 as x1 where (t1.cur_date is null));
select * from t1
where id in (select id from t1 as x1 where (t1.cur_date is null));
explain extended
select * from t2
where id in (select id from t2 as x1 where (t2.cur_date is null));
select * from t2
where id in (select id from t2 as x1 where (t2.cur_date is null));
insert into t1 (id, cur_date) values (2, '2007-04-26 18:30:22');
insert into t2 (id, cur_date) values (2, '2007-04-26');
explain extended
select * from t1
where id in (select id from t1 as x1 where (t1.cur_date is null));
select * from t1
where id in (select id from t1 as x1 where (t1.cur_date is null));
explain extended
select * from t2
where id in (select id from t2 as x1 where (t2.cur_date is null));
select * from t2
where id in (select id from t2 as x1 where (t2.cur_date is null));
drop table t1,t2;
--echo End of 5.0 tests
#
# Test of storing datetime into date fields
#
set @org_mode=@@sql_mode;
create table t1 (da date default '1962-03-03 23:33:34', dt datetime default '1962-03-03');
show create table t1;
insert into t1 values ();
insert into t1 values ('2007-03-23 13:49:38','2007-03-23 13:49:38');
set @@sql_mode='ansi,traditional';
insert into t1 values ('2007-03-23 13:49:38','2007-03-23 13:49:38');
insert into t1 set dt='2007-03-23 13:49:38',da=dt;
# Test error handling
--error 1292
insert into t1 values ('2007-03-32','2007-03-23 13:49:38');
select * from t1;
drop table t1;
--error 1067
create table t1 (da date default '1962-03-32 23:33:34', dt datetime default '1962-03-03');
--error 1067
create table t1 (t time default '916:00:00 a');
set @@sql_mode= @org_mode;
SET STORAGE_ENGINE='tokudb';
# bug in decimal() with negative numbers by kaido@tradenet.ee
--disable_warnings
DROP TABLE IF EXISTS t1, t2;
--enable_warnings
SET SQL_WARNINGS=1;
CREATE TABLE t1 (
id int(11) NOT NULL auto_increment,
datatype_id int(11) DEFAULT '0' NOT NULL,
minvalue decimal(20,10) DEFAULT '0.0000000000' NOT NULL,
maxvalue decimal(20,10) DEFAULT '0.0000000000' NOT NULL,
valuename varchar(20),
forecolor int(11),
backcolor int(11),
PRIMARY KEY (id),
UNIQUE datatype_id (datatype_id, minvalue, maxvalue)
);
INSERT INTO t1 VALUES ( '1', '4', '0.0000000000', '0.0000000000', 'Ei saja', '0', '16776960');
INSERT INTO t1 VALUES ( '2', '4', '1.0000000000', '1.0000000000', 'Sajab', '16777215', '255');
INSERT INTO t1 VALUES ( '3', '1', '2.0000000000', '49.0000000000', '', '0', '16777215');
INSERT INTO t1 VALUES ( '60', '11', '0.0000000000', '0.0000000000', 'Rikkis', '16777215', '16711680');
INSERT INTO t1 VALUES ( '4', '12', '1.0000000000', '1.0000000000', 'nork sadu', '65280', '14474460');
INSERT INTO t1 VALUES ( '5', '12', '2.0000000000', '2.0000000000', 'keskmine sadu', '255', '14474460');
INSERT INTO t1 VALUES ( '6', '12', '3.0000000000', '3.0000000000', 'tugev sadu', '127', '14474460');
INSERT INTO t1 VALUES ( '43', '39', '6.0000000000', '6.0000000000', 'lobjakas', '13107327', '16763080');
INSERT INTO t1 VALUES ( '40', '39', '2.0000000000', '2.0000000000', 'vihm', '8355839', '16777215');
INSERT INTO t1 VALUES ( '53', '1', '-35.0000000000', '-5.0000000000', '', '0', '16777215');
INSERT INTO t1 VALUES ( '41', '39', '3.0000000000', '3.0000000000', 'klm vihm', '120', '16763080');
INSERT INTO t1 VALUES ( '12', '21', '21.0000000000', '21.0000000000', 'Kuiv', '13158600', '16777215');
INSERT INTO t1 VALUES ( '13', '21', '13.0000000000', '13.0000000000', 'Mrg', '5263615', '16777215');
INSERT INTO t1 VALUES ( '14', '21', '22.0000000000', '22.0000000000', 'Niiske', '9869055', '16777215');
INSERT INTO t1 VALUES ( '19', '21', '33.0000000000', '33.0000000000', 'Mrg', '5263615', '16777215');
INSERT INTO t1 VALUES ( '15', '21', '23.0000000000', '23.0000000000', 'Mrg', '5263615', '16777215');
INSERT INTO t1 VALUES ( '16', '21', '31.0000000000', '31.0000000000', 'Kuiv', '13158600', '16777215');
INSERT INTO t1 VALUES ( '17', '21', '12.0000000000', '12.0000000000', 'Niiske', '9869055', '16777215');
INSERT INTO t1 VALUES ( '18', '21', '32.0000000000', '32.0000000000', 'Niiske', '9869055', '16777215');
INSERT INTO t1 VALUES ( '20', '21', '331.0000000000', '331.0000000000', 'Hrmatise hoiatus!', '14448840', '13158600');
INSERT INTO t1 VALUES ( '21', '21', '11.0000000000', '11.0000000000', 'Kuiv', '13158600', '16777215');
INSERT INTO t1 VALUES ( '22', '33', '21.0000000000', '21.0000000000', 'Pilves, kuiv', '8355711', '12632256');
INSERT INTO t1 VALUES ( '23', '33', '13.0000000000', '13.0000000000', 'Sajab, mrg', '0', '8355839');
INSERT INTO t1 VALUES ( '24', '33', '22.0000000000', '22.0000000000', 'Pilves, niiske', '8355711', '12632319');
INSERT INTO t1 VALUES ( '29', '33', '33.0000000000', '33.0000000000', 'Selge, mrg', '16777215', '8355839');
INSERT INTO t1 VALUES ( '25', '33', '23.0000000000', '23.0000000000', 'Pilves, mrg', '8355711', '8355839');
INSERT INTO t1 VALUES ( '26', '33', '31.0000000000', '31.0000000000', 'Selge, kuiv', '16777215', '12632256');
INSERT INTO t1 VALUES ( '27', '33', '12.0000000000', '12.0000000000', 'Sajab, niiske', '0', '12632319');
INSERT INTO t1 VALUES ( '28', '33', '32.0000000000', '32.0000000000', 'Selge, niiske', '16777215', '12632319');
INSERT INTO t1 VALUES ( '30', '33', '331.0000000000', '331.0000000000', 'Hrmatis! selge,kuiv', '16711680', '12632256');
INSERT INTO t1 VALUES ( '31', '33', '11.0000000000', '11.0000000000', 'Sajab, kuiv', '0', '12632256');
INSERT INTO t1 VALUES ( '32', '11', '1.0000000000', '1.0000000000', 'Korras', '16777215', '49152');
INSERT INTO t1 VALUES ( '33', '21', '335.0000000000', '335.0000000000', 'Hrmatis!', '14448840', '11842740');
INSERT INTO t1 VALUES ( '34', '21', '134.0000000000', '134.0000000000', 'Hoiatus, M+S!', '255', '13158600');
INSERT INTO t1 VALUES ( '35', '21', '133.0000000000', '133.0000000000', 'Hoiatus, mrg!', '5263615', '13158600');
INSERT INTO t1 VALUES ( '36', '21', '135.0000000000', '135.0000000000', 'Hrmatis!', '14448840', '11842740');
INSERT INTO t1 VALUES ( '37', '21', '334.0000000000', '334.0000000000', 'Hrmatise hoiatus!', '14448840', '13158600');
INSERT INTO t1 VALUES ( '38', '21', '132.0000000000', '132.0000000000', 'Hoiatus, niiske!', '9869055', '13158600');
INSERT INTO t1 VALUES ( '39', '39', '1.0000000000', '1.0000000000', 'ei saja', '11206570', '16777215');
INSERT INTO t1 VALUES ( '44', '39', '4.0000000000', '5.0000000000', 'lumi', '16711680', '16763080');
INSERT INTO t1 VALUES ( '45', '12', '0.0000000000', '0.0000000000', '', '16777215', '14474460');
INSERT INTO t1 VALUES ( '46', '39', '8.0000000000', '8.0000000000', 'rahe', '9830400', '16763080');
INSERT INTO t1 VALUES ( '47', '39', '9.0000000000', '9.0000000000', 'tp ebaselge', '12582912', '16777215');
INSERT INTO t1 VALUES ( '48', '39', '7.0000000000', '7.0000000000', 'lumetuisk', '7209070', '16763080');
INSERT INTO t1 VALUES ( '142', '15', '2.0000000000', '49.0000000000', '', '0', '16777215');
INSERT INTO t1 VALUES ( '52', '1', '-4.9000000000', '-0.1000000000', '', '0', '15774720');
INSERT INTO t1 VALUES ( '141', '15', '-4.9000000000', '-0.1000000000', '', '0', '15774720');
INSERT INTO t1 VALUES ( '55', '8', '0.0000000000', '0.0000000000', '', '0', '16777215');
INSERT INTO t1 VALUES ( '56', '8', '0.0100000000', '0.1000000000', '', '0', '16770560');
INSERT INTO t1 VALUES ( '57', '8', '0.1100000000', '25.0000000000', '', '0', '15774720');
INSERT INTO t1 VALUES ( '58', '2', '90.0000000000', '94.9000000000', '', NULL, '16770560');
INSERT INTO t1 VALUES ( '59', '6', '0.0000000000', '360.0000000000', '', NULL, '16777215');
INSERT INTO t1 VALUES ( '61', '21', '38.0000000000', '38.0000000000', 'Niiske', '9869055', '16777215');
INSERT INTO t1 VALUES ( '62', '38', '500.0000000000', '999.0000000000', '', '0', '16770560');
INSERT INTO t1 VALUES ( '63', '38', '1000.0000000000', '2000.0000000000', '', '0', '16777215');
INSERT INTO t1 VALUES ( '64', '17', '0.0000000000', '0.0000000000', '', NULL, '16777215');
INSERT INTO t1 VALUES ( '65', '17', '0.1000000000', '10.0000000000', '', NULL, '16770560');
INSERT INTO t1 VALUES ( '67', '21', '412.0000000000', '412.0000000000', 'Niiske', '9869055', '16777215');
INSERT INTO t1 VALUES ( '68', '21', '413.0000000000', '413.0000000000', 'Mrg', '5263615', '16777215');
INSERT INTO t1 VALUES ( '69', '21', '113.0000000000', '113.0000000000', 'Mrg', '5263615', '16777215');
INSERT INTO t1 VALUES ( '70', '21', '416.0000000000', '416.0000000000', 'Lumine!', '16711680', '11842740');
INSERT INTO t1 VALUES ( '71', '38', '0.0000000000', '499.0000000000', '', NULL, '16711680');
INSERT INTO t1 VALUES ( '72', '22', '-49.0000000000', '49.0000000000', '', NULL, '16777215');
INSERT INTO t1 VALUES ( '73', '13', '0.0000000000', '9.9000000000', '', NULL, '16777215');
INSERT INTO t1 VALUES ( '74', '13', '10.0000000000', '14.9000000000', '', NULL, '16770560');
INSERT INTO t1 VALUES ( '75', '7', '0.0000000000', '50.0000000000', '', NULL, '16777215');
INSERT INTO t1 VALUES ( '76', '18', '0.0000000000', '0.0000000000', '', NULL, '16777215');
INSERT INTO t1 VALUES ( '77', '18', '0.1000000000', '10.0000000000', '', NULL, '16770560');
INSERT INTO t1 VALUES ( '78', '19', '300.0000000000', '400.0000000000', '', NULL, '16777215');
INSERT INTO t1 VALUES ( '79', '19', '0.0000000000', '299.0000000000', '', NULL, '16770560');
INSERT INTO t1 VALUES ( '80', '23', '0.0000000000', '100.0000000000', '', NULL, '16777215');
INSERT INTO t1 VALUES ( '81', '24', '0.0000000000', '200.0000000000', '', NULL, '16777215');
INSERT INTO t1 VALUES ( '82', '26', '0.0000000000', '0.0000000000', '', NULL, '16777215');
INSERT INTO t1 VALUES ( '83', '26', '0.1000000000', '5.0000000000', '', NULL, '16776960');
INSERT INTO t1 VALUES ( '84', '21', '422.0000000000', '422.0000000000', 'Niiske', '9869055', '16777215');
INSERT INTO t1 VALUES ( '85', '21', '411.0000000000', '411.0000000000', 'Saju hoiat.,kuiv!', '16777215', '13158600');
INSERT INTO t1 VALUES ( '86', '21', '423.0000000000', '423.0000000000', 'Mrg', '5263615', '16777215');
INSERT INTO t1 VALUES ( '144', '16', '-49.0000000000', '-5.0000000000', '', NULL, '16777215');
INSERT INTO t1 VALUES ( '88', '16', '2.0000000000', '49.0000000000', '', NULL, '16777215');
INSERT INTO t1 VALUES ( '89', '21', '338.0000000000', '338.0000000000', 'Hrm.hoiatus, N+S!', '16744319', '13158600');
INSERT INTO t1 VALUES ( '90', '21', '332.0000000000', '332.0000000000', 'Hrm.hoiat., niiske!', '16744319', '13158600');
INSERT INTO t1 VALUES ( '91', '21', '114.0000000000', '114.0000000000', 'Hoiatus, M+S!', '255', '13158600');
INSERT INTO t1 VALUES ( '92', '21', '117.0000000000', '117.0000000000', 'Hoiatus, J!', '14448840', '16711680');
INSERT INTO t1 VALUES ( '93', '21', '116.0000000000', '116.0000000000', 'Lumine!', '16711680', '11842740');
INSERT INTO t1 VALUES ( '94', '21', '414.0000000000', '414.0000000000', 'Hoiatus, M+S!', '255', '13158600');
INSERT INTO t1 VALUES ( '95', '21', '325.0000000000', '325.0000000000', 'Hrmatis!', '14448840', '11842740');
INSERT INTO t1 VALUES ( '96', '21', '321.0000000000', '321.0000000000', 'Hrmatise hoiatus!', '14448840', '13158600');
INSERT INTO t1 VALUES ( '97', '21', '328.0000000000', '328.0000000000', 'Hrm.hoiatus, N+S!', '16744319', '13158600');
INSERT INTO t1 VALUES ( '98', '21', '28.0000000000', '28.0000000000', 'Niiske ja sool', '9869055', '16777215');
INSERT INTO t1 VALUES ( '99', '21', '118.0000000000', '118.0000000000', 'Hoiatus, N+S!', '9869055', '13158600');
INSERT INTO t1 VALUES ( '100', '21', '418.0000000000', '418.0000000000', 'Hoiatus, N+S!', '9869055', '13158600');
INSERT INTO t1 VALUES ( '101', '21', '322.0000000000', '322.0000000000', 'Hrm.hoiat., niiske!', '16744319', '13158600');
INSERT INTO t1 VALUES ( '102', '21', '428.0000000000', '428.0000000000', 'Hoiatus, N+S!', '9869055', '13158600');
INSERT INTO t1 VALUES ( '103', '21', '432.0000000000', '432.0000000000', 'Hoiatus, niiske!', '7895240', '13158600');
INSERT INTO t1 VALUES ( '104', '21', '421.0000000000', '421.0000000000', 'Saju hoiat.,kuiv!', '16777215', '13158600');
INSERT INTO t1 VALUES ( '105', '21', '24.0000000000', '24.0000000000', 'Mrg ja sool', '255', '16777215');
INSERT INTO t1 VALUES ( '106', '21', '438.0000000000', '438.0000000000', 'Hoiatus, N+S!', '9869055', '13158600');
INSERT INTO t1 VALUES ( '107', '21', '112.0000000000', '112.0000000000', 'Hoiatus, niiske!', '9869055', '13158600');
INSERT INTO t1 VALUES ( '108', '21', '34.0000000000', '34.0000000000', 'Mrg ja sool', '255', '16777215');
INSERT INTO t1 VALUES ( '109', '21', '434.0000000000', '434.0000000000', 'Hoiatus, M+S!', '255', '13158600');
INSERT INTO t1 VALUES ( '110', '21', '124.0000000000', '124.0000000000', 'Hoiatus, M+S!', '255', '13158600');
INSERT INTO t1 VALUES ( '111', '21', '424.0000000000', '424.0000000000', 'Hoiatus, M+S!', '255', '13158600');
INSERT INTO t1 VALUES ( '112', '21', '123.0000000000', '123.0000000000', 'Hoiatus, mrg!', '5263615', '13158600');
INSERT INTO t1 VALUES ( '140', '15', '-49.0000000000', '-5.0000000000', '', '0', '16777215');
INSERT INTO t1 VALUES ( '114', '21', '18.0000000000', '18.0000000000', 'Niiske ja sool', '9869055', '16777215');
INSERT INTO t1 VALUES ( '115', '21', '122.0000000000', '122.0000000000', 'Hoiatus, niiske!', '9869055', '13158600');
INSERT INTO t1 VALUES ( '116', '21', '14.0000000000', '14.0000000000', 'Mrg ja sool', '255', '16777215');
INSERT INTO t1 VALUES ( '117', '21', '311.0000000000', '311.0000000000', 'Hrmatise hoiatus!', '14448840', '13158600');
INSERT INTO t1 VALUES ( '121', '2', '95.0000000000', '100.0000000000', '', NULL, '15774720');
INSERT INTO t1 VALUES ( '118', '2', '0.0000000000', '89.9000000000', '', NULL, '16777215');
INSERT INTO t1 VALUES ( '119', '21', '16.0000000000', '16.0000000000', 'Lumine!', '16711680', '11842740');
INSERT INTO t1 VALUES ( '120', '21', '26.0000000000', '26.0000000000', 'Lumine!', '16711680', '11842740');
INSERT INTO t1 VALUES ( '122', '13', '15.0000000000', '50.0000000000', '', NULL, '15774720');
INSERT INTO t1 VALUES ( '123', '5', '0.0000000000', '9.9000000000', '', NULL, '16777215');
INSERT INTO t1 VALUES ( '124', '5', '10.0000000000', '14.9000000000', '', NULL, '16770560');
INSERT INTO t1 VALUES ( '125', '5', '15.0000000000', '50.0000000000', '', NULL, '15774720');
INSERT INTO t1 VALUES ( '126', '21', '128.0000000000', '128.0000000000', 'Hoiatus, N+S!', '9869055', '13158600');
INSERT INTO t1 VALUES ( '127', '21', '318.0000000000', '318.0000000000', 'Hrm.hoiatus, N+S!', '16744319', '13158600');
INSERT INTO t1 VALUES ( '128', '21', '312.0000000000', '312.0000000000', 'Hrm.hoiat., niiske!', '16744319', '13158600');
INSERT INTO t1 VALUES ( '129', '21', '126.0000000000', '126.0000000000', 'Lumine!', '16711680', '11842740');
INSERT INTO t1 VALUES ( '130', '21', '324.0000000000', '324.0000000000', 'Hrmatise hoiatus!', '14448840', '13158600');
INSERT INTO t1 VALUES ( '131', '21', '316.0000000000', '316.0000000000', 'Lumine!', '16711680', '11842740');
INSERT INTO t1 VALUES ( '132', '1', '0.0000000000', '1.9000000000', '', NULL, '16769024');
INSERT INTO t1 VALUES ( '134', '3', '-50.0000000000', '50.0000000000', '', NULL, '16777215');
INSERT INTO t1 VALUES ( '135', '8', '26.0000000000', '2000.0000000000', '', '9868950', '15774720');
INSERT INTO t1 VALUES ( '136', '21', '426.0000000000', '426.0000000000', 'Lumine!', '16711680', '11842740');
INSERT INTO t1 VALUES ( '137', '21', '127.0000000000', '127.0000000000', 'Hoiatus, J!', '14448840', '16711680');
INSERT INTO t1 VALUES ( '138', '21', '121.0000000000', '121.0000000000', 'Kuiv', '13158600', '16777215');
INSERT INTO t1 VALUES ( '139', '21', '326.0000000000', '326.0000000000', 'Lumine!', '16711680', '11842740');
INSERT INTO t1 VALUES ( '143', '16', '-4.9000000000', '-0.1000000000', '', NULL, '15774720');
INSERT INTO t1 VALUES ( '145', '15', '0.0000000000', '1.9000000000', '', '0', '16769024');
INSERT INTO t1 VALUES ( '146', '16', '0.0000000000', '1.9000000000', '', '0', '16769024');
select * from t1 where minvalue<=1 and maxvalue>=-1 and datatype_id=16;
select * from t1 where minvalue<=-1 and maxvalue>=-1 and datatype_id=16;
drop table t1;
#
# Test of correct handling leading zero and +/- signs
# then values are passed as strings
# Also test overflow handling in this case
#
create table t1 (a decimal(10,2));
insert into t1 values ("0.0"),("-0.0"),("+0.0"),("01.0"),("+01.0"),("-01.0");
insert into t1 values ("-.1"),("+.1"),(".1");
insert into t1 values ("00000000000001"),("+0000000000001"),("-0000000000001");
insert into t1 values ("+111111111.11"),("111111111.11"),("-11111111.11");
insert into t1 values ("-111111111.11"),("+1111111111.11"),("1111111111.11");
insert into t1 values ("1e+1000"),("1e-1000"),("-1e+1000");
insert into t1 values ("1e+4294967296"),("1e-4294967296");
insert into t1 values ("1e+18446744073709551615"),("1e+18446744073709551616"),("1e-9223372036854775807"),("1e-9223372036854775809");
insert into t1 values ("123.4e"),("123.4e+2"),("123.4e-2"),("123e1"),("123e+0");
select * from t1;
drop table t1;
create table t1 (a decimal(10,2) unsigned);
insert into t1 values ("0.0"),("-0.0"),("+0.0"),("01.0"),("+01.0"),("-01.0");
insert into t1 values ("-.1"),("+.1"),(".1");
insert into t1 values ("00000000000001"),("+0000000000001"),("-0000000000001");
insert into t1 values ("+111111111.11"),("111111111.11"),("-11111111.11");
insert into t1 values ("-111111111.11"),("+1111111111.11"),("1111111111.11");
insert into t1 values ("1e+1000"),("1e-1000"),("-1e+1000");
insert into t1 values ("123.4e"),("123.4e+2"),("123.4e-2"),("123e1"),("123e+0");
select * from t1;
drop table t1;
create table t1 (a decimal(10,2) zerofill);
insert into t1 values ("0.0"),("-0.0"),("+0.0"),("01.0"),("+01.0"),("-01.0");
insert into t1 values ("-.1"),("+.1"),(".1");
insert into t1 values ("00000000000001"),("+0000000000001"),("-0000000000001");
insert into t1 values ("+111111111.11"),("111111111.11"),("-11111111.11");
insert into t1 values ("-111111111.11"),("+1111111111.11"),("1111111111.11");
insert into t1 values ("1e+1000"),("1e-1000"),("-1e+1000");
insert into t1 values ("123.4e"),("123.4e+2"),("123.4e-2"),("123e1"),("123e+0");
select * from t1;
drop table t1;
create table t1 (a decimal(10,2));
# The -0.0 needs to be quoted as not all platforms supports this
insert into t1 values (0.0),("-0.0"),(+0.0),(01.0),(+01.0),(-01.0);
insert into t1 values (-.1),(+.1),(.1);
insert into t1 values (00000000000001),(+0000000000001),(-0000000000001);
insert into t1 values (+111111111.11),(111111111.11),(-11111111.11);
insert into t1 values (-111111111.11),(+1111111111.11),(1111111111.11);
insert into t1 values (1e+100),(1e-100),(-1e+100);
insert into t1 values (123.4e0),(123.4e+2),(123.4e-2),(123e1),(123e+0);
insert into t1 values (MID("987",1,2)),("987 "),("987.6e+2 ");
select * from t1;
drop table t1;
#
# Test correct handling of overflowed decimal values
#
create table t1 (a decimal);
insert into t1 values (-99999999999999),(-1),('+1'),('01'),('+00000000000001'),('+12345678901'),(99999999999999);
select * from t1;
drop table t1;
create table t1 (a decimal unsigned);
insert into t1 values (-99999999999999),(-1),('+1'),('01'),('+00000000000001'),('+1234567890'),(99999999999999);
select * from t1;
drop table t1;
create table t1 (a decimal zerofill);
insert into t1 values (-99999999999999),(-1),('+1'),('01'),('+00000000000001'),('+1234567890'),(99999999999999);
select * from t1;
drop table t1;
create table t1 (a decimal unsigned zerofill);
insert into t1 values (-99999999999999),(-1),('+1'),('01'),('+00000000000001'),('+1234567890'),(99999999999999);
select * from t1;
drop table t1;
# Exponent overflow bug
create table t1(a decimal(10,0));
insert into t1 values ("1e4294967295");
select * from t1;
delete from t1;
insert into t1 values("1e4294967297");
select * from t1;
drop table t1;
#
# Test of wrong decimal type
#
--error 1064
CREATE TABLE t1 (a_dec DECIMAL(-1,0));
--error 1064
CREATE TABLE t1 (a_dec DECIMAL(-2,1));
--error 1064
CREATE TABLE t1 (a_dec DECIMAL(-1,1));
--error 1427
CREATE TABLE t1 (a_dec DECIMAL(0,11));
#
# Zero prepend overflow bug
#
--disable_warnings
create table t1(a decimal(7,3));
insert into t1 values ('1'),('+1'),('-1'),('0000000001'),('+0000000001'),('-0000000001'),('10'),('+10'),('-10'),('0000000010'),('+0000000010'),('-0000000010'),('100'),('+100'),('-100'),('0000000100'),('+0000000100'),('-0000000100'),('1000'),('+1000'),('-1000'),('0000001000'),('+0000001000'),('-0000001000'),('10000'),('+10000'),('-10000'),('0000010000'),('+0000010000'),('-0000010000'),('100000'),('+100000'),('-100000'),('0000100000'),('+0000100000'),('-0000100000'),('1000000'),('+1000000'),('-1000000'),('0001000000'),('+0001000000'),('-0001000000'),('10000000'),('+10000000'),('-10000000'),('0010000000'),('+0010000000'),('-0010000000'),('100000000'),('+100000000'),('-100000000'),('0100000000'),('+0100000000'),('-0100000000'),('1000000000'),('+1000000000'),('-1000000000'),('1000000000'),('+1000000000'),('-1000000000');
select * from t1;
drop table t1;
create table t1(a decimal(7,3) unsigned);
insert into t1 values ('1'),('+1'),('-1'),('0000000001'),('+0000000001'),('-0000000001'),('10'),('+10'),('-10'),('0000000010'),('+0000000010'),('-0000000010'),('100'),('+100'),('-100'),('0000000100'),('+0000000100'),('-0000000100'),('1000'),('+1000'),('-1000'),('0000001000'),('+0000001000'),('-0000001000'),('10000'),('+10000'),('-10000'),('0000010000'),('+0000010000'),('-0000010000'),('100000'),('+100000'),('-100000'),('0000100000'),('+0000100000'),('-0000100000'),('1000000'),('+1000000'),('-1000000'),('0001000000'),('+0001000000'),('-0001000000'),('10000000'),('+10000000'),('-10000000'),('0010000000'),('+0010000000'),('-0010000000'),('100000000'),('+100000000'),('-100000000'),('0100000000'),('+0100000000'),('-0100000000'),('1000000000'),('+1000000000'),('-1000000000'),('1000000000'),('+1000000000'),('-1000000000');
select * from t1;
drop table t1;
create table t1(a decimal(7,3) zerofill);
insert into t1 values ('1'),('+1'),('-1'),('0000000001'),('+0000000001'),('-0000000001'),('10'),('+10'),('-10'),('0000000010'),('+0000000010'),('-0000000010'),('100'),('+100'),('-100'),('0000000100'),('+0000000100'),('-0000000100'),('1000'),('+1000'),('-1000'),('0000001000'),('+0000001000'),('-0000001000'),('10000'),('+10000'),('-10000'),('0000010000'),('+0000010000'),('-0000010000'),('100000'),('+100000'),('-100000'),('0000100000'),('+0000100000'),('-0000100000'),('1000000'),('+1000000'),('-1000000'),('0001000000'),('+0001000000'),('-0001000000'),('10000000'),('+10000000'),('-10000000'),('0010000000'),('+0010000000'),('-0010000000'),('100000000'),('+100000000'),('-100000000'),('0100000000'),('+0100000000'),('-0100000000'),('1000000000'),('+1000000000'),('-1000000000'),('1000000000'),('+1000000000'),('-1000000000');
--enable_warnings
select * from t1;
drop table t1;
#
# Bug #7589: a problem with update from column
#
create table t1(a decimal(10,5), b decimal(10,1));
insert into t1 values(123.12345, 123.12345);
update t1 set b=a;
select * from t1;
drop table t1;
--echo End of 4.1 tests
#
# Test for BUG#8397: decimal type in subselects (Item_cache_decimal)
#
CREATE TABLE t1
(EMPNUM CHAR(3) NOT NULL,
HOURS DECIMAL(5));
CREATE TABLE t2
(EMPNUM CHAR(3) NOT NULL,
HOURS BIGINT);
INSERT INTO t1 VALUES ('E1',40);
INSERT INTO t1 VALUES ('E8',NULL);
INSERT INTO t2 VALUES ('E1',40);
SELECT EMPNUM FROM t1 WHERE HOURS IN (SELECT HOURS FROM t2);
SELECT EMPNUM FROM t1 WHERE HOURS IN (SELECT HOURS FROM t1);
DROP TABLE t1,t2;
#
# Test limits of decimal
#
create table t1 (d decimal(64,0));
insert into t1 values (1);
select * from t1;
drop table t1;
create table t1 (d decimal(5));
show create table t1;
drop table t1;
create table t1 (d decimal);
show create table t1;
drop table t1;
--error 1426
create table t1 (d decimal(66,0));
#
# Test example from manual
#
CREATE TABLE t1 (i INT, d1 DECIMAL(9,2), d2 DECIMAL(9,2));
INSERT INTO t1 VALUES (1, 101.40, 21.40), (1, -80.00, 0.00),
(2, 0.00, 0.00), (2, -13.20, 0.00), (2, 59.60, 46.40),
(2, 30.40, 30.40), (3, 37.00, 7.40), (3, -29.60, 0.00),
(4, 60.00, 15.40), (4, -10.60, 0.00), (4, -34.00, 0.00),
(5, 33.00, 0.00), (5, -25.80, 0.00), (5, 0.00, 7.20),
(6, 0.00, 0.00), (6, -51.40, 0.00);
SELECT i, SUM(d1) AS a, SUM(d2) AS b FROM t1 GROUP BY i HAVING a <> b;
SELECT i, ROUND(SUM(d1), 2) AS a, ROUND(SUM(d2), 2) AS b FROM t1 GROUP BY i
HAVING a <> b;
drop table t1;
#
# A test case for Bug#4956 "strange result, insert into longtext, parameter
# with numeric value": ensure that conversion is done identically no matter
# where the input data comes from.
#
create table t1 (c1 varchar(100), c2 longtext);
insert into t1 set c1= 'non PS, 1.0 as constant', c2=1.0;
prepare stmt from "insert into t1 set c1='PS, 1.0 as constant ', c2=1.0";
execute stmt;
set @a=1.0;
insert into t1 set c1='non PS, 1.0 in parameter', c2=@a;
prepare stmt from "insert into t1 set c1='PS, 1.0 in parameter ', c2=?";
execute stmt using @a;
select * from t1;
deallocate prepare stmt;
drop table t1;
#
# A test case for Bug#5673 "Rounding problem in 4.0.21 inserting decimal
# value into a char field": this is a regression bug in 4.0 tree caused by
# a fix for some other decimal conversion issue. The patch never was
# approved to get into 4.0 (maybe because it was considered too intrusive)
#
create table t1 (
strippedproductid char(15) not null default '',
zlevelprice decimal(10,2) default null,
primary key (strippedproductid)
);
create table t2 (
productid char(15) not null default '',
zlevelprice char(21) default null,
primary key (productid)
);
insert into t1 values ('002trans','49.99');
insert into t1 values ('003trans','39.98');
insert into t1 values ('004trans','31.18');
insert INTO t2 SELECT * FROM t1;
select * from t2;
drop table t1, t2;
#
# Bug #17826 'type_decimal' fails with ps-protocol
#
create table t1 (f1 decimal(5));
insert into t1 values (40);
flush tables;
select f1 from t1 where f1 in (select f1 from t1);
drop table t1;
#
# Bug#22183: Unhandled NULL caused server crash
#
create table t1 as
select from_days(s) as date,t
from (select 1 as s,'t' as t union select null, null ) as sub1;
select group_concat(t) from t1 group by week(date)/10;
drop table t1;
#
# Bug#28980: ROUND(<dec expr>, <int col>) returned double values
#
CREATE TABLE t1 (
qty decimal(16,6) default NULL,
dps tinyint(3) unsigned default NULL
);
INSERT INTO t1 VALUES (1.1325,3);
SELECT ROUND(qty,3), dps, ROUND(qty,dps) FROM t1;
DROP TABLE t1;
#
# Bug#31019: MOD() function and operator crashes MySQL when
# divisor is very long and < 1
#
SELECT 1 % .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS '%';
SELECT MOD(1, .123456789123456789123456789123456789123456789123456789123456789123456789123456789) AS 'MOD()';
# Bug #31227: memory overrun with decimal (6,6) and zerofill and group_concat
# valgrind will complain about this (the group_concat(f2)) on unpatched mysqld.
#
create table t1 (f1 decimal(6,6),f2 decimal(6,6) zerofill);
insert into t1 values (-0.123456,0.123456);
select group_concat(f1),group_concat(f2) from t1;
drop table t1;
#
# BUG#31450 "Query causes error 1048"
#
create table t1 (
ua_id decimal(22,0) not null,
ua_invited_by_id decimal(22,0) default NULL,
primary key(ua_id)
);
insert into t1 values (123, NULL), (456, NULL);
--echo this must not produce error 1048:
select * from t1 where ua_invited_by_id not in (select ua_id from t1);
drop table t1;
#
# Bug #30889: filesort and order by with float/numeric crashes server
#
--disable_warnings
DROP TABLE IF EXISTS t3;
DROP TABLE IF EXISTS t4;
--enable_warnings
CREATE TABLE t1( a NUMERIC, b INT );
INSERT INTO t1 VALUES (123456, 40), (123456, 40);
SELECT TRUNCATE( a, b ) AS c FROM t1 ORDER BY c;
SELECT ROUND( a, b ) AS c FROM t1 ORDER BY c;
SELECT ROUND( a, 100 ) AS c FROM t1 ORDER BY c;
CREATE TABLE t2( a NUMERIC, b INT );
INSERT INTO t2 VALUES (123456, 100);
SELECT TRUNCATE( a, b ) AS c FROM t2 ORDER BY c;
SELECT ROUND( a, b ) AS c FROM t2 ORDER BY c;
CREATE TABLE t3( a DECIMAL, b INT );
INSERT INTO t3 VALUES (123456, 40), (123456, 40);
SELECT TRUNCATE( a, b ) AS c FROM t3 ORDER BY c;
SELECT ROUND( a, b ) AS c FROM t3 ORDER BY c;
SELECT ROUND( a, 100 ) AS c FROM t3 ORDER BY c;
CREATE TABLE t4( a DECIMAL, b INT );
INSERT INTO t4 VALUES (123456, 40), (123456, 40);
SELECT TRUNCATE( a, b ) AS c FROM t4 ORDER BY c;
SELECT ROUND( a, b ) AS c FROM t4 ORDER BY c;
SELECT ROUND( a, 100 ) AS c FROM t4 ORDER BY c;
delete from t1;
INSERT INTO t1 VALUES (1234567890, 20), (999.99, 5);
show create table t1;
select round(a,b) as c from t1 order by c;
DROP TABLE t1, t2, t3, t4;
--echo End of 5.0 tests
SET STORAGE_ENGINE='tokudb';
#
# Problem with many enums
#
--disable_warnings
DROP TABLE if exists t1;
--enable_warnings
CREATE TABLE t1 (
field enum('001001','001004','001010','001018','001019','001020','001021','001027','001028','001029','001030','001031','001100','002003','002004','002005','002007','002008','002009','002012','002013','002014','003002','003003','003004','003005','003006','003007','003008','003009','003010','003011','003012','003013','003014','003015','003016','003017','003018','003019','004002','004003','004005','004006','004007','004008','004010','004012','004014','004016','004017','004020','004021','004022','004023','004024','004025','004026','006002','006004','006006','006010','006011','006012','006013','006014','007001','007002','007003','007004','007005','007006','007007','007008','007009','007010','007011','007012','007013','007014','007015','007016','007017','007018','007019','007020','007021','007022','007023','007024','007025','007026','007027','007028','007029','007030','007031','007032','007033','007034','007035','007036','007037','007038','007039','007040','007043','007044','009001','009002','009004','009005','009006','009007','009008','009009','009010','009011','009012','009013','010002','010003','010004','010005','010006','010007','010008','010009','010010','010011','010012','010013','010015','010016','010017','010018','010019','010020','010021','010022','010023','010024','010025','010026','010027','010028','011001','011002','011003','011004','011006','011012','011013','011014','011015','011016','012017','012018','012019','012023','012027','012028','012029','012030','012031','012032','012033','012034','012035','012036','012037','012038','012039','014001','016002','016003','016004','016007','016010','016011','016016','016019','016020','016021','016022','016023','016024','016026','016027','016028','016029','016030','016031','016032','016033','016034','017002','018001','019002','019004','020001','020003','020004','020005','020006','020007','020008','020009','022001','022002','022003','023001','023002','023003','023004','023005','023006','023007','023008','023010','023011','023012','023017','023019','023020','023021','023025','023026','023027','023028','023029','023030','023031','023032','023033','023034','023035','025001','025003','025004','025005','025006','025007','025008','025009','025010','025011','025012','025013','025014','025015','025016','025017','025018','025019','025020','025021','025022','025023','025024','025025','025026','025027','025028','025029','025030','025031','025032','025033','025034','025035','025036','025037','025038','025039','025040','025041','025042','025043','025044','025045','025046','025047','025048','025049','025050','025051','025052','025053','025054','025055','025056','025057','025058','025059','025060','025061','025062','025063','027001','027002','027011','035008','035012','036001','037001','037003','037004','037005','037006','037007','037008','037009','038004','038005','038006','038007','038009','039001','039002','039003','039004','039005','039006','046001','046002','046003','046004','046005','046007','046008','046009','046010','046011','046012','046013','046014','047001','047002','048001','051001','051002','051003','051004','052001','052002','052005','053015','053016','053019','053020','053023','053024','053026','053028','053029','053033','053034','053036','053037','053038','053039','053041','053042','053043','053045','053046','053047','053048','053051','053052','053054','053055','053056','053057','053068','053069','053070','053073','053074','053075','053086','053094','053095','053096','053097','053098','053099','053100','053101','053102','053103','053104','053105','053107','053122','053123','053124','053125','053127','053128','054001','054002','054003','054004','054005','054006','054007','054009','054010','056001','056002','056003','056004','056005','056006','056009','056010','056011','056016','056017','056018','056019','056020','056021','056022','057001','057002','057003','057004','058002','058003','058004','058005','060001','060003','060004','060005','060006','060007','061002','061003','061004','061005','061006','069006','069007','069010','069011','069012','069013','069014','069015','069016','069017','069018','069020','069021','069022','069023','069024','071002','071003','071004','071005','071006','071008','071011','071013','071020','071021','071022','072001','073001','073002','073003','073004','074001','074002','074003','074004','074005','074006','074007','074008','074009','074010','074011','074012','075001','075007','076101','076102','076103','077001','077002','077003','077004','077006','077007','077008','077009','078005','079002','079003','079004','079005','079006','079007','081001','082006','082007','082011','082013','082014','082015','082016','082017','082021','082022','082023','082024','082025','082026','082027','082028','082029','082030','082031','082032','082033','082034','082035','082036','082037','082038','082039','082040','082041','082042','082043','082044','084001','084002','084003','084004','084005','084007','084008','084009','084011','084013','084014','084016','084017','084027','084031','084032','084033','084035','084036','084037','084038','084039','084040','084041','084042','084043','084044','084045','084046','084047','084048','084049','084050','084051','085001','085002','085003','085004','085005','085006','085007','085009','085011','085012','085013','085014','085015','085016','085017','085018','085019','085020','085021','085022','085023','085028','085029','085030','085031','085033','085034','085035','085036','085037','085038','085040','085041','085042','085043','085044','085045','085046','085047','085048','085063','085064','085065','085068','085070','085071','085073','085082','085083','085086','085088','085089','085090','085091','085092','085093','085094','085095','085096','085097','085098','085099','085100','085101','085102','085103','085104','085105','085106','085107','085108','085109','085110','085111','085112','085113','085115','085119','085120','085121','085122','085123','085124','085125','085126','085127','085128','085129','085130','085132','085133','085134','085135','085136','085137','086001','086002','086003','086004','086005','088001','088003','088005','088006','088007','088008','088009','089001','090001','090002','090003','090004','090005','090006','090007','090008','090009','090010','090013','090015','090016','090017','090018','090019','090022','090027','090028','091001','091002','091005','091008','091009','091010','091011','091012','091013','091014','091015','091016','091017','091018','093001','093003','093098','093100','093102','093104','093141','093142','093146','093151','093153','093167','093168','093176','094001','094002','094004','094005','095004','099001','099002','100001','101001','102002','102003','105001','105002','106001','113001','113002','113003','113004','113005','113006','113007','113008','113009','113010','113011','113012','113013','113014','113015','113016','113017','113018','113019','113020','113021','113022','113023','113024','113025','113026','113027','113028','114001','115001','115002','115003','115004','115005','115006','115007','115008','115009','115010','115011','115012','115013','115014','115015','115016','115017','115018','115020','115021','115022','115023','115025','115026','115027','115028','115029','115030','115031','115032','115033','115034','115035','115036','115039','115040','115041','115042','115043','115044','115045','115046','115047','115048','115049','115050','115051','115052','115053','115054','115055','115056','115057','115059','115060','115061','115062','115063','115064','115065','115066','115067','115068','115069','115070','115071','115072','115073','115075','115076','115081','115082','115085','115086','115087','115088','115095','115096','115097','115098','115099','115101','115102','115103','115104','115105','115106','115108','115109','115110','115111','115112','115113','115114','115115','115116','115117','115118','115119','115120','115121','115122','116001','116002','116003','116004','116005','116006','116007','116008','116009','116010','116011','116012','117001','117002','117003','123001','124010','124014','124015','124019','124024','124025','124026','124027','124028','124029','124030','124031','124032','124033','124035','124036','124037','124038','124039','124040','124041','124042','124043','124044','124045','124046','124047','124048','124049','124050','124051','124052','124053','124054','124055','124056','124057','124058','124059','124060','124061','124062','124063','124064','124065','126001','126002','126003','126004','126005','126006','126007','126008','126009','126010','126011','126012','130001','132001','132002','132003','133001','133008','133009','133010','133011','133012','133013','133014','133015','133016','133017','133018','133019','133020','133021','133022','133023','133024','133025','133027','133028','133029','133030','133031','134001','135001','135002','135003','135004','135005','135006','135007','135008','135009','135010','136001','137009','137010','137011','137012','137013','137014','137015','137016','137017','137018','137019','138001','138002','138003','138004','139001','139003','140001','141001','141002','141003','141006','141007','141008','141009','141011','141012','141014','141015','141016','141017','141018','141019','141020','141021','141022','141023','141024','141025','141026','141027','141028','142001','142002','142003','142004','142005','142006','142007','142008','142010','142011','142012','144001','145001','145002','145003','145004','145005','145006','145007','145008','145009','145010','145011','145012','145013','145014','145015','145016','147001','150003','150005','150009','150013','150014','150015','150016','150017','150020','150021','152001','152002','152003','152004','152005','152006','152007','154001','154002','154003','155001','155002','155003','155004','155005','155006','159001','159002','159003','159004','160001','160002','160003','161001','162001','162002','162003','162004','162007','162010','162011','162012','163001','163002','163003','163005','163010','163011','163014','163015','163016','165001','165002','165003','165004','165005','165006','165007','165008','165009','165010','165011','165012','165013','165014','165015','165016','165017','165018','165019','165020','165021','165022','165023','165024','165025','165026','165027','165028','165029','165030','165031','165032','165033','165034','165035','165036','167001','168001','168002','168003','168004','168005','168007','168008','168009','168010','168011','168012','168013','168014','169001','169002','169003','169007','169008','169009','169010','170001','171001','171002','171003','171004','171005','171006','171007','171008','171009','172001','174001','174002','174003','176001','176002','176003','177001','177002','179001','179002','179003','179004','179005','179006','179007','179008','179009','179010','179011','179012','179013','179014','179015','179016','179017','179018','179019','179020','179021','179022','179023','179024','179025','179026','179027','179028','179029','179030','179031','179032','179033','179034','179035','179036','179037','179038','179039','179040','179041','179042','179043','179044','179045','179046','179047','180001','180010','180012','180013','180014','180015','180016','180017','180018','180019','180020','180021','180022','180023','180024','180025','180026','180027','180028','180030','180031','180032','180033','180034','180035','180036','180037','180038','180039','180041','180042','180043','180044','180045','180046','180047','180048','180049','180050','180051','180052','180053','180054','180055','180056','180057','180058','180059','180060','180061','180062','180063','180064','180065','180066','180067','180068','180069','180070','180071','182001','184001','184002','184005','184006','184007','184008','184009','184010','184011','185001','185003','187001','188001','188002','188003','188004','188005','188006','188007','188008','188009','188010','188011','191001','191002','192002','194001','194002','194003','194004','194005','194006','194007','195001','195002','195003','195004','195005','195006','195007','196001','196002','197001','197002','197003','197004','197005','197006','198001','198003','198004','198005','198006','198007','198008','198009','198010','198011','198012','198013','198014','198015','198016','198017','201001','201002','201005','202001','203001','203002','203003','203017','203018','203019','204001','204002','204003','205001','208001','208002','208003','208004','208005','209001','209002','209003','210001','210002','210003','210004','210005','210006','210007','210008','210009','210010','210011','210012','210013','211017','212001','212002','212003','212004','212005','212006','212007','212008','212009','212010','212011','212012','212013','218001','218003','218004','218006','218007','218008','218009','218011','218015','218016','218017','218018','218019','218020','218021','218022','218023','218024','218025','218026','218027','218028','218029','218030','218031','218032','218033','218034','218035','218036','221001','221002','221003','221004','221005','221006','221007','221008','221009','221010','221011','221012','221013','223001','223002','223003','224001','224002','224003','224006','224007','224008','225001','225002','225003','225004','225005','225006','225007','225008','225009','225010','225011','225012','225013','226001','226002','226003','226004','226005','226006','226007','226008','226009','227001','227002','227003','227004','227005','227006','227007','227008','227009','227010','227011','227012','227013','227014','227015','227016','227017','227018','227019','227020','227021','227022','227023','227024','227025','227026','227027','227028','227029','227030','227031','227032','227033','227034','227035','227036','227037','227038','227039','227040','227041','227042','227043','227044','227045','227046','227047','227048','227049','227050','227051','227052','227053','227054','227055','227056','227057','227058','227059','227060','227061','227062','227063','227064','227065','227066','227067','227068','227069','227070','227071','227072','227073','227074','227075','227076','227077','227078','227079','227080','227081','227082','227083','227084','227085','227086','227087','227088','227089','227090','227091','227092','227093','227094','227095','227096','227097','227098','227099','227100','227101','227102','227103','227104','227105','227106','227107','227108','227109','227110','227111','227112','227113','227114','227115','227116','227117','227118','227119','227120','227122','227123','227124','227125','227126','227127','227128','227129','227130','227131','227132','227133','227134','227135','227136','227137','227138','227139','227140','227141','227142','227143','227144','227145','227146','227147','227148','227149','227150','227151','227152','228001','229001','229002','229003','229004','229005','230001','230002','232001','233001','233002','233003','233004','233005','233006','233007','233008','234001','234002','234003','234004','234005','234006','234007','234008','234009','234010','234011','234012','234013','234014','234015','234016','234017','234018','234019','234020','234021','234022','234023','234024','234025','234026','234027','234028','234029','234030','235001','235002','235003','235004','235005','236001','236002','236003','237001','238002','238003','238004','238005','238006','238007','238008','333013','333014','333015','333016','333017','333018','333019','333020','333021','333022','333023','333024','333025','333030','333031','333032','333033','333034','333035','334001','334002','334003','334004','334005','334006','334007','336004','337001','337002','337003','337004','339001','339002','343001','344001','344002','344003','344004','344005','345001','345002','345003','347001','347002','348001','348002','348003','348004','348005','349001','349002','349003','350001','353001','353002','353003','353004','355001','355002','355003','355004','355005','355006','356001','358001','359001','359002','360001','360002','360003','360004','360005','366001','366002','366003','366004','369001','373001','373002','373003','373004','373005','373006','373007','373008','373009','373010','373011','373012','373013','373014','373015','373016','373017','373018','373019','373020','373021','374001','374002','374003','374004','374005','374006','374007','374008','374009','374010','374011','374012','374013','374014','374015','374016','376001','376002','376003','376004','376005','376006','376007','376008','376009','376010','376011','376012','376013','376016','376017','376018','376019','376020','376021','379003','382001','382002','383001','384001','384002','385001','385002','386001','386002','386003','386004','386005','386006','386007','386008','386009','386010','386011','386012','386013','386014','387001','389001','389002','389003','389004','392001','393001','393002','393003','393004','395001','396001','397001','397002','399001','399002','399003','400001','400002','401001','401002','401003','402001','402002','402003','402004','402005','403001','403002','403003','504001','504002','504004','504005','504006','504007','504008','504009','504010','504011','504012','504013','504014','504017','504018','504019','504021','504022','504023','504024','504025','506001','506002','508001','508002','511001','511002','511003','511004','511005','511006','511007','511008','511009','511010','511011','511012','511013','511014','511017','511018','511020','511021','511022','511024','511028','511029','513001','513002','513003','513004','514001','515001','515002','515003','515007','515008','515009','515010','515011','515012','515013','515014','515015','518001','518002','518003','520001','520002','521001','521002','521003','521004','521005','521006','521007','521008','521009','521010','521011','521012','521013','521014','521015','521016','523001','523002','523003','523004','523005','523006','523007','524001','700001','701001','701002','701003','702001','702002','702003','702004','702005','702006','702007','702008','703001','703002','703003','704001','704002','704003','704004','705001','706001','706002','707001','707002','707003','708001','709001','709002','710001','710002','711001','711002','712001','713001','713002','714001','714002','715001','716001','718001','718002','719001','719002','991001','991002','991003','991004','991005','991006','991007','991008','992001','995001','996001','996002','996003','998001','998002','998003','998004','998005','998006','998007','999001','999002','011017','011018','034001','034002','071010','208006','239001','519001','519003','126013','184012','053071','374017','374018','374019','374020','374021','404001','405002','405001','405003','405007','405006','405005','405004','240011','240010','240009','240008','240007','240006','240005','240004','240003','240002','240001','240012','240013','240014','240015','240016','240017','357001','235006','235007','712002','355008','355007','056023','999999','046015','019005','126014','241003','241002','241001','240018','240020','240019','242001','242002','242003','242004','242005','242006','089002','406001','406002','406003','406004','406005','406006','243001','243002','243003','243004','243005','243006','243007','243008','010030','010029','407001','407006','407005','407004','407003','407002','408001','366005','133032','016035','077010','996004','025064','011019','407007','407008','407009','409001','115123','504026','039007','039009','039008','039010','039011','039012','180072','240021','240023','408002','405008','235008','525001','525002','525003','525004','410001','410002','410003','410004','410005','410006','410007','410008','410009','410010','410011','410012','410013','410014','410015','410016','344006','240031','240030','240029','240028','240027','240026','240025','240024','240034','240033','240032','410017','410018','411001','411002','411003','411004','411005','411006','411007','411008','203020','203021','203022','412001','412002','412003','412004','069025','244001','244002','244009','244008','244007','244006','244005','244004','244003','244015','244014','244013','244012','244011','244010','244016','244017','240042','240041','240040','240039','240038','240037','240036','240035','405009','405010','240043','504034','504033','504032','504031','504030','504029','504028','504027','504042','504041','504040','504039','504038','504037','504036','504035','800001','410019','410020','410021','244018','244019','244020','399004','413001','504043','198018','198019','344007','082045','010031','010032','010033','010034','010035','504044','515016','801002','801003','801004','801005','802001','801001','414001','414002','414003','141029','141030','803001','803002','803003','803004','803005','803006','803007','803008','803009','803010','803011','803012','803013','803014','803015','803016','803017','410022','410023','803018','803019','803020','415002','415001','244021','011020','011023','011022','011021','025065','165037','165038','165039','416001','416002','416003','417001','418001','504045','803022','803021','240022','419001','420001','804010','804009','804008','804007','804006','804005','804004','804003','804002','804001','804020','804019','804018','804017','804016','804015','804014','804013','804012','804011','804024','804021','804023','804022','511019','511016','511015','511032','511031','511030','511027','511026','511025','511033','511023','133034','133033','169011','344008','344009','244022','244026','244025','244030','244023','244024','244027','244028','244029','244031','082046','082047','082048','126015','126016','416004','416005','421001','421002','016037','016036','115124','115125','115126','240049','240048','240047','240046','240045','240044','244032','244033','422001','422002','422003','422004','422005','184013','239002','805001','805002','805003','805004','805005','056024','423001','344010','235009','212014','056025','056026','802002','244034','244035','244036','244037','244038','244039','515017','504046','203015','245002','245001','071023','056027','056028','056029','056030','056031','056032','424001','056034','056033','805006','805007','805008','805009','805010','422008','422007','422006','422010','422009','422011','209004','150022','150023','100002','056035','023036','185004','185005','246001','247001','247002','425001','416006','165042','165041','165040','165043','010040','010039','010038','010037','010036','422012','422013','422014','422015','426000','248001','248002','248003','248004','248005','249001','249002','249003','249004','249005','249006','250007','250001','250002','250003','250004','250005','250006','250008','250009','250010','250011','250012','250013','251001','251002','422016','422017','422018','806001','806002','116013','235010','235011','091026','091027','091028','091029','091019','091020','091021','091022','091023','091024','091025','252001','243009','249007','249008','249009','011024','011025','427001','428002','428001','169012','429001','429002','429003') DEFAULT '001001' NOT NULL,
KEY field (field)
);
INSERT INTO t1 VALUES ('001001'),('001001'),('001001'),('001001'),('001001'),('001001'),('001001'),('001001'),('001001'),('001010'),('001010'),('001010'),('001010'),('001010'),('001018'),('001018'),('001018'),('001018'),('001018'),('001018'),('001020'),('001020'),('001020'),('001020'),('001020'),('001020'),('001020'),('001020'),('001021'),('001021'),('001021'),('001021'),('001021'),('001021'),('001027'),('001027'),('001028'),('001030'),('001030'),('001030'),('001030'),('001031'),('001031'),('001031'),('001031'),('001031'),('001100'),('001100'),('002003'),('002003'),('002003'),('002003'),('002003'),('002003'),('002003'),('002003'),('002003'),('002004'),('002004'),('002004'),('002004'),('002004'),('002004'),('002004'),('002004'),('002004'),('002005'),('002005'),('002005'),('002005'),('002005'),('002005'),('002005'),('002005'),('002007'),('002007'),('002007'),('002007'),('002007'),('002007'),('002007'),('002008'),('002008'),('002008'),('002008'),('002008'),('002008'),('002008'),('002008'),('002009'),('002009'),('002009'),('002009'),('002009'),('002009'),('002009'),('002009'),('002012'),('002012'),('002012'),('002012'),('002012'),('002012'),('002012'),('002013'),('002013'),('002013'),('002013'),('002013'),('002013'),('002013'),('002013'),('002013'),('002014'),('002014'),('002014'),('002014'),('002014'),('002014'),('002014'),('002014'),('003002'),('003002'),('003002'),('003002'),('003002'),('003002'),('003003'),('003003'),('003003'),('003003'),('003003'),('003003'),('003004'),('003004'),('003004'),('003004'),('003004'),('003004'),('003005'),('003005'),('003005'),('003005'),('003005'),('003005'),('003005'),('003005'),('003005'),('003006'),('003006'),('003006'),('003006'),('003006'),('003006'),('003006'),('003006'),('003007'),('003007'),('003007'),('003007'),('003007'),('003008'),('003008'),('003008'),('003008'),('003008'),('003008'),('003009'),('003009'),('003009'),('003009'),('003009'),('003009'),('003009'),('003009'),('003009'),('003010'),('003010'),('003010'),('003010'),('003010'),('003010'),('003010'),('003010'),('003010'),('003011'),('003011'),('003011'),('003011'),('003011'),('003011'),('003011'),('003011'),('003012'),('003012'),('003012'),('003012'),('003012'),('003012'),('003012'),('003012'),('003013'),('003013'),('003013'),('003013'),('003013'),('003013'),('003013'),('003013'),('003014'),('003014'),('003014'),('003014'),('003014'),('003014'),('003014'),('003014'),('003015'),('003015'),('003015'),('003015'),('003015'),('003015'),('003016'),('003016'),('003016'),('003016'),('003016'),('003016'),('003017'),('003017'),('003017'),('003017'),('003017'),('003018'),('003018'),('003018'),('003018'),('003018'),('003019'),('003019'),('004003'),('004005'),('004005'),('004005'),('004005'),('004005'),('004005'),('004006'),('004008'),('004010'),('004012'),('004012'),('004014'),('004014'),('004014'),('004014'),('004014'),('004016'),('004017'),('004017'),('004017'),('004017'),('004017'),('004017'),('004017'),('004017'),('004020'),('004020'),('004020'),('004020'),('004020'),('004020'),('004021'),('004021'),('004021'),('004021'),('004021'),('004021'),('004021'),('004022'),('004023'),('004023'),('004023'),('004023'),('004023'),('004023'),('004023'),('004025'),('004026'),('004026'),('004026'),('004026'),('004026'),('006004'),('006006'),('006010'),('006010'),('006010'),('006010'),('006010'),('006010'),('006010'),('006011'),('006011'),('006011'),('006011'),('006011'),('006011'),('006012'),('006012'),('006012'),('006012'),('006012'),('006012'),('006014'),('006014'),('006014'),('007001'),('007001'),('007002'),('007003'),('007005'),('007007'),('007008'),('007009'),('007011'),('007012'),('007013'),('007015'),('007016'),('007017'),('007018'),('007019'),('007019'),('007020'),('007021'),('007021'),('007022'),('007023'),('007023'),('007025'),('007025'),('007025'),('007027'),('007029'),('007031'),('007031'),('007032'),('007034'),('007034'),('007036'),('007036'),('007036'),('007037'),('007037'),('007038'),('007040'),('007040'),('007040'),('007043'),('009001'),('009001'),('009001'),('009001'),('009001'),('009001'),('009001'),('009002'),('009002'),('009002'),('009002'),('009002'),('009004'),('009004'),('009004'),('009004'),('009005'),('009005'),('009005'),('009005'),('009005'),('009005'),('009005'),('009005'),('009006'),('009006'),('009006'),('009006'),('009007'),('009007'),('009007'),('009007'),('009007'),('009007'),('009008'),('009010'),('009010'),('009010'),('009010'),('009010'),('009010'),('009011'),('009011'),('009011'),('009011'),('009011'),('009012'),('009013'),('009013'),('009013'),('010002'),('010002'),('010002'),('010002'),('010002'),('010002'),('010002'),('010002'),('010003'),('010003'),('010003'),('010003'),('010003'),('010003'),('010003'),('010003'),('010003'),('010004'),('010004'),('010004'),('010004'),('010004'),('010004'),('010004'),('010004'),('010004'),('010005'),('010005'),('010005'),('010005'),('010006'),('010006'),('010006'),('010006'),('010006'),('010006'),('010006'),('010006'),('010006'),('010007'),('010007'),('010007'),('010007'),('010007'),('010007'),('010008'),('010008'),('010008'),('010008'),('010008'),('010008'),('010008'),('010009'),('010009'),('010009'),('010009'),('010009'),('010009'),('010010'),('010010'),('010010'),('010010'),('010010'),('010010'),('010010'),('010011'),('010011'),('010011'),('010011'),('010011'),('010011'),('010011'),('010011'),('010012'),('010012'),('010012'),('010012'),('010012'),('010012'),('010012'),('010013'),('010013'),('010013'),('010013'),('010013'),('010013'),('010015'),('010016'),('010016'),('010016'),('010016'),('010016'),('010016'),('010016'),('010016'),('010017'),('010017'),('010017'),('010017'),('010017'),('010017'),('010018'),('010018'),('010018'),('010018'),('010018'),('010018'),('010018'),('010018'),('010018'),('010019'),('010019'),('010019'),('010019'),('010019'),('010019'),('010020'),('010020'),('010020'),('010021'),('010021'),('010021'),('010021'),('010021'),('010021'),('010022'),('010022'),('010022'),('010022'),('010022'),('010022'),('010022'),('010022'),('010023'),('010023'),('010023'),('010023'),('010023'),('010023'),('010023'),('010023'),('010026'),('010027'),('010028'),('010028'),('011001'),('011001'),('011001'),('011001'),('011001'),('011001'),('011001'),('011002'),('011002'),('011002'),('011002'),('011002'),('011002'),('011002'),('011003'),('011003'),('011003'),('011003'),('011003'),('011003'),('011003'),('011003'),('011004'),('011004'),('011004'),('011004'),('011004'),('011004'),('011004'),('011006'),('011006'),('011006'),('011006'),('011006'),('011006'),('011006'),('011012'),('011012'),('011012'),('011013'),('011013'),('011013'),('011013'),('011013'),('011013'),('011014'),('011014'),('011014'),('011014'),('011015'),('011015'),('011015'),('011015'),('011015'),('011016'),('011016'),('011016'),('011016'),('011016'),('012017'),('012017'),('012027'),('012027'),('012032'),('012034'),('012036'),('012036'),('012037'),('012037'),('012038'),('012039'),('014001'),('014001'),('016016'),('016016'),('016016'),('016019'),('016020'),('016020'),('016020'),('016020'),('016020'),('016020'),('016020'),('016020'),('016021'),('016021'),('016021'),('016021'),('016021'),('016021'),('016021'),('016022'),('016022'),('016022'),('016023'),('016023'),('016023'),('016024'),('016024'),('016024'),('016024'),('016024'),('016024'),('016024'),('016026'),('016026'),('016026'),('016026'),('016026'),('016026'),('016028'),('016028'),('016028'),('016028'),('016028'),('016028'),('016028'),('016029'),('016029'),('016030'),('016031'),('016032'),('016032'),('016032'),('016032'),('016032'),('016032'),('016032'),('016033'),('016033'),('016033'),('016033'),('016033'),('016034'),('016034'),('016034'),('016034'),('016034'),('017002'),('017002'),('017002'),('017002'),('017002'),('018001'),('018001'),('018001'),('018001'),('018001'),('018001'),('018001'),('018001'),('019002'),('019002'),('019002'),('019002'),('019002'),('019002'),('019004'),('019004'),('019004'),('019004'),('019004'),('019004'),('020001'),('020001'),('020001'),('020001'),('020004'),('020006'),('020006'),('020006'),('020006'),('020006'),('020006'),('020008'),('020009'),('020009'),('020009'),('020009'),('020009'),('022001'),('022001'),('022001'),('022001'),('022002'),('022002'),('022002'),('022002'),('022003'),('022003'),('022003'),('022003'),('023001'),('023002'),('023002'),('023002'),('023002'),('023002'),('023002'),('023003'),('023003'),('023003'),('023003'),('023004'),('023004'),('023005'),('023005'),('023006'),('023006'),('023006'),('023006'),('023006'),('023006'),('023007'),('023007'),('023010'),('023010'),('023011'),('023011'),('023017'),('023019'),('023019'),('023019'),('023020'),('023020'),('023025'),('023025'),('023025'),('023026'),('023026'),('023026'),('023027'),('023027'),('023027'),('023028'),('023028'),('023029'),('023029'),('023030'),('023030'),('023032'),('023033'),('023033'),('023033'),('023033'),('023033'),('023033'),('023034'),('023035'),('023035'),('025001'),('025001'),('025001'),('025001'),('025001'),('025001'),('025001'),('025003'),('025003'),('025004'),('025004'),('025005'),('025005'),('025007'),('025007'),('025008'),('025008'),('025009'),('025010'),('025010'),('025010'),('025011'),('025011'),('025012'),('025012'),('025013'),('025013'),('025013'),('025014'),('025015'),('025016'),('025018'),('025018'),('025019'),('025019'),('025020'),('025020'),('025021'),('025022'),('025022'),('025023'),('025023'),('025024'),('025025'),('025025'),('025026'),('025026'),('025027'),('025027'),('025027'),('025028'),('025030'),('025031'),('025033'),('025034'),('025035'),('025037'),('025041'),('025042'),('025043'),('025046'),('025048'),('025048'),('025048'),('025049'),('025049'),('025049'),('025050'),('025050'),('025050'),('025051'),('025051'),('025052'),('025052'),('025052'),('025053'),('025053'),('025054'),('025054'),('025054'),('025054'),('025055'),('025056'),('025056'),('025056'),('025056'),('025056'),('025056'),('025056'),('025056'),('025056'),('025057'),('025057'),('025058'),('025058'),('025060'),('025060'),('025061'),('025062'),('025063'),('027001'),('027002'),('027011'),('036001'),('036001'),('036001'),('036001'),('036001'),('037003'),('037006'),('037007'),('037008'),('037008'),('038009'),('039001'),('039001'),('039001'),('039001'),('039001'),('039001'),('039002'),('039002'),('039002'),('039002'),('039002'),('039003'),('039003'),('039003'),('039003'),('039003'),('039003'),('039004'),('039004'),('039004'),('039004'),('039004'),('039005'),('039005'),('039005'),('039005'),('039005'),('039006'),('039006'),('039006'),('039006'),('046001'),('046001'),('046001'),('046001'),('046001'),('046001'),('046001'),('046001'),('046002'),('046002'),('046002'),('046002'),('046002'),('046002'),('046002'),('046002'),('046003'),('046003'),('046003'),('046003'),('046003'),('046003'),('046003'),('046005'),('046005'),('046005'),('046005'),('046005'),('046005'),('046005'),('046007'),('046007'),('046007'),('046007'),('046007'),('046007'),('046008'),('046008'),('046008'),('046008'),('046008'),('046009'),('046009'),('046009'),('046010'),('046012'),('046012'),('046012'),('046013'),('046014'),('046014'),('046014'),('047001'),('047001'),('047001'),('047001'),('047001'),('047001'),('047001'),('047001'),('047002'),('047002'),('047002'),('047002'),('047002'),('047002'),('047002'),('047002'),('048001'),('048001'),('048001'),('048001'),('048001'),('048001'),('048001'),('048001'),('051003'),('051003'),('051003'),('051003'),('051003'),('051004'),('051004'),('051004'),('051004'),('052001'),('052001'),('052001'),('052001'),('052001'),('052001'),('052001'),('052001'),('052002'),('052002'),('052005'),('052005'),('052005'),('052005'),('052005'),('052005'),('053016'),('053019'),('053019'),('053023'),('053023'),('053023'),('053023'),('053024'),('053024'),('053024'),('053026'),('053026'),('053026'),('053026'),('053028'),('053028'),('053029'),('053029'),('053029'),('053029'),('053033'),('053033'),('053033'),('053045'),('053046'),('053051'),('053051'),('053051'),('053054'),('053054'),('053054'),('053054'),('053057'),('053069'),('053069'),('053097'),('053107'),('053125'),('053125'),('053127'),('054001'),('054001'),('054001'),('054001'),('054001'),('054001'),('054001'),('054002'),('054002'),('054002'),('054002'),('054002'),('054002'),('054003'),('054003'),('054003'),('054003'),('054003'),('054003'),('054003'),('054004'),('054004'),('054004'),('054004'),('054004'),('054004'),('054004'),('054006'),('054006'),('054006'),('054007'),('054007'),('054007'),('054007'),('054007'),('054009'),('054009'),('054009'),('054009'),('054010'),('054010'),('054010'),('054010'),('054010'),('054010'),('054010'),('056001'),('056001'),('056001'),('056001'),('056001'),('056001'),('056001'),('056001'),('056001'),('056002'),('056002'),('056002'),('056002'),('056002'),('056002'),('056002'),('056002'),('056003'),('056003'),('056003'),('056003'),('056003'),('056003'),('056004'),('056004'),('056004'),('056004'),('056004'),('056004'),('056004'),('056005'),('056005'),('056005'),('056005'),('056005'),('056005'),('056005'),('056005'),('056005'),('056006'),('056006'),('056006'),('056006'),('056006'),('056006'),('056006'),('056006'),('056006'),('056009'),('056009'),('056009'),('056011'),('056016'),('056016'),('056016'),('056016'),('056016'),('056016'),('056016'),('056017'),('056017'),('056017'),('056017'),('056017'),('056017'),('056017'),('056017'),('056017'),('056018'),('056018'),('056018'),('056018'),('056018'),('056018'),('056019'),('056019'),('056019'),('056019'),('056019'),('056019'),('056019'),('056019'),('056020'),('056020'),('056020'),('056020'),('056022'),('056022'),('056022'),('056022'),('056022'),('057003'),('057003'),('057004'),('058002'),('058002'),('058002'),('058002'),('058003'),('058003'),('058003'),('058003'),('058004'),('058004'),('058004'),('058005'),('058005'),('058005'),('060001'),('060001'),('060001'),('060001'),('060001'),('060004'),('060004'),('060004'),('060004'),('060004'),('060004'),('060005'),('060005'),('060005'),('060005'),('060005'),('060005'),('060007'),('060007'),('060007'),('060007'),('060007'),('060007'),('060007'),('061004'),('061004'),('061004'),('061004'),('061004'),('061004'),('061006'),('061006'),('061006'),('061006'),('061006'),('061006'),('069006'),('069006'),('069006'),('069006'),('069006'),('069006'),('069006'),('069006'),('069006'),('069007'),('069007'),('069007'),('069007'),('069007'),('069007'),('069007'),('069007'),('069010'),('069010'),('069010'),('069010'),('069010'),('069010'),('069011'),('069012'),('069012'),('069012'),('069012'),('069012'),('069012'),('069012'),('069012'),('069012'),('069012'),('069013'),('069013'),('069013'),('069013'),('069013'),('069013'),('069013'),('069013'),('069013'),('069014'),('069014'),('069014'),('069014'),('069014'),('069014'),('069014'),('069014'),('069014'),('069015'),('069015'),('069015'),('069015'),('069015'),('069015'),('069015'),('069015'),('069015'),('069015'),('069016'),('069016'),('069016'),('069016'),('069016'),('069018'),('069018'),('069018'),('069018'),('069018'),('069018'),('069018'),('069018'),('069018'),('069020'),('069020'),('069020'),('069020'),('069021'),('069023'),('071002'),('071002'),('071002'),('071002'),('071002'),('071003'),('071003'),('071003'),('071003'),('071003'),('071004'),('071004'),('071004'),('071004'),('071004'),('071005'),('071005'),('071005'),('071005'),('071005'),('071005'),('071006'),('071006'),('071006'),('071006'),('071008'),('071008'),('071008'),('071008'),('071008'),('071008'),('071011'),('071011'),('071011'),('071011'),('071011'),('071020'),('071020'),('071020'),('071020'),('071020'),('071021'),('071022'),('071022'),('071022'),('072001'),('072001'),('074001'),('074002'),('074002'),('074002'),('074002'),('074002'),('074002'),('074002'),('074002'),('074003'),('074003'),('074003'),('074003'),('074003'),('074003'),('074003'),('074003'),('074004'),('074004'),('074004'),('074004'),('074004'),('074004'),('074004'),('074004'),('074005'),('074005'),('074005'),('074005'),('074005'),('074005'),('074005'),('074005'),('074006'),('074006'),('074006'),('074006'),('074006'),('074006'),('074006'),('074006'),('074007'),('074007'),('074007'),('074007'),('074007'),('074007'),('074007'),('074007'),('074008'),('074008'),('074008'),('074008'),('074008'),('074008'),('074008'),('074008'),('074009'),('074009'),('074009'),('074009'),('074009'),('074009'),('074009'),('074009'),('074010'),('074010'),('074010'),('074010'),('074010'),('074010'),('074010'),('074010'),('074011'),('074011'),('074011'),('074011'),('074011'),('074011'),('074011'),('074011'),('074012'),('074012'),('074012'),('074012'),('074012'),('074012'),('074012'),('075001'),('075001'),('075001'),('075007'),('075007'),('075007'),('075007'),('076101'),('076101'),('076101'),('076101'),('076102'),('076102'),('076102'),('076103'),('076103'),('076103'),('076103'),('076103'),('077001'),('077001'),('077001'),('077002'),('077002'),('077002'),('077002'),('077002'),('077002'),('077002'),('077003'),('077003'),('077003'),('077003'),('077003'),('077003'),('077003'),('077004'),('077004'),('077004'),('077004'),('077004'),('077004'),('077006'),('077006'),('077008'),('077008'),('077008'),('077008'),('077008'),('077008'),('077008'),('077009'),('077009'),('077009'),('077009'),('077009'),('077009'),('077009'),('078005'),('078005'),('078005'),('079002'),('079002'),('079002'),('079002'),('079002'),('079002'),('079002'),('079003'),('079003'),('079004'),('079004'),('079005'),('079005'),('079005'),('079005'),('079005'),('079005'),('079006'),('079006'),('079006'),('079006'),('079007'),('079007'),('079007'),('079007'),('079007'),('081001'),('081001'),('081001'),('081001'),('081001'),('082011'),('082011'),('082011'),('082011'),('082011'),('082013'),('082013'),('082013'),('082013'),('082013'),('082013'),('082014'),('082014'),('082014'),('082014'),('082014'),('082014'),('082014'),('082015'),('082015'),('082015'),('082015'),('082015'),('082016'),('082016'),('082016'),('082016'),('082016'),('082016'),('082017'),('082017'),('082017'),('082017'),('082017'),('082017'),('082017'),('082021'),('082021'),('082022'),('082022'),('082022'),('082022'),('082022'),('082023'),('082023'),('082023'),('082023'),('082023'),('082024'),('082024'),('082024'),('082024'),('082024'),('082025'),('082025'),('082025'),('082025'),('082025'),('082026'),('082026'),('082026'),('082026'),('082026'),('082027'),('082027'),('082027'),('082027'),('082027'),('082028'),('082028'),('082028'),('082028'),('082029'),('082029'),('082029'),('082029'),('082029'),('082030'),('082030'),('082030'),('082030'),('082031'),('082031'),('082031'),('082031'),('082031'),('082032'),('082032'),('082032'),('082033'),('082033'),('082034'),('082034'),('082034'),('082034'),('082034'),('082034'),('082034'),('082035'),('082035'),('082035'),('082036'),('082036'),('082036'),('082036'),('082037'),('082037'),('082037'),('082038'),('082038'),('082038'),('082038'),('082039'),('082039'),('082039'),('082039'),('082040'),('082040'),('082040'),('082040'),('082040'),('082041'),('082041'),('082041'),('082041'),('082042'),('082042'),('082043'),('082043'),('082043'),('082043'),('082043'),('082044'),('082044'),('082044'),('082044'),('084001'),('084002'),('084002'),('084002'),('084002'),('084003'),('084003'),('084003'),('084003'),('084003'),('084003'),('084003'),('084003'),('084004'),('084004'),('084004'),('084004'),('084004'),('084005'),('084005'),('084005'),('084005'),('084005'),('084007'),('084007'),('084007'),('084007'),('084007'),('084007'),('084008'),('084008'),('084008'),('084008'),('084008'),('084008'),('084009'),('084009'),('084009'),('084009'),('084009'),('084009'),('084011'),('084013'),('084013'),('084013'),('084013'),('084013'),('084014'),('084014'),('084014'),('084016'),('084016'),('084016'),('084016'),('084016'),('084016'),('084016'),('084016'),('084017'),('084017'),('084017'),('084017'),('084017'),('084017'),('084017'),('084017'),('084017'),('084027'),('084027'),('084027'),('084027'),('084027'),('084027'),('084032'),('084032'),('084033'),('084033'),('084033'),('084035'),('084035'),('084035'),('084036'),('084036'),('084036'),('084036'),('084036'),('084036'),('084037'),('084037'),('084038'),('084038'),('084038'),('084038'),('084038'),('084038'),('084039'),('084039'),('084039'),('084039'),('084040'),('084040'),('084040'),('084040'),('084040'),('084041'),('084041'),('084041'),('084041'),('084042'),('084042'),('084043'),('084043'),('084043'),('084043'),('084044'),('084044'),('084044'),('084044'),('084044'),('084045'),('084046'),('084046'),('084046'),('084047'),('084048'),('084048'),('084049'),('084049'),('084050'),('084051'),('084051'),('085001'),('085001'),('085001'),('085001'),('085001'),('085001'),('085002'),('085002'),('085002'),('085002'),('085003'),('085003'),('085003'),('085003'),('085003'),('085003'),('085003'),('085004'),('085004'),('085004'),('085004'),('085004'),('085004'),('085004'),('085005'),('085005'),('085005'),('085005'),('085005'),('085005'),('085006'),('085006'),('085006'),('085006'),('085006'),('085006'),('085006'),('085006'),('085007'),('085007'),('085007'),('085007'),('085007'),('085007'),('085007'),('085009'),('085009'),('085009'),('085009'),('085009'),('085009'),('085011'),('085011'),('085011'),('085011'),('085011'),('085011'),('085011'),('085011'),('085012'),('085012'),('085012'),('085012'),('085012'),('085012'),('085012'),('085014'),('085014'),('085014'),('085014'),('085014'),('085014'),('085014'),('085014'),('085014'),('085015'),('085015'),('085015'),('085015'),('085015'),('085015'),('085015'),('085015'),('085016'),('085016'),('085016'),('085016'),('085016'),('085016'),('085016'),('085016'),('085017'),('085017'),('085017'),('085017'),('085017'),('085018'),('085018'),('085018'),('085018'),('085018'),('085019'),('085019'),('085019'),('085019'),('085019'),('085019'),('085019'),('085019'),('085019'),('085020'),('085020'),('085020'),('085020'),('085020'),('085020'),('085022'),('085022'),('085022'),('085022'),('085022'),('085022'),('085023'),('085023'),('085023'),('085023'),('085023'),('085028'),('085028'),('085028'),('085028'),('085028'),('085028'),('085028'),('085029'),('085029'),('085029'),('085029'),('085029'),('085029'),('085029'),('085030'),('085030'),('085030'),('085030'),('085030'),('085030'),('085030'),('085031'),('085031'),('085031'),('085031'),('085031'),('085031'),('085031'),('085033'),('085034'),('085034'),('085034'),('085034'),('085034'),('085034'),('085034'),('085035'),('085035'),('085035'),('085035'),('085035'),('085035'),('085036'),('085036'),('085036'),('085036'),('085036'),('085036'),('085037'),('085037'),('085037'),('085037'),('085037'),('085037'),('085038'),('085038'),('085038'),('085038'),('085038'),('085038'),('085038'),('085040'),('085040'),('085040'),('085040'),('085040'),('085040'),('085040'),('085040'),('085041'),('085041'),('085041'),('085041'),('085041'),('085041'),('085041'),('085041'),('085042'),('085042'),('085042'),('085042'),('085042'),('085042'),('085042'),('085043'),('085043'),('085043'),('085043'),('085043'),('085043'),('085044'),('085044'),('085044'),('085044'),('085044'),('085044'),('085044'),('085045'),('085045'),('085045'),('085045'),('085045'),('085046'),('085046'),('085046'),('085046'),('085046'),('085046'),('085046'),('085046'),('085047'),('085047'),('085047'),('085047'),('085047'),('085047'),('085047'),('085047'),('085048'),('085048'),('085048'),('085048'),('085048'),('085048'),('085048'),('085063'),('085063'),('085063'),('085063'),('085063'),('085064'),('085064'),('085064'),('085064'),('085064'),('085065'),('085065'),('085068'),('085068'),('085068'),('085068'),('085068'),('085068'),('085071'),('085071'),('085071'),('085071'),('085071'),('085071'),('085073'),('085073'),('085082'),('085082'),('085082'),('085082'),('085082'),('085086'),('085086'),('085086'),('085088'),('085088'),('085088'),('085088'),('085088'),('085088'),('085088'),('085089'),('085089'),('085090'),('085090'),('085090'),('085090'),('085090'),('085090'),('085090'),('085090'),('085091'),('085091'),('085091'),('085091'),('085091'),('085092'),('085092'),('085092'),('085093'),('085093'),('085095'),('085095'),('085095'),('085095'),('085095'),('085096'),('085096'),('085096'),('085096'),('085096'),('085096'),('085097'),('085097'),('085097'),('085097'),('085097'),('085098'),('085098'),('085098'),('085098'),('085098'),('085098'),('085098'),('085099'),('085099'),('085099'),('085099'),('085099'),('085099'),('085099'),('085100'),('085100'),('085100'),('085100'),('085100'),('085100'),('085100'),('085100'),('085100'),('085100'),('085101'),('085101'),('085101'),('085101'),('085101'),('085101'),('085101'),('085101'),('085102'),('085102'),('085103'),('085103'),('085103'),('085104'),('085104'),('085104'),('085104'),('085104'),('085105'),('085105'),('085106'),('085106'),('085106'),('085106'),('085106'),('085106'),('085108'),('085108'),('085109'),('085109'),('085109'),('085109'),('085109'),('085109'),('085109'),('085109'),('085110'),('085110'),('085110'),('085110'),('085110'),('085111'),('085111'),('085111'),('085112'),('085112'),('085112'),('085112'),('085113'),('085113'),('085113'),('085113'),('085113'),('085115'),('085120'),('085121'),('085121'),('085121'),('085121'),('085122'),('085122'),('085122'),('085122'),('085122'),('085122'),('085122'),('085122'),('085123'),('085123'),('085123'),('085123'),('085123'),('085123'),('085123'),('085123'),('085125'),('085125'),('085125'),('085125'),('085125'),('085126'),('085126'),('085126'),('085126'),('085126'),('085127'),('085127'),('085127'),('085127'),('085127'),('085127'),('085127'),('085127'),('085128'),('085128'),('085128'),('085128'),('085128'),('085129'),('085129'),('085129'),('085129'),('085129'),('085130'),('085130'),('085130'),('085130'),('085130'),('085132'),('085132'),('085132'),('085132'),('085132'),('085132'),('085133'),('085133'),('085133'),('085133'),('085133'),('085134'),('085134'),('085134'),('085135'),('085135'),('085135'),('085136'),('085136'),('085136'),('085136'),('085137'),('085137'),('085137'),('085137'),('085137'),('085137'),('085137'),('086002'),('086002'),('086002'),('086002'),('086003'),('086003'),('086003'),('086003'),('086005'),('088001'),('088001'),('088001'),('088001'),('088001'),('088003'),('088003'),('088003'),('088003'),('088003'),('088003'),('088005'),('088005'),('088005'),('088005'),('088005'),('088006'),('088006'),('088006'),('088006'),('088006'),('088007'),('088007'),('088007'),('088008'),('088008'),('088008'),('088008'),('088009'),('088009'),('088009'),('088009'),('088009'),('089001'),('089001'),('089001'),('089001'),('089001'),('089001'),('089001'),('090001'),('090001'),('090001'),('090001'),('090001'),('090001'),('090001'),('090002'),('090002'),('090002'),('090002'),('090002'),('090002'),('090003'),('090003'),('090003'),('090003'),('090003'),('090003'),('090003'),('090004'),('090004'),('090004'),('090004'),('090004'),('090004'),('090004'),('090006'),('090006'),('090006'),('090006'),('090006'),('090006'),('090006'),('090008'),('090008'),('090008'),('090008'),('090008'),('090009'),('090009'),('090009'),('090009'),('090009'),('090010'),('090010'),('090013'),('090013'),('090013'),('090016'),('090016'),('090017'),('090018'),('090022'),('090027'),('091001'),('091001'),('091001'),('091001'),('091001'),('091001'),('091002'),('091002'),('091002'),('091002'),('091002'),('091002'),('091009'),('091009'),('091009'),('091009'),('091009'),('091011'),('091011'),('091011'),('091011'),('091011'),('091011'),('091011'),('091012'),('091012'),('091013'),('091013'),('091013'),('091013'),('091013'),('091013'),('091015'),('091015'),('091015'),('091015'),('091015'),('091015'),('091016'),('091016'),('091016'),('091016'),('091016'),('091017'),('091017'),('091018'),('091018'),('091018'),('091018'),('093003'),('093003'),('093003'),('093003'),('093003'),('093003'),('099001'),('099001'),('099001'),('099001'),('099001'),('099001'),('099001'),('100001'),('100001'),('100001'),('100001'),('106001'),('113005'),('113005'),('113005'),('113006'),('113006'),('113018'),('113019'),('113020'),('115001'),('115001'),('115001'),('115002'),('115002'),('115003'),('115004'),('115004'),('115004'),('115004'),('115005'),('115005'),('115005'),('115006'),('115006'),('115006'),('115007'),('115007'),('115007'),('115007'),('115007'),('115008'),('115008'),('115008'),('115009'),('115010'),('115010'),('115010'),('115010'),('115010'),('115011'),('115011'),('115011'),('115011'),('115012'),('115012'),('115013'),('115013'),('115013'),('115014'),('115014'),('115014'),('115014'),('115015'),('115015'),('115015'),('115016'),('115016'),('115016'),('115016'),('115017'),('115017'),('115017'),('115017'),('115017'),('115018'),('115018'),('115020'),('115020'),('115021'),('115021'),('115022'),('115022'),('115022'),('115023'),('115023'),('115023'),('115023'),('115023'),('115025'),('115025'),('115025'),('115026'),('115026'),('115027'),('115027'),('115027'),('115028'),('115028'),('115028'),('115028'),('115029'),('115029'),('115029'),('115030'),('115030'),('115030'),('115031'),('115031'),('115032'),('115032'),('115032'),('115033'),('115033'),('115033'),('115033'),('115034'),('115034'),('115034'),('115035'),('115035'),('115036'),('115036'),('115036'),('115036'),('115036'),('115039'),('115040'),('115040'),('115040'),('115041'),('115041'),('115041'),('115041'),('115041'),('115042'),('115042'),('115042'),('115042'),('115042'),('115043'),('115043'),('115043'),('115044'),('115044'),('115044'),('115044'),('115046'),('115046'),('115046'),('115047'),('115048'),('115050'),('115050'),('115050'),('115050'),('115050'),('115051'),('115051'),('115051'),('115052'),('115053'),('115053'),('115054'),('115054'),('115054'),('115055'),('115055'),('115055'),('115057'),('115059'),('115059'),('115059'),('115059'),('115060'),('115060'),('115060'),('115060'),('115060'),('115060'),('115061'),('115061'),('115061'),('115062'),('115062'),('115062'),('115062'),('115064'),('115064'),('115064'),('115065'),('115065'),('115065'),('115065'),('115066'),('115066'),('115066'),('115067'),('115067'),('115067'),('115068'),('115068'),('115068'),('115069'),('115069'),('115069'),('115069'),('115069'),('115070'),('115070'),('115070'),('115071'),('115071'),('115071'),('115072'),('115072'),('115072'),('115073'),('115073'),('115075'),('115075'),('115075'),('115076'),('115076'),('115076'),('115076'),('115076'),('115076'),('115081'),('115081'),('115081'),('115082'),('115082'),('115082'),('115085'),('115085'),('115085'),('115085'),('115085'),('115086'),('115086'),('115086'),('115087'),('115087'),('115088'),('115088'),('115088'),('115088'),('115088'),('115095'),('115095'),('115095'),('115096'),('115096'),('115097'),('115097'),('115098'),('115098'),('115099'),('115101'),('115102'),('115102'),('115102'),('115103'),('115103'),('115104'),('115104'),('115104'),('115104'),('115105'),('115105'),('115106'),('115106'),('115106'),('115106'),('115106'),('115108'),('115109'),('115111'),('115111'),('115111'),('115111'),('115112'),('115112'),('115112'),('115112'),('115112'),('115113'),('115113'),('115113'),('115114'),('115114'),('115114'),('115114'),('115114'),('115115'),('115115'),('115115'),('115115'),('115116'),('115117'),('115117'),('115117'),('115118'),('115118'),('115119'),('115119'),('115119'),('115119'),('115120'),('115121'),('115121'),('115122'),('115122'),('116001'),('116003'),('116003'),('116003'),('116003'),('116004'),('116004'),('116005'),('116005'),('116006'),('116006'),('116006'),('116007'),('116007'),('116008'),('116008'),('116009'),('116009'),('116009'),('116010'),('116010'),('116010'),('116010'),('116011'),('116011'),('116011'),('116011'),('116012'),('116012'),('123001'),('123001'),('123001'),('123001'),('123001'),('124065'),('126001'),('126001'),('126001'),('126001'),('126001'),('126001'),('126001'),('126001'),('126002'),('126002'),('126002'),('126002'),('126002'),('126002'),('126002'),('126002'),('126003'),('126003'),('126003'),('126003'),('126003'),('126003'),('126003'),('126003'),('126003'),('126004'),('126004'),('126004'),('126004'),('126004'),('126004'),('126004'),('126004'),('126004'),('126004'),('126005'),('126005'),('126005'),('126005'),('126005'),('126005'),('126005'),('126005'),('126005'),('126006'),('126006'),('126006'),('126006'),('126006'),('126006'),('126006'),('126006'),('126006'),('126007'),('126007'),('126007'),('126007'),('126007'),('126007'),('126007'),('126008'),('126008'),('126008'),('126008'),('126008'),('126008'),('126008'),('126008'),('126009'),('126009'),('126009'),('126009'),('126009'),('126009'),('126009'),('126009'),('126010'),('126010'),('126010'),('126010'),('126010'),('126010'),('126010'),('126010'),('126010'),('126011'),('126011'),('126011'),('126011'),('126011'),('126011'),('126011'),('126012'),('126012'),('126012'),('126012'),('130001'),('130001'),('130001'),('130001'),('132001'),('132001'),('132001'),('132001'),('132001'),('132002'),('132002'),('132002'),('132002'),('132002'),('132002'),('132002'),('133001'),('133001'),('133008'),('133009'),('133010'),('133011'),('133011'),('133011'),('133011'),('133011'),('133011'),('133012'),('133015'),('133015'),('133015'),('133015'),('133016'),('133018'),('133018'),('133018'),('133018'),('133018'),('133019'),('133021'),('133021'),('133022'),('133022'),('133023'),('133023'),('133024'),('133024'),('133024'),('133024'),('133024'),('133024'),('133025'),('133027'),('133027'),('133027'),('133027'),('133027'),('133028'),('133028'),('133028'),('133029'),('133029'),('133029'),('133029'),('133029'),('133029'),('133030'),('133030'),('133031'),('133031'),('133031'),('134001'),('134001'),('134001'),('135001'),('135001'),('135001'),('135001'),('135001'),('135002'),('135002'),('135002'),('135004'),('135010'),('135010'),('135010'),('135010'),('135010'),('135010'),('137010'),('137011'),('137012'),('137014'),('137015'),('137015'),('137016'),('137019'),('139001'),('140001'),('140001'),('140001'),('140001'),('140001'),('140001'),('141001'),('141001'),('141001'),('141001'),('141001'),('141002'),('141002'),('141002'),('141002'),('141002'),('141003'),('141003'),('141003'),('141003'),('141003'),('141003'),('141003'),('141003'),('141006'),('141006'),('141006'),('141006'),('141006'),('141006'),('141006'),('141006'),('141007'),('141007'),('141007'),('141007'),('141007'),('141009'),('141009'),('141009'),('141009'),('141009'),('141011'),('141011'),('141011'),('141011'),('141011'),('141011'),('141012'),('141014'),('141014'),('141014'),('141014'),('141014'),('141014'),('141014'),('141014'),('141015'),('141015'),('141015'),('141015'),('141015'),('141016'),('141016'),('141016'),('141016'),('141016'),('141016'),('141017'),('141017'),('141017'),('141017'),('141017'),('141017'),('141018'),('141018'),('141018'),('141018'),('141019'),('141019'),('141019'),('141019'),('141020'),('141020'),('141020'),('141020'),('141020'),('141020'),('141020'),('141021'),('141021'),('141021'),('141021'),('141021'),('141021'),('141022'),('141022'),('141022'),('141022'),('141022'),('141022'),('141023'),('141023'),('141023'),('141023'),('141023'),('141023'),('141023'),('141024'),('141025'),('141025'),('141025'),('141026'),('141026'),('141026'),('141026'),('141026'),('141026'),('141027'),('141027'),('141027'),('141027'),('141027'),('141028'),('141028'),('145001'),('145001'),('145001'),('145001'),('145001'),('145001'),('145001'),('145001'),('145001'),('145002'),('145002'),('145002'),('145002'),('145002'),('145002'),('145002'),('145002'),('145002'),('145003'),('145003'),('145003'),('145003'),('145003'),('145003'),('145003'),('145003'),('145003'),('145003'),('145004'),('145004'),('145004'),('145004'),('145004'),('145004'),('145004'),('145004'),('145004'),('145005'),('145005'),('145005'),('145005'),('145005'),('145005'),('145005'),('145005'),('145005'),('145006'),('145006'),('145006'),('145006'),('145006'),('145006'),('145006'),('145006'),('145006'),('145008'),('145008'),('145008'),('145008'),('145008'),('145008'),('145008'),('145008'),('145009'),('145009'),('145009'),('145009'),('145009'),('145009'),('145009'),('145011'),('145011'),('145011'),('145011'),('145011'),('145011'),('145011'),('145011'),('145012'),('145012'),('145012'),('145012'),('145012'),('145012'),('145012'),('145012'),('145013'),('145013'),('145013'),('145013'),('145013'),('145013'),('145013'),('150009'),('150013'),('150014'),('150015'),('150015'),('150015'),('150016'),('150016'),('150017'),('150017'),('150017'),('150017'),('150020'),('152001'),('152001'),('152001'),('152002'),('152003'),('152003'),('152003'),('152003'),('152004'),('152005'),('152006'),('152006'),('152006'),('152006'),('152007'),('154001'),('154002'),('154002'),('155001'),('155001'),('155002'),('155003'),('155004'),('155004'),('155006'),('159001'),('159003'),('160001'),('160001'),('160001'),('160001'),('160002'),('160002'),('161001'),('162002'),('162002'),('162003'),('162003'),('162003'),('162003'),('162003'),('162007'),('162012'),('162012'),('162012'),('163001'),('163001'),('163001'),('163011'),('163015'),('163016'),('163016'),('165001'),('165001'),('165001'),('165001'),('165002'),('165002'),('165002'),('165002'),('165003'),('165003'),('165003'),('165004'),('165004'),('165004'),('165005'),('165005'),('165005'),('165006'),('165006'),('165006'),('165006'),('165007'),('165007'),('165007'),('165007'),('165008'),('165008'),('165008'),('165008'),('165009'),('165009'),('165009'),('165009'),('165010'),('165010'),('165010'),('165011'),('165011'),('165012'),('165012'),('165012'),('165013'),('165013'),('165013'),('165014'),('165014'),('165014'),('165015'),('165015'),('165015'),('165015'),('165016'),('165016'),('165016'),('165017'),('165017'),('165017'),('165017'),('165018'),('165018'),('165018'),('165018'),('165019'),('165019'),('165019'),('165019'),('165020'),('165020'),('165020'),('165020'),('165021'),('165021'),('165021'),('165021'),('165022'),('165022'),('165022'),('165023'),('165024'),('165024'),('165024'),('165025'),('165025'),('165025'),('165026'),('165026'),('165026'),('165028'),('165029'),('165030'),('165030'),('165030'),('165031'),('165031'),('165033'),('165033'),('165034'),('165034'),('165034'),('165035'),('165035'),('165035'),('165036'),('165036'),('165036'),('168003'),('168003'),('168004'),('168005'),('168014'),('169001'),('169001'),('169001'),('169001'),('169001'),('169001'),('169001'),('169001'),('169001'),('169001'),('169002'),('169002'),('169002'),('169002'),('169002'),('169002'),('169002'),('169002'),('169002'),('169002'),('169003'),('169003'),('169003'),('169003'),('169007'),('169007'),('169007'),('169007'),('169007'),('169007'),('169007'),('169007'),('169007'),('169007'),('169008'),('169008'),('169008'),('169008'),('169008'),('169008'),('169008'),('169009'),('169009'),('169009'),('169009'),('169010'),('171006'),('171006'),('171007'),('171007'),('171008'),('171008'),('171008'),('171009'),('171009'),('171009'),('172001'),('176001'),('176001'),('176001'),('176001'),('176001'),('176001'),('176001'),('176002'),('176002'),('176002'),('176002'),('176002'),('176003'),('176003'),('176003'),('176003'),('176003'),('176003'),('177001'),('177001'),('177001'),('177001'),('177001'),('177001'),('179007'),('179007'),('179012'),('179012'),('179012'),('179012'),('179012'),('179012'),('179013'),('179013'),('179013'),('179013'),('179013'),('179013'),('179042'),('179044'),('179045'),('180001'),('180013'),('180014'),('180014'),('180015'),('180017'),('180018'),('180020'),('180020'),('180021'),('180021'),('180027'),('180030'),('180033'),('180035'),('180036'),('180037'),('180038'),('180041'),('180042'),('180045'),('180045'),('180047'),('180048'),('180049'),('180050'),('180054'),('180060'),('180066'),('180067'),('180068'),('180070'),('182001'),('184001'),('184002'),('184005'),('184005'),('184005'),('184005'),('184006'),('184006'),('184006'),('184006'),('184008'),('184008'),('184008'),('184008'),('184009'),('184009'),('184009'),('184009'),('184010'),('184010'),('184010'),('184010'),('184011'),('184011'),('184011'),('184011'),('185001'),('185001'),('185001'),('185001'),('185001'),('185001'),('185001'),('185003'),('185003'),('185003'),('185003'),('185003'),('185003'),('185003'),('187001'),('191002'),('191002'),('192002'),('194003'),('197001'),('197001'),('197001'),('197001'),('197001'),('197001'),('197001'),('197002'),('197002'),('197002'),('197002'),('197002'),('197002'),('197002'),('197003'),('197003'),('197003'),('197003'),('197003'),('197003'),('197003'),('197004'),('197004'),('197004'),('197004'),('197004'),('197004'),('197004'),('197005'),('197005'),('197005'),('197005'),('197005'),('197005'),('197006'),('197006'),('197006'),('197006'),('197006'),('198001'),('198001'),('198001'),('198001'),('198001'),('198001'),('198003'),('198003'),('198003'),('198004'),('198004'),('198004'),('198004'),('198004'),('198004'),('198005'),('198005'),('198005'),('198005'),('198005'),('198005'),('198005'),('198006'),('198006'),('198006'),('198006'),('198006'),('198006'),('198007'),('198007'),('198007'),('198007'),('198007'),('198007'),('198007'),('198008'),('198008'),('198008'),('198008'),('198008'),('198008'),('198009'),('198009'),('198009'),('198009'),('198009'),('198009'),('198009'),('198010'),('198010'),('198010'),('198010'),('198010'),('198010'),('198011'),('198012'),('198012'),('198012'),('198012'),('198015'),('198015'),('198016'),('198016'),('198016'),('198016'),('198016'),('198016'),('198017'),('198017'),('198017'),('198017'),('198017'),('198017'),('201001'),('201001'),('201001'),('201001'),('201001'),('201002'),('202001'),('202001'),('203001'),('203001'),('203001'),('203001'),('203001'),('203001'),('203001'),('203002'),('203002'),('203002'),('203002'),('203003'),('203003'),('203003'),('203003'),('203003'),('203017'),('203017'),('203017'),('203017'),('203017'),('203017'),('203017'),('203017'),('203017'),('203018'),('203018'),('203018'),('203018'),('203018'),('203019'),('203019'),('203019'),('203019'),('203019'),('204001'),('204002'),('205001'),('205001'),('205001'),('205001'),('205001'),('205001'),('205001'),('208001'),('208001'),('208002'),('208002'),('208002'),('208003'),('208003'),('208003'),('208004'),('208004'),('208004'),('208004'),('208004'),('208004'),('208004'),('208005'),('208005'),('208005'),('208005'),('208005'),('209001'),('209001'),('209001'),('209001'),('209001'),('209002'),('209002'),('209002'),('209002'),('209002'),('209003'),('209003'),('209003'),('209003'),('209003'),('210001'),('210001'),('210001'),('210001'),('210001'),('210004'),('210004'),('210004'),('210004'),('210004'),('210004'),('210009'),('210010'),('212001'),('212001'),('212002'),('212002'),('212002'),('212002'),('212003'),('212003'),('212003'),('212004'),('212004'),('212004'),('212005'),('212005'),('212005'),('212005'),('212005'),('212006'),('212006'),('212006'),('212007'),('212007'),('212008'),('212008'),('212008'),('212008'),('212009'),('212009'),('212009'),('212009'),('212010'),('212010'),('212010'),('212010'),('212011'),('212011'),('212012'),('212012'),('212013'),('212013'),('212013'),('218001'),('218004'),('218009'),('218011'),('218011'),('218015'),('218020'),('218021'),('218021'),('218022'),('218022'),('218022'),('218023'),('218024'),('218025'),('218026'),('218026'),('218027'),('218028'),('218029'),('218029'),('218029'),('218030'),('218031'),('221001'),('221001'),('221001'),('221001'),('221001'),('221001'),('221002'),('221002'),('221002'),('221002'),('221002'),('221002'),('221003'),('221003'),('221003'),('221003'),('221003'),('221003'),('221004'),('221004'),('221004'),('221004'),('221004'),('221004'),('221005'),('221005'),('221005'),('221005'),('221005'),('221006'),('221006'),('221006'),('221006'),('221006'),('221007'),('221007'),('221007'),('221007'),('221007'),('221007'),('221008'),('221008'),('221008'),('221008'),('221008'),('221008'),('221009'),('221009'),('221009'),('221009'),('221009'),('221009'),('221010'),('221010'),('221010'),('221010'),('221011'),('221011'),('221011'),('221011'),('221012'),('221012'),('221012'),('221012'),('221012'),('221012'),('221013'),('221013'),('221013'),('221013'),('221013'),('221013'),('223003'),('223003'),('224001'),('224001'),('224002'),('224002'),('224003'),('224007'),('224008'),('225001'),('225002'),('225002'),('225002'),('225003'),('225003'),('225003'),('225003'),('225004'),('225004'),('225004'),('225005'),('225005'),('225005'),('225005'),('225005'),('225005'),('225006'),('225006'),('225006'),('225007'),('225007'),('225007'),('225008'),('225008'),('225008'),('225008'),('225008'),('225009'),('225009'),('225009'),('225010'),('225010'),('225010'),('225011'),('225011'),('225011'),('225011'),('225011'),('225012'),('225012'),('225012'),('225012'),('225012'),('225012'),('225013'),('225013'),('226001'),('226002'),('226003'),('226003'),('226005'),('226005'),('226006'),('226007'),('226007'),('226007'),('226007'),('227011'),('227015'),('227015'),('227041'),('227045'),('227052'),('227056'),('227063'),('227064'),('227066'),('227067'),('227069'),('227071'),('227073'),('227085'),('227116'),('227119'),('227131'),('227133'),('227147'),('229005'),('229005'),('229005'),('233003'),('233004'),('235001'),('235001'),('235002'),('235003'),('235003'),('235003'),('235004'),('235005'),('235005'),('235005'),('235005'),('235005'),('235005'),('235005'),('236001'),('236001'),('236001'),('236001'),('236002'),('236003'),('236003'),('236003'),('236003'),('236003'),('236003'),('238002'),('238002'),('238002'),('238002'),('238002'),('238002'),('238003'),('238003'),('238003'),('238003'),('238003'),('238003'),('238004'),('238004'),('238004'),('238004'),('238004'),('238005'),('238005'),('238005'),('238007'),('238007'),('238007'),('238007'),('238007'),('238007'),('238007'),('238008'),('238008'),('238008'),('238008'),('238008'),('238008'),('238008'),('334005'),('334006'),('337001'),('337001'),('337001'),('337002'),('337002'),('337003'),('337003'),('337003'),('337004'),('343001'),('343001'),('344001'),('344002'),('344003'),('344004'),('344005'),('344005'),('345001'),('345001'),('348001'),('348004'),('348005'),('348005'),('349001'),('349001'),('349002'),('349002'),('349002'),('350001'),('353002'),('353002'),('353002'),('353003'),('355001'),('355002'),('355005'),('355006'),('355006'),('356001'),('358001'),('358001'),('358001'),('359001'),('359001'),('359002'),('359002'),('359002'),('359002'),('360001'),('360001'),('360002'),('360002'),('360003'),('360003'),('360004'),('360004'),('360005'),('360005'),('360005'),('366001'),('366002'),('366002'),('366003'),('366004'),('369001'),('369001'),('373001'),('373002'),('373002'),('373003'),('373003'),('373005'),('373007'),('373008'),('373009'),('373009'),('373010'),('373010'),('373010'),('373011'),('373011'),('373011'),('373011'),('373012'),('373012'),('373012'),('373013'),('373013'),('373014'),('373014'),('373015'),('373015'),('373015'),('373015'),('373017'),('373017'),('373017'),('373017'),('373018'),('373021'),('374002'),('374004'),('374006'),('374007'),('374008'),('374009'),('374010'),('374011'),('374012'),('374015'),('374016'),('382001'),('382002'),('382002'),('384001'),('386001'),('386001'),('386001'),('386001'),('386001'),('386001'),('386001'),('386002'),('386002'),('386002'),('386002'),('386002'),('386002'),('386002'),('386003'),('386003'),('386003'),('386003'),('386003'),('386003'),('386003'),('386003'),('386003'),('386004'),('386004'),('386004'),('386004'),('386004'),('386004'),('386004'),('386004'),('386005'),('386005'),('386005'),('386005'),('386005'),('386005'),('386005'),('386006'),('386006'),('386006'),('386006'),('386006'),('386006'),('386007'),('386007'),('386007'),('386007'),('386007'),('386007'),('386007'),('386007'),('386007'),('386008'),('386008'),('386008'),('386008'),('386008'),('386008'),('386008'),('386008'),('386009'),('386009'),('386009'),('386010'),('386010'),('386010'),('386010'),('386010'),('386010'),('386010'),('386010'),('386011'),('386011'),('386011'),('386011'),('386011'),('386011'),('386011'),('386011'),('386011'),('386012'),('386012'),('386012'),('386012'),('386012'),('386012'),('386012'),('386012'),('386012'),('386013'),('386013'),('386013'),('386013'),('386013'),('386013'),('386013'),('386014'),('386014'),('386014'),('386014'),('389001'),('389002'),('389002'),('389003'),('389003'),('389003'),('389003'),('389004'),('389004'),('389004'),('389004'),('392001'),('393001'),('393002'),('393002'),('393003'),('393004'),('395001'),('395001'),('397001'),('397001'),('397001'),('397002'),('399001'),('399001'),('399001'),('399001'),('399001'),('399001'),('399001'),('399002'),('399002'),('399002'),('399002'),('399002'),('399002'),('399002'),('399003'),('400001'),('400001'),('400001'),('400001'),('400002'),('403002'),('504001'),('504001'),('504002'),('504002'),('504002'),('504004'),('504004'),('504005'),('504006'),('504007'),('504007'),('504007'),('504008'),('504008'),('504009'),('504009'),('504009'),('504009'),('504009'),('504010'),('504011'),('504011'),('504012'),('504012'),('504014'),('504014'),('504014'),('504014'),('504014'),('504014'),('504014'),('504014'),('504017'),('504017'),('504021'),('504021'),('504021'),('504021'),('504021'),('504021'),('504021'),('504022'),('504023'),('504023'),('504024'),('504024'),('504025'),('504025'),('506001'),('506001'),('506001'),('506001'),('506001'),('506001'),('506002'),('506002'),('506002'),('506002'),('506002'),('511001'),('511001'),('511001'),('511001'),('511001'),('511001'),('511001'),('511002'),('511002'),('511002'),('511002'),('511002'),('511002'),('511002'),('511003'),('511003'),('511003'),('511003'),('511003'),('511003'),('511004'),('511004'),('511004'),('511004'),('511004'),('511004'),('511004'),('511005'),('511005'),('511005'),('511005'),('511005'),('511005'),('511005'),('511006'),('511006'),('511006'),('511006'),('511006'),('511006'),('511006'),('511007'),('511007'),('511007'),('511007'),('511007'),('511008'),('511008'),('511008'),('511008'),('511008'),('511008'),('511009'),('511009'),('511009'),('511009'),('511009'),('511009'),('511010'),('511010'),('511010'),('511010'),('511010'),('511010'),('511011'),('511011'),('511011'),('511011'),('511011'),('511011'),('511012'),('511012'),('511012'),('511012'),('511012'),('511012'),('511012'),('511013'),('511013'),('511013'),('511013'),('511013'),('511013'),('511013'),('511014'),('511014'),('511014'),('511014'),('511014'),('511017'),('511018'),('511020'),('511021'),('511022'),('511024'),('511028'),('511029'),('511029'),('511029'),('511029'),('511029'),('511029'),('513001'),('513001'),('513001'),('513001'),('513001'),('513001'),('513001'),('513001'),('513002'),('513002'),('513002'),('513002'),('513002'),('513002'),('513003'),('513003'),('513003'),('513003'),('513003'),('513003'),('513003'),('513003'),('513004'),('513004'),('513004'),('515001'),('515001'),('515001'),('515001'),('515001'),('515002'),('515002'),('515003'),('515003'),('515007'),('515007'),('515008'),('515011'),('515011'),('515011'),('515011'),('515011'),('515011'),('515012'),('515012'),('515012'),('515012'),('515013'),('515013'),('515013'),('515013'),('515013'),('515014'),('515014'),('515014'),('515014'),('515014'),('515015'),('515015'),('515015'),('515015'),('515015'),('518001'),('518002'),('521001'),('521002'),('521002'),('521002'),('521003'),('521003'),('521003'),('521003'),('521004'),('521004'),('521004'),('521004'),('521005'),('521005'),('521005'),('521005'),('521006'),('521006'),('521006'),('521009'),('521010'),('521010'),('521010'),('521010'),('521011'),('521011'),('521011'),('521011'),('521012'),('521013'),('521013'),('521015'),('521016'),('521016'),('523001'),('523001'),('523001'),('523001'),('523001'),('523001'),('523001'),('523002'),('523002'),('523002'),('523002'),('523002'),('523002'),('523003'),('523003'),('523003'),('523003'),('523003'),('523003'),('523003'),('523004'),('523004'),('523004'),('523004'),('523004'),('523004'),('523005'),('523005'),('523005'),('523005'),('523005'),('523005'),('523005'),('523005'),('523006'),('523006'),('523006'),('523006'),('523006'),('523006'),('523006'),('523007'),('523007'),('523007'),('523007'),('523007'),('523007'),('523007'),('524001'),('700001'),('701001'),('701002'),('701003'),('702001'),('702002'),('702004'),('702005'),('704001'),('704004'),('705001'),('706001'),('706002'),('707001'),('707002'),('707003'),('708001'),('710001'),('710002'),('711001'),('711002'),('712001'),('714001'),('714002'),('715001'),('719001'),('719002'),('991002'),('991002'),('991002'),('991003'),('991003'),('991003'),('991003'),('991003'),('991003'),('991003'),('991004'),('991004'),('991004'),('991005'),('991005'),('991005'),('991006'),('991007'),('995001'),('995001'),('995001'),('995001'),('995001'),('995001'),('995001'),('995001'),('995001'),('995001'),('995001'),('996001'),('996001'),('996001'),('996001'),('996001'),('996001'),('996001'),('996001'),('996002'),('996002'),('996003'),('996003'),('996003'),('996003'),('996003'),('998001'),('998001'),('998001'),('998001'),('998001'),('998001'),('998001'),('998001'),('998001'),('998001'),('998002'),('998002'),('998002'),('998002'),('998002'),('998002'),('998002'),('998002'),('998002'),('998002'),('998003'),('998003'),('998003'),('998003'),('998003'),('998003'),('998003'),('998003'),('998004'),('998004'),('998005'),('998005'),('998006'),('998007'),('999001'),('999001'),('999001'),('999001'),('999001'),('999001'),('999001'),('999001'),('999001'),('999001'),('999001'),('999002'),('999002'),('011017'),('011017'),('011017'),('011017'),('011017'),('011017'),('011017'),('011018'),('011018'),('011018'),('011018'),('034001'),('034001'),('034002'),('034002'),('071010'),('071010'),('071010'),('519001'),('126013'),('126013'),('126013'),('126013'),('126013'),('184012'),('184012'),('184012'),('404001'),('405002'),('405002'),('405001'),('405003'),('405006'),('240011'),('240011'),('240011'),('240011'),('240011'),('240011'),('240010'),('240010'),('240010'),('240009'),('240009'),('240009'),('240009'),('240008'),('240008'),('240008'),('240007'),('240007'),('240007'),('240007'),('240007'),('240007'),('240005'),('240005'),('240005'),('240005'),('240005'),('240004'),('240004'),('240004'),('240004'),('240004'),('240003'),('240003'),('240003'),('240003'),('240002'),('240002'),('240002'),('240002'),('240002'),('240002'),('240002'),('240001'),('240001'),('240001'),('240001'),('240001'),('240012'),('240012'),('240012'),('240012'),('240012'),('240013'),('240014'),('240015'),('240015'),('240015'),('240015'),('240015'),('240015'),('240015'),('240015'),('240016'),('240016'),('240016'),('240016'),('240016'),('240016'),('240017'),('240017'),('240017'),('357001'),('357001'),('235006'),('235006'),('235007'),('235007'),('235007'),('235007'),('235007'),('056023'),('056023'),('056023'),('056023'),('056023'),('046015'),('019005'),('019005'),('126014'),('126014'),('126014'),('126014'),('126014'),('126014'),('241003'),('241003'),('241003'),('241003'),('241003'),('241003'),('241002'),('241002'),('241002'),('241002'),('241002'),('241002'),('241001'),('241001'),('241001'),('241001'),('241001'),('240020'),('240020'),('240020'),('240020'),('240020'),('240020'),('240019'),('240019'),('240019'),('242001'),('242002'),('242004'),('242005'),('242006'),('089002'),('089002'),('089002'),('089002'),('089002'),('089002'),('406001'),('406002'),('406003'),('406004'),('406004'),('243001'),('243005'),('243006'),('243007'),('243008'),('408001'),('408001'),('408001'),('408001'),('408001'),('366005'),('366005'),('016035'),('016035'),('016035'),('016035'),('077010'),('996004'),('996004'),('996004'),('996004'),('996004'),('996004'),('996004'),('996004'),('025064'),('025064'),('025064'),('025064'),('011019'),('011019'),('011019'),('011019'),('011019'),('115123'),('115123'),('504026'),('039007'),('039009'),('039008'),('039008'),('039010'),('039010'),('039011'),('039012'),('180072'),('240021'),('240021'),('240021'),('240021'),('240021'),('240021'),('240021'),('240023'),('240023'),('240023'),('240023'),('405008'),('405008'),('525002'),('410002'),('410002'),('410004'),('410005'),('410005'),('410006'),('410007'),('410007'),('410008'),('410009'),('410010'),('410011'),('410011'),('410012'),('410012'),('410013'),('410013'),('410014'),('410014'),('410016'),('410016'),('344006'),('240031'),('240031'),('240031'),('240031'),('240030'),('240030'),('240030'),('240030'),('240029'),('240029'),('240029'),('240029'),('240028'),('240028'),('240028'),('240028'),('240027'),('240027'),('240026'),('240026'),('240026'),('240025'),('240025'),('240025'),('240025'),('240024'),('240024'),('240034'),('240034'),('240034'),('240033'),('240033'),('240033'),('240032'),('240032'),('240032'),('240032'),('411001'),('411002'),('203020'),('069025'),('069025'),('069025'),('069025'),('069025'),('069025'),('244001'),('244001'),('244001'),('244001'),('244001'),('244001'),('244001'),('244001'),('244001'),('244001'),('244001'),('244002'),('244002'),('244002'),('244002'),('244002'),('244002'),('244002'),('244002'),('244002'),('244002'),('244002'),('244009'),('244009'),('244009'),('244009'),('244009'),('244009'),('244009'),('244009'),('244009'),('244009'),('244009'),('244008'),('244008'),('244008'),('244008'),('244008'),('244008'),('244008'),('244008'),('244008'),('244008'),('244008'),('244007'),('244007'),('244007'),('244007'),('244007'),('244007'),('244007'),('244007'),('244007'),('244007'),('244007'),('244006'),('244006'),('244006'),('244006'),('244006'),('244006'),('244006'),('244006'),('244006'),('244006'),('244006'),('244004'),('244004'),('244004'),('244004'),('244004'),('244004'),('244004'),('244004'),('244004'),('244004'),('244004'),('244003'),('244003'),('244003'),('244003'),('244003'),('244003'),('244003'),('244003'),('244003'),('244003'),('244003'),('244014'),('244014'),('244014'),('244014'),('244014'),('244014'),('244014'),('244014'),('244013'),('244013'),('244013'),('244013'),('244013'),('244013'),('244013'),('244013'),('244012'),('244012'),('244012'),('244012'),('244012'),('244012'),('244012'),('244012'),('244011'),('244011'),('244011'),('244011'),('244011'),('244011'),('244011'),('244011'),('244016'),('244016'),('244016'),('244016'),('244016'),('244016'),('244016'),('244016'),('244016'),('244016'),('244016'),('244017'),('244017'),('244017'),('244017'),('244017'),('244017'),('244017'),('244017'),('244017'),('240040'),('240037'),('405009'),('405009'),('405009'),('405010'),('405010'),('240043'),('240043'),('504028'),('504040'),('800001'),('410019'),('410019'),('410020'),('410020'),('410020'),('410021'),('410021'),('244018'),('244018'),('244018'),('244018'),('244018'),('244018'),('244018'),('244018'),('244018'),('244018'),('244018'),('244019'),('244019'),('244019'),('244019'),('244019'),('244019'),('244019'),('244019'),('244019'),('244019'),('244019'),('244020'),('244020'),('244020'),('244020'),('244020'),('244020'),('244020'),('244020'),('413001'),('344007'),('082045'),('082045'),('082045'),('082045'),('082045'),('010031'),('010031'),('010031'),('010031'),('010032'),('010032'),('010032'),('010032'),('010033'),('010033'),('010033'),('010033'),('010033'),('010034'),('010034'),('010034'),('010034'),('010035'),('010035'),('010035'),('010035'),('504044'),('515016'),('515016'),('515016'),('515016'),('801002'),('801003'),('801004'),('801005'),('802001'),('801001'),('414001'),('141029'),('803001'),('803002'),('803004'),('803005'),('803006'),('803007'),('803008'),('803009'),('803013'),('803014'),('803015'),('803016'),('803017'),('410022'),('410023'),('410023'),('803019'),('415002'),('415001'),('244021'),('244021'),('244021'),('244021'),('244021'),('244021'),('244021'),('011020'),('011020'),('011020'),('011020'),('011023'),('011023'),('011023'),('011023'),('011022'),('011022'),('011022'),('011022'),('011022'),('011022'),('011021'),('011021'),('011021'),('011021'),('025065'),('025065'),('025065'),('025065'),('165037'),('165037'),('165038'),('165038'),('165038'),('165039'),('416001'),('416001'),('416001'),('416001'),('416001'),('416002'),('416003'),('417001'),('418001'),('504045'),('504045'),('504045'),('803022'),('240022'),('240022'),('240022'),('240022'),('420001'),('420001'),('420001'),('420001'),('804010'),('804005'),('804002'),('804018'),('804013'),('511019'),('511016'),('511015'),('511032'),('511031'),('511030'),('511027'),('511026'),('511025'),('511033'),('511023'),('133034'),('133034'),('133034'),('133033'),('169011'),('169011'),('169011'),('169011'),('169011'),('344008'),('244022'),('244022'),('244022'),('244022'),('244022'),('244022'),('244022'),('244026'),('244026'),('244026'),('244026'),('244026'),('244026'),('244025'),('244025'),('244025'),('244025'),('244025'),('244025'),('244025'),('244025'),('244030'),('244030'),('244030'),('244030'),('244030'),('244030'),('244030'),('244030'),('244023'),('244023'),('244023'),('244023'),('244023'),('244023'),('244024'),('244024'),('244024'),('244024'),('244024'),('244024'),('244024'),('244024'),('244027'),('244027'),('244027'),('244027'),('244027'),('244027'),('244027'),('244027'),('244028'),('244028'),('244028'),('244028'),('244028'),('244028'),('244028'),('244028'),('244029'),('244029'),('244029'),('244029'),('244029'),('244029'),('244029'),('244029'),('244031'),('244031'),('244031'),('244031'),('244031'),('244031'),('244031'),('244031'),('082046'),('082046'),('082046'),('082046'),('082047'),('082047'),('082048'),('082048'),('126015'),('126015'),('126016'),('126016'),('126016'),('126016'),('126016'),('416005'),('421001'),('421001'),('421002'),('016037'),('016037'),('016037'),('016037'),('016036'),('016036'),('016036'),('016036'),('115124'),('115124'),('115126'),('240049'),('240049'),('240048'),('240048'),('240047'),('240047'),('240046'),('240046'),('240045'),('240044'),('244032'),('244033'),('422002'),('422004'),('422004'),('422004'),('422005'),('422005'),('184013'),('184013'),('184013'),('805001'),('805002'),('805003'),('805004'),('805005'),('056024'),('056024'),('056024'),('423001'),('344010'),('235009'),('235009'),('235009'),('235009'),('212014'),('212014'),('056025'),('056025'),('056025'),('056026'),('056026'),('056026'),('056026'),('056026'),('056026'),('244034'),('244034'),('244034'),('244034'),('244034'),('244034'),('244035'),('244035'),('244035'),('244035'),('244035'),('244035'),('244035'),('244036'),('244036'),('244036'),('244036'),('244036'),('244036'),('244036'),('244037'),('244037'),('244037'),('244037'),('244037'),('244037'),('244037'),('244038'),('244038'),('244038'),('244038'),('244038'),('244038'),('244038'),('244039'),('244039'),('244039'),('244039'),('244039'),('244039'),('244039'),('203015'),('245002'),('245002'),('245001'),('245001'),('056029'),('056030'),('056032'),('424001'),('056034'),('056034'),('056034'),('056034'),('056033'),('056033'),('056033'),('805006'),('805007'),('805008'),('805009'),('805010'),('422008'),('422008'),('422007'),('422007'),('422006'),('422006'),('422010'),('422009'),('422009'),('422011'),('422011'),('209004'),('209004'),('150022'),('100002'),('056035'),('056035'),('056035'),('023036'),('023036'),('185005'),('246001'),('246001'),('247001'),('247001'),('247001'),('247001'),('247001'),('247001'),('247001'),('247002'),('247002'),('425001'),('416006'),('416006'),('165042'),('165041'),('165040'),('165043'),('010040'),('010039'),('010038'),('010036'),('248001'),('248002'),('248003'),('248004'),('248005'),('249001'),('249003'),('249004'),('249005'),('250007'),('250001'),('250002'),('250003'),('250004'),('250005'),('250006'),('250008'),('250009'),('250010'),('250011'),('250012'),('250013'),('251001'),('251002'),('806001'),('806002'),('235010'),('243009'),('249007'),('249008'),('249009'),('011024'),('011025'),('429001'),('429001'),('429002'),('429002'),('429003'),('429003');
select field from t1 group by field;
drop table t1;
#
# Test of enum with space
#
create table t1 (a enum (' ','a','b') not null);
show create table t1;
drop table t1;
create table t1 (a enum (' ','a','b ') not null default 'b ');
show create table t1;
drop table t1;
#
# Tests of wrong enum values (bug #2023)
#
create table t1 (a enum ('0','1'));
insert into t1 set a='foobar';
select * from t1;
update t1 set a = replace(a,'x','y');
select * from t1;
drop table t1;
#
# Bug #2077
#
set names latin1;
create table t1 (a enum(0xE4, '1', '2') not null default 0xE4);
show columns from t1;
show create table t1;
drop table t1;
#
# Bug #5628 German characters in field-defs will be '?'
# with some table definitions
#
set names latin1;
CREATE TABLE t1 (
a INT default 1,
b ENUM('value','_value','') character set latin1 NOT NULL
);
show create table t1;
show columns from t1;
drop table t1;
#
# Bugs #6154, 6206: ENUMs are not case sensitive even if declared BINARY
#
CREATE TABLE t1 (c enum('a', 'A') BINARY);
INSERT INTO t1 VALUES ('a'),('A');
SELECT * FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (c enum('ae','oe','ue','ss') collate latin1_german2_ci);
INSERT INTO t1 VALUES (''),(''),(''),('');
SELECT * FROM t1;
DROP TABLE t1;
#
# Bug #6379: ENUM values are incorrectly converted
#
# Check latin1 -> utf8 conversion
#
CREATE TABLE t1 (
a ENUM('','','') character set utf8 default ''
);
show create table t1;
insert into t1 values (''), (''), ('');
select a from t1 order by a;
drop table t1;
#
# Now check utf8 -> latin1 conversion
# This test emulates loading a script generated with mysqldump
#
set names utf8;
CREATE TABLE t1 (
a ENUM('ä','ö','ü') character set latin1 default 'ü'
);
insert into t1 values ('ä'),('ö'),('ü');
# Now check what has been loaded
set names latin1;
show create table t1;
select a from t1 order by a;
drop table t1;
#
# Test bug where enum fields where extended for each ALTER TABLE
#
create table t1 (a enum ('Y','N') CHARACTER SET utf8 COLLATE utf8_bin);
insert into t1 values ('Y');
alter table t1 add b set ('Y','N') CHARACTER SET utf8 COLLATE utf8_bin;
alter table t1 add c enum ('Y','N') CHARACTER SET utf8 COLLATE utf8_bin;
--enable_metadata
select * from t1;
--disable_metadata
drop table t1;
#
# Bug #6840 Default value is not checked in ALTER column SET DEFAULT 'x'
#
create table t1 (a enum('x','y') default 'x');
--error 1067
alter table t1 alter a set default 'z';
drop table t1;
create table t1 (a set('x','y') default 'x');
--error 1067
alter table t1 alter a set default 'z';
drop table t1;
#
# Bug#20922 mysql removes a name of first column in a table
#
create table t1 (f1 int);
alter table t1 add f2 enum(0xFFFF);
show create table t1;
drop table t1;
#
# Bug#24660 "enum" field type definition problem
#
create table t1(russian enum('E','F','EF','FE') NOT NULL DEFAULT'E');
show create table t1;
drop table t1;
create table t1(denormal enum('E','F','E,F','F,E') NOT NULL DEFAULT'E');
show create table t1;
drop table t1;
create table t1(russian_deviant enum('E','F','EF','F,E') NOT NULL DEFAULT'E');
show create table t1;
drop table t1;
#
# Bug #29251: MySQL coerces special 0 enum values to normal '' value
# when ALTERing the column
#
CREATE TABLE t1 (
id INT AUTO_INCREMENT PRIMARY KEY,
c1 ENUM('a', '', 'b')
);
INSERT INTO t1 (c1) VALUES (0), ('a'), (''), ('b');
SELECT id, c1 + 0, c1 FROM t1;
ALTER TABLE t1 CHANGE c1 c1 ENUM('a', '') NOT NULL;
SELECT id, c1 + 0, c1 FROM t1;
DROP TABLE t1;
--echo End of 4.1 tests
#
# Bug#28729: Field_enum wrongly reported an error while storing an empty string.
#
create table t1(f1 set('a','b'), index(f1));
insert into t1 values(''),(''),('a'),('b');
select * from t1 where f1='';
drop table t1;
#
# Bug#29360: Confluence of the special 0 enum value with the normal empty string
# value during field to field copy.
#
CREATE TABLE t1 (c1 ENUM('a', '', 'b'));
INSERT INTO t1 (c1) VALUES ('b');
INSERT INTO t1 (c1) VALUES ('');
INSERT INTO t1 (c1) VALUES (0);
INSERT INTO t1 (c1) VALUES ('');
SELECT c1 + 0, COUNT(c1) FROM t1 GROUP BY c1;
CREATE TABLE t2 SELECT * FROM t1;
SELECT c1 + 0 FROM t2;
DROP TABLE t1,t2;
#
# Bug#29661: Lookup by 0 for a primary index over a enum type
#
CREATE TABLE t1(a enum('a','b','c','d'));
INSERT INTO t1 VALUES (4),(1),(0),(3);
SELECT a FROM t1;
EXPLAIN SELECT a FROM t1 WHERE a=0;
SELECT a FROM t1 WHERE a=0;
ALTER TABLE t1 ADD PRIMARY KEY (a);
EXPLAIN SELECT a FROM t1 WHERE a=0;
SELECT a FROM t1 WHERE a=0;
DROP TABLE t1;
--echo End of 5.1 tests
SET STORAGE_ENGINE='tokudb';
# Description
# -----------
# Numeric floating point.
--disable_warnings
drop table if exists t1,t2;
--enable_warnings
SELECT 10,10.0,10.,.1e+2,100.0e-1;
SELECT 6e-05, -6e-05, --6e-05, -6e-05+1.000000;
SELECT 1e1,1.e1,1.0e1,1e+1,1.e+1,1.0e+1,1e-1,1.e-1,1.0e-1;
SELECT 0.001e+1,0.001e-1, -0.001e+01,-0.001e-01;
SELECT 123.23E+02,-123.23E-02,"123.23E+02"+0.0,"-123.23E-02"+0.0;
SELECT 2147483647E+02,21474836.47E+06;
create table t1 (f1 float(24),f2 float(52));
# We mask out Privileges column because it differs for embedded server
--replace_column 8 #
show full columns from t1;
insert into t1 values(10,10),(1e+5,1e+5),(1234567890,1234567890),(1e+10,1e+10),(1e+15,1e+15),(1e+20,1e+20),(1e+50,1e+50),(1e+150,1e+150);
insert into t1 values(-10,-10),(1e-5,1e-5),(1e-10,1e-10),(1e-15,1e-15),(1e-20,1e-20),(1e-50,1e-50),(1e-150,1e-150);
select * from t1;
drop table t1;
create table t1 (datum double);
insert into t1 values (0.5),(1.0),(1.5),(2.0),(2.5);
select * from t1;
select * from t1 where datum < 1.5;
select * from t1 where datum > 1.5;
select * from t1 where datum = 1.5;
drop table t1;
create table t1 (a decimal(7,3) not null, key (a));
insert into t1 values ("0"),("-0.00"),("-0.01"),("-0.002"),("1");
select a from t1 order by a;
select min(a) from t1;
drop table t1;
#
# BUG#3612, BUG#4393, BUG#4356, BUG#4394
#
create table t1 (c1 double, c2 varchar(20));
insert t1 values (121,"16");
select c1 + c1 * (c2 / 100) as col from t1;
create table t2 select c1 + c1 * (c2 / 100) as col1, round(c1, 5) as col2, round(c1, 35) as col3, sqrt(c1*1e-15) col4 from t1;
# Floats are a bit different in PS
--disable_ps_protocol
select * from t2;
--enable_ps_protocol
show create table t2;
drop table t1,t2;
# Bug #1022: When a table contains a 'float' field,
# and one of the functions MAX, MIN, or AVG is used on that field,
# the system crashes.
create table t1 (a float);
insert into t1 values (1);
select max(a),min(a),avg(a) from t1;
drop table t1;
#
# FLOAT/DOUBLE/DECIMAL handling
#
create table t1 (f float, f2 float(24), f3 float(6,2), d double, d2 float(53), d3 double(10,3), de decimal, de2 decimal(6), de3 decimal(5,2), n numeric, n2 numeric(8), n3 numeric(7,6));
# We mask out Privileges column because it differs for embedded server
--replace_column 8 #
show full columns from t1;
drop table t1;
create table t1 (a decimal(7,3) not null, key (a));
insert into t1 values ("0"),("-0.00"),("-0.01"),("-0.002"),("1");
select a from t1 order by a;
select min(a) from t1;
drop table t1;
--error 1425
create table t1 (a float(200,100), b double(200,100));
#
# float in a char(1) field
#
create table t1 (c20 char);
insert into t1 values (5000.0);
insert into t1 values (0.5e4);
drop table t1;
# Errors
--error 1063
create table t1 (f float(54)); # Should give an error
--disable_warnings
drop table if exists t1;
--enable_warnings
# Don't allow 'double unsigned' to be set to a negative value (Bug #7700)
create table t1 (d1 double, d2 double unsigned);
insert into t1 set d1 = -1.0;
update t1 set d2 = d1;
select * from t1;
drop table t1;
# Ensure that maximum values as the result of number of decimals
# being specified in table schema are enforced (Bug #7361)
create table t1 (f float(4,3));
insert into t1 values (-11.0),(-11),("-11"),(11.0),(11),("11");
select * from t1;
drop table if exists t1;
create table t1 (f double(4,3));
insert into t1 values (-11.0),(-11),("-11"),(11.0),(11),("11");
select * from t1;
drop table if exists t1;
# Check conversion of floats to character field (Bug #7774)
create table t1 (c char(20));
insert into t1 values (5e-28);
select * from t1;
drop table t1;
create table t1 (c char(6));
insert into t1 values (2e5),(2e6),(2e-4),(2e-5);
select * from t1;
drop table t1;
#
# Test of comparison of integer with float-in-range (Bug #7840)
# This is needed because some ODBC applications (like Foxpro) uses
# floats for everything.
#
CREATE TABLE t1 (
reckey int unsigned NOT NULL,
recdesc varchar(50) NOT NULL,
PRIMARY KEY (reckey)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO t1 VALUES (108, 'Has 108 as key');
INSERT INTO t1 VALUES (109, 'Has 109 as key');
select * from t1 where reckey=108;
select * from t1 where reckey=1.08E2;
select * from t1 where reckey=109;
select * from t1 where reckey=1.09E2;
drop table t1;
#
# Bug #13372 (decimal union)
#
create table t1 (d double(10,1));
create table t2 (d double(10,9));
insert into t1 values ("100000000.0");
insert into t2 values ("1.23456780");
create table t3 select * from t2 union select * from t1;
select * from t3;
show create table t3;
drop table t1, t2, t3;
#
# Bug #9855 (inconsistent column type for create select
#
create table t1 select 105213674794682365.00 + 0.0 x;
show warnings;
desc t1;
drop table t1;
create table t1 select 0.0 x;
desc t1;
create table t2 select 105213674794682365.00 y;
desc t2;
create table t3 select x+y a from t1,t2;
show warnings;
desc t3;
drop table t1,t2,t3;
#
# Bug #22129: A small double precision number becomes zero
#
# check if underflows are detected correctly
select 1e-308, 1.00000001e-300, 100000000e-300;
# check if overflows are detected correctly
select 10e307;
#
# Bug #19690: ORDER BY eliminates rows from the result
#
create table t1(a int, b double(8, 2));
insert into t1 values
(1, 28.50), (1, 121.85), (1, 157.23), (1, 1351.00), (1, -1965.35), (1, 81.75),
(1, 217.08), (1, 7.94), (4, 96.07), (4, 6404.65), (4, -6500.72), (2, 100.00),
(5, 5.00), (5, -2104.80), (5, 2033.80), (5, 0.07), (5, 65.93),
(3, -4986.24), (3, 5.00), (3, 4857.34), (3, 123.74), (3, 0.16),
(6, -1695.31), (6, 1003.77), (6, 499.72), (6, 191.82);
explain select sum(b) s from t1 group by a;
select sum(b) s from t1 group by a;
select sum(b) s from t1 group by a having s <> 0;
select sum(b) s from t1 group by a having s <> 0 order by s;
select sum(b) s from t1 group by a having s <=> 0;
select sum(b) s from t1 group by a having s <=> 0 order by s;
alter table t1 add key (a, b);
explain select sum(b) s from t1 group by a;
select sum(b) s from t1 group by a;
select sum(b) s from t1 group by a having s <> 0;
select sum(b) s from t1 group by a having s <> 0 order by s;
select sum(b) s from t1 group by a having s <=> 0;
select sum(b) s from t1 group by a having s <=> 0 order by s;
drop table t1;
--echo End of 4.1 tests
#
# bug #12694 (float(m,d) specifications)
#
--error 1427
create table t1 (s1 float(0,2));
--error 1427
create table t1 (s1 float(1,2));
#
# MySQL Bugs: #11589: mysqltest --ps-protocol, strange output, float/double/real with zerofill
#
CREATE TABLE t1 (
f1 real zerofill,
f2 double zerofill,
f3 float zerofill);
INSERT INTO t1 VALUES ( 0.314152e+1, 0.314152e+1, 0.314152e+1);
let $my_stmt= select f1, f2, f3 FROM t1;
eval PREPARE stmt1 FROM '$my_stmt';
select f1, f2, f3 FROM t1;
eval $my_stmt;
EXECUTE stmt1;
DROP TABLE t1;
# Bug #28121 "INSERT or UPDATE into DOUBLE(200,0) field being truncated to 31 digits"
#
create table t1 (f1 double(200, 0));
insert into t1 values (1e199), (-1e199);
insert into t1 values (1e200), (-1e200);
insert into t1 values (2e200), (-2e200);
select f1 + 0e0 from t1;
drop table t1;
create table t1 (f1 float(30, 0));
insert into t1 values (1e29), (-1e29);
insert into t1 values (1e30), (-1e30);
insert into t1 values (2e30), (-2e30);
select f1 + 0e0 from t1;
drop table t1;
--echo End of 5.0 tests
SET STORAGE_ENGINE='tokudb';
#
# Test nchar/nvarchar
#
--disable_warnings
drop table if exists t1;
--enable_warnings
create table t1 (c nchar(10));
show create table t1;
drop table t1;
create table t1 (c national char(10));
show create table t1;
drop table t1;
create table t1 (c national varchar(10));
show create table t1;
drop table t1;
create table t1 (c nvarchar(10));
show create table t1;
drop table t1;
create table t1 (c nchar varchar(10));
show create table t1;
drop table t1;
create table t1 (c national character varying(10));
show create table t1;
drop table t1;
create table t1 (c nchar varying(10));
show create table t1;
drop table t1;
# End of 4.1 tests
SET STORAGE_ENGINE='tokudb';
--disable_warnings
drop table if exists t1;
--enable_warnings
#
# constant IN function test
#
select 1.1 IN (1.0, 1.2);
select 1.1 IN (1.0, 1.2, 1.1, 1.4, 0.5);
select 1.1 IN (1.0, 1.2, NULL, 1.4, 0.5);
select 0.5 IN (1.0, 1.2, NULL, 1.4, 0.5);
select 1 IN (1.11, 1.2, 1.1, 1.4, 1, 0.5);
select 1 IN (1.11, 1.2, 1.1, 1.4, NULL, 0.5);
#
# case function test
#
select case 1.0 when 0.1 then "a" when 1.0 then "b" else "c" END;
select case 0.1 when 0.1 then "a" when 1.0 then "b" else "c" END;
select case 1 when 0.1 then "a" when 1.0 then "b" else "c" END;
select case 1.0 when 0.1 then "a" when 1 then "b" else "c" END;
select case 1.001 when 0.1 then "a" when 1 then "b" else "c" END;
#
# non constant IN test
#
create table t1 (a decimal(6,3));
insert into t1 values (1.0), (NULL), (0.1);
select * from t1;
select 0.1 in (1.0, 1.2, 1.1, a, 1.4, 0.5) from t1;
drop table t1;
#
# if function test
#
create table t1 select if(1, 1.1, 1.2), if(0, 1.1, 1.2), if(0.1, 1.1, 1.2), if(0, 1, 1.1), if(0, NULL, 1.2), if(1, 0.22e1, 1.1), if(1E0, 1.1, 1.2);
select * from t1;
show create table t1;
drop table t1;
#
# NULLIF
#
create table t1 select nullif(1.1, 1.1), nullif(1.1, 1.2), nullif(1.1, 0.11e1), nullif(1.0, 1), nullif(1, 1.0), nullif(1, 1.1);
select * from t1;
show create table t1;
drop table t1;
#
# saving in decimal field with overflow
#
create table t1 (a decimal(4,2));
insert into t1 value (10000), (1.1e10), ("11111"), (100000.1);
insert into t1 value (-10000), (-1.1e10), ("-11111"), (-100000.1);
select a from t1;
drop table t1;
create table t1 (a decimal(4,2) unsigned);
insert into t1 value (10000), (1.1e10), ("11111"), (100000.1);
insert into t1 value (-10000), (-1.1e10), ("-11111"), (-100000.1);
select a from t1;
drop table t1;
#
# saving in field with overflow from decimal
#
create table t1 (a bigint);
insert into t1 values (18446744073709551615.0);
insert into t1 values (9223372036854775808.0);
insert into t1 values (-18446744073709551615.0);
select * from t1;
drop table t1;
create table t1 (a bigint unsigned);
insert into t1 values (18446744073709551615.0);
insert into t1 values (9223372036854775808.0);
insert into t1 values (9999999999999999999999999.000);
insert into t1 values (-1.0);
select * from t1;
drop table t1;
create table t1 (a tinyint);
insert into t1 values (18446744073709551615.0);
insert into t1 values (9223372036854775808.0);
select * from t1;
drop table t1;
#
# test that functions create decimal fields
#
create table t1 select round(15.4,-1), truncate(-5678.123451,-3), abs(-1.1), -(-1.1);
show create table t1;
drop table t1;
#
# Trydy's tests
#
set session sql_mode='traditional';
select 1e10/0e0;
create table wl1612 (col1 int, col2 decimal(38,10), col3 numeric(38,10));
insert into wl1612 values(1,12345678901234567890.1234567890,12345678901234567890.1234567890);
select * from wl1612;
insert into wl1612 values(2,01234567890123456789.0123456789,01234567890123456789.0123456789);
select * from wl1612 where col1=2;
insert into wl1612 values(3,1234567890123456789012345678.0123456789,1234567890123456789012345678.0123456789);
select * from wl1612 where col1=3;
select col1/0 from wl1612;
select col2/0 from wl1612;
select col3/0 from wl1612;
insert into wl1612 values(5,5000.0005,5000.0005);
insert into wl1612 values(6,5000.0005,5000.0005);
select sum(col2),sum(col3) from wl1612;
#select avg(col2),avg(col3) from wl1612;
insert into wl1612 values(7,500000.000005,500000.000005);
insert into wl1612 values(8,500000.000005,500000.000005);
select sum(col2),sum(col3) from wl1612 where col1>4;
#select avg(col2),avg(col3) from wl1612 where col1>4;
#insert into wl1612 (col1,col2) values(9,123456789012345678901234567890);
#insert into wl1612 (col1,col3) values(9,123456789012345678901234567890);
insert into wl1612 (col1, col2) values(9,1.01234567891);
insert into wl1612 (col1, col2) values(10,1.01234567894);
insert into wl1612 (col1, col2) values(11,1.01234567895);
insert into wl1612 (col1, col2) values(12,1.01234567896);
select col1,col2 from wl1612 where col1>8;
insert into wl1612 (col1, col3) values(13,1.01234567891);
insert into wl1612 (col1, col3) values(14,1.01234567894);
insert into wl1612 (col1, col3) values(15,1.01234567895);
insert into wl1612 (col1, col3) values(16,1.01234567896);
select col1,col3 from wl1612 where col1>12;
select col1 from wl1612 where col1>4 and col2=1.01234567891;
#-- should return 0 rows
#
select col1 from wl1612 where col1>4 and col2=1.0123456789;
#-- should return col1 values 9 & 10
#
select col1 from wl1612 where col1>4 and col2<>1.0123456789;
#-- should return col1 values 5,6,7,8,11,12
#
select col1 from wl1612 where col1>4 and col2<1.0123456789;
#-- should return 0 rows
#
select col1 from wl1612 where col1>4 and col2<=1.0123456789;
#-- should return col1 values 9 & 10
#
select col1 from wl1612 where col1>4 and col2>1.0123456789;
#-- should return col1 values 5,6,7,8,11,12
#
select col1 from wl1612 where col1>4 and col2>=1.0123456789;
#-- should return col1 values 5,6,7,8,910,11,12
#
#select col1, col2 from wl1612 where col1=11 or col1=12;
select col1 from wl1612 where col1>4 and col2=1.012345679;
#-- should return col1 values 11,12
#
select col1 from wl1612 where col1>4 and col2<>1.012345679;
#-- should return col1 values 5,6,7,8,9,10
#
select col1 from wl1612 where col1>4 and col3=1.01234567891;
#-- should return 0 rows
#
select col1 from wl1612 where col1>4 and col3=1.0123456789;
#-- should return col1 values 13,14
#
select col1 from wl1612 where col1>4 and col3<>1.0123456789;
#-- should return col1 values 5,6,7,8,15,16
#
select col1 from wl1612 where col1>4 and col3<1.0123456789;
#-- should return 0 rows
#
select col1 from wl1612 where col1>4 and col3<=1.0123456789;
#-- should return col1 values 13,14
#
select col1 from wl1612 where col1>4 and col3>1.0123456789;
#-- should return col1 values 5,6,7,8,15,16
#
select col1 from wl1612 where col1>4 and col3>=1.0123456789;
#-- should return col1 values 5,6,7,8,13,14,15,16
#
select col1 from wl1612 where col1>4 and col3=1.012345679;
#-- should return col1 values 15,16
#
select col1 from wl1612 where col1>4 and col3<>1.012345679;
#-- should return col1 values 5,6,7,8,13,14
#
drop table wl1612;
#
select 1/3;
#
select 0.8=0.7+0.1;
#-- should return 1 (true)
#
select 0.7+0.1;
#
create table wl1612_1 (col1 int);
insert into wl1612_1 values(10);
#
select * from wl1612_1 where 0.8=0.7+0.1;
#--should return 1 row (col1=10)
#
select 0.07+0.07 from wl1612_1;
#
select 0.07-0.07 from wl1612_1;
#
select 0.07*0.07 from wl1612_1;
#
select 0.07/0.07 from wl1612_1;
#
drop table wl1612_1;
#
create table wl1612_2 (col1 decimal(10,2), col2 numeric(10,2));
insert into wl1612_2 values(1,1);
insert into wl1612_2 values(+1,+1);
insert into wl1612_2 values(+01,+01);
insert into wl1612_2 values(+001,+001);
#
select col1,count(*) from wl1612_2 group by col1;
#
select col2,count(*) from wl1612_2 group by col2;
#
drop table wl1612_2;
#
create table wl1612_3 (col1 decimal(10,2), col2 numeric(10,2));
insert into wl1612_3 values('1','1');
insert into wl1612_3 values('+1','+1');
#
insert into wl1612_3 values('+01','+01');
insert into wl1612_3 values('+001','+001');
#
select col1,count(*) from wl1612_3 group by col1;
#
select col2,count(*) from wl1612_3 group by col2;
#
drop table wl1612_3;
#
select mod(234,10) ;
#-- should return 4
#
select mod(234.567,10.555);
#-- should return 2.357
#
select mod(-234.567,10.555);
#-- should return -2.357
#
select mod(234.567,-10.555);
#-- should return 2.357
#
select round(15.1);
#-- should return 15
#
select round(15.4);
#-- should return 15
#
select round(15.5);
#-- should return 16
#
select round(15.6);
#-- should return 16
#
select round(15.9);
#-- should return 16
#
select round(-15.1);
#-- should return -15
#
select round(-15.4);
#-- should return -15
#
select round(-15.5);
#-- should return -16
#
select round(-15.6);
#-- should return -16
#
select round(-15.9);
#-- should return -16
#
select round(15.1,1);
#-- should return 15.1
#
select round(15.4,1);
#-- should return 15.4
#
select round(15.5,1);
#-- should return 15.5
#
select round(15.6,1);
#-- should return 15.6
#
select round(15.9,1);
#-- should return 15.9
#
select round(-15.1,1);
#-- should return -15.1
#
select round(-15.4,1);
#-- should return -15.4
#
select round(-15.5,1);
#-- should return -15.5
#
select round(-15.6,1);
#-- should return -15.6
#
select round(-15.9,1);
#-- should return -15.9
#
select round(15.1,0);
#-- should return 15
#
select round(15.4,0);
#-- should return 15
#
select round(15.5,0);
#-- should return 16
#
select round(15.6,0);
#-- should return 16
#
select round(15.9,0);
#-- should return 16
#
select round(-15.1,0);
#-- should return -15
#
select round(-15.4,0);
#-- should return -15
#
select round(-15.5,0);
#-- should return -16
#
select round(-15.6,0);
#-- should return -16
#
select round(-15.9,0);
#-- should return -16
#
select round(15.1,-1);
#-- should return 20
#
select round(15.4,-1);
#-- should return 20
#
select round(15.5,-1);
#-- should return 20
#
select round(15.6,-1);
#-- should return 20
#
select round(15.9,-1);
#-- should return 20
#
select round(-15.1,-1);
#-- should return -20
#
select round(-15.4,-1);
#-- should return -20
#
select round(-15.5,-1);
#-- should return -20
#
select round(-15.6,-1);
#-- should return -20
#
select round(-15.91,-1);
#-- should return -20
#
select truncate(5678.123451,0);
#-- should return 5678
#
select truncate(5678.123451,1);
#-- should return 5678.1
#
select truncate(5678.123451,2);
#-- should return 5678.12
#
select truncate(5678.123451,3);
#-- should return 5678.123
#
select truncate(5678.123451,4);
#-- should return 5678.1234
#
select truncate(5678.123451,5);
#-- should return 5678.12345
#
select truncate(5678.123451,6);
#-- should return 5678.123451
#
select truncate(5678.123451,-1);
#-- should return 5670
#
select truncate(5678.123451,-2);
#-- should return 5600
#
select truncate(5678.123451,-3);
#-- should return 5000
#
select truncate(5678.123451,-4);
#-- should return 0
#
select truncate(-5678.123451,0);
#-- should return -5678
#
select truncate(-5678.123451,1);
#-- should return -5678.1
#
select truncate(-5678.123451,2);
#-- should return -5678.12
#
select truncate(-5678.123451,3);
#-- should return -5678.123
#
select truncate(-5678.123451,4);
#-- should return -5678.1234
#
select truncate(-5678.123451,5);
#-- should return -5678.12345
#
select truncate(-5678.123451,6);
#-- should return -5678.123451
#
select truncate(-5678.123451,-1);
#-- should return -5670
#
select truncate(-5678.123451,-2);
#-- should return -5600
#
select truncate(-5678.123451,-3);
#-- should return -5000
#
select truncate(-5678.123451,-4);
#-- should return 0
#
#drop table if exists wl1612_4;
create table wl1612_4 (col1 int, col2 decimal(30,25), col3 numeric(30,25));
#
insert into wl1612_4 values(1,0.0123456789012345678912345,0.0123456789012345678912345);
#
select col2/9999999999 from wl1612_4 where col1=1;
#
select col3/9999999999 from wl1612_4 where col1=1;
#
select 9999999999/col2 from wl1612_4 where col1=1;
#
select 9999999999/col3 from wl1612_4 where col1=1;
#
select col2*9999999999 from wl1612_4 where col1=1;
#
select col3*9999999999 from wl1612_4 where col1=1;
#
insert into wl1612_4 values(2,55555.0123456789012345678912345,55555.0123456789012345678912345);
#
select col2/9999999999 from wl1612_4 where col1=2;
#
select col3/9999999999 from wl1612_4 where col1=2;
#
select 9999999999/col2 from wl1612_4 where col1=2;
#
select 9999999999/col3 from wl1612_4 where col1=2;
#
select col2*9999999999 from wl1612_4 where col1=2;
#
select col3*9999999999 from wl1612_4 where col1=2;
#
drop table wl1612_4;
#
#
#
#
#-- Additional tests for WL#1612 Precision math
#
#-- Comparisons should show that a number is
#-- exactly equal to its value as displayed.
#
set sql_mode='';
#
select 23.4 + (-41.7), 23.4 - (41.7) = -18.3;
#
select -18.3=-18.3;
#
select 18.3=18.3;
#
select -18.3=18.3;
#
select 0.8 = 0.7 + 0.1;
#
#-- It should be possible to define a column
#-- with up to 38 digits precision either before
#-- or after the decimal point. Any number which
#-- is inserted, if it's within the range, should
#-- be exactly the same as the number that gets
#-- selected.
#
drop table if exists t1;
#
create table t1 (col1 decimal(38));
#
insert into t1 values (12345678901234567890123456789012345678);
#
select * from t1;
#-- should return:
#+----------------------------------------+
#| col1 |
#+----------------------------------------+
#| 12345678901234567890123456789012345678 |
#+----------------------------------------+
#
#drop table t1;
#
#create table t1 (col1 decimal(38,38));
#
#insert into t1 values (.12345678901234567890123456789012345678);
#
#select * from t1;
#-- should return:
#+------------------------------------------+
#| col1 |
#+------------------------------------------+
#| 0.12345678901234567890123456789012345678 |
#+------------------------------------------+
#
drop table t1;
#
create table t1 (col1 decimal(31,30));
#
insert into t1 values (0.00000000001);
#
select * from t1;
#-- should return:
#+---------------+
#|col1 |
#+---------------+
#| 0.00000000001 |
#+---------------+
#
drop table t1;
#
#-- The usual arithmetic operators / * + - should work.
#
#select 77777777777777777777777777777777777777 / 7777777777777777777777777777777777777 = 10;
#-- should return 0 (false).
#
select 7777777777777777777777777777777777777 * 10;
#-- should return 77777777777777777777777777777777777770
#
select .7777777777777777777777777777777777777 *
1000000000000000000;
#-- should return 777777777777777777.7777777777777777777
#
select .7777777777777777777777777777777777777 - 0.1;
#-- should return .6777777777777777777777777777777777777
#
select .343434343434343434 + .343434343434343434;
#-- should return .686868686868686868
#
#-- 5. All arithmetic functions mentioned in the
#MySQL Reference Manual should work.
#
select abs(9999999999999999999999);
#-- should return 9999999999999999999999
#
select abs(-9999999999999999999999);
#-- should return 9999999999999999999999
#
select ceiling(999999999999999999);
select ceiling(99999999999999999999);
#-- should return 99999999999999999999
#
select ceiling(9.9999999999999999999);
#-- should return 10
#
select ceiling(-9.9999999999999999999);
#-- should return 9
#
select floor(999999999999999999);
select floor(9999999999999999999999);
#-- should return 9999999999999999999999
#
select floor(9.999999999999999999999);
#-- should return 9
#
select floor(-9.999999999999999999999);
#-- should return -10
#
select floor(-999999999999999999999.999);
select ceiling(999999999999999999999.999);
#
#
select 99999999999999999999999999999999999999 mod 3;
#-- should return 0
#
select round(99999999999999999.999);
#-- should return 100000000000000000
#
select round(-99999999999999999.999);
#-- should return -100000000000000000
#
select round(99999999999999999.999,3);
#-- should return 100000000000000000.000
#
select round(-99999999999999999.999,3);
#-- should return -100000000000000000.000
#
select truncate(99999999999999999999999999999999999999,31);
#-- should return 99999999999999999999999999999999999999.000
#
select truncate(99.999999999999999999999999999999999999,31);
#-- should return 99.9999999999999999999999999999999
#
select truncate(99999999999999999999999999999999999999,-31);
# should return 90000000000000000000000000000000
#
#-- 6. Set functions (AVG, SUM, COUNT) should work.
#
#drop table if exists t1;
#
#delimiter //
#
#create procedure p1 () begin
# declare v1 int default 1; declare v2 decimal(0,38) default 0;
# create table t1 (col1 decimal(0,38));
# while v1 <= 10000 do
# insert into t1 values (-v2);
# set v2 = v2 + 0.00000000000000000000000000000000000001;
# set v1 = v1 + 1;
# end while;
# select avg(col1),sum(col1),count(col1) from t1; end;//
#
#call p1()//
#-- should return
# -- avg(col1)=0.00000000000000000000000000000000000001 added 10,000 times, then divided by 10,000
# -- sum(col1)=0.00000000000000000000000000000000000001 added 10,000 times
#
# -- count(col1)=10000
#
#delimiter ;//
#
#drop procedure p1;
#drop table t1;
#
#-- When I say DECIMAL(x) I should be able to store x digits.
#-- If I can't, there should be an error at CREATE time.
#
#drop table if exists t1;
#
#create table t1 (col1 decimal(254));
#-- should return SQLSTATE 22003 numeric value out of range
#
#-- When I say DECIMAL(x,y) there should be no silent change of precision or
#-- scale.
#
#drop table if exists t1;
#
#create table t1 (col1 decimal(0,38));
#
#show create table t1;
#-- should return:
#+-------+--------------------------------+
#| Table | Create Table |
#+-------+--------------------------------+
#| t9 | CREATE TABLE `t1` ( |
#|`s1` decimal(0,38) default NULL |
#| ) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
#+-------+--------------------------------+
#
#drop table t1;
#
#-- From WL#1612 "The future" point 2.:
#-- The standard requires that we treat numbers like "0.5" as
#-- DECIMAL or NUMERIC, not as floating-point.
#
#drop table if exists t1;
#
#
create table t1 as select 0.5;
#
show create table t1;
#-- should return:
#+-------+-----------------------------------+
#| Table | Create Table |
#+-------+-----------------------------------+
#| t7 | CREATE TABLE `t1` ( |
#| `0.5` decimal(3,1) NOT NULL default '0.0' |
#| ) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
#+-------+-----------------------------------+
#
drop table t1;
#
#-- From WL#1612, "The future", point 3.: We have to start rounding correctly.
#
select round(1.5),round(2.5);
#-- should return:
#+------------+------------+
#| round(1.5) | round(2.5) |
#+------------+------------+
#| 2 | 3 |
#+------------+------------+
#
#-- From WL#1612, "The future", point 4.: "select 0.07 * 0.07;" should return 0.0049, not 0.00.
#-- If operand#1 has scale X and operand#2 has scale Y, then result should have scale (X+Y).
#
select 0.07 * 0.07;
#-- should return 0.0049
#
#-- From WL#1612, "The future", point 5.: Division by zero is an error.
#
set sql_mode='traditional';
#
select 1E-500 = 0;
#-- should return 1 (true).
#
select 1 / 1E-500;
#
#-- should return SQLSTATE 22012 division by zero.
#
select 1 / 0;
#-- should return SQLSTATE 22012 division by zero.
#
#+-------+
#| 1 / 0 |
#+-------+
#| NULL |
#+-------+
#1 row in set, 1 warning (0.00 sec)
#
#-- From WL#1612 "The future" point 6.: Overflow is an error.
#
#set sql_mode='';
#
#select 1E300 * 1E300;
#-- should return SQLSTATE 22003 numeric value out of range
#
#select 18446744073709551615 + 1;
#-- should return SQLSTATE 22003 numeric value out of range
#
#-- 14. From WL#1612 "The future" point 7.:
#-- If s1 is INTEGER and s2 is DECIMAL, then
#-- "create table tk7 as select avg(s1),avg(s2) from tk;"
#-- should not create a table with "double(17,4)" data types.
#-- The result of AVG must still be exact numeric, with a
#-- scale the same or greater than the operand's scale.
#-- The result of SUM must still be exact numeric, with
#-- a scale the same as the operand's scale.
#
#drop table if exists t1;
#drop table if exists t2;
#
#create table t1 (col1 int, col2 decimal(5));
#
#create table t2 as select avg(col1),avg(col2) from t1;
#
#
#show create table t2;
#-- should return:
#+-------+---------------------------------+
#| Table | Create Table |
#+-------+---------------------------------+
#| t2 | CREATE TABLE `t2` ( |
#| `avg(col1)` decimal(17,4) default NULL, |
#| `avg(col2)` decimal(17,5) default NULL |
#| ) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
#+-------+---------------------------------+
#
#drop table t2;
#drop table t1;
#
#-- From WL#1612 "The future" point 8.: Stop storing leading "+" signs and
# leading "0"s.
#
#drop table if exists t1;
#
#create table t1 (col1 decimal(5,2),col2 decimal(5) zerofill, col3 decimal(3,1));
#
#insert into t1 values (1,1,1);
#
#select col1 from t1 union select col2 from t1 union select col3 from t1;
#
#drop table t1;
#
#-- From WL#1612, The future" point 9.:
#-- Accept the data type and precision and scale as the user
#-- asks, or return an error, but don't change to something else.
#
#drop table if exists t1;
#
#create table t1 (col1 numeric(4,2));
#
#show create table t1;
#
#drop table t1;
#
#-- The scripts in the following bugs should work:
#
#BUG#559 Maximum precision for DECIMAL column ...
#BUG#1499 INSERT/UPDATE into decimal field rounding problem
#BUG#1845 Not correctly recognising value for decimal field
#BUG#2493 Round function doesn't work correctly
#BUG#2649 round(0.5) gives 0 (should be 1)
#BUG#3612 impicite rounding of VARCHARS during aritchmetic operations...
#BUG#3722 SELECT fails for certain values in Double(255,10) column.
#BUG#4485 Floating point conversions are inconsistent
#BUG#4891 MATH
#BUG#5931 Out-of-range values are accepted
#BUG#6048 Stored procedure causes operating system reboot
#BUG#6053 DOUBLE PRECISION literal
# Tests from 'traditional' mode tests
#
set sql_mode='ansi,traditional';
#
CREATE TABLE Sow6_2f (col1 NUMERIC(4,2));
#-- should return OK
INSERT INTO Sow6_2f VALUES (10.55);
#-- should return OK
INSERT INTO Sow6_2f VALUES (10.5555);
#-- should return OK
INSERT INTO Sow6_2f VALUES (-10.55);
#-- should return OK
INSERT INTO Sow6_2f VALUES (-10.5555);
#-- should return OK
INSERT INTO Sow6_2f VALUES (11);
#-- should return OK
-- error 1264
INSERT INTO Sow6_2f VALUES (101.55);
#-- should return SQLSTATE 22003 numeric value out of range
-- error 1264
UPDATE Sow6_2f SET col1 = col1 * 50 WHERE col1 = 11;
#-- should return SQLSTATE 22003 numeric value out of range
-- error 1365
UPDATE Sow6_2f SET col1 = col1 / 0 WHERE col1 > 0;
#-- should return SQLSTATE 22012 division by zero
SELECT MOD(col1,0) FROM Sow6_2f;
#-- should return SQLSTATE 22012 division by zero
-- error 1366
INSERT INTO Sow6_2f VALUES ('a59b');
#-- should return SQLSTATE 22018 invalid character value for cast
drop table Sow6_2f;
#
# bug#9501
#
select 10.3330000000000/12.34500000;
#
# Bug #10404
#
set sql_mode='';
select 0/0;
#
# bug #9546
#
--disable_ps_protocol
select 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 as x;
select 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 + 1 as x;
--enable_ps_protocol
#
# Bug #10004
#
select 0.190287977636363637 + 0.040372670 * 0 - 0;
#
# Bug #9527
#
select -0.123 * 0;
#
# Bug #10232
#
CREATE TABLE t1 (f1 DECIMAL (12,9), f2 DECIMAL(2,2));
INSERT INTO t1 VALUES (10.5, 0);
UPDATE t1 SET f1 = 4.5;
SELECT * FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (f1 DECIMAL (64,20), f2 DECIMAL(2,2));
INSERT INTO t1 VALUES (9999999999999999999999999999999999, 0);
SELECT * FROM t1;
DROP TABLE t1;
#
# Bug #10599: problem with NULL
#
select abs(10/0);
select abs(NULL);
#
# Bug #9894 (negative to unsigned column)
#
set @@sql_mode='traditional';
create table t1( d1 decimal(18) unsigned, d2 decimal(20) unsigned, d3 decimal (22) unsigned);
--error 1264
insert into t1 values(1,-1,-1);
drop table t1;
create table t1 (col1 decimal(5,2), col2 numeric(5,2));
--error 1264
insert into t1 values (999.999,999.999);
--error 1264
insert into t1 values (-999.999,-999.999);
select * from t1;
drop table t1;
set sql_mode='';
#
# Bug #8425 (insufficient precision of the division)
#
set @sav_dpi= @@div_precision_increment;
set @@div_precision_increment=15;
create table t1 (col1 int, col2 decimal(30,25), col3 numeric(30,25));
insert into t1 values (1,0.0123456789012345678912345,0.0123456789012345678912345);
select col2/9999999999 from t1 where col1=1;
select 9999999999/col2 from t1 where col1=1;
select 77777777/7777777;
drop table t1;
set div_precision_increment= @sav_dpi;
#
# Bug #10896 (0.00 > -0.00)
#
create table t1 (a decimal(4,2));
insert into t1 values (0.00);
select * from t1 where a > -0.00;
select * from t1 where a = -0.00;
drop table t1;
#
# Bug #11215: a problem with LONGLONG_MIN
#
create table t1 (col1 bigint default -9223372036854775808);
insert into t1 values (default);
select * from t1;
drop table t1;
#
# Bug #10891 (converting to decimal crashes server)
#
select cast('1.00000001335143196001808973960578441619873046875E-10' as decimal(30,15));
#
# Bug #11708 (conversion to decimal fails in decimal part)
#
select ln(14000) c1, convert(ln(14000),decimal(5,3)) c2, cast(ln(14000) as decimal(5,3)) c3;
--error 1427
select convert(ln(14000),decimal(2,3)) c1;
--error 1427
select cast(ln(14000) as decimal(2,3)) c1;
#
# Bug #8449 (Silent column changes)
#
--error 1426
create table t1 (sl decimal(70,30));
--error 1425
create table t1 (sl decimal(32,31));
--error 1425
create table t1 (sl decimal(0,38));
--error 1427
create table t1 (sl decimal(0,30));
create table t1 (sl decimal(5, 5));
show create table t1;
drop table t1;
# Test limits
create table t1 (sl decimal(65, 30));
show create table t1;
drop table t1;
#
# Bug 11557 (DEFAULT values rounded improperly
#
create table t1 (
f1 decimal unsigned not null default 17.49,
f2 decimal unsigned not null default 17.68,
f3 decimal unsigned not null default 99.2,
f4 decimal unsigned not null default 99.7,
f5 decimal unsigned not null default 104.49,
f6 decimal unsigned not null default 199.91,
f7 decimal unsigned not null default 999.9,
f8 decimal unsigned not null default 9999.99);
insert into t1 (f1) values (1);
select * from t1;
drop table t1;
#
# Bug 12173 (show create table fails)
#
create table t1 (
f0 decimal (30,30) zerofill not null DEFAULT 0,
f1 decimal (0,0) zerofill not null default 0);
show create table t1;
drop table t1;
#
# Bug 12938 (arithmetic loop's zero)
#
--disable_warnings
drop procedure if exists wg2;
--enable_warnings
delimiter //;
create procedure wg2()
begin
declare v int default 1;
declare tdec decimal(5) default 0;
while v <= 9 do set tdec =tdec * 10;
select v, tdec;
set v = v + 1;
end while;
end//
call wg2()//
delimiter ;//
drop procedure wg2;
#
# Bug #12979 Stored procedures: crash if inout decimal parameter
# (not a SP bug in fact)
#
select cast(@non_existing_user_var/2 as DECIMAL);
#
# Bug #13667 (Inconsistency for decimal(m,d) specification
#
--error 1427
create table t (d decimal(0,10));
#
# Bug #14268 (bad FLOAT->DECIMAL conversion)
#
CREATE TABLE t1 (
my_float FLOAT,
my_double DOUBLE,
my_varchar VARCHAR(50),
my_decimal DECIMAL(65,30)
);
SHOW CREATE TABLE t1;
let $max_power= 32;
while ($max_power)
{
eval INSERT INTO t1 SET my_float = 1.175494345e-$max_power,
my_double = 1.175494345e-$max_power,
my_varchar = '1.175494345e-$max_power';
dec $max_power;
}
SELECT my_float, my_double, my_varchar FROM t1;
# Expected result 0.000000000011754943372854760000
# On windows we get 0.000000000011754943372854770000
# use replace_result to correct it
--replace_result 0.000000000011754943372854770000 0.000000000011754943372854760000
SELECT CAST(my_float AS DECIMAL(65,30)), my_float FROM t1;
SELECT CAST(my_double AS DECIMAL(65,30)), my_double FROM t1;
SELECT CAST(my_varchar AS DECIMAL(65,30)), my_varchar FROM t1;
# We have to disable warnings here as the test in
# Field_new_decimal::store(double):
# if (nr2 != nr)
# fails randomly depending on compiler options
--disable_warnings
UPDATE t1 SET my_decimal = my_float;
# Expected result 0.000000000011754943372854760000
# On windows we get 0.000000000011754943372854770000
# use replace_result to correct it
--replace_result 0.000000000011754943372854770000 0.000000000011754943372854760000
SELECT my_decimal, my_float FROM t1;
UPDATE t1 SET my_decimal = my_double;
SELECT my_decimal, my_double FROM t1;
--enable_warnings
UPDATE t1 SET my_decimal = my_varchar;
SELECT my_decimal, my_varchar FROM t1;
DROP TABLE t1;
#
# Bug #13573 (Wrong data inserted for too big values)
#
create table t1 (c1 decimal(64));
--disable_ps_protocol
insert into t1 values(
89000000000000000000000000000000000000000000000000000000000000000000000000000000000000000);
insert into t1 values(
99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 *
99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999);
--enable_ps_protocol
insert into t1 values(1e100);
select * from t1;
drop table t1;
#
# Bug #18014: problem with 'alter table'
#
create table t1(a decimal(7,2));
insert into t1 values(123.12);
select * from t1;
alter table t1 modify a decimal(10,2);
select * from t1;
drop table t1;
#
# Bug#19667 group by a decimal expression yields wrong result
#
create table t1 (i int, j int);
insert into t1 values (1,1), (1,2), (2,3), (2,4);
select i, count(distinct j) from t1 group by i;
select i+0.0 as i2, count(distinct j) from t1 group by i2;
drop table t1;
create table t1(f1 decimal(20,6));
insert into t1 values (CAST('10:11:12' AS date) + interval 14 microsecond);
insert into t1 values (CAST('10:11:12' AS time));
select * from t1;
drop table t1;
#
# Bug #8663 (cant use bigint as input to CAST)
#
select cast(19999999999999999999 as unsigned);
#
# Bug #24558: Increasing decimal column length causes data loss
#
create table t1(a decimal(18));
insert into t1 values(123456789012345678);
alter table t1 modify column a decimal(19);
select * from t1;
drop table t1;
#
# Bug #27957 cast as decimal does not check overflow, also inconsistent with group, subselect
#
select cast(11.1234 as DECIMAL(3,2));
select * from (select cast(11.1234 as DECIMAL(3,2))) t;
select cast(a as DECIMAL(3,2))
from (select 11.1233 as a
UNION select 11.1234
UNION select 12.1234
) t;
select cast(a as DECIMAL(3,2)), count(*)
from (select 11.1233 as a
UNION select 11.1234
UNION select 12.1234
) t group by 1;
#
# Bug #28361 Buffer overflow in DECIMAL code on Windows
#
create table t1 (s varchar(100));
insert into t1 values (0.00000000010000000000000000364321973154977415791655470655996396089904010295867919921875);
drop table t1;
#
# Bug #27984 Long Decimal Maths produces truncated results
#
SELECT 1.000000000000 * 99.999999999998 / 100 a,1.000000000000 * (99.999999999998 / 100) b;
#
# Bug #29415: CAST AS DECIMAL(P,S) with too big precision/scale
#
SELECT CAST(1 AS decimal(65,10));
--error ER_TOO_BIG_PRECISION
SELECT CAST(1 AS decimal(66,10));
SELECT CAST(1 AS decimal(65,30));
--error ER_TOO_BIG_SCALE
SELECT CAST(1 AS decimal(65,31));
CREATE TABLE t1 (a int DEFAULT NULL, b int DEFAULT NULL);
INSERT INTO t1 VALUES (3,30), (1,10), (2,10);
SELECT a+CAST(1 AS decimal(65,30)) AS aa, SUM(b) FROM t1 GROUP BY aa;
--error ER_TOO_BIG_SCALE
SELECT a+CAST(1 AS decimal(65,31)) AS aa, SUM(b) FROM t1 GROUP BY aa;
DROP TABLE t1;
#
# Bug #29417: assertion abort for a grouping query with decimal user variable
#
CREATE TABLE t1 (a int DEFAULT NULL, b int DEFAULT NULL);
INSERT INTO t1 VALUES (3,30), (1,10), (2,10);
SET @a= CAST(1 AS decimal);
SELECT 1 FROM t1 GROUP BY @b := @a, @b;
DROP TABLE t1;
#
# Bug #24907: unpredictable (display) precission, if input precission
# increases
#
# As per 10.1.1. Overview of Numeric Types, type (new) DECIMAL has a
# maxmimum precision of 30 places after the decimal point. Show that
# temp field creation beyond that works and throws a truncation warning.
# DECIMAL(37,36) should be adjusted to DECIMAL(31,30).
CREATE TABLE t1 SELECT 0.123456789012345678901234567890123456 AS f1;
DESC t1;
SELECT f1 FROM t1;
DROP TABLE t1;
# too many decimal places, AND too many digits altogether (90 = 45+45).
# should preserve integers (65 = 45+20)
CREATE TABLE t1 SELECT 123451234512345123451234512345123451234512345.678906789067890678906789067890678906789067890 AS f1;
DESC t1;
SELECT f1 FROM t1;
DROP TABLE t1;
--echo End of 5.0 tests
#
# Bug#16172 DECIMAL data type processed incorrectly
#
select cast(143.481 as decimal(4,1));
select cast(143.481 as decimal(4,0));
select cast(143.481 as decimal(2,1));
select cast(-3.4 as decimal(2,1));
select cast(99.6 as decimal(2,0));
select cast(-13.4 as decimal(2,1));
select cast(98.6 as decimal(2,0));
SET STORAGE_ENGINE='tokudb';
#
# Test of SET with space
#
--disable_warnings
drop table if exists t1;
--enable_warnings
create table t1 (a set (' ','a','b') not null);
show create table t1;
drop table t1;
create table t1 (a set (' ','a','b ') not null default 'b ');
show create table t1;
drop table t1;
CREATE TABLE t1 ( user varchar(64) NOT NULL default '', path varchar(255) NOT NULL default '', privilege set('select','RESERVED30','RESERVED29','RESERVED28','RESERVED27','RESERVED26', 'RESERVED25','RESERVED24','data.delete','RESERVED22','RESERVED21', 'RESERVED20','data.insert.none','data.insert.approve', 'data.insert.delete','data.insert.move','data.insert.propose', 'data.insert.reject','RESERVED13','RESERVED12','RESERVED11','RESERVED10', 'RESERVED09','data.update','RESERVED07','RESERVED06','RESERVED05', 'RESERVED04','metadata.delete','metadata.put','RESERVED01','RESERVED00') NOT NULL default '', KEY user (user) ) ENGINE=MyISAM CHARSET=utf8;
DROP TABLE t1;
#
# Check that SET is case sensitive with a binary collation
#
set names latin1;
create table t1 (s set ('a','A') character set latin1 collate latin1_bin);
show create table t1;
insert into t1 values ('a'),('a,A'),('A,a'),('A');
select s from t1 order by s;
select s from t1 order by concat(s);
drop table t1;
#
# Check that SET honors a more complex collation correctly
#
CREATE TABLE t1 (c set('ae','oe','ue','ss') collate latin1_german2_ci);
INSERT INTO t1 VALUES (''),(''),(''),('');
INSERT INTO t1 VALUES ('ae'),('oe'),('ue'),('ss');
INSERT INTO t1 VALUES (',,,');
INSERT INTO t1 VALUES ('ae,oe,ue,ss');
SELECT c FROM t1 ORDER BY c;
SELECT c FROM t1 ORDER BY concat(c);
DROP TABLE t1;
# End of 4.1 tests
#
# Bug#27069 set with identical elements are created
#
--error 1097
create table t1(f1
set('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17',
'18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33',
'34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49',
'50','51','52','53','54','55','56','57','58','59','60','61','62','63','64','128'));
create table t1(f1
set('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17',
'18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33',
'34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49',
'50','51','52','53','54','55','56','57','58','59','60','61','62','63','64','1'));
show create table t1;
drop table t1;
SET STORAGE_ENGINE='tokudb';
#
# testing of the TIME column type
#
--disable_warnings
drop table if exists t1;
--enable_warnings
create table t1 (t time);
insert into t1 values("10:22:33"),("12:34:56.78"),(10),(1234),(123456.78),(1234559.99),("1"),("1:23"),("1:23:45"), ("10.22"), ("-10 1:22:33.45"),("20 10:22:33"),("1999-02-03 20:33:34");
insert t1 values (30),(1230),("1230"),("12:30"),("12:30:35"),("1 12:30:31.32");
select * from t1;
# Test wrong values
insert into t1 values("10.22.22"),(1234567),(123456789),(123456789.10),("10 22:22"),("12.45a");
select * from t1;
drop table t1;
create table t1 (t time);
insert into t1 values ('09:00:00'),('13:00:00'),('19:38:34'), ('13:00:00'),('09:00:00'),('09:00:00'),('13:00:00'),('13:00:00'),('13:00:00'),('09:00:00');
select t, time_to_sec(t),sec_to_time(time_to_sec(t)) from t1;
select sec_to_time(time_to_sec(t)) from t1;
drop table t1;
#
# BUG #12440: Incorrect processing of time values containing
# long fraction part and/or large exponent part.
#
# These must return normal result:
# ##########################################################
# To be uncommented after fix BUG #15805
# ##########################################################
# SELECT CAST(235959.123456 AS TIME);
# SELECT CAST(0.235959123456e+6 AS TIME);
# SELECT CAST(235959123456e-6 AS TIME);
# These must cut fraction part and produce warning:
# SELECT CAST(235959.1234567 AS TIME);
# SELECT CAST(0.2359591234567e6 AS TIME);
# This must return NULL and produce warning:
# SELECT CAST(0.2359591234567e+30 AS TIME);
# ##########################################################
# End of 4.1 tests
#
# Bug#29555: Comparing time values as strings may lead to a wrong result.
#
select cast('100:55:50' as time) < cast('24:00:00' as time);
select cast('100:55:50' as time) < cast('024:00:00' as time);
select cast('300:55:50' as time) < cast('240:00:00' as time);
select cast('100:55:50' as time) > cast('24:00:00' as time);
select cast('100:55:50' as time) > cast('024:00:00' as time);
select cast('300:55:50' as time) > cast('240:00:00' as time);
create table t1 (f1 time);
insert into t1 values ('24:00:00');
select cast('24:00:00' as time) = (select f1 from t1);
drop table t1;
#
# Bug#29739: Incorrect time comparison in BETWEEN.
#
create table t1(f1 time, f2 time);
insert into t1 values('20:00:00','150:00:00');
select 1 from t1 where cast('100:00:00' as time) between f1 and f2;
drop table t1;
#
# Bug#29729: Wrong conversion error led to an empty result set.
#
CREATE TABLE t1 (
f2 date NOT NULL,
f3 int(11) unsigned NOT NULL default '0',
PRIMARY KEY (f3, f2)
);
insert into t1 values('2007-07-01', 1);
insert into t1 values('2007-07-01', 2);
insert into t1 values('2007-07-02', 1);
insert into t1 values('2007-07-02', 2);
SELECT sum(f3) FROM t1 where f2='2007-07-01 00:00:00' group by f2;
drop table t1;
SET STORAGE_ENGINE='tokudb';
#
# Test timestamp
#
--disable_warnings
drop table if exists t1,t2;
--enable_warnings
# Set timezone to GMT-3, to make it possible to use "interval 3 hour"
set time_zone="+03:00";
CREATE TABLE t1 (a int, t timestamp);
CREATE TABLE t2 (a int, t datetime);
SET TIMESTAMP=1234;
insert into t1 values(1,NULL);
insert into t1 values(2,"2002-03-03");
SET TIMESTAMP=1235;
insert into t1 values(3,NULL);
SET TIMESTAMP=1236;
insert into t1 (a) values(4);
insert into t2 values(5,"2002-03-04"),(6,NULL),(7,"2002-03-05"),(8,"00-00-00");
SET TIMESTAMP=1237;
insert into t1 select * from t2;
SET TIMESTAMP=1238;
insert into t1 (a) select a+1 from t2 where a=8;
select * from t1;
drop table t1,t2;
SET TIMESTAMP=1234;
CREATE TABLE t1 (value TEXT NOT NULL, id VARCHAR(32) NOT NULL, stamp timestamp, PRIMARY KEY (id));
INSERT INTO t1 VALUES ("my value", "myKey","1999-04-02 00:00:00");
SELECT stamp FROM t1 WHERE id="myKey";
UPDATE t1 SET value="my value" WHERE id="myKey";
SELECT stamp FROM t1 WHERE id="myKey";
UPDATE t1 SET id="myKey" WHERE value="my value";
SELECT stamp FROM t1 WHERE id="myKey";
drop table t1;
create table t1 (a timestamp);
insert into t1 values (now());
select date_format(a,"%Y %y"),year(a),year(now()) from t1;
drop table t1;
create table t1 (ix timestamp);
insert into t1 values (19991101000000),(19990102030405),(19990630232922),(19990601000000),(19990930232922),(19990531232922),(19990501000000),(19991101000000),(19990501000000);
select ix+0 from t1;
truncate table t1;
insert into t1 values ("19991101000000"),("19990102030405"),("19990630232922"),("19990601000000");
select ix+0 from t1;
drop table t1;
CREATE TABLE t1 (date date, date_time datetime, time_stamp timestamp);
INSERT INTO t1 VALUES ("1998-12-31","1998-12-31 23:59:59",19981231235959);
INSERT INTO t1 VALUES ("1999-01-01","1999-01-01 00:00:00",19990101000000);
INSERT INTO t1 VALUES ("1999-09-09","1999-09-09 23:59:59",19990909235959);
INSERT INTO t1 VALUES ("2000-01-01","2000-01-01 00:00:00",20000101000000);
INSERT INTO t1 VALUES ("2000-02-28","2000-02-28 00:00:00",20000228000000);
INSERT INTO t1 VALUES ("2000-02-29","2000-02-29 00:00:00",20000229000000);
INSERT INTO t1 VALUES ("2000-03-01","2000-03-01 00:00:00",20000301000000);
INSERT INTO t1 VALUES ("2000-12-31","2000-12-31 23:59:59",20001231235959);
INSERT INTO t1 VALUES ("2001-01-01","2001-01-01 00:00:00",20010101000000);
INSERT INTO t1 VALUES ("2004-12-31","2004-12-31 23:59:59",20041231235959);
INSERT INTO t1 VALUES ("2005-01-01","2005-01-01 00:00:00",20050101000000);
INSERT INTO t1 VALUES ("2030-01-01","2030-01-01 00:00:00",20300101000000);
# The following will get you an different answer on 64 bit machines
#INSERT INTO t1 VALUES ("2050-01-01","2050-01-01 00:00:00",20500101000000);
SELECT * FROM t1;
drop table t1;
create table t1 (t2 timestamp(2), t4 timestamp(4), t6 timestamp(6),
t8 timestamp(8), t10 timestamp(10), t12 timestamp(12),
t14 timestamp(14));
insert t1 values (0,0,0,0,0,0,0),
("1997-12-31 23:47:59", "1997-12-31 23:47:59", "1997-12-31 23:47:59",
"1997-12-31 23:47:59", "1997-12-31 23:47:59", "1997-12-31 23:47:59",
"1997-12-31 23:47:59");
select * from t1;
select * from t1;
drop table t1;
#
# Let us check if we properly treat wrong datetimes and produce proper warnings
# (for both strings and numbers)
#
create table t1 (ix timestamp);
insert into t1 values (0),(20030101010160),(20030101016001),(20030101240101),(20030132010101),(20031301010101),(20031200000000),(20030000000000);
select ix+0 from t1;
truncate table t1;
insert into t1 values ("00000000000000"),("20030101010160"),("20030101016001"),("20030101240101"),("20030132010101"),("20031301010101"),("20031200000000"),("20030000000000");
select ix+0 from t1;
truncate table t1;
insert into t1 values ("0000-00-00 00:00:00 some trailer"),("2003-01-01 00:00:00 some trailer");
select ix+0 from t1;
drop table t1;
#
# Test for TIMESTAMP column with default now() and on update now() clauses
#
# These statements should fail.
--error 1293
create table t1 (t1 timestamp, t2 timestamp default now());
--error 1293
create table t1 (t1 timestamp, t2 timestamp on update now());
--error 1293
create table t1 (t1 timestamp, t2 timestamp default now() on update now());
--error 1293
create table t1 (t1 timestamp default now(), t2 timestamp on update now());
--error 1293
create table t1 (t1 timestamp on update now(), t2 timestamp default now() on update now());
# Let us test TIMESTAMP auto-update behaviour
# Also we will test behaviour of TIMESTAMP field in SHOW CREATE TABLE and
# behaviour of DEFAULT literal for such fields
create table t1 (t1 timestamp default '2003-01-01 00:00:00', t2 datetime, t3 timestamp);
SET TIMESTAMP=1000000000;
insert into t1 values ();
SET TIMESTAMP=1000000001;
update t1 set t2=now();
SET TIMESTAMP=1000000002;
insert into t1 (t1,t3) values (default, default);
select * from t1;
show create table t1;
show columns from t1;
drop table t1;
create table t1 (t1 timestamp default now(), t2 datetime, t3 timestamp);
SET TIMESTAMP=1000000002;
insert into t1 values ();
SET TIMESTAMP=1000000003;
update t1 set t2=now();
SET TIMESTAMP=1000000003;
insert into t1 (t1,t3) values (default, default);
select * from t1;
show create table t1;
show columns from t1;
drop table t1;
create table t1 (t1 timestamp default '2003-01-01 00:00:00' on update now(), t2 datetime);
SET TIMESTAMP=1000000004;
insert into t1 values ();
select * from t1;
SET TIMESTAMP=1000000005;
update t1 set t2=now();
SET TIMESTAMP=1000000005;
insert into t1 (t1) values (default);
select * from t1;
show create table t1;
show columns from t1;
drop table t1;
create table t1 (t1 timestamp default now() on update now(), t2 datetime);
SET TIMESTAMP=1000000006;
insert into t1 values ();
select * from t1;
SET TIMESTAMP=1000000007;
update t1 set t2=now();
SET TIMESTAMP=1000000007;
insert into t1 (t1) values (default);
select * from t1;
show create table t1;
show columns from t1;
drop table t1;
create table t1 (t1 timestamp, t2 datetime, t3 timestamp);
SET TIMESTAMP=1000000007;
insert into t1 values ();
select * from t1;
SET TIMESTAMP=1000000008;
update t1 set t2=now();
SET TIMESTAMP=1000000008;
insert into t1 (t1,t3) values (default, default);
select * from t1;
show create table t1;
show columns from t1;
drop table t1;
# Let us test if CURRENT_TIMESTAMP also works well as default value
# (Of course NOW and CURRENT_TIMESTAMP are same for parser but still just
# for demonstartion.)
create table t1 (t1 timestamp default current_timestamp on update current_timestamp, t2 datetime);
SET TIMESTAMP=1000000009;
insert into t1 values ();
select * from t1;
SET TIMESTAMP=1000000010;
update t1 set t2=now();
SET TIMESTAMP=1000000011;
insert into t1 (t1) values (default);
select * from t1;
show create table t1;
show columns from t1;
truncate table t1;
#
# Let us test some cases when auto-set should be disabled or influence
# on server behavior in some other way.
#
# Update statement that explicitly sets field should not auto-set it.
insert into t1 values ('2004-04-01 00:00:00', '2004-04-01 00:00:00');
SET TIMESTAMP=1000000012;
update t1 set t1= '2004-04-02 00:00:00';
select * from t1;
# The same for multi updates
update t1 as ta, t1 as tb set tb.t1= '2004-04-03 00:00:00';
select * from t1;
drop table t1;
# Now let us test replace it should behave exactly like delete+insert
# Case where optimization is possible DEFAULT = ON UPDATE
create table t1 (pk int primary key, t1 timestamp default current_timestamp on update current_timestamp, bulk int);
insert into t1 values (1, '2004-04-01 00:00:00', 10);
SET TIMESTAMP=1000000013;
replace into t1 set pk = 1, bulk= 20;
select * from t1;
drop table t1;
# Case in which there should not be optimisation
create table t1 (pk int primary key, t1 timestamp default '2003-01-01 00:00:00' on update current_timestamp, bulk int);
insert into t1 values (1, '2004-04-01 00:00:00', 10);
SET TIMESTAMP=1000000014;
replace into t1 set pk = 1, bulk= 20;
select * from t1;
drop table t1;
# Other similar case
create table t1 (pk int primary key, t1 timestamp default current_timestamp, bulk int);
insert into t1 values (1, '2004-04-01 00:00:00', 10);
SET TIMESTAMP=1000000015;
replace into t1 set pk = 1, bulk= 20;
select * from t1;
drop table t1;
# Let us test alter now
create table t1 (t1 timestamp default current_timestamp on update current_timestamp);
insert into t1 values ('2004-04-01 00:00:00');
SET TIMESTAMP=1000000016;
alter table t1 add i int default 10;
select * from t1;
drop table t1;
#
# Test for TIMESTAMP columns which are able to store NULLs
#
# Unlike for default TIMESTAMP fields we don't interpret first field
# in this table as TIMESTAMP with DEFAULT NOW() ON UPDATE NOW() properties.
create table t1 (a timestamp null, b timestamp null);
show create table t1;
insert into t1 values (NULL, NULL);
SET TIMESTAMP=1000000017;
insert into t1 values ();
select * from t1;
drop table t1;
# But explicit auto-set properties still should be OK.
create table t1 (a timestamp null default current_timestamp on update current_timestamp, b timestamp null);
show create table t1;
insert into t1 values (NULL, NULL);
SET TIMESTAMP=1000000018;
insert into t1 values ();
select * from t1;
drop table t1;
# It is also OK to specify NULL as default explicitly for such fields.
# This is also a test for bug #2464, DEFAULT keyword in INSERT statement
# should return default value for column.
create table t1 (a timestamp null default null, b timestamp null default '2003-01-01 00:00:00');
show create table t1;
insert into t1 values (NULL, NULL);
insert into t1 values (DEFAULT, DEFAULT);
select * from t1;
drop table t1;
#
# Let us test behavior of ALTER TABLE when it converts columns
# containing NULL to TIMESTAMP columns.
#
create table t1 (a bigint, b bigint);
insert into t1 values (NULL, NULL), (20030101000000, 20030102000000);
set timestamp=1000000019;
alter table t1 modify a timestamp, modify b timestamp;
select * from t1;
drop table t1;
#
# Test for bug #4131, TIMESTAMP columns missing minutes and seconds when
# using GROUP BY in @@new=1 mode.
#
create table t1 (a char(2), t timestamp);
insert into t1 values ('a', '2004-01-01 00:00:00'), ('a', '2004-01-01 01:00:00'),
('b', '2004-02-01 00:00:00');
select max(t) from t1 group by a;
drop table t1;
#
# Test for bug #7418 "TIMESTAMP not always converted to DATETIME in MAXDB
# mode". TIMESTAMP columns should be converted DATETIME columns in MAXDB
# mode regardless of whether a display width is given.
#
set sql_mode='maxdb';
create table t1 (a timestamp, b timestamp(19));
show create table t1;
# restore default mode
set sql_mode='';
drop table t1;
#
# Bug#7806 - insert on duplicate key and auto-update of timestamp
#
create table t1 (a int auto_increment primary key, b int, c timestamp);
insert into t1 (a, b, c) values (1, 0, '2001-01-01 01:01:01'),
(2, 0, '2002-02-02 02:02:02'), (3, 0, '2003-03-03 03:03:03');
select * from t1;
update t1 set b = 2, c = c where a = 2;
select * from t1;
insert into t1 (a) values (4);
select * from t1;
update t1 set c = '2004-04-04 04:04:04' where a = 4;
select * from t1;
insert into t1 (a) values (3), (5) on duplicate key update b = 3, c = c;
select * from t1;
insert into t1 (a, c) values (4, '2004-04-04 00:00:00'),
(6, '2006-06-06 06:06:06') on duplicate key update b = 4;
select * from t1;
drop table t1;
# End of 4.1 tests
# Restore timezone to default
set time_zone= @@global.time_zone;
CREATE TABLE t1 (
`id` int(11) NOT NULL auto_increment,
`username` varchar(80) NOT NULL default '',
`posted_on` timestamp NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
show fields from t1;
select is_nullable from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='t1' and COLUMN_NAME='posted_on';
drop table t1;
SET STORAGE_ENGINE='tokudb';
#
# test of unsigned int
#
--disable_warnings
drop table if exists t1;
--enable_warnings
SET SQL_WARNINGS=1;
create table t1 (this int unsigned);
insert into t1 values (1);
insert into t1 values (-1);
insert into t1 values ('5000000000');
select * from t1;
drop table t1;
# End of 4.1 tests
SET STORAGE_ENGINE='tokudb';
--disable_warnings
drop table if exists t1, t2, vchar;
--enable_warnings
set tokudb_load_save_space=1;
create table t1 (v varchar(30), c char(3), e enum('abc','def','ghi'), t text);
create table vchar (v varchar(30), c char(3), e enum('abc','def','ghi'), t text);
truncate table vchar;
show create table t1;
show create table vchar;
insert into t1 values ('abc', 'de', 'ghi', 'jkl');
insert into t1 values ('abc ', 'de ', 'ghi', 'jkl ');
insert into t1 values ('abc ', 'd ', 'ghi', 'jkl ');
insert into vchar values ('abc', 'de', 'ghi', 'jkl');
insert into vchar values ('abc ', 'de ', 'ghi', 'jkl ');
insert into vchar values ('abc ', 'd ', 'ghi', 'jkl ');
select length(v),length(c),length(e),length(t) from t1;
select length(v),length(c),length(e),length(t) from vchar;
alter table vchar add i int;
show create table vchar;
select length(v),length(c),length(e),length(t) from vchar;
drop table t1, vchar;
create table t1 (v varchar(20));
insert into t1 values('a ');
select v='a' from t1;
select binary v='a' from t1;
select binary v='a ' from t1;
insert into t1 values('a');
--error ER_DUP_ENTRY
alter table t1 add primary key (v);
drop table t1;
create table t1 (v varbinary(20));
insert into t1 values('a');
insert into t1 values('a ');
alter table t1 add primary key (v);
drop table t1;
#
# Test with varchar of lengths 254,255,256,258 & 258 to ensure we don't
# have any problems with varchar with one or two byte length_bytes
#
create table t1 (v varchar(254), index (v));
insert into t1 values ("This is a test ");
insert into t1 values ("Some sample data");
insert into t1 values (" garbage ");
insert into t1 values (" This is a test ");
insert into t1 values ("This is a test");
insert into t1 values ("Hello world");
insert into t1 values ("Foo bar");
insert into t1 values ("This is a test");
insert into t1 values ("MySQL varchar test");
insert into t1 values ("test MySQL varchar");
insert into t1 values ("This is a long string to have some random length data included");
insert into t1 values ("Short string");
insert into t1 values ("VSS");
insert into t1 values ("Some samples");
insert into t1 values ("Bar foo");
insert into t1 values ("Bye");
let $i= 255;
let $j= 5;
while ($j)
{
select * from t1 where v like 'This is a test' order by v;
select * from t1 where v='This is a test' order by v;
select * from t1 where v like 'S%' order by v;
explain select * from t1 where v like 'This is a test' order by v;
explain select * from t1 where v='This is a test' order by v;
explain select * from t1 where v like 'S%' order by v;
alter table t1 drop index v;
eval alter table t1 change v v varchar($i);
alter table t1 add index v(v);
inc $i;
dec $j;
}
let $i= 258;
let $j= 6;
while ($j)
{
select * from t1 where v like 'This is a test' order by v;
select * from t1 where v='This is a test' order by v;
select * from t1 where v like 'S%' order by v;
explain select * from t1 where v like 'This is a test' order by v;
explain select * from t1 where v='This is a test' order by v;
explain select * from t1 where v like 'S%' order by v;
eval alter table t1 change v v varchar($i);
dec $i;
dec $j;
}
alter table t1 change v v varchar(254), drop key v;
# Test with length(varchar) > 256 and key < 256 (to ensure things works with
# different kind of packing
alter table t1 change v v varchar(300), add key (v(10));
select * from t1 where v like 'This is a test' order by v;
select * from t1 where v='This is a test' order by v;
select * from t1 where v like 'S%' order by v;
explain select * from t1 where v like 'This is a test' order by v;
explain select * from t1 where v='This is a test' order by v;
explain select * from t1 where v like 'S%' order by v;
drop table t1;
#
# bug#9339 - meaningless Field_varstring::get_key_image
#
create table t1 (pkcol varchar(16), othercol varchar(16), primary key (pkcol));
insert into t1 values ('test', 'something');
update t1 set othercol='somethingelse' where pkcol='test';
select * from t1;
drop table t1;
#
# Bug #9489: problems with key handling
#
create table t1 (a int, b varchar(12));
insert into t1 values (1, 'A'), (22, NULL);
create table t2 (a int);
insert into t2 values (22), (22);
select t1.a, t1.b, min(t1.b) from t1 inner join t2 ON t2.a = t1.a
group by t1.b, t1.a;
drop table t1, t2;
#
# Bug #10543: convert varchar with index to text
#
create table t1 (f1 varchar(65500));
create index index1 on t1(f1(10));
show create table t1;
alter table t1 modify f1 varchar(255);
show create table t1;
alter table t1 modify f1 tinytext;
show create table t1;
drop table t1;
#
# BUG#15588: String overrun
#
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1(f1 VARCHAR(100) DEFAULT 'test');
INSERT INTO t1 VALUES(SUBSTR(f1, 1, 3));
DROP TABLE IF EXISTS t1;
CREATE TABLE t1(f1 CHAR(100) DEFAULT 'test');
INSERT INTO t1 VALUES(SUBSTR(f1, 1, 3));
DROP TABLE IF EXISTS t1;
#
# Bug#14897 "ResultSet.getString("table.column") sometimes doesn't find the
# column"
# Test that after upgrading an old 4.1 VARCHAR column to 5.0 VARCHAR we preserve
# the original column metadata.
#
--disable_warnings
drop table if exists t1, t2, t3;
--enable_warnings
create table t3 (
id int(11),
en varchar(255) character set utf8,
cz varchar(255) character set utf8
);
#remove_file $MYSQLTEST_VARDIR/master-data/test/t3.frm;
#copy_file $MYSQL_TEST_DIR/std_data/14897.frm $MYSQLTEST_VARDIR/master-data/test/t3.frm;
truncate table t3;
insert into t3 (id, en, cz) values
(1,'en string 1','cz string 1'),
(2,'en string 2','cz string 2'),
(3,'en string 3','cz string 3');
create table t1 (
id int(11),
name_id int(11)
);
insert into t1 (id, name_id) values (1,1), (2,3), (3,3);
create table t2 (id int(11));
insert into t2 (id) values (1), (2), (3);
# max_length is different for varchar fields in ps-protocol and we can't
# replace a single metadata column, disable PS protocol
--disable_ps_protocol
--enable_metadata
select t1.*, t2.id, t3.en, t3.cz from t1 left join t2 on t1.id=t2.id
left join t3 on t1.id=t3.id order by t3.id;
--disable_metadata
--enable_ps_protocol
drop table t1, t2, t3;
#
# Bug #11927: Warnings shown for CAST( chr as signed) but not (chr + 0)
#
CREATE TABLE t1 (a CHAR(2));
INSERT INTO t1 VALUES (10), (50), (30), ('1a'), (60), ('t');
SELECT a,(a + 0) FROM t1 ORDER BY a;
SELECT a,(a DIV 2) FROM t1 ORDER BY a;
SELECT a,CAST(a AS SIGNED) FROM t1 ORDER BY a;
DROP TABLE t1;
SET STORAGE_ENGINE='tokudb';
#
# Test year
#
--disable_warnings
drop table if exists t1;
--enable_warnings
create table t1 (y year,y2 year(2));
insert into t1 values (0,0),(1999,1999),(2000,2000),(2001,2001),(70,70),(69,69);
select * from t1;
select * from t1 order by y;
select * from t1 order by y2;
drop table t1;
#
# Bug 2335
#
create table t1 (y year);
insert into t1 values (now());
select if(y = now(), 1, 0) from t1;
drop table t1;
#
# Bug #27176: Assigning a string to an year column has unexpected results
#
create table t1(a year);
insert into t1 values (2000.5), ('2000.5'), ('2001a'), ('2.001E3');
select * from t1;
drop table t1;
--echo End of 5.0 tests
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