Commit 48e50085 authored by unknown's avatar unknown

wl2126 ndb read_multi_range - bugfixes + more tests


mysql-test/r/ndb_read_multi_range.result:
  add order by tests + mixed ranges
mysql-test/t/ndb_read_multi_range.test:
  add order by tests + mixed ranges
ndb/include/kernel/signaldata/TcIndx.hpp:
  removed TcIndxRef (use TcKeyRef instead)
ndb/src/kernel/blocks/dbtc/DbtcMain.cpp:
  removed TcIndxRef (use TcKeyRef instead)
ndb/src/ndbapi/NdbIndexOperation.cpp:
  removed TcIndxRef (use TcKeyRef instead)
sql/ha_ndbcluster.cc:
  bug fixes in batched ranged access (when ordered)
parent a26737a0
......@@ -33,18 +33,20 @@ a b c
5 2 12
9 2 8
drop table r1;
create table r1 as select * from t1 where a in (33,8,12);
create table r1 as select * from t1 where a in (2,8) or (a > 11) or (a <= 1);
select * from r1 order by a;
a b c
1 2 1
2 3 2
8 5 9
12 5 5
drop table r1;
select * from t1 where a in (33,34,35) order by a;
a b c
select * from t1 where a in (33,8,12) order by a;
create table r1 as select * from t1 where a in (33,8,12);
select * from r1 order by a;
a b c
8 5 9
12 5 5
drop table r1;
create table r1 as select * from t1 where a in (2,33,8,12,34);
select * from r1 order by a;
a b c
......@@ -73,6 +75,50 @@ a b c
drop table r1;
select * from t1 where b in (45,22) order by a;
a b c
create table r1 as select * from t1 where c in (2,8,33);
select * from r1 order by a;
a b c
2 3 2
9 2 8
drop table r1;
create table r1 as select * from t1 where c in (13,2,8,33,12);
select * from r1 order by a;
a b c
2 3 2
5 2 12
9 2 8
drop table r1;
select * from t1 where a in (33,8,12) order by a;
a b c
8 5 9
12 5 5
select * from t1 where a in (33,34,35) order by a;
a b c
select * from t1 where a in (2,8) or (a > 11) or (a <= 1) order by a;
a b c
1 2 1
2 3 2
8 5 9
12 5 5
select * from t1 where b in (6,7) or (b <= 5) or (b >= 10) order by b,a;
a b c
1 2 1
5 2 12
9 2 8
2 3 2
6 3 11
10 3 7
3 4 3
7 4 10
11 4 6
4 5 4
8 5 9
12 5 5
select * from t1 where c in (13,2,8,33,12) order by c,a;
a b c
2 3 2
9 2 8
5 2 12
drop table t1;
create table t1 (
a int not null,
......
......@@ -34,12 +34,15 @@ create table r1 as select * from t1 where c in (2,8,12);
select * from r1 order by a;
drop table r1;
# batch mixed
create table r1 as select * from t1 where a in (2,8) or (a > 11) or (a <= 1);
select * from r1 order by a;
drop table r1;
# batch on primary key, missing values
create table r1 as select * from t1 where a in (33,8,12);
select * from r1 order by a;
drop table r1;
select * from t1 where a in (33,34,35) order by a;
select * from t1 where a in (33,8,12) order by a;
create table r1 as select * from t1 where a in (2,33,8,12,34);
select * from r1 order by a;
drop table r1;
......@@ -54,15 +57,19 @@ select * from r1 order by a;
drop table r1;
select * from t1 where b in (45,22) order by a;
# current bug in ndb, cannot handle missing values for unique indexes
# batch on unique hash index, missing values
#create table r1 as select * from t1 where c in (2,8,33);
#select * from r1 order by a;
#drop table r1;
#create table r1 as select * from t1 where c in (13,2,8,33,12);
#select * from r1 order by a;
#drop table r1;
create table r1 as select * from t1 where c in (2,8,33);
select * from r1 order by a;
drop table r1;
create table r1 as select * from t1 where c in (13,2,8,33,12);
select * from r1 order by a;
drop table r1;
select * from t1 where a in (33,8,12) order by a;
select * from t1 where a in (33,34,35) order by a;
select * from t1 where a in (2,8) or (a > 11) or (a <= 1) order by a;
select * from t1 where b in (6,7) or (b <= 5) or (b >= 10) order by b,a;
select * from t1 where c in (13,2,8,33,12) order by c,a;
drop table t1;
#
......
......@@ -123,34 +123,4 @@ TcIndxConf::setMarkerFlag(Uint32 & confInfo, Uint32 flag){
confInfo |= (flag << 17);
}
class TcIndxRef {
/**
* Reciver(s)
*/
friend class NdbIndexOperation;
/**
* Sender(s)
*/
friend class Dbtc;
/**
* For printing
*/
friend bool printTCINDXREF(FILE *, const Uint32 *, Uint32, Uint16);
public:
/**
* Length of signal
*/
public:
STATIC_CONST( SignalLength = 4 );
private:
Uint32 connectPtr;
Uint32 transId[2];
Uint32 errorCode;
};
#endif
......@@ -11144,14 +11144,14 @@ void Dbtc::execTCINDXREQ(Signal* signal)
if (!seizeIndexOperation(regApiPtr, indexOpPtr)) {
jam();
// Failed to allocate index operation
TcIndxRef * const tcIndxRef = (TcIndxRef *)signal->getDataPtrSend();
TcKeyRef * const tcIndxRef = (TcKeyRef *)signal->getDataPtrSend();
tcIndxRef->connectPtr = tcIndxReq->senderData;
tcIndxRef->transId[0] = regApiPtr->transid[0];
tcIndxRef->transId[1] = regApiPtr->transid[1];
tcIndxRef->errorCode = 4000;
sendSignal(regApiPtr->ndbapiBlockref, GSN_TCINDXREF, signal,
TcIndxRef::SignalLength, JBB);
TcKeyRef::SignalLength, JBB);
return;
}
TcIndexOperation* indexOp = indexOpPtr.p;
......@@ -11465,14 +11465,14 @@ void Dbtc::execTCKEYCONF(Signal* signal)
case(IOS_NOOP): {
jam();
// Should never happen, abort
TcIndxRef * const tcIndxRef = (TcIndxRef *)signal->getDataPtrSend();
TcKeyRef * const tcIndxRef = (TcKeyRef *)signal->getDataPtrSend();
tcIndxRef->connectPtr = indexOp->tcIndxReq.senderData;
tcIndxRef->transId[0] = regApiPtr->transid[0];
tcIndxRef->transId[1] = regApiPtr->transid[1];
tcIndxRef->errorCode = 4349;
sendSignal(regApiPtr->ndbapiBlockref, GSN_TCINDXREF, signal,
TcIndxRef::SignalLength, JBB);
TcKeyRef::SignalLength, JBB);
return;
}
case(IOS_INDEX_ACCESS): {
......@@ -11484,14 +11484,14 @@ void Dbtc::execTCKEYCONF(Signal* signal)
case(IOS_INDEX_ACCESS_WAIT_FOR_TRANSID_AI): {
jam();
// Double TCKEYCONF, should never happen, abort
TcIndxRef * const tcIndxRef = (TcIndxRef *)signal->getDataPtrSend();
TcKeyRef * const tcIndxRef = (TcKeyRef *)signal->getDataPtrSend();
tcIndxRef->connectPtr = indexOp->tcIndxReq.senderData;
tcIndxRef->transId[0] = regApiPtr->transid[0];
tcIndxRef->transId[1] = regApiPtr->transid[1];
tcIndxRef->errorCode = 4349;
sendSignal(regApiPtr->ndbapiBlockref, GSN_TCINDXREF, signal,
TcIndxRef::SignalLength, JBB);
TcKeyRef::SignalLength, JBB);
return;
}
case(IOS_INDEX_ACCESS_WAIT_FOR_TCKEYCONF): {
......@@ -11578,7 +11578,7 @@ void Dbtc::execTCKEYREF(Signal* signal)
jam();
TcKeyReq * const tcIndxReq = &indexOp->tcIndxReq;
TcIndxRef * const tcIndxRef = (TcIndxRef *)signal->getDataPtrSend();
TcKeyRef * const tcIndxRef = (TcKeyRef *)signal->getDataPtrSend();
ndbassert(regApiPtr->noIndexOp);
regApiPtr->noIndexOp--; // Decrease count
......@@ -11587,7 +11587,7 @@ void Dbtc::execTCKEYREF(Signal* signal)
tcIndxRef->transId[1] = tcKeyRef->transId[1];
tcIndxRef->errorCode = tcKeyRef->errorCode;
sendSignal(regApiPtr->ndbapiBlockref,
GSN_TCINDXREF, signal, TcIndxRef::SignalLength, JBB);
GSN_TCINDXREF, signal, TcKeyRef::SignalLength, JBB);
return;
}
}
......@@ -11654,14 +11654,14 @@ void Dbtc::execTRANSID_AI(Signal* signal)
signal->getLength() - TransIdAI::HeaderLength)) {
jam();
// Failed to allocate space for TransIdAI
TcIndxRef * const tcIndxRef = (TcIndxRef *)signal->getDataPtrSend();
TcKeyRef * const tcIndxRef = (TcKeyRef *)signal->getDataPtrSend();
tcIndxRef->connectPtr = indexOp->tcIndxReq.senderData;
tcIndxRef->transId[0] = regApiPtr->transid[0];
tcIndxRef->transId[1] = regApiPtr->transid[1];
tcIndxRef->errorCode = 4000;
sendSignal(regApiPtr->ndbapiBlockref, GSN_TCINDXREF, signal,
TcIndxRef::SignalLength, JBB);
TcKeyRef::SignalLength, JBB);
return;
}
......@@ -11669,14 +11669,14 @@ void Dbtc::execTRANSID_AI(Signal* signal)
case(IOS_NOOP): {
jam();
// Should never happen, abort
TcIndxRef * const tcIndxRef = (TcIndxRef *)signal->getDataPtrSend();
TcKeyRef * const tcIndxRef = (TcKeyRef *)signal->getDataPtrSend();
tcIndxRef->connectPtr = indexOp->tcIndxReq.senderData;
tcIndxRef->transId[0] = regApiPtr->transid[0];
tcIndxRef->transId[1] = regApiPtr->transid[1];
tcIndxRef->errorCode = 4349;
sendSignal(regApiPtr->ndbapiBlockref, GSN_TCINDXREF, signal,
TcIndxRef::SignalLength, JBB);
TcKeyRef::SignalLength, JBB);
return;
break;
}
......@@ -11697,14 +11697,14 @@ void Dbtc::execTRANSID_AI(Signal* signal)
#endif
/*
// Too many TRANSID_AI
TcIndxRef * const tcIndxRef = (TcIndxRef *)signal->getDataPtrSend();
TcKeyRef * const tcIndxRef = (TcKeyRef *)signal->getDataPtrSend();
tcIndexRef->connectPtr = indexOp->tcIndxReq.senderData;
tcIndxRef->transId[0] = regApiPtr->transid[0];
tcIndxRef->transId[1] = regApiPtr->transid[1];
tcIndxRef->errorCode = 4349;
sendSignal(regApiPtr->ndbapiBlockref, GSN_TCINDXREF, signal,
TcIndxRef::SignalLength, JBB);
TcKeyRef::SignalLength, JBB);
*/
break;
}
......@@ -11722,14 +11722,14 @@ void Dbtc::execTRANSID_AI(Signal* signal)
case(IOS_INDEX_OPERATION): {
// Should never receive TRANSID_AI in this state!!
jam();
TcIndxRef * const tcIndxRef = (TcIndxRef *)signal->getDataPtrSend();
TcKeyRef * const tcIndxRef = (TcKeyRef *)signal->getDataPtrSend();
tcIndxRef->connectPtr = indexOp->tcIndxReq.senderData;
tcIndxRef->transId[0] = regApiPtr->transid[0];
tcIndxRef->transId[1] = regApiPtr->transid[1];
tcIndxRef->errorCode = 4349;
sendSignal(regApiPtr->ndbapiBlockref, GSN_TCINDXREF, signal,
TcIndxRef::SignalLength, JBB);
TcKeyRef::SignalLength, JBB);
return;
}
}
......@@ -11775,14 +11775,14 @@ void Dbtc::readIndexTable(Signal* signal,
if ((indexData = c_theIndexes.getPtr(indexOp->tcIndxReq.tableId)) == NULL) {
jam();
// Failed to find index record
TcIndxRef * const tcIndxRef = (TcIndxRef *)signal->getDataPtrSend();
TcKeyRef * const tcIndxRef = (TcKeyRef *)signal->getDataPtrSend();
tcIndxRef->connectPtr = indexOp->tcIndxReq.senderData;
tcIndxRef->transId[0] = regApiPtr->transid[0];
tcIndxRef->transId[1] = regApiPtr->transid[1];
tcIndxRef->errorCode = 4000;
sendSignal(regApiPtr->ndbapiBlockref, GSN_TCINDXREF, signal,
TcIndxRef::SignalLength, JBB);
TcKeyRef::SignalLength, JBB);
return;
}
tcKeyReq->transId1 = transId1;
......@@ -11895,14 +11895,14 @@ void Dbtc::executeIndexOperation(Signal* signal,
if ((indexData = c_theIndexes.getPtr(tcIndxReq->tableId)) == NULL) {
jam();
// Failed to find index record
TcIndxRef * const tcIndxRef = (TcIndxRef *)signal->getDataPtrSend();
TcKeyRef * const tcIndxRef = (TcKeyRef *)signal->getDataPtrSend();
tcIndxRef->connectPtr = indexOp->tcIndxReq.senderData;
tcIndxRef->transId[0] = regApiPtr->transid[0];
tcIndxRef->transId[1] = regApiPtr->transid[1];
tcIndxRef->errorCode = 4349;
sendSignal(regApiPtr->ndbapiBlockref, GSN_TCINDXREF, signal,
TcIndxRef::SignalLength, JBB);
TcKeyRef::SignalLength, JBB);
return;
}
// Find schema version of primary table
......
......@@ -411,17 +411,5 @@ Remark: Handles the reception of the TCKEYREF signal.
int
NdbIndexOperation::receiveTCINDXREF( NdbApiSignal* aSignal)
{
const TcIndxRef * const tcIndxRef = CAST_CONSTPTR(TcIndxRef, aSignal->getDataPtr());
if (checkState_TransId(aSignal) == -1) {
return -1;
}//if
theStatus = Finished;
theNdbCon->theReturnStatus = NdbConnection::ReturnFailure;
Uint32 errorCode = tcIndxRef->errorCode;
theError.code = errorCode;
theNdbCon->setOperationErrorCodeAbort(errorCode);
return theNdbCon->OpCompleteFailure(theNdbCon->m_abortOption);
return NdbOperation::receiveTCKEYREF(aSignal);
}//NdbIndexOperation::receiveTCINDXREF()
......@@ -3306,7 +3306,7 @@ static int create_ndb_column(NDBCOL &col,
col.setPartSize(0);
col.setStripeSize(0);
break;
mysql_type_blob:
//mysql_type_blob:
case MYSQL_TYPE_BLOB:
if (field->flags & BINARY_FLAG)
col.setType(NDBCOL::Blob);
......@@ -4788,11 +4788,12 @@ ha_ndbcluster::read_multi_range_first(key_multi_range **found_range_p,
case ORDERED_INDEX:
range:
ranges[i].range_flag &= ~(uint)UNIQUE_RANGE;
if (sorted && scanOp != 0 && curr != buffer->buffer)
if (sorted && scanOp != 0)
{
/**
* We currently don't support batching of ordered range scans
*/
i--;
curr= (byte*)buffer->buffer_end;
break;
}
......@@ -4865,12 +4866,47 @@ ha_ndbcluster::read_multi_range_next(key_multi_range ** multi_range_found_p)
}
else if(m_active_cursor)
{
if(m_active_cursor->nextResult())
goto found;
int check;
bool contact_ndb= m_lock.type < TL_WRITE_ALLOW_WRITE;
do {
check= m_active_cursor->nextResult(contact_ndb, m_force_send);
if (check == 0)
goto found;
else if (check == 1 || check == 2)
{
// 1: No more records
// 2: No more cached records
/*
Before fetching more rows and releasing lock(s),
all pending update or delete operations should
be sent to NDB
*/
DBUG_PRINT("info", ("ops_pending: %d", m_ops_pending));
if (m_ops_pending)
{
// if (current_thd->transaction.on)
if (m_transaction_on)
{
if (execute_no_commit(this, m_active_trans) != 0)
DBUG_RETURN(ndb_err(m_active_trans));
}
else
{
if (execute_commit(this, m_active_trans) != 0)
DBUG_RETURN(ndb_err(m_active_trans));
int res= m_active_trans->restart();
DBUG_ASSERT(res == 0);
}
m_ops_pending= 0;
}
contact_ndb= (check == 2);
}
} while (check == 2);
multi_range_curr++;
m_multi_range_result_ptr += reclength;
m_active_cursor->close();
m_active_cursor= 0;
}
......@@ -4893,17 +4929,23 @@ ha_ndbcluster::read_multi_range_next(key_multi_range ** multi_range_found_p)
multi_range_sorted,
multi_range_buffer));
found_next:
multi_range_curr++;
op= m_active_trans->getNextCompletedOperation(op);
m_multi_range_result_ptr += reclength;
found:
* multi_range_found_p= multi_ranges + multi_range_curr;
memcpy(table->record[0], m_multi_range_result_ptr, reclength);
unpack_record(table->record[0]);
table->status= 0;
DBUG_RETURN(0);
found_next:
* multi_range_found_p= multi_ranges + multi_range_curr;
memcpy(table->record[0], m_multi_range_result_ptr, reclength);
unpack_record(table->record[0]);
table->status= 0;
multi_range_curr++;
op= m_active_trans->getNextCompletedOperation(op);
m_multi_range_result_ptr += reclength;
DBUG_RETURN(0);
}
#endif /* HAVE_NDBCLUSTER_DB */
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