List:Internals« Previous MessageNext Message »
From:Martin Skold Date:March 22 2005 5:42pm
Subject:bk commit into 4.1 tree (mskold:1.2142) BUG#8753
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of marty. When marty does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2142 05/03/22 17:42:08 mskold@stripped +3 -0
  Extra fix for perceived problem with fix for Bug #8753 Invalid schema object version
after dropping index

  sql/ha_ndbcluster.h
    1.50 05/03/22 17:41:44 mskold@stripped +2 -1
    Extra fix for perceived problem with fix for Bug #8753 Invalid schema object version
after dropping index

  sql/ha_ndbcluster.cc
    1.134 05/03/22 17:41:44 mskold@stripped +35 -21
    Extra fix for perceived problem with fix for Bug #8753 Invalid schema object version
after dropping index

  ndb/src/ndbapi/DictCache.cpp
    1.10 05/03/22 17:41:44 mskold@stripped +5 -4
    Extra fix for perceived problem with fix for Bug #8753 Invalid schema object version
after dropping index

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	mskold
# Host:	blowfish.ndb.mysql.com
# Root:	/usr/local/home/marty/MySQL/mysql-4.1

--- 1.9/ndb/src/ndbapi/DictCache.cpp	Thu Dec  9 15:05:43 2004
+++ 1.10/ndb/src/ndbapi/DictCache.cpp	Tue Mar 22 17:41:44 2005
@@ -24,12 +24,13 @@
 Ndb_local_table_info *
 Ndb_local_table_info::create(NdbTableImpl *table_impl, Uint32 sz)
 {
-  if (sz % 8 != 0) // round to Uint64
-    sz += 8 - sz % 8;
-  void *data= malloc(sizeof(NdbTableImpl)+sz-8);
+  Uint32 tot_size= sizeof(NdbTableImpl *) + sz;
+  if (sz % 8 != 0)  
+    tot_size += sz % 8;  // round to Uint64
+  void *data= malloc(tot_size);
   if (data == 0)
     return 0;
-  memset(data,0,sizeof(NdbTableImpl)+sz-8);
+  memset(data, 0, tot_size);
   new (data) Ndb_local_table_info(table_impl);
   return (Ndb_local_table_info *) data;
 }

--- 1.133/sql/ha_ndbcluster.cc	Mon Mar 14 12:07:40 2005
+++ 1.134/sql/ha_ndbcluster.cc	Tue Mar 22 17:41:44 2005
@@ -225,7 +225,7 @@
  * manage uncommitted insert/deletes during transactio to get records correct
  */
 
