Commit 2e43e470 authored by unknown's avatar unknown
Browse files

moved all ndb thread specific data into new placeholder

new methods to keep "records" up to date
unset flag HA_NOT_EXACT_COUNT to make handler read "records" field, for count() optim and join optimization
new methods to keep "records" up to datecorrect record field in ndbcluster handler
new method for ndbcluster handler to store/retrieve table and thread specific data
changed local hash to store new table_info object, with placeholders for local data, instead of TableImpl
hanged deleteKey to return ponter to deleted object
moved heavy global cache fetch from inline to separate method


mysql-test/r/ndb_alter_table.result:
  correct record field in ndbcluster handler
mysql-test/r/ndb_blob.result:
  correct record field in ndbcluster handler
ndb/include/ndbapi/NdbDictionary.hpp:
  new method for ndbcluster handler to store/retrieve table and thread specific data
ndb/src/ndbapi/DictCache.cpp:
  changed local hash to store new table_info object, with placeholders for local data, instead of TableImpl
ndb/src/ndbapi/DictCache.hpp:
  changed local hash to store new table_info object, with placeholders for local data, instead of TableImpl
ndb/src/ndbapi/Ndb.cpp:
  replaced method DictionaryImpl::getTable with DictionaryImpl::get_local_table_info
ndb/src/ndbapi/NdbDictionary.cpp:
  new method for ndbcluster handler to store/retrieve table and thread specific data
ndb/src/ndbapi/NdbDictionaryImpl.cpp:
  changed local hash to store new table_info object, with placeholders for local data, instead of TableImpl
  moved heavy global cache fetch from inline to separate method
ndb/src/ndbapi/NdbDictionaryImpl.hpp:
  replaced method DictionaryImpl::getTable with DictionaryImpl::get_local_table_info
ndb/src/ndbapi/NdbLinHash.hpp:
  changed deleteKey to return ponter to deleted object
sql/ha_ndbcluster.cc:
  moved all ndb thread specific data into new placeholder
  new methods to keep "records" up to date
  unset flag HA_NOT_EXACT_COUNT to make handler read "records" field, for count() optim and join optimization
sql/ha_ndbcluster.h:
  new methods to keep "records" up to date
sql/sql_class.h:
  moved all ndb thread specific data into new placeholder
parent cd573513
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -18,12 +18,12 @@ col5 enum('PENDING', 'ACTIVE', 'DISABLED') not null,
col6 int not null, to_be_deleted int)  ENGINE=ndbcluster;
show table status;
Name	Engine	Version	Row_format	Rows	Avg_row_length	Data_length	Max_data_length	Index_length	Data_free	Auto_increment	Create_time	Update_time	Check_time	Collation	Checksum	Create_options	Comment
t1	ndbcluster	9	Dynamic	100	0	0	NULL	0	0	1	NULL	NULL	NULL	latin1_swedish_ci	NULL		
t1	ndbcluster	9	Dynamic	0	0	0	NULL	0	0	1	NULL	NULL	NULL	latin1_swedish_ci	NULL		
insert into t1 values
(0,4,3,5,"PENDING",1,7),(NULL,4,3,5,"PENDING",1,7),(31,4,3,5,"PENDING",1,7), (7,4,3,5,"PENDING",1,7), (NULL,4,3,5,"PENDING",1,7), (100,4,3,5,"PENDING",1,7), (99,4,3,5,"PENDING",1,7), (8,4,3,5,"PENDING",1,7), (NULL,4,3,5,"PENDING",1,7);
show table status;
Name	Engine	Version	Row_format	Rows	Avg_row_length	Data_length	Max_data_length	Index_length	Data_free	Auto_increment	Create_time	Update_time	Check_time	Collation	Checksum	Create_options	Comment
t1	ndbcluster	9	Dynamic	100	0	0	NULL	0	0	102	NULL	NULL	NULL	latin1_swedish_ci	NULL		
t1	ndbcluster	9	Dynamic	9	0	0	NULL	0	0	102	NULL	NULL	NULL	latin1_swedish_ci	NULL		
select * from t1 order by col1;
col1	col2	col3	col4	col5	col6	to_be_deleted
0	4	3	5	PENDING	1	7
@@ -43,7 +43,7 @@ change column col2 fourth varchar(30) not null after col3,
modify column col6 int not null first;
show table status;
Name	Engine	Version	Row_format	Rows	Avg_row_length	Data_length	Max_data_length	Index_length	Data_free	Auto_increment	Create_time	Update_time	Check_time	Collation	Checksum	Create_options	Comment
t1	ndbcluster	9	Dynamic	100	0	0	NULL	0	0	102	NULL	NULL	NULL	latin1_swedish_ci	NULL		
t1	ndbcluster	9	Dynamic	9	0	0	NULL	0	0	102	NULL	NULL	NULL	latin1_swedish_ci	NULL		
select * from t1 order by col1;
col6	col1	col3	fourth	col4	col4_5	col5	col7	col8
1	0	3	4	5		PENDING		0000-00-00 00:00:00
@@ -58,7 +58,7 @@ col6 col1 col3 fourth col4 col4_5 col5 col7 col8
insert into t1 values (2, NULL,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00');
show table status;
Name	Engine	Version	Row_format	Rows	Avg_row_length	Data_length	Max_data_length	Index_length	Data_free	Auto_increment	Create_time	Update_time	Check_time	Collation	Checksum	Create_options	Comment
t1	ndbcluster	9	Dynamic	100	0	0	NULL	0	0	103	NULL	NULL	NULL	latin1_swedish_ci	NULL		
t1	ndbcluster	9	Dynamic	10	0	0	NULL	0	0	103	NULL	NULL	NULL	latin1_swedish_ci	NULL		
select * from t1 order by col1;
col6	col1	col3	fourth	col4	col4_5	col5	col7	col8
1	0	3	4	5		PENDING		0000-00-00 00:00:00
+2 −2
Original line number Diff line number Diff line
@@ -150,7 +150,7 @@ insert into t1 values(9,'b9',999,'dd9');
commit;
explain select * from t1;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	100	
1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	9	
select * from t1 order by a;
a	b	c	d
1	b1	111	dd1
@@ -185,7 +185,7 @@ insert into t1 values(2,@b2,222,@d2);
commit;
explain select * from t1;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	100	
1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	
select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3)
from t1 order by a;
a	length(b)	substr(b,1+2*900,2)	length(d)	substr(d,1+3*900,3)
+2 −0
Original line number Diff line number Diff line
@@ -1066,6 +1066,8 @@ public:
    Dictionary(NdbDictionaryImpl&);
    const Table * getIndexTable(const char * indexName, 
				const char * tableName);
  public:
    const Table * getTable(const char * name, void **data);
  };
};

