Commit a945c58f authored by mskold@mysql.com's avatar mskold@mysql.com

Merge mysql.com:/usr/local/home/marty/MySQL/mysql-5.0

into  mysql.com:/usr/local/home/marty/MySQL/mysql-5.1-new
parents 94814d73 a40d9128
...@@ -577,6 +577,25 @@ pk1 b c ...@@ -577,6 +577,25 @@ pk1 b c
2 2 17 2 2 17
4 4 3 4 4 3
6 6 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; DROP TABLE t1;
CREATE TABLE t1(a INT) ENGINE=ndb; CREATE TABLE t1(a INT) ENGINE=ndb;
INSERT IGNORE INTO t1 VALUES (1); INSERT IGNORE INTO t1 VALUES (1);
...@@ -586,7 +605,7 @@ INSERT IGNORE INTO t1 SELECT a FROM t1; ...@@ -586,7 +605,7 @@ INSERT IGNORE INTO t1 SELECT a FROM t1;
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);
INSERT IGNORE INTO t1 VALUES (1); INSERT IGNORE INTO t1 VALUES (1);
SELECT * FROM t1; SELECT * FROM t1 ORDER BY a;
a a
1 1
1 1
...@@ -606,4 +625,11 @@ a ...@@ -606,4 +625,11 @@ a
1 1
1 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; DROP TABLE t1;
...@@ -19,3 +19,15 @@ gesuchnr benutzer_id ...@@ -19,3 +19,15 @@ gesuchnr benutzer_id
2 1 2 1
3 2 3 2
drop table t1; 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
...@@ -591,14 +591,14 @@ DELETE FROM t1 WHERE pk1 = 2 OR pk1 = 4 OR pk1 = 6; ...@@ -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; 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; select * from t1 where pk1 = b and b != c order by pk1;
# The following test case currently does not work # Test handling of duplicate unique
#DELETE FROM t1; DELETE FROM t1;
#CREATE UNIQUE INDEX bi ON t1(b); CREATE UNIQUE INDEX bi ON t1(b);
#INSERT INTO t1 VALUES INSERT INTO t1 VALUES
#(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), (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); (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; 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; select * from t1 order by pk1;
DROP TABLE t1; DROP TABLE t1;
...@@ -614,7 +614,12 @@ INSERT IGNORE INTO t1 SELECT a FROM 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 SELECT a FROM t1;
INSERT IGNORE INTO t1 VALUES (1); INSERT IGNORE INTO t1 VALUES (1);
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; DROP TABLE t1;
# End of 4.1 tests # End of 4.1 tests
...@@ -27,4 +27,15 @@ replace into t1 (gesuchnr,benutzer_id) values (1,1); ...@@ -27,4 +27,15 @@ replace into t1 (gesuchnr,benutzer_id) values (1,1);
select * from t1 order by gesuchnr; select * from t1 order by gesuchnr;
drop table t1; 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 # End of 4.1 tests
...@@ -129,6 +129,11 @@ public: ...@@ -129,6 +129,11 @@ public:
*/ */
int deleteTuple(); int deleteTuple();
/**
* Get index object for this operation
*/
const NdbDictionary::Index * getIndex() const;
#ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED #ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
/** /**
* Define the NdbIndexOperation to be a standard operation of type * Define the NdbIndexOperation to be a standard operation of type
......
...@@ -55,6 +55,29 @@ public: ...@@ -55,6 +55,29 @@ public:
* @{ * @{
*/ */
/**
* 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 * Lock when performing read
*/ */
...@@ -720,6 +743,11 @@ public: ...@@ -720,6 +743,11 @@ public:
*/ */
const NdbDictionary::Table * getTable() const; const NdbDictionary::Table * getTable() const;
/**
* Get the type of access for this operation
*/
const Type getType() const;
/** @} *********************************************************************/ /** @} *********************************************************************/
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
...@@ -773,7 +801,7 @@ protected: ...@@ -773,7 +801,7 @@ protected:
int init(const class NdbTableImpl*, NdbTransaction* aCon); int init(const class NdbTableImpl*, NdbTransaction* aCon);
void initInterpreter(); void initInterpreter();
NdbOperation(Ndb* aNdb); NdbOperation(Ndb* aNdb, Type aType = PrimaryKeyAccess);
virtual ~NdbOperation(); virtual ~NdbOperation();
void next(NdbOperation*); // Set next pointer void next(NdbOperation*); // Set next pointer
NdbOperation* next(); // Get next pointer NdbOperation* next(); // Get next pointer
...@@ -887,6 +915,8 @@ protected: ...@@ -887,6 +915,8 @@ protected:
* These are the private variables that are defined in the operation objects. * These are the private variables that are defined in the operation objects.
*****************************************************************************/ *****************************************************************************/
Type m_type;
NdbReceiver theReceiver; NdbReceiver theReceiver;
NdbError theError; // Errorcode NdbError theError; // Errorcode
...@@ -1050,6 +1080,19 @@ NdbOperation::getFirstRecAttr() const ...@@ -1050,6 +1080,19 @@ NdbOperation::getFirstRecAttr() const
return theReceiver.theFirstRecAttr; return theReceiver.theFirstRecAttr;
} }
/******************************************************************************
Type getType()
Return Value Return the Type.
Remark: Gets type of access.
******************************************************************************/
inline
const NdbOperation::Type
NdbOperation::getType() const
{
return m_type;
}
/****************************************************************************** /******************************************************************************
OperationStatus Status(); OperationStatus Status();
......
...@@ -178,7 +178,8 @@ public: ...@@ -178,7 +178,8 @@ public:
int restart(bool forceSend = false); int restart(bool forceSend = false);
protected: protected:
NdbScanOperation(Ndb* aNdb); NdbScanOperation(Ndb* aNdb,
NdbOperation::Type aType = NdbOperation::TableScan);
virtual ~NdbScanOperation(); virtual ~NdbScanOperation();
int nextResultImpl(bool fetchAllowed = true, bool forceSend = false); int nextResultImpl(bool fetchAllowed = true, bool forceSend = false);
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include <signaldata/IndxAttrInfo.hpp> #include <signaldata/IndxAttrInfo.hpp>
NdbIndexOperation::NdbIndexOperation(Ndb* aNdb) : NdbIndexOperation::NdbIndexOperation(Ndb* aNdb) :
NdbOperation(aNdb), NdbOperation(aNdb, NdbOperation::UniqueIndexAccess),
m_theIndex(NULL) m_theIndex(NULL)
{ {
m_tcReqGSN = GSN_TCINDXREQ; m_tcReqGSN = GSN_TCINDXREQ;
...@@ -164,6 +164,12 @@ int NdbIndexOperation::interpretedDeleteTuple() ...@@ -164,6 +164,12 @@ int NdbIndexOperation::interpretedDeleteTuple()
return NdbOperation::interpretedDeleteTuple(); return NdbOperation::interpretedDeleteTuple();
} }
const NdbDictionary::Index*
NdbIndexOperation::getIndex() const
{
return m_theIndex;
}
int int
NdbIndexOperation::prepareSend(Uint32 aTC_ConnectPtr, Uint64 aTransactionId) NdbIndexOperation::prepareSend(Uint32 aTC_ConnectPtr, Uint64 aTransactionId)
{ {
......
...@@ -37,7 +37,8 @@ ...@@ -37,7 +37,8 @@
* aTable: Pointers to the Table object * aTable: Pointers to the Table object
* Remark: Creat an object of NdbOperation. * Remark: Creat an object of NdbOperation.
****************************************************************************/ ****************************************************************************/
NdbOperation::NdbOperation(Ndb* aNdb) : NdbOperation::NdbOperation(Ndb* aNdb, NdbOperation::Type aType) :
m_type(aType),
theReceiver(aNdb), theReceiver(aNdb),
theErrorLine(0), theErrorLine(0),
theNdb(aNdb), theNdb(aNdb),
......
...@@ -37,8 +37,8 @@ ...@@ -37,8 +37,8 @@
#define DEBUG_NEXT_RESULT 0 #define DEBUG_NEXT_RESULT 0
NdbScanOperation::NdbScanOperation(Ndb* aNdb) : NdbScanOperation::NdbScanOperation(Ndb* aNdb, NdbOperation::Type aType) :
NdbOperation(aNdb), NdbOperation(aNdb, aType),
m_transConnection(NULL) m_transConnection(NULL)
{ {
theParallelism = 0; theParallelism = 0;
...@@ -1032,7 +1032,7 @@ NdbScanOperation::getBlobHandle(Uint32 anAttrId) ...@@ -1032,7 +1032,7 @@ NdbScanOperation::getBlobHandle(Uint32 anAttrId)
} }
NdbIndexScanOperation::NdbIndexScanOperation(Ndb* aNdb) NdbIndexScanOperation::NdbIndexScanOperation(Ndb* aNdb)
: NdbScanOperation(aNdb) : NdbScanOperation(aNdb, NdbOperation::OrderedIndexScan)
{ {
} }
......
...@@ -1193,6 +1193,8 @@ NdbTransaction::getNdbIndexScanOperation(const NdbIndexImpl* index, ...@@ -1193,6 +1193,8 @@ NdbTransaction::getNdbIndexScanOperation(const NdbIndexImpl* index,
{ {
tOp->m_currentTable = table; tOp->m_currentTable = table;
} }
// Mark that this really an NdbIndexScanOperation
tOp->m_type = NdbOperation::OrderedIndexScan;
return tOp; return tOp;
} else { } else {
setOperationErrorCodeAbort(4271); setOperationErrorCodeAbort(4271);
...@@ -1254,6 +1256,8 @@ NdbTransaction::getNdbScanOperation(const NdbTableImpl * tab) ...@@ -1254,6 +1256,8 @@ NdbTransaction::getNdbScanOperation(const NdbTableImpl * tab)
if (tOp->init(tab, this) != -1) { if (tOp->init(tab, this) != -1) {
define_scan_op(tOp); define_scan_op(tOp);
// Mark that this NdbIndexScanOperation is used as NdbScanOperation
tOp->m_type = NdbOperation::TableScan;
return tOp; return tOp;
} else { } else {
theNdb->releaseScanOperation(tOp); theNdb->releaseScanOperation(tOp);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment