summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <mskold@mysql.com>2005-04-27 18:17:41 +0200
committerunknown <mskold@mysql.com>2005-04-27 18:17:41 +0200
commit27a6a8146417829d9edfcb8fb86306f985e03bd2 (patch)
tree271a87a13563c1c954f883b1f0422343d6f16a41 /sql
parentb580f8ddf509f4f1e2c28b1ed49f440de918286b (diff)
downloadmariadb-git-27a6a8146417829d9edfcb8fb86306f985e03bd2.tar.gz
Fix for avoiding gettin Invalid schema object version when doing local changes
Diffstat (limited to 'sql')
-rw-r--r--sql/ha_ndbcluster.cc54
-rw-r--r--sql/ha_ndbcluster.h4
2 files changed, 43 insertions, 15 deletions
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc
index 8c12cccf5ee..0d6bfcb9d0d 100644
--- a/sql/ha_ndbcluster.cc
+++ b/sql/ha_ndbcluster.cc
@@ -331,11 +331,14 @@ void ha_ndbcluster::no_uncommitted_rows_reset(THD *thd)
# The mapped error code
*/
-void ha_ndbcluster::invalidateDictionaryCache()
+void ha_ndbcluster::invalidate_dictionary_cache(bool global)
{
NDBDICT *dict= get_ndb()->getDictionary();
DBUG_PRINT("info", ("invalidating %s", m_tabname));
- dict->invalidateTable(m_tabname);
+ if (global)
+ dict->invalidateTable(m_tabname);
+ else
+ dict->removeCachedTable(m_tabname);
table->version=0L; /* Free when thread is ready */
/* Invalidate indexes */
for (uint i= 0; i < table->keys; i++)
@@ -347,12 +350,21 @@ void ha_ndbcluster::invalidateDictionaryCache()
switch(idx_type) {
case(PRIMARY_KEY_ORDERED_INDEX):
case(ORDERED_INDEX):
- dict->invalidateIndex(index->getName(), m_tabname);
+ if (global)
+ dict->invalidateIndex(index->getName(), m_tabname);
+ else
+ dict->removeCachedIndex(index->getName(), m_tabname);
break;
case(UNIQUE_ORDERED_INDEX):
- dict->invalidateIndex(index->getName(), m_tabname);
+ if (global)
+ dict->invalidateIndex(index->getName(), m_tabname);
+ else
+ dict->removeCachedIndex(index->getName(), m_tabname);
case(UNIQUE_INDEX):
- dict->invalidateIndex(unique_index->getName(), m_tabname);
+ if (global)
+ dict->invalidateIndex(unique_index->getName(), m_tabname);
+ else
+ dict->removeCachedIndex(unique_index->getName(), m_tabname);
break;
case(PRIMARY_KEY_INDEX):
case(UNDEFINED_INDEX):
@@ -371,7 +383,7 @@ int ha_ndbcluster::ndb_err(NdbConnection *trans)
switch (err.classification) {
case NdbError::SchemaError:
{
- invalidateDictionaryCache();
+ invalidate_dictionary_cache(TRUE);
if (err.code==284)
{
@@ -767,7 +779,13 @@ int ha_ndbcluster::get_metadata(const char *path)
if (!(tab= dict->getTable(m_tabname)))
ERR_RETURN(dict->getNdbError());
- DBUG_PRINT("info", ("Table schema version: %d", tab->getObjectVersion()));
+ if (tab->getObjectStatus() == NdbDictionary::Object::Invalid)
+ {
+ invalidate_dictionary_cache(FALSE);
+ if (!(tab= dict->getTable(m_tabname)))
+ ERR_RETURN(dict->getNdbError());
+ DBUG_PRINT("info", ("Table schema version: %d", tab->getObjectVersion()));
+ }
/*
Compare FrmData in NDB with frm file from disk.
*/
@@ -786,7 +804,7 @@ int ha_ndbcluster::get_metadata(const char *path)
if (!invalidating_ndb_table)
{
DBUG_PRINT("info", ("Invalidating table"));
- invalidateDictionaryCache();
+ invalidate_dictionary_cache(TRUE);
invalidating_ndb_table= TRUE;
}
else
@@ -812,7 +830,7 @@ int ha_ndbcluster::get_metadata(const char *path)
if (error)
DBUG_RETURN(error);
- m_tableVersion= tab->getObjectVersion();
+ m_table_version= tab->getObjectVersion();
m_table= (void *)tab;
m_table_info= NULL; // Set in external lock
@@ -3226,15 +3244,25 @@ int ha_ndbcluster::external_lock(THD *thd, int lock_type)
void *tab_info;
if (!(tab= dict->getTable(m_tabname, &tab_info)))
ERR_RETURN(dict->getNdbError());
- DBUG_PRINT("info", ("Table schema version: %d", tab->getObjectVersion()));
- if (m_table != (void *)tab || m_tableVersion != tab->getObjectVersion())
+ DBUG_PRINT("info", ("Table schema version: %d",
+ tab->getObjectVersion()));
+ // Check if thread has stale local cache
+ if (tab->getObjectStatus() == NdbDictionary::Object::Invalid)
+ {
+ invalidate_dictionary_cache(FALSE);
+ if (!(tab= dict->getTable(m_tabname)))
+ ERR_RETURN(dict->getNdbError());
+ DBUG_PRINT("info", ("Table schema version: %d",
+ tab->getObjectVersion()));
+ }
+ if (m_table != (void *)tab || m_table_version < tab->getObjectVersion())
{
/*
The table has been altered, refresh the index list
*/
build_index_list(ndb, table, ILBP_OPEN);
m_table= (void *)tab;
- m_tableVersion = tab->getObjectVersion();
+ m_table_version = tab->getObjectVersion();
}
m_table_info= tab_info;
}
@@ -4006,7 +4034,7 @@ ha_ndbcluster::ha_ndbcluster(TABLE *table_arg):
m_active_trans(NULL),
m_active_cursor(NULL),
m_table(NULL),
- m_tableVersion(-1),
+ m_table_version(-1),
m_table_info(NULL),
m_table_flags(HA_REC_NOT_IN_SEQ |
HA_NULL_IN_KEY |
diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h
index ac2d27b9ec7..7de5dd503e7 100644
--- a/sql/ha_ndbcluster.h
+++ b/sql/ha_ndbcluster.h
@@ -203,7 +203,7 @@ class ha_ndbcluster: public handler
void print_results();
longlong get_auto_increment();
- void invalidateDictionaryCache();
+ void invalidate_dictionary_cache(bool global);
int ndb_err(NdbConnection*);
bool uses_blob_value(bool all_fields);
@@ -215,7 +215,7 @@ class ha_ndbcluster: public handler
NdbConnection *m_active_trans;
NdbResultSet *m_active_cursor;
void *m_table;
- int m_tableVersion;
+ int m_table_version;
void *m_table_info;
char m_dbname[FN_HEADLEN];
//char m_schemaname[FN_HEADLEN];