summaryrefslogtreecommitdiffstats
path: root/mysql-test/main/ps_innodb.test
blob: 6f56af352718d5f11871367b47b62f58212aab75 (plain)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
--source include/have_innodb.inc

--echo #
--echo # MDEV-17042: prepared statement does not return error with
--echo # SQL_MODE STRICT_TRANS_TABLES. (Part 2)
--echo #

set @save_sql_mode=@@sql_mode;
set sql_mode='STRICT_TRANS_TABLES';

CREATE TABLE t1 (id int, count int) engine=innodb;
insert into t1 values (1,1),(0,2);
--error ER_TRUNCATED_WRONG_VALUE
update t1 set count = count + 1 where id = '1bad';

prepare stmt from "update t1 set count = count + 1 where id = '1bad'";
--error ER_TRUNCATED_WRONG_VALUE
execute stmt;
deallocate prepare stmt;

prepare stmt from 'update t1 set count = count + 1 where id = ?';
set @a = '1bad';
--error ER_TRUNCATED_WRONG_VALUE
execute stmt using @a;
deallocate prepare stmt;
drop table t1;

CREATE TABLE t1 (id decimal(10,5), count int) engine=innodb;
insert into t1 values (1,1),(0,2);
--error ER_TRUNCATED_WRONG_VALUE
update t1 set count = count + 1 where id = '1bad';

prepare stmt from "update t1 set count = count + 1 where id = '1bad'";
--error ER_TRUNCATED_WRONG_VALUE
execute stmt;
deallocate prepare stmt;

prepare stmt from 'update t1 set count = count + 1 where id = ?';
set @a = '1bad';
--error ER_TRUNCATED_WRONG_VALUE
execute stmt using @a;
deallocate prepare stmt;
drop table t1;

CREATE TABLE t1 (id double, count int) engine=innodb;
insert into t1 values (1,1),(0,2);
--error ER_TRUNCATED_WRONG_VALUE
update t1 set count = count + 1 where id = '1bad';

prepare stmt from "update t1 set count = count + 1 where id = '1bad'";
--error ER_TRUNCATED_WRONG_VALUE
execute stmt;
deallocate prepare stmt;

prepare stmt from 'update t1 set count = count + 1 where id = ?';
set @a = '1bad';
--error ER_TRUNCATED_WRONG_VALUE
execute stmt using @a;
deallocate prepare stmt;
drop table t1;

CREATE TABLE t1 (id date, count int) engine=innodb;
insert into t1 values ("2019-06-11",1),("2019-06-12",2);
--error ER_TRUNCATED_WRONG_VALUE
update t1 set count = count + 1 where id = '1bad';

prepare stmt from "update t1 set count = count + 1 where id = '1bad'";
--error ER_TRUNCATED_WRONG_VALUE
execute stmt;
deallocate prepare stmt;

prepare stmt from 'update t1 set count = count + 1 where id = ?';
set @a = '1bad';
--error ER_TRUNCATED_WRONG_VALUE
execute stmt using @a;
deallocate prepare stmt;
drop table t1;
set sql_mode=@save_sql_mode;

--echo # End of 5.5 tests