BUG10365 Cluster handler uses non-standard error code

  - Updated after review
parent 8771c732
...@@ -4300,7 +4300,7 @@ int ndbcluster_discover(THD* thd, const char *db, const char *name, ...@@ -4300,7 +4300,7 @@ int ndbcluster_discover(THD* thd, const char *db, const char *name,
{ {
const NdbError err= dict->getNdbError(); const NdbError err= dict->getNdbError();
if (err.code == 709) if (err.code == 709)
DBUG_RETURN(1); DBUG_RETURN(-1);
ERR_RETURN(err); ERR_RETURN(err);
} }
DBUG_PRINT("info", ("Found table %s", tab->getName())); DBUG_PRINT("info", ("Found table %s", tab->getName()));
......
...@@ -1340,8 +1340,9 @@ int ha_create_table(const char *name, HA_CREATE_INFO *create_info, ...@@ -1340,8 +1340,9 @@ int ha_create_table(const char *name, HA_CREATE_INFO *create_info,
if found, write the frm file to disk. if found, write the frm file to disk.
RETURN VALUES: RETURN VALUES:
-1 : Table did not exists
0 : Table created ok 0 : Table created ok
1 : Table could not be created > 0 : Error, table existed but could not be created
*/ */
...@@ -1361,10 +1362,10 @@ int ha_create_table_from_engine(THD* thd, ...@@ -1361,10 +1362,10 @@ int ha_create_table_from_engine(THD* thd,
bzero((char*) &create_info,sizeof(create_info)); bzero((char*) &create_info,sizeof(create_info));
if(ha_discover(thd, db, name, &frmblob, &frmlen)) if(error= ha_discover(thd, db, name, &frmblob, &frmlen))
{ {
// Table could not be discovered and thus not created // Table could not be discovered and thus not created
DBUG_RETURN(1); DBUG_RETURN(error);
} }
/* /*
...@@ -1377,11 +1378,11 @@ int ha_create_table_from_engine(THD* thd, ...@@ -1377,11 +1378,11 @@ int ha_create_table_from_engine(THD* thd,
if (writefrm(path, frmblob, frmlen)) if (writefrm(path, frmblob, frmlen))
{ {
my_free((char*) frmblob, MYF(MY_ALLOW_ZERO_PTR)); my_free((char*) frmblob, MYF(MY_ALLOW_ZERO_PTR));
DBUG_RETURN(1); DBUG_RETURN(2);
} }
if (openfrm(path,"",0,(uint) READ_ALL, 0, &table)) if (openfrm(path,"",0,(uint) READ_ALL, 0, &table))
DBUG_RETURN(1); DBUG_RETURN(3);
update_create_info_from_table(&create_info, &table); update_create_info_from_table(&create_info, &table);
create_info.table_options|= HA_CREATE_FROM_ENGINE; create_info.table_options|= HA_CREATE_FROM_ENGINE;
...@@ -1506,14 +1507,15 @@ int ha_change_key_cache(KEY_CACHE *old_key_cache, ...@@ -1506,14 +1507,15 @@ int ha_change_key_cache(KEY_CACHE *old_key_cache,
Try to discover one table from handler(s) Try to discover one table from handler(s)
RETURN RETURN
0 ok. In this case *frmblob and *frmlen are set -1 : Table did not exists
>=1 error. frmblob and frmlen may not be set 0 : OK. In this case *frmblob and *frmlen are set
>0 : error. frmblob and frmlen may not be set
*/ */
int ha_discover(THD *thd, const char *db, const char *name, int ha_discover(THD *thd, const char *db, const char *name,
const void **frmblob, uint *frmlen) const void **frmblob, uint *frmlen)
{ {
int error= 1; // Table does not exist in any handler int error= -1; // Table does not exist in any handler
DBUG_ENTER("ha_discover"); DBUG_ENTER("ha_discover");
DBUG_PRINT("enter", ("db: %s, name: %s", db, name)); DBUG_PRINT("enter", ("db: %s, name: %s", db, name));
#ifdef HAVE_NDBCLUSTER_DB #ifdef HAVE_NDBCLUSTER_DB
......
...@@ -1376,8 +1376,7 @@ static int open_unireg_entry(THD *thd, TABLE *entry, const char *db, ...@@ -1376,8 +1376,7 @@ static int open_unireg_entry(THD *thd, TABLE *entry, const char *db,
*/ */
if (discover_retry_count++ != 0) if (discover_retry_count++ != 0)
goto err; goto err;
if (ha_table_exists_in_engine(thd, db, name) && if (ha_create_table_from_engine(thd, db, name) > 0)
ha_create_table_from_engine(thd, db, name))
{ {
/* Give right error message */ /* Give right error message */
thd->clear_error(); thd->clear_error();
......
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