List:Internals« Previous MessageNext Message »
From:Osku Salerma Date:September 14 2005 7:46am
Subject:bk commit into 5.0 tree (osku:1.1950)
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of osku. When osku does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.1950 05/09/14 10:46:13 osku@127.(none) +7 -0
  Merge 127.(none):/home/osku/mysql/5.0/clean
  into  127.(none):/home/osku/mysql/5.0/fkem

  sql/sql_table.cc
    1.273 05/09/14 10:45:58 osku@127.(none) +0 -0
    Auto merged

  sql/sql_parse.cc
    1.486 05/09/14 10:45:57 osku@127.(none) +0 -0
    Auto merged

  sql/sql_class.h
    1.265 05/09/14 10:45:56 osku@127.(none) +0 -0
    Auto merged

  sql/sql_class.cc
    1.211 05/09/14 10:45:56 osku@127.(none) +0 -0
    Auto merged

  sql/handler.cc
    1.188 05/09/14 10:45:56 osku@127.(none) +0 -0
    Auto merged

  mysql-test/t/innodb.test
    1.109 05/09/14 10:45:56 osku@127.(none) +0 -0
    Auto merged

  mysql-test/r/innodb.result
    1.134 05/09/14 10:45:56 osku@127.(none) +0 -0
    Auto merged

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	osku
# Host:	127.(none)
# Root:	/home/osku/mysql/5.0/fkem/RESYNC

--- 1.187/sql/handler.cc	2005-09-14 01:41:38 +03:00
+++ 1.188/sql/handler.cc	2005-09-14 10:45:56 +03:00
@@ -310,8 +310,8 @@
   SETMSG(HA_ERR_READ_ONLY_TRANSACTION,  ER(ER_READ_ONLY_TRANSACTION));
   SETMSG(HA_ERR_LOCK_DEADLOCK,          ER(ER_LOCK_DEADLOCK));
   SETMSG(HA_ERR_CANNOT_ADD_FOREIGN,     ER(ER_CANNOT_ADD_FOREIGN));
-  SETMSG(HA_ERR_NO_REFERENCED_ROW,      ER(ER_NO_REFERENCED_ROW));
-  SETMSG(HA_ERR_ROW_IS_REFERENCED,      ER(ER_ROW_IS_REFERENCED));
+  SETMSG(HA_ERR_NO_REFERENCED_ROW,      ER(ER_NO_REFERENCED_ROW_2));
+  SETMSG(HA_ERR_ROW_IS_REFERENCED,      ER(ER_ROW_IS_REFERENCED_2));
   SETMSG(HA_ERR_NO_SAVEPOINT,           "No savepoint with that name");
   SETMSG(HA_ERR_NON_UNIQUE_BLOCK_SIZE,  "Non unique key block size");
   SETMSG(HA_ERR_NO_SUCH_TABLE,          "No such table: '%.64s'");
@@ -1703,11 +1703,11 @@
     textno=ER_CANNOT_ADD_FOREIGN;
     break;
   case HA_ERR_ROW_IS_REFERENCED:
-    textno=ER_ROW_IS_REFERENCED;
-    break;
+    my_error(ER_ROW_IS_REFERENCED_2, MYF(0), current_thd->detailed_error);
+    DBUG_VOID_RETURN;
   case HA_ERR_NO_REFERENCED_ROW:
-    textno=ER_NO_REFERENCED_ROW;
-    break;
+    my_error(ER_NO_REFERENCED_ROW_2, MYF(0), current_thd->detailed_error);
+    DBUG_VOID_RETURN;
   case HA_ERR_TABLE_DEF_CHANGED:
     textno=ER_TABLE_DEF_CHANGED;
     break;

--- 1.210/sql/sql_class.cc	2005-09-13 16:32:34 +03:00
+++ 1.211/sql/sql_class.cc	2005-09-14 10:45:56 +03:00
@@ -210,6 +210,7 @@
   db_charset= global_system_variables.collation_database;
   bzero(ha_data, sizeof(ha_data));
   mysys_var=0;
