summaryrefslogtreecommitdiff
path: root/ndb
diff options
context:
space:
mode:
Diffstat (limited to 'ndb')
-rw-r--r--ndb/include/ndbapi/NdbDictionary.hpp7
-rw-r--r--ndb/src/ndbapi/NdbDictionary.cpp7
-rw-r--r--ndb/src/ndbapi/NdbDictionaryImpl.cpp46
3 files changed, 36 insertions, 24 deletions
diff --git a/ndb/include/ndbapi/NdbDictionary.hpp b/ndb/include/ndbapi/NdbDictionary.hpp
index a3115076624..e07fc64f064 100644
--- a/ndb/include/ndbapi/NdbDictionary.hpp
+++ b/ndb/include/ndbapi/NdbDictionary.hpp
@@ -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
diff --git a/ndb/src/ndbapi/NdbDictionary.cpp b/ndb/src/ndbapi/NdbDictionary.cpp
index 09d15c7f962..d1827c6895f 100644
--- a/ndb/src/ndbapi/NdbDictionary.cpp
+++ b/ndb/src/ndbapi/NdbDictionary.cpp
@@ -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)
{
diff --git a/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/ndb/src/ndbapi/NdbDictionaryImpl.cpp
index 345f2caac89..393a436ff85 100644
--- a/ndb/src/ndbapi/NdbDictionaryImpl.cpp
+++ b/ndb/src/ndbapi/NdbDictionaryImpl.cpp
@@ -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) {
@@ -1433,7 +1432,7 @@ int NdbDictionaryImpl::alterTable(NdbTableImpl &impl)
m_globalHash->unlock();
}
}
- return ret;
+ DBUG_RETURN(ret)
}
int
@@ -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();
@@ -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());
@@ -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()) {
@@ -1616,7 +1616,7 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb,
}
}
}
- return ret;
+ DBUG_RETURN(ret);
}
int
@@ -1675,17 +1675,17 @@ NdbDictInterface::alterTable(NdbApiSignal* signal, LinearSectionPtr ptr[3])
int errCodes[noErrCodes] =
{AlterTableRef::NotMaster,
AlterTableRef::Busy};
- int r = dictSignal(signal,ptr,1,
- 1/*use masternode id*/,
- 100,WAIT_ALTER_TAB_REQ,
- WAITFOR_RESPONSE_TIMEOUT,
- errCodes, noErrCodes);
- if(m_error.code == AlterTableRef::InvalidTableVersion) {
- // Clear caches and try again
- return INCOMPATIBLE_VERSION;
- }
-
- return r;
+ int r = dictSignal(signal,ptr,1,
+ 1/*use masternode id*/,
+ 100,WAIT_ALTER_TAB_REQ,
+ WAITFOR_RESPONSE_TIMEOUT,
+ errCodes, noErrCodes);
+ if(m_error.code == AlterTableRef::InvalidTableVersion) {
+ // Clear caches and try again
+ return INCOMPATIBLE_VERSION;
+ }
+
+ return r;
}
void