Skip to content

Commit 454589b

Browse files
author
Alexander Barkov
committed
MDEV-9393 Split Copy_field::get_copy_func() into virtual methods in Field
Also fixes: MDEV-9391 InnoDB does not produce warnings when doing WHERE int_column=varchar_column MDEV-9337 ALTER from DECIMAL and INT to DATETIME returns a wrong result MDEV-9340 Copying from INT/DOUBLE to ENUM is inconsistent MDEV-9392 Copying from DECIMAL to YEAR is not consistent about warnings
1 parent 250ab81 commit 454589b

18 files changed

+828
-127
lines changed

mysql-test/r/join_cache.result

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4691,6 +4691,9 @@ FROM t1 LEFT JOIN
46914691
(t2 LEFT OUTER JOIN t3 ON t2.b = t3.b) ON t2.a = t1.b
46924692
WHERE t3.a BETWEEN 3 AND 11 OR t1.a <= t2.c;
46934693
a
4694+
Warnings:
4695+
Warning 1292 Truncated incorrect INTEGER value: 'h'
4696+
Warning 1292 Truncated incorrect INTEGER value: 'j'
46944697
SET SESSION optimizer_switch = 'outer_join_with_cache=off';
46954698
SET SESSION join_cache_level = DEFAULT;
46964699
DROP TABLE t1,t2,t3;

mysql-test/r/subselect_sj2.result

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,8 @@ SELECT d FROM t2, t1
937937
WHERE a = d AND ( pk < 2 OR d = 'z' )
938938
);
939939
a b c
940+
Warnings:
941+
Warning 1292 Truncated incorrect INTEGER value: 'x'
940942
DROP TABLE t1, t2;
941943
#
942944
# BUG#951937: Wrong result (missing rows) with semijoin+materialization, IN subquery, InnoDB, TEMPTABLE view

mysql-test/r/subselect_sj2_jcl6.result

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,8 @@ SELECT d FROM t2, t1
952952
WHERE a = d AND ( pk < 2 OR d = 'z' )
953953
);
954954
a b c
955+
Warnings:
956+
Warning 1292 Truncated incorrect INTEGER value: 'x'
955957
DROP TABLE t1, t2;
956958
#
957959
# BUG#951937: Wrong result (missing rows) with semijoin+materialization, IN subquery, InnoDB, TEMPTABLE view

mysql-test/r/subselect_sj2_mat.result

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,8 @@ SELECT d FROM t2, t1
939939
WHERE a = d AND ( pk < 2 OR d = 'z' )
940940
);
941941
a b c
942+
Warnings:
943+
Warning 1292 Truncated incorrect INTEGER value: 'x'
942944
DROP TABLE t1, t2;
943945
#
944946
# BUG#951937: Wrong result (missing rows) with semijoin+materialization, IN subquery, InnoDB, TEMPTABLE view

mysql-test/r/type_datetime.result

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,3 +1141,54 @@ DROP TABLE t1;
11411141
#
11421142
# End of 10.1 tests
11431143
#
1144+
#
1145+
# Start of 10.2 tests
1146+
#
1147+
#
1148+
# MDEV-9337 ALTER from DECIMAL and INT to DATETIME returns a wrong result
1149+
#
1150+
CREATE TABLE t1 (a DATETIME);
1151+
INSERT INTO t1 VALUES (1000);
1152+
SELECT * FROM t1;
1153+
a
1154+
2000-10-00 00:00:00
1155+
DROP TABLE t1;
1156+
CREATE TABLE t1 (a DATETIME);
1157+
CREATE TABLE t2 (a INT);
1158+
INSERT INTO t2 VALUES (1000);
1159+
INSERT INTO t1 SELECT * FROM t2;
1160+
SELECT * FROM t1;
1161+
a
1162+
2000-10-00 00:00:00
1163+
DROP TABLE t1,t2;
1164+
CREATE TABLE t1 (a INT);
1165+
INSERT INTO t1 VALUES (1000);
1166+
ALTER TABLE t1 MODIFY a DATETIME;
1167+
SELECT * FROM t1;
1168+
a
1169+
2000-10-00 00:00:00
1170+
DROP TABLE t1;
1171+
CREATE TABLE t1 (a DATETIME);
1172+
INSERT INTO t1 VALUES (1000.0);
1173+
SELECT * FROM t1;
1174+
a
1175+
2000-10-00 00:00:00
1176+
DROP TABLE IF EXISTS t1;
1177+
CREATE TABLE t1 (a DATETIME);
1178+
CREATE TABLE t2 (a DECIMAL(4,0));
1179+
INSERT INTO t2 VALUES (1000);
1180+
INSERT INTO t1 SELECT * FROM t2;
1181+
SELECT * FROM t1;
1182+
a
1183+
2000-10-00 00:00:00
1184+
DROP TABLE t1,t2;
1185+
CREATE TABLE t1 (a DECIMAL(4,0));
1186+
INSERT INTO t1 VALUES (1000);
1187+
ALTER TABLE t1 MODIFY a DATETIME;
1188+
SELECT * FROM t1;
1189+
a
1190+
2000-10-00 00:00:00
1191+
DROP TABLE t1;
1192+
#
1193+
# End of 10.2 tests
1194+
#