+  detailed_error[0] = '\0';
   binlog_evt_union.do_union= FALSE;
 #ifndef DBUG_OFF
   dbug_sentry=THD_SENTRY_MAGIC;

--- 1.264/sql/sql_class.h	2005-09-13 16:32:35 +03:00
+++ 1.265/sql/sql_class.h	2005-09-14 10:45:56 +03:00
@@ -1175,6 +1175,12 @@
   thr_lock_type update_lock_default;
   delayed_insert *di;
 
+  /* Table handlers can store detailed error messages in this that are
+     added to the normal error message. That needs special-case code in
+     handler::print_error for all error codes that want to do this. It's
+     valid for this to be empty. */
+  char detailed_error[ERRMSGSIZE + 20];
+
   /* <> 0 if we are inside of trigger or stored function. */
   uint in_sub_stmt;
 

--- 1.485/sql/sql_parse.cc	2005-09-13 13:51:21 +03:00
+++ 1.486/sql/sql_parse.cc	2005-09-14 10:45:57 +03:00
@@ -2299,7 +2299,9 @@
   SELECT_LEX_UNIT *unit= &lex->unit;
   /* Saved variable value */
   DBUG_ENTER("mysql_execute_command");
+
   thd->net.no_send_error= 0;
+  thd->detailed_error[0] = '\0';
 
   /*
     In many cases first table of main SELECT_LEX have special meaning =>

--- 1.272/sql/sql_table.cc	2005-09-14 01:44:02 +03:00
+++ 1.273/sql/sql_table.cc	2005-09-14 10:45:58 +03:00
@@ -309,7 +309,7 @@
       my_printf_error(ER_BAD_TABLE_ERROR, ER(ER_BAD_TABLE_ERROR), MYF(0),
                       wrong_tables.c_ptr());
     else
-      my_message(ER_ROW_IS_REFERENCED, ER(ER_ROW_IS_REFERENCED), MYF(0));
+      my_error(ER_ROW_IS_REFERENCED_2, MYF(0), thd->detailed_error);
     error= 1;
   }
 
@@ -3481,7 +3481,7 @@
   if (lower_case_table_names)
     my_casedn_str(files_charset_info, tmp_name);
   if (new_db_type != old_db_type && !table->file->can_switch_engines()) {
-    my_error(ER_ROW_IS_REFERENCED, MYF(0));
+    my_error(ER_ROW_IS_REFERENCED_2, MYF(0), "");
     goto err;
   }
   create_info->db_type=new_db_type;

--- 1.133/mysql-test/r/innodb.result	2005-09-13 01:44:44 +03:00
+++ 1.134/mysql-test/r/innodb.result	2005-09-14 10:45:56 +03:00
@@ -1378,9 +1378,9 @@
 create table `t3` (`id` int( 11 ) not null default '0',key `id` ( `id` ) ,constraint `t2_id_fk` foreign key ( `id` ) references `t2` (`id` )) engine = innodb;
 insert into `t3`values ( 1 ) ;
 delete t3,t2,t1 from t1,t2,t3 where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
-ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test/t2`, CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`))
 update t1,t2,t3 set t3.id=5, t2.id=6, t1.id=7  where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
-ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test/t2`, CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`))
 update t3 set  t3.id=7  where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
 ERROR 42S22: Unknown column 't1.id' in 'where clause'
 drop table t3,t2,t1;
@@ -1392,7 +1392,7 @@
 insert into t1 values(0,0),(1,0),(2,1),(3,2),(4,3),(5,4),(6,5),(7,6),
 (8,7),(9,8),(10,9),(11,10),(12,11),(13,12),(14,13),(15,14);
 delete from t1 where id=0;
-ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test/t1`, CONSTRAINT `t1_ibfk_1` FOREIGN KEY (`pid`) REFERENCES `t1` (`id`) ON DELETE CASCADE)
 delete from t1 where id=15;
 delete from t1 where id=0;
 drop table t1;
@@ -2550,3 +2550,26 @@
 ) ENGINE=InnoDB;
 Got one of the listed errors
 DROP TABLE t1;
+CREATE TABLE t1
+(
+id INT PRIMARY KEY
+) ENGINE=InnoDB;
+CREATE TABLE t2
+(
+v INT,
+CONSTRAINT c1 FOREIGN KEY (v) REFERENCES t1(id)
+) ENGINE=InnoDB;
+INSERT INTO t2 VALUES(2);
+ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test/t2`, CONSTRAINT `c1` FOREIGN KEY (`v`) REFERENCES `t1` (`id`))
+INSERT INTO t1 VALUES(1);
+INSERT INTO t2 VALUES(1);
+DELETE FROM t1 WHERE id = 1;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test/t2`, CONSTRAINT `c1` FOREIGN KEY (`v`) REFERENCES `t1` (`id`))
+DROP TABLE t1;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails ()
+SET FOREIGN_KEY_CHECKS=0;
+DROP TABLE t1;
+SET FOREIGN_KEY_CHECKS=1;
+INSERT INTO t2 VALUES(3);
+ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test/t2`, CONSTRAINT `c1` FOREIGN KEY (`v`) REFERENCES `t1` (`id`))
+DROP TABLE t2;

--- 1.108/mysql-test/t/innodb.test	2005-09-14 01:41:37 +03:00
+++ 1.109/mysql-test/t/innodb.test	2005-09-14 10:45:56 +03:00
@@ -978,9 +978,9 @@
 insert into `t2`values ( 1 ) ;
 create table `t3` (`id` int( 11 ) not null default '0',key `id` ( `id` ) ,constraint `t2_id_fk` foreign key ( `id` ) references `t2` (`id` )) engine = innodb;
 insert into `t3`values ( 1 ) ;
---error 1217
+--error 1445
 delete t3,t2,t1 from t1,t2,t3 where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
---error 1217
+--error 1445
 update t1,t2,t3 set t3.id=5, t2.id=6, t1.id=7  where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
 --error 1054
 update t3 set  t3.id=7  where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
@@ -996,7 +996,7 @@
 	foreign key(pid) references t1(id) on delete cascade) engine=innodb;
 insert into t1 values(0,0),(1,0),(2,1),(3,2),(4,3),(5,4),(6,5),(7,6),
 	(8,7),(9,8),(10,9),(11,10),(12,11),(13,12),(14,13),(15,14);
--- error 1217
+-- error 1445
 delete from t1 where id=0;
 delete from t1 where id=15;
 delete from t1 where id=0;
@@ -1473,3 +1473,39 @@
  FOREIGN KEY (b) REFERENCES test.t1(id)
 ) ENGINE=InnoDB;
 DROP TABLE t1;
+
+#
+# Test improved foreign key error messages (bug #3443)
+#
+
+CREATE TABLE t1
+(
+ id INT PRIMARY KEY
+) ENGINE=InnoDB;
+
+CREATE TABLE t2
+(
+ v INT,
+ CONSTRAINT c1 FOREIGN KEY (v) REFERENCES t1(id)
+) ENGINE=InnoDB;
+
+--error 1446
+INSERT INTO t2 VALUES(2);
+
+INSERT INTO t1 VALUES(1);
+INSERT INTO t2 VALUES(1);
+
+--error 1445
+DELETE FROM t1 WHERE id = 1;
+
+--error 1445
+DROP TABLE t1;
+
+SET FOREIGN_KEY_CHECKS=0;
+DROP TABLE t1;
+SET FOREIGN_KEY_CHECKS=1;
+
+--error 1446
+INSERT INTO t2 VALUES(3);
+
+DROP TABLE t2;
Thread
bk commit into 5.0 tree (osku:1.1950)Osku Salerma14 Sep