diff --git a/dbcon/mysql/ha_calpont.cpp b/dbcon/mysql/ha_calpont.cpp index 6d29d8035..5f42d6d69 100755 --- a/dbcon/mysql/ha_calpont.cpp +++ b/dbcon/mysql/ha_calpont.cpp @@ -159,28 +159,26 @@ static uchar* calpont_get_key(INFINIDB_SHARE *share, size_t *length, int calpont_discover(handlerton *hton, THD* thd, TABLE_SHARE *share) { DBUG_ENTER("calpont_discover"); - DBUG_PRINT("calpont_discover", ("db: '%s' name: '%s'", share->db.str, - share->table_name.str)); + DBUG_PRINT("calpont_discover", ("db: '%s' name: '%s'", share->db.str, share->table_name.str)); #ifdef INFINIDB_DEBUG fprintf(stderr, "calpont_discover()\n"); #endif - uchar* frm_data = NULL; - size_t frm_len = 0; - int error = 0; + uchar* frm_data = NULL; + size_t frm_len = 0; + int error = 0; + if (!ha_calpont_impl_discover_existence(share->db.str, share->table_name.str)) + DBUG_RETURN(HA_ERR_NO_SUCH_TABLE); - if (!ha_calpont_impl_discover_existence(share->db.str, share->table_name.str)) - DBUG_RETURN(HA_ERR_NO_SUCH_TABLE); - - error = share->read_frm_image((const uchar**)&frm_data, &frm_len); + error = share->read_frm_image((const uchar**)&frm_data, &frm_len); if (error) - DBUG_RETURN(HA_ERR_NO_SUCH_TABLE); + DBUG_RETURN(HA_ERR_NO_SUCH_TABLE); my_errno= share->init_from_binary_frm_image(thd, 1, frm_data, frm_len); - my_free(frm_data); + my_free(frm_data); DBUG_RETURN(my_errno); } @@ -215,7 +213,7 @@ static int calpont_init_func(void *p) calpont_hton->state= SHOW_OPTION_YES; calpont_hton->create= calpont_create_handler; calpont_hton->flags= HTON_CAN_RECREATE; -// calpont_hton->discover_table= calpont_discover; + calpont_hton->discover_table= calpont_discover; calpont_hton->discover_table_existence= calpont_discover_existence; calpont_hton->commit= calpont_commit; calpont_hton->rollback= calpont_rollback; @@ -1030,7 +1028,7 @@ int ha_calpont::create(const char *name, TABLE *table_arg, DBUG_ENTER("ha_calpont::create"); int rc = ha_calpont_impl_create(name, table_arg, create_info); - + table_arg->s->write_frm_image(); DBUG_RETURN(rc); } diff --git a/dbcon/mysql/ha_calpont_ddl.cpp b/dbcon/mysql/ha_calpont_ddl.cpp index 8e0bfba21..a7f05cb91 100755 --- a/dbcon/mysql/ha_calpont_ddl.cpp +++ b/dbcon/mysql/ha_calpont_ddl.cpp @@ -2094,13 +2094,14 @@ int ha_calpont_impl_create_(const char *name, TABLE *table_arg, HA_CREATE_INFO * return rc; } -int ha_calpont_impl_delete_table_(const char *name, cal_connection_info& ci) +int ha_calpont_impl_delete_table_(const char *db, const char *name, cal_connection_info& ci) { #ifdef INFINIDB_DEBUG - cout << "ha_calpont_impl_delete_table: " << name << endl; + cout << "ha_calpont_impl_delete_table: " << db << name << endl; #endif THD *thd = current_thd; std::string tbl(name); + std::string schema(db); std::string stmt(idb_mysql_query_str(thd)); algorithm::to_upper(stmt); // @bug 4158 allow table name with 'restrict' in it (but not by itself) @@ -2124,12 +2125,10 @@ int ha_calpont_impl_delete_table_(const char *name, cal_connection_info& ci) return 1; } - TABLE_LIST *first_table= (TABLE_LIST*) thd->lex->select_lex.table_list.first; - string db = first_table->table->s->db.str; string emsg; stmt = idb_mysql_query_str(thd); stmt += ";"; - int rc = ProcessDDLStatement(stmt, db, tbl, tid2sid(thd->thread_id), emsg); + int rc = ProcessDDLStatement(stmt, schema, tbl, tid2sid(thd->thread_id), emsg); if (rc != 0) push_warning(thd, Sql_condition::WARN_LEVEL_NOTE, 9999, emsg.c_str()); return rc; diff --git a/dbcon/mysql/ha_calpont_impl.cpp b/dbcon/mysql/ha_calpont_impl.cpp index 3f912e55f..c2d8221f6 100755 --- a/dbcon/mysql/ha_calpont_impl.cpp +++ b/dbcon/mysql/ha_calpont_impl.cpp @@ -3180,10 +3180,6 @@ int ha_calpont_impl_delete_table(const char *name) setError(thd, ER_INTERNAL_ERROR, "Null table pointer detected when dropping table"); return 1; } - if (!(first_table->table && first_table->table->s && first_table->table->s->db.str)) - return 0; - - string db = first_table->table->s->db.str; if (!ci) return 0; @@ -3193,7 +3189,7 @@ int ha_calpont_impl_delete_table(const char *name) return 0; } // @bug 1793. make vtable droppable in calpontsys. "$vtable" ==> "@0024vtable" passed in as name. - if (db == "calpontsys" && string(name).find("@0024vtable") == string::npos) + if (strcmp(first_table->db, "calpontsys") == 0 && string(name).find("@0024vtable") == string::npos) { std::string stmt(idb_mysql_query_str(thd)); algorithm::to_upper(stmt); @@ -3206,7 +3202,7 @@ int ha_calpont_impl_delete_table(const char *name) return 1; } - int rc = ha_calpont_impl_delete_table_(name, *ci); + int rc = ha_calpont_impl_delete_table_(first_table->db, name, *ci); return rc; } int ha_calpont_impl_write_row(uchar *buf, TABLE* table) diff --git a/dbcon/mysql/ha_calpont_impl.h b/dbcon/mysql/ha_calpont_impl.h index 93ae91094..8e03f7806 100644 --- a/dbcon/mysql/ha_calpont_impl.h +++ b/dbcon/mysql/ha_calpont_impl.h @@ -60,7 +60,7 @@ extern int ha_calpont_impl_write_last_batch(TABLE* table, cal_impl_if::cal_conne extern int ha_calpont_impl_commit_ (handlerton *hton, THD *thd, bool all, cal_impl_if::cal_connection_info& ci); extern int ha_calpont_impl_rollback_ (handlerton *hton, THD *thd, bool all, cal_impl_if::cal_connection_info& ci); extern int ha_calpont_impl_close_connection_ (handlerton *hton, THD *thd, cal_impl_if::cal_connection_info& ci); -extern int ha_calpont_impl_delete_table_(const char *name, cal_impl_if::cal_connection_info& ci); +extern int ha_calpont_impl_delete_table_(const char *db, const char *name, cal_impl_if::cal_connection_info& ci); extern int ha_calpont_impl_create_(const char *name, TABLE *table_arg, HA_CREATE_INFO *create_info, cal_impl_if::cal_connection_info& ci); extern std::string ha_calpont_impl_markpartition_ (execplan::CalpontSystemCatalog::TableName tableName, uint32_t partition);