Below is the list of changes that have just been committed into a local
5.1 repository of zhl. When zhl 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-02-09 18:15:48+00:00, lzhou@dev3-63.(none) +8 -0
Merge dev3-63.(none):/home/zhl/mysql/mysql-5.0/bug22025
into dev3-63.(none):/home/zhl/mysql/mysql-5.1/bug22025
MERGE: 1.1810.2372.82
sql/ha_ndbcluster.cc@stripped, 2007-02-09 18:15:07+00:00, lzhou@dev3-63.(none) +0 -0
Auto merged
MERGE: 1.175.63.9
sql/ha_ndbcluster.h@stripped, 2007-02-09 18:15:08+00:00, lzhou@dev3-63.(none) +0 -0
Auto merged
MERGE: 1.82.4.11
storage/ndb/include/ndbapi/NdbIndexScanOperation.hpp@stripped, 2007-02-09 18:15:08+00:00, lzhou@dev3-63.(none) +0 -0
Auto merged
MERGE: 1.17.7.2
storage/ndb/include/ndbapi/NdbIndexScanOperation.hpp@stripped, 2007-02-09 18:15:06+00:00, lzhou@dev3-63.(none) +0 -0
Merge rename: ndb/include/ndbapi/NdbIndexScanOperation.hpp -> storage/ndb/include/ndbapi/NdbIndexScanOperation.hpp
storage/ndb/include/ndbapi/NdbScanOperation.hpp@stripped, 2007-02-09 18:15:08+00:00, lzhou@dev3-63.(none) +0 -0
Auto merged
MERGE: 1.32.10.2
storage/ndb/include/ndbapi/NdbScanOperation.hpp@stripped, 2007-02-09 18:15:06+00:00, lzhou@dev3-63.(none) +0 -0
Merge rename: ndb/include/ndbapi/NdbScanOperation.hpp -> storage/ndb/include/ndbapi/NdbScanOperation.hpp
storage/ndb/src/common/debugger/EventLogger.cpp@stripped, 2007-02-09 18:15:30+00:00, lzhou@dev3-63.(none) +14 -144
MERGE: 1.21.9.2
storage/ndb/src/common/debugger/EventLogger.cpp@stripped, 2007-02-09 18:15:06+00:00, lzhou@dev3-63.(none) +0 -0
Merge rename: ndb/src/common/debugger/EventLogger.cpp -> storage/ndb/src/common/debugger/EventLogger.cpp
storage/ndb/src/mgmclient/CommandInterpreter.cpp@stripped, 2007-02-09 18:15:08+00:00, lzhou@dev3-63.(none) +0 -0
Auto merged
MERGE: 1.49.28.3
storage/ndb/src/mgmclient/CommandInterpreter.cpp@stripped, 2007-02-09 18:15:06+00:00, lzhou@dev3-63.(none) +0 -0
Merge rename: ndb/src/mgmclient/CommandInterpreter.cpp -> storage/ndb/src/mgmclient/CommandInterpreter.cpp
storage/ndb/src/ndbapi/Ndb.cpp@stripped, 2007-02-09 18:15:34+00:00, lzhou@dev3-63.(none) +118 -354
MERGE: 1.49.20.2
storage/ndb/src/ndbapi/Ndb.cpp@stripped, 2007-02-09 18:15:07+00:00, lzhou@dev3-63.(none) +0 -0
Merge rename: ndb/src/ndbapi/Ndb.cpp -> storage/ndb/src/ndbapi/Ndb.cpp
storage/ndb/src/ndbapi/NdbScanOperation.cpp@stripped, 2007-02-09 18:15:08+00:00, lzhou@dev3-63.(none) +0 -0
Auto merged
MERGE: 1.66.24.2
storage/ndb/src/ndbapi/NdbScanOperation.cpp@stripped, 2007-02-09 18:15:07+00:00, lzhou@dev3-63.(none) +0 -0
Merge rename: ndb/src/ndbapi/NdbScanOperation.cpp -> storage/ndb/src/ndbapi/NdbScanOperation.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: lzhou
# Host: dev3-63.(none)
# Root: /home/zhl/mysql/mysql-5.1/bug22025/RESYNC
--- 1.17.7.1/ndb/include/ndbapi/NdbIndexScanOperation.hpp 2007-02-09 18:16:06 +00:00
+++ 1.29/storage/ndb/include/ndbapi/NdbIndexScanOperation.hpp 2007-02-09 18:16:06 +00:00
@@ -29,6 +29,7 @@ class NdbIndexScanOperation : public Ndb
friend class NdbResultSet;
friend class NdbOperation;
friend class NdbScanOperation;
+ friend class NdbIndexStat;
#endif
public:
@@ -117,17 +118,23 @@ public:
* @param attr Attribute name, alternatively:
* @param type Type of bound
* @param value Pointer to bound value, 0 for NULL
- * @param len Value length in bytes.
- * Fixed per datatype and can be omitted
* @return 0 if successful otherwise -1
+ *
+ * @note See comment under equal() about data format and length.
*/
- int setBound(const char* attr, int type, const void* value, Uint32 len = 0);
+#ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
+ int setBound(const char* attr, int type, const void* value, Uint32 len);
+#endif
+ int setBound(const char* attr, int type, const void* value);
/**
* Define bound on index key in range scan using index column id.
* See the other setBound() method for details.
*/
- int setBound(Uint32 anAttrId, int type, const void* aValue, Uint32 len = 0);
+#ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
+ int setBound(Uint32 anAttrId, int type, const void* aValue, Uint32 len);
+#endif
+ int setBound(Uint32 anAttrId, int type, const void* aValue);
/**
* Reset bounds and put operation in list that will be
@@ -155,19 +162,21 @@ public:
* Is current scan sorted descending
*/
bool getDescending() const { return m_descending; }
+
private:
NdbIndexScanOperation(Ndb* aNdb);
virtual ~NdbIndexScanOperation();
- int setBound(const NdbColumnImpl*, int type, const void* aValue, Uint32 len);
+ int setBound(const NdbColumnImpl*, int type, const void* aValue);
int insertBOUNDS(Uint32 * data, Uint32 sz);
+ Uint32 getKeyFromSCANTABREQ(Uint32* data, Uint32 size);
- virtual int equal_impl(const NdbColumnImpl*, const char*, Uint32);
+ virtual int equal_impl(const NdbColumnImpl*, const char*);
virtual NdbRecAttr* getValue_impl(const NdbColumnImpl*, char*);
void fix_get_values();
int next_result_ordered(bool fetchAllowed, bool forceSend = false);
- int send_next_scan_ordered(Uint32 idx, bool forceSend = false);
+ int send_next_scan_ordered(Uint32 idx);
int compare(Uint32 key, Uint32 cols, const NdbReceiver*, const NdbReceiver*);
Uint32 m_sort_columns;
@@ -176,5 +185,21 @@ private:
friend struct Ndb_free_list_t<NdbIndexScanOperation>;
};
+
+inline
+int
+NdbIndexScanOperation::setBound(const char* attr, int type, const void* value,
+ Uint32 len)
+{
+ return setBound(attr, type, value);
+}
+
+inline
+int
+NdbIndexScanOperation::setBound(Uint32 anAttrId, int type, const void* value,
+ Uint32 len)
+{
+ return setBound(anAttrId, type, value);
+}
#endif
--- 1.32.10.1/ndb/include/ndbapi/NdbScanOperation.hpp 2007-02-09 18:16:06 +00:00
+++ 1.48/storage/ndb/include/ndbapi/NdbScanOperation.hpp 2007-02-09 18:16:06 +00:00
@@ -20,6 +20,7 @@
class NdbBlob;
class NdbResultSet;
+class PollGuard;
/**
* @class NdbScanOperation
@@ -41,7 +42,8 @@ public:
* ranges (bounds) are to be passed.
*/
enum ScanFlag {
- SF_TupScan = (1 << 16), // scan TUP
+ SF_TupScan = (1 << 16), // scan TUP order
+ SF_DiskScan = (2 << 16), // scan in DISK order
SF_OrderBy = (1 << 24), // index scan in order
SF_Descending = (2 << 24), // index scan in descending order
SF_ReadRangeNo = (4 << 24), // enable @ref get_range_no
@@ -202,7 +204,8 @@ protected:
int nextResultImpl(bool fetchAllowed = true, bool forceSend = false);
virtual void release();
- int close_impl(class TransporterFacade*, bool forceSend = false);
+ int close_impl(class TransporterFacade*, bool forceSend,
+ PollGuard *poll_guard);
// Overloaded methods from NdbCursorOperation
int executeCursor(int ProcessorId);
@@ -211,7 +214,6 @@ protected:
int init(const NdbTableImpl* tab, NdbTransaction*);
int prepareSend(Uint32 TC_ConnectPtr, Uint64 TransactionId);
int doSend(int ProcessorId);
- void checkForceSend(bool forceSend);
virtual void setErrorCode(int aErrorCode);
virtual void setErrorCodeAbort(int aErrorCode);
@@ -253,12 +255,12 @@ protected:
Uint32 m_sent_receivers_count; // NOTE needs mutex to access
NdbReceiver** m_sent_receivers; // receive thread puts them here
- int send_next_scan(Uint32 cnt, bool close, bool forceSend = false);
+ int send_next_scan(Uint32 cnt, bool close);
void receiver_delivered(NdbReceiver*);
void receiver_completed(NdbReceiver*);
void execCLOSE_SCAN_REP();
- int getKeyFromKEYINFO20(Uint32* data, unsigned size);
+ int getKeyFromKEYINFO20(Uint32* data, Uint32 & size);
NdbOperation* takeOverScanOp(OperationType opType, NdbTransaction*);
bool m_ordered;
@@ -266,6 +268,7 @@ protected:
Uint32 m_read_range_no;
NdbRecAttr *m_curr_row; // Pointer to last returned row
bool m_multi_range; // Mark if operation is part of multi-range scan
+ bool m_executed; // Marker if operation should be released at close
};
inline
--- 1.49.28.2/ndb/src/mgmclient/CommandInterpreter.cpp 2007-02-09 18:16:06 +00:00
+++ 1.83/storage/ndb/src/mgmclient/CommandInterpreter.cpp 2007-02-09 18:16:06 +00:00
@@ -15,14 +15,7 @@
#include <ndb_global.h>
#include <my_sys.h>
-
-//#define HAVE_GLOBAL_REPLICATION
-
#include <Vector.hpp>
-#ifdef HAVE_GLOBAL_REPLICATION
-#include "../rep/repapi/repapi.h"
-#endif
-
#include <mgmapi.h>
#include <util/BaseString.hpp>
@@ -125,7 +118,7 @@ public:
int executeStatus(int processId, const char* parameters, bool all);
int executeEventReporting(int processId, const char* parameters, bool all);
int executeDumpState(int processId, const char* parameters, bool all);
- int executeStartBackup(char * parameters);
+ int executeStartBackup(char * parameters, bool interactive);
int executeAbortBackup(char * parameters);
int executeStop(Vector<BaseString> &command_list, unsigned command_pos,
int *node_ids, int no_of_nodes);
@@ -167,11 +160,6 @@ private:
int m_verbose;
int try_reconnect;
int m_error;
-#ifdef HAVE_GLOBAL_REPLICATION
- NdbRepHandle m_repserver;
- const char *rep_host;
- bool rep_connected;
-#endif
struct NdbThread* m_event_thread;
NdbMutex *m_print_mutex;
};
@@ -236,10 +224,6 @@ extern "C" {
#include <NdbMem.h>
#include <EventLogger.hpp>
#include <signaldata/SetLogLevelOrd.hpp>
-#include <signaldata/GrepImpl.hpp>
-#ifdef HAVE_GLOBAL_REPLICATION
-
-#endif // HAVE_GLOBAL_REPLICATION
#include "MgmtErrorReporter.hpp"
#include <Parser.hpp>
#include <SocketServer.hpp>
@@ -267,9 +251,6 @@ static const char* helpText =
"---------------------------------------------------------------------------\n"
"HELP Print help text\n"
"HELP COMMAND Print detailed help for COMMAND(e.g. SHOW)\n"
-#ifdef HAVE_GLOBAL_REPLICATION
-"HELP REPLICATION Help for global replication\n"
-#endif // HAVE_GLOBAL_REPLICATION
#ifdef VM_TRACE // DEBUG ONLY
"HELP DEBUG Help for debug compiled version\n"
#endif
@@ -293,9 +274,6 @@ static const char* helpText =
"EXIT SINGLE USER MODE Exit single user mode\n"
"<id> STATUS Print status\n"
"<id> CLUSTERLOG {<category>=<level>}+ Set log level for cluster log\n"
-#ifdef HAVE_GLOBAL_REPLICATION
-"REP CONNECT <host:port> Connect to REP server on host:port\n"
-#endif
"PURGE STALE SESSIONS Reset reserved nodeid's in the mgmt server\n"
"CONNECT [<connectstring>] Connect to management server (reconnect if already connected)\n"
"QUIT Quit management client\n"
@@ -595,39 +573,6 @@ static const char* helpTextQuit =
;
-#ifdef HAVE_GLOBAL_REPLICATION
-static const char* helpTextRep =
-"---------------------------------------------------------------------------\n"
-" NDB Cluster -- Management Client -- Help for Global Replication\n"
-"---------------------------------------------------------------------------\n"
-"Commands should be executed on the standby NDB Cluster\n"
-"These features are in an experimental release state.\n"
-"\n"
-"Simple Commands:\n"
-"REP START Start Global Replication\n"
-"REP START REQUESTOR Start Global Replication Requestor\n"
-"REP STATUS Show Global Replication status\n"
-"REP STOP Stop Global Replication\n"
-"REP STOP REQUESTOR Stop Global Replication Requestor\n"
-"\n"
-"Advanced Commands:\n"
-"REP START <protocol> Starts protocol\n"
-"REP STOP <protocol> Stops protocol\n"
-"<protocol> = TRANSFER | APPLY | DELETE\n"
-"\n"
-#ifdef VM_TRACE // DEBUG ONLY
-"Debugging commands:\n"
-"REP DELETE Removes epochs stored in primary and standy systems\n"
-"REP DROP <tableid> Drop a table in SS identified by table id\n"
-"REP SLOWSTOP Stop Replication (Tries to synchonize with primary)\n"
-"REP FASTSTOP Stop Replication (Stops in consistent state)\n"
-"<component> = SUBSCRIPTION\n"
-" METALOG | METASCAN | DATALOG | DATASCAN\n"
-" REQUESTOR | TRANSFER | APPLY | DELETE\n"
-#endif
-;
-#endif // HAVE_GLOBAL_REPLICATION
-
#ifdef VM_TRACE // DEBUG ONLY
static const char* helpTextDebug =
"---------------------------------------------------------------------------\n"
@@ -680,10 +625,6 @@ struct st_cmd_help {
{"PURGE STALE SESSIONS", helpTextPurgeStaleSessions},
{"CONNECT", helpTextConnect},
{"QUIT", helpTextQuit},
-#ifdef HAVE_GLOBAL_REPLICATION
- {"REPLICATION", helpTextRep},
- {"REP", helpTextRep},
-#endif // HAVE_GLOBAL_REPLICATION
#ifdef VM_TRACE // DEBUG ONLY
{"DEBUG", helpTextDebug},
#endif //VM_TRACE
@@ -723,11 +664,6 @@ CommandInterpreter::CommandInterpreter(c
m_event_thread= NULL;
try_reconnect = 0;
m_print_mutex= NdbMutex_Create();
-#ifdef HAVE_GLOBAL_REPLICATION
- rep_host = NULL;
- m_repserver = NULL;
- rep_connected = false;
-#endif
}
/*
@@ -1054,7 +990,7 @@ CommandInterpreter::execute_impl(const c
else if(strcasecmp(firstToken, "START") == 0 &&
allAfterFirstToken != NULL &&
strncasecmp(allAfterFirstToken, "BACKUP", sizeof("BACKUP") - 1) == 0){
- m_error= executeStartBackup(allAfterFirstToken);
+ m_error= executeStartBackup(allAfterFirstToken, interactive);
DBUG_RETURN(true);
}
else if(strcasecmp(firstToken, "ABORT") == 0 &&
@@ -1066,14 +1002,7 @@ CommandInterpreter::execute_impl(const c
else if (strcasecmp(firstToken, "PURGE") == 0) {
m_error = executePurge(allAfterFirstToken);
DBUG_RETURN(true);
- }
-#ifdef HAVE_GLOBAL_REPLICATION
- else if(strcasecmp(firstToken, "REPLICATION") == 0 ||
- strcasecmp(firstToken, "REP") == 0) {
- m_error = executeRep(allAfterFirstToken);
- DBUG_RETURN(true);
- }
-#endif // HAVE_GLOBAL_REPLICATION
+ }
else if(strcasecmp(firstToken, "ENTER") == 0 &&
allAfterFirstToken != NULL &&
strncasecmp(allAfterFirstToken, "SINGLE USER MODE ",
@@ -1549,7 +1478,6 @@ CommandInterpreter::executePurge(char* p
return -1;
}
- int i;
char *str;
if (ndb_mgm_purge_stale_sessions(m_mgmsrv, &str)) {
@@ -1628,8 +1556,8 @@ CommandInterpreter::executeShow(char* pa
case NDB_MGM_NODE_TYPE_UNKNOWN:
ndbout << "Error: Unknown Node Type" << endl;
return -1;
- case NDB_MGM_NODE_TYPE_REP:
- abort();
+ case NDB_MGM_NODE_TYPE_MAX:
+ break; /* purify: deadcode */
}
}
@@ -1667,7 +1595,6 @@ CommandInterpreter::executeConnect(char*
{
BaseString *basestring = NULL;
- int retval;
disconnect();
if (!emptyString(parameters)) {
basestring= new BaseString(parameters);
@@ -1704,7 +1631,15 @@ CommandInterpreter::executeClusterLog(ch
char * item = strtok_r(tmpString, " ", &tmpPtr);
int enable;
- const unsigned int *enabled= ndb_mgm_get_logfilter(m_mgmsrv);
+ ndb_mgm_severity enabled[NDB_MGM_EVENT_SEVERITY_ALL] =
+ {{NDB_MGM_EVENT_SEVERITY_ON,0},
+ {NDB_MGM_EVENT_SEVERITY_DEBUG,0},
+ {NDB_MGM_EVENT_SEVERITY_INFO,0},
+ {NDB_MGM_EVENT_SEVERITY_WARNING,0},
+ {NDB_MGM_EVENT_SEVERITY_ERROR,0},
+ {NDB_MGM_EVENT_SEVERITY_CRITICAL,0},
+ {NDB_MGM_EVENT_SEVERITY_ALERT,0}};
+ ndb_mgm_get_clusterlog_severity_filter(m_mgmsrv, &enabled[0], NDB_MGM_EVENT_SEVERITY_ALL);
if(enabled == NULL) {
ndbout << "Couldn't get status" << endl;
printError();
@@ -1717,25 +1652,25 @@ CommandInterpreter::executeClusterLog(ch
********************/
if (strcasecmp(item, "INFO") == 0) {
DBUG_PRINT("info",("INFO"));
- if(enabled[0] == 0)
+ if(enabled[0].value == 0)
{
ndbout << "Cluster logging is disabled." << endl;
m_error = 0;
DBUG_VOID_RETURN;
}
#if 0
- for(i = 0; i<7;i++)
- printf("enabled[%d] = %d\n", i, enabled[i]);
+ for(i = 0; i<DB_MGM_EVENT_SEVERITY_ALL;i++)
+ printf("enabled[%d] = %d\n", i, enabled[i].value);
#endif
ndbout << "Severities enabled: ";
for(i = 1; i < (int)NDB_MGM_EVENT_SEVERITY_ALL; i++) {
- const char *str= ndb_mgm_get_event_severity_string((ndb_mgm_event_severity)i);
+ const char *str= ndb_mgm_get_event_severity_string(enabled[i].category);
if (str == 0)
{
DBUG_ASSERT(false);
continue;
}
- if(enabled[i])
+ if(enabled[i].value)
ndbout << BaseString(str).ndb_toupper() << " ";
}
ndbout << endl;
@@ -2102,7 +2037,6 @@ CommandInterpreter::executeStatus(int pr
ndb_mgm_node_status status;
Uint32 startPhase, version;
- bool system;
struct ndb_mgm_cluster_state *cl;
cl = ndb_mgm_get_status(m_mgmsrv);
@@ -2526,24 +2460,17 @@ CommandInterpreter::executeEventReportin
return retval;
}
+
/*****************************************************************************
* Backup
*****************************************************************************/
int
-CommandInterpreter::executeStartBackup(char* parameters)
+CommandInterpreter::executeStartBackup(char* parameters, bool interactive)
{
struct ndb_mgm_reply reply;
unsigned int backupId;
-#if 0
- int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_BACKUP, 0 };
- int fd = ndb_mgm_listen_event(m_mgmsrv, filter);
- if (fd < 0)
- {
- ndbout << "Initializing start of backup failed" << endl;
- printError();
- return fd;
- }
-#endif
+ int fd = -1;
+
Vector<BaseString> args;
{
BaseString(parameters).split(args);
@@ -2556,25 +2483,21 @@ CommandInterpreter::executeStartBackup(c
int sz= args.size();
int result;
- if (sz == 2 &&
- args[1] == "NOWAIT")
+ int flags = 2;
+ if (sz == 2 && args[1] == "NOWAIT")
{
+ flags = 0;
result = ndb_mgm_start_backup(m_mgmsrv, 0, &backupId, &reply);
}
- else if (sz == 1 ||
- (sz == 3 &&
- args[1] == "WAIT" &&
- args[2] == "COMPLETED"))
+ else if (sz == 1 || (sz == 3 && args[1] == "WAIT" && args[2] == "COMPLETED"))
{
+ flags = 2;
ndbout_c("Waiting for completed, this may take several minutes");
- result = ndb_mgm_start_backup(m_mgmsrv, 2, &backupId, &reply);
}
- else if (sz == 3 &&
- args[1] == "WAIT" &&
- args[2] == "STARTED")
+ else if (sz == 3 && args[1] == "WAIT" && args[2] == "STARTED")
{
ndbout_c("Waiting for started, this may take several minutes");
- result = ndb_mgm_start_backup(m_mgmsrv, 1, &backupId, &reply);
+ flags = 1;
}
else
{
@@ -2582,45 +2505,63 @@ CommandInterpreter::executeStartBackup(c
return -1;
}
+ /**
+ * If interactive...event listner is already running
+ */
+ if (flags == 2 && !interactive)
+ {
+ int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_BACKUP, 0, 0 };
+ fd = ndb_mgm_listen_event(m_mgmsrv, filter);
+ if (fd < 0)
+ {
+ ndbout << "Initializing start of backup failed" << endl;
+ printError();
+ return fd;
+ }
+ }
+ result = ndb_mgm_start_backup(m_mgmsrv, flags, &backupId, &reply);
+
if (result != 0) {
ndbout << "Backup failed" << endl;
printError();
-#if 0
- close(fd);
-#endif
+
+ if (fd >= 0)
+ close(fd);
return result;
}
-#if 0
- ndbout_c("Waiting for completed, this may take several minutes");
- char *tmp;
- char buf[1024];
+
+ if (fd >= 0)
{
- SocketInputStream in(fd);
- int count = 0;
+ char *tmp;
+ char buf[1024];
+ {
+ SocketInputStream in(fd);
+ int count = 0;
+ do {
+ tmp = in.gets(buf, 1024);
+ if(tmp)
+ {
+ ndbout << tmp;
+ unsigned int id;
+ if(sscanf(tmp, "%*[^:]: Backup %d ", &id) == 1 && id == backupId){
+ count++;
+ }
+ }
+ } while(count < 2);
+ }
+
+ SocketInputStream in(fd, 10);
do {
tmp = in.gets(buf, 1024);
- if(tmp)
+ if(tmp && tmp[0] != 0)
{
ndbout << tmp;
- unsigned int id;
- if(sscanf(tmp, "%*[^:]: Backup %d ", &id) == 1 && id == backupId){
- count++;
- }
}
- } while(count < 2);
+ } while(tmp && tmp[0] != 0);
+
+ close(fd);
}
- SocketInputStream in(fd, 10);
- do {
- tmp = in.gets(buf, 1024);
- if(tmp && tmp[0] != 0)
- {
- ndbout << tmp;
- }
- } while(tmp && tmp[0] != 0);
-
- close(fd);
-#endif
return 0;
}
@@ -2653,234 +2594,5 @@ CommandInterpreter::executeAbortBackup(c
ndbout << "Invalid arguments: expected <BackupId>" << endl;
return -1;
}
-
-#ifdef HAVE_GLOBAL_REPLICATION
-/*****************************************************************************
- * Global Replication
- *
- * For information about the different commands, see
- * GrepReq::Request in file signaldata/grepImpl.cpp.
- *
- * Below are commands as of 2003-07-05 (may change!):
- * START = 0, ///< Start Global Replication (all phases)
- * START_METALOG = 1, ///< Start Global Replication (all phases)
- * START_METASCAN = 2, ///< Start Global Replication (all phases)
- * START_DATALOG = 3, ///< Start Global Replication (all phases)
- * START_DATASCAN = 4, ///< Start Global Replication (all phases)
- * START_REQUESTOR = 5, ///< Start Global Replication (all phases)
- * ABORT = 6, ///< Immediate stop (removes subscription)
- * SLOW_STOP = 7, ///< Stop after finishing applying current GCI epoch
- * FAST_STOP = 8, ///< Stop after finishing applying all PS GCI epochs
- * START_TRANSFER = 9, ///< Start SS-PS transfer
- * STOP_TRANSFER = 10, ///< Stop SS-PS transfer
- * START_APPLY = 11, ///< Start applying GCI epochs in SS
- * STOP_APPLY = 12, ///< Stop applying GCI epochs in SS
- * STATUS = 13, ///< Status
- * START_SUBSCR = 14,
- * REMOVE_BUFFERS = 15,
- * DROP_TABLE = 16
-
- *****************************************************************************/
-
-int
-CommandInterpreter::executeRep(char* parameters)
-{
- if (emptyString(parameters)) {
- ndbout << helpTextRep;
- return 0;
- }
-
- char * line = my_strdup(parameters,MYF(MY_WME));
- My_auto_ptr<char> ap1((char*)line);
- char * firstToken = strtok(line, " ");
-
- struct ndb_rep_reply reply;
- unsigned int repId;
-
-
- if (!strcasecmp(firstToken, "CONNECT")) {
- char * host = strtok(NULL, "\0");
- for (unsigned int i = 0; i < strlen(host); ++i) {
- host[i] = tolower(host[i]);
- }
-
- if(host == NULL)
- {
- ndbout_c("host:port must be specified.");
- return -1;
- }
-
- if(rep_connected) {
- if(m_repserver != NULL) {
- ndb_rep_disconnect(m_repserver);
- rep_connected = false;
- }
- }
-
- if(m_repserver == NULL)
- m_repserver = ndb_rep_create_handle();
- if(ndb_rep_connect(m_repserver, host) < 0){
- ndbout_c("Failed to connect to %s", host);
- return -1;
- }
- else
- rep_connected=true;
- return 0;
-
- if(!rep_connected) {
- ndbout_c("Not connected to REP server");
- return -1;
- }
- }
-
- /********
- * START
- ********/
- if (!strcasecmp(firstToken, "START")) {
-
- unsigned int req;
- char *startType = strtok(NULL, "\0");
-
- if (startType == NULL) {
- req = GrepReq::START;
- } else if (!strcasecmp(startType, "SUBSCRIPTION")) {
- req = GrepReq::START_SUBSCR;
- } else if (!strcasecmp(startType, "METALOG")) {
- req = GrepReq::START_METALOG;
- } else if (!strcasecmp(startType, "METASCAN")) {
- req = GrepReq::START_METASCAN;
- } else if (!strcasecmp(startType, "DATALOG")) {
- req = GrepReq::START_DATALOG;
- } else if (!strcasecmp(startType, "DATASCAN")) {
- req = GrepReq::START_DATASCAN;
- } else if (!strcasecmp(startType, "REQUESTOR")) {
- req = GrepReq::START_REQUESTOR;
- } else if (!strcasecmp(startType, "TRANSFER")) {
- req = GrepReq::START_TRANSFER;
- } else if (!strcasecmp(startType, "APPLY")) {
- req = GrepReq::START_APPLY;
- } else if (!strcasecmp(startType, "DELETE")) {
- req = GrepReq::START_DELETE;
- } else {
- ndbout_c("Illegal argument to command 'REPLICATION START'");
- return -1;
- }
-
- int result = ndb_rep_command(m_repserver, req, &repId, &reply);
-
- if (result != 0) {
- ndbout << "Start of Global Replication failed" << endl;
- return -1;
- } else {
- ndbout << "Start of Global Replication ordered" << endl;
- }
- return 0;
- }
-
- /********
- * STOP
- ********/
- if (!strcasecmp(firstToken, "STOP")) {
- unsigned int req;
- char *startType = strtok(NULL, " ");
- unsigned int epoch = 0;
-
- if (startType == NULL) {
- /**
- * Stop immediately
- */
- req = GrepReq::STOP;
- } else if (!strcasecmp(startType, "EPOCH")) {
- char *strEpoch = strtok(NULL, "\0");
- if(strEpoch == NULL) {
- ndbout_c("Epoch expected!");
- return -1;
- }
- req = GrepReq::STOP;
- epoch=atoi(strEpoch);
- } else if (!strcasecmp(startType, "SUBSCRIPTION")) {
- req = GrepReq::STOP_SUBSCR;
- } else if (!strcasecmp(startType, "METALOG")) {
- req = GrepReq::STOP_METALOG;
- } else if (!strcasecmp(startType, "METASCAN")) {
- req = GrepReq::STOP_METASCAN;
- } else if (!strcasecmp(startType, "DATALOG")) {
- req = GrepReq::STOP_DATALOG;
- } else if (!strcasecmp(startType, "DATASCAN")) {
- req = GrepReq::STOP_DATASCAN;
- } else if (!strcasecmp(startType, "REQUESTOR")) {
- req = GrepReq::STOP_REQUESTOR;
- } else if (!strcasecmp(startType, "TRANSFER")) {
- req = GrepReq::STOP_TRANSFER;
- } else if (!strcasecmp(startType, "APPLY")) {
- req = GrepReq::STOP_APPLY;
- } else if (!strcasecmp(startType, "DELETE")) {
- req = GrepReq::STOP_DELETE;
- } else {
- ndbout_c("Illegal argument to command 'REPLICATION STOP'");
- return -1;
- }
- int result = ndb_rep_command(m_repserver, req, &repId, &reply, epoch);
-
- if (result != 0) {
- ndbout << "Stop command failed" << endl;
- return -1;
- } else {
- ndbout << "Stop ordered" << endl;
- }
- return 0;
- }
-
- /*********
- * STATUS
- *********/
- if (!strcasecmp(firstToken, "STATUS")) {
- struct rep_state repstate;
- int result =
- ndb_rep_get_status(m_repserver, &repId, &reply, &repstate);
-
- if (result != 0) {
- ndbout << "Status request of Global Replication failed" << endl;
- return -1;
- } else {
- ndbout << "Status request of Global Replication ordered" << endl;
- ndbout << "See printout at one of the DB nodes" << endl;
- ndbout << "(Better status report is under development.)" << endl;
- ndbout << " SubscriptionId " << repstate.subid
- << " SubscriptionKey " << repstate.subkey << endl;
- }
- return 0;
- }
-
- /*********
- * QUERY (see repapi.h for querable counters)
- *********/
- if (!strcasecmp(firstToken, "QUERY")) {
- char *query = strtok(NULL, "\0");
- int queryCounter=-1;
- if(query != NULL) {
- queryCounter = atoi(query);
- }
- struct rep_state repstate;
- unsigned repId = 0;
- int result = ndb_rep_query(m_repserver, (QueryCounter)queryCounter,
- &repId, &reply, &repstate);
-
- if (result != 0) {
- ndbout << "Query repserver failed" << endl;
- return -1;
- } else {
- ndbout << "Query repserver sucessful" << endl;
- ndbout_c("repstate : QueryCounter %d, f=%d l=%d"
- " nodegroups %d" ,
- repstate.queryCounter,
- repstate.first[0], repstate.last[0],
- repstate.no_of_nodegroups );
- }
- return 0;
- }
- return 0;
-}
-#endif // HAVE_GLOBAL_REPLICATION
template class Vector<char const*>;
--- 1.66.24.1/ndb/src/ndbapi/NdbScanOperation.cpp 2007-02-09 18:16:06 +00:00
+++ 1.110/storage/ndb/src/ndbapi/NdbScanOperation.cpp 2007-02-09 18:16:06 +00:00
@@ -49,6 +49,7 @@ NdbScanOperation::NdbScanOperation(Ndb*
m_receivers = 0;
m_array = new Uint32[1]; // skip if on delete in fix_receivers
theSCAN_TABREQ = 0;
+ m_executed = false;
}
NdbScanOperation::~NdbScanOperation()
@@ -110,6 +111,7 @@ NdbScanOperation::init(const NdbTableImp
theNdbCon->theMagicNumber = 0xFE11DF;
theNoOfTupKeyLeft = tab->m_noOfDistributionKeys;
m_read_range_no = 0;
+ m_executed = false;
return 0;
}
@@ -161,9 +163,25 @@ NdbScanOperation::readTuples(NdbScanOper
}
m_keyInfo = ((scan_flags & SF_KeyInfo) || lockExcl) ? 1 : 0;
+ bool tupScan = (scan_flags & SF_TupScan);
+#if 1 // XXX temp for testing
+ { char* p = getenv("NDB_USE_TUPSCAN");
+ if (p != 0) {
+ unsigned n = atoi(p); // 0-10
+ if ((unsigned int) (::time(0) % 10) < n) tupScan = true;
+ }
+ }
+#endif
+ if (scan_flags & SF_DiskScan)
+ {
+ tupScan = true;
+ m_no_disk_flag = false;
+ }
+
bool rangeScan = false;
- if (m_accessTable->m_indexType == NdbDictionary::Index::OrderedIndex)
+ if ( (int) m_accessTable->m_indexType ==
+ (int) NdbDictionary::Index::OrderedIndex)
{
if (m_currentTable == m_accessTable){
// Old way of scanning indexes, should not be allowed
@@ -176,12 +194,9 @@ NdbScanOperation::readTuples(NdbScanOper
theStatus = GetValue;
theOperationType = OpenRangeScanRequest;
rangeScan = true;
- }
-
- bool tupScan = (scan_flags & SF_TupScan);
- if (tupScan && rangeScan)
tupScan = false;
-
+ }
+
if (rangeScan && (scan_flags & SF_OrderBy))
parallel = fragCount;
@@ -201,7 +216,7 @@ NdbScanOperation::readTuples(NdbScanOper
theSCAN_TABREQ->setSignal(GSN_SCAN_TABREQ);
ScanTabReq * req = CAST_PTR(ScanTabReq, theSCAN_TABREQ->getDataPtrSend());
req->apiConnectPtr = theNdbCon->theTCConPtr;
- req->tableId = m_accessTable->m_tableId;
+ req->tableId = m_accessTable->m_id;
req->tableSchemaVersion = m_accessTable->m_version;
req->storedProcId = 0xFFFF;
req->buddyConPtr = theNdbCon->theBuddyConPtr;
@@ -362,7 +377,7 @@ NdbScanOperation::getFirstATTRINFOScan()
int
NdbScanOperation::executeCursor(int nodeId){
NdbTransaction * tCon = theNdbCon;
- TransporterFacade* tp = TransporterFacade::instance();
+ TransporterFacade* tp = theNdb->theImpl->m_transporter_facade;
Guard guard(tp->theMutexPtr);
Uint32 magic = tCon->theMagicNumber;
@@ -384,6 +399,7 @@ NdbScanOperation::executeCursor(int node
if (doSendScan(nodeId) == -1)
return -1;
+ m_executed= true; // Mark operation as executed
return 0;
} else {
if (!(tp->get_node_stopping(nodeId) &&
@@ -463,18 +479,28 @@ int NdbScanOperation::nextResultImpl(boo
}
Uint32 nodeId = theNdbCon->theDBnode;
- TransporterFacade* tp = TransporterFacade::instance();
- Guard guard(tp->theMutexPtr);
- if(theError.code)
- return -1;
+ TransporterFacade* tp = theNdb->theImpl->m_transporter_facade;
+ /*
+ The PollGuard has an implicit call of unlock_and_signal through the
+ ~PollGuard method. This method is called implicitly by the compiler
+ in all places where the object is out of context due to a return,
+ break, continue or simply end of statement block
+ */
+ PollGuard poll_guard(tp, &theNdb->theImpl->theWaiter,
+ theNdb->theNdbBlockNumber);
- Uint32 seq = theNdbCon->theNodeSequence;
- if(seq == tp->getNodeSequence(nodeId) && send_next_scan(idx, false,
- forceSend) == 0){
+ const Uint32 seq = theNdbCon->theNodeSequence;
+
+ if(theError.code)
+ {
+ goto err4;
+ }
+
+ if(seq == tp->getNodeSequence(nodeId) && send_next_scan(idx, false) == 0)
+ {
idx = m_current_api_receiver;
last = m_api_receivers_count;
-
Uint32 timeout = tp->m_waitfor_timeout;
do {
@@ -501,12 +527,10 @@ int NdbScanOperation::nextResultImpl(boo
/**
* No completed...
*/
- theNdb->theImpl->theWaiter.m_node = nodeId;
- theNdb->theImpl->theWaiter.m_state = WAIT_SCAN;
- int return_code = theNdb->receiveResponse(3*timeout);
- if (return_code == 0 && seq == tp->getNodeSequence(nodeId)) {
+ int ret_code= poll_guard.wait_scan(3*timeout, nodeId, forceSend);
+ if (ret_code == 0 && seq == tp->getNodeSequence(nodeId)) {
continue;
- } else if(return_code == -1){
+ } else if(ret_code == -1){
retVal = -1;
} else {
idx = last;
@@ -556,17 +580,21 @@ int NdbScanOperation::nextResultImpl(boo
if(theError.code == 0)
setErrorCode(4028); // seq changed = Node fail
break;
+ case -4:
+err4:
+ setErrorCode(theError.code);
+ break;
}
theNdbCon->theTransactionIsStarted = false;
theNdbCon->theReleaseOnClose = true;
- if(DEBUG_NEXT_RESULT) ndbout_c("return -1", retVal);
+ if(DEBUG_NEXT_RESULT) ndbout_c("return %d", retVal);
return -1;
}
int
-NdbScanOperation::send_next_scan(Uint32 cnt, bool stopScanFlag,
- bool forceSend){
+NdbScanOperation::send_next_scan(Uint32 cnt, bool stopScanFlag)
+{
if(cnt > 0){
NdbApiSignal tSignal(theNdb->theMyRef);
tSignal.setSignal(GSN_SCAN_NEXTREQ);
@@ -601,7 +629,7 @@ NdbScanOperation::send_next_scan(Uint32
if(sent)
{
Uint32 nodeId = theNdbCon->theDBnode;
- TransporterFacade * tp = TransporterFacade::instance();
+ TransporterFacade * tp = theNdb->theImpl->m_transporter_facade;
if(cnt > 21){
tSignal.setLength(4);
LinearSectionPtr ptr[3];
@@ -613,9 +641,6 @@ NdbScanOperation::send_next_scan(Uint32
ret = tp->sendSignal(&tSignal, nodeId);
}
}
-
- if (!ret) checkForceSend(forceSend);
-
m_sent_receivers_count = last + sent;
m_api_receivers_count -= cnt;
m_current_api_receiver = 0;
@@ -625,15 +650,6 @@ NdbScanOperation::send_next_scan(Uint32
return 0;
}
-void NdbScanOperation::checkForceSend(bool forceSend)
-{
- if (forceSend) {
- TransporterFacade::instance()->forceSend(theNdb->theNdbBlockNumber);
- } else {
- TransporterFacade::instance()->checkForceSend(theNdb->theNdbBlockNumber);
- }//if
-}
-
int
NdbScanOperation::prepareSend(Uint32 TC_ConnectPtr, Uint64 TransactionId)
{
@@ -653,8 +669,8 @@ void NdbScanOperation::close(bool forceS
{
DBUG_ENTER("NdbScanOperation::close");
DBUG_PRINT("enter", ("this: 0x%lx tcon: 0x%lx con: 0x%lx force: %d release: %d",
- (long)this,
- (long)m_transConnection, (long)theNdbCon,
+ (long) this,
+ (long) m_transConnection, (long) theNdbCon,
forceSend, releaseOp));
if(m_transConnection){
@@ -668,10 +684,16 @@ void NdbScanOperation::close(bool forceS
m_conf_receivers_count,
m_sent_receivers_count);
- TransporterFacade* tp = TransporterFacade::instance();
- Guard guard(tp->theMutexPtr);
- close_impl(tp, forceSend);
-
+ TransporterFacade* tp = theNdb->theImpl->m_transporter_facade;
+ /*
+ The PollGuard has an implicit call of unlock_and_signal through the
+ ~PollGuard method. This method is called implicitly by the compiler
+ in all places where the object is out of context due to a return,
+ break, continue or simply end of statement block
+ */
+ PollGuard poll_guard(tp, &theNdb->theImpl->theWaiter,
+ theNdb->theNdbBlockNumber);
+ close_impl(tp, forceSend, &poll_guard);
}
NdbConnection* tCon = theNdbCon;
@@ -794,6 +816,7 @@ int NdbScanOperation::prepareSendScan(Ui
*/
Uint32 reqInfo = req->requestInfo;
ScanTabReq::setKeyinfoFlag(reqInfo, keyInfo);
+ ScanTabReq::setNoDiskFlag(reqInfo, m_no_disk_flag);
req->requestInfo = reqInfo;
for(Uint32 i = 0; i<theParallelism; i++){
@@ -829,7 +852,6 @@ NdbScanOperation::doSendScan(int aProces
tSignal = theSCAN_TABREQ;
Uint32 tupKeyLen = theTupKeyLen;
- Uint32 len = theTotalNrOfKeyWordInSignal;
Uint32 aTC_ConnectPtr = theNdbCon->theTCConPtr;
Uint64 transId = theNdbCon->theTransactionId;
@@ -844,7 +866,7 @@ NdbScanOperation::doSendScan(int aProces
req->requestInfo = tmp;
tSignal->setLength(ScanTabReq::StaticLength + theDistrKeyIndicator_);
- TransporterFacade *tp = TransporterFacade::instance();
+ TransporterFacade *tp = theNdb->theImpl->m_transporter_facade;
LinearSectionPtr ptr[3];
ptr[0].p = m_prepared_receivers;
ptr[0].sz = theParallelism;
@@ -928,13 +950,20 @@ NdbScanOperation::doSendScan(int aProces
* the scan process.
****************************************************************************/
int
-NdbScanOperation::getKeyFromKEYINFO20(Uint32* data, unsigned size)
+NdbScanOperation::getKeyFromKEYINFO20(Uint32* data, Uint32 & size)
{
NdbRecAttr * tRecAttr = m_curr_row;
if(tRecAttr)
{
const Uint32 * src = (Uint32*)tRecAttr->aRef();
- memcpy(data, src, 4*size);
+
+ assert(tRecAttr->get_size_in_bytes() > 0);
+ assert(tRecAttr->get_size_in_bytes() < 65536);
+ const Uint32 len = (tRecAttr->get_size_in_bytes() + 3)/4-1;
+
+ assert(size >= len);
+ memcpy(data, src, 4*len);
+ size = len;
return 0;
}
return -1;
@@ -959,10 +988,13 @@ NdbScanOperation::takeOverScanOp(Operati
}
pTrans->theSimpleState = 0;
- const Uint32 len = (tRecAttr->attrSize() * tRecAttr->arraySize() + 3)/4-1;
-
+ assert(tRecAttr->get_size_in_bytes() > 0);
+ assert(tRecAttr->get_size_in_bytes() < 65536);
+ const Uint32 len = (tRecAttr->get_size_in_bytes() + 3)/4-1;
+
newOp->theTupKeyLen = len;
newOp->theOperationType = opType;
+ newOp->m_abortOption = AbortOnError;
switch (opType) {
case (ReadRequest):
newOp->theLockMode = theLockMode;
@@ -1058,23 +1090,23 @@ NdbIndexScanOperation::~NdbIndexScanOper
int
NdbIndexScanOperation::setBound(const char* anAttrName, int type,
- const void* aValue, Uint32 len)
+ const void* aValue)
{
- return setBound(m_accessTable->getColumn(anAttrName), type, aValue, len);
+ return setBound(m_accessTable->getColumn(anAttrName), type, aValue);
}
int
NdbIndexScanOperation::setBound(Uint32 anAttrId, int type,
- const void* aValue, Uint32 len)
+ const void* aValue)
{
- return setBound(m_accessTable->getColumn(anAttrId), type, aValue, len);
+ return setBound(m_accessTable->getColumn(anAttrId), type, aValue);
}
int
NdbIndexScanOperation::equal_impl(const NdbColumnImpl* anAttrObject,
- const char* aValue,
- Uint32 len){
- return setBound(anAttrObject, BoundEQ, aValue, len);
+ const char* aValue)
+{
+ return setBound(anAttrObject, BoundEQ, aValue);
}
NdbRecAttr*
@@ -1084,7 +1116,7 @@ NdbIndexScanOperation::getValue_impl(con
return NdbScanOperation::getValue_impl(attrInfo, aValue);
}
- int id = attrInfo->m_attrId; // In "real" table
+ int id = attrInfo->getColumnNo(); // In "real" table
assert(m_accessTable->m_index);
int sz = (int)m_accessTable->m_index->m_key_ids.size();
if(id >= sz || (id = m_accessTable->m_index->m_key_ids[id]) == -1){
@@ -1121,7 +1153,7 @@ NdbIndexScanOperation::getValue_impl(con
*/
int
NdbIndexScanOperation::setBound(const NdbColumnImpl* tAttrInfo,
- int type, const void* aValue, Uint32 len)
+ int type, const void* aValue)
{
if (!tAttrInfo)
{
@@ -1129,24 +1161,23 @@ NdbIndexScanOperation::setBound(const Nd
return -1;
}
if (theOperationType == OpenRangeScanRequest &&
- (0 <= type && type <= 4) &&
- len <= 8000) {
+ (0 <= type && type <= 4)) {
// insert bound type
Uint32 currLen = theTotalNrOfKeyWordInSignal;
Uint32 remaining = KeyInfo::DataLength - currLen;
- Uint32 sizeInBytes = tAttrInfo->m_attrSize * tAttrInfo->m_arraySize;
bool tDistrKey = tAttrInfo->m_distributionKey;
- len = aValue != NULL ? sizeInBytes : 0;
- if (len != sizeInBytes && (len != 0)) {
- setErrorCodeAbort(4209);
- return -1;
- }
+ Uint32 len = 0;
+ if (aValue != NULL)
+ if (! tAttrInfo->get_var_length(aValue, len)) {
+ setErrorCodeAbort(4209);
+ return -1;
+ }
// insert attribute header
Uint32 tIndexAttrId = tAttrInfo->m_attrId;
Uint32 sizeInWords = (len + 3) / 4;
- AttributeHeader ah(tIndexAttrId, sizeInWords);
+ AttributeHeader ah(tIndexAttrId, sizeInWords << 2);
const Uint32 ahValue = ah.m_value;
const Uint32 align = (UintPtr(aValue) & 7);
@@ -1156,25 +1187,31 @@ NdbIndexScanOperation::setBound(const Nd
const bool nobytes = (len & 0x3) == 0;
const Uint32 totalLen = 2 + sizeInWords;
Uint32 tupKeyLen = theTupKeyLen;
+ union {
+ Uint32 tempData[2000];
+ Uint64 __align;
+ };
+ Uint64 *valPtr;
if(remaining > totalLen && aligned && nobytes){
Uint32 * dst = theKEYINFOptr + currLen;
* dst ++ = type;
* dst ++ = ahValue;
memcpy(dst, aValue, 4 * sizeInWords);
theTotalNrOfKeyWordInSignal = currLen + totalLen;
+ valPtr = (Uint64*)aValue;
} else {
if(!aligned || !nobytes){
- Uint32 tempData[2000];
tempData[0] = type;
tempData[1] = ahValue;
tempData[2 + (len >> 2)] = 0;
memcpy(tempData+2, aValue, len);
-
insertBOUNDS(tempData, 2+sizeInWords);
+ valPtr = (Uint64*)(tempData+2);
} else {
Uint32 buf[2] = { type, ahValue };
insertBOUNDS(buf, 2);
insertBOUNDS((Uint32*)aValue, sizeInWords);
+ valPtr = (Uint64*)aValue;
}
}
theTupKeyLen = tupKeyLen + totalLen;
@@ -1191,7 +1228,7 @@ NdbIndexScanOperation::setBound(const Nd
if(type == BoundEQ && tDistrKey && !m_multi_range)
{
theNoOfTupKeyLeft--;
- return handle_distribution_key((Uint64*)aValue, sizeInWords);
+ return handle_distribution_key(valPtr, sizeInWords);
}
return 0;
} else {
@@ -1240,6 +1277,31 @@ error:
return -1;
}
+Uint32
+NdbIndexScanOperation::getKeyFromSCANTABREQ(Uint32* data, Uint32 size)
+{
+ DBUG_ENTER("NdbIndexScanOperation::getKeyFromSCANTABREQ");
+ assert(size >= theTotalNrOfKeyWordInSignal);
+ size = theTotalNrOfKeyWordInSignal;
+ NdbApiSignal* tSignal = theSCAN_TABREQ->next();
+ Uint32 pos = 0;
+ while (pos < size) {
+ assert(tSignal != NULL);
+ Uint32* tData = tSignal->getDataPtrSend();
+ Uint32 rem = size - pos;
+ if (rem > KeyInfo::DataLength)
+ rem = KeyInfo::DataLength;
+ Uint32 i = 0;
+ while (i < rem) {
+ data[pos + i] = tData[KeyInfo::HeaderLength + i];
+ i++;
+ }
+ pos += rem;
+ }
+ DBUG_DUMP("key", (char*)data, size << 2);
+ DBUG_RETURN(size);
+}
+
int
NdbIndexScanOperation::readTuples(LockMode lm,
Uint32 scan_flags,
@@ -1300,8 +1362,6 @@ NdbIndexScanOperation::fix_get_values(){
Uint32 cnt = m_accessTable->getNoOfColumns() - 1;
assert(cnt < NDB_MAX_NO_OF_ATTRIBUTES_IN_KEY);
- const NdbIndexImpl * idx = m_accessTable->m_index;
- const NdbTableImpl * tab = m_currentTable;
for(Uint32 i = 0; i<cnt; i++){
Uint32 val = theTupleKeyDefined[i][0];
switch(val){
@@ -1340,10 +1400,11 @@ NdbIndexScanOperation::compare(Uint32 sk
return (r1_null ? -1 : 1) * jdir;
}
const NdbColumnImpl & col = NdbColumnImpl::getImpl(* r1->m_column);
- Uint32 len = r1->theAttrSize * r1->theArraySize;
+ Uint32 len1 = r1->get_size_in_bytes();
+ Uint32 len2 = r2->get_size_in_bytes();
if(!r1_null){
const NdbSqlUtil::Type& sqlType = NdbSqlUtil::getType(col.m_type);
- int r = (*sqlType.m_cmp)(col.m_cs, d1, len, d2, len, true);
+ int r = (*sqlType.m_cmp)(col.m_cs, d1, len1, d2, len2, true);
if(r){
assert(r != NdbSqlUtil::CmpUnknown);
return r * jdir;
@@ -1381,26 +1442,31 @@ NdbIndexScanOperation::next_result_order
if(fetchNeeded){
if(fetchAllowed){
if(DEBUG_NEXT_RESULT) ndbout_c("performing fetch...");
- TransporterFacade* tp = TransporterFacade::instance();
- Guard guard(tp->theMutexPtr);
+ TransporterFacade* tp = theNdb->theImpl->m_transporter_facade;
+ /*
+ The PollGuard has an implicit call of unlock_and_signal through the
+ ~PollGuard method. This method is called implicitly by the compiler
+ in all places where the object is out of context due to a return,
+ break, continue or simply end of statement block
+ */
+ PollGuard poll_guard(tp, &theNdb->theImpl->theWaiter,
+ theNdb->theNdbBlockNumber);
if(theError.code)
return -1;
Uint32 seq = theNdbCon->theNodeSequence;
Uint32 nodeId = theNdbCon->theDBnode;
Uint32 timeout = tp->m_waitfor_timeout;
if(seq == tp->getNodeSequence(nodeId) &&
- !send_next_scan_ordered(s_idx, forceSend)){
+ !send_next_scan_ordered(s_idx)){
Uint32 tmp = m_sent_receivers_count;
s_idx = m_current_api_receiver;
while(m_sent_receivers_count > 0 && !theError.code){
- theNdb->theImpl->theWaiter.m_node = nodeId;
- theNdb->theImpl->theWaiter.m_state = WAIT_SCAN;
- int return_code = theNdb->receiveResponse(3*timeout);
- if (return_code == 0 && seq == tp->getNodeSequence(nodeId)) {
+ int ret_code= poll_guard.wait_scan(3*timeout, nodeId, forceSend);
+ if (ret_code == 0 && seq == tp->getNodeSequence(nodeId)) {
continue;
}
if(DEBUG_NEXT_RESULT) ndbout_c("return -1");
- if(return_code == -1){
+ if(ret_code == -1){
setErrorCode(4008);
} else {
setErrorCode(4028);
@@ -1487,7 +1553,8 @@ NdbIndexScanOperation::next_result_order
}
int
-NdbIndexScanOperation::send_next_scan_ordered(Uint32 idx, bool forceSend){
+NdbIndexScanOperation::send_next_scan_ordered(Uint32 idx)
+{
if(idx == theParallelism)
return 0;
@@ -1522,15 +1589,16 @@ NdbIndexScanOperation::send_next_scan_or
m_sent_receivers_count = last + 1;
Uint32 nodeId = theNdbCon->theDBnode;
- TransporterFacade * tp = TransporterFacade::instance();
+ TransporterFacade * tp = theNdb->theImpl->m_transporter_facade;
tSignal.setLength(4+1);
int ret= tp->sendSignal(&tSignal, nodeId);
- if (!ret) checkForceSend(forceSend);
return ret;
}
int
-NdbScanOperation::close_impl(TransporterFacade* tp, bool forceSend){
+NdbScanOperation::close_impl(TransporterFacade* tp, bool forceSend,
+ PollGuard *poll_guard)
+{
Uint32 seq = theNdbCon->theNodeSequence;
Uint32 nodeId = theNdbCon->theDBnode;
@@ -1541,15 +1609,12 @@ NdbScanOperation::close_impl(Transporter
}
Uint32 timeout = tp->m_waitfor_timeout;
-
/**
* Wait for outstanding
*/
while(theError.code == 0 && m_sent_receivers_count)
{
- theNdb->theImpl->theWaiter.m_node = nodeId;
- theNdb->theImpl->theWaiter.m_state = WAIT_SCAN;
- int return_code = theNdb->receiveResponse(3*timeout);
+ int return_code= poll_guard->wait_scan(3*timeout, nodeId, forceSend);
switch(return_code){
case 0:
break;
@@ -1606,7 +1671,7 @@ NdbScanOperation::close_impl(Transporter
}
// Send close scan
- if(send_next_scan(api+conf, true, forceSend) == -1)
+ if(send_next_scan(api+conf, true) == -1)
{
theNdbCon->theReleaseOnClose = true;
return -1;
@@ -1617,9 +1682,7 @@ NdbScanOperation::close_impl(Transporter
*/
while(m_sent_receivers_count+m_api_receivers_count+m_conf_receivers_count)
{
- theNdb->theImpl->theWaiter.m_node = nodeId;
- theNdb->theImpl->theWaiter.m_state = WAIT_SCAN;
- int return_code = theNdb->receiveResponse(3*timeout);
+ int return_code= poll_guard->wait_scan(3*timeout, nodeId, forceSend);
switch(return_code){
case 0:
break;
@@ -1658,13 +1721,20 @@ int
NdbScanOperation::restart(bool forceSend)
{
- TransporterFacade* tp = TransporterFacade::instance();
- Guard guard(tp->theMutexPtr);
+ TransporterFacade* tp = theNdb->theImpl->m_transporter_facade;
+ /*
+ The PollGuard has an implicit call of unlock_and_signal through the
+ ~PollGuard method. This method is called implicitly by the compiler
+ in all places where the object is out of context due to a return,
+ break, continue or simply end of statement block
+ */
+ PollGuard poll_guard(tp, &theNdb->theImpl->theWaiter,
+ theNdb->theNdbBlockNumber);
Uint32 nodeId = theNdbCon->theDBnode;
{
int res;
- if((res= close_impl(tp, forceSend)))
+ if((res= close_impl(tp, forceSend, &poll_guard)))
{
return res;
}
@@ -1678,7 +1748,6 @@ NdbScanOperation::restart(bool forceSend
theError.code = 0;
if (doSendScan(nodeId) == -1)
return -1;
-
return 0;
}
@@ -1687,9 +1756,16 @@ NdbIndexScanOperation::reset_bounds(bool
int res;
{
- TransporterFacade* tp = TransporterFacade::instance();
- Guard guard(tp->theMutexPtr);
- res= close_impl(tp, forceSend);
+ TransporterFacade* tp = theNdb->theImpl->m_transporter_facade;
+ /*
+ The PollGuard has an implicit call of unlock_and_signal through the
+ ~PollGuard method. This method is called implicitly by the compiler
+ in all places where the object is out of context due to a return,
+ break, continue or simply end of statement block
+ */
+ PollGuard poll_guard(tp, &theNdb->theImpl->theWaiter,
+ theNdb->theNdbBlockNumber);
+ res= close_impl(tp, forceSend, &poll_guard);
}
if(!res)
| Thread |
|---|
| • bk commit into 5.1 tree (lzhou:1.2431) | lzhou | 9 Feb |