MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:gni Date:April 16 2007 7:15am
Subject:bk commit into 5.1 tree (gni:1.2491) BUG#18676
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of root. When root 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@stripped, 2007-04-16 15:15:47+08:00, gni@stripped +6 -0
  BUG#18676 In order to coincide with 5.0 mysqld error code after bug#18676, Map the 4009 ndb error code to 157 mysql error code 

  mysql-test/r/ndb_autodiscover.result@stripped, 2007-04-16 15:15:44+08:00, gni@stripped +1 -1
    changes ndbd error code 4009 to mysqld error code 157 when no cluster connection

  sql/ha_ndbcluster.cc@stripped, 2007-04-16 15:15:44+08:00, gni@stripped +3 -3
    define return codes to ndbcluster_table_exists_in_engine to something useful

  sql/handler.cc@stripped, 2007-04-16 15:15:44+08:00, gni@stripped +18 -13
    define return codes to ha_table_exists_in_engine to something useful

  sql/sql_plugin.cc@stripped, 2007-04-16 15:15:44+08:00, gni@stripped +1 -0
    Add a comment

  sql/sql_table.cc@stripped, 2007-04-16 15:15:44+08:00, gni@stripped +17 -7
    clearly define what happens on create table if exists/not exists/not connected to engine

  storage/ndb/src/ndbapi/ndberror.c@stripped, 2007-04-16 15:15:44+08:00, gni@stripped +1 -1
    map 4009 ndb error code to 157 mysqld error code

# 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:	gni
# Host:	dev3-221.dev.cn.tlan
# Root:	/home/ngb/mysql/mysql-5.1/bug18676

--- 1.300/sql/handler.cc	2007-04-16 15:15:55 +08:00
+++ 1.301/sql/handler.cc	2007-04-16 15:15:55 +08:00
@@ -2860,20 +2860,21 @@
   DBUG_RETURN(error);
 }
 
-
-/** @brief
+/*
   Ask handler if the table exists in engine
 
   RETURN
-    0                   Table does not exist
-    1                   Table exists
-    #                   Error code
+    HA_ERR_NO_SUCH_TABLE     Table does not exist
+    HA_ERR_TABLE_EXIST       Table exists
+    #                        Error code
+
+ */
 
-*/
 struct st_table_exists_in_engine_args
 {
   const char *db;
   const char *name;
+  int err;
 };
 
 static my_bool table_exists_in_engine_handlerton(THD *thd, st_plugin_int *plugin,
@@ -2882,23 +2883,27 @@
   st_table_exists_in_engine_args *vargs= (st_table_exists_in_engine_args *)arg;
   handlerton *hton= (handlerton *)plugin->data;
 
+  int err= HA_ERR_NO_SUCH_TABLE;
+
   if (hton->state == SHOW_OPTION_YES && hton->table_exists_in_engine)
-    if ((hton->table_exists_in_engine(hton, thd, vargs->db, vargs->name)) == 1)
-      return TRUE;
+    err = hton->table_exists_in_engine(hton, thd, vargs->db, vargs->name);
+
+  vargs->err = err;
+  if (vargs->err == HA_ERR_TABLE_EXIST)
+    return TRUE;
 
   return FALSE;
 }
 
 int ha_table_exists_in_engine(THD* thd, const char* db, const char* name)
 {
-  int error= 0;
   DBUG_ENTER("ha_table_exists_in_engine");
   DBUG_PRINT("enter", ("db: %s, name: %s", db, name));
-  st_table_exists_in_engine_args args= {db, name};
-  error= plugin_foreach(thd, table_exists_in_engine_handlerton,
+  st_table_exists_in_engine_args args= {db, name, HA_ERR_NO_SUCH_TABLE};
+  plugin_foreach(thd, table_exists_in_engine_handlerton,
                  MYSQL_STORAGE_ENGINE_PLUGIN, &args);
-  DBUG_PRINT("exit", ("error: %d", error));
-  DBUG_RETURN(error);
+  DBUG_PRINT("exit", ("error: %d", args.err));
+  DBUG_RETURN(args.err);
 }
 
 #ifdef HAVE_NDB_BINLOG

--- 1.396/sql/sql_table.cc	2007-04-16 15:15:55 +08:00
+++ 1.397/sql/sql_table.cc	2007-04-16 15:15:55 +08:00
@@ -3481,15 +3481,25 @@
   {
     bool create_if_not_exists =
       create_info->options & HA_LEX_CREATE_IF_NOT_EXISTS;
-
-    if (ha_table_exists_in_engine(thd, db, table_name))
+    int retcode = ha_table_exists_in_engine(thd, db, table_name);
+    DBUG_PRINT("info", ("exists_in_engine: %u",retcode));
+    switch (retcode)
     {
-      DBUG_PRINT("info", ("Table with same name already existed in handler"));
+      case HA_ERR_NO_SUCH_TABLE:
+        /* Normal case, no table exists. we can go and create it */
+        break;
+      case HA_ERR_TABLE_EXIST:
+        DBUG_PRINT("info", ("Table existed in handler"));
 
-      if (create_if_not_exists)
-        goto warn;
-      my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name);
-      goto unlock_and_end;
+        if (create_if_not_exists)
+          goto warn;
+        my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name);
+        goto unlock_and_end;
+        break;
+      default:
+        DBUG_PRINT("info", ("error: %u from storage engine", retcode));
+        my_error(retcode, MYF(0),table_name);
+        goto unlock_and_end;
     }
   }
 