+22 −5
Original line number Diff line number Diff line
@@ -21,6 +21,21 @@
#include <NdbCondition.h>
#include <NdbSleep.h>

Ndb_local_table_info::Ndb_local_table_info(NdbTableImpl *table_impl, Uint32 sz)
{
  m_table_impl= table_impl;
  if (sz)
    m_local_data= malloc(sz);
  else
    m_local_data= 0;
}

Ndb_local_table_info::~Ndb_local_table_info()
{
  if (m_local_data)
    free(m_local_data);
}

LocalDictCache::LocalDictCache(){
  m_tableHash.createHashTable();
}
@@ -29,22 +44,24 @@ LocalDictCache::~LocalDictCache(){
  m_tableHash.releaseHashTable();
}

NdbTableImpl * 
Ndb_local_table_info * 
LocalDictCache::get(const char * name){
  const Uint32 len = strlen(name);
  return m_tableHash.getData(name, len);
}

void 
LocalDictCache::put(const char * name, NdbTableImpl * tab){
  const Uint32 id = tab->m_tableId;
LocalDictCache::put(const char * name, Ndb_local_table_info * tab_info){
  const Uint32 id = tab_info->m_table_impl->m_tableId;
  
  m_tableHash.insertKey(name, strlen(name), id, tab);
  m_tableHash.insertKey(name, strlen(name), id, tab_info);
}

void
LocalDictCache::drop(const char * name){
  m_tableHash.deleteKey(name, strlen(name));
  Ndb_local_table_info *info= m_tableHash.deleteKey(name, strlen(name));
  DBUG_ASSERT(info != 0);
  delete info;
}

/*****************************************************************
+13 −3
Original line number Diff line number Diff line
@@ -27,6 +27,16 @@
#include <Ndb.hpp>
#include "NdbLinHash.hpp"

class Ndb_local_table_info {
public:
  Ndb_local_table_info(NdbTableImpl *table_impl, Uint32 sz=0);
  ~Ndb_local_table_info();
  NdbTableImpl *m_table_impl;
  Uint64 m_first_tuple_id;
  Uint64 m_last_tuple_id;
  void *m_local_data;
};

/**
 * A non thread safe dict cache
 */
@@ -35,12 +45,12 @@ public:
  LocalDictCache();
  ~LocalDictCache();
  
  NdbTableImpl * get(const char * name);
  Ndb_local_table_info * get(const char * name);
  
  void put(const char * name, NdbTableImpl *);
  void put(const char * name, Ndb_local_table_info *);
  void drop(const char * name);
  
  NdbLinHash<NdbTableImpl> m_tableHash; // On name
  NdbLinHash<Ndb_local_table_info> m_tableHash; // On name
};

/**
Loading