Commit ad951308 authored by unknown's avatar unknown

ndb - bug#14509 v5.1 part 1/2 : ndb api level [requires part 2/2]


storage/ndb/src/ndbapi/ndberror.c:
  delete non-sense error 4336
storage/ndb/include/ndbapi/Ndb.hpp:
  add auto-incr methods which take explicit Ndb::TupleIdRange & argument
  for NDB API programs the range is under local dict cache (as in 5.0)
  the handler level uses its own Ndb objects and ranges
storage/ndb/src/ndbapi/DictCache.cpp:
  add auto-incr methods which take explicit Ndb::TupleIdRange & argument
  for NDB API programs the range is under local dict cache (as in 5.0)
  the handler level uses its own Ndb objects and ranges
storage/ndb/src/ndbapi/DictCache.hpp:
  add auto-incr methods which take explicit Ndb::TupleIdRange & argument
  for NDB API programs the range is under local dict cache (as in 5.0)
  the handler level uses its own Ndb objects and ranges
storage/ndb/src/ndbapi/Ndb.cpp:
  add auto-incr methods which take explicit Ndb::TupleIdRange & argument
  for NDB API programs the range is under local dict cache (as in 5.0)
  the handler level uses its own Ndb objects and ranges
storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp:
  add auto-incr methods which take explicit Ndb::TupleIdRange & argument
  for NDB API programs the range is under local dict cache (as in 5.0)
  the handler level uses its own Ndb objects and ranges
storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp:
  add auto-incr methods which take explicit Ndb::TupleIdRange & argument
  for NDB API programs the range is under local dict cache (as in 5.0)
  the handler level uses its own Ndb objects and ranges
