Commit 44271d49 authored by unknown's avatar unknown

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 


mysql-test/r/ndb_autodiscover.result:
  changes ndbd error code 4009 to mysqld error code 157 when no cluster connection
sql/ha_ndbcluster.cc:
  define return codes to ndbcluster_table_exists_in_engine to something useful
sql/handler.cc:
  define return codes to ha_table_exists_in_engine to something useful
sql/sql_plugin.cc:
  Add a comment
sql/sql_table.cc:
  clearly define what happens on create table if exists/not exists/not connected to engine
storage/ndb/src/ndbapi/ndberror.c:
  map 4009 ndb error code to 157 mysqld error code
parent ee58034f
......@@ -382,7 +382,7 @@ create table t1 (a int primary key) engine=ndb;
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 (
......
......@@ -6244,9 +6244,9 @@ int ndbcluster_table_exists_in_engine(handlerton *hton, THD* thd,
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 @@ int ndbcluster_find_files(handlerton *hton, THD *thd,
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();
......
......@@ -2860,20 +2860,21 @@ ha_find_files(THD *thd,const char *db,const char *path,
DBUG_RETURN(error);
}
/** @brief
/*
Ask handler if the table exists in engine
RETURN
0 Table does not exist
1 Table exists
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,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;
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)
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;
......@@ -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 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
......
......@@ -1009,6 +1009,7 @@ my_bool plugin_foreach_with_mask(THD *thd, plugin_foreach_func *func,
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;
}
......
......@@ -3481,15 +3481,25 @@ bool mysql_create_table_internal(THD *thd,
{
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;
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[] = {
*/
{ 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"},
......
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