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:
/**
* 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
*
......@@ -1471,28 +1473,47 @@ public:
*
* @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 getAutoIncrementValue(const char* aTableName,
Uint64 & tupleId, Uint32 cacheSize);
int getAutoIncrementValue(const NdbDictionary::Table * aTable,
Uint64 & tupleId, Uint32 cacheSize);
int getAutoIncrementValue(const NdbDictionary::Table * aTable,
TupleIdRange & range, Uint64 & tupleId,
Uint32 cacheSize);
int readAutoIncrementValue(const char* aTableName,
Uint64 & tupleId);
int readAutoIncrementValue(const NdbDictionary::Table * aTable,
Uint64 & tupleId);
int readAutoIncrementValue(const NdbDictionary::Table * aTable,
TupleIdRange & range, Uint64 & tupleId);
int setAutoIncrementValue(const char* aTableName,
Uint64 tupleId, bool increase);
int setAutoIncrementValue(const NdbDictionary::Table * aTable,
Uint64 tupleId, bool increase);
int setAutoIncrementValue(const NdbDictionary::Table * aTable,
TupleIdRange & range, 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);
int getTupleIdFromNdb(const NdbTableImpl* table,
TupleIdRange & range, Uint64 & tupleId,
Uint32 cacheSize);
int readTupleIdFromNdb(const NdbTableImpl* table,
TupleIdRange & range, Uint64 & tupleId);
int setTupleIdInNdb(const NdbTableImpl* table,
TupleIdRange & range, Uint64 tupleId, bool increase);
int opTupleIdOnNdb(const NdbTableImpl* table,
TupleIdRange & range, Uint64 & opValue, Uint32 op);
public:
/**
......
......@@ -47,8 +47,7 @@ Ndb_local_table_info::Ndb_local_table_info(NdbTableImpl *table_impl)
{
assert(! is_ndb_blob_table(table_impl));
m_table_impl= table_impl;
m_first_tuple_id = ~(Uint64)0;
m_last_tuple_id = ~(Uint64)0;
m_tuple_id_range.reset();
}
Ndb_local_table_info::~Ndb_local_table_info()
......
......@@ -35,8 +35,7 @@ public:
NdbTableImpl *m_table_impl;
// range of cached tuple ids per thread
Uint64 m_first_tuple_id;
Uint64 m_last_tuple_id;
Ndb::TupleIdRange m_tuple_id_range;
Uint64 m_local_data[1]; // Must be last member. Used to access extra space.
private:
......
This diff is collapsed.
......@@ -1343,9 +1343,6 @@ NdbDictionaryImpl::putTable(NdbTableImpl *impl)
Ndb_local_table_info::create(impl, m_local_table_data_size);
m_localHash.put(impl->m_internalName.c_str(), info);
m_ndb.theFirstTupleId[impl->getTableId()] = ~0;
m_ndb.theLastTupleId[impl->getTableId()] = ~0;
}
int
......@@ -2205,11 +2202,11 @@ NdbDictionaryImpl::createTable(NdbTableImpl &t)
}
if (autoIncrement) {
// XXX unlikely race condition - t.m_id may no longer be same table
if (! m_ndb.setTupleIdInNdb(t.m_id, initialValue, false)) {
if (m_ndb.theError.code)
m_error.code = m_ndb.theError.code;
else
m_error.code = 4336;
// the tuple id range is not used on input
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;
delete t2;
DBUG_RETURN(-1);
}
......
......@@ -950,8 +950,6 @@ NdbDictionaryImpl::get_local_table_info(const BaseString& internalTableName)
if (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[] = {
{ 4269, DMEC, IE, "No connection to ndb management server" },
{ 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" },
{ 4336, DMEC, AE, "Auto-increment value set below current value" },
{ 4271, DMEC, AE, "Invalid index object, not retrieved via getIndex()" },
{ 4272, DMEC, AE, "Table definition has undefined column" },
{ 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