mysql-test/r/type_enum.result

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2134,3 +2134,84 @@ DROP TABLE t1;
21342134
#
21352135
# End of 10.1 tests
21362136
#
2137+
#
2138+
# MDEV-9340 Copying from INT/DOUBLE to ENUM is inconsistent
2139+
#
2140+
CREATE TABLE t1 (a ENUM('9e200','9e100'));
2141+
CREATE TABLE t2 (a DOUBLE);
2142+
INSERT INTO t2 VALUES ('9e100');
2143+
INSERT INTO t1 SELECT * FROM t2;
2144+
Warnings:
2145+
Warning 1265 Data truncated for column 'a' at row 1
2146+
SELECT * FROM t1;
2147+
a
2148+
2149+
DROP TABLE t1,t2;
2150+
CREATE TABLE t1 (a DOUBLE);
2151+
INSERT INTO t1 VALUES (9e100);
2152+
ALTER TABLE t1 MODIFY a ENUM('9e200','9e100');
2153+
Warnings:
2154+
Warning 1292 Truncated incorrect INTEGER value: '9e100'
2155+
Warning 1265 Data truncated for column 'a' at row 1
2156+
SELECT * FROM t1;
2157+
a
2158+
2159+
DROP TABLE t1;
2160+
CREATE TABLE t1 (a ENUM('200','100'));
2161+
CREATE TABLE t2 (a DOUBLE);
2162+
INSERT INTO t2 VALUES ('100');
2163+
INSERT INTO t1 SELECT * FROM t2;
2164+
Warnings:
2165+
Warning 1265 Data truncated for column 'a' at row 1
2166+
SELECT * FROM t1;
2167+
a
2168+
2169+
DROP TABLE t1,t2;
2170+
CREATE TABLE t1 (a ENUM('200','100'));
2171+
CREATE TABLE t2 (a INT);
2172+
INSERT INTO t2 VALUES ('100');
2173+
INSERT INTO t1 SELECT * FROM t2;
2174+
Warnings:
2175+
Warning 1265 Data truncated for column 'a' at row 1
2176+
SELECT * FROM t1;
2177+
a
2178+
2179+
DROP TABLE t1,t2;
2180+
CREATE TABLE t1 (a INT);
2181+
INSERT INTO t1 VALUES ('200');
2182+
ALTER TABLE t1 MODIFY a ENUM('200','100');
2183+
Warnings:
2184+
Warning 1265 Data truncated for column 'a' at row 1
2185+
SELECT *FROM t1;
2186+
a
2187+
2188+
DROP TABLE t1;
2189+
CREATE TABLE t1 (a ENUM('200','100'));
2190+
CREATE TABLE t2 (a INT);
2191+
INSERT INTO t2 VALUES ('100');
2192+
INSERT INTO t1 SELECT * FROM t2;
2193+
Warnings:
2194+
Warning 1265 Data truncated for column 'a' at row 1
2195+
SELECT * FROM t1;
2196+
a
2197+
2198+
DROP TABLE t1,t2;
2199+
CREATE TABLE t1 (a ENUM('2001','2002'));
2200+
CREATE TABLE t2 (a YEAR);
2201+
INSERT INTO t2 VALUES ('2001');
2202+
INSERT INTO t1 SELECT * FROM t2;
2203+
Warnings:
2204+
Warning 1265 Data truncated for column 'a' at row 1
2205+
SELECT * FROM t1;
2206+
a
2207+
2208+
DROP TABLE t1,t2;
2209+
CREATE TABLE t1 (a YEAR);
2210+
INSERT INTO t1 VALUES ('2001');
2211+
ALTER TABLE t1 MODIFY a ENUM('2001','2002');
2212+
Warnings:
2213+
Warning 1265 Data truncated for column 'a' at row 1
2214+
SELECT * FROM t1;
2215+
a
2216+
2217+
DROP TABLE t1;

