Commit 4f0fe5ce authored by unknown's avatar unknown

Fixes for push version of discover of on-line altered table

parent 20ed4de5
...@@ -1320,11 +1320,16 @@ ndb_handle_schema_change(THD *thd, Ndb *ndb, NdbEventOperation *pOp, ...@@ -1320,11 +1320,16 @@ ndb_handle_schema_change(THD *thd, Ndb *ndb, NdbEventOperation *pOp,
Invalidate table and all it's indexes Invalidate table and all it's indexes
*/ */
ndb->setDatabaseName(share->table->s->db.str); ndb->setDatabaseName(share->table->s->db.str);
Thd_ndb *thd_ndb= get_thd_ndb(thd);
DBUG_ASSERT(thd_ndb != NULL);
Ndb* old_ndb= thd_ndb->ndb;
thd_ndb->ndb= ndb;
ha_ndbcluster table_handler(table_share); ha_ndbcluster table_handler(table_share);
table_handler.set_dbname(share->key); table_handler.set_dbname(share->key);
table_handler.set_tabname(share->key); table_handler.set_tabname(share->key);
table_handler.open_indexes(ndb, table, TRUE); table_handler.open_indexes(ndb, table, TRUE);
table_handler.invalidate_dictionary_cache(TRUE); table_handler.invalidate_dictionary_cache(TRUE);
thd_ndb->ndb= old_ndb;
if (online_alter_table) if (online_alter_table)
{ {
...@@ -1349,7 +1354,10 @@ ndb_handle_schema_change(THD *thd, Ndb *ndb, NdbEventOperation *pOp, ...@@ -1349,7 +1354,10 @@ ndb_handle_schema_change(THD *thd, Ndb *ndb, NdbEventOperation *pOp,
DBUG_DUMP("frm", (char*)altered_table->getFrmData(), DBUG_DUMP("frm", (char*)altered_table->getFrmData(),
altered_table->getFrmLength()); altered_table->getFrmLength());
pthread_mutex_lock(&LOCK_open); pthread_mutex_lock(&LOCK_open);
dict->putTable(altered_table); const NDBTAB *old= dict->getTable(tabname);
if (!old &&
old->getObjectVersion() != altered_table->getObjectVersion())
dict->putTable(altered_table);
if ((error= unpackfrm(&data, &length, altered_table->getFrmData())) || if ((error= unpackfrm(&data, &length, altered_table->getFrmData())) ||
(error= writefrm(key, data, length))) (error= writefrm(key, data, length)))
...@@ -1359,12 +1367,12 @@ ndb_handle_schema_change(THD *thd, Ndb *ndb, NdbEventOperation *pOp, ...@@ -1359,12 +1367,12 @@ ndb_handle_schema_change(THD *thd, Ndb *ndb, NdbEventOperation *pOp,
} }
pthread_mutex_unlock(&LOCK_open); pthread_mutex_unlock(&LOCK_open);
close_cached_tables((THD*) 0, 0, (TABLE_LIST*) 0); close_cached_tables((THD*) 0, 0, (TABLE_LIST*) 0);
/* pthread_mutex_lock(&LOCK_open);
if ((error= ndbcluster_binlog_open_table(thd, share, if ((error= ndbcluster_binlog_open_table(thd, share,
table_share, table))) table_share, table)))
sql_print_information("NDB: Failed to re-open table %s.%s", sql_print_information("NDB: Failed to re-open table %s.%s",
dbname, tabname); dbname, tabname);
*/ pthread_mutex_unlock(&LOCK_open);
} }
} }
remote_drop_table= 1; remote_drop_table= 1;
...@@ -2172,7 +2180,6 @@ ndbcluster_create_event_ops(NDB_SHARE *share, const NDBTAB *ndbtab, ...@@ -2172,7 +2180,6 @@ ndbcluster_create_event_ops(NDB_SHARE *share, const NDBTAB *ndbtab,
op= ndb->createEventOperation(event_name); op= ndb->createEventOperation(event_name);
// reset to catch errors // reset to catch errors
ndb->setDatabaseName(""); ndb->setDatabaseName("");
ndb->setDatabaseSchemaName("");
} }
if (!op) if (!op)
{ {
...@@ -2745,8 +2752,8 @@ pthread_handler_t ndb_binlog_thread_func(void *arg) ...@@ -2745,8 +2752,8 @@ pthread_handler_t ndb_binlog_thread_func(void *arg)
goto err; goto err;
} }
// empty database and schema // empty database
if (!(ndb= new Ndb(g_ndb_cluster_connection, "", "")) || if (!(ndb= new Ndb(g_ndb_cluster_connection, "")) ||
ndb->init()) ndb->init())
{ {
sql_print_error("NDB Binlog: Getting Ndb object failed"); sql_print_error("NDB Binlog: Getting Ndb object failed");
...@@ -3010,7 +3017,6 @@ pthread_handler_t ndb_binlog_thread_func(void *arg) ...@@ -3010,7 +3017,6 @@ pthread_handler_t ndb_binlog_thread_func(void *arg)
ndb_binlog_thread_handle_non_data_event(ndb, pOp, row); ndb_binlog_thread_handle_non_data_event(ndb, pOp, row);
// reset to catch errors // reset to catch errors
ndb->setDatabaseName(""); ndb->setDatabaseName("");
ndb->setDatabaseSchemaName("");
} }
pOp= ndb->nextEvent(); pOp= ndb->nextEvent();
......
...@@ -1310,8 +1310,10 @@ NdbDictionaryImpl::putTable(NdbTableImpl *impl) ...@@ -1310,8 +1310,10 @@ NdbDictionaryImpl::putTable(NdbTableImpl *impl)
m_globalHash->lock(); m_globalHash->lock();
if ((old= m_globalHash->get(impl->m_internalName.c_str()))) if ((old= m_globalHash->get(impl->m_internalName.c_str())))
{ {
old->m_status = NdbDictionary::Object::Invalid; m_globalHash->alter_table_rep(old->m_internalName.c_str(),
m_globalHash->drop(old); impl->m_id,
impl->m_version,
FALSE);
} }
m_globalHash->put(impl->m_internalName.c_str(), impl); m_globalHash->put(impl->m_internalName.c_str(), impl);
m_globalHash->unlock(); m_globalHash->unlock();
......
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