BUG#18676 In order to coincide with 5.0 mysqld error code after bug#18676, Map...

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 
parent 888fcd6f
...@@ -382,7 +382,7 @@ create table t1 (a int primary key) engine=ndb; ...@@ -382,7 +382,7 @@ create table t1 (a int primary key) engine=ndb;
select * from t1; select * from t1;
a a
select * from t1; select * from t1;
ERROR HY000: Can't lock file (errno: 4009) ERROR HY000: Can't lock file (errno: 157)
use test; use test;
drop database test_only_ndb_tables; drop database test_only_ndb_tables;
CREATE TABLE t9 ( CREATE TABLE t9 (
......
...@@ -6244,9 +6244,9 @@ int ndbcluster_table_exists_in_engine(handlerton *hton, THD* thd, ...@@ -6244,9 +6244,9 @@ int ndbcluster_table_exists_in_engine(handlerton *hton, THD* thd,
if (my_strcasecmp(system_charset_info, elmt.name, name)) if (my_strcasecmp(system_charset_info, elmt.name, name))
continue; continue;
DBUG_PRINT("info", ("Found table")); 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 @@ int ndbcluster_find_files(handlerton *hton, THD *thd, ...@@ -6608,7 +6608,7 @@ int ndbcluster_find_files(handlerton *hton, THD *thd,
DBUG_PRINT("info", ("%s existed on disk", name)); DBUG_PRINT("info", ("%s existed on disk", name));
// The .ndb file exists on disk, but it's not in list of tables in ndb // The .ndb file exists on disk, but it's not in list of tables in ndb
// Verify that handler agrees table is gone. // 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)); DBUG_PRINT("info", ("NDB says %s does not exists", file_name));
it.remove(); it.remove();
......
...@@ -2860,20 +2860,21 @@ ha_find_files(THD *thd,const char *db,const char *path, ...@@ -2860,20 +2860,21 @@ ha_find_files(THD *thd,const char *db,const char *path,
DBUG_RETURN(error); DBUG_RETURN(error);
} }
/*
/** @brief
Ask handler if the table exists in engine Ask handler if the table exists in engine
RETURN RETURN
0 Table does not exist HA_ERR_NO_SUCH_TABLE Table does not exist
1 Table exists HA_ERR_TABLE_EXIST Table exists
# Error code # Error code
*/ */
struct st_table_exists_in_engine_args struct st_table_exists_in_engine_args
{ {
const char *db; const char *db;
const char *name; const char *name;
int err;
}; };
static my_bool table_exists_in_engine_handlerton(THD *thd, st_plugin_int *plugin, static my_bool table_exists_in_engine_handlerton(THD *thd, st_plugin_int *plugin,
...@@ -2882,8 +2883,13 @@ static my_bool table_exists_in_engine_handlerton(THD *thd, st_plugin_int *plugin ...@@ -2882,8 +2883,13 @@ static my_bool table_exists_in_engine_handlerton(THD *thd, st_plugin_int *plugin
st_table_exists_in_engine_args *vargs= (st_table_exists_in_engine_args *)arg; st_table_exists_in_engine_args *vargs= (st_table_exists_in_engine_args *)arg;
handlerton *hton= (handlerton *)plugin->data; 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->state == SHOW_OPTION_YES && hton->table_exists_in_engine)
if ((hton->table_exists_in_engine(hton, thd, vargs->db, vargs->name)) == 1) 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 TRUE;
return FALSE; return FALSE;
...@@ -2891,14 +2897,13 @@ static my_bool table_exists_in_engine_handlerton(THD *thd, st_plugin_int *plugin ...@@ -2891,14 +2897,13 @@ static my_bool table_exists_in_engine_handlerton(THD *thd, st_plugin_int *plugin
int ha_table_exists_in_engine(THD* thd, const char* db, const char* name) 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_ENTER("ha_table_exists_in_engine");
DBUG_PRINT("enter", ("db: %s, name: %s", db, name)); DBUG_PRINT("enter", ("db: %s, name: %s", db, name));
st_table_exists_in_engine_args args= {db, name}; st_table_exists_in_engine_args args= {db, name, HA_ERR_NO_SUCH_TABLE};
error= plugin_foreach(thd, table_exists_in_engine_handlerton, plugin_foreach(thd, table_exists_in_engine_handlerton,
MYSQL_STORAGE_ENGINE_PLUGIN, &args); MYSQL_STORAGE_ENGINE_PLUGIN, &args);
DBUG_PRINT("exit", ("error: %d", error)); DBUG_PRINT("exit", ("error: %d", args.err));
DBUG_RETURN(error); DBUG_RETURN(args.err);
} }
#ifdef HAVE_NDB_BINLOG #ifdef HAVE_NDB_BINLOG
......
...@@ -1009,6 +1009,7 @@ my_bool plugin_foreach_with_mask(THD *thd, plugin_foreach_func *func, ...@@ -1009,6 +1009,7 @@ my_bool plugin_foreach_with_mask(THD *thd, plugin_foreach_func *func,
rw_unlock(&THR_LOCK_plugin); rw_unlock(&THR_LOCK_plugin);
} }
plugin= plugins[idx]; plugin= plugins[idx];
/* It will stop iterating on first engine error when "func" returns TRUE */
if (plugin && func(thd, plugin, arg)) if (plugin && func(thd, plugin, arg))
goto err; goto err;
} }
......
...@@ -3481,15 +3481,25 @@ bool mysql_create_table_internal(THD *thd, ...@@ -3481,15 +3481,25 @@ bool mysql_create_table_internal(THD *thd,
{ {
bool create_if_not_exists = bool create_if_not_exists =
create_info->options & HA_LEX_CREATE_IF_NOT_EXISTS; create_info->options & HA_LEX_CREATE_IF_NOT_EXISTS;
int retcode = ha_table_exists_in_engine(thd, db, table_name);
if (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) if (create_if_not_exists)
goto warn; goto warn;
my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name); my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name);
goto unlock_and_end; 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;
} }
} }
......
...@@ -151,7 +151,7 @@ ErrorBundle ErrorCodes[] = { ...@@ -151,7 +151,7 @@ ErrorBundle ErrorCodes[] = {
*/ */
{ 4007, DMEC, UR, "Send to ndbd node failed" }, { 4007, DMEC, UR, "Send to ndbd node failed" },
{ 4008, DMEC, UR, "Receive from NDB failed" }, { 4008, DMEC, UR, "Receive from NDB failed" },
{ 4009, DMEC, UR, "Cluster Failure" }, { 4009, HA_ERR_NO_CONNECTION, UR, "Cluster Failure" },
{ 4012, DMEC, UR, { 4012, DMEC, UR,
"Request ndbd time-out, maybe due to high load or communication problems"}, "Request ndbd time-out, maybe due to high load or communication problems"},
{ 4013, DMEC, UR, "Request timed out in waiting for node failure"}, { 4013, DMEC, UR, "Request timed out in waiting for node failure"},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment