Skip to content

Commit 2dcc711

Browse files
author
monty@mysql.com/narttu.mysql.fi
committed
Give warnings for unused objects
Changed error message to be compatible with old error file Added new error message for new DUP_ENTRY syntax
1 parent 693b906 commit 2dcc711

Some content is hidden

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

60 files changed

+282
-251
lines changed

BUILD/SETUP.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ if [ "x$warning_mode" != "xpedantic" ]; then
9292
# Both C and C++ warnings
9393
warnings="-Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W"
9494
warnings="$warnings -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare"
95-
warnings="$warnings -Wwrite-strings"
95+
warnings="$warnings -Wwrite-strings -Wunused-function -Wunused-label -Wunused-value -Wunused-variable -Wshadow"
9696
# C warnings
97-
c_warnings="$warnings -Wunused"
97+
c_warnings="$warnings -Wunused-parameter"
9898
# C++ warnings
9999
cxx_warnings="$warnings -Woverloaded-virtual -Wsign-promo -Wreorder"
100100
cxx_warnings="$warnings -Wctor-dtor-privacy -Wnon-virtual-dtor"

mysql-test/extra/binlog_tests/insert_select-binlog.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ insert into t1 values(2);
1313
create table t2(a int);
1414
insert into t2 values(1),(2);
1515
reset master;
16-
--error 1062
16+
--error ER_DUP_ENTRY_WITH_KEY_NAME
1717
insert into t1 select * from t2;
1818
# The above should produce an error, but still be in the binlog;
1919
# verify the binlog :
@@ -29,7 +29,7 @@ drop table t1, t2;
2929
create table t1(a int);
3030
insert into t1 values(1),(1);
3131
reset master;
32-
--error 1062
32+
--error ER_DUP_ENTRY_WITH_KEY_NAME
3333
create table t2(unique(a)) select a from t1;
3434
# The above should produce an error, *and* not appear in the binlog
3535
let $VERSION=`select version()`;

mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -273,25 +273,25 @@ set autocommit=0;
273273
CREATE TABLE t1 (a int, b int) engine=myisam;
274274
reset master;
275275
INSERT INTO t1 values (1,1),(1,2);
276-
--error 1062
276+
--error ER_DUP_ENTRY_WITH_KEY_NAME
277277
CREATE TABLE t2 (primary key (a)) engine=innodb select * from t1;
278278
# This should give warning
279279
DROP TABLE if exists t2;
280280
INSERT INTO t1 values (3,3);
281-
--error 1062
281+
--error ER_DUP_ENTRY_WITH_KEY_NAME
282282
CREATE TEMPORARY TABLE t2 (primary key (a)) engine=innodb select * from t1;
283283
ROLLBACK;
284284
# This should give warning
285285
DROP TABLE IF EXISTS t2;
286286

287287
CREATE TABLE t2 (a int, b int, primary key (a)) engine=innodb;
288288
INSERT INTO t1 VALUES (4,4);
289-
--error 1062
289+
--error ER_DUP_ENTRY_WITH_KEY_NAME
290290
CREATE TABLE IF NOT EXISTS t2 (primary key (a)) engine=innodb select * from t1;
291291
SELECT * from t2;
292292
TRUNCATE table t2;
293293
INSERT INTO t1 VALUES (5,5);
294-
--error 1062
294+
--error ER_DUP_ENTRY_WITH_KEY_NAME
295295
INSERT INTO t2 select * from t1;
296296
SELECT * FROM t2;
297297
DROP TABLE t2;
@@ -301,25 +301,25 @@ CREATE TEMPORARY TABLE t2 (a int, b int, primary key (a)) engine=innodb ;
301301
INSERT INTO t1 values (7,7);
302302
ROLLBACK;
303303
INSERT INTO t1 values (8,8);
304-
--error 1062
304+
--error ER_DUP_ENTRY_WITH_KEY_NAME
305305
CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) engine=innodb select * from t1;
306306
COMMIT;
307307
INSERT INTO t1 values (9,9);
308-
--error 1062
308+
--error ER_DUP_ENTRY_WITH_KEY_NAME
309309
CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) engine=innodb select * from t1;
310310
ROLLBACK;
311311
SELECT * from t2;
312312
TRUNCATE table t2;
313313
INSERT INTO t1 values (10,10);
314-
--error 1062
314+
--error ER_DUP_ENTRY_WITH_KEY_NAME
315315
INSERT INTO t2 select * from t1;
316316
SELECT * from t1;
317317
INSERT INTO t2 values (100,100);
318-
--error 1062
318+
--error ER_DUP_ENTRY_WITH_KEY_NAME
319319
CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) engine=innodb select * from t1;
320320
COMMIT;
321321
INSERT INTO t2 values (101,101);
322-
--error 1062
322+
--error ER_DUP_ENTRY_WITH_KEY_NAME
323323
CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) engine=innodb select * from t1;
324324
ROLLBACK;
325325
SELECT * from t2;

mysql-test/extra/rpl_tests/rpl_auto_increment.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ insert into t1 values (NULL),(5),(NULL),(NULL);
7676
insert into t1 values (500),(NULL),(502),(NULL),(NULL);
7777
select * from t1;
7878
set @@insert_id=600;
79-
--error 1062
79+
--error ER_DUP_ENTRY_WITH_KEY_NAME
8080
insert into t1 values(600),(NULL),(NULL);
8181
set @@insert_id=600;
8282
insert ignore into t1 values(600),(NULL),(NULL),(610),(NULL);
@@ -119,7 +119,7 @@ set auto_increment_increment=11;
119119
set auto_increment_offset=4;
120120
insert into t1 values(null);
121121
insert into t1 values(null);
122-
--error 1062
122+
--error ER_DUP_ENTRY_WITH_KEY_NAME
123123
insert into t1 values(null);
124124
select a, mod(a-@@auto_increment_offset,@@auto_increment_increment) from t1 order by a;
125125

mysql-test/extra/rpl_tests/rpl_foreign_key.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ SET TIMESTAMP=1000000000;
2222
CREATE TABLE t3 ( a INT UNIQUE );
2323
SET FOREIGN_KEY_CHECKS=0;
2424
# Had to add 1022 for run with ndb as ndb uses different
25-
# error and error code for 1062. Bug 16677
26-
--error 1022, 1062
25+
# error and error code for error ER_DUP_ENTRY_WITH_KEY_NAME. Bug 16677
26+
--error 1022, ER_DUP_ENTRY_WITH_KEY_NAME
2727
INSERT INTO t3 VALUES (1),(1);
2828
sync_slave_with_master;
2929

mysql-test/extra/rpl_tests/rpl_insert_id.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ SET TIMESTAMP=1000000000;
9797
CREATE TABLE t1 ( a INT UNIQUE );
9898
SET FOREIGN_KEY_CHECKS=0;
9999
# Duplicate Key Errors
100-
--error 1022, 1062
100+
--error 1022, ER_DUP_ENTRY_WITH_KEY_NAME
101101
INSERT INTO t1 VALUES (1),(1);
102102
sync_slave_with_master;
103103
connection master;

mysql-test/extra/rpl_tests/rpl_insert_id_pk.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ SET TIMESTAMP=1000000000;
8080
CREATE TABLE t1 ( a INT UNIQUE );
8181
SET FOREIGN_KEY_CHECKS=0;
8282
# Duplicate Key Errors codes
83-
--error 1022, 1062
83+
--error 1022, ER_DUP_ENTRY_WITH_KEY_NAME
8484
INSERT INTO t1 VALUES (1),(1);
8585
sync_slave_with_master;
8686
connection master;

mysql-test/extra/rpl_tests/rpl_loaddata.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ connection master;
130130
reset master;
131131
eval create table t2 (day date,id int(9),category enum('a','b','c'),name varchar(60),
132132
unique(day)) engine=$engine_type; # no transactions
133-
--error 1062
133+
--error ER_DUP_ENTRY_WITH_KEY_NAME
134134
load data infile '../std_data_ln/rpl_loaddata2.dat' into table t2 fields
135135
terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by
136136
'\n##\n' starting by '>' ignore 1 lines;
@@ -146,7 +146,7 @@ select * from t2;
146146
alter table t2 drop key day;
147147
connection master;
148148
delete from t2;
149-
--error 1062
149+
--error ER_DUP_ENTRY_WITH_KEY_NAME
150150
load data infile '../std_data_ln/rpl_loaddata2.dat' into table t2 fields
151151
terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by
152152
'\n##\n' starting by '>' ignore 1 lines;

mysql-test/extra/rpl_tests/rpl_row_basic.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,11 @@ eval CREATE TABLE t8 (a INT PRIMARY KEY, b INT UNIQUE, c INT UNIQUE) ENGINE = $t
196196

197197
# First we make sure that the constraints are correctly set.
198198
INSERT INTO t8 VALUES (99,99,99);
199-
--error 1062
199+
--error ER_DUP_ENTRY_WITH_KEY_NAME
200200
INSERT INTO t8 VALUES (99,22,33);
201-
--error 1062
201+
--error ER_DUP_ENTRY_WITH_KEY_NAME
202202
INSERT INTO t8 VALUES (11,99,33);
203-
--error 1062
203+
--error ER_DUP_ENTRY_WITH_KEY_NAME
204204
INSERT INTO t8 VALUES (11,22,99);
205205
SELECT * FROM t8 ORDER BY a;
206206

mysql-test/extra/rpl_tests/rpl_stm_EE_err2.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ set sql_log_bin=0;
1919
insert into t1 values(2);
2020
set sql_log_bin=1;
2121
save_master_pos;
22-
--error 1062
22+
--error ER_DUP_ENTRY_WITH_KEY_NAME
2323
insert into t1 values(1),(2);
2424
drop table t1;
2525
save_master_pos;

mysql-test/extra/rpl_tests/rpl_trig004.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ delimiter ;//
2929

3030
INSERT INTO test.t2 VALUES (1, 0.0);
3131
# Expect duplicate error 1022 == ndb
32-
--error 1022,1062
32+
--error 1022,error ER_DUP_ENTRY_WITH_KEY_NAME
3333
INSERT INTO test.t2 VALUES (1, 0.0);
3434

3535
#show binlog events;

mysql-test/include/mix1.inc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -393,44 +393,44 @@ DROP TABLE t1;
393393

394394
CREATE TABLE t1 (a int, b int);
395395
insert into t1 values (1,1),(1,2);
396-
--error 1062
396+
--error ER_DUP_ENTRY_WITH_KEY_NAME
397397
CREATE TABLE t2 (primary key (a)) select * from t1;
398398
# This should give warning
399399
drop table if exists t2;
400-
--error 1062
400+
--error ER_DUP_ENTRY_WITH_KEY_NAME
401401
CREATE TEMPORARY TABLE t2 (primary key (a)) select * from t1;
402402
# This should give warning
403403
drop table if exists t2;
404404
CREATE TABLE t2 (a int, b int, primary key (a));
405405
BEGIN;
406406
INSERT INTO t2 values(100,100);
407-
--error 1062
407+
--error ER_DUP_ENTRY_WITH_KEY_NAME
408408
CREATE TABLE IF NOT EXISTS t2 (primary key (a)) select * from t1;
409409
SELECT * from t2;
410410
ROLLBACK;
411411
SELECT * from t2;
412412
TRUNCATE table t2;
413-
--error 1062
413+
--error ER_DUP_ENTRY_WITH_KEY_NAME
414414
INSERT INTO t2 select * from t1;
415415
SELECT * from t2;
416416
drop table t2;
417417

