Loading mysql-test/r/ndb_alter_table.result +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, Loading Loading @@ -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; mysql-test/t/ndb_alter_table.test +16 −1 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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 ndb/include/ndbapi/Ndb.hpp +23 −25 Original line number Diff line number Diff line Loading @@ -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*); Loading Loading @@ -1431,27 +1432,29 @@ public: * * @param cacheSize number of values to cache in this Ndb object * * @return tuple id or 0 on error * @return 0 or -1 on error, and tupleId in out parameter */ Uint64 getAutoIncrementValue(const char* aTableName, Uint32 cacheSize = 1); Uint64 getAutoIncrementValue(const NdbDictionary::Table * aTable, Uint32 cacheSize = 1); Uint64 readAutoIncrementValue(const char* aTableName); Uint64 readAutoIncrementValue(const NdbDictionary::Table * aTable); bool setAutoIncrementValue(const char* aTableName, Uint64 val, 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); int getAutoIncrementValue(const char* aTableName, Uint64 & tupleId, Uint32 cacheSize); int getAutoIncrementValue(const NdbDictionary::Table * aTable, Uint64 & tupleId, Uint32 cacheSize); int readAutoIncrementValue(const char* aTableName, Uint64 & tupleId); int readAutoIncrementValue(const NdbDictionary::Table * aTable, Uint64 & tupleId); int setAutoIncrementValue(const char* aTableName, Uint64 tupleId, bool increase); int setAutoIncrementValue(const NdbDictionary::Table * aTable, Uint64 tupleId, bool increase); private: int getTupleIdFromNdb(Ndb_local_table_info* info, Uint64 & tupleId, Uint32 cacheSize); int readTupleIdFromNdb(Ndb_local_table_info* info, Uint64 & tupleId); int setTupleIdInNdb(Ndb_local_table_info* info, Uint64 tupleId, bool increase); int opTupleIdOnNdb(Ndb_local_table_info* info, Uint64 & opValue, Uint32 op); public: /** */ Loading Loading @@ -1651,11 +1654,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; Loading ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp +4 −6 Original line number Diff line number Diff line Loading @@ -1607,10 +1607,9 @@ void Ndbcntr::systemErrorLab(Signal* signal, int line) /* |-2048| # 1 00000001 | */ /* | : | : | */ /* | -1 | # 1 00000001 | */ /* | 0 | 0 | */ /* | 1 | 0 | */ /* | : | : | */ /* | 2047| 0 | */ /* | 1 | 0 | tupleid sequence now created on first use */ /* | : | : | v */ /* | 2048| 0 | v */ /*---------------------------------------------------------------------------*/ void Ndbcntr::createSystableLab(Signal* signal, unsigned index) { Loading Loading @@ -1819,8 +1818,7 @@ void Ndbcntr::crSystab8Lab(Signal* signal) jam(); ckey = 1; ctransidPhase = ZFALSE; crSystab7Lab(signal); return; // skip 2nd loop - tupleid sequence now created on first use }//if signal->theData[0] = ctcConnectionP; signal->theData[1] = reference(); Loading ndb/src/ndbapi/DictCache.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -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() Loading Loading
mysql-test/r/ndb_alter_table.result +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, Loading Loading @@ -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;
mysql-test/t/ndb_alter_table.test +16 −1 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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
ndb/include/ndbapi/Ndb.hpp +23 −25 Original line number Diff line number Diff line Loading @@ -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*); Loading Loading @@ -1431,27 +1432,29 @@ public: * * @param cacheSize number of values to cache in this Ndb object * * @return tuple id or 0 on error * @return 0 or -1 on error, and tupleId in out parameter */ Uint64 getAutoIncrementValue(const char* aTableName, Uint32 cacheSize = 1); Uint64 getAutoIncrementValue(const NdbDictionary::Table * aTable, Uint32 cacheSize = 1); Uint64 readAutoIncrementValue(const char* aTableName); Uint64 readAutoIncrementValue(const NdbDictionary::Table * aTable); bool setAutoIncrementValue(const char* aTableName, Uint64 val, 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); int getAutoIncrementValue(const char* aTableName, Uint64 & tupleId, Uint32 cacheSize); int getAutoIncrementValue(const NdbDictionary::Table * aTable, Uint64 & tupleId, Uint32 cacheSize); int readAutoIncrementValue(const char* aTableName, Uint64 & tupleId); int readAutoIncrementValue(const NdbDictionary::Table * aTable, Uint64 & tupleId); int setAutoIncrementValue(const char* aTableName, Uint64 tupleId, bool increase); int setAutoIncrementValue(const NdbDictionary::Table * aTable, Uint64 tupleId, bool increase); private: int getTupleIdFromNdb(Ndb_local_table_info* info, Uint64 & tupleId, Uint32 cacheSize); int readTupleIdFromNdb(Ndb_local_table_info* info, Uint64 & tupleId); int setTupleIdInNdb(Ndb_local_table_info* info, Uint64 tupleId, bool increase); int opTupleIdOnNdb(Ndb_local_table_info* info, Uint64 & opValue, Uint32 op); public: /** */ Loading Loading @@ -1651,11 +1654,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; Loading
ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp +4 −6 Original line number Diff line number Diff line Loading @@ -1607,10 +1607,9 @@ void Ndbcntr::systemErrorLab(Signal* signal, int line) /* |-2048| # 1 00000001 | */ /* | : | : | */ /* | -1 | # 1 00000001 | */ /* | 0 | 0 | */ /* | 1 | 0 | */ /* | : | : | */ /* | 2047| 0 | */ /* | 1 | 0 | tupleid sequence now created on first use */ /* | : | : | v */ /* | 2048| 0 | v */ /*---------------------------------------------------------------------------*/ void Ndbcntr::createSystableLab(Signal* signal, unsigned index) { Loading Loading @@ -1819,8 +1818,7 @@ void Ndbcntr::crSystab8Lab(Signal* signal) jam(); ckey = 1; ctransidPhase = ZFALSE; crSystab7Lab(signal); return; // skip 2nd loop - tupleid sequence now created on first use }//if signal->theData[0] = ctcConnectionP; signal->theData[1] = reference(); Loading
ndb/src/ndbapi/DictCache.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -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() Loading