diff --git a/extra/perror.c b/extra/perror.c
index e22ce467949370a9a7ad53f8afd5594a9faaf5f5..a2951bff66a6d8432ce921009dac939f76754154 100644
--- a/extra/perror.c
+++ b/extra/perror.c
@@ -59,8 +59,10 @@ static HA_ERRORS ha_errlist[]=
   { 121,"Duplicate key on write or update" },
   { 123,"Someone has changed the row since it was read; Update with is recoverable" },
   { 124,"Wrong index given to function" },
-  { 126,"Index file is crashed / Wrong file format" },
+  { 126,"Index file is crashed" },
   { 127,"Record-file is crashed" },
+  { 128,"Out of memory" },
+  { 130,"Incorrect file format" },
   { 131,"Command not supported by database" },
   { 132,"Old database file" },
   { 133,"No record read before update" },
@@ -73,7 +75,7 @@ static HA_ERRORS ha_errlist[]=
   { 140,"Wrong create options"},
   { 141,"Duplicate unique key or constraint on write or update"},
   { 142,"Unknown character set used"},
-  { 143,"Conflicting table definition between MERGE and mapped table"},
+  { 143,"Conflicting table definitions in sub-tables of MERGE table"},
   { 144,"Table is crashed and last repair failed"},
   { 145,"Table was marked as crashed and should be repaired"},
   { 146,"Lock timed out; Retry transaction"},
@@ -81,6 +83,8 @@ static HA_ERRORS ha_errlist[]=
   { 148,"Updates are not allowed under a read only transactions"},
   { 149,"Lock deadlock; Retry transaction"},
   { 150,"Foreign key constraint is incorrectly formed"},
+  { 151,"Cannot add a child row"},
+  { 152,"Cannot delete a parent row"},
   { -30999, "DB_INCOMPLETE: Sync didn't finish"},
   { -30998, "DB_KEYEMPTY: Key/data deleted or never created"},
   { -30997, "DB_KEYEXIST: The key/data pair already exists"},
diff --git a/include/my_base.h b/include/my_base.h
index feb5259ef0851d802676f29d1e3d54e272b68bd8..e1761eac8f9168e9750c598aaba0cfce98296113 100644
--- a/include/my_base.h
+++ b/include/my_base.h
@@ -216,6 +216,7 @@ enum ha_base_keytype {
 #define HA_ERR_CRASHED		126	/* Indexfile is crashed */
 #define HA_ERR_WRONG_IN_RECORD	127	/* Record-file is crashed */
 #define HA_ERR_OUT_OF_MEM	128	/* Record-file is crashed */
+#define HA_ERR_NOT_A_TABLE      130     /* not a MYI file - no signature */
 #define HA_ERR_WRONG_COMMAND	131	/* Command not supported */
 #define HA_ERR_OLD_FILE		132	/* old databasfile */
 #define HA_ERR_NO_ACTIVE_RECORD 133	/* No record read in update() */
@@ -228,10 +229,10 @@ enum ha_base_keytype {
 #define HA_WRONG_CREATE_OPTION	140	/* Wrong create option */
 #define HA_ERR_FOUND_DUPP_UNIQUE 141	/* Dupplicate unique on write */
 #define HA_ERR_UNKNOWN_CHARSET	 142	/* Can't open charset */
-#define HA_ERR_WRONG_TABLE_DEF	 143
+#define HA_ERR_WRONG_MRG_TABLE_DEF 143    /* conflicting MyISAM tables in MERGE */
 #define HA_ERR_CRASHED_ON_REPAIR 144	/* Last (automatic?) repair failed */
 #define HA_ERR_CRASHED_ON_USAGE  145	/* Table must be repaired */
-#define HA_ERR_LOCK_WAIT_TIMEOUT 146    
+#define HA_ERR_LOCK_WAIT_TIMEOUT 146
 #define HA_ERR_LOCK_TABLE_FULL   147
 #define HA_ERR_READ_ONLY_TRANSACTION 148 /* Updates not allowed */
 #define HA_ERR_LOCK_DEADLOCK	 149
diff --git a/myisam/mi_open.c b/myisam/mi_open.c
index 0da5ebabf40cb972d2c3ec0afad196daab337e11..077d8c7da3a150f52b9e1f34f3b065e36e99c519 100644
--- a/myisam/mi_open.c
+++ b/myisam/mi_open.c
@@ -114,7 +114,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
       DBUG_PRINT("error",("Wrong header in %s",name_buff));
       DBUG_DUMP("error_dump",(char*) share->state.header.file_version,
 		head_length);
-      my_errno=HA_ERR_WRONG_TABLE_DEF;
+      my_errno=HA_ERR_NOT_A_TABLE;
       goto err;
     }
     share->options= mi_uint2korr(share->state.header.options);
diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c
index f5bae72396ac77ed22484a772efbe1029e331315..6c541a444b7fef88b9114efe2d8d64a09f89670e 100644
--- a/myisam/myisamchk.c
+++ b/myisam/myisamchk.c
@@ -735,7 +735,7 @@ static int myisamchk(MI_CHECK *param, my_string filename)
     case HA_ERR_CRASHED:
       mi_check_print_error(param,"'%s' doesn't have a correct index definition. You need to recreate it before you can do a repair",filename);
       break;
-    case HA_ERR_WRONG_TABLE_DEF:
+    case HA_ERR_NOT_A_TABLE:
       mi_check_print_error(param,"'%s' is not a MyISAM-table",filename);
       break;
     case HA_ERR_CRASHED_ON_USAGE:
diff --git a/myisammrg/myrg_open.c b/myisammrg/myrg_open.c
index f996277d287e465da1959461a28a8af0bf4638e2..7ff00270c684d999c6a8a742110896b0d372da1b 100644
--- a/myisammrg/myrg_open.c
+++ b/myisammrg/myrg_open.c
@@ -84,7 +84,7 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking)
     last_isam=isam;
     if (info.reclength && info.reclength != isam->s->base.reclength)
     {
-      my_errno=HA_ERR_WRONG_IN_RECORD;
+      my_errno=HA_ERR_WRONG_MRG_TABLE_DEF;
       goto err;
     }
     info.reclength=isam->s->base.reclength;
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc
index caddd77fab89b3212328b6b1e617266a4d252312..f74cddbcee6f183f9468ccbcd7bad28f6d250507 100644
--- a/sql/ha_innodb.cc
+++ b/sql/ha_innodb.cc
@@ -231,7 +231,7 @@ convert_error_code_to_mysql(
 
         } else if (error == (int) DB_COL_APPEARS_TWICE_IN_INDEX) {
 
-    		return(HA_ERR_WRONG_TABLE_DEF);
+    		return(HA_ERR_CRASHED);
 
  	} else if (error == (int) DB_OUT_OF_FILE_SPACE) {
 
diff --git a/sql/ha_isam.cc b/sql/ha_isam.cc
index 6fa54d18aac9988a66c892bc10f7de0cc28b35e3..7371628890f4869912f8263e936a3a731d43739e 100644
--- a/sql/ha_isam.cc
+++ b/sql/ha_isam.cc
@@ -35,7 +35,7 @@
 *****************************************************************************/
 
 const char **ha_isam::bas_ext() const
-{ static const char *ext[]= { ".ISD",".ISM", NullS }; return ext; }
+{ static const char *ext[]= { ".ISM",".ISD", NullS }; return ext; }
 
 
 int ha_isam::open(const char *name, int mode, uint test_if_locked)
diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc
index 19e97c60dd3a3ae878b3e55b5b8f46b477187a97..81b04cf5ba7eee0c388bda3da3d879b5825620ca 100644
--- a/sql/ha_myisam.cc
+++ b/sql/ha_myisam.cc
@@ -117,7 +117,7 @@ void mi_check_print_warning(MI_CHECK *param, const char *fmt,...)
 }
 
 const char **ha_myisam::bas_ext() const
-{ static const char *ext[]= { ".MYD",".MYI", NullS }; return ext; }
+{ static const char *ext[]= { ".MYI",".MYD", NullS }; return ext; }
 
 
 const char *ha_myisam::index_type(uint key_number)
diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc
index a93d2e5ed431671227f9bedc2dfb7cbcae9fd1e2..616248b2cf300af27aeae59fb9885d1d6cca41a2 100644
--- a/sql/ha_myisammrg.cc
+++ b/sql/ha_myisammrg.cc
@@ -69,7 +69,7 @@ int ha_myisammrg::open(const char *name, int mode, uint test_if_locked)
 err:
   myrg_close(file);
   file=0;
-  return (my_errno= HA_ERR_WRONG_TABLE_DEF);
+  return (my_errno= HA_ERR_WRONG_MRG_TABLE_DEF);
 }
 
 int ha_myisammrg::close(void)
diff --git a/sql/handler.cc b/sql/handler.cc
index d4fd45613d46ab35f4d028251e8ba70816fada15..fb33888e91e904b7a676ef7ef6c8050eb97f4f31 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -679,7 +679,7 @@ void handler::print_error(int error, myf errflag)
   case HA_ERR_END_OF_FILE:
     textno=ER_KEY_NOT_FOUND;
     break;
-  case HA_ERR_WRONG_TABLE_DEF:
+  case HA_ERR_WRONG_MRG_TABLE_DEF:
     textno=ER_WRONG_MRG_TABLE;
     break;
   case HA_ERR_FOUND_DUPP_KEY: