From d18e5622ebacbb386b6cc8508dbdaae4216f4fa8 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 16 Jun 2005 15:17:47 +0200 Subject: 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 --- sql/handler.cc | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'sql/handler.cc') 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 -- cgit v1.2.1