Loading include/my_base.h +4 −1 Original line number Diff line number Diff line Loading @@ -367,8 +367,11 @@ enum ha_base_keytype { given value */ #define HA_ERR_RBR_LOGGING_FAILED 161 /* Row-based binlogging of row failed */ #define HA_ERR_DROP_INDEX_FK 162 /* Index needed in foreign key constr. */ #define HA_ERR_FOREIGN_DUPLICATE_KEY 163 /* Upholding foreign key constraints would lead to a duplicate key error in some other table. */ #define HA_ERR_LAST 162 /* Copy last error no */ #define HA_ERR_LAST 163 /* Copy last error no */ /* Add error numbers before HA_ERR_LAST and change it accordingly. */ #define HA_ERR_ERRORS (HA_ERR_LAST - HA_ERR_FIRST + 1) Loading mysql-test/r/innodb.result +18 −0 Original line number Diff line number Diff line Loading @@ -2758,3 +2758,21 @@ e varchar(255) character set utf8, key (a,b,c,d,e)) engine=innodb; ERROR 42000: Specified key was too long; max key length is 3072 bytes End of 5.0 tests CREATE TABLE t1 ( field1 varchar(8) NOT NULL DEFAULT '', field2 varchar(8) NOT NULL DEFAULT '', PRIMARY KEY (field1, field2) ) ENGINE=InnoDB; CREATE TABLE t2 ( field1 varchar(8) NOT NULL DEFAULT '' PRIMARY KEY, FOREIGN KEY (field1) REFERENCES t1 (field1) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB; INSERT INTO t1 VALUES ('old', 'somevalu'); INSERT INTO t1 VALUES ('other', 'anyvalue'); INSERT INTO t2 VALUES ('old'); INSERT INTO t2 VALUES ('other'); UPDATE t1 SET field1 = 'other' WHERE field2 = 'somevalu'; ERROR 23000: Upholding foreign key constraints for table 't1', entry 'other-somevalu', key 1 would lead to a duplicate entry DROP TABLE t2; DROP TABLE t1; mysql-test/t/innodb.test +29 −0 Original line number Diff line number Diff line Loading @@ -1715,3 +1715,32 @@ create table t1 (a varchar(255) character set utf8, key (a,b,c,d,e)) engine=innodb; --echo End of 5.0 tests # # Test that cascading updates leading to duplicate keys give the correct # error message (bug #9680) # CREATE TABLE t1 ( field1 varchar(8) NOT NULL DEFAULT '', field2 varchar(8) NOT NULL DEFAULT '', PRIMARY KEY (field1, field2) ) ENGINE=InnoDB; CREATE TABLE t2 ( field1 varchar(8) NOT NULL DEFAULT '' PRIMARY KEY, FOREIGN KEY (field1) REFERENCES t1 (field1) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB; INSERT INTO t1 VALUES ('old', 'somevalu'); INSERT INTO t1 VALUES ('other', 'anyvalue'); INSERT INTO t2 VALUES ('old'); INSERT INTO t2 VALUES ('other'); --error ER_FOREIGN_DUPLICATE_KEY UPDATE t1 SET field1 = 'other' WHERE field2 = 'somevalu'; DROP TABLE t2; DROP TABLE t1; sql/event_executor.cc +4 −3 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ extern ulong thread_created; extern const char *my_localhost; extern pthread_attr_t connection_attrib; pthread_mutex_t LOCK_event_arrays, LOCK_workers_count, Loading @@ -41,7 +42,7 @@ bool evex_is_running= false; ulonglong evex_main_thread_id= 0; ulong opt_event_executor; volatile my_bool event_executor_running_global_var; my_bool event_executor_running_global_var; static my_bool evex_mutexes_initted= false; static uint workers_count; Loading Loading @@ -102,7 +103,7 @@ init_events() { #ifndef DBUG_FAULTY_THR //TODO Andrey: Change the error code returned! if (pthread_create(&th, NULL, event_executor_main, (void*)NULL)) if (pthread_create(&th, &connection_attrib, event_executor_main,(void*)NULL)) DBUG_RETURN(ER_SLAVE_THREAD); #else event_executor_main(NULL); Loading Loading @@ -351,7 +352,7 @@ event_executor_main(void *arg) ++iter_num; DBUG_PRINT("info", (" Spawning a thread %d", iter_num)); #ifndef DBUG_FAULTY_THR if (pthread_create(&th, NULL, event_executor_worker, (void*)et)) if (pthread_create(&th,&connection_attrib,event_executor_worker,(void*)et)) { sql_print_error("Problem while trying to create a thread"); UNLOCK_MUTEX_AND_BAIL_OUT(LOCK_event_arrays, err); Loading sql/ha_innodb.cc +4 −0 Original line number Diff line number Diff line Loading @@ -465,6 +465,10 @@ convert_error_code_to_mysql( return(HA_ERR_FOUND_DUPP_KEY); } else if (error == (int) DB_FOREIGN_DUPLICATE_KEY) { return(HA_ERR_FOREIGN_DUPLICATE_KEY); } else if (error == (int) DB_RECORD_NOT_FOUND) { return(HA_ERR_NO_ACTIVE_RECORD); Loading Loading
include/my_base.h +4 −1 Original line number Diff line number Diff line Loading @@ -367,8 +367,11 @@ enum ha_base_keytype { given value */ #define HA_ERR_RBR_LOGGING_FAILED 161 /* Row-based binlogging of row failed */ #define HA_ERR_DROP_INDEX_FK 162 /* Index needed in foreign key constr. */ #define HA_ERR_FOREIGN_DUPLICATE_KEY 163 /* Upholding foreign key constraints would lead to a duplicate key error in some other table. */ #define HA_ERR_LAST 162 /* Copy last error no */ #define HA_ERR_LAST 163 /* Copy last error no */ /* Add error numbers before HA_ERR_LAST and change it accordingly. */ #define HA_ERR_ERRORS (HA_ERR_LAST - HA_ERR_FIRST + 1) Loading
mysql-test/r/innodb.result +18 −0 Original line number Diff line number Diff line Loading @@ -2758,3 +2758,21 @@ e varchar(255) character set utf8, key (a,b,c,d,e)) engine=innodb; ERROR 42000: Specified key was too long; max key length is 3072 bytes End of 5.0 tests CREATE TABLE t1 ( field1 varchar(8) NOT NULL DEFAULT '', field2 varchar(8) NOT NULL DEFAULT '', PRIMARY KEY (field1, field2) ) ENGINE=InnoDB; CREATE TABLE t2 ( field1 varchar(8) NOT NULL DEFAULT '' PRIMARY KEY, FOREIGN KEY (field1) REFERENCES t1 (field1) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB; INSERT INTO t1 VALUES ('old', 'somevalu'); INSERT INTO t1 VALUES ('other', 'anyvalue'); INSERT INTO t2 VALUES ('old'); INSERT INTO t2 VALUES ('other'); UPDATE t1 SET field1 = 'other' WHERE field2 = 'somevalu'; ERROR 23000: Upholding foreign key constraints for table 't1', entry 'other-somevalu', key 1 would lead to a duplicate entry DROP TABLE t2; DROP TABLE t1;
mysql-test/t/innodb.test +29 −0 Original line number Diff line number Diff line Loading @@ -1715,3 +1715,32 @@ create table t1 (a varchar(255) character set utf8, key (a,b,c,d,e)) engine=innodb; --echo End of 5.0 tests # # Test that cascading updates leading to duplicate keys give the correct # error message (bug #9680) # CREATE TABLE t1 ( field1 varchar(8) NOT NULL DEFAULT '', field2 varchar(8) NOT NULL DEFAULT '', PRIMARY KEY (field1, field2) ) ENGINE=InnoDB; CREATE TABLE t2 ( field1 varchar(8) NOT NULL DEFAULT '' PRIMARY KEY, FOREIGN KEY (field1) REFERENCES t1 (field1) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB; INSERT INTO t1 VALUES ('old', 'somevalu'); INSERT INTO t1 VALUES ('other', 'anyvalue'); INSERT INTO t2 VALUES ('old'); INSERT INTO t2 VALUES ('other'); --error ER_FOREIGN_DUPLICATE_KEY UPDATE t1 SET field1 = 'other' WHERE field2 = 'somevalu'; DROP TABLE t2; DROP TABLE t1;
sql/event_executor.cc +4 −3 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ extern ulong thread_created; extern const char *my_localhost; extern pthread_attr_t connection_attrib; pthread_mutex_t LOCK_event_arrays, LOCK_workers_count, Loading @@ -41,7 +42,7 @@ bool evex_is_running= false; ulonglong evex_main_thread_id= 0; ulong opt_event_executor; volatile my_bool event_executor_running_global_var; my_bool event_executor_running_global_var; static my_bool evex_mutexes_initted= false; static uint workers_count; Loading Loading @@ -102,7 +103,7 @@ init_events() { #ifndef DBUG_FAULTY_THR //TODO Andrey: Change the error code returned! if (pthread_create(&th, NULL, event_executor_main, (void*)NULL)) if (pthread_create(&th, &connection_attrib, event_executor_main,(void*)NULL)) DBUG_RETURN(ER_SLAVE_THREAD); #else event_executor_main(NULL); Loading Loading @@ -351,7 +352,7 @@ event_executor_main(void *arg) ++iter_num; DBUG_PRINT("info", (" Spawning a thread %d", iter_num)); #ifndef DBUG_FAULTY_THR if (pthread_create(&th, NULL, event_executor_worker, (void*)et)) if (pthread_create(&th,&connection_attrib,event_executor_worker,(void*)et)) { sql_print_error("Problem while trying to create a thread"); UNLOCK_MUTEX_AND_BAIL_OUT(LOCK_event_arrays, err); Loading
sql/ha_innodb.cc +4 −0 Original line number Diff line number Diff line Loading @@ -465,6 +465,10 @@ convert_error_code_to_mysql( return(HA_ERR_FOUND_DUPP_KEY); } else if (error == (int) DB_FOREIGN_DUPLICATE_KEY) { return(HA_ERR_FOREIGN_DUPLICATE_KEY); } else if (error == (int) DB_RECORD_NOT_FOUND) { return(HA_ERR_NO_ACTIVE_RECORD); Loading