mysql-test/r/type_int.result

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,60 @@ DROP TABLE t1;
3636
#
3737
# End of 10.1 tests
3838
#
39+
#
40+
# Start of 10.2 tests
41+
#
42+
#
43+
# MDEV-9393 Split Copy_field::get_copy_func() into virtual methods in Field
44+
#
45+
CREATE TABLE t1 (a INT);
46+
INSERT INTO t1 VALUES (10.1),(10.9);
47+
SELECT * FROM t1;
48+
a
49+
10
50+
11
51+
DROP TABLE t1;
52+
CREATE TABLE t1 (a INT);
53+
CREATE TABLE t2 (a DECIMAL(10,2));
54+
INSERT INTO t2 VALUES (10.1),(10.9);
55+
INSERT INTO t1 SELECT a FROM t2;
56+
SELECT * FROM t1;
57+
a
58+
10
59+
11
60+
DROP TABLE t1,t2;
61+
CREATE TABLE t1 (a DECIMAL(10,2));
62+
INSERT INTO t1 VALUES (10.1),(10.9);
63+
ALTER TABLE t1 MODIFY a INT;
64+
SELECT * FROM t1;
65+
a
66+
10
67+
11
68+
DROP TABLE t1;
69+
CREATE TABLE t1 (a INT);
70+
INSERT INTO t1 VALUES (TIME'00:00:10.1'),(TIME'00:00:10.9');
71+
SELECT * FROM t1;
72+
a
73+
10
74+
10
75+
DROP TABLE t1;
76+
CREATE TABLE t1 (a INT);
77+
CREATE TABLE t2 (a TIME(1));
78+
INSERT INTO t2 VALUES (10.1),(10.9);
79+
INSERT INTO t1 SELECT a FROM t2;
80+
SELECT * FROM t1;
81+
a
82+
10
83+
10
84+
DROP TABLE t1,t2;
85+
CREATE TABLE t1 (a TIME(1));
86+
INSERT INTO t1 VALUES (10.1),(10.9);
87+
ALTER TABLE t1 MODIFY a INT;
88+
SELECT * FROM t1;
89+
a
90+
10
91+
10
92+
DROP TABLE t1;
93+
#
94+
# End of 10.2 tests
95+
#

