~hartmut-php/mysql-server/cluster-7.2-showdbs

« back to all changes in this revision

Viewing changes to storage/ndb/src/ndbapi/NdbQueryBuilder.cpp

  • Committer: Jan Wedvik
  • Date: 2012-03-30 12:25:43 UTC
  • Revision ID: jan.wedvik@oracle.com-20120330122543-bks4vpvrvl80e2tc
This commit is a refactoring. NdbQueryBuilderImpl::m_id, NdbQueryBuilderImpl::m_ix are
renamed to m_opNo and m_internalOpNo. Associated methods are renamed in the same way.

Show diffs side-by-side

added added

removed removed

Lines of Context:
181
181
                           const NdbQueryOperand* const keys[],
182
182
                           const NdbQueryOptionsImpl& options,
183
183
                           const char* ident,
184
 
                           Uint32      ix,
185
 
                           Uint32      id,
 
184
                           Uint32      opNo,
 
185
                           Uint32      internalOpNo,
186
186
                           int& error);
187
187
 
188
188
  virtual const NdbQueryLookupOperationDef& getInterface() const
214
214
                           const NdbQueryOperand* const keys[],
215
215
                           const NdbQueryOptionsImpl& options,
216
216
                           const char* ident,
217
 
                           Uint32      ix,
218
 
                           Uint32      id,
 
217
                           Uint32      opNo,
 
218
                           Uint32      internalOpNo,
219
219
                           int& error)
220
 
    : NdbQueryLookupOperationDefImpl(table,keys,options,ident,ix,id,error)
 
220
    : NdbQueryLookupOperationDefImpl(table, keys, options, ident, opNo,
 
221
                                     internalOpNo, error)
221
222
  {}
222
223
 
223
224
  virtual NdbQueryOperationDef::Type getType() const
244
245
                           const NdbQueryOperand* const keys[],
245
246
                           const NdbQueryOptionsImpl& options,
246
247
                           const char* ident,
247
 
                           Uint32      ix,
248
 
                           Uint32      id,
 
248
                           Uint32      opNo,
 
249
                           Uint32      internalOpNo,
249
250
                           int& error)
250
251
    // Add 1 to 'id' since index lookup is serialized as two operations.
251
 
    : NdbQueryLookupOperationDefImpl(table,keys,options,ident,ix,id+1,error),
 
252
    : NdbQueryLookupOperationDefImpl(table, keys, options, ident, opNo,
 
253
                                     internalOpNo+1, error),
252
254
    m_index(index)
253
255
  {}
254
256
 
280
282
                           const NdbTableImpl& table,
281
283
                           const NdbQueryOptionsImpl& options,
282
284
                           const char* ident,
283
 
                           Uint32      ix,
284
 
                           Uint32      id,
 
285
                           Uint32      opNo,
 
286
                           Uint32      internalOpNo,
285
287
                           int& error)
286
 
    : NdbQueryScanOperationDefImpl(table,options,ident,ix,id,error),
 
288
    : NdbQueryScanOperationDefImpl(table, options, ident, opNo, 
 
289
                                   internalOpNo, error),
287
290
      m_interface(*this) 
288
291
  {}
289
292
 
626
629
 
627
630
 
628
631
Uint32
629
 
NdbQueryOperationDef::getQueryOperationIx() const
 
632
NdbQueryOperationDef::getOpNo() const
630
633
{
631
 
  return ::getImpl(*this).getQueryOperationIx();
 
634
  return ::getImpl(*this).getOpNo();
632
635
}
633
636
 
634
637
Uint32
884
887
                                       options ? options->getImpl() : defaultOptions,
885
888
                                       ident,
886
889
                                       m_impl.m_operations.size(),
887
 
                                       m_impl.getNextId(),
 
890
                                       m_impl.getNextInternalOpNo(),
888
891
                                       error);
889
892
 
890
893
  returnErrIf(m_impl.takeOwnership(op)!=0, Err_MemoryAlloc);
958
961
                                       options ? options->getImpl() : defaultOptions,
959
962
                                       ident,
960
963
                                       m_impl.m_operations.size(),
961
 
                                       m_impl.getNextId(),
 
964
                                       m_impl.getNextInternalOpNo(),
962
965
                                       error);
963
966
 
964
967
  returnErrIf(m_impl.takeOwnership(op)!=0, Err_MemoryAlloc);
999
1002
                                          options ? options->getImpl() : defaultOptions,
1000
1003
                                          ident,
1001
1004
                                          m_impl.m_operations.size(),
1002
 
                                          m_impl.getNextId(),
 
1005
                                          m_impl.getNextInternalOpNo(),
1003
1006
                                          error);
1004
1007
 
1005
1008
  returnErrIf(m_impl.takeOwnership(op)!=0, Err_MemoryAlloc);
1072
1075
                                          options ? options->getImpl() : defaultOptions,
1073
1076
                                          ident,
1074
1077
                                          m_impl.m_operations.size(),
1075
 
                                          m_impl.getNextId(),
 
1078
                                          m_impl.getNextInternalOpNo(),
1076
1079
                                          error);
1077
1080
 
1078
1081
  returnErrIf(m_impl.takeOwnership(op)!=0, Err_MemoryAlloc);
1271
1274
  // Set length and number of nodes in tree.
1272
1275
  Uint32 cntLen;
1273
1276
  QueryTree::setCntLen(cntLen, 
1274
 
                       m_operations[m_operations.size()-1]->getQueryOperationId()+1,
 
1277
                       m_operations[m_operations.size()-1]->getInternalOpNo()+1,
1275
1278
                       m_serializedDef.getSize());
1276
1279
  m_serializedDef.put(0,cntLen);
1277
1280
 
1636
1639
                           const NdbQueryOperand* const keys[],
1637
1640
                           const NdbQueryOptionsImpl& options,
1638
1641
                           const char* ident,
1639
 
                           Uint32      ix,
1640
 
                           Uint32      id,
 
1642
                           Uint32      opNo,
 
1643
                           Uint32      internalOpNo,
1641
1644
                           int& error)
1642
 
  : NdbQueryOperationDefImpl(table,options,ident,ix,id,error),
 
1645
  : NdbQueryOperationDefImpl(table, options, ident, opNo,
 
1646
                             internalOpNo, error),
1643
1647
   m_interface(*this)
1644
1648
{
1645
1649
  int i;
1659
1663
                           const NdbQueryIndexBound* bound,
1660
1664
                           const NdbQueryOptionsImpl& options,
1661
1665
                           const char* ident,
1662
 
                           Uint32      ix,
1663
 
                           Uint32      id,
 
1666
                           Uint32      opNo,
 
1667
                           Uint32      internalOpNo,
1664
1668
                           int& error)
1665
 
  : NdbQueryScanOperationDefImpl(table,options,ident,ix,id,error),
 
1669
  : NdbQueryScanOperationDefImpl(table, options, ident, opNo, internalOpNo, 
 
1670
                                 error),
1666
1671
  m_interface(*this), 
1667
1672
  m_index(index),
1668
1673
  m_paramInPruneKey(false)
1901
1906
                                     const NdbTableImpl& table,
1902
1907
                                     const NdbQueryOptionsImpl& options,
1903
1908
                                     const char* ident,
1904
 
                                     Uint32      ix,
1905
 
                                     Uint32      id,
 
1909
                                     Uint32      opNo,
 
1910
                                     Uint32      internalOpNo,
1906
1911
                                     int& error)
1907
1912
  :m_isPrepared(false), 
1908
1913
   m_diskInChildProjection(false), 
1909
1914
   m_table(table), 
1910
1915
   m_ident(ident), 
1911
 
   m_ix(ix), m_id(id),
 
1916
   m_opNo(opNo), m_internalOpNo(internalOpNo),
1912
1917
   m_options(options),
1913
1918
   m_parent(NULL), 
1914
1919
   m_children(), 
1921
1926
    error = Err_MemoryAlloc;
1922
1927
    return;
1923
1928
  }
1924
 
  if (unlikely(m_id >= NDB_SPJ_MAX_TREE_NODES))
 
1929
  if (unlikely(m_internalOpNo >= NDB_SPJ_MAX_TREE_NODES))
1925
1930
  {
1926
1931
    error = QRY_DEFINITION_TOO_LARGE;
1927
1932
    return;
2127
2132
  if (getParentOperation() != NULL)
2128
2133
  {
2129
2134
    Uint16Sequence parentSeq(serializedDef, 1);
2130
 
    assert (getParentOperation()->getQueryOperationId() < getQueryOperationId());
2131
 
    parentSeq.append(getParentOperation()->getQueryOperationId());
 
2135
    assert (getParentOperation()->getInternalOpNo() < getInternalOpNo());
 
2136
    parentSeq.append(getParentOperation()->getInternalOpNo());
2132
2137
    parentSeq.finish();
2133
2138
    return DABits::NI_HAS_PARENT;
2134
2139
  }
2212
2217
  ndbout << NdbQueryOperationDef::getTypeName(getType()) << endl;
2213
2218
  printMargin(depth, hasMoreSiblingsMask, false);
2214
2219
  // Print attributes.
2215
 
  ndbout << " opNo: " << getQueryOperationIx() << endl;
 
2220
  ndbout << " opNo: " << getOpNo() << endl;
2216
2221
  printMargin(depth, hasMoreSiblingsMask, false);
2217
2222
  ndbout << " table: " << getTable().getName() << endl;
2218
2223
  if (getIndex() != NULL)
2251
2256
   * Key value for root operation is constructed when query is instantiated with
2252
2257
   * NdbQueryOperationImpl::prepareIndexKeyInfo()
2253
2258
   */
2254
 
  if (getQueryOperationIx() == 0)
 
2259
  if (getOpNo() == 0)
2255
2260
    return 0;
2256
2261
 
2257
2262
  if (m_keys[0]!=NULL)
2328
2333
   * Bound value for root operation is constructed when query is instantiated with
2329
2334
   * NdbQueryOperationImpl::prepareIndexKeyInfo()
2330
2335
   */
2331
 
  if (getQueryOperationIx() == 0)
 
2336
  if (getOpNo() == 0)
2332
2337
    return 0;
2333
2338
 
2334
2339
  if (m_bound.lowKeys>0 || m_bound.highKeys>0)
2512
2517
   * Bound value for root operation is constructed when query is instantiated with
2513
2518
   * NdbQueryOperationImpl::prepareIndexKeyInfo()
2514
2519
   */
2515
 
  if (getQueryOperationIx() == 0)
 
2520
  if (getOpNo() == 0)
2516
2521
    return 0;
2517
2522
 
2518
2523
  if (m_bound.lowKeys>0 || m_bound.highKeys>0)
2621
2626
  }
