summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <msvensson@neptunus.(none)>2005-06-16 15:17:47 +0200
committerunknown <msvensson@neptunus.(none)>2005-06-16 15:17:47 +0200
commitd18e5622ebacbb386b6cc8508dbdaae4216f4fa8 (patch)
tree0167e85f11763eef319b96adca16e86741dbd20f /sql
parent09944efd71a7b11de5b06e76b8019aae53d9ca36 (diff)
downloadmariadb-git-d18e5622ebacbb386b6cc8508dbdaae4216f4fa8.tar.gz
BUG10365 Cluster handler uses non-standard error code
- Updated after review sql/ha_ndbcluster.cc: Return -1 if table does not exists sql/handler.cc: Return -1 if table does not exists Return 0 if table exists and it could be created Return >0 if table existed but it could not be created. sql/sql_base.cc: Only need to call ha_create_table_from_engine and check if result is > 0. If that is the case, print error message
Diffstat (limited to 'sql')
-rw-r--r--sql/ha_ndbcluster.cc2
-rw-r--r--sql/handler.cc18
-rw-r--r--sql/sql_base.cc3
3 files changed, 12 insertions, 11 deletions
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc
index 85b7ddc4892..a7d82396eb5 100644
--- a/sql/ha_ndbcluster.cc
+++ b/sql/ha_ndbcluster.cc
@@ -4300,7 +4300,7 @@ int ndbcluster_discover(THD* thd, const char *db, const char *name,
{
const NdbError err= dict->getNdbError();
if (err.code == 709)
- DBUG_RETURN(1);
+ DBUG_RETURN(-1);
ERR_RETURN(err);
}
DBUG_PRINT("info", ("Found table %s", tab->getName()));
diff --git a/sql/handler.cc b/sql/handler.cc
index ad5cd28d932..dacfc7d9ac5 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -1340,8 +1340,9 @@ int ha_create_table(const char *name, HA_CREATE_INFO *create_info,
if found, write the frm file to disk.
RETURN VALUES:
+ -1 : Table did not exists
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,
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
- DBUG_RETURN(1);
+ DBUG_RETURN(error);
}
/*
@@ -1377,11 +1378,11 @@ int ha_create_table_from_engine(THD* thd,
if (writefrm(path, frmblob, frmlen))
{
my_free((char*) frmblob, MYF(MY_ALLOW_ZERO_PTR));
- DBUG_RETURN(1);
+ DBUG_RETURN(2);
}
if (openfrm(path,"",0,(uint) READ_ALL, 0, &table))
- DBUG_RETURN(1);
+ DBUG_RETURN(3);
update_create_info_from_table(&create_info, &table);
create_info.table_options|= HA_CREATE_FROM_ENGINE;
@@ -1506,14 +1507,15 @@ int ha_change_key_cache(KEY_CACHE *old_key_cache,
Try to discover one table from handler(s)
RETURN
- 0 ok. In this case *frmblob and *frmlen are set
- >=1 error. frmblob and frmlen may not be set
+ -1 : Table did not exists
+ 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,
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_PRINT("enter", ("db: %s, name: %s", db, name));
#ifdef HAVE_NDBCLUSTER_DB
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 0aa2f1ce4b8..d6ef08b8a7c 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -1376,8 +1376,7 @@ static int open_unireg_entry(THD *thd, TABLE *entry, const char *db,
*/
if (discover_retry_count++ != 0)
goto err;
- if (ha_table_exists_in_engine(thd, db, name) &&
- ha_create_table_from_engine(thd, db, name))
+ if (ha_create_table_from_engine(thd, db, name) > 0)
{
/* Give right error message */
thd->clear_error();