-struct Ndb_table_local_info {
+struct Ndb_local_table_statistics {
   int no_uncommitted_rows_count;
   ulong last_count;
   ha_rows records;
@@ -246,7 +246,8 @@
   if (m_ha_not_exact_count)
     return;
   DBUG_ENTER("ha_ndbcluster::records_update");
-  struct Ndb_table_local_info *info= (struct Ndb_table_local_info *)m_table_info;
+  struct Ndb_local_table_statistics *info= 
+    (struct Ndb_local_table_statistics *)m_table_info;
   DBUG_PRINT("info", ("id=%d, no_uncommitted_rows_count=%d",
 		      ((const NDBTAB *)m_table)->getTableId(),
 		      info->no_uncommitted_rows_count));
@@ -282,7 +283,8 @@
   if (m_ha_not_exact_count)
     return;
   DBUG_ENTER("ha_ndbcluster::no_uncommitted_rows_init");
-  struct Ndb_table_local_info *info= (struct Ndb_table_local_info *)m_table_info;
+  struct Ndb_local_table_statistics *info= 
+    (struct Ndb_local_table_statistics *)m_table_info;
   Thd_ndb *thd_ndb= (Thd_ndb *)thd->transaction.thd_ndb;
   if (info->last_count != thd_ndb->count)
   {
@@ -301,8 +303,8 @@
   if (m_ha_not_exact_count)
     return;
   DBUG_ENTER("ha_ndbcluster::no_uncommitted_rows_update");
-  struct Ndb_table_local_info *info=
-    (struct Ndb_table_local_info *)m_table_info;
+  struct Ndb_local_table_statistics *info=
+    (struct Ndb_local_table_statistics *)m_table_info;
   info->no_uncommitted_rows_count+= c;
   DBUG_PRINT("info", ("id=%d, no_uncommitted_rows_count=%d",
 		      ((const NDBTAB *)m_table)->getTableId(),
@@ -716,10 +718,8 @@
   Get metadata for this table from NDB 
 
   IMPLEMENTATION
-    - save the NdbDictionary::Table for easy access
     - check that frm-file on disk is equal to frm-file
       of table accessed in NDB
-    - build a list of the indexes for the table
 */
 
 int ha_ndbcluster::get_metadata(const char *path)
@@ -783,11 +783,12 @@
 
   if (error)
     DBUG_RETURN(error);
-
-  m_table= NULL;
-  m_table_info= NULL;
   
-  DBUG_RETURN(build_index_list(table, ILBP_OPEN));  
+  m_tableVersion= tab->getObjectVersion();
+  m_table= (void *)tab; 
+  m_table_info= NULL; // Set in external lock
+  
+  DBUG_RETURN(build_index_list(ndb, table, ILBP_OPEN));
 }
 
 static int fix_unique_index_attr_order(NDB_INDEX_DATA &data,
@@ -815,7 +816,7 @@
 #endif
     for (unsigned j= 0; j < sz; j++)
     {
-      const NdbDictionary::Column *c= index->getColumn(j);
+      const NDBCOL *c= index->getColumn(j);
       if (strncmp(field_name, c->getName(), name_sz) == 0)
       {
 	data.unique_index_attrid_map[i]= j;
@@ -827,7 +828,7 @@
   DBUG_RETURN(0);
 }
 
-int ha_ndbcluster::build_index_list(TABLE *tab, enum ILBP phase)
+int ha_ndbcluster::build_index_list(Ndb *ndb, TABLE *tab, enum ILBP phase)
 {
   uint i;
   int error= 0;
@@ -836,8 +837,7 @@
   static const char* unique_suffix= "$unique";
   KEY* key_info= tab->key_info;
   const char **key_name= tab->keynames.type_names;
-  Ndb *ndb= get_ndb();
-  NdbDictionary::Dictionary *dict= ndb->getDictionary();
+  NDBDICT *dict= ndb->getDictionary();
   DBUG_ENTER("build_index_list");
   
   // Save information about all known indexes
@@ -3060,6 +3060,9 @@
  
   When a table lock is held one transaction will be started which holds
   the table lock and for each statement a hupp transaction will be started  
+  If we are locken the table then:
+  - save the NdbDictionary::Table for easy access
+  - build a list of the indexes for the table
  */
 
 int ha_ndbcluster::external_lock(THD *thd, int lock_type)
@@ -3166,7 +3169,15 @@
       if (!(tab= dict->getTable(m_tabname, &tab_info)))
 	ERR_RETURN(dict->getNdbError());
       DBUG_PRINT("info", ("Table schema version: %d", tab->getObjectVersion()));
-      m_table= (void *)tab;
+      if (m_table != (void *)tab || m_tableVersion != 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_info= tab_info;
     }
     no_uncommitted_rows_init(thd);
@@ -3716,7 +3727,7 @@
                       m_dbname, m_tabname));
 
   // Create secondary indexes
-  my_errno= build_index_list(form, ILBP_CREATE);
+  my_errno= build_index_list(ndb, form, ILBP_CREATE);
 
   if (!my_errno)
     my_errno= write_ndb_file();
@@ -3936,6 +3947,7 @@
   m_active_trans(NULL),
   m_active_cursor(NULL),
   m_table(NULL),
+  m_tableVersion(-1),
   m_table_info(NULL),
   m_table_flags(HA_REC_NOT_IN_SEQ |
 		HA_NULL_IN_KEY |
@@ -4075,7 +4087,9 @@
   DBUG_ENTER("seize_thd_ndb");
 
   thd_ndb= new Thd_ndb();
- 
thd_ndb->ndb->getDictionary()->set_local_table_data_size(sizeof(Ndb_table_local_info));
+  thd_ndb->ndb->getDictionary()->set_local_table_data_size(
+    sizeof(Ndb_local_table_statistics)
+    );
   if (thd_ndb->ndb->init(max_transactions) != 0)
   {
     ERR_PRINT(thd_ndb->ndb->getNdbError());
@@ -4168,7 +4182,7 @@
   ndb->setDatabaseName(db);
 
   NDBDICT* dict= ndb->getDictionary();
-  dict->set_local_table_data_size(sizeof(Ndb_table_local_info));
+  dict->set_local_table_data_size(sizeof(Ndb_local_table_statistics));
   dict->invalidateTable(name);
   if (!(tab= dict->getTable(name)))
   {    
@@ -4216,7 +4230,7 @@
   ndb->setDatabaseName(db);
 
   NDBDICT* dict= ndb->getDictionary();
-  dict->set_local_table_data_size(sizeof(Ndb_table_local_info));
+  dict->set_local_table_data_size(sizeof(Ndb_local_table_statistics));
   dict->invalidateTable(name);
   if (!(tab= dict->getTable(name)))
   {    
@@ -4420,7 +4434,7 @@
 
   // Create a Ndb object to open the connection  to NDB
   g_ndb= new Ndb(g_ndb_cluster_connection, "sys");
-  g_ndb->getDictionary()->set_local_table_data_size(sizeof(Ndb_table_local_info));
+ 
g_ndb->getDictionary()->set_local_table_data_size(sizeof(Ndb_local_table_statistics));
   if (g_ndb->init() != 0)
   {
     ERR_PRINT (g_ndb->getNdbError());

--- 1.49/sql/ha_ndbcluster.h	Mon Mar  7 10:53:03 2005
+++ 1.50/sql/ha_ndbcluster.h	Tue Mar 22 17:41:44 2005
@@ -156,7 +156,7 @@
   int create_unique_index(const char *name, KEY *key_info);
   int initialize_autoincrement(const void *table);
   enum ILBP {ILBP_CREATE = 0, ILBP_OPEN = 1}; // Index List Build Phase
-  int build_index_list(TABLE *tab, enum ILBP phase);
+  int build_index_list(Ndb *ndb, TABLE *tab, enum ILBP phase);
   int get_metadata(const char* path);
   void release_metadata();
   NDB_INDEX_TYPE get_index_type(uint idx_no) const;
@@ -213,6 +213,7 @@
   NdbConnection *m_active_trans;
   NdbResultSet *m_active_cursor;
   void *m_table;
+  int m_tableVersion;
   void *m_table_info;
   char m_dbname[FN_HEADLEN];
   //char m_schemaname[FN_HEADLEN];
Thread
bk commit into 4.1 tree (mskold:1.2142) BUG#8753Martin Skold22 Mar