mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 20:42:30 +01:00
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
This commit is contained in:
parent
57c68b1abe
commit
4ddf45b19c
3 changed files with 18 additions and 17 deletions
|
@ -439,7 +439,7 @@ t1 CREATE TABLE `t1` (
|
|||
`a14` blob,
|
||||
PRIMARY KEY (`a1`),
|
||||
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 a13;
|
||||
ALTER TABLE test.t1 DROP a12;
|
||||
|
@ -459,7 +459,7 @@ t1 CREATE TABLE `t1` (
|
|||
`a4` bit(1) DEFAULT NULL,
|
||||
`a5` tinyint(4) DEFAULT NULL,
|
||||
KEY `a3_i` (`a3`)
|
||||
) ENGINE=ndbcluster DEFAULT CHARSET=latin1
|
||||
) /*!50100 TABLESPACE ts STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1
|
||||
DROP TABLE test.t1;
|
||||
ALTER TABLESPACE ts
|
||||
DROP DATAFILE './table_space/datafile.dat'
|
||||
|
|
|
@ -4734,6 +4734,7 @@ int ha_ndbcluster::create(const char *name,
|
|||
const void *data, *pack_data;
|
||||
bool create_from_engine= (info->table_options & HA_OPTION_CREATE_FROM_ENGINE);
|
||||
bool is_truncate= (thd->lex->sql_command == SQLCOM_TRUNCATE);
|
||||
char tablespace[FN_LEN];
|
||||
|
||||
DBUG_ENTER("ha_ndbcluster::create");
|
||||
DBUG_PRINT("enter", ("name: %s", name));
|
||||
|
@ -4742,8 +4743,22 @@ int ha_ndbcluster::create(const char *name,
|
|||
set_dbname(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)
|
||||
{
|
||||
{
|
||||
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"));
|
||||
if ((my_errno= delete_table(name)))
|
||||
DBUG_RETURN(my_errno);
|
||||
|
@ -4903,12 +4918,7 @@ int ha_ndbcluster::create(const char *name,
|
|||
DBUG_RETURN(my_errno);
|
||||
}
|
||||
|
||||
if ((my_errno= check_ndb_connection()))
|
||||
DBUG_RETURN(my_errno);
|
||||
|
||||
// Create the table in NDB
|
||||
Ndb *ndb= get_ndb();
|
||||
NDBDICT *dict= ndb->getDictionary();
|
||||
if (dict->createTable(tab) != 0)
|
||||
{
|
||||
const NdbError err= dict->getNdbError();
|
||||
|
@ -8309,15 +8319,6 @@ ha_ndbcluster::setup_recattr(const NdbRecAttr* curr)
|
|||
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*
|
||||
ha_ndbcluster::update_table_comment(
|
||||
/* out: table comment + additional */
|
||||
|
@ -10016,6 +10017,7 @@ char* ha_ndbcluster::get_tablespace_name(THD *thd, char* name, uint name_len)
|
|||
ndberr= ndbdict->getNdbError();
|
||||
if(ndberr.classification != NdbError::NoError)
|
||||
goto err;
|
||||
DBUG_PRINT("info", ("Found tablespace '%s'", ts.getName()));
|
||||
if (name)
|
||||
{
|
||||
strxnmov(name, name_len, ts.getName(), NullS);
|
||||
|
|
|
@ -884,7 +884,6 @@ private:
|
|||
ulonglong *nb_reserved_values);
|
||||
bool uses_blob_value();
|
||||
|
||||
void update_create_info(HA_CREATE_INFO *create_info);
|
||||
char *update_table_comment(const char * comment);
|
||||
|
||||
int write_ndb_file(const char *name);
|
||||
|
|
Loading…
Reference in a new issue