418418
CREATE TEMPORARY TABLE t2 (a int, b int, primary key (a));
419419
BEGIN;
420420
INSERT INTO t2 values(100,100);
421-
--error 1062
421+
--error ER_DUP_ENTRY_WITH_KEY_NAME
422422
CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) select * from t1;
423423
SELECT * from t2;
424424
COMMIT;
425425
BEGIN;
426426
INSERT INTO t2 values(101,101);
427-
--error 1062
427+
--error ER_DUP_ENTRY_WITH_KEY_NAME
428428
CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) select * from t1;
429429
SELECT * from t2;
430430
ROLLBACK;
431431
SELECT * from t2;
432432
TRUNCATE table t2;
433-
--error 1062
433+
--error ER_DUP_ENTRY_WITH_KEY_NAME
434434
INSERT INTO t2 select * from t1;
435435
SELECT * from t2;
436436
drop table t1,t2;

mysql-test/include/mix2.inc

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ INSERT INTO t1 VALUES (1,0,0),(3,1,1),(4,1,1),(8,2,2),(9,2,2),(17,3,2),(22,4,2),
9696
update t1 set parent_id=parent_id+100;
9797
select * from t1 where parent_id=102;
9898
update t1 set id=id+1000;
99-
-- error 1062,1022
99+
-- error ER_DUP_ENTRY_WITH_KEY_NAME,1022
100100
update t1 set id=1024 where id=1009;
101101
select * from t1;
102102
update ignore t1 set id=id+1; # This will change all rows
@@ -179,13 +179,13 @@ commit;
179179
select n, "after commit" from t1;
180180
commit;
181181
insert into t1 values (5);
182-
-- error 1062
182+
-- error ER_DUP_ENTRY_WITH_KEY_NAME
183183
insert into t1 values (4);
184184
commit;
185185
select n, "after commit" from t1;
186186
set autocommit=1;
187187
insert into t1 values (6);
188-
-- error 1062
188+
-- error ER_DUP_ENTRY_WITH_KEY_NAME
189189
insert into t1 values (4);
190190
select n from t1;
191191
set autocommit=0;
@@ -259,7 +259,7 @@ drop table t1;
259259

260260
eval CREATE TABLE t1 (id char(8) not null primary key, val int not null) engine=$engine_type;
261261
insert into t1 values ('pippo', 12);
262-
-- error 1062
262+
-- error ER_DUP_ENTRY_WITH_KEY_NAME
263263
insert into t1 values ('pippo', 12); # Gives error
264264
delete from t1;
265265
delete from t1 where id = 'pippo';
@@ -390,9 +390,9 @@ eval CREATE TABLE t1 (
390390

391391
insert into t1 (ggid,passwd) values ('test1','xxx');
392392
insert into t1 (ggid,passwd) values ('test2','yyy');
393-
-- error 1062
393+
-- error ER_DUP_ENTRY_WITH_KEY_NAME
394394
insert into t1 (ggid,passwd) values ('test2','this will fail');
395-
-- error 1062
395+
-- error ER_DUP_ENTRY_WITH_KEY_NAME
396396
insert into t1 (ggid,id) values ('this will fail',1);
397397

398398
select * from t1 where ggid='test1';
@@ -401,7 +401,7 @@ select * from t1 where id=2;
401401

402402
replace into t1 (ggid,id) values ('this will work',1);
403403
replace into t1 (ggid,passwd) values ('test2','this will work');
404-
-- error 1062
404+
-- error ER_DUP_ENTRY_WITH_KEY_NAME
405405
update t1 set id=100,ggid='test2' where id=1;
406406
select * from t1;
407407
select * from t1 where id=1;
@@ -572,7 +572,7 @@ drop table t1;
572572
eval create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) engine=$engine_type;
573573
insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');
574574
LOCK TABLES t1 WRITE;
575-
--error 1062
575+
--error ER_DUP_ENTRY_WITH_KEY_NAME
576576
insert into t1 values (99,1,2,'D'),(1,1,2,'D');
577577
select id from t1;
578578
select id from t1;
@@ -583,7 +583,7 @@ eval create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 c
583583
insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');
584584
LOCK TABLES t1 WRITE;
585585
begin;
586-
--error 1062
586+
--error ER_DUP_ENTRY_WITH_KEY_NAME
587587
insert into t1 values (99,1,2,'D'),(1,1,2,'D');
588588
select id from t1;
589589
insert ignore into t1 values (100,1,2,'D'),(1,1,99,'D');
@@ -1513,7 +1513,7 @@ eval create table t1 (rowid int not null auto_increment, val int not null,primar
15131513
key (rowid), unique(val)) engine=$engine_type;
15141514
replace into t1 (val) values ('1'),('2');
15151515
replace into t1 (val) values ('1'),('2');
1516-
--error 1062
1516+
--error ER_DUP_ENTRY_WITH_KEY_NAME
15171517
insert into t1 (val) values ('1'),('2');
15181518
select * from t1;
15191519
drop table t1;
@@ -1528,7 +1528,7 @@ eval create table t1 (a int not null auto_increment primary key, val int) engine
15281528
insert into t1 (val) values (1);
15291529
update t1 set a=2 where a=1;
15301530
# We should get the following error because InnoDB does not update the counter
1531-
--error 1062
1531+
--error ER_DUP_ENTRY_WITH_KEY_NAME
15321532
insert into t1 (val) values (1);
15331533
select * from t1;
15341534
drop table t1;
@@ -2027,13 +2027,13 @@ eval create table t3 (s1 varchar(2) binary,primary key (s1)) engine=$engine_type
20272027
eval create table t4 (s1 char(2) binary,primary key (s1)) engine=$engine_type;
20282028

20292029
insert into t1 values (0x41),(0x4120),(0x4100);
2030-
-- error 1062
2030+
-- error ER_DUP_ENTRY_WITH_KEY_NAME
20312031
insert into t2 values (0x41),(0x4120),(0x4100);
20322032
insert into t2 values (0x41),(0x4120);
2033-
-- error 1062
2033+
-- error ER_DUP_ENTRY_WITH_KEY_NAME
20342034
insert into t3 values (0x41),(0x4120),(0x4100);
20352035
insert into t3 values (0x41),(0x4100);
2036-
-- error 1062
2036+
-- error ER_DUP_ENTRY_WITH_KEY_NAME
20372037
insert into t4 values (0x41),(0x4120),(0x4100);
20382038
insert into t4 values (0x41),(0x4100);
20392039
select hex(s1) from t1;

mysql-test/include/ps_modify.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ prepare stmt1 from 'insert into t1 values(6, ? )';
193193
execute stmt1 using @arg00;
194194
select a,b from t1 where b = @arg00;
195195
# the second insert fails, because the first column is primary key
196-
--error 1062
196+
--error ER_DUP_ENTRY_WITH_KEY_NAME
197197
execute stmt1 using @arg00;
198198
set @arg00=NULL ;
199199
prepare stmt1 from 'insert into t1 values(0, ? )';
@@ -272,7 +272,7 @@ execute stmt1 using @arg00, @arg01;
272272
select * from t1 order by a;
273273
set @arg00=81 ;
274274
set @arg01=1 ;
275-
--error 1062
275+
--error ER_DUP_ENTRY_WITH_KEY_NAME
276276
execute stmt1 using @arg00, @arg01;
277277

278278
## insert, autoincrement column and ' SELECT LAST_INSERT_ID() '

mysql-test/include/query_cache.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ delete from t3 where t1_id = 1 and t2_id = 1;
9090
select t1.* from t1, t2, t3 where t3.state & 1 = 0 and t3.t1_id = t1.id and t3.t2_id = t2.id and t1.id = 1 order by t1.a asc;
9191
begin;
9292
insert into t3 VALUES ( NULL, 1, 1, 2 );
93-
-- error 1062
93+
-- error ER_DUP_ENTRY_WITH_KEY_NAME
9494
insert into t3 VALUES ( NULL, 1, 1, 2 );
9595
commit;
9696
select t1.* from t1, t2, t3 where t3.state & 1 = 0 and t3.t1_id = t1.id and t3.t2_id = t2.id and t1.id = 1 order by t1.a asc;

0 commit comments

Comments
 (0)