Below is the list of changes that have just been committed into a local
5.1 repository of marty. When marty does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-06-14 16:18:40+02:00, mskold@stripped +3 -0
Merge mysql.com:/windows/Linux_space/MySQL/mysql-5.0-ndb
into mysql.com:/windows/Linux_space/MySQL/mysql-5.1-new-ndb
MERGE: 1.1810.2943.27
sql/ha_ndbcluster.cc@stripped, 2007-06-14 16:16:41+02:00, mskold@stripped +0 -1
Merge
MERGE: 1.175.1.138
sql/handler.cc@stripped, 2007-06-14 16:14:32+02:00, mskold@stripped +0 -0
Auto merged
MERGE: 1.167.1.67
storage/ndb/src/ndbapi/Ndb.cpp@stripped, 2007-06-14 16:18:36+02:00, mskold@stripped +2 -4
Merge
MERGE: 1.49.28.2
storage/ndb/src/ndbapi/Ndb.cpp@stripped, 2007-06-14 16:14:32+02:00, mskold@stripped
+0 -0
Merge rename: ndb/src/ndbapi/Ndb.cpp -> storage/ndb/src/ndbapi/Ndb.cpp
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: mskold
# Host: linux.site
# Root: /windows/Linux_space/MySQL/mysql-5.1-new-ndb/RESYNC
--- 1.49.28.1/ndb/src/ndbapi/Ndb.cpp 2007-06-14 16:18:50 +02:00
+++ 1.95/storage/ndb/src/ndbapi/Ndb.cpp 2007-06-14 16:18:50 +02:00
@@ -27,6 +27,8 @@ Name: Ndb.cpp
#include "NdbImpl.hpp"
#include <NdbOperation.hpp>
#include <NdbTransaction.hpp>
+#include <NdbEventOperation.hpp>
+#include <NdbEventOperationImpl.hpp>
#include <NdbRecAttr.hpp>
#include <md5_hash.hpp>
#include <NdbSleep.h>
@@ -142,7 +144,7 @@ Ndb::NDB_connect(Uint32 tNode)
//***************************************************************************
int tReturnCode;
- TransporterFacade *tp = TransporterFacade::instance();
+ TransporterFacade *tp = theImpl->m_transporter_facade;
DBUG_ENTER("Ndb::NDB_connect");
@@ -177,24 +179,9 @@ Ndb::NDB_connect(Uint32 tNode)
tSignal->setData(theMyRef, 2); // Set my block reference
tNdbCon->Status(NdbTransaction::Connecting); // Set status to connecting
Uint32 nodeSequence;
- { // send and receive signal
- Guard guard(tp->theMutexPtr);
- nodeSequence = tp->getNodeSequence(tNode);
- bool node_is_alive = tp->get_node_alive(tNode);
- if (node_is_alive) {
- DBUG_PRINT("info",("Sending signal to node %u", tNode));
- tReturnCode = tp->sendSignal(tSignal, tNode);
- releaseSignal(tSignal);
- if (tReturnCode != -1) {
- theImpl->theWaiter.m_node = tNode;
- theImpl->theWaiter.m_state = WAIT_TC_SEIZE;
- tReturnCode = receiveResponse();
- }//if
- } else {
- releaseSignal(tSignal);
- tReturnCode = -1;
- }//if
- }
+ tReturnCode= sendRecSignal(tNode, WAIT_TC_SEIZE, tSignal,
+ 0, &nodeSequence);
+ releaseSignal(tSignal);
if ((tReturnCode == 0) && (tNdbCon->Status() == NdbTransaction::Connected))
{
//************************************************
// Send and receive was successful
@@ -240,10 +227,9 @@ Remark: Disconnect all connection
void
Ndb::doDisconnect()
{
+ DBUG_ENTER("Ndb::doDisconnect");
NdbTransaction* tNdbCon;
CHECK_STATUS_MACRO_VOID;
- /* DBUG_ENTER must be after CHECK_STATUS_MACRO_VOID because of 'return' */
- DBUG_ENTER("Ndb::doDisconnect");
Uint32 tNoOfDbNodes = theImpl->theNoOfDBnodes;
Uint8 *theDBnodes= theImpl->theDBnodes;
@@ -603,6 +589,7 @@ Ndb::NdbTamper(TamperType aAction, int a
#ifdef CUSTOMER_RELEASE
return -1;
#else
+ DBUG_ENTER("Ndb::NdbTamper");
CHECK_STATUS_MACRO;
checkFailedNode();
@@ -624,20 +611,20 @@ Ndb::NdbTamper(TamperType aAction, int a
break;
default:
theError.code = 4102;
- return -1;
+ DBUG_RETURN(-1);
}
tNdbConn = getNdbCon(); // Get free connection object
if (tNdbConn == NULL) {
theError.code = 4000;
- return -1;
+ DBUG_RETURN(-1);
}
tSignal.setSignal(GSN_DIHNDBTAMPER);
tSignal.setData (tAction, 1);
tSignal.setData(tNdbConn->ptr2int(),2);
tSignal.setData(theMyRef,3); // Set return block reference
tNdbConn->Status(NdbTransaction::Connecting); // Set status to connecting
- TransporterFacade *tp = TransporterFacade::instance();
+ TransporterFacade *tp = theImpl->m_transporter_facade;
if (tAction == 3) {
tp->lock_mutex();
tp->sendSignal(&tSignal, aNode);
@@ -649,12 +636,12 @@ Ndb::NdbTamper(TamperType aAction, int a
if (tNode == 0) {
theError.code = 4002;
releaseNdbCon(tNdbConn);
- return -1;
+ DBUG_RETURN(-1);
}//if
ret_code = tp->sendSignal(&tSignal,aNode);
tp->unlock_mutex();
releaseNdbCon(tNdbConn);
- return ret_code;
+ DBUG_RETURN(ret_code);
} else {
do {
tp->lock_mutex();
@@ -665,7 +652,7 @@ Ndb::NdbTamper(TamperType aAction, int a
if (tNode == 0) {
theError.code = 4009;
releaseNdbCon(tNdbConn);
- return -1;
+ DBUG_RETURN(-1);
}//if
ret_code = sendRecSignal(tNode, WAIT_NDB_TAMPER, &tSignal, 0);
if (ret_code == 0) {
@@ -673,15 +660,15 @@ Ndb::NdbTamper(TamperType aAction, int a
theRestartGCI = 0;
}//if
releaseNdbCon(tNdbConn);
- return theRestartGCI;
+ DBUG_RETURN(theRestartGCI);
} else if ((ret_code == -5) || (ret_code == -2)) {
TRACE_DEBUG("Continue DIHNDBTAMPER when node failed/stopping");
} else {
- return -1;
+ DBUG_RETURN(-1);
}//if
} while (1);
}
- return 0;
+ DBUG_RETURN(0);
#endif
}
#if 0
@@ -768,7 +755,7 @@ Ndb::getNodeId()
/****************************************************************************
Uint64 getAutoIncrementValue( const char* aTableName,
- Uint64 & tupleId,
+ Uint64 & autoValue,
Uint32 cacheSize,
Uint64 step,
Uint64 start);
@@ -786,20 +773,22 @@ Remark: Returns a new autoincrement val
****************************************************************************/
int
Ndb::getAutoIncrementValue(const char* aTableName,
- Uint64 & autoValue, Uint32 cacheSize,
- Uint64 step, Uint64 start)
+ Uint64 & autoValue, Uint32 cacheSize,
+ Uint64 step, Uint64 start)
{
DBUG_ENTER("Ndb::getAutoIncrementValue");
+ ASSERT_NOT_MYSQLD;
BaseString internal_tabname(internalize_table_name(aTableName));
Ndb_local_table_info *info=
- theDictionary->get_local_table_info(internal_tabname, false);
+ theDictionary->get_local_table_info(internal_tabname);
if (info == 0) {
theError.code = theDictionary->getNdbError().code;
DBUG_RETURN(-1);
}
- DBUG_PRINT("info", ("step %lu", (ulong) step));
- if (getTupleIdFromNdb(info, autoValue, cacheSize, step, start) == -1)
+ const NdbTableImpl* table = info->m_table_impl;
+ TupleIdRange & range = info->m_tuple_id_range;
+ if (getTupleIdFromNdb(table, range, autoValue, cacheSize, step, start) == -1)
DBUG_RETURN(-1);
DBUG_PRINT("info", ("value %lu", (ulong) autoValue));
DBUG_RETURN(0);
@@ -807,31 +796,47 @@ Ndb::getAutoIncrementValue(const char* a
int
Ndb::getAutoIncrementValue(const NdbDictionary::Table * aTable,
- Uint64 & autoValue, Uint32 cacheSize,
- Uint64 step, Uint64 start)
+ Uint64 & autoValue, Uint32 cacheSize,
+ Uint64 step, Uint64 start)
{
DBUG_ENTER("Ndb::getAutoIncrementValue");
+ ASSERT_NOT_MYSQLD;
assert(aTable != 0);
const NdbTableImpl* table = & NdbTableImpl::getImpl(*aTable);
const BaseString& internal_tabname = table->m_internalName;
Ndb_local_table_info *info=
- theDictionary->get_local_table_info(internal_tabname, false);
+ theDictionary->get_local_table_info(internal_tabname);
if (info == 0) {
theError.code = theDictionary->getNdbError().code;
DBUG_RETURN(-1);
}
- DBUG_PRINT("info", ("step %lu", (ulong) step));
- if (getTupleIdFromNdb(info, autoValue, cacheSize, step, start) == -1)
+ TupleIdRange & range = info->m_tuple_id_range;
+ if (getTupleIdFromNdb(table, range, autoValue, cacheSize, step, start) == -1)
DBUG_RETURN(-1);
- DBUG_PRINT("info", ("value %lu", (ulong) autoValue));
+ DBUG_PRINT("info", ("value %lu", (ulong)autoValue));
DBUG_RETURN(0);
}
int
-Ndb::getTupleIdFromNdb(Ndb_local_table_info* info,
- Uint64 & tupleId, Uint32 cacheSize,
- Uint64 step, Uint64 start)
+Ndb::getAutoIncrementValue(const NdbDictionary::Table * aTable,
+ TupleIdRange & range, Uint64 & autoValue,
+ Uint32 cacheSize, Uint64 step, Uint64 start)
+{
+ DBUG_ENTER("Ndb::getAutoIncrementValue");
+ assert(aTable != 0);
+ const NdbTableImpl* table = & NdbTableImpl::getImpl(*aTable);
+
+ if (getTupleIdFromNdb(table, range, autoValue, cacheSize, step, start) == -1)
+ DBUG_RETURN(-1);
+ DBUG_PRINT("info", ("value %lu", (ulong)autoValue));
+ DBUG_RETURN(0);
+}
+
+int
+Ndb::getTupleIdFromNdb(const NdbTableImpl* table,
+ TupleIdRange & range, Uint64 & tupleId,
+ Uint32 cacheSize, Uint64 step, Uint64 start)
{
/*
Returns a new TupleId to the application.
@@ -843,25 +848,24 @@ Ndb::getTupleIdFromNdb(Ndb_local_table_i
5,15,25,35,...
*/
DBUG_ENTER("Ndb::getTupleIdFromNdb");
- DBUG_PRINT("info", ("Step %lu (%lu,%lu)", (ulong) step, (ulong)
info->m_first_tuple_id, (ulong) info->m_last_tuple_id));
/*
Check if the next value can be taken from the pre-fetched
sequence.
*/
- if (info->m_first_tuple_id != info->m_last_tuple_id &&
- info->m_first_tuple_id + step <= info->m_last_tuple_id)
+ if (range.m_first_tuple_id != range.m_last_tuple_id &&
+ range.m_first_tuple_id + step <= range.m_last_tuple_id)
{
- assert(info->m_first_tuple_id < info->m_last_tuple_id);
- info->m_first_tuple_id += step;
- tupleId = info->m_first_tuple_id;
+ assert(range.m_first_tuple_id < range.m_last_tuple_id);
+ range.m_first_tuple_id += step;
+ tupleId = range.m_first_tuple_id;
DBUG_PRINT("info", ("Next cached value %lu", (ulong) tupleId));
}
else
{
- /*
- If start value is greater than step it is ignored
- */
- Uint64 offset = (start > step) ? 1 : start;
+ /*
+ If start value is greater than step it is ignored
+ */
+ Uint64 offset = (start > step) ? 1 : start;
/*
Pre-fetch a number of values depending on cacheSize
@@ -869,7 +873,7 @@ Ndb::getTupleIdFromNdb(Ndb_local_table_i
if (cacheSize == 0)
cacheSize = 1;
- DBUG_PRINT("info", ("Reading %u values from database", (uint)cacheSize));
+ DBUG_PRINT("info", ("reading %u values from database", (uint)cacheSize));
/*
* reserve next cacheSize entries in db. adds cacheSize to NEXTID
* and returns first tupleId in the new range. If tupleId's are
@@ -877,7 +881,7 @@ Ndb::getTupleIdFromNdb(Ndb_local_table_i
*/
Uint64 opValue = cacheSize * step;
- if (opTupleIdOnNdb(info, opValue, 0) == -1)
+ if (opTupleIdOnNdb(table, range, opValue, 0) == -1)
DBUG_RETURN(-1);
DBUG_PRINT("info", ("Next value fetched from database %lu", (ulong) opValue));
DBUG_PRINT("info", ("Increasing %lu by offset %lu, increment is %lu", (ulong)
(ulong) opValue, (ulong) offset, (ulong) step));
@@ -887,7 +891,7 @@ Ndb::getTupleIdFromNdb(Ndb_local_table_i
current = (next < step) ? next : next - step;
tupleId = (opValue <= current) ? current : next;
DBUG_PRINT("info", ("Returning %lu", (ulong) tupleId));
- info->m_first_tuple_id = tupleId;
+ range.m_first_tuple_id = tupleId;
}
DBUG_RETURN(0);
}
@@ -897,15 +901,18 @@ Ndb::readAutoIncrementValue(const char*
Uint64 & tupleId)
{
DBUG_ENTER("Ndb::readAutoIncrementValue");
+ ASSERT_NOT_MYSQLD;
BaseString internal_tabname(internalize_table_name(aTableName));
Ndb_local_table_info *info=
- theDictionary->get_local_table_info(internal_tabname, false);
+ theDictionary->get_local_table_info(internal_tabname);
if (info == 0) {
theError.code = theDictionary->getNdbError().code;
DBUG_RETURN(-1);
}
- if (readTupleIdFromNdb(info, tupleId) == -1)
+ const NdbTableImpl* table = info->m_table_impl;
+ TupleIdRange & range = info->m_tuple_id_range;
+ if (readTupleIdFromNdb(table, range, tupleId) == -1)
DBUG_RETURN(-1);
DBUG_PRINT("info", ("value %lu", (ulong)tupleId));
DBUG_RETURN(0);
@@ -916,31 +923,47 @@ Ndb::readAutoIncrementValue(const NdbDic
Uint64 & tupleId)
{
DBUG_ENTER("Ndb::readAutoIncrementValue");
+ ASSERT_NOT_MYSQLD;
assert(aTable != 0);
const NdbTableImpl* table = & NdbTableImpl::getImpl(*aTable);
const BaseString& internal_tabname = table->m_internalName;
Ndb_local_table_info *info=
- theDictionary->get_local_table_info(internal_tabname, false);
+ theDictionary->get_local_table_info(internal_tabname);
if (info == 0) {
theError.code = theDictionary->getNdbError().code;
DBUG_RETURN(-1);
}
- if (readTupleIdFromNdb(info, tupleId) == -1)
+ TupleIdRange & range = info->m_tuple_id_range;
+ if (readTupleIdFromNdb(table, range, tupleId) == -1)
DBUG_RETURN(-1);
DBUG_PRINT("info", ("value %lu", (ulong)tupleId));
DBUG_RETURN(0);
}
int
-Ndb::readTupleIdFromNdb(Ndb_local_table_info* info,
- Uint64 & tupleId)
+Ndb::readAutoIncrementValue(const NdbDictionary::Table * aTable,
+ TupleIdRange & range, Uint64 & tupleId)
+{
+ DBUG_ENTER("Ndb::readAutoIncrementValue");
+ assert(aTable != 0);
+ const NdbTableImpl* table = & NdbTableImpl::getImpl(*aTable);
+
+ if (readTupleIdFromNdb(table, range, tupleId) == -1)
+ DBUG_RETURN(-1);
+ DBUG_PRINT("info", ("value %lu", (ulong)tupleId));
+ DBUG_RETURN(0);
+}
+
+int
+Ndb::readTupleIdFromNdb(const NdbTableImpl* table,
+ TupleIdRange & range, Uint64 & tupleId)
{
DBUG_ENTER("Ndb::readTupleIdFromNdb");
- if (info->m_first_tuple_id != info->m_last_tuple_id)
+ if (range.m_first_tuple_id != range.m_last_tuple_id)
{
- assert(info->m_first_tuple_id < info->m_last_tuple_id);
- tupleId = info->m_first_tuple_id + 1;
+ assert(range.m_first_tuple_id < range.m_last_tuple_id);
+ tupleId = range.m_first_tuple_id + 1;
}
else
{
@@ -949,7 +972,7 @@ Ndb::readTupleIdFromNdb(Ndb_local_table_
* only if no other transactions are allowed.
*/
Uint64 opValue = 0;
- if (opTupleIdOnNdb(info, opValue, 3) == -1)
+ if (opTupleIdOnNdb(table, range, opValue, 3) == -1)
DBUG_RETURN(-1);
tupleId = opValue;
}
@@ -961,15 +984,18 @@ Ndb::setAutoIncrementValue(const char* a
Uint64 tupleId, bool increase)
{
DBUG_ENTER("Ndb::setAutoIncrementValue");
+ ASSERT_NOT_MYSQLD;
BaseString internal_tabname(internalize_table_name(aTableName));
Ndb_local_table_info *info=
- theDictionary->get_local_table_info(internal_tabname, false);
+ theDictionary->get_local_table_info(internal_tabname);
if (info == 0) {
theError.code = theDictionary->getNdbError().code;
DBUG_RETURN(-1);
}
- if (setTupleIdInNdb(info, tupleId, increase) == -1)
+ const NdbTableImpl* table = info->m_table_impl;
+ TupleIdRange & range = info->m_tuple_id_range;
+ if (setTupleIdInNdb(table, range, tupleId, increase) == -1)
DBUG_RETURN(-1);
DBUG_RETURN(0);
}
@@ -979,36 +1005,52 @@ Ndb::setAutoIncrementValue(const NdbDict
Uint64 tupleId, bool increase)
{
DBUG_ENTER("Ndb::setAutoIncrementValue");
+ ASSERT_NOT_MYSQLD;
assert(aTable != 0);
const NdbTableImpl* table = & NdbTableImpl::getImpl(*aTable);
const BaseString& internal_tabname = table->m_internalName;
Ndb_local_table_info *info=
- theDictionary->get_local_table_info(internal_tabname, false);
+ theDictionary->get_local_table_info(internal_tabname);
if (info == 0) {
theError.code = theDictionary->getNdbError().code;
DBUG_RETURN(-1);
}
- if (setTupleIdInNdb(info, tupleId, increase) == -1)
+ TupleIdRange & range = info->m_tuple_id_range;
+ if (setTupleIdInNdb(table, range, tupleId, increase) == -1)
+ DBUG_RETURN(-1);
+ DBUG_RETURN(0);
+}
+
+int
+Ndb::setAutoIncrementValue(const NdbDictionary::Table * aTable,
+ TupleIdRange & range, Uint64 tupleId,
+ bool increase)
+{
+ DBUG_ENTER("Ndb::setAutoIncrementValue");
+ assert(aTable != 0);
+ const NdbTableImpl* table = & NdbTableImpl::getImpl(*aTable);
+
+ if (setTupleIdInNdb(table, range, tupleId, increase) == -1)
DBUG_RETURN(-1);
DBUG_RETURN(0);
}
int
-Ndb::setTupleIdInNdb(Ndb_local_table_info* info,
- Uint64 tupleId, bool increase)
+Ndb::setTupleIdInNdb(const NdbTableImpl* table,
+ TupleIdRange & range, Uint64 tupleId, bool increase)
{
DBUG_ENTER("Ndb::setTupleIdInNdb");
if (increase)
{
- if (info->m_first_tuple_id != info->m_last_tuple_id)
+ if (range.m_first_tuple_id != range.m_last_tuple_id)
{
- assert(info->m_first_tuple_id < info->m_last_tuple_id);
- if (tupleId <= info->m_first_tuple_id + 1)
+ assert(range.m_first_tuple_id < range.m_last_tuple_id);
+ if (tupleId <= range.m_first_tuple_id + 1)
DBUG_RETURN(0);
- if (tupleId <= info->m_last_tuple_id)
+ if (tupleId <= range.m_last_tuple_id)
{
- info->m_first_tuple_id = tupleId - 1;
+ range.m_first_tuple_id = tupleId - 1;
DBUG_PRINT("info",
("Setting next auto increment cached value to %lu",
(ulong)tupleId));
@@ -1019,7 +1061,7 @@ Ndb::setTupleIdInNdb(Ndb_local_table_inf
* if tupleId <= NEXTID, do nothing. otherwise update NEXTID to
* tupleId and set cached range to first = last = tupleId - 1.
*/
- if (opTupleIdOnNdb(info, tupleId, 2) == -1)
+ if (opTupleIdOnNdb(table, range, tupleId, 2) == -1)
DBUG_RETURN(-1);
}
else
@@ -1027,42 +1069,62 @@ Ndb::setTupleIdInNdb(Ndb_local_table_inf
/*
* update NEXTID to given value. reset cached range.
*/
- if (opTupleIdOnNdb(info, tupleId, 1) == -1)
+ if (opTupleIdOnNdb(table, range, tupleId, 1) == -1)
DBUG_RETURN(-1);
}
DBUG_RETURN(0);
}
+int Ndb::initAutoIncrement()
+{
+ if (m_sys_tab_0)
+ return 0;
+
+ BaseString currentDb(getDatabaseName());
+ BaseString currentSchema(getDatabaseSchemaName());
+
+ setDatabaseName("sys");
+ setDatabaseSchemaName("def");
+
+ m_sys_tab_0 = theDictionary->getTableGlobal("SYSTAB_0");
+
+ // Restore current name space
+ setDatabaseName(currentDb.c_str());
+ setDatabaseSchemaName(currentSchema.c_str());
+
+ if (m_sys_tab_0 == NULL) {
+ assert(theDictionary->m_error.code != 0);
+ theError.code = theDictionary->m_error.code;
+ return -1;
+ }
+
+ return 0;
+}
+
int
-Ndb::opTupleIdOnNdb(Ndb_local_table_info* info, Uint64 & opValue, Uint32 op)
+Ndb::opTupleIdOnNdb(const NdbTableImpl* table,
+ TupleIdRange & range, Uint64 & opValue, Uint32 op)
{
DBUG_ENTER("Ndb::opTupleIdOnNdb");
- Uint32 aTableId = info->m_table_impl->m_tableId;
+ Uint32 aTableId = table->m_id;
DBUG_PRINT("enter", ("table: %u value: %lu op: %u",
aTableId, (ulong) opValue, op));
- NdbTransaction* tConnection;
- NdbOperation* tOperation= 0; // Compiler warning if not initialized
+ NdbTransaction* tConnection = NULL;
+ NdbOperation* tOperation = NULL;
Uint64 tValue;
NdbRecAttr* tRecAttrResult;
- NdbError savedError;
-
- CHECK_STATUS_MACRO_ZERO;
+ CHECK_STATUS_MACRO;
- BaseString currentDb(getDatabaseName());
- BaseString currentSchema(getDatabaseSchemaName());
+ if (initAutoIncrement() == -1)
+ goto error_handler;
- setDatabaseName("sys");
- setDatabaseSchemaName("def");
tConnection = this->startTransaction();
if (tConnection == NULL)
- goto error_return;
+ goto error_handler;
- if (usingFullyQualifiedNames())
- tOperation = tConnection->getNdbOperation("SYSTAB_0");
- else
- tOperation = tConnection->getNdbOperation("sys/def/SYSTAB_0");
+ tOperation = tConnection->getNdbOperation(m_sys_tab_0);
if (tOperation == NULL)
goto error_handler;
@@ -1070,18 +1132,18 @@ Ndb::opTupleIdOnNdb(Ndb_local_table_info
{
case 0:
tOperation->interpretedUpdateTuple();
- tOperation->equal("SYSKEY_0", aTableId );
+ tOperation->equal("SYSKEY_0", aTableId);
tOperation->incValue("NEXTID", opValue);
tRecAttrResult = tOperation->getValue("NEXTID");
- if (tConnection->execute( Commit ) == -1 )
+ if (tConnection->execute( NdbTransaction::Commit ) == -1 )
goto error_handler;
tValue = tRecAttrResult->u_64_value();
- info->m_first_tuple_id = tValue - opValue;
- info->m_last_tuple_id = tValue - 1;
- opValue = info->m_first_tuple_id; // out
+ range.m_first_tuple_id = tValue - opValue;
+ range.m_last_tuple_id = tValue - 1;
+ opValue = range.m_first_tuple_id; // out
break;
case 1:
// create on first use
@@ -1089,11 +1151,10 @@ Ndb::opTupleIdOnNdb(Ndb_local_table_info
tOperation->equal("SYSKEY_0", aTableId );
tOperation->setValue("NEXTID", opValue);
- if (tConnection->execute( Commit ) == -1 )
+ if (tConnection->execute( NdbTransaction::Commit ) == -1 )
goto error_handler;
- info->m_first_tuple_id = ~(Uint64)0;
- info->m_last_tuple_id = ~(Uint64)0;
+ range.reset();
break;
case 2:
tOperation->interpretedUpdateTuple();
@@ -1107,24 +1168,24 @@ Ndb::opTupleIdOnNdb(Ndb_local_table_info
tOperation->def_label(0);
tOperation->interpret_exit_nok(9999);
- if (tConnection->execute( Commit ) == -1)
+ if (tConnection->execute( NdbTransaction::Commit ) == -1)
{
if (tConnection->theError.code != 9999)
goto error_handler;
}
else
{
- DBUG_PRINT("info",
- ("Setting next auto increment value (db) to %lu",
- (ulong)opValue));
- info->m_first_tuple_id = info->m_last_tuple_id = opValue - 1;
+ DBUG_PRINT("info",
+ ("Setting next auto increment value (db) to %lu",
+ (ulong) opValue));
+ range.m_first_tuple_id = range.m_last_tuple_id = opValue - 1;
}
break;
case 3:
tOperation->readTuple();
tOperation->equal("SYSKEY_0", aTableId );
tRecAttrResult = tOperation->getValue("NEXTID");
- if (tConnection->execute( Commit ) == -1 )
+ if (tConnection->execute( NdbTransaction::Commit ) == -1 )
goto error_handler;
opValue = tRecAttrResult->u_64_value(); // out
break;
@@ -1134,29 +1195,28 @@ Ndb::opTupleIdOnNdb(Ndb_local_table_info
this->closeTransaction(tConnection);
- // Restore current name space
- setDatabaseName(currentDb.c_str());
- setDatabaseSchemaName(currentSchema.c_str());
-
DBUG_RETURN(0);
- error_handler:
+error_handler:
+ DBUG_PRINT("error", ("ndb=%d con=%d op=%d",
+ theError.code,
+ tConnection != NULL ? tConnection->theError.code : -1,
+ tOperation != NULL ? tOperation->theError.code : -1));
+
+ if (theError.code == 0 && tConnection != NULL)
theError.code = tConnection->theError.code;
+ if (theError.code == 0 && tOperation != NULL)
+ theError.code = tOperation->theError.code;
+ DBUG_ASSERT(theError.code != 0);
- savedError = theError;
+ NdbError savedError;
+ savedError = theError;
+ if (tConnection != NULL)
this->closeTransaction(tConnection);
- theError = savedError;
- error_return:
- // Restore current name space
- setDatabaseName(currentDb.c_str());
- setDatabaseSchemaName(currentSchema.c_str());
+ theError = savedError;
- DBUG_PRINT("error", ("ndb=%d con=%d op=%d",
- theError.code,
- tConnection ? tConnection->theError.code : -1,
- tOperation ? tOperation->theError.code : -1));
DBUG_RETURN(-1);
}
@@ -1177,16 +1237,23 @@ convertEndian(Uint32 Data)
return Data;
#endif
}
+
+// <internal>
+Ndb_cluster_connection &
+Ndb::get_ndb_cluster_connection()
+{
+ return theImpl->m_ndb_cluster_connection;
+}
+
const char * Ndb::getCatalogName() const
{
return theImpl->m_dbname.c_str();
}
-
int Ndb::setCatalogName(const char * a_catalog_name)
{
- if (a_catalog_name)
- {
+ // TODO can table_name_separator be escaped?
+ if (a_catalog_name && ! strchr(a_catalog_name, table_name_separator)) {
if (!theImpl->m_dbname.assign(a_catalog_name) ||
theImpl->update_prefix())
{
@@ -1202,10 +1269,10 @@ const char * Ndb::getSchemaName() const
return theImpl->m_schemaname.c_str();
}
-
int Ndb::setSchemaName(const char * a_schema_name)
{
- if (a_schema_name) {
+ // TODO can table_name_separator be escaped?
+ if (a_schema_name && ! strchr(a_schema_name, table_name_separator)) {
if (!theImpl->m_schemaname.assign(a_schema_name) ||
theImpl->update_prefix())
{
@@ -1215,10 +1282,8 @@ int Ndb::setSchemaName(const char * a_sc
}
return 0;
}
+// </internal>
-/*
-Deprecated functions
-*/
const char * Ndb::getDatabaseName() const
{
return getCatalogName();
@@ -1238,6 +1303,26 @@ int Ndb::setDatabaseSchemaName(const cha
{
return setSchemaName(a_schema_name);
}
+
+int Ndb::setDatabaseAndSchemaName(const NdbDictionary::Table* t)
+{
+ const char* s0 = t->m_impl.m_internalName.c_str();
+ const char* s1 = strchr(s0, table_name_separator);
+ if (s1 && s1 != s0) {
+ const char* s2 = strchr(s1 + 1, table_name_separator);
+ if (s2 && s2 != s1 + 1) {
+ char buf[NAME_LEN + 1];
+ if (s1 - s0 <= NAME_LEN && s2 - (s1 + 1) <= NAME_LEN) {
+ sprintf(buf, "%.*s", (int) (s1 - s0), s0);
+ setDatabaseName(buf);
+ sprintf(buf, "%.*s", (int) (s2 - (s1 + 1)), s1 + 1);
+ setDatabaseSchemaName(buf);
+ return 0;
+ }
+ }
+ }
+ return -1;
+}
bool Ndb::usingFullyQualifiedNames()
{
@@ -1300,9 +1385,16 @@ Ndb::internalize_table_name(const char *
if (fullyQualifiedNames)
{
/* Internal table name format <db>/<schema>/<table>
- <db>/<schema> is already available in m_prefix
+ <db>/<schema>/ is already available in m_prefix
so just concat the two strings
*/
+#ifdef VM_TRACE
+ // verify that m_prefix looks like abc/def/
+ const char* s0 = theImpl->m_prefix.c_str();
+ const char* s1 = s0 ? strchr(s0, table_name_separator) : 0;
+ const char* s2 = s1 ? strchr(s1 + 1, table_name_separator) : 0;
+ assert(s1 && s1 != s0 && s2 && s2 != s1 + 1 && *(s2 +
1) == 0);
+#endif
ret.assfmt("%s%s",
theImpl->m_prefix.c_str(),
external_name);
@@ -1314,6 +1406,35 @@ Ndb::internalize_table_name(const char *
DBUG_RETURN(ret);
}
+const BaseString
+Ndb::old_internalize_index_name(const NdbTableImpl * table,
+ const char * external_name) const
+{
+ BaseString ret;
+ DBUG_ENTER("old_internalize_index_name");
+ DBUG_PRINT("enter", ("external_name: %s, table_id: %d",
+ external_name, table ? table->m_id : ~0));
+ if (!table)
+ {
+ DBUG_PRINT("error", ("!table"));
+ DBUG_RETURN(ret);
+ }
+
+ if (fullyQualifiedNames)
+ {
+ /* Internal index name format <db>/<schema>/<tabid>/<table>
*/
+ ret.assfmt("%s%d%c%s",
+ theImpl->m_prefix.c_str(),
+ table->m_id,
+ table_name_separator,
+ external_name);
+ }
+ else
+ ret.assign(external_name);
+
+ DBUG_PRINT("exit", ("internal_name: %s", ret.c_str()));
+ DBUG_RETURN(ret);
+}
const BaseString
Ndb::internalize_index_name(const NdbTableImpl * table,
@@ -1322,7 +1443,7 @@ Ndb::internalize_index_name(const NdbTab
BaseString ret;
DBUG_ENTER("internalize_index_name");
DBUG_PRINT("enter", ("external_name: %s, table_id: %d",
- external_name, table ? table->m_tableId : ~0));
+ external_name, table ? table->m_id : ~0));
if (!table)
{
DBUG_PRINT("error", ("!table"));
@@ -1331,10 +1452,10 @@ Ndb::internalize_index_name(const NdbTab
if (fullyQualifiedNames)
{
- /* Internal index name format <db>/<schema>/<tabid>/<table>
*/
+ /* Internal index name format sys/def/<tabid>/<table> */
ret.assfmt("%s%d%c%s",
- theImpl->m_prefix.c_str(),
- table->m_tableId,
+ theImpl->m_systemPrefix.c_str(),
+ table->m_id,
table_name_separator,
external_name);
}
@@ -1389,6 +1510,113 @@ Ndb::getSchemaFromInternalName(const cha
BaseString ret = BaseString(schemaName);
delete [] schemaName;
return ret;
+}
+
+// ToDo set event buffer size
+NdbEventOperation* Ndb::createEventOperation(const char* eventName)
+{
+ DBUG_ENTER("Ndb::createEventOperation");
+ NdbEventOperation* tOp= theEventBuffer->createEventOperation(eventName,
+ theError);
+ if (tOp)
+ {
+ // keep track of all event operations
+ NdbEventOperationImpl *op=
+ NdbEventBuffer::getEventOperationImpl(tOp);
+ op->m_next= theImpl->m_ev_op;
+ op->m_prev= 0;
+ theImpl->m_ev_op= op;
+ if (op->m_next)
+ op->m_next->m_prev= op;
+ }
+
+ DBUG_RETURN(tOp);
+}
+
+int Ndb::dropEventOperation(NdbEventOperation* tOp)
+{
+ DBUG_ENTER("Ndb::dropEventOperation");
+ DBUG_PRINT("info", ("name: %s", tOp->getEvent()->getTable()->getName()));
+ // remove it from list
+ NdbEventOperationImpl *op=
+ NdbEventBuffer::getEventOperationImpl(tOp);
+ if (op->m_next)
+ op->m_next->m_prev= op->m_prev;
+ if (op->m_prev)
+ op->m_prev->m_next= op->m_next;
+ else
+ theImpl->m_ev_op= op->m_next;
+
+ DBUG_PRINT("info", ("first: %s",
+ theImpl->m_ev_op ?
theImpl->m_ev_op->getEvent()->getTable()->getName() : "<empty>"));
+ assert(theImpl->m_ev_op == 0 || theImpl->m_ev_op->m_prev == 0);
+
+ theEventBuffer->dropEventOperation(tOp);
+ DBUG_RETURN(0);
+}
+
+NdbEventOperation *Ndb::getEventOperation(NdbEventOperation* tOp)
+{
+ NdbEventOperationImpl *op;
+ if (tOp)
+ op= NdbEventBuffer::getEventOperationImpl(tOp)->m_next;
+ else
+ op= theImpl->m_ev_op;
+ if (op)
+ return op->m_facade;
+ return 0;
+}
+
+int
+Ndb::pollEvents(int aMillisecondNumber, Uint64 *latestGCI)
+{
+ return theEventBuffer->pollEvents(aMillisecondNumber, latestGCI);
+}
+
+int
+Ndb::flushIncompleteEvents(Uint64 gci)
+{
+ return theEventBuffer->flushIncompleteEvents(gci);
+}
+
+NdbEventOperation *Ndb::nextEvent()
+{
+ return theEventBuffer->nextEvent();
+}
+
+const NdbEventOperation*
+Ndb::getGCIEventOperations(Uint32* iter, Uint32* event_types)
+{
+ NdbEventOperationImpl* op =
+ theEventBuffer->getGCIEventOperations(iter, event_types);
+ if (op != NULL)
+ return op->m_facade;
+ return NULL;
+}
+
+Uint64 Ndb::getLatestGCI()
+{
+ return theEventBuffer->getLatestGCI();
+}
+
+void Ndb::setReportThreshEventGCISlip(unsigned thresh)
+{
+ if (theEventBuffer->m_free_thresh != thresh)
+ {
+ theEventBuffer->m_free_thresh= thresh;
+ theEventBuffer->m_min_free_thresh= thresh;
+ theEventBuffer->m_max_free_thresh= 100;
+ }
+}
+
+void Ndb::setReportThreshEventFreeMem(unsigned thresh)
+{
+ if (theEventBuffer->m_free_thresh != thresh)
+ {
+ theEventBuffer->m_free_thresh= thresh;
+ theEventBuffer->m_min_free_thresh= thresh;
+ theEventBuffer->m_max_free_thresh= 100;
+ }
}
#ifdef VM_TRACE
| Thread |
|---|
| • bk commit into 5.1 tree (mskold:1.2518) | Martin Skold | 14 Jun |