mirror of
https://github.com/MariaDB/server.git
synced 2025-02-01 19:41:47 +01:00
Merge mskold@bk-internal.mysql.com:/home/bk/mysql-5.1-new
into mysql.com:/usr/local/home/marty/MySQL/mysql-5.1-new
This commit is contained in:
commit
a9123eeb13
3 changed files with 64 additions and 74 deletions
|
@ -6,17 +6,6 @@ DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7;
|
||||||
drop database if exists mysqltest;
|
drop database if exists mysqltest;
|
||||||
--enable_warnings
|
--enable_warnings
|
||||||
|
|
||||||
# workaround for bug#16445
|
|
||||||
# remove to reproduce bug and run tests drom ndb start
|
|
||||||
# and with ndb_autodiscover disabled
|
|
||||||
CREATE TABLE t1 (
|
|
||||||
pk1 INT NOT NULL PRIMARY KEY,
|
|
||||||
attr1 INT NOT NULL,
|
|
||||||
attr2 INT,
|
|
||||||
attr3 VARCHAR(10)
|
|
||||||
) ENGINE=ndbcluster;
|
|
||||||
drop table t1;
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Basic test to show that the NDB
|
# Basic test to show that the NDB
|
||||||
# table handler is working
|
# table handler is working
|
||||||
|
|
10
sql/field.cc
10
sql/field.cc
|
@ -5989,7 +5989,7 @@ int Field_str::store(double nr)
|
||||||
|
|
||||||
uint Field::is_equal(create_field *new_field)
|
uint Field::is_equal(create_field *new_field)
|
||||||
{
|
{
|
||||||
return (new_field->sql_type == type());
|
return (new_field->sql_type == real_type());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -6001,7 +6001,7 @@ uint Field_str::is_equal(create_field *new_field)
|
||||||
(flags & (BINCMP_FLAG | BINARY_FLAG))))
|
(flags & (BINCMP_FLAG | BINARY_FLAG))))
|
||||||
return 0; /* One of the fields is binary and the other one isn't */
|
return 0; /* One of the fields is binary and the other one isn't */
|
||||||
|
|
||||||
return ((new_field->sql_type == type()) &&
|
return ((new_field->sql_type == real_type()) &&
|
||||||
new_field->charset == field_charset &&
|
new_field->charset == field_charset &&
|
||||||
new_field->length == max_length());
|
new_field->length == max_length());
|
||||||
}
|
}
|
||||||
|
@ -6798,7 +6798,7 @@ Field *Field_varstring::new_key_field(MEM_ROOT *root,
|
||||||
|
|
||||||
uint Field_varstring::is_equal(create_field *new_field)
|
uint Field_varstring::is_equal(create_field *new_field)
|
||||||
{
|
{
|
||||||
if (new_field->sql_type == type() &&
|
if (new_field->sql_type == real_type() &&
|
||||||
new_field->charset == field_charset)
|
new_field->charset == field_charset)
|
||||||
{
|
{
|
||||||
if (new_field->length == max_length())
|
if (new_field->length == max_length())
|
||||||
|
@ -7957,12 +7957,12 @@ bool Field_num::eq_def(Field *field)
|
||||||
|
|
||||||
uint Field_num::is_equal(create_field *new_field)
|
uint Field_num::is_equal(create_field *new_field)
|
||||||
{
|
{
|
||||||
return ((new_field->sql_type == type()) &&
|
return ((new_field->sql_type == real_type()) &&
|
||||||
((new_field->flags & UNSIGNED_FLAG) == (uint) (flags &
|
((new_field->flags & UNSIGNED_FLAG) == (uint) (flags &
|
||||||
UNSIGNED_FLAG)) &&
|
UNSIGNED_FLAG)) &&
|
||||||
((new_field->flags & AUTO_INCREMENT_FLAG) ==
|
((new_field->flags & AUTO_INCREMENT_FLAG) ==
|
||||||
(uint) (flags & AUTO_INCREMENT_FLAG)) &&
|
(uint) (flags & AUTO_INCREMENT_FLAG)) &&
|
||||||
(new_field->length >= max_length()));
|
(new_field->length <= max_length()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1373,6 +1373,9 @@ ndb_handle_schema_change(THD *thd, Ndb *ndb, NdbEventOperation *pOp,
|
||||||
NDB_SHARE *share)
|
NDB_SHARE *share)
|
||||||
{
|
{
|
||||||
DBUG_ENTER("ndb_handle_schema_change");
|
DBUG_ENTER("ndb_handle_schema_change");
|
||||||
|
TABLE* table= share->table;
|
||||||
|
TABLE_SHARE *table_share= table->s;
|
||||||
|
const char *dbname= table_share->db.str;
|
||||||
bool do_close_cached_tables= FALSE;
|
bool do_close_cached_tables= FALSE;
|
||||||
bool is_online_alter_table= FALSE;
|
bool is_online_alter_table= FALSE;
|
||||||
bool is_rename_table= FALSE;
|
bool is_rename_table= FALSE;
|
||||||
|
@ -1392,70 +1395,68 @@ ndb_handle_schema_change(THD *thd, Ndb *ndb, NdbEventOperation *pOp,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_remote_change) /* includes CLUSTER_FAILURE */
|
/*
|
||||||
|
Refresh local dictionary cache by
|
||||||
|
invalidating table and all it's indexes
|
||||||
|
*/
|
||||||
|
ndb->setDatabaseName(dbname);
|
||||||
|
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);
|
||||||
|
table_handler.set_dbname(share->key);
|
||||||
|
table_handler.set_tabname(share->key);
|
||||||
|
table_handler.open_indexes(ndb, table, TRUE);
|
||||||
|
table_handler.invalidate_dictionary_cache(TRUE);
|
||||||
|
thd_ndb->ndb= old_ndb;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Refresh local frm file and dictionary cache if
|
||||||
|
remote on-line alter table
|
||||||
|
*/
|
||||||
|
if (is_remote_change && is_online_alter_table)
|
||||||
{
|
{
|
||||||
TABLE* table= share->table;
|
const char *tabname= table_share->table_name.str;
|
||||||
TABLE_SHARE *table_share= table->s;
|
char key[FN_REFLEN];
|
||||||
const char *dbname= table_share->db.str;
|
const void *data= 0, *pack_data= 0;
|
||||||
|
uint length, pack_length;
|
||||||
|
int error;
|
||||||
|
NDBDICT *dict= ndb->getDictionary();
|
||||||
|
const NDBTAB *altered_table= pOp->getTable();
|
||||||
|
|
||||||
/*
|
DBUG_PRINT("info", ("Detected frm change of table %s.%s",
|
||||||
Invalidate table and all it's indexes
|
dbname, tabname));
|
||||||
|
build_table_filename(key, FN_LEN-1, dbname, tabname, NullS);
|
||||||
|
/*
|
||||||
|
If the frm of the altered table is different than the one on
|
||||||
|
disk then overwrite it with the new table definition
|
||||||
*/
|
*/
|
||||||
ndb->setDatabaseName(dbname);
|
if (readfrm(key, &data, &length) == 0 &&
|
||||||
Thd_ndb *thd_ndb= get_thd_ndb(thd);
|
packfrm(data, length, &pack_data, &pack_length) == 0 &&
|
||||||
DBUG_ASSERT(thd_ndb != NULL);
|
cmp_frm(altered_table, pack_data, pack_length))
|
||||||
Ndb* old_ndb= thd_ndb->ndb;
|
|
||||||
thd_ndb->ndb= ndb;
|
|
||||||
ha_ndbcluster table_handler(table_share);
|
|
||||||
table_handler.set_dbname(share->key);
|
|
||||||
table_handler.set_tabname(share->key);
|
|
||||||
table_handler.open_indexes(ndb, table, TRUE);
|
|
||||||
table_handler.invalidate_dictionary_cache(TRUE);
|
|
||||||
thd_ndb->ndb= old_ndb;
|
|
||||||
|
|
||||||
if (is_online_alter_table)
|
|
||||||
{
|
{
|
||||||
const char *tabname= table_share->table_name.str;
|
DBUG_DUMP("frm", (char*)altered_table->getFrmData(),
|
||||||
char key[FN_REFLEN];
|
altered_table->getFrmLength());
|
||||||
const void *data= 0, *pack_data= 0;
|
pthread_mutex_lock(&LOCK_open);
|
||||||
uint length, pack_length;
|
const NDBTAB *old= dict->getTable(tabname);
|
||||||
int error;
|
if (!old &&
|
||||||
NDBDICT *dict= ndb->getDictionary();
|
old->getObjectVersion() != altered_table->getObjectVersion())
|
||||||
const NDBTAB *altered_table= pOp->getTable();
|
dict->putTable(altered_table);
|
||||||
|
|
||||||
DBUG_PRINT("info", ("Detected frm change of table %s.%s",
|
if ((error= unpackfrm(&data, &length, altered_table->getFrmData())) ||
|
||||||
dbname, tabname));
|
(error= writefrm(key, data, length)))
|
||||||
build_table_filename(key, FN_LEN-1, dbname, tabname, NullS);
|
|
||||||
/*
|
|
||||||
If the frm of the altered table is different than the one on
|
|
||||||
disk then overwrite it with the new table definition
|
|
||||||
*/
|
|
||||||
if (readfrm(key, &data, &length) == 0 &&
|
|
||||||
packfrm(data, length, &pack_data, &pack_length) == 0 &&
|
|
||||||
cmp_frm(altered_table, pack_data, pack_length))
|
|
||||||
{
|
{
|
||||||
DBUG_DUMP("frm", (char*)altered_table->getFrmData(),
|
sql_print_information("NDB: Failed write frm for %s.%s, error %d",
|
||||||
altered_table->getFrmLength());
|
dbname, tabname, error);
|
||||||
pthread_mutex_lock(&LOCK_open);
|
|
||||||
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())) ||
|
|
||||||
(error= writefrm(key, data, length)))
|
|
||||||
{
|
|
||||||
sql_print_information("NDB: Failed write frm for %s.%s, error %d",
|
|
||||||
dbname, tabname, error);
|
|
||||||
}
|
|
||||||
ndbcluster_binlog_close_table(thd, share);
|
|
||||||
close_cached_tables((THD*) 0, 0, (TABLE_LIST*) 0, TRUE);
|
|
||||||
if ((error= ndbcluster_binlog_open_table(thd, share,
|
|
||||||
table_share, table)))
|
|
||||||
sql_print_information("NDB: Failed to re-open table %s.%s",
|
|
||||||
dbname, tabname);
|
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
|
||||||
}
|
}
|
||||||
|
ndbcluster_binlog_close_table(thd, share);
|
||||||
|
close_cached_tables((THD*) 0, 0, (TABLE_LIST*) 0, TRUE);
|
||||||
|
if ((error= ndbcluster_binlog_open_table(thd, share,
|
||||||
|
table_share, table)))
|
||||||
|
sql_print_information("NDB: Failed to re-open table %s.%s",
|
||||||
|
dbname, tabname);
|
||||||
|
pthread_mutex_unlock(&LOCK_open);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue