Commit f272d327 authored by unknown's avatar unknown
Browse files

ndb - bug#14509, part 1: move autoincr pre-fetch from Ndb to local dict cache


mysql-test/r/ndb_alter_table.result:
  bug#14509, part 1
  move cached autoincr range from Ndb object to local dict cache (Ndb_local_table_info)
  remove private methods get/read/setTupleId by table name or table id
mysql-test/t/ndb_alter_table.test:
  bug#14509, part 1
  move cached autoincr range from Ndb object to local dict cache (Ndb_local_table_info)
  remove private methods get/read/setTupleId by table name or table id
ndb/include/ndbapi/Ndb.hpp:
  bug#14509, part 1
  move cached autoincr range from Ndb object to local dict cache (Ndb_local_table_info)
  remove private methods get/read/setTupleId by table name or table id
ndb/src/ndbapi/DictCache.cpp:
  bug#14509, part 1
  move cached autoincr range from Ndb object to local dict cache (Ndb_local_table_info)
  remove private methods get/read/setTupleId by table name or table id
ndb/src/ndbapi/DictCache.hpp:
  bug#14509, part 1
  move cached autoincr range from Ndb object to local dict cache (Ndb_local_table_info)
  remove private methods get/read/setTupleId by table name or table id
ndb/src/ndbapi/Ndb.cpp:
  bug#14509, part 1
  move cached autoincr range from Ndb object to local dict cache (Ndb_local_table_info)
  remove private methods get/read/setTupleId by table name or table id
ndb/src/ndbapi/NdbDictionaryImpl.cpp:
  bug#14509, part 1
  move cached autoincr range from Ndb object to local dict cache (Ndb_local_table_info)
  remove private methods get/read/setTupleId by table name or table id
ndb/src/ndbapi/Ndbinit.cpp:
  bug#14509, part 1
  move cached autoincr range from Ndb object to local dict cache (Ndb_local_table_info)
  remove private methods get/read/setTupleId by table name or table id
parent 47302570
Loading
Loading
Loading
Loading
+22 −1
Original line number Diff line number Diff line
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t1, t2;
drop database if exists mysqltest;
CREATE TABLE t1 (
a INT NOT NULL,
@@ -315,3 +315,24 @@ unique key tx1 (c002, c003, c004, c005)) engine=ndb;
create index tx2 
on t1 (c010, c011, c012, c013);
drop table t1;
create table t1 (a int primary key auto_increment, b int) engine=ndb;
insert into t1 (b) values (101),(102),(103);
select * from t1 where a = 3;
a	b
3	103
alter table t1 rename t2;
insert into t2 (b) values (201),(202),(203);
select * from t2 where a = 6;
a	b
6	203
alter table t2 add c int;
insert into t2 (b) values (301),(302),(303);
select * from t2 where a = 9;
a	b	c
9	303	NULL
alter table t2 rename t1;
insert into t1 (b) values (401),(402),(403);
select * from t1 where a = 12;
a	b	c
12	403	NULL
drop table t1;
+16 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@
-- source include/not_embedded.inc

--disable_warnings
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t1, t2;
drop database if exists mysqltest;
--enable_warnings

@@ -326,5 +326,20 @@ on t1 (c010, c011, c012, c013);

drop table t1;

# simple test that auto incr is not lost at rename or alter
create table t1 (a int primary key auto_increment, b int) engine=ndb;
insert into t1 (b) values (101),(102),(103);
select * from t1 where a = 3;
alter table t1 rename t2;
insert into t2 (b) values (201),(202),(203);
select * from t2 where a = 6;
alter table t2 add c int;
insert into t2 (b) values (301),(302),(303);
select * from t2 where a = 9;
alter table t2 rename t1;
insert into t1 (b) values (401),(402),(403);
select * from t1 where a = 12;
drop table t1;

# End of 4.1 tests
+7 −14
Original line number Diff line number Diff line
@@ -984,6 +984,7 @@ class BaseString;
class NdbEventOperation;
class NdbBlob;
class NdbReceiver;
class Ndb_local_table_info;
template <class T> struct Ndb_free_list_t;

typedef void (* NdbEventCallback)(NdbEventOperation*, Ndb*, void*);
@@ -1443,15 +1444,12 @@ public:
			     bool increase = false);
  bool setAutoIncrementValue(const NdbDictionary::Table * aTable, Uint64 val, 
			     bool increase = false);
  Uint64 getTupleIdFromNdb(const char* aTableName, 
			   Uint32 cacheSize = 1000);
  Uint64 getTupleIdFromNdb(Uint32 aTableId, 
			   Uint32 cacheSize = 1000);
  Uint64 readTupleIdFromNdb(Uint32 aTableId);
  bool setTupleIdInNdb(const char* aTableName, Uint64 val, 
		       bool increase);
  bool setTupleIdInNdb(Uint32 aTableId, Uint64 val, bool increase);
  Uint64 opTupleIdOnNdb(Uint32 aTableId, Uint64 opValue, Uint32 op);
private:
  Uint64 getTupleIdFromNdb(Ndb_local_table_info* info, Uint32 cacheSize);
  Uint64 readTupleIdFromNdb(Ndb_local_table_info* info);
  bool setTupleIdInNdb(Ndb_local_table_info* info, Uint64 val, bool increase);
  Uint64 opTupleIdOnNdb(Ndb_local_table_info* info, Uint64 opValue, Uint32 op);
public:

  /**
   */
@@ -1651,11 +1649,6 @@ private:
  Uint64               the_last_check_time;
  Uint64               theFirstTransId;

  // The tupleId is retreived from DB the 
  // tupleId is unique for each tableid. 
  Uint64               theFirstTupleId[2048]; 
  Uint64               theLastTupleId[2048];           

  Uint32		theRestartGCI;	// the Restart GCI used by DIHNDBTAMPER
  
  NdbError              theError;
+2 −0
Original line number Diff line number Diff line
@@ -45,6 +45,8 @@ void Ndb_local_table_info::destroy(Ndb_local_table_info *info)
Ndb_local_table_info::Ndb_local_table_info(NdbTableImpl *table_impl)
{
  m_table_impl= table_impl;
  m_first_tuple_id = ~(Uint64)0;
  m_last_tuple_id = ~(Uint64)0;
}

Ndb_local_table_info::~Ndb_local_table_info()
+5 −0
Original line number Diff line number Diff line
@@ -33,6 +33,11 @@ public:
  static Ndb_local_table_info *create(NdbTableImpl *table_impl, Uint32 sz=0);
  static void destroy(Ndb_local_table_info *);
  NdbTableImpl *m_table_impl;

  // range of cached tuple ids per thread
  Uint64 m_first_tuple_id;
  Uint64 m_last_tuple_id;

  Uint64 m_local_data[1]; // Must be last member. Used to access extra space.
private:
  Ndb_local_table_info(NdbTableImpl *table_impl);
Loading