Loading mysql-test/r/ndb_alter_table.result +16 −0 Original line number Diff line number Diff line DROP TABLE IF EXISTS t1; drop database if exists mysqltest; CREATE TABLE t1 ( a INT NOT NULL, b INT NOT NULL Loading @@ -9,6 +10,21 @@ SELECT * FROM t1; a b c 9410 9412 0 DROP TABLE t1; CREATE DATABASE mysqltest; USE mysqltest; CREATE TABLE t1 ( a INT NOT NULL, b INT NOT NULL ) ENGINE=ndbcluster; RENAME TABLE t1 TO test.t1; SHOW TABLES; Tables_in_mysqltest DROP DATABASE mysqltest; USE test; SHOW TABLES; Tables_in_test t1 DROP TABLE t1; create table t1 ( col1 int not null auto_increment primary key, col2 varchar(30) not null, Loading mysql-test/t/ndb_alter_table.test +17 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ --disable_warnings DROP TABLE IF EXISTS t1; drop database if exists mysqltest; --enable_warnings # Loading @@ -20,6 +21,22 @@ SELECT * FROM t1; DROP TABLE t1; # # Verfify changing table names between databases # CREATE DATABASE mysqltest; USE mysqltest; CREATE TABLE t1 ( a INT NOT NULL, b INT NOT NULL ) ENGINE=ndbcluster; RENAME TABLE t1 TO test.t1; SHOW TABLES; DROP DATABASE mysqltest; USE test; SHOW TABLES; DROP TABLE t1; # # More advanced test # Loading ndb/include/ndbapi/NdbDictionary.hpp +7 −0 Original line number Diff line number Diff line Loading @@ -989,6 +989,13 @@ public: */ Table getTableForAlteration(const char * name); /** * Get copy a copy of a table for alteration. * @param table Table object to alter * @return table if successful. NULL if undefined */ Table getTableForAlteration(const Table &); #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL /** * Invalidate cached table object Loading ndb/src/ndbapi/NdbDictionary.cpp +6 −1 Original line number Diff line number Diff line Loading @@ -775,12 +775,17 @@ NdbDictionary::Dictionary::removeCachedTable(const char * name){ NdbDictionary::Table NdbDictionary::Dictionary::getTableForAlteration(const char * name){ const NdbDictionary::Table * oldTable = getTable(name); const Table * oldTable = getTable(name); return (oldTable) ? NdbDictionary::Table(*oldTable) : NdbDictionary::Table(); } NdbDictionary::Table NdbDictionary::Dictionary::getTableForAlteration(const Table & tab){ return NdbDictionary::Table(tab); } int NdbDictionary::Dictionary::createIndex(const Index & ind) { Loading ndb/src/ndbapi/NdbDictionaryImpl.cpp +23 −23 Original line number Diff line number Diff line Loading @@ -1411,15 +1411,14 @@ int NdbDictionaryImpl::alterTable(NdbTableImpl &impl) const char * originalInternalName = internalName.c_str(); BaseString externalName = impl.m_externalName; const char * originalExternalName = externalName.c_str(); NdbTableImpl * oldTab = getTable(originalExternalName); if(!oldTab){ DBUG_ENTER("NdbDictionaryImpl::alterTable"); if(!get_local_table_info(originalInternalName, false)){ m_error.code = 709; return -1; DBUG_RETURN(-1); } // Alter the table int ret = m_receiver.alterTable(m_ndb, impl); if(ret == 0){ // Remove cached information and let it be refreshed at next access if (m_localHash.get(originalInternalName) != NULL) { Loading @@ -1433,7 +1432,7 @@ int NdbDictionaryImpl::alterTable(NdbTableImpl &impl) m_globalHash->unlock(); } } return ret; DBUG_RETURN(ret) } int Loading @@ -1448,15 +1447,16 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb, NdbTableImpl & impl, bool alter) { DBUG_ENTER("NdbDictInterface::createOrAlterTable"); unsigned i; if((unsigned)impl.getNoOfPrimaryKeys() > NDB_MAX_NO_OF_ATTRIBUTES_IN_KEY){ m_error.code = 4317; return -1; DBUG_RETURN(-1); } unsigned sz = impl.m_columns.size(); if (sz > NDB_MAX_ATTRIBUTES_IN_TABLE){ m_error.code = 4318; return -1; DBUG_RETURN(-1); } impl.copyNewProperties(); Loading Loading @@ -1491,7 +1491,7 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb, // Check max length of frm data if (impl.m_frm.length() > MAX_FRM_DATA_SIZE){ m_error.code = 1229; return -1; DBUG_RETURN(-1); } tmpTab.FrmLen = impl.m_frm.length(); memcpy(tmpTab.FrmData, impl.m_frm.get_data(), impl.m_frm.length()); Loading Loading @@ -1543,12 +1543,12 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb, // charset is defined exactly for char types if (col->getCharType() != (col->m_cs != NULL)) { m_error.code = 703; return -1; DBUG_RETURN(-1); } // primary key type check if (col->m_pk && ! NdbSqlUtil::usable_in_pk(col->m_type, col->m_cs)) { m_error.code = 743; return -1; DBUG_RETURN(-1); } // charset in upper half of precision if (col->getCharType()) { Loading Loading @@ -1616,7 +1616,7 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb, } } } return ret; DBUG_RETURN(ret); } int Loading Loading
mysql-test/r/ndb_alter_table.result +16 −0 Original line number Diff line number Diff line DROP TABLE IF EXISTS t1; drop database if exists mysqltest; CREATE TABLE t1 ( a INT NOT NULL, b INT NOT NULL Loading @@ -9,6 +10,21 @@ SELECT * FROM t1; a b c 9410 9412 0 DROP TABLE t1; CREATE DATABASE mysqltest; USE mysqltest; CREATE TABLE t1 ( a INT NOT NULL, b INT NOT NULL ) ENGINE=ndbcluster; RENAME TABLE t1 TO test.t1; SHOW TABLES; Tables_in_mysqltest DROP DATABASE mysqltest; USE test; SHOW TABLES; Tables_in_test t1 DROP TABLE t1; create table t1 ( col1 int not null auto_increment primary key, col2 varchar(30) not null, Loading
mysql-test/t/ndb_alter_table.test +17 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ --disable_warnings DROP TABLE IF EXISTS t1; drop database if exists mysqltest; --enable_warnings # Loading @@ -20,6 +21,22 @@ SELECT * FROM t1; DROP TABLE t1; # # Verfify changing table names between databases # CREATE DATABASE mysqltest; USE mysqltest; CREATE TABLE t1 ( a INT NOT NULL, b INT NOT NULL ) ENGINE=ndbcluster; RENAME TABLE t1 TO test.t1; SHOW TABLES; DROP DATABASE mysqltest; USE test; SHOW TABLES; DROP TABLE t1; # # More advanced test # Loading
ndb/include/ndbapi/NdbDictionary.hpp +7 −0 Original line number Diff line number Diff line Loading @@ -989,6 +989,13 @@ public: */ Table getTableForAlteration(const char * name); /** * Get copy a copy of a table for alteration. * @param table Table object to alter * @return table if successful. NULL if undefined */ Table getTableForAlteration(const Table &); #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL /** * Invalidate cached table object Loading
ndb/src/ndbapi/NdbDictionary.cpp +6 −1 Original line number Diff line number Diff line Loading @@ -775,12 +775,17 @@ NdbDictionary::Dictionary::removeCachedTable(const char * name){ NdbDictionary::Table NdbDictionary::Dictionary::getTableForAlteration(const char * name){ const NdbDictionary::Table * oldTable = getTable(name); const Table * oldTable = getTable(name); return (oldTable) ? NdbDictionary::Table(*oldTable) : NdbDictionary::Table(); } NdbDictionary::Table NdbDictionary::Dictionary::getTableForAlteration(const Table & tab){ return NdbDictionary::Table(tab); } int NdbDictionary::Dictionary::createIndex(const Index & ind) { Loading
ndb/src/ndbapi/NdbDictionaryImpl.cpp +23 −23 Original line number Diff line number Diff line Loading @@ -1411,15 +1411,14 @@ int NdbDictionaryImpl::alterTable(NdbTableImpl &impl) const char * originalInternalName = internalName.c_str(); BaseString externalName = impl.m_externalName; const char * originalExternalName = externalName.c_str(); NdbTableImpl * oldTab = getTable(originalExternalName); if(!oldTab){ DBUG_ENTER("NdbDictionaryImpl::alterTable"); if(!get_local_table_info(originalInternalName, false)){ m_error.code = 709; return -1; DBUG_RETURN(-1); } // Alter the table int ret = m_receiver.alterTable(m_ndb, impl); if(ret == 0){ // Remove cached information and let it be refreshed at next access if (m_localHash.get(originalInternalName) != NULL) { Loading @@ -1433,7 +1432,7 @@ int NdbDictionaryImpl::alterTable(NdbTableImpl &impl) m_globalHash->unlock(); } } return ret; DBUG_RETURN(ret) } int Loading @@ -1448,15 +1447,16 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb, NdbTableImpl & impl, bool alter) { DBUG_ENTER("NdbDictInterface::createOrAlterTable"); unsigned i; if((unsigned)impl.getNoOfPrimaryKeys() > NDB_MAX_NO_OF_ATTRIBUTES_IN_KEY){ m_error.code = 4317; return -1; DBUG_RETURN(-1); } unsigned sz = impl.m_columns.size(); if (sz > NDB_MAX_ATTRIBUTES_IN_TABLE){ m_error.code = 4318; return -1; DBUG_RETURN(-1); } impl.copyNewProperties(); Loading Loading @@ -1491,7 +1491,7 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb, // Check max length of frm data if (impl.m_frm.length() > MAX_FRM_DATA_SIZE){ m_error.code = 1229; return -1; DBUG_RETURN(-1); } tmpTab.FrmLen = impl.m_frm.length(); memcpy(tmpTab.FrmData, impl.m_frm.get_data(), impl.m_frm.length()); Loading Loading @@ -1543,12 +1543,12 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb, // charset is defined exactly for char types if (col->getCharType() != (col->m_cs != NULL)) { m_error.code = 703; return -1; DBUG_RETURN(-1); } // primary key type check if (col->m_pk && ! NdbSqlUtil::usable_in_pk(col->m_type, col->m_cs)) { m_error.code = 743; return -1; DBUG_RETURN(-1); } // charset in upper half of precision if (col->getCharType()) { Loading Loading @@ -1616,7 +1616,7 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb, } } } return ret; DBUG_RETURN(ret); } int Loading