mysql-test/r/type_num_innodb.result

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
#
2+
# Start of 10.2 tests
3+
#
4+
#
5+
# MDEV-9391 InnoDB does not produce warnings when doing WHERE int_column=varchar_column
6+
#
7+
CREATE TABLE t1 (
8+
a DOUBLE, b VARCHAR(1), c INT,
9+
KEY(a), KEY(b)
10+
) ENGINE=InnoDB;
11+
INSERT INTO t1 VALUES
12+
(1,'v',9),(2,'v',8),(3,'c',7),(4,'m',6),(5,'x',5),
13+
(6,'i',4),(7,'e',3),(8,'p',2),(9,'s',1),(10,'j',9),
14+
(11,'z',8),(12,'c',7),(13,'a',6),(14,'q',5),(15,'y',4),
15+
(16,'n',3),(17,'r',2),(18,'v',1),(19,'p',0);
16+
CREATE TABLE t2 (
17+
pk INT, d VARCHAR(1), e INT,
18+
PRIMARY KEY(pk), KEY(d,e)
19+
) ENGINE=InnoDB;
20+
INSERT INTO t2 VALUES
21+
(1,'x',1),(2,'d',2),(3,'r',3),(4,'f',4),(5,'y',5),
22+
(6,'u',6),(7,'m',7),(8,'k',8),(9,'o',9),(10,'w',1),
23+
(11,'m',2),(12,'q',3),(13,'m',4),(14,'d',5),
24+
(15,'g',6),(16,'x',7),(17,'f',8);
25+
SELECT * FROM t1,t2 WHERE a=d;
26+
a b c pk d e
27+
Warnings:
28+
Warning 1292 Truncated incorrect DOUBLE value: 'd'
29+
Warning 1292 Truncated incorrect DOUBLE value: 'd'
30+
Warning 1292 Truncated incorrect DOUBLE value: 'f'
31+
Warning 1292 Truncated incorrect DOUBLE value: 'f'
32+
Warning 1292 Truncated incorrect DOUBLE value: 'g'
33+
Warning 1292 Truncated incorrect DOUBLE value: 'k'
34+
Warning 1292 Truncated incorrect DOUBLE value: 'm'
35+
Warning 1292 Truncated incorrect DOUBLE value: 'm'
36+
Warning 1292 Truncated incorrect DOUBLE value: 'm'
37+
Warning 1292 Truncated incorrect DOUBLE value: 'o'
38+
Warning 1292 Truncated incorrect DOUBLE value: 'q'
39+
Warning 1292 Truncated incorrect DOUBLE value: 'r'
40+
Warning 1292 Truncated incorrect DOUBLE value: 'u'
41+
Warning 1292 Truncated incorrect DOUBLE value: 'w'
42+
Warning 1292 Truncated incorrect DOUBLE value: 'x'
43+
Warning 1292 Truncated incorrect DOUBLE value: 'x'
44+
Warning 1292 Truncated incorrect DOUBLE value: 'y'
45+
ALTER TABLE t1 MODIFY a DECIMAL(10,0);
46+
SELECT * FROM t1,t2 WHERE a=d;
47+
a b c pk d e
48+
Warnings:
49+
Warning 1918 Encountered illegal value '' when converting to DECIMAL
50+
Warning 1292 Truncated incorrect DECIMAL value: 'd'
51+
Warning 1918 Encountered illegal value '' when converting to DECIMAL
52+
Warning 1292 Truncated incorrect DECIMAL value: 'd'
53+
Warning 1918 Encountered illegal value '' when converting to DECIMAL
54+
Warning 1292 Truncated incorrect DECIMAL value: 'f'
55+
Warning 1918 Encountered illegal value '' when converting to DECIMAL
56+
Warning 1292 Truncated incorrect DECIMAL value: 'f'
57+
Warning 1918 Encountered illegal value '' when converting to DECIMAL
58+
Warning 1292 Truncated incorrect DECIMAL value: 'g'
59+
Warning 1918 Encountered illegal value '' when converting to DECIMAL
60+
Warning 1292 Truncated incorrect DECIMAL value: 'k'
61+
Warning 1918 Encountered illegal value '' when converting to DECIMAL
62+
Warning 1292 Truncated incorrect DECIMAL value: 'm'
63+
Warning 1918 Encountered illegal value '' when converting to DECIMAL
64+
Warning 1292 Truncated incorrect DECIMAL value: 'm'
65+
Warning 1918 Encountered illegal value '' when converting to DECIMAL
66+
Warning 1292 Truncated incorrect DECIMAL value: 'm'
67+
Warning 1918 Encountered illegal value '' when converting to DECIMAL
68+
Warning 1292 Truncated incorrect DECIMAL value: 'o'
69+
Warning 1918 Encountered illegal value '' when converting to DECIMAL
70+
Warning 1292 Truncated incorrect DECIMAL value: 'q'
71+
Warning 1918 Encountered illegal value '' when converting to DECIMAL
72+
Warning 1292 Truncated incorrect DECIMAL value: 'r'
73+
Warning 1918 Encountered illegal value '' when converting to DECIMAL
74+
Warning 1292 Truncated incorrect DECIMAL value: 'u'
75+
Warning 1918 Encountered illegal value '' when converting to DECIMAL
76+
Warning 1292 Truncated incorrect DECIMAL value: 'w'
77+
Warning 1918 Encountered illegal value '' when converting to DECIMAL
78+
Warning 1292 Truncated incorrect DECIMAL value: 'x'
79+
Warning 1918 Encountered illegal value '' when converting to DECIMAL
80+
Warning 1292 Truncated incorrect DECIMAL value: 'x'
81+
Warning 1918 Encountered illegal value '' when converting to DECIMAL
82+
Warning 1292 Truncated incorrect DECIMAL value: 'y'
83+
ALTER TABLE t1 MODIFY a DOUBLE;
84+
SELECT * FROM t1,t2 WHERE a=d;
85+
a b c pk d e
86+
Warnings:
87+
Warning 1292 Truncated incorrect DOUBLE value: 'd'
88+
Warning 1292 Truncated incorrect DOUBLE value: 'd'
89+
Warning 1292 Truncated incorrect DOUBLE value: 'f'
90+
Warning 1292 Truncated incorrect DOUBLE value: 'f'
91+
Warning 1292 Truncated incorrect DOUBLE value: 'g'
92+
Warning 1292 Truncated incorrect DOUBLE value: 'k'
93+
Warning 1292 Truncated incorrect DOUBLE value: 'm'
94+
Warning 1292 Truncated incorrect DOUBLE value: 'm'
95+
Warning 1292 Truncated incorrect DOUBLE value: 'm'
96+
Warning 1292 Truncated incorrect DOUBLE value: 'o'
97+
Warning 1292 Truncated incorrect DOUBLE value: 'q'
98+
Warning 1292 Truncated incorrect DOUBLE value: 'r'
99+
Warning 1292 Truncated incorrect DOUBLE value: 'u'
100+
Warning 1292 Truncated incorrect DOUBLE value: 'w'
101+
Warning 1292 Truncated incorrect DOUBLE value: 'x'
102+
Warning 1292 Truncated incorrect DOUBLE value: 'x'
103+
Warning 1292 Truncated incorrect DOUBLE value: 'y'
104+
DROP TABLE t1,t2;
105+
#
106+
# End of 10.2 tests
107+
#