parent 018f606c
...@@ -1463,7 +1463,9 @@ public: ...@@ -1463,7 +1463,9 @@ public:
/** /**
* Return a unique tuple id for a table. The id sequence is * Return a unique tuple id for a table. The id sequence is
* ascending but may contain gaps. * ascending but may contain gaps. Methods which have no
* TupleIdRange argument use NDB API dict cache. They may
* not be called from mysqld.
* *
* @param aTableName table name * @param aTableName table name
* *
...@@ -1471,28 +1473,47 @@ public: ...@@ -1471,28 +1473,47 @@ public:
* *
* @return 0 or -1 on error, and tupleId in out parameter * @return 0 or -1 on error, and tupleId in out parameter
*/ */
struct TupleIdRange {
Uint64 m_first_tuple_id;
Uint64 m_last_tuple_id;
void reset() {
m_first_tuple_id = ~(Uint64)0;
m_last_tuple_id = ~(Uint64)0;
};
};
int initAutoIncrement(); int initAutoIncrement();
int getAutoIncrementValue(const char* aTableName, int getAutoIncrementValue(const char* aTableName,
Uint64 & tupleId, Uint32 cacheSize); Uint64 & tupleId, Uint32 cacheSize);
int getAutoIncrementValue(const NdbDictionary::Table * aTable, int getAutoIncrementValue(const NdbDictionary::Table * aTable,
Uint64 & tupleId, Uint32 cacheSize); Uint64 & tupleId, Uint32 cacheSize);
int getAutoIncrementValue(const NdbDictionary::Table * aTable,
TupleIdRange & range, Uint64 & tupleId,
Uint32 cacheSize);
int readAutoIncrementValue(const char* aTableName, int readAutoIncrementValue(const char* aTableName,
Uint64 & tupleId); Uint64 & tupleId);
int readAutoIncrementValue(const NdbDictionary::Table * aTable, int readAutoIncrementValue(const NdbDictionary::Table * aTable,
Uint64 & tupleId); Uint64 & tupleId);
int readAutoIncrementValue(const NdbDictionary::Table * aTable,
TupleIdRange & range, Uint64 & tupleId);
int setAutoIncrementValue(const char* aTableName, int setAutoIncrementValue(const char* aTableName,
Uint64 tupleId, bool increase); Uint64 tupleId, bool increase);
int setAutoIncrementValue(const NdbDictionary::Table * aTable, int setAutoIncrementValue(const NdbDictionary::Table * aTable,
Uint64 tupleId, bool increase); Uint64 tupleId, bool increase);
int setAutoIncrementValue(const NdbDictionary::Table * aTable,
TupleIdRange & range, Uint64 tupleId,
bool increase);
private: private:
int getTupleIdFromNdb(Ndb_local_table_info* info, int getTupleIdFromNdb(const NdbTableImpl* table,
Uint64 & tupleId, Uint32 cacheSize); TupleIdRange & range, Uint64 & tupleId,
int readTupleIdFromNdb(Ndb_local_table_info* info, Uint32 cacheSize);
Uint64 & tupleId); int readTupleIdFromNdb(const NdbTableImpl* table,
int setTupleIdInNdb(Ndb_local_table_info* info, TupleIdRange & range, Uint64 & tupleId);
Uint64 tupleId, bool increase); int setTupleIdInNdb(const NdbTableImpl* table,
int opTupleIdOnNdb(Ndb_local_table_info* info, Uint64 & opValue, Uint32 op); TupleIdRange & range, Uint64 tupleId, bool increase);
int opTupleIdOnNdb(const NdbTableImpl* table,
TupleIdRange & range, Uint64 & opValue, Uint32 op);
public: public:
/** /**
......
...@@ -47,8 +47,7 @@ Ndb_local_table_info::Ndb_local_table_info(NdbTableImpl *table_impl) ...@@ -47,8 +47,7 @@ Ndb_local_table_info::Ndb_local_table_info(NdbTableImpl *table_impl)
{ {
assert(! is_ndb_blob_table(table_impl)); assert(! is_ndb_blob_table(table_impl));
m_table_impl= table_impl; m_table_impl= table_impl;
m_first_tuple_id = ~(Uint64)0; m_tuple_id_range.reset();
m_last_tuple_id = ~(Uint64)0;
} }
Ndb_local_table_info::~Ndb_local_table_info() Ndb_local_table_info::~Ndb_local_table_info()
......
...@@ -35,8 +35,7 @@ public: ...@@ -35,8 +35,7 @@ public:
NdbTableImpl *m_table_impl; NdbTableImpl *m_table_impl;
// range of cached tuple ids per thread // range of cached tuple ids per thread
Uint64 m_first_tuple_id; Ndb::TupleIdRange m_tuple_id_range;
Uint64 m_last_tuple_id;
Uint64 m_local_data[1]; // Must be last member. Used to access extra space. Uint64 m_local_data[1]; // Must be last member. Used to access extra space.
private: private:
......
This diff is collapsed.
...@@ -1343,9 +1343,6 @@ NdbDictionaryImpl::putTable(NdbTableImpl *impl) ...@@ -1343,9 +1343,6 @@ NdbDictionaryImpl::putTable(NdbTableImpl *impl)
Ndb_local_table_info::create(impl, m_local_table_data_size); Ndb_local_table_info::create(impl, m_local_table_data_size);
m_localHash.put(impl->m_internalName.c_str(), info); m_localHash.put(impl->m_internalName.c_str(), info);
m_ndb.theFirstTupleId[impl->getTableId()] = ~0;
m_ndb.theLastTupleId[impl->getTableId()] = ~0;
} }
int int
...@@ -2205,11 +2202,11 @@ NdbDictionaryImpl::createTable(NdbTableImpl &t) ...@@ -2205,11 +2202,11 @@ NdbDictionaryImpl::createTable(NdbTableImpl &t)
} }
if (autoIncrement) { if (autoIncrement) {
// XXX unlikely race condition - t.m_id may no longer be same table // XXX unlikely race condition - t.m_id may no longer be same table
if (! m_ndb.setTupleIdInNdb(t.m_id, initialValue, false)) { // the tuple id range is not used on input
if (m_ndb.theError.code) Ndb::TupleIdRange range;
if (m_ndb.setTupleIdInNdb(&t, range, initialValue, false) == -1) {
assert(m_ndb.theError.code != 0);
m_error.code = m_ndb.theError.code; m_error.code = m_ndb.theError.code;
else
m_error.code = 4336;
delete t2; delete t2;
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
......
...@@ -950,8 +950,6 @@ NdbDictionaryImpl::get_local_table_info(const BaseString& internalTableName) ...@@ -950,8 +950,6 @@ NdbDictionaryImpl::get_local_table_info(const BaseString& internalTableName)
if (info) if (info)
{ {
m_localHash.put(internalTableName.c_str(), info); m_localHash.put(internalTableName.c_str(), info);
m_ndb.theFirstTupleId[tab->getTableId()] = ~0;
m_ndb.theLastTupleId[tab->getTableId()] = ~0;
} }
} }
} }
......
...@@ -600,7 +600,6 @@ ErrorBundle ErrorCodes[] = { ...@@ -600,7 +600,6 @@ ErrorBundle ErrorCodes[] = {
{ 4269, DMEC, IE, "No connection to ndb management server" }, { 4269, DMEC, IE, "No connection to ndb management server" },
{ 4270, DMEC, IE, "Unknown blob error" }, { 4270, DMEC, IE, "Unknown blob error" },
{ 4335, DMEC, AE, "Only one autoincrement column allowed per table. Having a table without primary key uses an autoincremented hidden key, i.e. a table without a primary key can not have an autoincremented column" }, { 4335, DMEC, AE, "Only one autoincrement column allowed per table. Having a table without primary key uses an autoincremented hidden key, i.e. a table without a primary key can not have an autoincremented column" },
{ 4336, DMEC, AE, "Auto-increment value set below current value" },
{ 4271, DMEC, AE, "Invalid index object, not retrieved via getIndex()" }, { 4271, DMEC, AE, "Invalid index object, not retrieved via getIndex()" },
{ 4272, DMEC, AE, "Table definition has undefined column" }, { 4272, DMEC, AE, "Table definition has undefined column" },
{ 4273, DMEC, IE, "No blob table in dict cache" }, { 4273, DMEC, IE, "No blob table in dict cache" },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment