summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <mskold@mysql.com>2005-11-21 08:42:36 +0100
committerunknown <mskold@mysql.com>2005-11-21 08:42:36 +0100
commit1dfaaba874c5f02222e149466743abb0c268c5d3 (patch)
treebd34e500c79c0e69fa79d23240e0cbf217069e26
parent83bbd30c480d97f57203b999cff4517f5e04bf13 (diff)
parentbb8bee51e4a6340bc14a825abc62c656152ee56c (diff)
downloadmariadb-git-1dfaaba874c5f02222e149466743abb0c268c5d3.tar.gz
Merge mskold@bk-internal.mysql.com:/home/bk/mysql-4.1
into mysql.com:/usr/local/home/marty/MySQL/mysql-4.1
-rw-r--r--mysql-test/r/ndb_alter_table.result3
-rw-r--r--mysql-test/t/ndb_alter_table.test4
-rw-r--r--sql/ha_ndbcluster.cc44
3 files changed, 44 insertions, 7 deletions
diff --git a/mysql-test/r/ndb_alter_table.result b/mysql-test/r/ndb_alter_table.result
index 3714ea14e16..62e8455ae9f 100644
--- a/mysql-test/r/ndb_alter_table.result
+++ b/mysql-test/r/ndb_alter_table.result
@@ -179,8 +179,7 @@ a b c
2 two two
alter table t1 drop index c;
select * from t1 where b = 'two';
-a b c
-2 two two
+ERROR HY000: Table definition has changed, please retry transaction
select * from t1 where b = 'two';
a b c
2 two two
diff --git a/mysql-test/t/ndb_alter_table.test b/mysql-test/t/ndb_alter_table.test
index 5c792f76316..d89b81859e7 100644
--- a/mysql-test/t/ndb_alter_table.test
+++ b/mysql-test/t/ndb_alter_table.test
@@ -138,6 +138,7 @@ INSERT INTO t1 VALUES (1,2,0),(18,19,4),(20,21,0);
select c from t1 order by c;
drop table t1;
+--disable_ps_protocol
create table t1 ( a int primary key, b varchar(10), c varchar(10), index (b) )
engine=ndb;
insert into t1 values (1,'one','one'), (2,'two','two'), (3,'three','three');
@@ -147,10 +148,13 @@ select * from t1 where b = 'two';
connection server1;
alter table t1 drop index c;
connection server2;
+# This should fail since index information is not automatically refreshed
+--error 1105
select * from t1 where b = 'two';
select * from t1 where b = 'two';
connection server1;
drop table t1;
+--enable_ps_protocol
#--disable_warnings
#DROP TABLE IF EXISTS t2;
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc
index 608dc3eaa54..6760208488f 100644
--- a/sql/ha_ndbcluster.cc
+++ b/sql/ha_ndbcluster.cc
@@ -50,6 +50,8 @@ static const char *ha_ndb_ext=".ndb";
#define NDB_FAILED_AUTO_INCREMENT ~(Uint64)0
#define NDB_AUTO_INCREMENT_RETRIES 10
+#define NDB_INVALID_SCHEMA_OBJECT 241
+
#define ERR_PRINT(err) \
DBUG_PRINT("error", ("%d message: %s", err.code, err.message))
@@ -212,7 +214,21 @@ Thd_ndb::Thd_ndb()
Thd_ndb::~Thd_ndb()
{
if (ndb)
+ {
+#ifndef DBUG_OFF
+ Ndb::Free_list_usage tmp; tmp.m_name= 0;
+ while (ndb->get_free_list_usage(&tmp))
+ {
+ uint leaked= (uint) tmp.m_created - tmp.m_free;
+ if (leaked)
+ fprintf(stderr, "NDB: Found %u %s%s that %s not been released\n",
+ leaked, tmp.m_name,
+ (leaked == 1)?"":"'s",
+ (leaked == 1)?"has":"have");
+ }
+#endif
delete ndb;
+ }
ndb= 0;
}
@@ -3269,15 +3285,19 @@ int ha_ndbcluster::external_lock(THD *thd, int lock_type)
DBUG_PRINT("info", ("Table schema version: %d",
tab->getObjectVersion()));
}
- if (m_table != (void *)tab || m_table_version < tab->getObjectVersion())
+ if (m_table != (void *)tab)
{
- /*
- The table has been altered, refresh the index list
- */
- build_index_list(ndb, table, ILBP_OPEN);
m_table= (void *)tab;
m_table_version = tab->getObjectVersion();
}
+ else if (m_table_version < tab->getObjectVersion())
+ {
+ /*
+ The table has been altered, caller has to retry
+ */
+ NdbError err= ndb->getNdbError(NDB_INVALID_SCHEMA_OBJECT);
+ DBUG_RETURN(ndb_to_mysql_error(&err));
+ }
m_table_info= tab_info;
}
no_uncommitted_rows_init(thd);
@@ -4657,7 +4677,21 @@ bool ndbcluster_end()
{
DBUG_ENTER("ndbcluster_end");
if(g_ndb)
+ {
+#ifndef DBUG_OFF
+ Ndb::Free_list_usage tmp; tmp.m_name= 0;
+ while (g_ndb->get_free_list_usage(&tmp))
+ {
+ uint leaked= (uint) tmp.m_created - tmp.m_free;
+ if (leaked)
+ fprintf(stderr, "NDB: Found %u %s%s that %s not been released\n",
+ leaked, tmp.m_name,
+ (leaked == 1)?"":"'s",
+ (leaked == 1)?"has":"have");
+ }
+#endif
delete g_ndb;
+ }
g_ndb= NULL;
if (g_ndb_cluster_connection)
delete g_ndb_cluster_connection;