@@ -181,6 +181,7 @@ class NdbQueryLookupOperationDefImpl : public NdbQueryOperationDefImpl
181
181
const NdbQueryOptionsImpl& options,
182
182
const char * ident,
183
183
Uint32 ix,
184
+ Uint32 id,
184
185
int & error);
185
186
186
187
virtual const NdbQueryLookupOperationDef& getInterface () const
@@ -213,8 +214,9 @@ class NdbQueryPKLookupOperationDefImpl : public NdbQueryLookupOperationDefImpl
213
214
const NdbQueryOptionsImpl& options,
214
215
const char * ident,
215
216
Uint32 ix,
217
+ Uint32 id,
216
218
int & error)
217
- : NdbQueryLookupOperationDefImpl(table,keys,options,ident,ix,error)
219
+ : NdbQueryLookupOperationDefImpl(table,keys,options,ident,ix,id, error)
218
220
{}
219
221
220
222
virtual NdbQueryOperationDef::Type getType () const
@@ -242,8 +244,10 @@ class NdbQueryIndexOperationDefImpl : public NdbQueryLookupOperationDefImpl
242
244
const NdbQueryOptionsImpl& options,
243
245
const char * ident,
244
246
Uint32 ix,
247
+ Uint32 id,
245
248
int & error)
246
- : NdbQueryLookupOperationDefImpl(table,keys,options,ident,ix,error),
249
+ // Add 1 to 'id' since index lookup is serialized as two operations.
250
+ : NdbQueryLookupOperationDefImpl(table,keys,options,ident,ix,id+1 ,error),
247
251
m_index(index)
248
252
{}
249
253
@@ -276,8 +280,9 @@ class NdbQueryTableScanOperationDefImpl : public NdbQueryScanOperationDefImpl
276
280
const NdbQueryOptionsImpl& options,
277
281
const char * ident,
278
282
Uint32 ix,
283
+ Uint32 id,
279
284
int & error)
280
- : NdbQueryScanOperationDefImpl(table,options,ident,ix,error),
285
+ : NdbQueryScanOperationDefImpl(table,options,ident,ix,id, error),
281
286
m_interface(*this )
282
287
{}
283
288
@@ -859,6 +864,7 @@ NdbQueryBuilder::readTuple(const NdbDictionary::Table* table, // Primary key
859
864
options ? options->getImpl () : defaultOptions,
860
865
ident,
861
866
m_impl.m_operations .size (),
867
+ m_impl.getNextId (),
862
868
error);
863
869
864
870
returnErrIf (m_impl.takeOwnership (op)!=0 , Err_MemoryAlloc);
@@ -928,6 +934,7 @@ NdbQueryBuilder::readTuple(const NdbDictionary::Index* index, // Unique key l
928
934
options ? options->getImpl () : defaultOptions,
929
935
ident,
930
936
m_impl.m_operations .size (),
937
+ m_impl.getNextId (),
931
938
error);
932
939
933
940
returnErrIf (m_impl.takeOwnership (op)!=0 , Err_MemoryAlloc);
@@ -962,6 +969,7 @@ NdbQueryBuilder::scanTable(const NdbDictionary::Table* table,
962
969
options ? options->getImpl () : defaultOptions,
963
970
ident,
964
971
m_impl.m_operations .size (),
972
+ m_impl.getNextId (),
965
973
error);
966
974
967
975
returnErrIf (m_impl.takeOwnership (op)!=0 , Err_MemoryAlloc);
@@ -1004,6 +1012,7 @@ NdbQueryBuilder::scanIndex(const NdbDictionary::Index* index,
1004
1012
options ? options->getImpl () : defaultOptions,
1005
1013
ident,
1006
1014
m_impl.m_operations .size (),
1015
+ m_impl.getNextId (),
1007
1016
error);
1008
1017
1009
1018
returnErrIf (m_impl.takeOwnership (op)!=0 , Err_MemoryAlloc);
@@ -1194,26 +1203,22 @@ NdbQueryDefImpl(const Vector<NdbQueryOperationDefImpl*>& operations,
1194
1203
return ;
1195
1204
}
1196
1205
1197
- Uint32 nodeId = 0 ;
1198
-
1199
1206
/* Grab first word, such that serialization of operation 0 will start from
1200
1207
* offset 1, leaving space for the length field to be updated later
1201
1208
*/
1202
1209
m_serializedDef.append (0 );
1203
1210
for (Uint32 i = 0 ; i<m_operations.size (); i++){
1204
1211
NdbQueryOperationDefImpl* op = m_operations[i];
1205
- op->assignQueryOperationId (nodeId);
1206
1212
error = op->serializeOperation (m_serializedDef);
1207
1213
if (unlikely (error != 0 )){
1208
1214
return ;
1209
1215
}
1210
1216
}
1211
- assert (nodeId >= m_operations.size ());
1212
1217
1213
1218
// Set length and number of nodes in tree.
1214
1219
Uint32 cntLen;
1215
1220
QueryTree::setCntLen (cntLen,
1216
- nodeId ,
1221
+ m_operations[m_operations. size ()- 1 ]-> getQueryOperationId ()+ 1 ,
1217
1222
m_serializedDef.getSize ());
1218
1223
m_serializedDef.put (0 ,cntLen);
1219
1224
@@ -1579,8 +1584,9 @@ NdbQueryLookupOperationDefImpl::NdbQueryLookupOperationDefImpl (
1579
1584
const NdbQueryOptionsImpl& options,
1580
1585
const char * ident,
1581
1586
Uint32 ix,
1587
+ Uint32 id,
1582
1588
int & error)
1583
- : NdbQueryOperationDefImpl(table,options,ident,ix,error),
1589
+ : NdbQueryOperationDefImpl(table,options,ident,ix,id, error),
1584
1590
m_interface(*this )
1585
1591
{
1586
1592
int i;
@@ -1601,8 +1607,9 @@ NdbQueryIndexScanOperationDefImpl::NdbQueryIndexScanOperationDefImpl (
1601
1607
const NdbQueryOptionsImpl& options,
1602
1608
const char * ident,
1603
1609
Uint32 ix,
1610
+ Uint32 id,
1604
1611
int & error)
1605
- : NdbQueryScanOperationDefImpl(table,options,ident,ix,error),
1612
+ : NdbQueryScanOperationDefImpl(table,options,ident,ix,id, error),
1606
1613
m_interface(*this ),
1607
1614
m_index(index)
1608
1615
{
@@ -1841,12 +1848,13 @@ NdbQueryOperationDefImpl::NdbQueryOperationDefImpl (
1841
1848
const NdbQueryOptionsImpl& options,
1842
1849
const char * ident,
1843
1850
Uint32 ix,
1851
+ Uint32 id,
1844
1852
int & error)
1845
1853
:m_isPrepared(false ),
1846
1854
m_diskInChildProjection(false ),
1847
1855
m_table(table),
1848
1856
m_ident(ident),
1849
- m_ix(ix), m_id(ix ),
1857
+ m_ix(ix), m_id(id ),
1850
1858
m_options(options),
1851
1859
m_parent(NULL ),
1852
1860
m_children(),
@@ -1859,6 +1867,11 @@ NdbQueryOperationDefImpl::NdbQueryOperationDefImpl (
1859
1867
error = Err_MemoryAlloc;
1860
1868
return ;
1861
1869
}
1870
+ if (unlikely (m_id >= NDB_SPJ_MAX_TREE_NODES))
1871
+ {
1872
+ error = QRY_DEFINITION_TOO_LARGE;
1873
+ return ;
1874
+ }
1862
1875
if (m_options.m_parent != NULL )
1863
1876
{
1864
1877
m_parent = m_options.m_parent ;
@@ -2690,8 +2703,9 @@ NdbQueryScanOperationDefImpl::NdbQueryScanOperationDefImpl (
2690
2703
const NdbQueryOptionsImpl& options,
2691
2704
const char * ident,
2692
2705
Uint32 ix,
2706
+ Uint32 id,
2693
2707
int & error)
2694
- : NdbQueryOperationDefImpl(table,options,ident,ix,error)
2708
+ : NdbQueryOperationDefImpl(table,options,ident,ix,id, error)
2695
2709
{}
2696
2710
2697
2711
int
0 commit comments