mysql-test/r/type_time.result

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,3 +1217,32 @@ DROP TABLE t1;
12171217
#
12181218
# End of 10.1 tests
12191219
#
1220+
#
1221+
# Start of 10.2 tests
1222+
#
1223+
#
1224+
# MDEV-9393 Split Copy_field::get_copy_func() into virtual methods in Field
1225+
#
1226+
CREATE TABLE t1 (a YEAR, b TIME, c YEAR);
1227+
CREATE TABLE t2 (a YEAR);
1228+
INSERT INTO t2 VALUES (0),(1999),(2000),(2030),(2050),(2070);
1229+
INSERT INTO t1 (a,b,c) SELECT a,a,a FROM t2;
1230+
Warnings:
1231+
Warning 1265 Data truncated for column 'b' at row 2
1232+
Warning 1265 Data truncated for column 'b' at row 6
1233+
ALTER TABLE t1 MODIFY c TIME;
1234+
Warnings:
1235+
Warning 1265 Data truncated for column 'c' at row 2
1236+
Warning 1265 Data truncated for column 'c' at row 6
1237+
SELECT * FROM t1;
1238+
a b c
1239+
0000 00:00:00 00:00:00
1240+
1999 00:00:00 00:00:00
1241+
2000 00:20:00 00:20:00
1242+
2030 00:20:30 00:20:30
1243+
2050 00:20:50 00:20:50
1244+
2070 00:00:00 00:00:00
1245+
DROP TABLE t1,t2;
1246+
#
1247+
# End of 10.2 tests
1248+
#

0 commit comments

Comments
 (0)