diff options
author | unknown <mskold@mysql.com> | 2006-03-23 22:39:30 +0100 |
---|---|---|
committer | unknown <mskold@mysql.com> | 2006-03-23 22:39:30 +0100 |
commit | ff8f4ca4968053e5ef4d227721915db4b05f44f7 (patch) | |
tree | 663cd6576766a904a568b03694fc5fac1783e4b7 | |
parent | c22e3f99619f82517f9331867b721ae0fbf30d48 (diff) | |
parent | ef27bd8aac6e861a914c51c3c9dc4657f5302dfd (diff) | |
download | mariadb-git-ff8f4ca4968053e5ef4d227721915db4b05f44f7.tar.gz |
Merge mysql.com:/usr/local/home/marty/MySQL/mysql-5.0
into mysql.com:/usr/local/home/marty/MySQL/mysql-5.1-new
mysql-test/r/ndb_insert.result:
Auto merged
mysql-test/r/ndb_replace.result:
Auto merged
storage/ndb/include/ndbapi/NdbIndexOperation.hpp:
Auto merged
storage/ndb/include/ndbapi/NdbOperation.hpp:
Auto merged
storage/ndb/include/ndbapi/NdbScanOperation.hpp:
Auto merged
storage/ndb/src/ndbapi/NdbIndexOperation.cpp:
Auto merged
storage/ndb/src/ndbapi/NdbOperation.cpp:
Auto merged
storage/ndb/src/ndbapi/NdbScanOperation.cpp:
Auto merged
storage/ndb/src/ndbapi/NdbTransaction.cpp:
Auto merged
sql/ha_ndbcluster.cc:
Keeping local and do manual merge
sql/ha_ndbcluster.h:
Keeping local and do hand merge
-rw-r--r-- | mysql-test/r/ndb_insert.result | 28 | ||||
-rw-r--r-- | mysql-test/r/ndb_replace.result | 12 | ||||
-rw-r--r-- | mysql-test/t/ndb_insert.test | 23 | ||||
-rw-r--r-- | mysql-test/t/ndb_replace.test | 11 | ||||
-rw-r--r-- | storage/ndb/include/ndbapi/NdbIndexOperation.hpp | 5 | ||||
-rw-r--r-- | storage/ndb/include/ndbapi/NdbOperation.hpp | 47 | ||||
-rw-r--r-- | storage/ndb/include/ndbapi/NdbScanOperation.hpp | 3 | ||||
-rw-r--r-- | storage/ndb/src/ndbapi/NdbIndexOperation.cpp | 8 | ||||
-rw-r--r-- | storage/ndb/src/ndbapi/NdbOperation.cpp | 3 | ||||
-rw-r--r-- | storage/ndb/src/ndbapi/NdbScanOperation.cpp | 6 | ||||
-rw-r--r-- | storage/ndb/src/ndbapi/NdbTransaction.cpp | 4 |
11 files changed, 132 insertions, 18 deletions
diff --git a/mysql-test/r/ndb_insert.result b/mysql-test/r/ndb_insert.result index 11d322a06de..1da958ef0f7 100644 --- a/mysql-test/r/ndb_insert.result +++ b/mysql-test/r/ndb_insert.result @@ -577,6 +577,25 @@ pk1 b c 2 2 17 4 4 3 6 6 3 +DELETE FROM t1; +CREATE UNIQUE INDEX bi ON t1(b); +INSERT INTO t1 VALUES +(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), +(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10); +INSERT INTO t1 VALUES(0,1,0),(21,21,21) ON DUPLICATE KEY UPDATE pk1=b+10,b=b+10; +select * from t1 order by pk1; +pk1 b c +2 2 2 +3 3 3 +4 4 4 +5 5 5 +6 6 6 +7 7 7 +8 8 8 +9 9 9 +10 10 10 +11 11 1 +21 21 21 DROP TABLE t1; CREATE TABLE t1(a INT) ENGINE=ndb; INSERT IGNORE INTO t1 VALUES (1); @@ -586,7 +605,7 @@ INSERT IGNORE INTO t1 SELECT a FROM t1; INSERT IGNORE INTO t1 SELECT a FROM t1; INSERT IGNORE INTO t1 VALUES (1); INSERT IGNORE INTO t1 VALUES (1); -SELECT * FROM t1; +SELECT * FROM t1 ORDER BY a; a 1 1 @@ -606,4 +625,11 @@ a 1 1 1 +DELETE FROM t1; +CREATE UNIQUE INDEX ai ON t1(a); +INSERT IGNORE INTO t1 VALUES (1); +INSERT IGNORE INTO t1 VALUES (1); +SELECT * FROM t1 ORDER BY a; +a +1 DROP TABLE t1; diff --git a/mysql-test/r/ndb_replace.result b/mysql-test/r/ndb_replace.result index 6aa1a387661..5e49968ca64 100644 --- a/mysql-test/r/ndb_replace.result +++ b/mysql-test/r/ndb_replace.result @@ -19,3 +19,15 @@ gesuchnr benutzer_id 2 1 3 2 drop table t1; +CREATE TABLE t1(i INT PRIMARY KEY AUTO_INCREMENT, +j INT, +k INT, +UNIQUE INDEX(j) +) ENGINE = ndb; +INSERT INTO t1 VALUES (1,1,23),(2,2,24); +REPLACE INTO t1 (j,k) VALUES (1,42); +REPLACE INTO t1 (i,j) VALUES (17,2); +SELECT * from t1 ORDER BY i; +i j k +3 1 42 +17 2 24 diff --git a/mysql-test/t/ndb_insert.test b/mysql-test/t/ndb_insert.test index 92bc51bcf4f..4fe847058c4 100644 --- a/mysql-test/t/ndb_insert.test +++ b/mysql-test/t/ndb_insert.test @@ -591,14 +591,14 @@ DELETE FROM t1 WHERE pk1 = 2 OR pk1 = 4 OR pk1 = 6; INSERT INTO t1 VALUES(1,1,1),(2,2,17),(3,4,5) ON DUPLICATE KEY UPDATE pk1=b; select * from t1 where pk1 = b and b != c order by pk1; -# The following test case currently does not work -#DELETE FROM t1; -#CREATE UNIQUE INDEX bi ON t1(b); -#INSERT INTO t1 VALUES -#(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), -#(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10); -#INSERT INTO t1 VALUES(0,1,0),(21,21,21) ON DUPLICATE KEY UPDATE pk1=b+10,c=b+10; -#select * from t1 order by pk1; +# Test handling of duplicate unique +DELETE FROM t1; +CREATE UNIQUE INDEX bi ON t1(b); +INSERT INTO t1 VALUES +(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), +(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10); +INSERT INTO t1 VALUES(0,1,0),(21,21,21) ON DUPLICATE KEY UPDATE pk1=b+10,b=b+10; +select * from t1 order by pk1; DROP TABLE t1; @@ -614,7 +614,12 @@ INSERT IGNORE INTO t1 SELECT a FROM t1; INSERT IGNORE INTO t1 SELECT a FROM t1; INSERT IGNORE INTO t1 VALUES (1); INSERT IGNORE INTO t1 VALUES (1); -SELECT * FROM t1; +SELECT * FROM t1 ORDER BY a; +DELETE FROM t1; +CREATE UNIQUE INDEX ai ON t1(a); +INSERT IGNORE INTO t1 VALUES (1); +INSERT IGNORE INTO t1 VALUES (1); +SELECT * FROM t1 ORDER BY a; DROP TABLE t1; # End of 4.1 tests diff --git a/mysql-test/t/ndb_replace.test b/mysql-test/t/ndb_replace.test index b97a0322a6a..6cad80ef8ea 100644 --- a/mysql-test/t/ndb_replace.test +++ b/mysql-test/t/ndb_replace.test @@ -27,4 +27,15 @@ replace into t1 (gesuchnr,benutzer_id) values (1,1); select * from t1 order by gesuchnr; drop table t1; +# bug#17431 +CREATE TABLE t1(i INT PRIMARY KEY AUTO_INCREMENT, + j INT, + k INT, + UNIQUE INDEX(j) + ) ENGINE = ndb; +INSERT INTO t1 VALUES (1,1,23),(2,2,24); +REPLACE INTO t1 (j,k) VALUES (1,42); +REPLACE INTO t1 (i,j) VALUES (17,2); +SELECT * from t1 ORDER BY i; + # End of 4.1 tests diff --git a/storage/ndb/include/ndbapi/NdbIndexOperation.hpp b/storage/ndb/include/ndbapi/NdbIndexOperation.hpp index a8a15978568..d16cd071f77 100644 --- a/storage/ndb/include/ndbapi/NdbIndexOperation.hpp +++ b/storage/ndb/include/ndbapi/NdbIndexOperation.hpp @@ -129,6 +129,11 @@ public: */ int deleteTuple(); + /** + * Get index object for this operation + */ + const NdbDictionary::Index * getIndex() const; + #ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED /** * Define the NdbIndexOperation to be a standard operation of type diff --git a/storage/ndb/include/ndbapi/NdbOperation.hpp b/storage/ndb/include/ndbapi/NdbOperation.hpp index 3a442c94253..e747dedb84b 100644 --- a/storage/ndb/include/ndbapi/NdbOperation.hpp +++ b/storage/ndb/include/ndbapi/NdbOperation.hpp @@ -56,9 +56,32 @@ public: */ /** - * Lock when performing read + * Different access types (supported by sub-classes of NdbOperation) */ + + enum Type { + PrimaryKeyAccess ///< Read, insert, update, or delete using pk +#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL + = 0 // NdbOperation +#endif + ,UniqueIndexAccess ///< Read, update, or delete using unique index +#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL + = 1 // NdbIndexOperation +#endif + ,TableScan ///< Full table scan +#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL + = 2 // NdbScanOperation +#endif + ,OrderedIndexScan ///< Ordered index scan +#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL + = 3 // NdbIndexScanOperation +#endif + }; + /** + * Lock when performing read + */ + enum LockMode { LM_Read ///< Read with shared lock #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL @@ -720,6 +743,11 @@ public: */ const NdbDictionary::Table * getTable() const; + /** + * Get the type of access for this operation + */ + const Type getType() const; + /** @} *********************************************************************/ #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL @@ -773,7 +801,7 @@ protected: int init(const class NdbTableImpl*, NdbTransaction* aCon); void initInterpreter(); - NdbOperation(Ndb* aNdb); + NdbOperation(Ndb* aNdb, Type aType = PrimaryKeyAccess); virtual ~NdbOperation(); void next(NdbOperation*); // Set next pointer NdbOperation* next(); // Get next pointer @@ -887,6 +915,8 @@ protected: * These are the private variables that are defined in the operation objects. *****************************************************************************/ + Type m_type; + NdbReceiver theReceiver; NdbError theError; // Errorcode @@ -1051,6 +1081,19 @@ NdbOperation::getFirstRecAttr() const } /****************************************************************************** +Type getType() + +Return Value Return the Type. +Remark: Gets type of access. +******************************************************************************/ +inline +const NdbOperation::Type +NdbOperation::getType() const +{ + return m_type; +} + +/****************************************************************************** OperationStatus Status(); Return Value Return the OperationStatus. diff --git a/storage/ndb/include/ndbapi/NdbScanOperation.hpp b/storage/ndb/include/ndbapi/NdbScanOperation.hpp index 048e7a0c952..6f80a1627fe 100644 --- a/storage/ndb/include/ndbapi/NdbScanOperation.hpp +++ b/storage/ndb/include/ndbapi/NdbScanOperation.hpp @@ -178,7 +178,8 @@ public: int restart(bool forceSend = false); protected: - NdbScanOperation(Ndb* aNdb); + NdbScanOperation(Ndb* aNdb, + NdbOperation::Type aType = NdbOperation::TableScan); virtual ~NdbScanOperation(); int nextResultImpl(bool fetchAllowed = true, bool forceSend = false); diff --git a/storage/ndb/src/ndbapi/NdbIndexOperation.cpp b/storage/ndb/src/ndbapi/NdbIndexOperation.cpp index 250af162262..39dbab423d3 100644 --- a/storage/ndb/src/ndbapi/NdbIndexOperation.cpp +++ b/storage/ndb/src/ndbapi/NdbIndexOperation.cpp @@ -26,7 +26,7 @@ #include <signaldata/IndxAttrInfo.hpp> NdbIndexOperation::NdbIndexOperation(Ndb* aNdb) : - NdbOperation(aNdb), + NdbOperation(aNdb, NdbOperation::UniqueIndexAccess), m_theIndex(NULL) { m_tcReqGSN = GSN_TCINDXREQ; @@ -164,6 +164,12 @@ int NdbIndexOperation::interpretedDeleteTuple() return NdbOperation::interpretedDeleteTuple(); } +const NdbDictionary::Index* +NdbIndexOperation::getIndex() const +{ + return m_theIndex; +} + int NdbIndexOperation::prepareSend(Uint32 aTC_ConnectPtr, Uint64 aTransactionId) { diff --git a/storage/ndb/src/ndbapi/NdbOperation.cpp b/storage/ndb/src/ndbapi/NdbOperation.cpp index c88b3a5e6ac..769ce0662ef 100644 --- a/storage/ndb/src/ndbapi/NdbOperation.cpp +++ b/storage/ndb/src/ndbapi/NdbOperation.cpp @@ -37,7 +37,8 @@ * aTable: Pointers to the Table object * Remark: Creat an object of NdbOperation. ****************************************************************************/ -NdbOperation::NdbOperation(Ndb* aNdb) : +NdbOperation::NdbOperation(Ndb* aNdb, NdbOperation::Type aType) : + m_type(aType), theReceiver(aNdb), theErrorLine(0), theNdb(aNdb), diff --git a/storage/ndb/src/ndbapi/NdbScanOperation.cpp b/storage/ndb/src/ndbapi/NdbScanOperation.cpp index c841a371af9..ad80d2e7c0c 100644 --- a/storage/ndb/src/ndbapi/NdbScanOperation.cpp +++ b/storage/ndb/src/ndbapi/NdbScanOperation.cpp @@ -37,8 +37,8 @@ #define DEBUG_NEXT_RESULT 0 -NdbScanOperation::NdbScanOperation(Ndb* aNdb) : - NdbOperation(aNdb), +NdbScanOperation::NdbScanOperation(Ndb* aNdb, NdbOperation::Type aType) : + NdbOperation(aNdb, aType), m_transConnection(NULL) { theParallelism = 0; @@ -1032,7 +1032,7 @@ NdbScanOperation::getBlobHandle(Uint32 anAttrId) } NdbIndexScanOperation::NdbIndexScanOperation(Ndb* aNdb) - : NdbScanOperation(aNdb) + : NdbScanOperation(aNdb, NdbOperation::OrderedIndexScan) { } diff --git a/storage/ndb/src/ndbapi/NdbTransaction.cpp b/storage/ndb/src/ndbapi/NdbTransaction.cpp index f309c448fd3..82125985b52 100644 --- a/storage/ndb/src/ndbapi/NdbTransaction.cpp +++ b/storage/ndb/src/ndbapi/NdbTransaction.cpp @@ -1193,6 +1193,8 @@ NdbTransaction::getNdbIndexScanOperation(const NdbIndexImpl* index, { tOp->m_currentTable = table; } + // Mark that this really an NdbIndexScanOperation + tOp->m_type = NdbOperation::OrderedIndexScan; return tOp; } else { setOperationErrorCodeAbort(4271); @@ -1254,6 +1256,8 @@ NdbTransaction::getNdbScanOperation(const NdbTableImpl * tab) if (tOp->init(tab, this) != -1) { define_scan_op(tOp); + // Mark that this NdbIndexScanOperation is used as NdbScanOperation + tOp->m_type = NdbOperation::TableScan; return tOp; } else { theNdb->releaseScanOperation(tOp); |