Skip to content

Commit f47a3f9

Browse files
committed
WL#7764: Make STRICT mode for transactional SEs default in 5.7
Change default SQL mode from 'NO_ENGINE_SUBSTITUTION' to 'NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES'. Introduce command line option --sql_mode to mysqlslap tool. This facilitates to emulate client load in user defined SQL mode.
1 parent 323ee9e commit f47a3f9

File tree

792 files changed

+6432
-2934
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

792 files changed

+6432
-2934
lines changed

client/mysqlslap.c

+21
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ static ulonglong auto_generate_sql_unique_query_number;
170170
static unsigned int auto_generate_sql_secondary_indexes;
171171
static ulonglong num_of_query;
172172
static ulonglong auto_generate_sql_number;
173+
static const char *sql_mode= NULL;
173174
const char *concurrency_str= NULL;
174175
static char *create_string;
175176
uint *concurrency;
@@ -258,6 +259,7 @@ static int generate_primary_key_list(MYSQL *mysql, option_string *engine_stmt);
258259
static int drop_primary_key_list(void);
259260
static int create_schema(MYSQL *mysql, const char *db, statement *stmt,
260261
option_string *engine_stmt);
262+
static void set_sql_mode(MYSQL *mysql);
261263
static int run_scheduler(stats *sptr, statement *stmts, uint concur,
262264
ulonglong limit);
263265
pthread_handler_t run_task(void *p);
@@ -367,6 +369,7 @@ int main(int argc, char **argv)
367369
exit(1);
368370
}
369371
}
372+
set_sql_mode(&mysql);
370373

371374
native_mutex_init(&counter_mutex, NULL);
372375
native_cond_init(&count_threshold);
@@ -704,6 +707,8 @@ static struct my_option my_long_options[] =
704707
0, 0, 0, 0, 0, 0},
705708
{"version", 'V', "Output version information and exit.", 0, 0, 0,
706709
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
710+
{"sql_mode", 0, "Specify sql_mode to run mysqlslap tool", &sql_mode,
711+
&sql_mode, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
707712
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
708713
};
709714

@@ -1619,6 +1624,22 @@ drop_primary_key_list(void)
16191624
return 0;
16201625
}
16211626

1627+
static void set_sql_mode(MYSQL *mysql)
1628+
{
1629+
if (sql_mode != NULL)
1630+
{
1631+
char query[512];
1632+
size_t len;
1633+
len= my_snprintf(query, HUGE_STRING_LENGTH, "SET sql_mode = `%s`", sql_mode);
1634+
1635+
if (run_query(mysql, query, len))
1636+
{
1637+
fprintf(stderr,"%s:%s\n", my_progname, mysql_error(mysql));
1638+
exit(1);
1639+
}
1640+
}
1641+
}
1642+
16221643
static int
16231644
create_schema(MYSQL *mysql, const char *db, statement *stmt,
16241645
option_string *engine_stmt)

mysql-test/extra/binlog_tests/binlog.test

+2-2
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ DROP PROCEDURE p4;
208208
reset master;
209209
create table t1 (id tinyint auto_increment primary key);
210210
set insert_id=128;
211-
insert into t1 values(null);
211+
insert ignore into t1 values(null);
212212
select * from t1;
213213
drop table t1;
214214

@@ -227,7 +227,7 @@ create table if not exists t3 like tt1;
227227

228228
--disable_warnings
229229
USE mysql;
230-
INSERT INTO user SET host='localhost', user='@#@', password=password('Just a test');
230+
INSERT IGNORE INTO user SET host='localhost', user='@#@', password=password('Just a test');
231231
UPDATE user SET password=password('Another password') WHERE host='localhost' AND user='@#@';
232232
DELETE FROM user WHERE host='localhost' AND user='@#@';
233233
--enable_warnings

mysql-test/extra/binlog_tests/binlog_mysqlbinlog_row.inc

+2
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ INSERT INTO t1 VALUES (NOW(6), NOW(6), NOW(6), NOW(6), NOW(6), NOW(6));
448448
DROP TABLE t1;
449449

450450
SET @ts='2001-01-01 00:00:00.123456';
451+
SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
451452
CREATE TABLE t1 (
452453
c85 TIMESTAMP(6), c86 TIMESTAMP(5), c87 TIMESTAMP(4),
453454
c88 TIMESTAMP(3), c89 TIMESTAMP(2), c90 TIMESTAMP(1)
@@ -459,6 +460,7 @@ DROP TABLE t1;
459460

460461
SET timestamp=1000000000;
461462
SET time_zone=default;
463+
SET sql_mode = default;
462464
#
463465
# End of FSP-enabled data types
464466
#

mysql-test/extra/binlog_tests/ctype_cp932.test

+2-2
Original file line numberDiff line numberDiff line change
@@ -436,9 +436,9 @@ drop table t2;
436436
#
437437
create table t1 (col1 varchar(1)) character set cp932;
438438
insert into t1 values ('a');
439-
insert into t1 values ('ab');
439+
insert ignore into t1 values ('ab');
440440
select * from t1;
441-
insert into t1 values ('abc');
441+
insert ignore into t1 values ('abc');
442442
select * from t1;
443443
drop table t1;
444444

mysql-test/extra/rpl_tests/rpl_auto_increment.test

+2
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ select * from t1;
106106

107107
connection master;
108108
drop table t1;
109+
SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
109110
create table t1 (a tinyint not null auto_increment primary key) engine=myisam;
110111
insert into t1 values(103);
111112
set auto_increment_increment=11;
@@ -138,6 +139,7 @@ select * from t3 order by a;
138139
connection master;
139140

140141
drop table t1,t2,t3;
142+
SET sql_mode = default;
141143
--source include/sync_slave_sql_with_master.inc
142144

143145
#

mysql-test/extra/rpl_tests/rpl_extra_col_master.test

+5-5
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,9 @@ some var char';
254254
INSERT into t4 set f1=1, f2=1, f3=1, f4='first', f7='f7: medium size blob', f10='f10:
255255
binary data';
256256
INSERT into t31 set f1=1, f2=1, f3=1, f4='first';
257-
INSERT into t31 set f1=1, f2=1, f3=2, f4='second',
257+
INSERT IGNORE into t31 set f1=1, f2=1, f3=2, f4='second',
258258
f9=2.2, f10='seven samurai', f28=222.222, f35='222';
259-
INSERT into t31 values (1, 1, 3, 'third',
259+
INSERT IGNORE into t31 values (1, 1, 3, 'third',
260260
/* f5 BIGINT, */ 333333333333333333333333,
261261
/* f6 BLOB, */ '3333333333333333333333',
262262
/* f7 DATE, */ '2007-07-18',
@@ -290,7 +290,7 @@ binary data';
290290
/*f35 VARCHAR(257),*/ 'three times three'
291291
);
292292

293-
INSERT into t31 values (1, 1, 4, 'fourth',
293+
INSERT IGNORE into t31 values (1, 1, 4, 'fourth',
294294
/* f5 BIGINT, */ 333333333333333333333333,
295295
/* f6 BLOB, */ '3333333333333333333333',
296296
/* f7 DATE, */ '2007-07-18',
@@ -409,7 +409,7 @@ connection master;
409409
update t31 set f5=555555555555555 where f3=6;
410410
update t31 set f2=2 where f3=2;
411411
update t31 set f1=NULL where f3=1;
412-
update t31 set f3=NULL, f27=NULL, f35='f35 new value' where f3=3;
412+
update ignore t31 set f3=NULL, f27=NULL, f35='f35 new value' where f3=3;
413413

414414
--echo
415415
--echo ** Delete from Master **
@@ -1036,7 +1036,7 @@ SET SQL_LOG_BIN=1;
10361036
-- connection master
10371037

10381038
-- disable_warnings
1039-
INSERT INTO t1 VALUES ();
1039+
INSERT IGNORE INTO t1 VALUES ();
10401040

10411041
# insert multi-byte chars that will take more than 255 bytes
10421042
SET @text= REPEAT(_utf8'ç', 255);

mysql-test/extra/rpl_tests/rpl_extra_col_slave.test

+2-1
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ DROP TABLE t6;
305305

306306
--echo *** Create t7 on slave ***
307307
STOP SLAVE;
308+
SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
308309
eval CREATE TABLE t7 (a INT KEY, b BLOB, c CHAR(5),
309310
d TIMESTAMP NULL DEFAULT '0000-00-00 00:00:00',
310311
e CHAR(20) DEFAULT 'Extra Column Testing')
@@ -350,7 +351,7 @@ STOP SLAVE;
350351
eval CREATE TABLE t8 (a INT KEY, b BLOB, c CHAR(5),
351352
d TIMESTAMP NULL DEFAULT '0000-00-00 00:00:00',
352353
e INT)ENGINE=$engine_type;
353-
354+
SET sql_mode = default;
354355
--echo *** Create t8 on Master ***
355356
connection master;
356357
eval CREATE TABLE t8 (a INT PRIMARY KEY, b BLOB, c CHAR(5)

mysql-test/extra/rpl_tests/rpl_not_null.test

+4
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,17 @@ PRIMARY KEY(`a`)) ENGINE=$engine DEFAULT CHARSET=LATIN1;
3838
eval CREATE TABLE t2(`a` INT, `b` DATE DEFAULT NULL,
3939
PRIMARY KEY(`a`)) ENGINE=$engine DEFAULT CHARSET=LATIN1;
4040

41+
SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
42+
4143
eval CREATE TABLE t3(`a` INT, `b` DATE DEFAULT '0000-00-00',
4244
`c` INT DEFAULT 500,
4345
PRIMARY KEY(`a`)) ENGINE=$engine DEFAULT CHARSET=LATIN1;
4446

4547
eval CREATE TABLE t4(`a` INT, `b` DATE DEFAULT '0000-00-00',
4648
PRIMARY KEY(`a`)) ENGINE=$engine DEFAULT CHARSET=LATIN1;
4749

50+
SET sql_mode = default;
51+
4852
--echo ************* EXECUTION WITH INSERTS *************
4953
connection master;
5054
INSERT INTO t1(a,b,c) VALUES (1, null, 1);

mysql-test/extra/rpl_tests/rpl_record_compare.test

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
INSERT INTO t1 ( c5, c6 ) VALUES ( 1 , 35 );
1313
INSERT INTO t1 ( c5, c6 ) VALUES ( NULL, 35 );
1414
-- disable_warnings
15-
UPDATE t1 SET c5 = 'a';
15+
UPDATE IGNORE t1 SET c5 = 'a';
1616
-- enable_warnings
1717
-- source include/sync_slave_sql_with_master.inc
1818

@@ -33,7 +33,7 @@ DROP TABLE t1;
3333
INSERT INTO t1 ( c5, c6 ) VALUES ( 1 , 35 );
3434
INSERT INTO t1 ( c5, c6 ) VALUES ( NULL, 35 );
3535
-- disable_warnings
36-
UPDATE t1 SET c5 = 'a';
36+
UPDATE IGNORE t1 SET c5 = 'a';
3737
-- enable_warnings
3838
-- source include/sync_slave_sql_with_master.inc
3939

mysql-test/extra/rpl_tests/rpl_row_basic.test

+17-17
Original file line numberDiff line numberDiff line change
@@ -637,42 +637,42 @@ eval CREATE TABLE t1 (a bit) ENGINE=$type;
637637
INSERT IGNORE INTO t1 VALUES (NULL);
638638
INSERT INTO t1 ( a ) VALUES ( 0 );
639639
UPDATE t1 SET a = 0 WHERE a = 1 LIMIT 3;
640-
INSERT INTO t1 ( a ) VALUES ( 5 );
640+
INSERT IGNORE INTO t1 ( a ) VALUES ( 5 );
641641
DELETE FROM t1 WHERE a < 2 LIMIT 4;
642642
DELETE FROM t1 WHERE a < 9 LIMIT 4;
643-
INSERT INTO t1 ( a ) VALUES ( 9 );
643+
INSERT IGNORE INTO t1 ( a ) VALUES ( 9 );
644644
UPDATE t1 SET a = 8 WHERE a = 0 LIMIT 6;
645-
INSERT INTO t1 ( a ) VALUES ( 8 );
645+
INSERT IGNORE INTO t1 ( a ) VALUES ( 8 );
646646
UPDATE t1 SET a = 0 WHERE a < 6 LIMIT 0;
647-
INSERT INTO t1 ( a ) VALUES ( 4 );
648-
INSERT INTO t1 ( a ) VALUES ( 3 );
647+
INSERT IGNORE INTO t1 ( a ) VALUES ( 4 );
648+
INSERT IGNORE INTO t1 ( a ) VALUES ( 3 );
649649
UPDATE t1 SET a = 0 WHERE a = 7 LIMIT 6;
650650
DELETE FROM t1 WHERE a = 4 LIMIT 7;
651-
UPDATE t1 SET a = 9 WHERE a < 2 LIMIT 9;
651+
UPDATE IGNORE t1 SET a = 9 WHERE a < 2 LIMIT 9;
652652
UPDATE t1 SET a = 0 WHERE a < 9 LIMIT 2;
653653
DELETE FROM t1 WHERE a < 0 LIMIT 5;
654-
INSERT INTO t1 ( a ) VALUES ( 5 );
655-
UPDATE t1 SET a = 4 WHERE a < 6 LIMIT 4;
656-
INSERT INTO t1 ( a ) VALUES ( 5 );
657-
UPDATE t1 SET a = 9 WHERE a < 5 LIMIT 8;
654+
INSERT IGNORE INTO t1 ( a ) VALUES ( 5 );
655+
UPDATE IGNORE t1 SET a = 4 WHERE a < 6 LIMIT 4;
656+
INSERT IGNORE INTO t1 ( a ) VALUES ( 5 );
657+
UPDATE IGNORE t1 SET a = 9 WHERE a < 5 LIMIT 8;
658658
DELETE FROM t1 WHERE a < 8 LIMIT 8;
659-
INSERT INTO t1 ( a ) VALUES ( 6 );
659+
INSERT IGNORE INTO t1 ( a ) VALUES ( 6 );
660660
DELETE FROM t1 WHERE a < 6 LIMIT 7;
661661
UPDATE t1 SET a = 7 WHERE a = 3 LIMIT 7;
662662
UPDATE t1 SET a = 8 WHERE a = 0 LIMIT 6;
663-
INSERT INTO t1 ( a ) VALUES ( 7 );
663+
INSERT IGNORE INTO t1 ( a ) VALUES ( 7 );
664664
DELETE FROM t1 WHERE a < 9 LIMIT 4;
665-
INSERT INTO t1 ( a ) VALUES ( 7 );
666-
INSERT INTO t1 ( a ) VALUES ( 6 );
665+
INSERT IGNORE INTO t1 ( a ) VALUES ( 7 );
666+
INSERT IGNORE INTO t1 ( a ) VALUES ( 6 );
667667
UPDATE t1 SET a = 8 WHERE a = 3 LIMIT 4;
668668
DELETE FROM t1 WHERE a = 2 LIMIT 9;
669669
DELETE FROM t1 WHERE a = 1 LIMIT 4;
670670
UPDATE t1 SET a = 4 WHERE a = 2 LIMIT 7;
671-
INSERT INTO t1 ( a ) VALUES ( 0 );
671+
INSERT IGNORE INTO t1 ( a ) VALUES ( 0 );
672672
DELETE FROM t1 WHERE a < 3 LIMIT 0;
673673
UPDATE t1 SET a = 8 WHERE a = 5 LIMIT 2;
674-
INSERT INTO t1 ( a ) VALUES ( 1 );
675-
UPDATE t1 SET a = 9 WHERE a < 5 LIMIT 3;
674+
INSERT IGNORE INTO t1 ( a ) VALUES ( 1 );
675+
UPDATE IGNORE t1 SET a = 9 WHERE a < 5 LIMIT 3;
676676
--enable_warnings
677677

678678
--source include/sync_slave_sql_with_master.inc

mysql-test/extra/rpl_tests/rpl_sp.test

+2-1
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,9 @@ select * from mysql.proc where db='mysqltest1';
291291
# Let's check a failing-in-the-middle function
292292
connection master;
293293
delete from t2;
294+
SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
294295
alter table t2 add unique (a);
295-
296+
SET sql_mode = default;
296297
drop function fn1;
297298

298299
delimiter |;
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Allow anonymous users to connect
22
disable_warnings;
33
disable_query_log;
4-
INSERT INTO mysql.user (host, user) VALUES ('localhost','');
4+
INSERT IGNORE INTO mysql.user (host, user) VALUES ('localhost','');
55
FLUSH PRIVILEGES;
66
enable_query_log;
77
enable_warnings;

mysql-test/include/commit.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ select * from t2;
267267
insert into t2 (a) values (1026);
268268
--replace_result $MYSQLTEST_VARDIR ..
269269
--error ER_DUP_ENTRY
270-
eval load data infile "../../std_data/words.dat" into table t1 (a) set a:=f2(26);
270+
eval load data infile "../../std_data/words.dat" ignore into table t1 (a) set a:=f2(26);
271271
272272
select * from t2;
273273
rollback;

mysql-test/include/common-tests.inc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1768,7 +1768,7 @@ show keys from t2;
17681768

17691769
drop table t4, t3, t2, t1;
17701770

1771-
1771+
SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
17721772
CREATE TABLE t1 (
17731773
cont_nr int(11) NOT NULL auto_increment,
17741774
ver_nr int(11) NOT NULL default '0',
@@ -1818,7 +1818,7 @@ CREATE TABLE t1 (
18181818
KEY kundentyp(kundentyp),
18191819
KEY p_nr(p_nr,suffix)
18201820
) ENGINE=MyISAM;
1821-
1821+
SET sql_mode = default;
18221822
INSERT INTO t1 VALUES (3359356,405,3359356,'Mustermann Musterfrau',52500,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1485525,2122316,'+','','N',1909160,'MobilComSuper92000D2',NULL,NULL,'MS9ND2',3,24,'MobilCom Shop Koeln',52500,NULL,'auto',20010202105916,'Mobilfunk','PP','','','');
18231823
INSERT INTO t1 VALUES (3359357,468,3359357,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1503580,2139699,'+','','P',1909171,'MobilComSuper9D1T10SFreisprech(Akquise)',NULL,NULL,'MS9NS1',327,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','','');
18241824
INSERT INTO t1 VALUES (3359358,407,3359358,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1501358,2137473,'N','','N',1909159,'MobilComSuper92000D2',NULL,NULL,'MS9ND2',325,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','','');

mysql-test/include/ctype_common.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ DROP TABLE t1;
5858
# Bug #32726: crash with cast in order by clause and cp932 charset
5959
#
6060
create table t1 (a set('a') not null);
61-
insert into t1 values (),();
61+
insert ignore into t1 values (),();
6262
select cast(a as char(1)) from t1;
6363
select a sounds like a from t1;
6464
select 1 from t1 order by cast(a as char(1));

mysql-test/include/ctype_numconv.inc

+4-4
Original file line numberDiff line numberDiff line change
@@ -729,12 +729,12 @@ select hex(concat(period_add(200902, 2)));
729729
create table t1 as select concat(period_add(200902, 2)) as c1;
730730
show create table t1;
731731
drop table t1;
732-
732+
SET sql_mode = '';
733733
select hex(concat(period_diff(200902, 200802)));
734734
create table t1 as select concat(period_add(200902, 200802)) as c1;
735735
show create table t1;
736736
drop table t1;
737-
737+
SET sql_mode = default;
738738
select hex(concat(to_days(20090224)));
739739
create table t1 as select concat(to_days(20090224)) as c1;
740740
show create table t1;
@@ -1159,7 +1159,7 @@ show create table t2;
11591159
drop table t1, t2;
11601160

11611161
create table t1 (a timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP);
1162-
insert into t1 values (0);
1162+
insert ignore into t1 values (0);
11631163
insert into t1 values (20010203040506);
11641164
insert into t1 values (19800203040506);
11651165
insert into t1 values ('2001-02-03 04:05:06');
@@ -1471,7 +1471,7 @@ drop table t1;
14711471
drop view v1;
14721472

14731473
create table t1 (a timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP);
1474-
insert into t1 values (0);
1474+
insert ignore into t1 values (0);
14751475
insert into t1 values (20010203040506);
14761476
insert into t1 values (19800203040506);
14771477
insert into t1 values ('2001-02-03 04:05:06');

0 commit comments

Comments
 (0)