Commit a6cbee1d authored by unknown's avatar unknown

ha_ndbcluster.h, ndb_dd_alter.result, ha_ndbcluster.cc:

  bug#25296  Truncate table converts NDB disk based tables to in-memory tables: Changed fix to use get_tablespace_name directly instead


sql/ha_ndbcluster.h:
  bug#25296  Truncate table converts NDB disk based tables to in-memory tables: Changed fix to use get_tablespace_name directly instead
mysql-test/r/ndb_dd_alter.result:
  bug#25296  Truncate table converts NDB disk based tables to in-memory tables: Changed fix to use get_tablespace_name directly instead
sql/ha_ndbcluster.cc:
  bug#25296  Truncate table converts NDB disk based tables to in-memory tables: Changed fix to use get_tablespace_name directly instead
parent 43c38958
...@@ -439,7 +439,7 @@ t1 CREATE TABLE `t1` ( ...@@ -439,7 +439,7 @@ t1 CREATE TABLE `t1` (
`a14` blob, `a14` blob,
PRIMARY KEY (`a1`), PRIMARY KEY (`a1`),
KEY `a3_i` (`a3`) KEY `a3_i` (`a3`)
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 ) /*!50100 TABLESPACE ts STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1
ALTER TABLE test.t1 DROP a14; ALTER TABLE test.t1 DROP a14;
ALTER TABLE test.t1 DROP a13; ALTER TABLE test.t1 DROP a13;
ALTER TABLE test.t1 DROP a12; ALTER TABLE test.t1 DROP a12;
...@@ -459,7 +459,7 @@ t1 CREATE TABLE `t1` ( ...@@ -459,7 +459,7 @@ t1 CREATE TABLE `t1` (
`a4` bit(1) DEFAULT NULL, `a4` bit(1) DEFAULT NULL,
`a5` tinyint(4) DEFAULT NULL, `a5` tinyint(4) DEFAULT NULL,
KEY `a3_i` (`a3`) KEY `a3_i` (`a3`)
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 ) /*!50100 TABLESPACE ts STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1
DROP TABLE test.t1; DROP TABLE test.t1;
ALTER TABLESPACE ts ALTER TABLESPACE ts
DROP DATAFILE './table_space/datafile.dat' DROP DATAFILE './table_space/datafile.dat'
......
...@@ -4734,6 +4734,7 @@ int ha_ndbcluster::create(const char *name, ...@@ -4734,6 +4734,7 @@ int ha_ndbcluster::create(const char *name,
const void *data, *pack_data; const void *data, *pack_data;
bool create_from_engine= (info->table_options & HA_OPTION_CREATE_FROM_ENGINE); bool create_from_engine= (info->table_options & HA_OPTION_CREATE_FROM_ENGINE);
bool is_truncate= (thd->lex->sql_command == SQLCOM_TRUNCATE); bool is_truncate= (thd->lex->sql_command == SQLCOM_TRUNCATE);
char tablespace[FN_LEN];
DBUG_ENTER("ha_ndbcluster::create"); DBUG_ENTER("ha_ndbcluster::create");
DBUG_PRINT("enter", ("name: %s", name)); DBUG_PRINT("enter", ("name: %s", name));
...@@ -4742,8 +4743,22 @@ int ha_ndbcluster::create(const char *name, ...@@ -4742,8 +4743,22 @@ int ha_ndbcluster::create(const char *name,
set_dbname(name); set_dbname(name);
set_tabname(name); set_tabname(name);
if ((my_errno= check_ndb_connection()))
DBUG_RETURN(my_errno);
Ndb *ndb= get_ndb();
NDBDICT *dict= ndb->getDictionary();
if (is_truncate) if (is_truncate)
{ {
{
Ndb_table_guard ndbtab_g(dict, m_tabname);
if (!(m_table= ndbtab_g.get_table()))
ERR_RETURN(dict->getNdbError());
if ((get_tablespace_name(thd, tablespace, FN_LEN)))
info->tablespace= tablespace;
m_table= NULL;
}
DBUG_PRINT("info", ("Dropping and re-creating table for TRUNCATE")); DBUG_PRINT("info", ("Dropping and re-creating table for TRUNCATE"));
if ((my_errno= delete_table(name))) if ((my_errno= delete_table(name)))
DBUG_RETURN(my_errno); DBUG_RETURN(my_errno);
...@@ -4903,12 +4918,7 @@ int ha_ndbcluster::create(const char *name, ...@@ -4903,12 +4918,7 @@ int ha_ndbcluster::create(const char *name,
DBUG_RETURN(my_errno); DBUG_RETURN(my_errno);
} }
if ((my_errno= check_ndb_connection()))
DBUG_RETURN(my_errno);
// Create the table in NDB // Create the table in NDB
Ndb *ndb= get_ndb();
NDBDICT *dict= ndb->getDictionary();
if (dict->createTable(tab) != 0) if (dict->createTable(tab) != 0)
{ {
const NdbError err= dict->getNdbError(); const NdbError err= dict->getNdbError();
...@@ -8309,15 +8319,6 @@ ha_ndbcluster::setup_recattr(const NdbRecAttr* curr) ...@@ -8309,15 +8319,6 @@ ha_ndbcluster::setup_recattr(const NdbRecAttr* curr)
DBUG_RETURN(0); DBUG_RETURN(0);
} }
void ha_ndbcluster::update_create_info(HA_CREATE_INFO *create_info)
{
THD *thd= current_thd;
if (thd->lex->sql_command == SQLCOM_TRUNCATE &&
get_tablespace_name(thd,0,0))
create_info->storage_media= HA_SM_DISK;
}
char* char*
ha_ndbcluster::update_table_comment( ha_ndbcluster::update_table_comment(
/* out: table comment + additional */ /* out: table comment + additional */
...@@ -10016,6 +10017,7 @@ char* ha_ndbcluster::get_tablespace_name(THD *thd, char* name, uint name_len) ...@@ -10016,6 +10017,7 @@ char* ha_ndbcluster::get_tablespace_name(THD *thd, char* name, uint name_len)
ndberr= ndbdict->getNdbError(); ndberr= ndbdict->getNdbError();
if(ndberr.classification != NdbError::NoError) if(ndberr.classification != NdbError::NoError)
goto err; goto err;
DBUG_PRINT("info", ("Found tablespace '%s'", ts.getName()));
if (name) if (name)
{ {
strxnmov(name, name_len, ts.getName(), NullS); strxnmov(name, name_len, ts.getName(), NullS);
......
...@@ -884,7 +884,6 @@ private: ...@@ -884,7 +884,6 @@ private:
ulonglong *nb_reserved_values); ulonglong *nb_reserved_values);
bool uses_blob_value(); bool uses_blob_value();
void update_create_info(HA_CREATE_INFO *create_info);
char *update_table_comment(const char * comment); char *update_table_comment(const char * comment);
int write_ndb_file(const char *name); int write_ndb_file(const char *name);
......
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