2622
2627
 
2623
2628
#ifdef __TRACE_SERIALIZATION
2624
 
  ndbout << "Serialized node " << getQueryOperationId() << " : ";
 
2629
  ndbout << "Serialized node " << getInternalOpNo() << " : ";
2625
2630
  for (Uint32 i = startPos; i < serializedDef.getSize(); i++) {
2626
2631
    char buf[12];
2627
2632
    sprintf(buf, "%.8x", serializedDef.get(i));
2654
2659
    Uint32 requestInfo = QN_LookupNode::L_UNIQUE_INDEX;
2655
2660
 
2656
2661
    // Optional part1: Make list of parent nodes.
2657
 
    assert (getQueryOperationId() > 0);
 
2662
    assert (getInternalOpNo() > 0);
2658
2663
    requestInfo |= appendParentList (serializedDef);
2659
2664
 
2660
2665
    // Part2: m_keys[] are the keys to be used for index
2686
2691
    }
2687
2692
 
2688
2693
#ifdef __TRACE_SERIALIZATION
2689
 
    ndbout << "Serialized index " << getQueryOperationId()-1 << " : ";
 
2694
    ndbout << "Serialized index " << getInternalOpNo()-1 << " : ";
2690
2695
    for (Uint32 i = startPos; i < serializedDef.getSize(); i++){
2691
2696
      char buf[12];
2692
2697
      sprintf(buf, "%.8x", serializedDef.get(i));
2712
2717
  // Optional part1: Append index as (single) parent op..
2713
2718
  { requestInfo |= DABits::NI_HAS_PARENT;
2714
2719
    Uint16Sequence parentSeq(serializedDef,1);
2715
 
    parentSeq.append(getQueryOperationId()-1);
 
2720
    parentSeq.append(getInternalOpNo()-1);
2716
2721
    parentSeq.finish();
2717
2722
  }
2718
2723
 
2742
2747
  }
2743
2748
 
2744
2749
#ifdef __TRACE_SERIALIZATION
2745
 
  ndbout << "Serialized node " << getQueryOperationId() << " : ";
 
2750
  ndbout << "Serialized node " << getInternalOpNo() << " : ";
2746
2751
  for (Uint32 i = startPos; i < serializedDef.getSize(); i++) {
2747
2752
    char buf[12];
2748
2753
    sprintf(buf, "%.8x", serializedDef.get(i));
2759
2764
                           const NdbTableImpl& table,
2760
2765
                           const NdbQueryOptionsImpl& options,
2761
2766
                           const char* ident,
2762
 
                           Uint32      ix,
2763
 
                           Uint32      id,
 
2767
                           Uint32      opNo,
 
2768
                           Uint32      internalOpNo,
2764
2769
                           int& error)
2765
 
  : NdbQueryOperationDefImpl(table,options,ident,ix,id,error)
 
2770
  : NdbQueryOperationDefImpl(table, options, ident, opNo, internalOpNo, error)
2766
2771
{}
2767
2772
 
2768
2773
int
2769
2774
NdbQueryScanOperationDefImpl::serialize(Uint32Buffer& serializedDef,
2770
2775
                                        const NdbTableImpl& tableOrIndex)
2771
2776
{
2772
 
  bool isRoot = (getQueryOperationIx()==0);
 
2777
  bool isRoot = (getOpNo()==0);
2773
2778
 
2774
2779
  // This method should only be invoked once.
2775
2780
  assert (!m_isPrepared);
2824
2829
  }
2825
2830
 
2826
2831
#ifdef __TRACE_SERIALIZATION
2827
 
  ndbout << "Serialized node " << getQueryOperationId() << " : ";
 
2832
  ndbout << "Serialized node " << getInternalOpNo() << " : ";
2828
2833
  for(Uint32 i = startPos; i < serializedDef.getSize(); i++){
2829
2834
    char buf[12];
2830
2835
    sprintf(buf, "%.8x", serializedDef.get(i));