--- 1.31/mysql-test/r/ndb_autodiscover.result	2007-04-16 15:15:55 +08:00
+++ 1.32/mysql-test/r/ndb_autodiscover.result	2007-04-16 15:15:55 +08:00
@@ -382,7 +382,7 @@
 select * from t1;
 a
 select * from t1;
-ERROR HY000: Can't lock file (errno: 4009)
+ERROR HY000: Can't lock file (errno: 157)
 use test;
 drop database test_only_ndb_tables;
 CREATE TABLE t9 (

--- 1.425/sql/ha_ndbcluster.cc	2007-04-16 15:15:55 +08:00
+++ 1.426/sql/ha_ndbcluster.cc	2007-04-16 15:15:55 +08:00
@@ -6244,9 +6244,9 @@
     if (my_strcasecmp(system_charset_info, elmt.name, name))
       continue;
     DBUG_PRINT("info", ("Found table"));
-    DBUG_RETURN(1);
+    DBUG_RETURN(HA_ERR_TABLE_EXIST);
   }
-  DBUG_RETURN(0);
+  DBUG_RETURN(HA_ERR_NO_SUCH_TABLE);
 }
 
 
@@ -6608,7 +6608,7 @@
     DBUG_PRINT("info", ("%s existed on disk", name));     
     // The .ndb file exists on disk, but it's not in list of tables in ndb
     // Verify that handler agrees table is gone.
-    if (ndbcluster_table_exists_in_engine(hton, thd, db, file_name) == 0)    
+    if (ndbcluster_table_exists_in_engine(hton, thd, db, file_name) == HA_ERR_NO_SUCH_TABLE)    
     {
       DBUG_PRINT("info", ("NDB says %s does not exists", file_name));     
       it.remove();

--- 1.44/sql/sql_plugin.cc	2007-04-16 15:15:55 +08:00
+++ 1.45/sql/sql_plugin.cc	2007-04-16 15:15:55 +08:00
@@ -1009,6 +1009,7 @@
       rw_unlock(&THR_LOCK_plugin);
     }
     plugin= plugins[idx];
+    /* It will stop iterating on first engine error when "func" returns TRUE */
     if (plugin && func(thd, plugin, arg))
         goto err;
   }

--- 1.87/storage/ndb/src/ndbapi/ndberror.c	2007-04-16 15:15:55 +08:00
+++ 1.88/storage/ndb/src/ndbapi/ndberror.c	2007-04-16 15:15:55 +08:00
@@ -151,7 +151,7 @@
    */
   { 4007, DMEC, UR, "Send to ndbd node failed" },
   { 4008, DMEC, UR, "Receive from NDB failed" },
-  { 4009, DMEC, UR, "Cluster Failure" },
+  { 4009, HA_ERR_NO_CONNECTION, UR, "Cluster Failure" },
   { 4012, DMEC, UR, 
     "Request ndbd time-out, maybe due to high load or communication problems"}, 
   { 4013, DMEC, UR, "Request timed out in waiting for node failure"}, 
Thread
bk commit into 5.1 tree (gni:1.2491) BUG#18676gni16 Apr