diff --git a/BUILD/SETUP.sh b/BUILD/SETUP.sh index 1f62ffe7c26..274676e0ead 100755 --- a/BUILD/SETUP.sh +++ b/BUILD/SETUP.sh @@ -92,9 +92,9 @@ if [ "x$warning_mode" != "xpedantic" ]; then # Both C and C++ warnings warnings="-Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W" warnings="$warnings -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare" - warnings="$warnings -Wwrite-strings" + warnings="$warnings -Wwrite-strings -Wunused-function -Wunused-label -Wunused-value -Wunused-variable" # C warnings - c_warnings="$warnings -Wunused" + c_warnings="$warnings -Wunused-parameter" # C++ warnings cxx_warnings="$warnings -Woverloaded-virtual -Wsign-promo -Wreorder" cxx_warnings="$warnings -Wctor-dtor-privacy -Wnon-virtual-dtor" diff --git a/configure.in b/configure.in index 17a9714c16c..0665362085c 100644 --- a/configure.in +++ b/configure.in @@ -7,7 +7,7 @@ AC_INIT(sql/mysqld.cc) AC_CANONICAL_SYSTEM # The Docs Makefile.am parses this line! # remember to also update version.c in ndb -AM_INIT_AUTOMAKE(mysql, 5.1.15-beta) +AM_INIT_AUTOMAKE(mysql, 5.1.16-beta) AM_CONFIG_HEADER(config.h) PROTOCOL_VERSION=10 diff --git a/include/thr_lock.h b/include/thr_lock.h index 363babeaa63..99bb7545006 100644 --- a/include/thr_lock.h +++ b/include/thr_lock.h @@ -121,6 +121,7 @@ typedef struct st_thr_lock { void (*get_status)(void*, int); /* When one gets a lock */ void (*copy_status)(void*,void*); void (*update_status)(void*); /* Before release of write */ + void (*restore_status)(void*); /* Before release of read */ my_bool (*check_status)(void *); } THR_LOCK; diff --git a/mysql-test/extra/binlog_tests/insert_select-binlog.test b/mysql-test/extra/binlog_tests/insert_select-binlog.test index 268e9280b32..07da4a1907f 100644 --- a/mysql-test/extra/binlog_tests/insert_select-binlog.test +++ b/mysql-test/extra/binlog_tests/insert_select-binlog.test @@ -13,7 +13,7 @@ insert into t1 values(2); create table t2(a int); insert into t2 values(1),(2); reset master; ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 select * from t2; # The above should produce an error, but still be in the binlog; # verify the binlog : @@ -29,7 +29,7 @@ drop table t1, t2; create table t1(a int); insert into t1 values(1),(1); reset master; ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME create table t2(unique(a)) select a from t1; # The above should produce an error, *and* not appear in the binlog let $VERSION=`select version()`; diff --git a/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test b/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test index bdc49573ae5..bb4194bc7a7 100644 --- a/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test +++ b/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test @@ -273,12 +273,12 @@ set autocommit=0; CREATE TABLE t1 (a int, b int) engine=myisam; reset master; INSERT INTO t1 values (1,1),(1,2); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME CREATE TABLE t2 (primary key (a)) engine=innodb select * from t1; # This should give warning DROP TABLE if exists t2; INSERT INTO t1 values (3,3); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME CREATE TEMPORARY TABLE t2 (primary key (a)) engine=innodb select * from t1; ROLLBACK; # This should give warning @@ -286,12 +286,12 @@ DROP TABLE IF EXISTS t2; CREATE TABLE t2 (a int, b int, primary key (a)) engine=innodb; INSERT INTO t1 VALUES (4,4); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME CREATE TABLE IF NOT EXISTS t2 (primary key (a)) engine=innodb select * from t1; SELECT * from t2; TRUNCATE table t2; INSERT INTO t1 VALUES (5,5); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME INSERT INTO t2 select * from t1; SELECT * FROM t2; DROP TABLE t2; @@ -301,25 +301,25 @@ CREATE TEMPORARY TABLE t2 (a int, b int, primary key (a)) engine=innodb ; INSERT INTO t1 values (7,7); ROLLBACK; INSERT INTO t1 values (8,8); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) engine=innodb select * from t1; COMMIT; INSERT INTO t1 values (9,9); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) engine=innodb select * from t1; ROLLBACK; SELECT * from t2; TRUNCATE table t2; INSERT INTO t1 values (10,10); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME INSERT INTO t2 select * from t1; SELECT * from t1; INSERT INTO t2 values (100,100); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) engine=innodb select * from t1; COMMIT; INSERT INTO t2 values (101,101); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) engine=innodb select * from t1; ROLLBACK; SELECT * from t2; diff --git a/mysql-test/extra/rpl_tests/rpl_auto_increment.test b/mysql-test/extra/rpl_tests/rpl_auto_increment.test index dbae317e8ab..410aeecb7ee 100644 --- a/mysql-test/extra/rpl_tests/rpl_auto_increment.test +++ b/mysql-test/extra/rpl_tests/rpl_auto_increment.test @@ -76,7 +76,7 @@ insert into t1 values (NULL),(5),(NULL),(NULL); insert into t1 values (500),(NULL),(502),(NULL),(NULL); select * from t1; set @@insert_id=600; ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values(600),(NULL),(NULL); set @@insert_id=600; insert ignore into t1 values(600),(NULL),(NULL),(610),(NULL); @@ -119,7 +119,7 @@ set auto_increment_increment=11; set auto_increment_offset=4; insert into t1 values(null); insert into t1 values(null); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values(null); select a, mod(a-@@auto_increment_offset,@@auto_increment_increment) from t1 order by a; diff --git a/mysql-test/extra/rpl_tests/rpl_foreign_key.test b/mysql-test/extra/rpl_tests/rpl_foreign_key.test index 0f4cd856db6..8558650fd04 100644 --- a/mysql-test/extra/rpl_tests/rpl_foreign_key.test +++ b/mysql-test/extra/rpl_tests/rpl_foreign_key.test @@ -22,8 +22,8 @@ SET TIMESTAMP=1000000000; CREATE TABLE t3 ( a INT UNIQUE ); SET FOREIGN_KEY_CHECKS=0; # Had to add 1022 for run with ndb as ndb uses different -# error and error code for 1062. Bug 16677 ---error 1022, 1062 +# error and error code for error ER_DUP_ENTRY_WITH_KEY_NAME. Bug 16677 +--error 1022, ER_DUP_ENTRY_WITH_KEY_NAME INSERT INTO t3 VALUES (1),(1); sync_slave_with_master; diff --git a/mysql-test/extra/rpl_tests/rpl_insert_id.test b/mysql-test/extra/rpl_tests/rpl_insert_id.test index 33194270d37..0b07216cf11 100644 --- a/mysql-test/extra/rpl_tests/rpl_insert_id.test +++ b/mysql-test/extra/rpl_tests/rpl_insert_id.test @@ -97,7 +97,7 @@ SET TIMESTAMP=1000000000; CREATE TABLE t1 ( a INT UNIQUE ); SET FOREIGN_KEY_CHECKS=0; # Duplicate Key Errors ---error 1022, 1062 +--error 1022, ER_DUP_ENTRY_WITH_KEY_NAME INSERT INTO t1 VALUES (1),(1); sync_slave_with_master; connection master; diff --git a/mysql-test/extra/rpl_tests/rpl_insert_id_pk.test b/mysql-test/extra/rpl_tests/rpl_insert_id_pk.test index 6feafc5a9a7..5a646bd49e3 100644 --- a/mysql-test/extra/rpl_tests/rpl_insert_id_pk.test +++ b/mysql-test/extra/rpl_tests/rpl_insert_id_pk.test @@ -80,7 +80,7 @@ SET TIMESTAMP=1000000000; CREATE TABLE t1 ( a INT UNIQUE ); SET FOREIGN_KEY_CHECKS=0; # Duplicate Key Errors codes ---error 1022, 1062 +--error 1022, ER_DUP_ENTRY_WITH_KEY_NAME INSERT INTO t1 VALUES (1),(1); sync_slave_with_master; connection master; diff --git a/mysql-test/extra/rpl_tests/rpl_loaddata.test b/mysql-test/extra/rpl_tests/rpl_loaddata.test index e58908ec7e9..111b66ff7fe 100644 --- a/mysql-test/extra/rpl_tests/rpl_loaddata.test +++ b/mysql-test/extra/rpl_tests/rpl_loaddata.test @@ -130,7 +130,7 @@ connection master; reset master; eval create table t2 (day date,id int(9),category enum('a','b','c'),name varchar(60), unique(day)) engine=$engine_type; # no transactions ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME load data infile '../std_data_ln/rpl_loaddata2.dat' into table t2 fields terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by '\n##\n' starting by '>' ignore 1 lines; @@ -146,7 +146,7 @@ select * from t2; alter table t2 drop key day; connection master; delete from t2; ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME load data infile '../std_data_ln/rpl_loaddata2.dat' into table t2 fields terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by '\n##\n' starting by '>' ignore 1 lines; diff --git a/mysql-test/extra/rpl_tests/rpl_row_basic.test b/mysql-test/extra/rpl_tests/rpl_row_basic.test index c2001091b45..9ba06096faf 100644 --- a/mysql-test/extra/rpl_tests/rpl_row_basic.test +++ b/mysql-test/extra/rpl_tests/rpl_row_basic.test @@ -195,11 +195,11 @@ eval CREATE TABLE t8 (a INT PRIMARY KEY, b INT UNIQUE, c INT UNIQUE) ENGINE = $t # First we make sure that the constraints are correctly set. INSERT INTO t8 VALUES (99,99,99); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME INSERT INTO t8 VALUES (99,22,33); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME INSERT INTO t8 VALUES (11,99,33); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME INSERT INTO t8 VALUES (11,22,99); SELECT * FROM t8 ORDER BY a; diff --git a/mysql-test/extra/rpl_tests/rpl_stm_EE_err2.test b/mysql-test/extra/rpl_tests/rpl_stm_EE_err2.test index 6abd2ae844e..654cb523f74 100644 --- a/mysql-test/extra/rpl_tests/rpl_stm_EE_err2.test +++ b/mysql-test/extra/rpl_tests/rpl_stm_EE_err2.test @@ -19,7 +19,7 @@ set sql_log_bin=0; insert into t1 values(2); set sql_log_bin=1; save_master_pos; ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values(1),(2); drop table t1; save_master_pos; diff --git a/mysql-test/extra/rpl_tests/rpl_trig004.test b/mysql-test/extra/rpl_tests/rpl_trig004.test index 0206241eae9..5144943bc64 100644 --- a/mysql-test/extra/rpl_tests/rpl_trig004.test +++ b/mysql-test/extra/rpl_tests/rpl_trig004.test @@ -29,7 +29,7 @@ delimiter ;// INSERT INTO test.t2 VALUES (1, 0.0); # Expect duplicate error 1022 == ndb ---error 1022,1062 +--error 1022, ER_DUP_ENTRY_WITH_KEY_NAME INSERT INTO test.t2 VALUES (1, 0.0); #show binlog events; diff --git a/mysql-test/include/mix1.inc b/mysql-test/include/mix1.inc index 9619db2203c..4bd93220c1e 100644 --- a/mysql-test/include/mix1.inc +++ b/mysql-test/include/mix1.inc @@ -393,24 +393,24 @@ DROP TABLE t1; CREATE TABLE t1 (a int, b int); insert into t1 values (1,1),(1,2); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME CREATE TABLE t2 (primary key (a)) select * from t1; # This should give warning drop table if exists t2; ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME CREATE TEMPORARY TABLE t2 (primary key (a)) select * from t1; # This should give warning drop table if exists t2; CREATE TABLE t2 (a int, b int, primary key (a)); BEGIN; INSERT INTO t2 values(100,100); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME CREATE TABLE IF NOT EXISTS t2 (primary key (a)) select * from t1; SELECT * from t2; ROLLBACK; SELECT * from t2; TRUNCATE table t2; ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME INSERT INTO t2 select * from t1; SELECT * from t2; drop table t2; @@ -418,19 +418,19 @@ drop table t2; CREATE TEMPORARY TABLE t2 (a int, b int, primary key (a)); BEGIN; INSERT INTO t2 values(100,100); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) select * from t1; SELECT * from t2; COMMIT; BEGIN; INSERT INTO t2 values(101,101); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) select * from t1; SELECT * from t2; ROLLBACK; SELECT * from t2; TRUNCATE table t2; ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME INSERT INTO t2 select * from t1; SELECT * from t2; drop table t1,t2; diff --git a/mysql-test/include/mix2.inc b/mysql-test/include/mix2.inc index 8c11f094907..9bbf2dc0be4 100644 --- a/mysql-test/include/mix2.inc +++ b/mysql-test/include/mix2.inc @@ -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), update t1 set parent_id=parent_id+100; select * from t1 where parent_id=102; update t1 set id=id+1000; --- error 1062,1022 +-- error ER_DUP_ENTRY_WITH_KEY_NAME,1022 update t1 set id=1024 where id=1009; select * from t1; update ignore t1 set id=id+1; # This will change all rows @@ -179,13 +179,13 @@ commit; select n, "after commit" from t1; commit; insert into t1 values (5); --- error 1062 +-- error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values (4); commit; select n, "after commit" from t1; set autocommit=1; insert into t1 values (6); --- error 1062 +-- error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values (4); select n from t1; set autocommit=0; @@ -259,7 +259,7 @@ drop table t1; eval CREATE TABLE t1 (id char(8) not null primary key, val int not null) engine=$engine_type; insert into t1 values ('pippo', 12); --- error 1062 +-- error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('pippo', 12); # Gives error delete from t1; delete from t1 where id = 'pippo'; @@ -390,9 +390,9 @@ eval CREATE TABLE t1 ( insert into t1 (ggid,passwd) values ('test1','xxx'); insert into t1 (ggid,passwd) values ('test2','yyy'); --- error 1062 +-- error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 (ggid,passwd) values ('test2','this will fail'); --- error 1062 +-- error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 (ggid,id) values ('this will fail',1); select * from t1 where ggid='test1'; @@ -401,7 +401,7 @@ select * from t1 where id=2; replace into t1 (ggid,id) values ('this will work',1); replace into t1 (ggid,passwd) values ('test2','this will work'); --- error 1062 +-- error ER_DUP_ENTRY_WITH_KEY_NAME update t1 set id=100,ggid='test2' where id=1; select * from t1; select * from t1 where id=1; @@ -572,7 +572,7 @@ drop table t1; 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; insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL'); LOCK TABLES t1 WRITE; ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values (99,1,2,'D'),(1,1,2,'D'); select id from t1; 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 insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL'); LOCK TABLES t1 WRITE; begin; ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values (99,1,2,'D'),(1,1,2,'D'); select id from t1; 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 key (rowid), unique(val)) engine=$engine_type; replace into t1 (val) values ('1'),('2'); replace into t1 (val) values ('1'),('2'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 (val) values ('1'),('2'); select * from t1; drop table t1; @@ -1528,7 +1528,7 @@ eval create table t1 (a int not null auto_increment primary key, val int) engine insert into t1 (val) values (1); update t1 set a=2 where a=1; # We should get the following error because InnoDB does not update the counter ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 (val) values (1); select * from t1; drop table t1; @@ -2027,13 +2027,13 @@ eval create table t3 (s1 varchar(2) binary,primary key (s1)) engine=$engine_type eval create table t4 (s1 char(2) binary,primary key (s1)) engine=$engine_type; insert into t1 values (0x41),(0x4120),(0x4100); --- error 1062 +-- error ER_DUP_ENTRY_WITH_KEY_NAME insert into t2 values (0x41),(0x4120),(0x4100); insert into t2 values (0x41),(0x4120); --- error 1062 +-- error ER_DUP_ENTRY_WITH_KEY_NAME insert into t3 values (0x41),(0x4120),(0x4100); insert into t3 values (0x41),(0x4100); --- error 1062 +-- error ER_DUP_ENTRY_WITH_KEY_NAME insert into t4 values (0x41),(0x4120),(0x4100); insert into t4 values (0x41),(0x4100); select hex(s1) from t1; diff --git a/mysql-test/include/ps_modify.inc b/mysql-test/include/ps_modify.inc index 633c317f4b2..9e38671263f 100644 --- a/mysql-test/include/ps_modify.inc +++ b/mysql-test/include/ps_modify.inc @@ -193,7 +193,7 @@ prepare stmt1 from 'insert into t1 values(6, ? )'; execute stmt1 using @arg00; select a,b from t1 where b = @arg00; # the second insert fails, because the first column is primary key ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME execute stmt1 using @arg00; set @arg00=NULL ; prepare stmt1 from 'insert into t1 values(0, ? )'; @@ -272,7 +272,7 @@ execute stmt1 using @arg00, @arg01; select * from t1 order by a; set @arg00=81 ; set @arg01=1 ; ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME execute stmt1 using @arg00, @arg01; ## insert, autoincrement column and ' SELECT LAST_INSERT_ID() ' diff --git a/mysql-test/include/query_cache.inc b/mysql-test/include/query_cache.inc index 0cf2f7cdfe9..b54976886bd 100644 --- a/mysql-test/include/query_cache.inc +++ b/mysql-test/include/query_cache.inc @@ -90,7 +90,7 @@ delete from t3 where t1_id = 1 and t2_id = 1; 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; begin; insert into t3 VALUES ( NULL, 1, 1, 2 ); --- error 1062 +-- error ER_DUP_ENTRY_WITH_KEY_NAME insert into t3 VALUES ( NULL, 1, 1, 2 ); commit; 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; diff --git a/mysql-test/include/varchar.inc b/mysql-test/include/varchar.inc index 70b563e871c..2d683a15030 100644 --- a/mysql-test/include/varchar.inc +++ b/mysql-test/include/varchar.inc @@ -81,7 +81,7 @@ explain select count(*) from t1 where v between 'a' and 'a '; --replace_column 9 # explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n'; ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME alter table t1 add unique(v); alter table t1 add key(v); select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a'; @@ -179,17 +179,17 @@ drop table t1; create table t1 (a char(10), unique (a)); insert into t1 values ('a '); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('a '); alter table t1 modify a varchar(10); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('a '),('a '),('a '),('a '); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('a '); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('a '); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('a '); update t1 set a='a ' where a like 'a%'; select concat(a,'.') from t1; diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index 7bef6c2efba..c2bbb01af8c 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -285,7 +285,7 @@ ERROR 23000: Duplicate entry '3' for key 'PRIMARY' show warnings; Level Code Message Note 1050 Table 't1' already exists -Error 1062 Duplicate entry '3' for key 'PRIMARY' +Error 1582 Duplicate entry '3' for key 'PRIMARY' show status like "Opened_tables"; Variable_name Value Opened_tables 2 diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index 5a506a010df..8560efd4ee1 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -922,6 +922,27 @@ SET @@myisam_repair_threads=1; SHOW VARIABLES LIKE 'myisam_repair%'; Variable_name Value myisam_repair_threads 1 +CREATE TABLE t1(a VARCHAR(16)); +INSERT INTO t1 VALUES('aaaaaaaa'),(NULL); +UPDATE t1 AS ta1, t1 AS ta2 SET ta1.a='aaaaaaaaaaaaaaaa'; +SELECT * FROM t1; +a +aaaaaaaaaaaaaaaa +aaaaaaaaaaaaaaaa +DROP TABLE t1; +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES(1),(2); +UPDATE t1,t1 AS t2 SET t1.a=t1.a+2 WHERE t1.a=t2.a-1; +SELECT * FROM t1 ORDER BY a; +a +2 +3 +DROP TABLE t1; +CREATE TABLE t1 (c1 TEXT) AVG_ROW_LENGTH=70100 MAX_ROWS=4100100100; +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 MyISAM 10 Dynamic X X X 72057594037927935 X X X X X X latin1_swedish_ci X max_rows=4100100100 avg_row_length=70100 +DROP TABLE t1; End of 4.1 tests set storage_engine=MyISAM; drop table if exists t1,t2,t3; diff --git a/mysql-test/r/rpl_sp.result b/mysql-test/r/rpl_sp.result index 34ff77996be..ea07a86d009 100644 --- a/mysql-test/r/rpl_sp.result +++ b/mysql-test/r/rpl_sp.result @@ -107,7 +107,7 @@ call foo4(); ERROR 23000: Duplicate entry '20' for key 'a' show warnings; Level Code Message -Error 1062 Duplicate entry '20' for key 'a' +Error 1582 Duplicate entry '20' for key 'a' select * from t2; a 20 @@ -241,7 +241,7 @@ return 10; end| do fn1(100); Warnings: -Error 1062 Duplicate entry '100' for key 'a' +Error 1582 Duplicate entry '100' for key 'a' select fn1(20); ERROR 23000: Duplicate entry '20' for key 'a' select * from t2; diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index c2d86ebc42d..51ab8d5e139 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -1493,10 +1493,10 @@ insert into t3 (a) values (1)| create procedure h_ee() deterministic begin -declare continue handler for 1062 -- ER_DUP_ENTRY +declare continue handler for 1582 -- ER_DUP_ENTRY_WITH_KEY_NAME select 'Outer (bad)' as 'h_ee'; begin -declare continue handler for 1062 -- ER_DUP_ENTRY +declare continue handler for 1582 -- ER_DUP_ENTRY_WITH_KEY_NAME select 'Inner (good)' as 'h_ee'; insert into t3 values (1); end; @@ -1504,7 +1504,7 @@ end| create procedure h_es() deterministic begin -declare continue handler for 1062 -- ER_DUP_ENTRY +declare continue handler for 1582 -- ER_DUP_ENTRY_WITH_KEY_NAME select 'Outer (good)' as 'h_es'; begin -- integrity constraint violation @@ -1541,7 +1541,7 @@ end| create procedure h_ex() deterministic begin -declare continue handler for 1062 -- ER_DUP_ENTRY +declare continue handler for 1582 -- ER_DUP_ENTRY_WITH_KEY_NAME select 'Outer (good)' as 'h_ex'; begin declare continue handler for sqlexception @@ -1556,7 +1556,7 @@ begin declare continue handler for sqlstate '23000' select 'Outer (bad)' as 'h_se'; begin -declare continue handler for 1062 -- ER_DUP_ENTRY +declare continue handler for 1582 -- ER_DUP_ENTRY_WITH_KEY_NAME select 'Inner (good)' as 'h_se'; insert into t3 values (1); end; @@ -1696,7 +1696,7 @@ begin declare continue handler for sqlexception select 'Outer (bad)' as 'h_xe'; begin -declare continue handler for 1062 -- ER_DUP_ENTRY +declare continue handler for 1582 -- ER_DUP_ENTRY_WITH_KEY_NAME select 'Inner (good)' as 'h_xe'; insert into t3 values (1); end; @@ -4701,10 +4701,10 @@ insert into t3 values (1)| create procedure bug15011() deterministic begin -declare continue handler for 1062 +declare continue handler for 1582 select 'Outer' as 'Handler'; begin -declare continue handler for 1062 +declare continue handler for 1582 select 'Inner' as 'Handler'; insert into t3 values (1); end; diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index b338ba12685..1b20b4b223c 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -2675,19 +2675,21 @@ lName varchar(25) NOT NULL, DOB date NOT NULL, uID int unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY); INSERT INTO t1(fName, lName, DOB) VALUES -('Alice', 'Hill', date_sub(curdate(), interval 15271 day)), -('Bob', 'Adams', date_sub(curdate(), interval 33600 day)), -('Carol', 'Simpson', date_sub(curdate(), interval 13700 day)); +('Hank', 'Hill', '1964-09-29'), +('Tom', 'Adams', '1908-02-14'), +('Homer', 'Simpson', '1968-03-05'); CREATE VIEW v1 AS SELECT (year(now())-year(DOB)) AS Age FROM t1 HAVING Age < 75; SHOW CREATE VIEW v1; View Create View v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select (year(now()) - year(`t1`.`DOB`)) AS `Age` from `t1` having (`Age` < 75) +set timestamp=1136066400; SELECT (year(now())-year(DOB)) AS Age FROM t1 HAVING Age < 75; Age 42 38 +set timestamp=1136066400; SELECT * FROM v1; Age 42 diff --git a/mysql-test/t/auto_increment.test b/mysql-test/t/auto_increment.test index f869dc06187..f9a4a49d447 100644 --- a/mysql-test/t/auto_increment.test +++ b/mysql-test/t/auto_increment.test @@ -101,10 +101,10 @@ insert into t1 set i = 254; insert into t1 set i = null; select last_insert_id(); explain extended select last_insert_id(); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 set i = 254; select last_insert_id(); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 set i = null; select last_insert_id(); drop table t1; @@ -122,7 +122,7 @@ insert into t1 values (NULL, 10); select last_insert_id(); insert into t1 values (NULL, 15); select last_insert_id(); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values (NULL, 10); select last_insert_id(); @@ -277,7 +277,7 @@ create table t1 (rowid int not null auto_increment, val int not null,primary key (rowid), unique(val)); replace into t1 (val) values ('1'),('2'); replace into t1 (val) values ('1'),('2'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 (val) values ('1'),('2'); select * from t1; drop table t1; @@ -300,7 +300,7 @@ drop table t1; CREATE TABLE t1 (t1 INT(10) PRIMARY KEY, t2 INT(10)); INSERT INTO t1 VALUES(0, 0); INSERT INTO t1 VALUES(1, 1); ---error ER_DUP_ENTRY +--error ER_DUP_ENTRY_WITH_KEY_NAME ALTER TABLE t1 CHANGE t1 t1 INT(10) auto_increment; DROP TABLE t1; diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test index a2853ca3191..b4837b4ccbb 100644 --- a/mysql-test/t/create.test +++ b/mysql-test/t/create.test @@ -153,7 +153,7 @@ drop table if exists t1,t2; CREATE TABLE t1 (a int not null); INSERT INTO t1 values (1),(2),(1); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME CREATE TABLE t2 (primary key(a)) SELECT * FROM t1; --error 1146 SELECT * from t2; @@ -232,7 +232,7 @@ insert into t1 values (1,1); create table if not exists t1 select 2; select * from t1; create table if not exists t1 select 3 as 'a',4 as 'b'; ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME create table if not exists t1 select 3 as 'a',3 as 'b'; show warnings; show status like "Opened_tables"; @@ -684,30 +684,30 @@ drop table t1; CREATE TABLE t1 (a int, b int); insert into t1 values (1,1),(1,2); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME CREATE TABLE t2 (primary key (a)) select * from t1; # This should give warning drop table if exists t2; ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME CREATE TEMPORARY TABLE t2 (primary key (a)) select * from t1; # This should give warning drop table if exists t2; CREATE TABLE t2 (a int, b int, primary key (a)); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME CREATE TABLE IF NOT EXISTS t2 (primary key (a)) select * from t1; SELECT * from t2; TRUNCATE table t2; ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME INSERT INTO t2 select * from t1; SELECT * from t2; drop table t2; CREATE TEMPORARY TABLE t2 (a int, b int, primary key (a)); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) select * from t1; SELECT * from t2; TRUNCATE table t2; ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME INSERT INTO t2 select * from t1; SELECT * from t2; drop table t1,t2; diff --git a/mysql-test/t/create_select_tmp.test b/mysql-test/t/create_select_tmp.test index ba9898b7752..eacea1ac376 100644 --- a/mysql-test/t/create_select_tmp.test +++ b/mysql-test/t/create_select_tmp.test @@ -14,19 +14,19 @@ drop table if exists t1, t2; --enable_warnings CREATE TABLE t1 ( a int ); INSERT INTO t1 VALUES (1),(2),(1); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME CREATE TABLE t2 ( PRIMARY KEY (a) ) ENGINE=INNODB SELECT a FROM t1; --error 1146 select * from t2; ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME CREATE TEMPORARY TABLE t2 ( PRIMARY KEY (a) ) ENGINE=INNODB SELECT a FROM t1; --error 1146 select * from t2; ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME CREATE TABLE t2 ( PRIMARY KEY (a) ) ENGINE=MYISAM SELECT a FROM t1; --error 1146 select * from t2; ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME CREATE TEMPORARY TABLE t2 ( PRIMARY KEY (a) ) ENGINE=MYISAM SELECT a FROM t1; --error 1146 select * from t2; diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index 3a62ed1f7cd..47a43258be1 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -230,9 +230,9 @@ drop table t2; create table t1 (c varchar(30) character set utf8, unique(c(10))); insert into t1 values ('1'),('2'),('3'),('x'),('y'),('z'); insert into t1 values ('aaaaaaaaaa'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('aaaaaaaaaaa'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('aaaaaaaaaaaa'); insert into t1 values (repeat('b',20)); select c c1 from t1 where c='1'; @@ -254,9 +254,9 @@ create table t1 (c varchar(30) character set utf8, unique(c(10))) engine=innodb; --enable_warnings insert into t1 values ('1'),('2'),('3'),('x'),('y'),('z'); insert into t1 values ('aaaaaaaaaa'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('aaaaaaaaaaa'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('aaaaaaaaaaaa'); insert into t1 values (repeat('b',20)); select c c1 from t1 where c='1'; @@ -276,23 +276,23 @@ create table t1 (c char(3) character set utf8, unique (c(2))); insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z'); insert into t1 values ('a'); insert into t1 values ('aa'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('aaa'); insert into t1 values ('b'); insert into t1 values ('bb'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('bbb'); insert into t1 values ('а'); insert into t1 values ('аа'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('ааа'); insert into t1 values ('б'); insert into t1 values ('бб'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('ббб'); insert into t1 values ('ꪪ'); insert into t1 values ('ꪪꪪ'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('ꪪꪪꪪ'); drop table t1; # @@ -305,23 +305,23 @@ create table t1 (c char(3) character set utf8, unique (c(2))) engine=innodb; insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z'); insert into t1 values ('a'); insert into t1 values ('aa'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('aaa'); insert into t1 values ('b'); insert into t1 values ('bb'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('bbb'); insert into t1 values ('а'); insert into t1 values ('аа'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('ааа'); insert into t1 values ('б'); insert into t1 values ('бб'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('ббб'); insert into t1 values ('ꪪ'); insert into t1 values ('ꪪꪪ'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('ꪪꪪꪪ'); drop table t1; # @@ -334,14 +334,14 @@ unique key a using hash (c(1)) ) engine=heap; show create table t1; insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('aa'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('aaa'); insert into t1 values ('б'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('бб'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('ббб'); select c as c_all from t1 order by c; select c as c_a from t1 where c='a'; @@ -358,14 +358,14 @@ unique key a using btree (c(1)) ) engine=heap; show create table t1; insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('aa'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('aaa'); insert into t1 values ('б'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('бб'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('ббб'); select c as c_all from t1 order by c; select c as c_a from t1 where c='a'; @@ -383,14 +383,14 @@ unique key a (c(1)) ) engine=innodb; --enable_warnings insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('aa'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('aaa'); insert into t1 values ('б'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('бб'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('ббб'); select c as c_all from t1 order by c; select c as c_a from t1 where c='a'; @@ -404,9 +404,9 @@ drop table t1; create table t1 (c varchar(30) character set utf8 collate utf8_bin, unique(c(10))); insert into t1 values ('1'),('2'),('3'),('x'),('y'),('z'); insert into t1 values ('aaaaaaaaaa'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('aaaaaaaaaaa'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('aaaaaaaaaaaa'); insert into t1 values (repeat('b',20)); select c c1 from t1 where c='1'; @@ -427,23 +427,23 @@ create table t1 (c char(3) character set utf8 collate utf8_bin, unique (c(2))); insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z'); insert into t1 values ('a'); insert into t1 values ('aa'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('aaa'); insert into t1 values ('b'); insert into t1 values ('bb'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('bbb'); insert into t1 values ('а'); insert into t1 values ('аа'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('ааа'); insert into t1 values ('б'); insert into t1 values ('бб'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('ббб'); insert into t1 values ('ꪪ'); insert into t1 values ('ꪪꪪ'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('ꪪꪪꪪ'); drop table t1; @@ -457,14 +457,14 @@ unique key a using hash (c(1)) ) engine=heap; show create table t1; insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('aa'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('aaa'); insert into t1 values ('б'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('бб'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('ббб'); select c as c_all from t1 order by c; select c as c_a from t1 where c='a'; @@ -481,14 +481,14 @@ unique key a using btree (c(1)) ) engine=heap; show create table t1; insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('aa'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('aaa'); insert into t1 values ('б'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('бб'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('ббб'); select c as c_all from t1 order by c; select c as c_a from t1 where c='a'; @@ -506,14 +506,14 @@ unique key a (c(1)) ) engine=innodb; --enable_warnings insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('aa'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('aaa'); insert into t1 values ('б'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('бб'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('ббб'); select c as c_all from t1 order by c; select c as c_a from t1 where c='a'; diff --git a/mysql-test/t/delayed.test b/mysql-test/t/delayed.test index fe8bc167e0f..3ccee525d10 100644 --- a/mysql-test/t/delayed.test +++ b/mysql-test/t/delayed.test @@ -184,7 +184,7 @@ INSERT INTO t1 VALUES( 49, 71), (NULL, 72), (NULL, 73); INSERT INTO t1 VALUES(NULL, 81), (NULL, 82), (NULL, 83); # Create a duplicate value. SET insert_id= 114; ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME INSERT INTO t1 VALUES(NULL, 91); INSERT INTO t1 VALUES (NULL, 92), (NULL, 93); # Check what we have now diff --git a/mysql-test/t/heap.test b/mysql-test/t/heap.test index e501fce1eeb..624597cd8d7 100644 --- a/mysql-test/t/heap.test +++ b/mysql-test/t/heap.test @@ -128,7 +128,7 @@ SELECT * FROM t1 WHERE b=NULL; explain SELECT * FROM t1 WHERE b IS NULL; SELECT * FROM t1 WHERE b<=>NULL; ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME INSERT INTO t1 VALUES (1,3); DROP TABLE t1; @@ -270,7 +270,7 @@ explain select count(*) from t1 where v like 'a%'; explain select count(*) from t1 where v between 'a' and 'a '; explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n'; ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME alter table t1 add unique(v); select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a' order by length(concat('*',v,'*',c,'*',t,'*')); explain select * from t1 where v='a'; @@ -296,17 +296,17 @@ drop table t1; create table t1 (a char(10), unique (a)); insert into t1 values ('a'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('a '); alter table t1 modify a varchar(10); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('a '),('a '),('a '),('a '); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('a '); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('a '); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('a '); update t1 set a='a ' where a like 'a '; update t1 set a='a ' where a like 'a '; @@ -357,7 +357,7 @@ explain select count(*) from t1 where v between 'a' and 'a '; --replace_column 9 # explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n'; ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME alter table t1 add unique(v); select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a' order by length(concat('*',v,'*',c,'*',t,'*')); # Number of rows is not constant for b-trees keys @@ -372,17 +372,17 @@ drop table t1; create table t1 (a char(10), unique using btree (a)) engine=heap; insert into t1 values ('a'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('a '); alter table t1 modify a varchar(10); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('a '),('a '),('a '),('a '); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('a '); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('a '); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('a '); update t1 set a='a ' where a like 'a '; update t1 set a='a ' where a like 'a '; @@ -432,7 +432,7 @@ create table t1 (a int not null, b int not null auto_increment, # create table t1 (c char(255), primary key(c(90))); insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"); drop table t1; diff --git a/mysql-test/t/heap_btree.test b/mysql-test/t/heap_btree.test index 03ba8661a3c..68aa79834fc 100644 --- a/mysql-test/t/heap_btree.test +++ b/mysql-test/t/heap_btree.test @@ -143,7 +143,7 @@ SELECT * FROM t1 WHERE b=NULL; explain SELECT * FROM t1 WHERE b IS NULL; SELECT * FROM t1 WHERE b<=>NULL; ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME INSERT INTO t1 VALUES (1,3); DROP TABLE t1; diff --git a/mysql-test/t/heap_hash.test b/mysql-test/t/heap_hash.test index 28a75a5ee11..774f83f43b0 100644 --- a/mysql-test/t/heap_hash.test +++ b/mysql-test/t/heap_hash.test @@ -128,7 +128,7 @@ SELECT * FROM t1 WHERE b=NULL; explain SELECT * FROM t1 WHERE b IS NULL; SELECT * FROM t1 WHERE b<=>NULL; ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME INSERT INTO t1 VALUES (1,3); DROP TABLE t1; diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test index e1e74ac8a11..6e33cf1f14c 100644 --- a/mysql-test/t/innodb.test +++ b/mysql-test/t/innodb.test @@ -53,7 +53,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), update t1 set parent_id=parent_id+100; select * from t1 where parent_id=102; update t1 set id=id+1000; --- error 1062,1022 +-- error ER_DUP_ENTRY_WITH_KEY_NAME,1022 update t1 set id=1024 where id=1009; select * from t1; update ignore t1 set id=id+1; # This will change all rows @@ -134,13 +134,13 @@ commit; select n, "after commit" from t1; commit; insert into t1 values (5); --- error 1062 +-- error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values (4); commit; select n, "after commit" from t1; set autocommit=1; insert into t1 values (6); --- error 1062 +-- error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values (4); select n from t1; set autocommit=0; @@ -214,7 +214,7 @@ drop table t1; CREATE TABLE t1 (id char(8) not null primary key, val int not null) engine=innodb; insert into t1 values ('pippo', 12); --- error 1062 +-- error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values ('pippo', 12); # Gives error delete from t1; delete from t1 where id = 'pippo'; @@ -342,9 +342,9 @@ CREATE TABLE t1 ( insert into t1 (ggid,passwd) values ('test1','xxx'); insert into t1 (ggid,passwd) values ('test2','yyy'); --- error 1062 +-- error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 (ggid,passwd) values ('test2','this will fail'); --- error 1062 +-- error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 (ggid,id) values ('this will fail',1); select * from t1 where ggid='test1'; @@ -353,7 +353,7 @@ select * from t1 where id=2; replace into t1 (ggid,id) values ('this will work',1); replace into t1 (ggid,passwd) values ('test2','this will work'); --- error 1062 +-- error ER_DUP_ENTRY_WITH_KEY_NAME update t1 set id=100,ggid='test2' where id=1; select * from t1; select * from t1 where id=1; @@ -524,7 +524,7 @@ drop table t1; 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=innodb; insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL'); LOCK TABLES t1 WRITE; ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values (99,1,2,'D'),(1,1,2,'D'); select id from t1; select id from t1; @@ -535,7 +535,7 @@ create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(3 insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL'); LOCK TABLES t1 WRITE; begin; ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values (99,1,2,'D'),(1,1,2,'D'); select id from t1; insert ignore into t1 values (100,1,2,'D'),(1,1,99,'D'); @@ -1408,7 +1408,7 @@ create table t1 (rowid int not null auto_increment, val int not null,primary key (rowid), unique(val)) engine=innodb; replace into t1 (val) values ('1'),('2'); replace into t1 (val) values ('1'),('2'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 (val) values ('1'),('2'); select * from t1; drop table t1; @@ -1421,7 +1421,7 @@ create table t1 (a int not null auto_increment primary key, val int) engine=Inno insert into t1 (val) values (1); update t1 set a=2 where a=1; # We should get the following error because InnoDB does not update the counter ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 (val) values (1); select * from t1; drop table t1; @@ -1877,13 +1877,13 @@ create table t3 (s1 varchar(2) binary,primary key (s1)) engine=innodb; create table t4 (s1 char(2) binary,primary key (s1)) engine=innodb; insert into t1 values (0x41),(0x4120),(0x4100); --- error 1062 +-- error ER_DUP_ENTRY_WITH_KEY_NAME insert into t2 values (0x41),(0x4120),(0x4100); insert into t2 values (0x41),(0x4120); --- error 1062 +-- error ER_DUP_ENTRY_WITH_KEY_NAME insert into t3 values (0x41),(0x4120),(0x4100); insert into t3 values (0x41),(0x4100); --- error 1062 +-- error ER_DUP_ENTRY_WITH_KEY_NAME insert into t4 values (0x41),(0x4120),(0x4100); insert into t4 values (0x41),(0x4100); select hex(s1) from t1; diff --git a/mysql-test/t/insert_select.test b/mysql-test/t/insert_select.test index 404d67390ab..1994d23afd7 100644 --- a/mysql-test/t/insert_select.test +++ b/mysql-test/t/insert_select.test @@ -10,7 +10,7 @@ create table t1 (bandID MEDIUMINT UNSIGNED NOT NULL PRIMARY KEY, payoutID SMALLI insert into t1 (bandID,payoutID) VALUES (1,6),(2,6),(3,4),(4,9),(5,10),(6,1),(7,12),(8,12); create table t2 (payoutID SMALLINT UNSIGNED NOT NULL PRIMARY KEY); insert into t2 (payoutID) SELECT DISTINCT payoutID FROM t1; ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t2 (payoutID) SELECT payoutID+10 FROM t1; insert ignore into t2 (payoutID) SELECT payoutID+10 FROM t1; select * from t2; @@ -101,7 +101,7 @@ create table t1 (a int not null primary key, b char(10)); create table t2 (a int not null, b char(10)); insert into t1 values (1,"t1:1"),(3,"t1:3"); insert into t2 values (2,"t2:2"), (3,"t2:3"); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 select * from t2; select * from t1; # REPLACE .. SELECT is not yet supported by PS diff --git a/mysql-test/t/insert_update.test b/mysql-test/t/insert_update.test index b3813864464..8a3e0306025 100644 --- a/mysql-test/t/insert_update.test +++ b/mysql-test/t/insert_update.test @@ -12,7 +12,7 @@ INSERT t1 VALUES (8,4,50) ON DUPLICATE KEY UPDATE c=c+1000; SELECT * FROM t1; INSERT t1 VALUES (1,4,60) ON DUPLICATE KEY UPDATE c=c+10000; SELECT * FROM t1; --- error 1062 +-- error ER_DUP_ENTRY_WITH_KEY_NAME INSERT t1 VALUES (1,9,70) ON DUPLICATE KEY UPDATE c=c+100000, b=4; SELECT * FROM t1; TRUNCATE TABLE t1; @@ -63,7 +63,7 @@ INSERT t1 SELECT 8,4,50 FROM DUAL ON DUPLICATE KEY UPDATE c=c+1000; SELECT * FROM t1; INSERT t1 SELECT 1,4,60 FROM DUAL ON DUPLICATE KEY UPDATE c=c+10000; SELECT * FROM t1; --- error 1062 +-- error ER_DUP_ENTRY_WITH_KEY_NAME INSERT t1 SELECT 1,9,70 FROM DUAL ON DUPLICATE KEY UPDATE c=c+100000, b=4; SELECT * FROM t1; TRUNCATE TABLE t1; diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test index 72a2935337d..9bc88a95ffe 100644 --- a/mysql-test/t/join_outer.test +++ b/mysql-test/t/join_outer.test @@ -97,7 +97,7 @@ WHERE t1.uniq_id = 4 ORDER BY t2.c_amount; INSERT INTO t2 VALUES (2,3,3000,6000,0,0,746584,837484,'yes'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME INSERT INTO t2 VALUES (2,3,3000,6000,0,0,746584,837484,'yes'); INSERT INTO t2 VALUES (7,3,1000,2000,0,0,746294,937484,'yes'); diff --git a/mysql-test/t/key.test b/mysql-test/t/key.test index 7c6b38cb871..0a5eb17f6f5 100644 --- a/mysql-test/t/key.test +++ b/mysql-test/t/key.test @@ -150,7 +150,7 @@ create table t1 ); INSERT INTO t1 VALUES (1, 1, 1, 1, 'a'); INSERT INTO t1 VALUES (1, 1, 1, 1, 'b'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME INSERT INTO t1 VALUES (1, 1, 1, 1, 'a'); drop table t1; @@ -243,13 +243,13 @@ show create table t1; insert t1 values ('cccc', 'tttt'), (0xD0B1212223D0B1D0B1D0B1D0B1D0B1, 0xD0B1D0B1212223D0B1D0B1D0B1D0B1), (0xD0B1222123D0B1D0B1D0B1D0B1D0B1, 0xD0B1D0B1222123D0B1D0B1D0B1D0B1); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert t1 (c) values ('cc22'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert t1 (t) values ('ttt22'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert t1 (c) values (0xD0B1212322D0B1D0B1D0B1D0B1D0B1); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert t1 (t) values (0xD0B1D0B1212322D0B1D0B1D0B1D0B1); select c from t1 where c='cccc'; select t from t1 where t='tttt'; @@ -438,7 +438,7 @@ insert into t1 values(1, 'b', 'b', NULL); # Drop some indexes for new adds. alter table t1 drop index i3, drop index i2, drop index i1; # Add indexes, one is unique on non-unique values. ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME alter table t1 add index i3 (c3), add index i2 (c2), add unique index i1 (c1); drop table t1; diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test index 5498468d902..ac2b9471fe9 100644 --- a/mysql-test/t/merge.test +++ b/mysql-test/t/merge.test @@ -195,9 +195,9 @@ select * from t6 order by a,b; insert into t1 values (99,NULL); select * from t4 where a+0 > 90; # bug#4008 - cannot determine a unique key that caused "dupl. key error" ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert t5 values (1,1); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert t6 values (2,1); insert t5 values (1,1) on duplicate key update b=b+10; insert t6 values (2,1) on duplicate key update b=b+20; diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index 0898f7d9896..4281030fc3c 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -453,9 +453,9 @@ create table t1 (a int not null auto_increment primary key, b text not null, uni insert into t1 (b) values ('a'),('b'),('c'); select concat(b,'.') from t1; update t1 set b='b ' where a=2; ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME update t1 set b='b ' where a > 1; ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 (b) values ('b'); select * from t1; delete from t1 where b='b'; @@ -847,6 +847,33 @@ DROP TABLE t1; SET @@myisam_repair_threads=1; SHOW VARIABLES LIKE 'myisam_repair%'; +# +# BUG#21310 - Trees in SQL causing a "crashed" table with MyISAM storage +# engine +# + +# A simplified test case that reflect crashed table issue. +CREATE TABLE t1(a VARCHAR(16)); +INSERT INTO t1 VALUES('aaaaaaaa'),(NULL); +UPDATE t1 AS ta1, t1 AS ta2 SET ta1.a='aaaaaaaaaaaaaaaa'; +SELECT * FROM t1; +DROP TABLE t1; + +# A test case that reflect wrong result set. +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES(1),(2); +UPDATE t1,t1 AS t2 SET t1.a=t1.a+2 WHERE t1.a=t2.a-1; +SELECT * FROM t1 ORDER BY a; +DROP TABLE t1; + +# +# Bug#24607 - MyISAM pointer size determined incorrectly +# +CREATE TABLE t1 (c1 TEXT) AVG_ROW_LENGTH=70100 MAX_ROWS=4100100100; +--replace_column 5 X 6 X 7 X 9 X 10 X 11 X 12 X 13 X 14 X 16 X +SHOW TABLE STATUS LIKE 't1'; +DROP TABLE t1; + --echo End of 4.1 tests diff --git a/mysql-test/t/ndb_basic.test b/mysql-test/t/ndb_basic.test index 29b63a5a24a..ad5f9c652c7 100644 --- a/mysql-test/t/ndb_basic.test +++ b/mysql-test/t/ndb_basic.test @@ -792,7 +792,7 @@ drop table t1,t2; # insert ignore create table t1 (a int not null primary key, b int not null) engine=ndb; insert into t1 values (1,10), (2,20), (3,30); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 set a=1, b=100; insert ignore into t1 set a=1, b=100; select * from t1 order by a; @@ -805,12 +805,12 @@ create table t1 (a int not null primary key, b int not null) engine=ndb; create table t2 (c int not null primary key, d int not null) engine=ndb; insert into t1 values (1,10), (2,10), (3,30), (4, 30); insert into t2 values (1,10), (2,10), (3,30), (4, 30); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME update t1 set a = 1 where a = 3; select * from t1 order by a; update t1 set b = 1 where a > 1 order by a desc limit 1; select * from t1 order by a; ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME update t1,t2 set a = 1, c = 1 where a = 3 and c = 3; select * from t1 order by a; update ignore t1,t2 set a = 1, c = 1 where a = 3 and c = 3; diff --git a/mysql-test/t/ndb_charset.test b/mysql-test/t/ndb_charset.test index a429ee5e1dc..2cdb1972225 100644 --- a/mysql-test/t/ndb_charset.test +++ b/mysql-test/t/ndb_charset.test @@ -38,9 +38,9 @@ create table t1 ( # ok insert into t1 values('aAa'); # fail ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values('aaa'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values('AAA'); # 1 select * from t1 order by a; @@ -61,9 +61,9 @@ create table t1 ( ) engine=ndb; # insert into t1 values ('A'),('b '),('C '),('d '),('E'),('f'); --- error 1062 +-- error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values('b'); --- error 1062 +-- error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values('a '); # select a,length(a) from t1 order by a; @@ -106,9 +106,9 @@ create table t1 ( # ok insert into t1 values(1, 'aAa'); # fail ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values(2, 'aaa'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values(3, 'AAA'); # 1 select * from t1 order by p; @@ -131,9 +131,9 @@ create table t1 ( ) engine=ndb; # insert into t1 values (1,'A'),(2,'b '),(3,'C '),(4,'d '),(5,'E'),(6,'f'); --- error 1062 +-- error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values(99,'b'); --- error 1062 +-- error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values(99,'a '); # select a,length(a) from t1 order by a; @@ -231,7 +231,7 @@ drop table t1; # ('a','A '),('B ','b'),('c','C '),('D','d'),('e ','E'),('F','f '), # ('A','b '),('b ','C'),('C','d '),('d','E'),('E ','f'), # ('a','C '),('B ','d'),('c','E '),('D','f'); -#-- error 1062 +#-- error ER_DUP_ENTRY_WITH_KEY_NAME #insert into t1 values('d','f'); # #select a,b,length(a),length(b) from t1 order by a,b limit 3; diff --git a/mysql-test/t/ndb_index_unique.test b/mysql-test/t/ndb_index_unique.test index 8f1a4e35ece..e6d3fbb87a0 100644 --- a/mysql-test/t/ndb_index_unique.test +++ b/mysql-test/t/ndb_index_unique.test @@ -22,7 +22,7 @@ select * from t1 where b = 4 order by b; insert into t1 values(7,8,3); select * from t1 where b = 4 order by a; --- error 1062 +-- error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values(8, 2, 3); select * from t1 order by a; delete from t1 where a = 1; @@ -59,7 +59,7 @@ select * from t1 use index (bc) where b IS NULL and c IS NULL order by a; select * from t1 use index (bc) where b IS NULL and c = 2 order by a; select * from t1 use index (bc) where b < 4 order by a; select * from t1 use index (bc) where b IS NOT NULL order by a; --- error 1062 +-- error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values(5,1,1); drop table t1; @@ -82,7 +82,7 @@ select * from t2 where c = 6; insert into t2 values(7,8,3); select * from t2 where b = 4 order by a; --- error 1062 +-- error ER_DUP_ENTRY_WITH_KEY_NAME insert into t2 values(8, 2, 3); select * from t2 order by a; delete from t2 where a = 1; @@ -91,7 +91,7 @@ select * from t2 order by a; # Bug #24818 CREATE UNIQUE INDEX (...) USING HASH on a NDB table crashes mysqld create unique index bi using hash on t2(b); --- error 1062 +-- error ER_DUP_ENTRY_WITH_KEY_NAME insert into t2 values(9, 3, 1); alter table t2 drop index bi; insert into t2 values(9, 3, 1); @@ -154,7 +154,7 @@ insert into t1 values (-1,NULL), (0,0), (1,NULL),(2,2),(3,NULL),(4,4); select * from t1 order by pk; ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values (5,0); select * from t1 order by pk; delete from t1 where a = 0; @@ -173,7 +173,7 @@ insert into t2 values (-1,1,17,NULL),(0,NULL,18,NULL),(1,3,19,'abc'); select * from t2 order by pk; ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t2 values(2,3,19,'abc'); select * from t2 order by pk; delete from t2 where c IS NOT NULL; @@ -342,7 +342,7 @@ create table t1 (a int primary key, b varchar(1000) not null, unique key (b)) engine=ndb charset=utf8; insert into t1 values (1, repeat(_utf8 0xe288ab6474, 200)); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values (2, repeat(_utf8 0xe288ab6474, 200)); select a, sha1(b) from t1; diff --git a/mysql-test/t/ndb_insert.test b/mysql-test/t/ndb_insert.test index bf25ca9a133..936bcb305ab 100644 --- a/mysql-test/t/ndb_insert.test +++ b/mysql-test/t/ndb_insert.test @@ -433,7 +433,7 @@ SELECT COUNT(*) FROM t1; # # Insert duplicate rows # ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME INSERT INTO t1 VALUES (1,1,1); --error 1022 diff --git a/mysql-test/t/ndb_replace.test b/mysql-test/t/ndb_replace.test index 476a607ed44..fcbefe710ca 100644 --- a/mysql-test/t/ndb_replace.test +++ b/mysql-test/t/ndb_replace.test @@ -21,7 +21,7 @@ replace into t1 (gesuchnr,benutzer_id) values (1,1); insert into t1 (gesuchnr, benutzer_id) value (3,2); replace into t1 (gesuchnr,benutzer_id) values (1,1); replace into t1 (gesuchnr,benutzer_id) values (1,1); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 (gesuchnr,benutzer_id) values (1,1); replace into t1 (gesuchnr,benutzer_id) values (1,1); select * from t1 order by gesuchnr; diff --git a/mysql-test/t/ndb_update.test b/mysql-test/t/ndb_update.test index ebcc6995d74..335c43bc796 100644 --- a/mysql-test/t/ndb_update.test +++ b/mysql-test/t/ndb_update.test @@ -23,11 +23,11 @@ UPDATE t1 set b = c; select * from t1 order by pk1; UPDATE t1 set pk1 = 4 where pk1 = 1; select * from t1 order by pk1; ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME UPDATE t1 set pk1 = 4 where pk1 = 2; UPDATE IGNORE t1 set pk1 = 4 where pk1 = 2; select * from t1 order by pk1; --- error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME UPDATE t1 set pk1 = 1, c = 2 where pk1 = 4; UPDATE IGNORE t1 set pk1 = 1, c = 2 where pk1 = 4; select * from t1 order by pk1; diff --git a/mysql-test/t/replace.test b/mysql-test/t/replace.test index 269854fb180..4e88379241c 100644 --- a/mysql-test/t/replace.test +++ b/mysql-test/t/replace.test @@ -25,9 +25,9 @@ drop table t1; create table t1 (a tinyint not null auto_increment primary key, b char(20) default "default_value"); insert into t1 values (126,"first"),(63, "middle"),(0,"last"); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values (0,"error"); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME replace into t1 values (0,"error"); replace into t1 values (126,"first updated"); replace into t1 values (63,default); diff --git a/mysql-test/t/rpl_err_ignoredtable.test b/mysql-test/t/rpl_err_ignoredtable.test index 42ca8cf2e8b..4d4be6ae786 100644 --- a/mysql-test/t/rpl_err_ignoredtable.test +++ b/mysql-test/t/rpl_err_ignoredtable.test @@ -11,7 +11,7 @@ connection master; create table t1 (a int primary key); create table t4 (a int primary key); # generate an error that goes to the binlog ---error 1022, 1062 +--error 1022, ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values (1),(1); insert into t4 values (1),(2); save_master_pos; diff --git a/mysql-test/t/rpl_row_create_table.test b/mysql-test/t/rpl_row_create_table.test index 6accf0c8bef..6afcae4b5e6 100644 --- a/mysql-test/t/rpl_row_create_table.test +++ b/mysql-test/t/rpl_row_create_table.test @@ -67,7 +67,7 @@ SELECT * FROM t6 ORDER BY a,b,c; connection master; # Test for erroneous constructions ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME CREATE TABLE t7 (UNIQUE(b)) SELECT a,b FROM tt3; # Shouldn't be written to the binary log --replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ @@ -75,7 +75,7 @@ SHOW BINLOG EVENTS FROM 1118; # Test that INSERT-SELECT works the same way as for SBR. CREATE TABLE t7 (a INT, b INT UNIQUE); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME INSERT INTO t7 SELECT a,b FROM tt3; SELECT * FROM t7 ORDER BY a,b; # Should be written to the binary log diff --git a/mysql-test/t/rpl_skip_error-slave.opt b/mysql-test/t/rpl_skip_error-slave.opt index f6f258f799f..982362d93a5 100644 --- a/mysql-test/t/rpl_skip_error-slave.opt +++ b/mysql-test/t/rpl_skip_error-slave.opt @@ -1 +1 @@ ---slave-skip-error=1053,1062 +--slave-skip-error=1053,1582 diff --git a/mysql-test/t/rpl_sp.test b/mysql-test/t/rpl_sp.test index 9a1960db647..9230b3bff4f 100644 --- a/mysql-test/t/rpl_sp.test +++ b/mysql-test/t/rpl_sp.test @@ -153,7 +153,7 @@ create procedure foo4() delimiter ;| ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME call foo4(); show warnings; @@ -308,7 +308,7 @@ delimiter ;| do fn1(100); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME select fn1(20); select * from t2; diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test index be803a74c7b..938baec51d1 100644 --- a/mysql-test/t/show_check.test +++ b/mysql-test/t/show_check.test @@ -30,7 +30,7 @@ check table t1 changed; check table t1 medium; check table t1 extended; show index from t1; ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values (5,5,5); optimize table t1; optimize table t1; diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test index 456a23123d3..3f3aba383d7 100644 --- a/mysql-test/t/sp-error.test +++ b/mysql-test/t/sp-error.test @@ -586,7 +586,7 @@ begin end| set @x = 0| ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME call bug3279(@x)| select @x| drop procedure bug3279| diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index 19c70b1bd1e..38753ed3ac0 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -1763,11 +1763,11 @@ insert into t3 (a) values (1)| create procedure h_ee() deterministic begin - declare continue handler for 1062 -- ER_DUP_ENTRY + declare continue handler for 1582 -- ER_DUP_ENTRY_WITH_KEY_NAME select 'Outer (bad)' as 'h_ee'; begin - declare continue handler for 1062 -- ER_DUP_ENTRY + declare continue handler for 1582 -- ER_DUP_ENTRY_WITH_KEY_NAME select 'Inner (good)' as 'h_ee'; insert into t3 values (1); @@ -1777,7 +1777,7 @@ end| create procedure h_es() deterministic begin - declare continue handler for 1062 -- ER_DUP_ENTRY + declare continue handler for 1582 -- ER_DUP_ENTRY_WITH_KEY_NAME select 'Outer (good)' as 'h_es'; begin @@ -1823,7 +1823,7 @@ end| create procedure h_ex() deterministic begin - declare continue handler for 1062 -- ER_DUP_ENTRY + declare continue handler for 1582 -- ER_DUP_ENTRY_WITH_KEY_NAME select 'Outer (good)' as 'h_ex'; begin @@ -1842,7 +1842,7 @@ begin select 'Outer (bad)' as 'h_se'; begin - declare continue handler for 1062 -- ER_DUP_ENTRY + declare continue handler for 1582 -- ER_DUP_ENTRY_WITH_KEY_NAME select 'Inner (good)' as 'h_se'; insert into t3 values (1); @@ -2015,7 +2015,7 @@ begin select 'Outer (bad)' as 'h_xe'; begin - declare continue handler for 1062 -- ER_DUP_ENTRY + declare continue handler for 1582 -- ER_DUP_ENTRY_WITH_KEY_NAME select 'Inner (good)' as 'h_xe'; insert into t3 values (1); @@ -4507,7 +4507,7 @@ begin select bug12379(); end| ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME select bug12379()| select 1| # statement-based binlogging will show warning which row-based won't; @@ -4518,7 +4518,7 @@ select 2| call bug12379_2()| --enable_warnings select 3| ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME call bug12379_3()| select 4| @@ -4600,7 +4600,7 @@ end| call bug6127()| select * from t3| ---error ER_DUP_ENTRY +--error ER_DUP_ENTRY_WITH_KEY_NAME call bug6127()| select * from t3| set sql_mode=@sm| @@ -5528,11 +5528,11 @@ insert into t3 values (1)| create procedure bug15011() deterministic begin - declare continue handler for 1062 + declare continue handler for 1582 select 'Outer' as 'Handler'; begin - declare continue handler for 1062 + declare continue handler for 1582 select 'Inner' as 'Handler'; insert into t3 values (1); diff --git a/mysql-test/t/sp_trans.test b/mysql-test/t/sp_trans.test index 325e11b1ec9..a79f6c7e7e0 100644 --- a/mysql-test/t/sp_trans.test +++ b/mysql-test/t/sp_trans.test @@ -89,7 +89,7 @@ create function bug10015_5(i int) returns int end if; return i; end| ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values (bug10015_5(4)), (bug10015_5(5))| select * from t1| drop function bug10015_5| diff --git a/mysql-test/t/temp_table.test b/mysql-test/t/temp_table.test index 123007b10c7..d06fde87b34 100644 --- a/mysql-test/t/temp_table.test +++ b/mysql-test/t/temp_table.test @@ -73,7 +73,7 @@ drop table t1,t2; # create temporary table t1 (a int not null); insert into t1 values (1),(1); --- error 1062 +-- error ER_DUP_ENTRY_WITH_KEY_NAME alter table t1 add primary key (a); drop table t1; diff --git a/mysql-test/t/type_binary.test b/mysql-test/t/type_binary.test index 91eba9b328e..a09e487f6cb 100644 --- a/mysql-test/t/type_binary.test +++ b/mysql-test/t/type_binary.test @@ -31,7 +31,7 @@ drop table t1; create table t1 (s1 binary(2) primary key); insert into t1 values (0x01); insert into t1 values (0x0120); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 values (0x0100); select hex(s1) from t1 order by s1; # check index search diff --git a/mysql-test/t/type_bit.test b/mysql-test/t/type_bit.test index 48ad24ff6b7..8141bdedd50 100644 --- a/mysql-test/t/type_bit.test +++ b/mysql-test/t/type_bit.test @@ -39,7 +39,7 @@ 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 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME alter table t1 add unique (a); drop table t1; diff --git a/mysql-test/t/type_bit_innodb.test b/mysql-test/t/type_bit_innodb.test index dbca69d67f0..4ee97782452 100644 --- a/mysql-test/t/type_bit_innodb.test +++ b/mysql-test/t/type_bit_innodb.test @@ -40,7 +40,7 @@ drop table t1; create table t1 (a bit) engine=innodb; insert into t1 values (b'0'), (b'1'), (b'000'), (b'100'), (b'001'); select hex(a) from t1; ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME alter table t1 add unique (a); drop table t1; diff --git a/mysql-test/t/type_blob.test b/mysql-test/t/type_blob.test index 6d79dcc863b..cd8f2d48eea 100644 --- a/mysql-test/t/type_blob.test +++ b/mysql-test/t/type_blob.test @@ -334,9 +334,9 @@ drop table t1; # create table t1 (id integer primary key auto_increment, txt text not null, unique index txt_index (txt (20))); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME insert into t1 (txt) values ('Chevy'), ('Chevy '); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME 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 '); diff --git a/mysql-test/t/type_varchar.test b/mysql-test/t/type_varchar.test index 7b87a388c56..3ba80514ff9 100644 --- a/mysql-test/t/type_varchar.test +++ b/mysql-test/t/type_varchar.test @@ -25,7 +25,7 @@ select v='a' from t1; select binary v='a' from t1; select binary v='a ' from t1; insert into t1 values('a'); ---error 1062 +--error ER_DUP_ENTRY_WITH_KEY_NAME alter table t1 add primary key (v); drop table t1; create table t1 (v varbinary(20)); diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index ea429e2a0f0..3c5308a935c 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -2544,16 +2544,18 @@ CREATE TABLE t1( uID int unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY); INSERT INTO t1(fName, lName, DOB) VALUES - ('Alice', 'Hill', date_sub(curdate(), interval 15271 day)), - ('Bob', 'Adams', date_sub(curdate(), interval 33600 day)), - ('Carol', 'Simpson', date_sub(curdate(), interval 13700 day)); + ('Hank', 'Hill', '1964-09-29'), + ('Tom', 'Adams', '1908-02-14'), + ('Homer', 'Simpson', '1968-03-05'); CREATE VIEW v1 AS SELECT (year(now())-year(DOB)) AS Age FROM t1 HAVING Age < 75; SHOW CREATE VIEW v1; +set timestamp=1136066400; SELECT (year(now())-year(DOB)) AS Age FROM t1 HAVING Age < 75; +set timestamp=1136066400; SELECT * FROM v1; DROP VIEW v1; diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c index 2a1b94a363e..5ce7e99fbdc 100644 --- a/mysys/thr_lock.c +++ b/mysys/thr_lock.c @@ -757,8 +757,16 @@ void thr_unlock(THR_LOCK_DATA *data) } else lock->write.last=data->prev; - if (lock_type >= TL_WRITE_CONCURRENT_INSERT && lock->update_status) - (*lock->update_status)(data->status_param); + if (lock_type >= TL_WRITE_CONCURRENT_INSERT) + { + if (lock->update_status) + (*lock->update_status)(data->status_param); + } + else + { + if (lock->restore_status) + (*lock->restore_status)(data->status_param); + } if (lock_type == TL_READ_NO_INSERT) lock->read_no_write_count--; data->type=TL_UNLOCK; /* Mark unlocked */ diff --git a/scripts/fill_help_tables.sh b/scripts/fill_help_tables.sh index 1dff7edd268..e600d24032b 100644 --- a/scripts/fill_help_tables.sh +++ b/scripts/fill_help_tables.sh @@ -521,6 +521,7 @@ print <key_info[key_nr].name); } } @@ -2099,7 +2099,7 @@ void handler::print_error(int error, myf errflag) uint key_nr=get_dup_key(error); if ((int) key_nr >= 0) { - print_keydup_error(key_nr, ER(ER_DUP_ENTRY)); + print_keydup_error(key_nr, ER(ER_DUP_ENTRY_WITH_KEY_NAME)); DBUG_VOID_RETURN; } textno=ER_DUP_KEY; diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index 15ea8f67c0d..29fde49bbd6 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -1479,30 +1479,30 @@ ER_DUP_KEYNAME 42000 S1009 swe "Nyckelnamn '%-.64s' finns flera gnger" ukr " ' '%-.64s'" ER_DUP_ENTRY 23000 S1009 - cze "Zvojen-B kl '%-.64s' (slo kle '%-.64s')" - dan "Ens vrdier '%-.64s' for indeks '%-.64s'" - nla "Dubbele ingang '%-.64s' voor zoeksleutel '%-.64s'" - eng "Duplicate entry '%-.64s' for key '%-.64s'" - jps "'%-.64s' key '%-.64s' ɂďdĂ܂", - est "Kattuv vrtus '%-.64s' vtmele '%-.64s'" - fre "Duplicata du champ '%-.64s' pour la clef '%-.64s'" - ger "Doppelter Eintrag '%-.64s' fr Schlssel '%-.64s'" - greek " '%-.64s' '%-.64s'" - hun "Duplikalt bejegyzes '%-.64s' a '%-.64s' kulcs szerint." - ita "Valore duplicato '%-.64s' per la chiave '%-.64s'" - jpn "'%-.64s' key '%-.64s' ˤƽʣƤޤ" - kor "ߺ Է '%-.64s': key '%-.64s'" - nor "Like verdier '%-.64s' for nkkel '%-.64s'" - norwegian-ny "Like verdiar '%-.64s' for nykkel '%-.64s'" - pol "Powtrzone wyst?pienie '%-.64s' dla klucza '%-.64s'" - por "Entrada '%-.64s' duplicada para a chave '%-.64s'" - rum "Cimpul '%-.64s' e duplicat pentru cheia '%-.64s'" - rus " '%-.64s' '%-.64s'" - serbian "Dupliran unos '%-.64s' za klju '%-.64s'" - slo "Opakovan k '%-.64s' (slo ka '%-.64s')" - spa "Entrada duplicada '%-.64s' para la clave '%-.64s'" - swe "Dubbel nyckel '%-.64s' fr nyckel '%-.64s'" - ukr " '%-.64s' '%-.64s'" + cze "Zvojen-B kl '%-.64s' (slo kle %d)" + dan "Ens vrdier '%-.64s' for indeks %d" + nla "Dubbele ingang '%-.64s' voor zoeksleutel %d" + eng "Duplicate entry '%-.64s' for key %d" + jps "'%-.64s' key %d ɂďdĂ܂", + est "Kattuv vrtus '%-.64s' vtmele %d" + fre "Duplicata du champ '%-.64s' pour la clef %d" + ger "Doppelter Eintrag '%-.64s' fr Schlssel %d" + greek " '%-.64s' %d" + hun "Duplikalt bejegyzes '%-.64s' a %d kulcs szerint." + ita "Valore duplicato '%-.64s' per la chiave %d" + jpn "'%-.64s' key %d ˤƽʣƤޤ" + kor "ߺ Է '%-.64s': key %d" + nor "Like verdier '%-.64s' for nkkel %d" + norwegian-ny "Like verdiar '%-.64s' for nykkel %d" + pol "Powtrzone wyst?pienie '%-.64s' dla klucza %d" + por "Entrada '%-.64s' duplicada para a chave %d" + rum "Cimpul '%-.64s' e duplicat pentru cheia %d" + rus " '%-.64s' %d" + serbian "Dupliran unos '%-.64s' za klju '%d'" + slo "Opakovan k '%-.64s' (slo ka %d)" + spa "Entrada duplicada '%-.64s' para la clave %d" + swe "Dubbel nyckel '%-.64s' fr nyckel %d" + ukr " '%-.64s' %d" ER_WRONG_FIELD_SPEC 42000 S1009 cze "Chybn-B specifikace sloupce '%-.64s'" dan "Forkert kolonnespecifikaton for felt '%-.64s'" @@ -6025,6 +6025,31 @@ ER_WRONG_PARAMETERS_TO_STORED_FCT 42000 ER_NATIVE_FCT_NAME_COLLISION eng "This function '%-.64s' has the same name as a native function" ger "Die Funktion '%-.64s' hat denselben Namen wie eine native Funktion" +ER_DUP_ENTRY_WITH_KEY_NAME 23000 S1009 + cze "Zvojen-B kl '%-.64s' (slo kle '%-.64s')" + dan "Ens vrdier '%-.64s' for indeks '%-.64s'" + nla "Dubbele ingang '%-.64s' voor zoeksleutel '%-.64s'" + eng "Duplicate entry '%-.64s' for key '%-.64s'" + jps "'%-.64s' key '%-.64s' ɂďdĂ܂", + est "Kattuv vrtus '%-.64s' vtmele '%-.64s'" + fre "Duplicata du champ '%-.64s' pour la clef '%-.64s'" + ger "Doppelter Eintrag '%-.64s' fr Schlssel '%-.64s'" + greek " '%-.64s' '%-.64s'" + hun "Duplikalt bejegyzes '%-.64s' a '%-.64s' kulcs szerint." + ita "Valore duplicato '%-.64s' per la chiave '%-.64s'" + jpn "'%-.64s' key '%-.64s' ˤƽʣƤޤ" + kor "ߺ Է '%-.64s': key '%-.64s'" + nor "Like verdier '%-.64s' for nkkel '%-.64s'" + norwegian-ny "Like verdiar '%-.64s' for nykkel '%-.64s'" + pol "Powtrzone wyst?pienie '%-.64s' dla klucza '%-.64s'" + por "Entrada '%-.64s' duplicada para a chave '%-.64s'" + rum "Cimpul '%-.64s' e duplicat pentru cheia '%-.64s'" + rus " '%-.64s' '%-.64s'" + serbian "Dupliran unos '%-.64s' za klju '%-.64s'" + slo "Opakovan k '%-.64s' (slo ka '%-.64s')" + spa "Entrada duplicada '%-.64s' para la clave '%-.64s'" + swe "Dubbel nyckel '%-.64s' fr nyckel '%-.64s'" + ukr " '%-.64s' '%-.64s'" ER_BINLOG_PURGE_EMFILE eng "Too many files opened, please execute the command again" ger "Zu viele offene Dateien, bitte fhren Sie den Befehl noch einmal aus" diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 35a5547a730..c2be1b55b7f 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -6820,7 +6820,7 @@ copy_data_between_tables(TABLE *from,TABLE *to, uint key_nr= to->file->get_dup_key(error); if ((int) key_nr >= 0) { - const char *err_msg= ER(ER_DUP_ENTRY); + const char *err_msg= ER(ER_DUP_ENTRY_WITH_KEY_NAME); if (key_nr == 0 && (to->key_info[0].key_part[0].field->flags & AUTO_INCREMENT_FLAG)) diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 9952a4f534b..370efff201b 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -24,8 +24,6 @@ #include "sp_head.h" #include "sql_trigger.h" -static bool safe_update_on_fly(JOIN_TAB *join_tab); - /* Return 0 if row hasn't changed */ static bool compare_record(TABLE *table) @@ -1160,30 +1158,74 @@ int multi_update::prepare(List ¬_used_values, for (i=0 ; i < table_count ; i++) set_if_bigger(max_fields, fields_for_table[i]->elements); copy_field= new Copy_field[max_fields]; - - /* - Mark all copies of tables that are updates to ensure that - init_read_record() will not try to enable a cache on them - - The problem is that for queries like - - UPDATE t1, t1 AS t2 SET t1.b=t2.c WHERE t1.a=t2.a; - - the row buffer may contain things that doesn't match what is on disk - which will cause an error when reading a row. - (This issue is mostly relevent for MyISAM tables) - */ - for (table_ref= leaves; table_ref; table_ref= table_ref->next_leaf) - { - TABLE *table=table_ref->table; - if ((tables_to_update & table->map) && - unique_table(thd, table_ref, update_tables)) - table->no_cache= 1; // Disable row cache - } DBUG_RETURN(thd->is_fatal_error != 0); } +/* + Check if table is safe to update on fly + + SYNOPSIS + safe_update_on_fly() + thd Thread handler + join_tab How table is used in join + all_tables List of tables + + NOTES + We can update the first table in join on the fly if we know that + a row in this table will never be read twice. This is true under + the following conditions: + + - We are doing a table scan and the data is in a separate file (MyISAM) or + if we don't update a clustered key. + + - We are doing a range scan and we don't update the scan key or + the primary key for a clustered table handler. + + - Table is not joined to itself. + + This function gets information about fields to be updated from + the TABLE::write_set bitmap. + + WARNING + This code is a bit dependent of how make_join_readinfo() works. + + RETURN + 0 Not safe to update + 1 Safe to update +*/ + +static bool safe_update_on_fly(THD *thd, JOIN_TAB *join_tab, + TABLE_LIST *table_ref, TABLE_LIST *all_tables) +{ + TABLE *table= join_tab->table; + if (unique_table(thd, table_ref, all_tables)) + return 0; + switch (join_tab->type) { + case JT_SYSTEM: + case JT_CONST: + case JT_EQ_REF: + return TRUE; // At most one matching row + case JT_REF: + case JT_REF_OR_NULL: + return !is_key_used(table, join_tab->ref.key, table->write_set); + case JT_ALL: + /* If range search on index */ + if (join_tab->quick) + return !join_tab->quick->is_keys_used(table->write_set); + /* If scanning in clustered key */ + if ((table->file->ha_table_flags() & HA_PRIMARY_KEY_IN_READ_INDEX) && + table->s->primary_key < MAX_KEY) + return !is_key_used(table, table->s->primary_key, table->write_set); + return TRUE; + default: + break; // Avoid compler warning + } + return FALSE; + +} + + /* Initialize table for multi table @@ -1220,7 +1262,7 @@ multi_update::initialize_tables(JOIN *join) table->file->extra(HA_EXTRA_IGNORE_DUP_KEY); if (table == main_table) // First table in join { - if (safe_update_on_fly(join->join_tab)) + if (safe_update_on_fly(thd, join->join_tab, table_ref, all_tables)) { table_to_update= main_table; // Update table on the fly continue; @@ -1272,61 +1314,6 @@ multi_update::initialize_tables(JOIN *join) DBUG_RETURN(0); } -/* - Check if table is safe to update on fly - - SYNOPSIS - safe_update_on_fly - join_tab How table is used in join - - NOTES - We can update the first table in join on the fly if we know that - a row in this table will never be read twice. This is true under - the following conditions: - - - We are doing a table scan and the data is in a separate file (MyISAM) or - if we don't update a clustered key. - - - We are doing a range scan and we don't update the scan key or - the primary key for a clustered table handler. - - This function gets information about fields to be updated from - the TABLE::write_set bitmap. - - WARNING - This code is a bit dependent of how make_join_readinfo() works. - - RETURN - 0 Not safe to update - 1 Safe to update -*/ - -static bool safe_update_on_fly(JOIN_TAB *join_tab) -{ - TABLE *table= join_tab->table; - switch (join_tab->type) { - case JT_SYSTEM: - case JT_CONST: - case JT_EQ_REF: - return TRUE; // At most one matching row - case JT_REF: - case JT_REF_OR_NULL: - return !is_key_used(table, join_tab->ref.key, table->write_set); - case JT_ALL: - /* If range search on index */ - if (join_tab->quick) - return !join_tab->quick->is_keys_used(table->write_set); - /* If scanning in clustered key */ - if ((table->file->ha_table_flags() & HA_PRIMARY_KEY_IN_READ_INDEX) && - table->s->primary_key < MAX_KEY) - return !is_key_used(table, table->s->primary_key, table->write_set); - return TRUE; - default: - break; // Avoid compler warning - } - return FALSE; -} - multi_update::~multi_update() { diff --git a/sql/table.cc b/sql/table.cc index d4289aa1dd3..cf2eb1705a5 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -780,6 +780,8 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, memcpy(comment_pos, disk_buff+read_length-com_length, com_length); fix_type_pointers(&interval_array, &share->fieldnames, 1, &names); + if (share->fieldnames.count != share->fields) + goto err; fix_type_pointers(&interval_array, share->intervals, interval_count, &names); diff --git a/storage/myisam/mi_create.c b/storage/myisam/mi_create.c index 83f899dbbda..2b8cbcc7da5 100644 --- a/storage/myisam/mi_create.c +++ b/storage/myisam/mi_create.c @@ -850,18 +850,19 @@ uint mi_get_pointer_length(ulonglong file_length, uint def) if (file_length) /* If not default */ { #ifdef NOT_YET_READY_FOR_8_BYTE_POINTERS - if (file_length >= (longlong) 1 << 56) + if (file_length >= ULL(1) << 56) def=8; + else #endif - if (file_length >= (longlong) 1 << 48) + if (file_length >= ULL(1) << 48) def=7; - if (file_length >= (longlong) 1 << 40) + else if (file_length >= ULL(1) << 40) def=6; - else if (file_length >= (longlong) 1 << 32) + else if (file_length >= ULL(1) << 32) def=5; - else if (file_length >= (1L << 24)) + else if (file_length >= ULL(1) << 24) def=4; - else if (file_length >= (1L << 16)) + else if (file_length >= ULL(1) << 16) def=3; else def=2; diff --git a/storage/myisam/mi_dynrec.c b/storage/myisam/mi_dynrec.c index cae8f5b448c..642efbd4389 100644 --- a/storage/myisam/mi_dynrec.c +++ b/storage/myisam/mi_dynrec.c @@ -254,7 +254,7 @@ int _mi_write_blob_record(MI_INFO *info, const byte *record) #endif if (!(rec_buff=(byte*) my_alloca(reclength))) { - my_errno=ENOMEM; + my_errno= HA_ERR_OUT_OF_MEM; /* purecov: inspected */ return(-1); } reclength2= _mi_rec_pack(info,rec_buff+ALIGN_SIZE(MI_MAX_DYN_BLOCK_HEADER), @@ -288,7 +288,7 @@ int _mi_update_blob_record(MI_INFO *info, my_off_t pos, const byte *record) #endif if (!(rec_buff=(byte*) my_alloca(reclength))) { - my_errno=ENOMEM; + my_errno= HA_ERR_OUT_OF_MEM; /* purecov: inspected */ return(-1); } reclength=_mi_rec_pack(info,rec_buff+ALIGN_SIZE(MI_MAX_DYN_BLOCK_HEADER), diff --git a/storage/myisam/mi_locking.c b/storage/myisam/mi_locking.c index 44aa02f6431..e822ea9e6da 100644 --- a/storage/myisam/mi_locking.c +++ b/storage/myisam/mi_locking.c @@ -338,6 +338,15 @@ void mi_update_status(void* param) } } + +void mi_restore_status(void *param) +{ + MI_INFO *info= (MI_INFO*) param; + info->state= &info->s->state.state; + info->append_insert_at_end= 0; +} + + void mi_copy_status(void* to,void *from) { ((MI_INFO*) to)->state= &((MI_INFO*) from)->save_state; diff --git a/storage/myisam/mi_open.c b/storage/myisam/mi_open.c index 7b08ddf27cc..afed5d05963 100644 --- a/storage/myisam/mi_open.c +++ b/storage/myisam/mi_open.c @@ -334,7 +334,13 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) for (j=0 ; j < share->keyinfo[i].keysegs; j++,pos++) { disk_pos=mi_keyseg_read(disk_pos, pos); - + if (pos->flag & HA_BLOB_PART && + ! (share->options & (HA_OPTION_COMPRESS_RECORD | + HA_OPTION_PACK_RECORD))) + { + my_errno= HA_ERR_CRASHED; + goto err; + } if (pos->type == HA_KEYTYPE_TEXT || pos->type == HA_KEYTYPE_VARTEXT1 || pos->type == HA_KEYTYPE_VARTEXT2) @@ -453,6 +459,13 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) offset+=share->rec[i].length; } share->rec[i].type=(int) FIELD_LAST; /* End marker */ + if (offset > share->base.reclength) + { + /* purecov: begin inspected */ + my_errno= HA_ERR_CRASHED; + goto err; + /* purecov: end */ + } if (! lock_error) { @@ -518,6 +531,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) share->lock.get_status=mi_get_status; share->lock.copy_status=mi_copy_status; share->lock.update_status=mi_update_status; + share->lock.restore_status= mi_restore_status; share->lock.check_status=mi_check_status; } } diff --git a/storage/myisam/mi_update.c b/storage/myisam/mi_update.c index b35c27d75ad..bea457d2e9a 100644 --- a/storage/myisam/mi_update.c +++ b/storage/myisam/mi_update.c @@ -196,7 +196,8 @@ err: save_errno=my_errno; if (changed) key_changed|= HA_STATE_CHANGED; - if (my_errno == HA_ERR_FOUND_DUPP_KEY || my_errno == HA_ERR_RECORD_FILE_FULL) + if (my_errno == HA_ERR_FOUND_DUPP_KEY || my_errno == HA_ERR_OUT_OF_MEM || + my_errno == HA_ERR_RECORD_FILE_FULL) { info->errkey= (int) i; flag=0; diff --git a/storage/myisam/mi_write.c b/storage/myisam/mi_write.c index 184270a0364..57c054f2de8 100644 --- a/storage/myisam/mi_write.c +++ b/storage/myisam/mi_write.c @@ -180,7 +180,7 @@ int mi_write(MI_INFO *info, byte *record) err: save_errno=my_errno; if (my_errno == HA_ERR_FOUND_DUPP_KEY || my_errno == HA_ERR_RECORD_FILE_FULL || - my_errno == HA_ERR_NULL_IN_SPATIAL) + my_errno == HA_ERR_NULL_IN_SPATIAL || my_errno == HA_ERR_OUT_OF_MEM) { if (info->bulk_insert) { diff --git a/storage/myisam/myisamdef.h b/storage/myisam/myisamdef.h index a9cf4163c9e..dceccd10ae2 100644 --- a/storage/myisam/myisamdef.h +++ b/storage/myisam/myisamdef.h @@ -753,6 +753,7 @@ int mi_unique_comp(MI_UNIQUEDEF *def, const byte *a, const byte *b, my_bool null_are_equal); void mi_get_status(void* param, int concurrent_insert); void mi_update_status(void* param); +void mi_restore_status(void* param); void mi_copy_status(void* to,void *from); my_bool mi_check_status(void* param); void mi_disable_non_unique_index(MI_INFO *info, ha_rows rows); diff --git a/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp b/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp index fe10cf133c2..828ba51bc21 100644 --- a/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp +++ b/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp @@ -562,6 +562,7 @@ NdbEventOperationImpl::execute_nolock() // add kernel reference // removed on TE_STOP, TE_CLUSTER_FAILURE, or error below m_ref_count++; + m_node_bit_mask.set(0u); DBUG_PRINT("info", ("m_ref_count: %u for op: %p", m_ref_count, this)); int r= NdbDictionaryImpl::getImpl(*myDict).executeSubscribeEvent(*this); if (r == 0) { @@ -594,6 +595,7 @@ NdbEventOperationImpl::execute_nolock() // remove kernel reference // added above m_ref_count--; + m_node_bit_mask.clear(0u); DBUG_PRINT("info", ("m_ref_count: %u for op: %p", m_ref_count, this)); m_state= EO_ERROR; mi_type= 0; @@ -1810,6 +1812,7 @@ NdbEventBuffer::insertDataL(NdbEventOperationImpl *op, op->m_ref_count, op, SubTableData::getNdbdNodeId(ri))); break; case NdbDictionary::Event::_TE_ACTIVE: + DBUG_ASSERT(op->m_node_bit_mask.get(0u) != 0); op->m_node_bit_mask.set(SubTableData::getNdbdNodeId(ri)); // internal event, do not relay to user DBUG_PRINT("info", @@ -1818,7 +1821,7 @@ NdbEventBuffer::insertDataL(NdbEventOperationImpl *op, DBUG_RETURN_EVENT(0); break; case NdbDictionary::Event::_TE_CLUSTER_FAILURE: - if (!op->m_node_bit_mask.isclear()) + if (op->m_node_bit_mask.get(0)) { op->m_node_bit_mask.clear(); DBUG_ASSERT(op->m_ref_count > 0); @@ -1838,8 +1841,14 @@ NdbEventBuffer::insertDataL(NdbEventOperationImpl *op, op->theMainOp->m_ref_count, op->theMainOp)); } } + else + { + DBUG_ASSERT(op->m_node_bit_mask.isclear() != 0); + } break; case NdbDictionary::Event::_TE_STOP: + DBUG_ASSERT(op->m_node_bit_mask.get(0u) != 0); + op->m_node_bit_mask.clear(0u); op->m_node_bit_mask.clear(SubTableData::getNdbdNodeId(ri)); if (op->m_node_bit_mask.isclear()) { @@ -1860,6 +1869,10 @@ NdbEventBuffer::insertDataL(NdbEventOperationImpl *op, op->theMainOp->m_ref_count, op->theMainOp)); } } + else + { + op->m_node_bit_mask.set(0u); + } break; default: break; @@ -2599,6 +2612,8 @@ EventBufData_list::add_gci_op(Gci_op g) this, old_list)); delete [] old_list; } + else + assert(old_list == 0); DBUG_PRINT_EVENT("info", ("this: %p new m_gci_op_list: %p", this, m_gci_op_list)); m_gci_op_alloc = n; diff --git a/storage/ndb/src/ndbapi/NdbEventOperationImpl.hpp b/storage/ndb/src/ndbapi/NdbEventOperationImpl.hpp index 04a62b91002..6d58688fa88 100644 --- a/storage/ndb/src/ndbapi/NdbEventOperationImpl.hpp +++ b/storage/ndb/src/ndbapi/NdbEventOperationImpl.hpp @@ -421,6 +421,8 @@ public: when m_node_bit_mask becomes clear, the kernel reference is removed from m_ref_count + + node id 0 is used to denote that cluster has a reference */ Bitmask<(unsigned int)_NDB_NODE_BITMASK_SIZE> m_node_bit_mask;