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-05-09 15:30:40+02:00, mskold@stripped +7 -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.2902.1
mysql-test/r/ndb_insert.result@stripped, 2007-05-09 15:20:04+02:00, mskold@stripped +0 -0
Auto merged
MERGE: 1.8.1.4
mysql-test/t/ndb_insert.test@stripped, 2007-05-09 15:20:04+02:00, mskold@stripped +0 -0
Auto merged
MERGE: 1.12.1.2
sql/ha_ndbcluster.cc@stripped, 2007-05-09 15:25:22+02:00, mskold@stripped +1 -11
Using local (will merge manually)
MERGE: 1.175.1.137
sql/handler.cc@stripped, 2007-05-09 15:26:26+02:00, mskold@stripped +0 -4
Using local (will merge manually)
MERGE: 1.167.1.66
sql/handler.h@stripped, 2007-05-09 15:30:36+02:00, mskold@stripped +5 -4
Merge
MERGE: 1.138.2.46
storage/ndb/include/ndbapi/Ndb.hpp@stripped, 2007-05-09 15:29:54+02:00, mskold@stripped +2
-6
Using local (will merge manually)
MERGE: 1.39.13.2
storage/ndb/include/ndbapi/Ndb.hpp@stripped, 2007-05-09 15:20:03+02:00,
mskold@stripped +0 -0
Merge rename: ndb/include/ndbapi/Ndb.hpp -> storage/ndb/include/ndbapi/Ndb.hpp
storage/ndb/src/ndbapi/Ndb.cpp@stripped, 2007-05-09 15:30:14+02:00, mskold@stripped +20
-73
Using local (will merge manually)
MERGE: 1.49.27.2
storage/ndb/src/ndbapi/Ndb.cpp@stripped, 2007-05-09 15:20:04+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.256/sql/handler.h 2007-05-09 15:30:55 +02:00
+++ 1.257/sql/handler.h 2007-05-09 15:30:55 +02:00
@@ -113,10 +113,12 @@
#define HA_CAN_BIT_FIELD (1 << 28) /* supports bit fields */
#define HA_NEED_READ_RANGE_BUFFER (1 << 29) /* for read_multi_range */
#define HA_ANY_INDEX_MAY_BE_UNIQUE (1 << 30)
-#define HA_NO_COPY_ON_ALTER (LL(1) << 31)
-#define HA_HAS_RECORDS (LL(1) << 32) /* records() gives exact count*/
+/* The storage engine manages auto_increment itself */
+#define HA_EXTERNAL_AUTO_INCREMENT (1 << 31)
+#define HA_NO_COPY_ON_ALTER (LL(1) << 32)
+#define HA_HAS_RECORDS (LL(1) << 33) /* records() gives exact count*/
/* Has it's own method of binlog logging */
-#define HA_HAS_OWN_BINLOGGING (LL(1) << 33)
+#define HA_HAS_OWN_BINLOGGING (LL(1) << 34)
/* bits in index_flags(index_number) for what you can do with index */
#define HA_READ_NEXT 1 /* TODO really use this flag */
--- 1.13/mysql-test/r/ndb_insert.result 2007-05-09 15:30:55 +02:00
+++ 1.14/mysql-test/r/ndb_insert.result 2007-05-09 15:30:55 +02:00
@@ -657,3 +657,172 @@ a b
2 NULL
3 NULL
drop table t1;
+CREATE TABLE t1 (
+pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
+b INT NOT NULL,
+c INT NOT NULL UNIQUE
+) ENGINE=NDBCLUSTER;
+CREATE TABLE t2 (
+pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
+b INT NOT NULL,
+c INT NOT NULL UNIQUE
+) ENGINE=MYISAM;
+SET @@session.auto_increment_increment=10;
+INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2);
+INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2);
+SELECT * FROM t1 ORDER BY pk;
+pk b c
+1 1 0
+11 2 1
+21 3 2
+SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c;
+COUNT(t1.pk)
+3
+TRUNCATE t1;
+TRUNCATE t2;
+SET @@session.auto_increment_offset=5;
+INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2);
+INSERT INTO t1 (pk,b,c) VALUES (27,4,3),(NULL,5,4),(99,6,5),(NULL,7,6);
+INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2);
+INSERT INTO t2 (pk,b,c) VALUES (27,4,3),(NULL,5,4),(99,6,5),(NULL,7,6);
+SELECT * FROM t1 ORDER BY pk;
+pk b c
+5 1 0
+15 2 1
+25 3 2
+27 4 3
+35 5 4
+99 6 5
+105 7 6
+SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c;
+COUNT(t1.pk)
+7
+TRUNCATE t1;
+TRUNCATE t2;
+SET @@session.auto_increment_increment=2;
+INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2);
+INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2);
+SELECT * FROM t1 ORDER BY pk;
+pk b c
+1 1 0
+3 2 1
+5 3 2
+SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c;
+COUNT(t1.pk)
+3
+DROP TABLE t1, t2;
+CREATE TABLE t1 (
+pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
+b INT NOT NULL,
+c INT NOT NULL UNIQUE
+) ENGINE=NDBCLUSTER AUTO_INCREMENT = 7;
+CREATE TABLE t2 (
+pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
+b INT NOT NULL,
+c INT NOT NULL UNIQUE
+) ENGINE=MYISAM AUTO_INCREMENT = 7;
+SET @@session.auto_increment_offset=1;
+SET @@session.auto_increment_increment=1;
+INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2);
+INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2);
+SELECT * FROM t1 ORDER BY pk;
+pk b c
+7 1 0
+8 2 1
+9 3 2
+SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c;
+COUNT(t1.pk)
+3
+DROP TABLE t1, t2;
+CREATE TABLE t1 (
+pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
+b INT NOT NULL,
+c INT NOT NULL UNIQUE
+) ENGINE=NDBCLUSTER AUTO_INCREMENT = 3;
+CREATE TABLE t2 (
+pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
+b INT NOT NULL,
+c INT NOT NULL UNIQUE
+) ENGINE=MYISAM AUTO_INCREMENT = 3;
+SET @@session.auto_increment_offset=5;
+SET @@session.auto_increment_increment=10;
+INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2);
+INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2);
+SELECT * FROM t1 ORDER BY pk;
+pk b c
+5 1 0
+15 2 1
+25 3 2
+SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c;
+COUNT(t1.pk)
+3
+DROP TABLE t1, t2;
+CREATE TABLE t1 (
+pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
+b INT NOT NULL,
+c INT NOT NULL UNIQUE
+) ENGINE=NDBCLUSTER AUTO_INCREMENT = 7;
+CREATE TABLE t2 (
+pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
+b INT NOT NULL,
+c INT NOT NULL UNIQUE
+) ENGINE=MYISAM AUTO_INCREMENT = 7;
+SET @@session.auto_increment_offset=5;
+SET @@session.auto_increment_increment=10;
+INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2);
+INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2);
+SELECT * FROM t1 ORDER BY pk;
+pk b c
+15 1 0
+25 2 1
+35 3 2
+SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c;
+COUNT(t1.pk)
+3
+DROP TABLE t1, t2;
+CREATE TABLE t1 (
+pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
+b INT NOT NULL,
+c INT NOT NULL UNIQUE
+) ENGINE=NDBCLUSTER AUTO_INCREMENT = 5;
+CREATE TABLE t2 (
+pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
+b INT NOT NULL,
+c INT NOT NULL UNIQUE
+) ENGINE=MYISAM AUTO_INCREMENT = 5;
+SET @@session.auto_increment_offset=5;
+SET @@session.auto_increment_increment=10;
+INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2);
+INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2);
+SELECT * FROM t1 ORDER BY pk;
+pk b c
+5 1 0
+15 2 1
+25 3 2
+SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c;
+COUNT(t1.pk)
+3
+DROP TABLE t1, t2;
+CREATE TABLE t1 (
+pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
+b INT NOT NULL,
+c INT NOT NULL UNIQUE
+) ENGINE=NDBCLUSTER AUTO_INCREMENT = 100;
+CREATE TABLE t2 (
+pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
+b INT NOT NULL,
+c INT NOT NULL UNIQUE
+) ENGINE=MYISAM AUTO_INCREMENT = 100;
+SET @@session.auto_increment_offset=5;
+SET @@session.auto_increment_increment=10;
+INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2);
+INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2);
+SELECT * FROM t1 ORDER BY pk;
+pk b c
+105 1 0
+115 2 1
+125 3 2
+SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c;
+COUNT(t1.pk)
+3
+DROP TABLE t1, t2;
--- 1.14/mysql-test/t/ndb_insert.test 2007-05-09 15:30:55 +02:00
+++ 1.15/mysql-test/t/ndb_insert.test 2007-05-09 15:30:55 +02:00
@@ -639,4 +639,141 @@ insert ignore into t1 values (1,0), (2,0
select * from t1 order by a;
drop table t1;
+# Bug#26342 auto_increment_increment AND auto_increment_offset REALLY REALLY anger NDB
cluster
+
+CREATE TABLE t1 (
+ pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ b INT NOT NULL,
+ c INT NOT NULL UNIQUE
+) ENGINE=NDBCLUSTER;
+
+CREATE TABLE t2 (
+ pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ b INT NOT NULL,
+ c INT NOT NULL UNIQUE
+) ENGINE=MYISAM;
+
+SET @@session.auto_increment_increment=10;
+INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2);
+INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2);
+SELECT * FROM t1 ORDER BY pk;
+SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c;
+TRUNCATE t1;
+TRUNCATE t2;
+SET @@session.auto_increment_offset=5;
+INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2);
+INSERT INTO t1 (pk,b,c) VALUES (27,4,3),(NULL,5,4),(99,6,5),(NULL,7,6);
+INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2);
+INSERT INTO t2 (pk,b,c) VALUES (27,4,3),(NULL,5,4),(99,6,5),(NULL,7,6);
+SELECT * FROM t1 ORDER BY pk;
+SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c;
+TRUNCATE t1;
+TRUNCATE t2;
+SET @@session.auto_increment_increment=2;
+INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2);
+INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2);
+SELECT * FROM t1 ORDER BY pk;
+SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c;
+DROP TABLE t1, t2;
+
+CREATE TABLE t1 (
+ pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ b INT NOT NULL,
+ c INT NOT NULL UNIQUE
+) ENGINE=NDBCLUSTER AUTO_INCREMENT = 7;
+
+CREATE TABLE t2 (
+ pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ b INT NOT NULL,
+ c INT NOT NULL UNIQUE
+) ENGINE=MYISAM AUTO_INCREMENT = 7;
+
+SET @@session.auto_increment_offset=1;
+SET @@session.auto_increment_increment=1;
+INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2);
+INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2);
+SELECT * FROM t1 ORDER BY pk;
+SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c;
+DROP TABLE t1, t2;
+
+CREATE TABLE t1 (
+ pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ b INT NOT NULL,
+ c INT NOT NULL UNIQUE
+) ENGINE=NDBCLUSTER AUTO_INCREMENT = 3;
+
+CREATE TABLE t2 (
+ pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ b INT NOT NULL,
+ c INT NOT NULL UNIQUE
+) ENGINE=MYISAM AUTO_INCREMENT = 3;
+
+SET @@session.auto_increment_offset=5;
+SET @@session.auto_increment_increment=10;
+INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2);
+INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2);
+SELECT * FROM t1 ORDER BY pk;
+SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c;
+DROP TABLE t1, t2;
+
+CREATE TABLE t1 (
+ pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ b INT NOT NULL,
+ c INT NOT NULL UNIQUE
+) ENGINE=NDBCLUSTER AUTO_INCREMENT = 7;
+
+CREATE TABLE t2 (
+ pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ b INT NOT NULL,
+ c INT NOT NULL UNIQUE
+) ENGINE=MYISAM AUTO_INCREMENT = 7;
+
+SET @@session.auto_increment_offset=5;
+SET @@session.auto_increment_increment=10;
+INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2);
+INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2);
+SELECT * FROM t1 ORDER BY pk;
+SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c;
+DROP TABLE t1, t2;
+
+CREATE TABLE t1 (
+ pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ b INT NOT NULL,
+ c INT NOT NULL UNIQUE
+) ENGINE=NDBCLUSTER AUTO_INCREMENT = 5;
+
+CREATE TABLE t2 (
+ pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ b INT NOT NULL,
+ c INT NOT NULL UNIQUE
+) ENGINE=MYISAM AUTO_INCREMENT = 5;
+
+SET @@session.auto_increment_offset=5;
+SET @@session.auto_increment_increment=10;
+INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2);
+INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2);
+SELECT * FROM t1 ORDER BY pk;
+SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c;
+DROP TABLE t1, t2;
+
+CREATE TABLE t1 (
+ pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ b INT NOT NULL,
+ c INT NOT NULL UNIQUE
+) ENGINE=NDBCLUSTER AUTO_INCREMENT = 100;
+
+CREATE TABLE t2 (
+ pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ b INT NOT NULL,
+ c INT NOT NULL UNIQUE
+) ENGINE=MYISAM AUTO_INCREMENT = 100;
+
+SET @@session.auto_increment_offset=5;
+SET @@session.auto_increment_increment=10;
+INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2);
+INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2);
+SELECT * FROM t1 ORDER BY pk;
+SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c;
+DROP TABLE t1, t2;
+
# End of 4.1 tests
--- 1.39.13.1/ndb/include/ndbapi/Ndb.hpp 2007-05-09 15:30:55 +02:00
+++ 1.64/storage/ndb/include/ndbapi/Ndb.hpp 2007-05-09 15:30:55 +02:00
@@ -37,6 +37,9 @@
In addition, the NDB API defines a structure NdbError, which contains the
specification for an error.
+ It is also possible to receive "events" triggered when data in the database in
changed.
+ This is done through the NdbEventOperation class.
+
There are also some auxiliary classes, which are listed in the class hierarchy.
The main structure of an application program is as follows:
@@ -497,12 +500,11 @@
There are four conditions leading to the transfer of database
operations from Ndb object buffers to the NDB kernel:
- -# The NDB Transporter (TCP/IP, OSE, SCI or shared memory)
+ -# The NDB Transporter (TCP/IP, SCI or shared memory)
decides that a buffer is full and sends it off.
The buffer size is implementation-dependent and
may change between MySQL Cluster releases.
On TCP/IP the buffer size is usually around 64 KB;
- on OSE/Delta it is usually less than 2000 bytes.
Since each Ndb object provides a single buffer per storage node,
the notion of a "full" buffer is local to this storage node.
-# The accumulation of statistical data on transferred information
@@ -964,6 +966,7 @@
class NdbObjectIdMap;
class NdbOperation;
+class NdbEventOperationImpl;
class NdbScanOperation;
class NdbIndexScanOperation;
class NdbIndexOperation;
@@ -976,22 +979,20 @@ class NdbSubroutine;
class NdbCall;
class Table;
class BaseString;
+class NdbEventOperation;
class NdbBlob;
class NdbReceiver;
+class TransporterFacade;
+class PollGuard;
class Ndb_local_table_info;
template <class T> struct Ndb_free_list_t;
+typedef void (* NdbEventCallback)(NdbEventOperation*, Ndb*, void*);
-#if defined NDB_OSE
-/**
- * Default time to wait for response after request has been sent to
- * NDB Cluster (Set to 10 seconds usually, but to 100 s in
- * the OSE operating system)
- */
-#define WAITFOR_RESPONSE_TIMEOUT 100000 // Milliseconds
-#else
#define WAITFOR_RESPONSE_TIMEOUT 120000 // Milliseconds
-#endif
+
+#define NDB_SYSTEM_DATABASE "sys"
+#define NDB_SYSTEM_SCHEMA "def"
/**
* @class Ndb
@@ -1042,6 +1043,8 @@ class Ndb
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
friend class NdbReceiver;
friend class NdbOperation;
+ friend class NdbEventOperationImpl;
+ friend class NdbEventBuffer;
friend class NdbTransaction;
friend class Table;
friend class NdbApiSignal;
@@ -1081,6 +1084,15 @@ public:
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
/**
+ * The current ndb_cluster_connection get_ndb_cluster_connection.
+ *
+ * @return the current connection
+ */
+ Ndb_cluster_connection& get_ndb_cluster_connection();
+#endif
+
+#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
+ /**
* The current catalog name can be fetched by getCatalogName.
*
* @return the current catalog name
@@ -1137,6 +1149,15 @@ public:
*/
int setDatabaseSchemaName(const char * aDatabaseSchemaName);
+#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
+ /** Set database and schema name to match previously retrieved table
+ *
+ * Returns non-zero if table internal name does not contain
+ * non-empty database and schema names
+ */
+ int setDatabaseAndSchemaName(const NdbDictionary::Table* t);
+#endif
+
/**
* Initializes the Ndb object
*
@@ -1189,6 +1210,71 @@ public:
/** @} *********************************************************************/
/**
+ * @name Event subscriptions
+ * @{
+ */
+
+ /**
+ * Create a subcription to an event defined in the database
+ *
+ * @param eventName
+ * unique identifier of the event
+ *
+ * @return Object representing an event, NULL on failure
+ */
+ NdbEventOperation* createEventOperation(const char* eventName);
+ /**
+ * Drop a subscription to an event
+ *
+ * @param eventOp
+ * Event operation
+ *
+ * @return 0 on success
+ */
+ int dropEventOperation(NdbEventOperation* eventOp);
+
+ /**
+ * Wait for an event to occur. Will return as soon as an event
+ * is detected on any of the created events.
+ *
+ * @param aMillisecondNumber
+ * maximum time to wait
+ *
+ * @return > 0 if events available, 0 if no events available, < 0 on failure
+ */
+ int pollEvents(int aMillisecondNumber, Uint64 *latestGCI= 0);
+
+ /**
+ * Returns an event operation that has data after a pollEvents
+ *
+ * @return an event operations that has data, NULL if no events left with data.
+ */
+ NdbEventOperation *nextEvent();
+
+ /**
+ * Iterate over distinct event operations which are part of current
+ * GCI. Valid after nextEvent. Used to get summary information for
+ * the epoch (e.g. list of all tables) before processing event data.
+ *
+ * Set *iter=0 to start. Returns NULL when no more. If event_types
+ * is not NULL, it returns bitmask of received event types.
+ */
+ const NdbEventOperation*
+ getGCIEventOperations(Uint32* iter, Uint32* event_types);
+
+
+#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
+ int flushIncompleteEvents(Uint64 gci);
+ NdbEventOperation *getEventOperation(NdbEventOperation* eventOp= 0);
+ Uint64 getLatestGCI();
+ void forceGCP();
+ void setReportThreshEventGCISlip(unsigned thresh);
+ void setReportThreshEventFreeMem(unsigned thresh);
+#endif
+
+ /** @} *********************************************************************/
+
+ /**
* @name Starting and Closing Transactions
* @{
*/
@@ -1379,7 +1465,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
*
@@ -1387,29 +1475,48 @@ public:
*
* @return 0 or -1 on error, and tupleId in out parameter
*/
+ struct TupleIdRange {
+ 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,
- Uint64 step = 1, Uint64 start = 1);
+ Uint64 & tupleId, Uint32 cacheSize);
+ int getAutoIncrementValue(const NdbDictionary::Table * aTable,
+ Uint64 & tupleId, Uint32 cacheSize);
int getAutoIncrementValue(const NdbDictionary::Table * aTable,
- Uint64 & tupleId, Uint32 cacheSize,
- Uint64 step = 1, Uint64 start = 1);
+ 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,
- Uint64 step = 1, Uint64 start = 1 );
- 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:
/**
@@ -1433,12 +1540,18 @@ public:
/*****************************************************************************
* These are service routines used by the other classes in the NDBAPI.
****************************************************************************/
+ Uint32 get_cond_wait_index() { return cond_wait_index; }
+ void set_cond_wait_index(Uint32 index) { cond_wait_index = index; }
private:
+ Uint32 cond_wait_index;
+ Ndb *cond_signal_ndb;
+ void cond_signal();
void setup(Ndb_cluster_connection *ndb_cluster_connection,
const char* aCatalogName, const char* aSchemaName);
void connected(Uint32 block_reference);
+ void report_node_connected(Uint32 nodeId);
NdbTransaction* startTransactionLocal(Uint32 aPrio, Uint32 aFragmentId);
@@ -1460,7 +1573,6 @@ private:
NdbIndexScanOperation* getScanOperation(); // Get a scan operation from idle
NdbIndexOperation* getIndexOperation();// Get an index operation from idle
- class NdbGlobalEventBufferHandle* getGlobalEventBufferHandle();
NdbBlob* getNdbBlob();// Get a blob handle etc
void releaseSignal(NdbApiSignal* anApiSignal);
@@ -1484,13 +1596,11 @@ private:
// synchronous and asynchronous interface
void handleReceivedSignal(NdbApiSignal* anApiSignal, struct LinearSectionPtr ptr[3]);
- // Receive response signals
- int receiveResponse(int waitTime = WAITFOR_RESPONSE_TIMEOUT);
-
int sendRecSignal(Uint16 aNodeId,
Uint32 aWaitState,
NdbApiSignal* aSignal,
- Uint32 nodeSequence);
+ Uint32 nodeSequence,
+ Uint32 *ret_conn_seq= 0);
// Sets Restart GCI in Ndb object
void RestartGCI(int aRestartGCI);
@@ -1547,7 +1657,9 @@ private:
Uint32 pollCompleted(NdbTransaction** aCopyArray);
void sendPrepTrans(int forceSend);
void reportCallback(NdbTransaction** aCopyArray, Uint32 aNoOfComplTrans);
- void waitCompletedTransactions(int milliSecs, int noOfEventsToWaitFor);
+ int poll_trans(int milliSecs, int noOfEventsToWaitFor, PollGuard *pg);
+ void waitCompletedTransactions(int milliSecs, int noOfEventsToWaitFor,
+ PollGuard *pg);
void completedTransaction(NdbTransaction* aTransaction);
void completedScanTransaction(NdbTransaction* aTransaction);
@@ -1563,6 +1675,8 @@ private:
const char * externalizeIndexName(const char * internalIndexName,
bool fullyQualifiedNames);
const char * externalizeIndexName(const char * internalIndexName);
+ const BaseString old_internalize_index_name(const NdbTableImpl * table,
+ const char * external_name) const;
const BaseString internalize_index_name(const NdbTableImpl * table,
const char * external_name) const;
@@ -1599,7 +1713,7 @@ private:
class NdbImpl * theImpl;
class NdbDictionaryImpl* theDictionary;
- class NdbGlobalEventBufferHandle* theGlobalEventBufferHandle;
+ class NdbEventBuffer* theEventBuffer;
NdbTransaction* theTransactionList;
NdbTransaction** theConnectionArray;
@@ -1609,6 +1723,8 @@ private:
Uint64 the_last_check_time;
Uint64 theFirstTransId;
+ // The tupleId is retrieved from DB
+ const NdbDictionary::Table *m_sys_tab_0;
Uint32 theRestartGCI; // the Restart GCI used by DIHNDBTAMPER
--- 1.49.27.1/ndb/src/ndbapi/Ndb.cpp 2007-05-09 15:30:55 +02:00
+++ 1.93/storage/ndb/src/ndbapi/Ndb.cpp 2007-05-09 15:30:55 +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
@@ -767,127 +754,98 @@ Ndb::getNodeId()
}
/****************************************************************************
-Uint64 getAutoIncrementValue( const char* aTableName,
- Uint64 & tupleId,
- Uint32 cacheSize,
- Uint64 step,
- Uint64 start);
-
-Parameters: aTableName (IN) : The table name.
- autoValue (OUT) : Returns new autoincrement value
- cacheSize (IN) : Prefetch this many values
- step (IN) : Specifies the step between the
- autoincrement values.
- start (IN) : Start value for first value
-Remark: Returns a new autoincrement value to the application.
- The autoincrement values can be increased by steps
- (default 1) and a number of values can be prefetched
- by specifying cacheSize (default 10).
+Uint64 getTupleIdFromNdb( Uint32 aTableId, Uint32 cacheSize );
+
+Parameters: aTableId : The TableId.
+ cacheSize: Prefetch this many values
+Remark: Returns a new TupleId to the application.
+ The TupleId comes from SYSTAB_0 where SYSKEY_0 = TableId.
+ It is initialized to (TableId << 48) + 1 in NdbcntrMain.cpp.
****************************************************************************/
int
Ndb::getAutoIncrementValue(const char* aTableName,
- Uint64 & autoValue, Uint32 cacheSize,
- Uint64 step, Uint64 start)
+ Uint64 & tupleId, Uint32 cacheSize)
{
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, tupleId, cacheSize) == -1)
DBUG_RETURN(-1);
- DBUG_PRINT("info", ("value %lu", (ulong) autoValue));
+ DBUG_PRINT("info", ("value %lu", (ulong) tupleId));
DBUG_RETURN(0);
}
int
Ndb::getAutoIncrementValue(const NdbDictionary::Table * aTable,
- Uint64 & autoValue, Uint32 cacheSize,
- Uint64 step, Uint64 start)
+ Uint64 & tupleId, Uint32 cacheSize)
{
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, tupleId, cacheSize) == -1)
DBUG_RETURN(-1);
- DBUG_PRINT("info", ("value %lu", (ulong) autoValue));
+ DBUG_PRINT("info", ("value %lu", (ulong)tupleId));
DBUG_RETURN(0);
}
int
-Ndb::getTupleIdFromNdb(Ndb_local_table_info* info,
- Uint64 & tupleId, Uint32 cacheSize,
- Uint64 step, Uint64 start)
-{
-/*
- Returns a new TupleId to the application.
- The TupleId comes from SYSTAB_0 where SYSKEY_0 = TableId.
- It is initialized to (TableId << 48) + 1 in NdbcntrMain.cpp.
- In most cases step= start= 1, in which case we get:
- 1,2,3,4,5,...
- If step=10 and start=5 and first number is 1, we get:
- 5,15,25,35,...
-*/
+Ndb::getAutoIncrementValue(const NdbDictionary::Table * aTable,
+ TupleIdRange & range, Uint64 & tupleId,
+ Uint32 cacheSize)
+{
+ DBUG_ENTER("Ndb::getAutoIncrementValue");
+ assert(aTable != 0);
+ const NdbTableImpl* table = & NdbTableImpl::getImpl(*aTable);
+
+ if (getTupleIdFromNdb(table, range, tupleId, cacheSize) == -1)
+ DBUG_RETURN(-1);
+ DBUG_PRINT("info", ("value %lu", (ulong)tupleId));
+ DBUG_RETURN(0);
+}
+
+int
+Ndb::getTupleIdFromNdb(const NdbTableImpl* table,
+ TupleIdRange & range, Uint64 & tupleId, Uint32 cacheSize)
+{
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)
{
- assert(info->m_first_tuple_id < info->m_last_tuple_id);
- info->m_first_tuple_id += step;
- tupleId = info->m_first_tuple_id;
- DBUG_PRINT("info", ("Next cached value %lu", (ulong) tupleId));
+ assert(range.m_first_tuple_id < range.m_last_tuple_id);
+ 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;
-
- /*
- Pre-fetch a number of values depending on cacheSize
- */
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
- * incremented in steps then multiply the cacheSize with step size.
+ * and returns first tupleId in the new range.
*/
- Uint64 opValue = cacheSize * step;
-
- if (opTupleIdOnNdb(info, opValue, 0) == -1)
+ Uint64 opValue = cacheSize;
+ 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));
- Uint64 current, next;
- next = ((Uint64) (opValue + step - offset)) / step;
- next = next * step + offset;
- current = (next < step) ? next : next - step;
- tupleId = (opValue <= current) ? current : next;
- DBUG_PRINT("info", ("Returning %lu", (ulong) tupleId));
- info->m_first_tuple_id = tupleId;
+ tupleId = opValue;
}
DBUG_RETURN(0);
}
@@ -897,15 +855,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 +877,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::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(Ndb_local_table_info* info,
- Uint64 & tupleId)
+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 +926,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 +938,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 +959,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::setTupleIdInNdb(Ndb_local_table_info* info,
- Uint64 tupleId, bool increase)
+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(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 +1015,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 +1023,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 +1086,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 +1105,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 +1122,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 +1149,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 +1191,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 +1223,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 +1236,8 @@ int Ndb::setSchemaName(const char * a_sc
}
return 0;
}
+// </internal>
-/*
-Deprecated functions
-*/
const char * Ndb::getDatabaseName() const
{
return getCatalogName();
@@ -1238,6 +1257,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 +1339,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 +1360,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 +1397,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 +1406,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 +1464,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.2511) | Martin Skold | 9 May |