~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to sql/opt_range.cc

  • Committer: brian
  • Date: 2008-07-03 13:40:21 UTC
  • Revision ID: brian@localhost.localdomain-20080703134021-7p4ab3xpjpmbcebi
Update for using real bool types.

Show diffs side-by-side

added added

removed removed

Lines of Context:
568
568
      "keypart IS NULL".
569
569
 
570
570
    RETURN
571
 
      TRUE   This SEL_ARG object represents a singlepoint interval
572
 
      FALSE  Otherwise
 
571
      true   This SEL_ARG object represents a singlepoint interval
 
572
      false  Otherwise
573
573
  */
574
574
 
575
575
  bool is_singlepoint()
579
579
      flags, and the same for right edge.
580
580
    */
581
581
    if (min_flag || max_flag)
582
 
      return FALSE;
 
582
      return false;
583
583
    uchar *min_val= min_value;
584
584
    uchar *max_val= max_value;
585
585
 
587
587
    {
588
588
      /* First byte is a NULL value indicator */
589
589
      if (*min_val != *max_val)
590
 
        return FALSE;
 
590
        return false;
591
591
 
592
592
      if (*min_val)
593
 
        return TRUE; /* This "x IS NULL" */
 
593
        return true; /* This "x IS NULL" */
594
594
      min_val++;
595
595
      max_val++;
596
596
    }
673
673
  
674
674
  /*
675
675
    used_key_no -> table_key_no translation table. Only makes sense if
676
 
    using_real_indexes==TRUE
 
676
    using_real_indexes==true
677
677
  */
678
678
  uint real_keynr[MAX_KEY];
679
679
  /* Number of SEL_ARG objects allocated by SEL_ARG::clone_tree operations */
702
702
  uint *imerge_cost_buff;     /* buffer for index_merge cost estimates */
703
703
  uint imerge_cost_buff_size; /* size of the buffer */
704
704
 
705
 
  /* TRUE if last checked tree->key can be used for ROR-scan */
 
705
  /* true if last checked tree->key can be used for ROR-scan */
706
706
  bool is_ror_scan;
707
707
  /* Number of ranges in the last checked tree->key */
708
708
  uint n_ranges;
911
911
 
912
912
  RETURN
913
913
    0 - OK
914
 
    1 - One of conditions in result is always TRUE and this SEL_IMERGE
 
914
    1 - One of conditions in result is always true and this SEL_IMERGE
915
915
        should be discarded.
916
916
   -1 - An error occurred
917
917
*/
950
950
    i.e. all conjuncts except the first one are currently dropped.
951
951
    This is done to avoid producing N*K ways to do index_merge.
952
952
 
953
 
    If (a_1||b_1) produce a condition that is always TRUE, NULL is returned
 
953
    If (a_1||b_1) produce a condition that is always true, NULL is returned
954
954
    and index_merge is discarded (while it is actually possible to try
955
955
    harder).
956
956
 
1114
1114
    *create_error= 1;
1115
1115
  }
1116
1116
  else
1117
 
    bitmap_init(&column_bitmap, bitmap, head->s->fields, FALSE);
 
1117
    bitmap_init(&column_bitmap, bitmap, head->s->fields, false);
1118
1118
  DBUG_VOID_RETURN;
1119
1119
}
1120
1120
 
1228
1228
                                                       bool retrieve_full_rows,
1229
1229
                                                       MEM_ROOT *parent_alloc)
1230
1230
  : cpk_quick(NULL), thd(thd_param), need_to_fetch_row(retrieve_full_rows),
1231
 
    scans_inited(FALSE)
 
1231
    scans_inited(false)
1232
1232
{
1233
1233
  index= MAX_KEY;
1234
1234
  head= table;
1265
1265
 
1266
1266
  SYNOPSIS
1267
1267
    QUICK_RANGE_SELECT::init_ror_merged_scan()
1268
 
      reuse_handler If TRUE, use head->file, otherwise create a separate
 
1268
      reuse_handler If true, use head->file, otherwise create a separate
1269
1269
                    handler object
1270
1270
 
1271
1271
  NOTES
1333
1333
    file->close();
1334
1334
    goto failure;
1335
1335
  }
1336
 
  free_file= TRUE;
 
1336
  free_file= true;
1337
1337
  last_rowid= file->ref;
1338
1338
 
1339
1339
end:
1370
1370
  Initialize this quick select to be a part of a ROR-merged scan.
1371
1371
  SYNOPSIS
1372
1372
    QUICK_ROR_INTERSECT_SELECT::init_ror_merged_scan()
1373
 
      reuse_handler If TRUE, use head->file, otherwise create separate
 
1373
      reuse_handler If true, use head->file, otherwise create separate
1374
1374
                    handler object.
1375
1375
  RETURN
1376
1376
    0     OK
1391
1391
      There is no use of this->file. Use it for the first of merged range
1392
1392
      selects.
1393
1393
    */
1394
 
    if (quick->init_ror_merged_scan(TRUE))
 
1394
    if (quick->init_ror_merged_scan(true))
1395
1395
      DBUG_RETURN(1);
1396
1396
    quick->file->extra(HA_EXTRA_KEYREAD_PRESERVE_FIELDS);
1397
1397
  }
1398
1398
  while ((quick= quick_it++))
1399
1399
  {
1400
 
    if (quick->init_ror_merged_scan(FALSE))
 
1400
    if (quick->init_ror_merged_scan(false))
1401
1401
      DBUG_RETURN(1);
1402
1402
    quick->file->extra(HA_EXTRA_KEYREAD_PRESERVE_FIELDS);
1403
1403
    /* All merged scans share the same record buffer in intersection. */
1425
1425
int QUICK_ROR_INTERSECT_SELECT::reset()
1426
1426
{
1427
1427
  DBUG_ENTER("QUICK_ROR_INTERSECT_SELECT::reset");
1428
 
  if (!scans_inited && init_ror_merged_scan(TRUE))
 
1428
  if (!scans_inited && init_ror_merged_scan(true))
1429
1429
    DBUG_RETURN(1);
1430
 
  scans_inited= TRUE;
 
1430
  scans_inited= true;
1431
1431
  List_iterator_fast<QUICK_RANGE_SELECT> it(quick_selects);
1432
1432
  QUICK_RANGE_SELECT *quick;
1433
1433
  while ((quick= it++))
1447
1447
    This call can only be made before init() is called.
1448
1448
 
1449
1449
  RETURN
1450
 
    FALSE OK
1451
 
    TRUE  Out of memory.
 
1450
    false OK
 
1451
    true  Out of memory.
1452
1452
*/
1453
1453
 
1454
1454
bool
1471
1471
 
1472
1472
QUICK_ROR_UNION_SELECT::QUICK_ROR_UNION_SELECT(THD *thd_param,
1473
1473
                                               TABLE *table)
1474
 
  : thd(thd_param), scans_inited(FALSE)
 
1474
  : thd(thd_param), scans_inited(false)
1475
1475
{
1476
1476
  index= MAX_KEY;
1477
1477
  head= table;
1496
1496
{
1497
1497
  DBUG_ENTER("QUICK_ROR_UNION_SELECT::init");
1498
1498
  if (init_queue(&queue, quick_selects.elements, 0,
1499
 
                 FALSE , QUICK_ROR_UNION_SELECT::queue_cmp,
 
1499
                 false , QUICK_ROR_UNION_SELECT::queue_cmp,
1500
1500
                 (void*) this))
1501
1501
  {
1502
1502
    bzero(&queue, sizeof(QUEUE));
1544
1544
  QUICK_SELECT_I *quick;
1545
1545
  int error;
1546
1546
  DBUG_ENTER("QUICK_ROR_UNION_SELECT::reset");
1547
 
  have_prev_rowid= FALSE;
 
1547
  have_prev_rowid= false;
1548
1548
  if (!scans_inited)
1549
1549
  {
1550
1550
    List_iterator_fast<QUICK_SELECT_I> it(quick_selects);
1551
1551
    while ((quick= it++))
1552
1552
    {
1553
 
      if (quick->init_ror_merged_scan(FALSE))
 
1553
      if (quick->init_ror_merged_scan(false))
1554
1554
        DBUG_RETURN(1);
1555
1555
    }
1556
 
    scans_inited= TRUE;
 
1556
    scans_inited= true;
1557
1557
  }
1558
1558
  queue_remove_all(&queue);
1559
1559
  /*
1885
1885
  ha_rows records; /* estimate of #rows to be examined */
1886
1886
 
1887
1887
  /*
1888
 
    If TRUE, the scan returns rows in rowid order. This is used only for
 
1888
    If true, the scan returns rows in rowid order. This is used only for
1889
1889
    scans that can be both ROR and non-ROR.
1890
1890
  */
1891
1891
  bool is_ror;
1895
1895
    SYNOPSIS
1896
1896
     make_quick()
1897
1897
       param               Parameter from test_quick_select
1898
 
       retrieve_full_rows  If TRUE, created quick select will do full record
 
1898
       retrieve_full_rows  If true, created quick select will do full record
1899
1899
                           retrieval.
1900
1900
       parent_alloc        Memory pool to use, if any.
1901
1901
 
1974
1974
  struct st_ror_scan_info **first_scan;
1975
1975
  struct st_ror_scan_info **last_scan; /* End of the above array */
1976
1976
  struct st_ror_scan_info *cpk_scan;  /* Clustered PK scan, if there is one */
1977
 
  bool is_covering; /* TRUE if no row retrieval phase is necessary */
 
1977
  bool is_covering; /* true if no row retrieval phase is necessary */
1978
1978
  double index_scan_costs; /* SUM(cost(index_scan)) */
1979
1979
};
1980
1980
 
2087
2087
  param->fields_bitmap_size= table->s->column_bitmap_size;
2088
2088
  if (!(tmp= (my_bitmap_map*) alloc_root(param->mem_root,
2089
2089
                                  param->fields_bitmap_size)) ||
2090
 
      bitmap_init(&param->needed_fields, tmp, table->s->fields, FALSE))
 
2090
      bitmap_init(&param->needed_fields, tmp, table->s->fields, false))
2091
2091
    return 1;
2092
2092
 
2093
2093
  bitmap_copy(&param->needed_fields, table->read_set);
2229
2229
    param.old_root= thd->mem_root;
2230
2230
    param.needed_reg= &needed_reg;
2231
2231
    param.imerge_cost_buff_size= 0;
2232
 
    param.using_real_indexes= TRUE;
2233
 
    param.remove_jump_scans= TRUE;
 
2232
    param.using_real_indexes= true;
 
2233
    param.remove_jump_scans= true;
2234
2234
    param.force_default_mrr= ordered_output;
2235
2235
 
2236
2236
    thd->no_errors=1;                           // Don't warn about NULL
2341
2341
      {
2342
2342
        TRP_RANGE         *range_trp;
2343
2343
        TRP_ROR_INTERSECT *rori_trp;
2344
 
        bool can_build_covering= FALSE;
 
2344
        bool can_build_covering= false;
2345
2345
 
2346
2346
        /* Get best 'range' plan and prepare data for making other plans */
2347
 
        if ((range_trp= get_key_scans_params(&param, tree, FALSE, TRUE,
 
2347
        if ((range_trp= get_key_scans_params(&param, tree, false, true,
2348
2348
                                             best_read_time)))
2349
2349
        {
2350
2350
          best_trp= range_trp;
2407
2407
    if (best_trp)
2408
2408
    {
2409
2409
      records= best_trp->records;
2410
 
      if (!(quick= best_trp->make_quick(&param, TRUE)) || quick->init())
 
2410
      if (!(quick= best_trp->make_quick(&param, true)) || quick->init())
2411
2411
      {
2412
2412
        delete quick;
2413
2413
        quick= NULL;
2504
2504
  TRP_RANGE **range_scans;
2505
2505
  TRP_RANGE **cur_child;
2506
2506
  TRP_RANGE **cpk_scan= NULL;
2507
 
  bool imerge_too_expensive= FALSE;
 
2507
  bool imerge_too_expensive= false;
2508
2508
  double imerge_cost= 0.0;
2509
2509
  ha_rows cpk_scan_records= 0;
2510
2510
  ha_rows non_cpk_scan_records= 0;
2511
2511
  bool pk_is_clustered= param->table->file->primary_key_is_clustered();
2512
 
  bool all_scans_ror_able= TRUE;
2513
 
  bool all_scans_rors= TRUE;
 
2512
  bool all_scans_ror_able= true;
 
2513
  bool all_scans_rors= true;
2514
2514
  uint unique_calc_buff_size;
2515
2515
  TABLE_READ_PLAN **roru_read_plans;
2516
2516
  TABLE_READ_PLAN **cur_roru_plan;
2535
2535
  {
2536
2536
    DBUG_EXECUTE("info", print_sel_tree(param, *ptree, &(*ptree)->keys_map,
2537
2537
                                        "tree in SEL_IMERGE"););
2538
 
    if (!(*cur_child= get_key_scans_params(param, *ptree, TRUE, FALSE, read_time)))
 
2538
    if (!(*cur_child= get_key_scans_params(param, *ptree, true, false, read_time)))
2539
2539
    {
2540
2540
      /*
2541
2541
        One of index scans in this index_merge is more expensive than entire
2543
2543
        any possible ROR-union) will be more expensive then, too. We continue
2544
2544
        here only to update SQL_SELECT members.
2545
2545
      */
2546
 
      imerge_too_expensive= TRUE;
 
2546
      imerge_too_expensive= true;
2547
2547
    }
2548
2548
    if (imerge_too_expensive)
2549
2549
      continue;
2802
2802
    DBUG_RETURN(NULL);
2803
2803
 
2804
2804
  if (bitmap_init(&ror_scan->covered_fields, bitmap_buf,
2805
 
                  param->table->s->fields, FALSE))
 
2805
                  param->table->s->fields, false))
2806
2806
    DBUG_RETURN(NULL);
2807
2807
  bitmap_clear_all(&ror_scan->covered_fields);
2808
2808
 
2887
2887
    non-index_only index intersection will be employed.
2888
2888
  */
2889
2889
  double out_rows;
2890
 
  /* TRUE if covered_fields is a superset of needed_fields */
 
2890
  /* true if covered_fields is a superset of needed_fields */
2891
2891
  bool is_covering;
2892
2892
 
2893
2893
  ha_rows index_records; /* sum(#records to look in indexes) */
2921
2921
                                         param->fields_bitmap_size)))
2922
2922
    return NULL;
2923
2923
  if (bitmap_init(&info->covered_fields, buf, param->table->s->fields,
2924
 
                  FALSE))
 
2924
                  false))
2925
2925
    return NULL;
2926
 
  info->is_covering= FALSE;
 
2926
  info->is_covering= false;
2927
2927
  info->index_scan_costs= 0.0;
2928
2928
  info->index_records= 0;
2929
2929
  info->out_rows= (double) param->table->file->stats.records;
3121
3121
      param        Parameter from test_quick_select
3122
3122
      info         ROR-intersection structure to add the scan to.
3123
3123
      ror_scan     ROR scan info to add.
3124
 
      is_cpk_scan  If TRUE, add the scan as CPK scan (this can be inferred
 
3124
      is_cpk_scan  If true, add the scan as CPK scan (this can be inferred
3125
3125
                   from other parameters and is passed separately only to
3126
3126
                   avoid duplicating the inference code)
3127
3127
 
3143
3143
                           ror_scan_selectivity({scan1}, scan2) * ... *
3144
3144
                           ror_scan_selectivity({scan1,...}, scanN). 
3145
3145
  RETURN
3146
 
    TRUE   ROR scan added to ROR-intersection, cost updated.
3147
 
    FALSE  It doesn't make sense to add this ROR scan to this ROR-intersection.
 
3146
    true   ROR scan added to ROR-intersection, cost updated.
 
3147
    false  It doesn't make sense to add this ROR scan to this ROR-intersection.
3148
3148
*/
3149
3149
 
3150
3150
static bool ror_intersect_add(ROR_INTERSECT_INFO *info,
3163
3163
  {
3164
3164
    /* Don't add this scan if it doesn't improve selectivity. */
3165
3165
    DBUG_PRINT("info", ("The scan doesn't improve selectivity."));
3166
 
    DBUG_RETURN(FALSE);
 
3166
    DBUG_RETURN(false);
3167
3167
  }
3168
3168
  
3169
3169
  info->out_rows *= selectivity_mult;
3187
3187
                                               &info->covered_fields))
3188
3188
    {
3189
3189
      DBUG_PRINT("info", ("ROR-intersect is covering now"));
3190
 
      info->is_covering= TRUE;
 
3190
      info->is_covering= true;
3191
3191
    }
3192
3192
  }
3193
3193
 
3206
3206
  DBUG_PRINT("info", ("New out_rows: %g", info->out_rows));
3207
3207
  DBUG_PRINT("info", ("New cost: %g, %scovering", info->total_cost,
3208
3208
                      info->is_covering?"" : "non-"));
3209
 
  DBUG_RETURN(TRUE);
 
3209
  DBUG_RETURN(true);
3210
3210
}
3211
3211
 
3212
3212
 
3220
3220
      tree             Transformed restriction condition to be used to look
3221
3221
                       for ROR scans.
3222
3222
      read_time        Do not return read plans with cost > read_time.
3223
 
      are_all_covering [out] set to TRUE if union of all scans covers all
 
3223
      are_all_covering [out] set to true if union of all scans covers all
3224
3224
                       fields needed by the query (and it is possible to build
3225
3225
                       a covering ROR-intersection)
3226
3226
 
3293
3293
  ROR_SCAN_INFO **cur_ror_scan;
3294
3294
  ROR_SCAN_INFO *cpk_scan= NULL;
3295
3295
  uint cpk_no;
3296
 
  bool cpk_scan_used= FALSE;
 
3296
  bool cpk_scan_used= false;
3297
3297
 
3298
3298
  if (!(tree->ror_scans= (ROR_SCAN_INFO**)alloc_root(param->mem_root,
3299
3299
                                                     sizeof(ROR_SCAN_INFO*)*
3354
3354
  while (cur_ror_scan != tree->ror_scans_end && !intersect->is_covering)
3355
3355
  {
3356
3356
    /* S= S + first(R);  R= R - first(R); */
3357
 
    if (!ror_intersect_add(intersect, *cur_ror_scan, FALSE))
 
3357
    if (!ror_intersect_add(intersect, *cur_ror_scan, false))
3358
3358
    {
3359
3359
      cur_ror_scan++;
3360
3360
      continue;
3393
3393
  */
3394
3394
  if (cpk_scan && !intersect->is_covering)
3395
3395
  {
3396
 
    if (ror_intersect_add(intersect, cpk_scan, TRUE) && 
 
3396
    if (ror_intersect_add(intersect, cpk_scan, true) && 
3397
3397
        (intersect->total_cost < min_cost))
3398
3398
    {
3399
 
      cpk_scan_used= TRUE;
 
3399
      cpk_scan_used= true;
3400
3400
      intersect_best= intersect; //just set pointer here
3401
3401
    }
3402
3402
  }
3491
3491
                                               param->fields_bitmap_size);
3492
3492
  if (!covered_fields->bitmap ||
3493
3493
      bitmap_init(covered_fields, covered_fields->bitmap,
3494
 
                  param->table->s->fields, FALSE))
 
3494
                  param->table->s->fields, false))
3495
3495
    DBUG_RETURN(0);
3496
3496
  bitmap_clear_all(covered_fields);
3497
3497
 
3570
3570
    DBUG_RETURN(NULL);
3571
3571
  memcpy(trp->first_scan, tree->ror_scans, best_num*sizeof(ROR_SCAN_INFO*));
3572
3572
  trp->last_scan=  trp->first_scan + best_num;
3573
 
  trp->is_covering= TRUE;
 
3573
  trp->is_covering= true;
3574
3574
  trp->read_cost= total_cost;
3575
3575
  trp->records= records;
3576
3576
  trp->cpk_scan= NULL;
3590
3590
    get_key_scans_params()
3591
3591
      param                    Parameters from test_quick_select
3592
3592
      tree                     Make range select for this SEL_TREE
3593
 
      index_read_must_be_used  TRUE <=> assume 'index only' option will be set
 
3593
      index_read_must_be_used  true <=> assume 'index only' option will be set
3594
3594
                               (except for clustered PK indexes)
3595
 
      update_tbl_stats         TRUE <=> update table->quick_* with information
 
3595
      update_tbl_stats         true <=> update table->quick_* with information
3596
3596
                               about range scans we've evaluated.
3597
3597
      read_time                Maximum cost. i.e. don't create read plans with 
3598
3598
                               cost > read_time.
3601
3601
    Find the best "range" table read plan for given SEL_TREE. 
3602
3602
    The side effects are 
3603
3603
     - tree->ror_scans is updated to indicate which scans are ROR scans.
3604
 
     - if update_tbl_stats=TRUE then table->quick_* is updated with info
 
3604
     - if update_tbl_stats=true then table->quick_* is updated with info
3605
3605
       about every possible range scan.
3606
3606
 
3607
3607
  RETURN
3706
3706
       range_scan++)
3707
3707
  {
3708
3708
    if (!(quick= (QUICK_RANGE_SELECT*)
3709
 
          ((*range_scan)->make_quick(param, FALSE, &quick_imerge->alloc)))||
 
3709
          ((*range_scan)->make_quick(param, false, &quick_imerge->alloc)))||
3710
3710
        quick_imerge->push_quick_back(quick))
3711
3711
    {
3712
3712
      delete quick;
3729
3729
  if ((quick_intrsect=
3730
3730
         new QUICK_ROR_INTERSECT_SELECT(param->thd, param->table,
3731
3731
                                        (retrieve_full_rows? (!is_covering) :
3732
 
                                         FALSE),
 
3732
                                         false),
3733
3733
                                        parent_alloc)))
3734
3734
  {
3735
3735
    DBUG_EXECUTE("info", print_ror_scans_arr(param->table,
3784
3784
  {
3785
3785
    for (scan= first_ror; scan != last_ror; scan++)
3786
3786
    {
3787
 
      if (!(quick= (*scan)->make_quick(param, FALSE, &quick_roru->alloc)) ||
 
3787
      if (!(quick= (*scan)->make_quick(param, false, &quick_roru->alloc)) ||
3788
3788
          quick_roru->push_quick_back(quick))
3789
3789
        DBUG_RETURN(NULL);
3790
3790
    }
3840
3840
      field       field in the predicate
3841
3841
      value       constant in the predicate
3842
3842
      cmp_type    compare type for the field
3843
 
      inv         TRUE <> NOT cond_func is considered
 
3843
      inv         true <> NOT cond_func is considered
3844
3844
                  (makes sense only when cond_func is BETWEEN or IN) 
3845
3845
 
3846
3846
  RETURN 
4082
4082
      value       constant in the predicate
4083
4083
                  (for BETWEEN it contains the number of the field argument,
4084
4084
                   for IN it's always 0) 
4085
 
      inv         TRUE <> NOT cond_func is considered
 
4085
      inv         true <> NOT cond_func is considered
4086
4086
                  (makes sense only when cond_func is BETWEEN or IN)
4087
4087
 
4088
4088
  DESCRIPTION
4128
4128
    In the cases when one of the items f1, f2 is a constant c1 we do not create
4129
4129
    a tree for it at all. It works for BETWEEN predicates but does not
4130
4130
    work for NOT BETWEEN predicates as we have to evaluate the expression
4131
 
    with it. If it is TRUE then the other tree can be completely ignored.
 
4131
    with it. If it is true then the other tree can be completely ignored.
4132
4132
    We do not do it now and no trees are built in these cases for
4133
4133
    NOT BETWEEN predicates.
4134
4134
 
4190
4190
  SEL_TREE *tree=0;
4191
4191
  SEL_TREE *ftree= 0;
4192
4192
  Item_field *field_item= 0;
4193
 
  bool inv= FALSE;
 
4193
  bool inv= false;
4194
4194
  Item *value= 0;
4195
4195
  DBUG_ENTER("get_mm_tree");
4196
4196
 
4470
4470
    optimize_range= field->optimize_range(param->real_keynr[key_part->key],
4471
4471
                                          key_part->part);
4472
4472
  else
4473
 
    optimize_range= TRUE;
 
4473
    optimize_range= true;
4474
4474
 
4475
4475
  if (type == Item_func::LIKE_FUNC)
4476
4476
  {
4639
4639
  {
4640
4640
    field->table->in_use->variables.sql_mode= orig_sql_mode;
4641
4641
    /* This happens when we try to insert a NULL field in a not null column */
4642
 
    tree= &null_element;                        // cmp with NULL is never TRUE
 
4642
    tree= &null_element;                        // cmp with NULL is never true
4643
4643
    goto end;
4644
4644
  }
4645
4645
  field->table->in_use->variables.sql_mode= orig_sql_mode;
4656
4656
  /*
4657
4657
    Check if we are comparing an UNSIGNED integer with a negative constant.
4658
4658
    In this case we know that:
4659
 
    (a) (unsigned_int [< | <=] negative_constant) == FALSE
4660
 
    (b) (unsigned_int [> | >=] negative_constant) == TRUE
 
4659
    (a) (unsigned_int [< | <=] negative_constant) == false
 
4660
    (b) (unsigned_int [> | >=] negative_constant) == true
4661
4661
    In case (a) the condition is false for all values, and in case (b) it
4662
4662
    is true for all values, so we can avoid unnecessary retrieval and condition
4663
4663
    testing, and we also get correct comparison of unsinged integers with
4722
4722
** If tree is 0 it means that the condition can't be tested. It refers
4723
4723
** to a non existent table or to a field in current table with isn't a key.
4724
4724
** The different tree flags:
4725
 
** IMPOSSIBLE:   Condition is never TRUE
4726
 
** ALWAYS:       Condition is always TRUE
 
4725
** IMPOSSIBLE:   Condition is never true
 
4726
** ALWAYS:       Condition is always true
4727
4727
** MAYBE:        Condition may exists when tables are read
4728
4728
** MAYBE_KEY:    Condition refers to a key that may be used in join loop
4729
4729
** KEY_RANGE:    Condition uses a key
4848
4848
  common_keys.intersect(tree2->keys_map);
4849
4849
 
4850
4850
  if (common_keys.is_clear_all())
4851
 
    DBUG_RETURN(FALSE);
 
4851
    DBUG_RETURN(false);
4852
4852
 
4853
4853
  /* trees have a common key, check if they refer to same key part */
4854
4854
  SEL_ARG **key1,**key2;
4860
4860
      key2= tree2->keys + key_no;
4861
4861
      if ((*key1)->part == (*key2)->part)
4862
4862
      {
4863
 
        DBUG_RETURN(TRUE);
 
4863
        DBUG_RETURN(true);
4864
4864
      }
4865
4865
    }
4866
4866
  }
4867
 
  DBUG_RETURN(FALSE);
 
4867
  DBUG_RETURN(false);
4868
4868
}
4869
4869
 
4870
4870
 
4925
4925
 
4926
4926
static bool remove_nonrange_trees(RANGE_OPT_PARAM *param, SEL_TREE *tree)
4927
4927
{
4928
 
  bool res= FALSE;
 
4928
  bool res= false;
4929
4929
  for (uint i=0; i < param->keys; i++)
4930
4930
  {
4931
4931
    if (tree->keys[i])
4936
4936
        tree->keys_map.clear_bit(i);
4937
4937
      }
4938
4938
      else
4939
 
        res= TRUE;
 
4939
        res= true;
4940
4940
    }
4941
4941
  }
4942
4942
  return !res;
6007
6007
  RANGE_SEQ_ENTRY stack[MAX_REF_PARTS];
6008
6008
  int i; /* Index of last used element in the above array */
6009
6009
  
6010
 
  bool at_start; /* TRUE <=> The traversal has just started */
 
6010
  bool at_start; /* true <=> The traversal has just started */
6011
6011
} SEL_ARG_RANGE_SEQ;
6012
6012
 
6013
6013
 
6027
6027
range_seq_t sel_arg_range_seq_init(void *init_param, uint n_ranges, uint flags)
6028
6028
{
6029
6029
  SEL_ARG_RANGE_SEQ *seq= (SEL_ARG_RANGE_SEQ*)init_param;
6030
 
  seq->at_start= TRUE;
 
6030
  seq->at_start= true;
6031
6031
  seq->stack[0].key_tree= NULL;
6032
6032
  seq->stack[0].min_key= seq->param->min_key;
6033
6033
  seq->stack[0].min_key_flag= 0;
6098
6098
  if (seq->at_start)
6099
6099
  {
6100
6100
    key_tree= seq->start;
6101
 
    seq->at_start= FALSE;
 
6101
    seq->at_start= false;
6102
6102
    goto walk_up_n_right;
6103
6103
  }
6104
6104
 
6112
6112
    seq->i--;
6113
6113
    step_down_to(seq, key_tree->next);
6114
6114
    key_tree= key_tree->next;
6115
 
    seq->param->is_ror_scan= FALSE;
 
6115
    seq->param->is_ror_scan= false;
6116
6116
    goto walk_right_n_up;
6117
6117
  }
6118
6118
 
6154
6154
            !memcmp(cur[-1].min_key, cur[-1].max_key, len) &&
6155
6155
            !key_tree->min_flag && !key_tree->max_flag))
6156
6156
      {
6157
 
        seq->param->is_ror_scan= FALSE;
 
6157
        seq->param->is_ror_scan= false;
6158
6158
        if (!key_tree->min_flag)
6159
6159
          cur->min_key_parts += 
6160
6160
            key_tree->next_key_part->store_min_key(seq->param->key[seq->keyno],
6226
6226
            (range->start_key.length == range->end_key.length) &&
6227
6227
            !memcmp(range->start_key.key, range->end_key.key, range->start_key.length) &&
6228
6228
            is_key_scan_ror(seq->param, seq->real_keyno, key_tree->part + 1)))
6229
 
        seq->param->is_ror_scan= FALSE;
 
6229
        seq->param->is_ror_scan= false;
6230
6230
    }
6231
6231
  }
6232
6232
  seq->param->range_count++;
6242
6242
    check_quick_select()
6243
6243
      param             Parameter from test_quick_select
6244
6244
      idx               Number of index to use in PARAM::key SEL_TREE::key
6245
 
      index_only        TRUE  - assume only index tuples will be accessed
6246
 
                        FALSE - assume full table rows will be read
 
6245
      index_only        true  - assume only index tuples will be accessed
 
6246
                        false - assume full table rows will be read
6247
6247
      tree              Transformed selection condition, tree->key[idx] holds
6248
6248
                        the intervals for the given index.
6249
 
      update_tbl_stats  TRUE <=> update table->quick_* with information
 
6249
      update_tbl_stats  true <=> update table->quick_* with information
6250
6250
                        about range scan we've evaluated.
6251
6251
      mrr_flags   INOUT MRR access flags
6252
6252
      cost        OUT   Scan cost
6290
6290
  param->range_count=0;
6291
6291
  param->max_key_part=0;
6292
6292
 
6293
 
  param->is_ror_scan= TRUE;
6294
 
  if (file->index_flags(keynr, 0, TRUE) & HA_KEY_SCAN_NOT_ROR)
6295
 
    param->is_ror_scan= FALSE;
 
6293
  param->is_ror_scan= true;
 
6294
  if (file->index_flags(keynr, 0, true) & HA_KEY_SCAN_NOT_ROR)
 
6295
    param->is_ror_scan= false;
6296
6296
  
6297
6297
  *mrr_flags= param->force_default_mrr? HA_MRR_USE_DEFAULT_IMPL: 0;
6298
6298
  *mrr_flags|= HA_MRR_NO_ASSOCIATION;
6330
6330
      TODO: Don't have this logic here, make table engines return 
6331
6331
      appropriate flags instead.
6332
6332
    */
6333
 
    param->is_ror_scan= FALSE;
 
6333
    param->is_ror_scan= false;
6334
6334
  }
6335
6335
  else
6336
6336
  {
6337
6337
    /* Clustered PK scan is always a ROR scan (TODO: same as above) */
6338
6338
    if (param->table->s->primary_key == keynr && pk_is_clustered)
6339
 
      param->is_ror_scan= TRUE;
 
6339
      param->is_ror_scan= true;
6340
6340
  }
6341
6341
 
6342
6342
  DBUG_PRINT("exit", ("Records: %lu", (ulong) rows));
6377
6377
    Check (1) is made in quick_range_seq_next()
6378
6378
 
6379
6379
  RETURN
6380
 
    TRUE   The scan is ROR-scan
6381
 
    FALSE  Otherwise
 
6380
    true   The scan is ROR-scan
 
6381
    false  Otherwise
6382
6382
*/
6383
6383
 
6384
6384
static bool is_key_scan_ror(PARAM *param, uint keynr, uint8 nparts)
6394
6394
    uint16 fieldnr= param->table->key_info[keynr].
6395
6395
                    key_part[kp - table_key->key_part].fieldnr - 1;
6396
6396
    if (param->table->field[fieldnr]->key_length() != kp->length)
6397
 
      return FALSE;
 
6397
      return false;
6398
6398
  }
6399
6399
 
6400
6400
  if (key_part == key_part_end)
6401
 
    return TRUE;
 
6401
    return true;
6402
6402
 
6403
6403
  key_part= table_key->key_part + nparts;
6404
6404
  pk_number= param->table->s->primary_key;
6405
6405
  if (!param->table->file->primary_key_is_clustered() || pk_number == MAX_KEY)
6406
 
    return FALSE;
 
6406
    return false;
6407
6407
 
6408
6408
  KEY_PART_INFO *pk_part= param->table->key_info[pk_number].key_part;
6409
6409
  KEY_PART_INFO *pk_part_end= pk_part +
6413
6413
  {
6414
6414
    if ((key_part->field != pk_part->field) ||
6415
6415
        (key_part->length != pk_part->length))
6416
 
      return FALSE;
 
6416
      return false;
6417
6417
  }
6418
6418
  return (key_part == key_part_end);
6419
6419
}
6447
6447
                 uint mrr_buf_size, MEM_ROOT *parent_alloc)
6448
6448
{
6449
6449
  QUICK_RANGE_SELECT *quick;
6450
 
  bool create_err= FALSE;
 
6450
  bool create_err= false;
6451
6451
  DBUG_ENTER("get_quick_select");
6452
6452
 
6453
6453
  quick=new QUICK_RANGE_SELECT(param->thd, param->table,
6615
6615
 
6616
6616
 
6617
6617
/*
6618
 
  Return TRUE if any part of the key is NULL
 
6618
  Return true if any part of the key is NULL
6619
6619
 
6620
6620
  SYNOPSIS
6621
6621
    null_part_in_key()    
6624
6624
      length    Length of key values tuple in bytes.
6625
6625
 
6626
6626
  RETURN
6627
 
    TRUE   The tuple has at least one "keypartX is NULL"
6628
 
    FALSE  Otherwise
 
6627
    true   The tuple has at least one "keypartX is NULL"
 
6628
    false  Otherwise
6629
6629
*/
6630
6630
 
6631
6631
static bool null_part_in_key(KEY_PART *key_part, const uchar *key, uint length)
6711
6711
  KEY_PART *key_part;
6712
6712
  QUICK_RANGE *range;
6713
6713
  uint part;
6714
 
  bool create_err= FALSE;
 
6714
  bool create_err= false;
6715
6715
  COST_VECT cost;
6716
6716
 
6717
6717
  old_root= thd->mem_root;
6806
6806
  The merge/duplicate removal is performed using Unique class. We put all
6807
6807
  rowids into Unique, get the sorted sequence and destroy the Unique.
6808
6808
  
6809
 
  If table has a clustered primary key that covers all rows (TRUE for bdb
 
6809
  If table has a clustered primary key that covers all rows (true for bdb
6810
6810
  and innodb currently) and one of the index_merge scans is a scan on PK,
6811
6811
  then rows that will be retrieved by PK scan are not put into Unique and 
6812
6812
  primary key scan is not performed here, it is performed later separately.
6887
6887
  /* ok, all row ids are in Unique */
6888
6888
  result= unique->get(head);
6889
6889
  delete unique;
6890
 
  doing_pk_scan= FALSE;
 
6890
  doing_pk_scan= false;
6891
6891
  /* index_merge currently doesn't support "using index" at all */
6892
6892
  file->extra(HA_EXTRA_NO_KEYREAD);
6893
6893
  /* start table scan */
6920
6920
    /* All rows from Unique have been retrieved, do a clustered PK scan */
6921
6921
    if (pk_quick_select)
6922
6922
    {
6923
 
      doing_pk_scan= TRUE;
 
6923
      doing_pk_scan= true;
6924
6924
      if ((result= pk_quick_select->init()) ||
6925
6925
          (result= pk_quick_select->reset()))
6926
6926
        DBUG_RETURN(result);
7072
7072
      if (!have_prev_rowid)
7073
7073
      {
7074
7074
        /* No rows have been returned yet */
7075
 
        dup_row= FALSE;
7076
 
        have_prev_rowid= TRUE;
 
7075
        dup_row= false;
 
7076
        have_prev_rowid= true;
7077
7077
      }
7078
7078
      else
7079
7079
        dup_row= !head->file->cmp_ref(cur_rowid, prev_rowid);
7404
7404
    index_merge quick select.
7405
7405
 
7406
7406
  RETURN
7407
 
    TRUE  if current row will be retrieved by this quick select
7408
 
    FALSE if not
 
7407
    true  if current row will be retrieved by this quick select
 
7408
    false if not
7409
7409
*/
7410
7410
 
7411
7411
bool QUICK_RANGE_SELECT::row_in_ranges()
7607
7607
 
7608
7608
 
7609
7609
/*
7610
 
 * TRUE if this range will require using HA_READ_AFTER_KEY
 
7610
 * true if this range will require using HA_READ_AFTER_KEY
7611
7611
   See comment in get_next() about this
7612
7612
 */
7613
7613
 
7628
7628
void QUICK_INDEX_MERGE_SELECT::add_info_string(String *str)
7629
7629
{
7630
7630
  QUICK_RANGE_SELECT *quick;
7631
 
  bool first= TRUE;
 
7631
  bool first= true;
7632
7632
  List_iterator_fast<QUICK_RANGE_SELECT> it(quick_selects);
7633
7633
  str->append(STRING_WITH_LEN("sort_union("));
7634
7634
  while ((quick= it++))
7636
7636
    if (!first)
7637
7637
      str->append(',');
7638
7638
    else
7639
 
      first= FALSE;
 
7639
      first= false;
7640
7640
    quick->add_info_string(str);
7641
7641
  }
7642
7642
  if (pk_quick_select)
7649
7649
 
7650
7650
void QUICK_ROR_INTERSECT_SELECT::add_info_string(String *str)
7651
7651
{
7652
 
  bool first= TRUE;
 
7652
  bool first= true;
7653
7653
  QUICK_RANGE_SELECT *quick;
7654
7654
  List_iterator_fast<QUICK_RANGE_SELECT> it(quick_selects);
7655
7655
  str->append(STRING_WITH_LEN("intersect("));
7659
7659
    if (!first)
7660
7660
      str->append(',');
7661
7661
    else
7662
 
      first= FALSE;
 
7662
      first= false;
7663
7663
    str->append(key_info->name);
7664
7664
  }
7665
7665
  if (cpk_quick)
7673
7673
 
7674
7674
void QUICK_ROR_UNION_SELECT::add_info_string(String *str)
7675
7675
{
7676
 
  bool first= TRUE;
 
7676
  bool first= true;
7677
7677
  QUICK_SELECT_I *quick;
7678
7678
  List_iterator_fast<QUICK_SELECT_I> it(quick_selects);
7679
7679
  str->append(STRING_WITH_LEN("union("));
7682
7682
    if (!first)
7683
7683
      str->append(',');
7684
7684
    else
7685
 
      first= FALSE;
 
7685
      first= false;
7686
7686
    quick->add_info_string(str);
7687
7687
  }
7688
7688
  str->append(')');
7705
7705
{
7706
7706
  char buf[64];
7707
7707
  uint length;
7708
 
  bool first= TRUE;
 
7708
  bool first= true;
7709
7709
  QUICK_RANGE_SELECT *quick;
7710
7710
 
7711
7711
  List_iterator_fast<QUICK_RANGE_SELECT> it(quick_selects);
7712
7712
  while ((quick= it++))
7713
7713
  {
7714
7714
    if (first)
7715
 
      first= FALSE;
 
7715
      first= false;
7716
7716
    else
7717
7717
    {
7718
7718
      key_names->append(',');
7740
7740
{
7741
7741
  char buf[64];
7742
7742
  uint length;
7743
 
  bool first= TRUE;
 
7743
  bool first= true;
7744
7744
  QUICK_RANGE_SELECT *quick;
7745
7745
  List_iterator_fast<QUICK_RANGE_SELECT> it(quick_selects);
7746
7746
  while ((quick= it++))
7747
7747
  {
7748
7748
    KEY *key_info= head->key_info + quick->index;
7749
7749
    if (first)
7750
 
      first= FALSE;
 
7750
      first= false;
7751
7751
    else
7752
7752
    {
7753
7753
      key_names->append(',');
7772
7772
void QUICK_ROR_UNION_SELECT::add_keys_and_lengths(String *key_names,
7773
7773
                                                  String *used_lengths)
7774
7774
{
7775
 
  bool first= TRUE;
 
7775
  bool first= true;
7776
7776
  QUICK_SELECT_I *quick;
7777
7777
  List_iterator_fast<QUICK_SELECT_I> it(quick_selects);
7778
7778
  while ((quick= it++))
7779
7779
  {
7780
7780
    if (first)
7781
 
      first= FALSE;
 
7781
      first= false;
7782
7782
    else
7783
7783
    {
7784
7784
      used_lengths->append(',');
7912
7912
    object, that is later used to construct a new QUICK_GROUP_MIN_MAX_SELECT.
7913
7913
    If (mem_root == NULL), then the function only tests whether the current
7914
7914
    query satisfies the conditions above, and, if so, sets
7915
 
    is_applicable = TRUE.
 
7915
    is_applicable = true.
7916
7916
 
7917
7917
    Queries with DISTINCT for which index access can be used are transformed
7918
7918
    into equivalent group-by queries of the form:
7948
7948
  THD *thd= param->thd;
7949
7949
  JOIN *join= thd->lex->current_select->join;
7950
7950
  TABLE *table= param->table;
7951
 
  bool have_min= FALSE;              /* TRUE if there is a MIN function. */
7952
 
  bool have_max= FALSE;              /* TRUE if there is a MAX function. */
 
7951
  bool have_min= false;              /* true if there is a MIN function. */
 
7952
  bool have_max= false;              /* true if there is a MAX function. */
7953
7953
  Item_field *min_max_arg_item= NULL; // The argument of all MIN/MAX functions
7954
7954
  KEY_PART_INFO *min_max_arg_part= NULL; /* The corresponding keypart. */
7955
7955
  uint group_prefix_len= 0; /* Length (in bytes) of the key prefix. */
7990
7990
    while ((min_max_item= *(func_ptr++)))
7991
7991
    {
7992
7992
      if (min_max_item->sum_func() == Item_sum::MIN_FUNC)
7993
 
        have_min= TRUE;
 
7993
        have_min= true;
7994
7994
      else if (min_max_item->sum_func() == Item_sum::MAX_FUNC)
7995
 
        have_max= TRUE;
 
7995
        have_max= true;
7996
7996
      else
7997
7997
        DBUG_RETURN(NULL);
7998
7998
 
8029
8029
 
8030
8030
  /*
8031
8031
    Check that table has at least one compound index such that the conditions
8032
 
    (GA1,GA2) are all TRUE. If there is more than one such index, select the
 
8032
    (GA1,GA2) are all true. If there is more than one such index, select the
8033
8033
    first one. Here we set the variables: group_prefix_len and index_info.
8034
8034
  */
8035
8035
  KEY *cur_index_info= table->key_info;
8163
8163
        goto next_index;
8164
8164
    }
8165
8165
    else
8166
 
      DBUG_ASSERT(FALSE);
 
8166
      DBUG_ASSERT(false);
8167
8167
 
8168
8168
    /* Check (SA2). */
8169
8169
    if (min_max_arg_item)
8277
8277
      uint mrr_flags= HA_MRR_USE_DEFAULT_IMPL;
8278
8278
      uint mrr_bufsize=0;
8279
8279
      cur_quick_prefix_records= check_quick_select(param, cur_param_idx, 
8280
 
                                                   FALSE /*don't care*/, 
8281
 
                                                   cur_index_tree, TRUE,
 
8280
                                                   false /*don't care*/, 
 
8281
                                                   cur_index_tree, true,
8282
8282
                                                   &mrr_flags, &mrr_bufsize,
8283
8283
                                                   &dummy_cost);
8284
8284
    }
8363
8363
    predicates: {=, !=, <, <=, >, >=, between, is null, is not null}.
8364
8364
 
8365
8365
  RETURN
8366
 
    TRUE  if cond passes the test
8367
 
    FALSE o/w
 
8366
    true  if cond passes the test
 
8367
    false o/w
8368
8368
*/
8369
8369
 
8370
8370
static bool
8385
8385
    {
8386
8386
      if (!check_group_min_max_predicates(and_or_arg, min_max_arg_item,
8387
8387
                                         image_type))
8388
 
        DBUG_RETURN(FALSE);
 
8388
        DBUG_RETURN(false);
8389
8389
    }
8390
 
    DBUG_RETURN(TRUE);
 
8390
    DBUG_RETURN(true);
8391
8391
  }
8392
8392
 
8393
8393
  /*
8400
8400
    so.
8401
8401
  */
8402
8402
  if (cond_type == Item::SUBSELECT_ITEM)
8403
 
    DBUG_RETURN(FALSE);
 
8403
    DBUG_RETURN(false);
8404
8404
  
8405
8405
  /* We presume that at this point there are no other Items than functions. */
8406
8406
  DBUG_ASSERT(cond_type == Item::FUNC_ITEM);
8433
8433
            pred_type != Item_func::ISNOTNULL_FUNC &&
8434
8434
            pred_type != Item_func::EQ_FUNC        &&
8435
8435
            pred_type != Item_func::NE_FUNC)
8436
 
          DBUG_RETURN(FALSE);
 
8436
          DBUG_RETURN(false);
8437
8437
 
8438
8438
        /* Check that pred compares min_max_arg_item with a constant. */
8439
8439
        Item *args[3];
8441
8441
        bool inv;
8442
8442
        /* Test if this is a comparison of a field and a constant. */
8443
8443
        if (!simple_pred(pred, args, &inv))
8444
 
          DBUG_RETURN(FALSE);
 
8444
          DBUG_RETURN(false);
8445
8445
 
8446
8446
        /* Check for compatible string comparisons - similar to get_mm_leaf. */
8447
8447
        if (args[0] && args[1] && !args[2] && // this is a binary function
8460
8460
             */
8461
8461
             (args[1]->result_type() != STRING_RESULT &&
8462
8462
              min_max_arg_item->field->cmp_type() != args[1]->result_type())))
8463
 
          DBUG_RETURN(FALSE);
 
8463
          DBUG_RETURN(false);
8464
8464
      }
8465
8465
    }
8466
8466
    else if (cur_arg->type() == Item::FUNC_ITEM)
8467
8467
    {
8468
8468
      if (!check_group_min_max_predicates(cur_arg, min_max_arg_item,
8469
8469
                                         image_type))
8470
 
        DBUG_RETURN(FALSE);
 
8470
        DBUG_RETURN(false);
8471
8471
    }
8472
8472
    else if (cur_arg->const_item())
8473
8473
    {
8474
 
      DBUG_RETURN(TRUE);
 
8474
      DBUG_RETURN(true);
8475
8475
    }
8476
8476
    else
8477
 
      DBUG_RETURN(FALSE);
 
8477
      DBUG_RETURN(false);
8478
8478
  }
8479
8479
 
8480
 
  DBUG_RETURN(TRUE);
 
8480
  DBUG_RETURN(true);
8481
8481
}
8482
8482
 
8483
8483
 
8508
8508
    key_infix_len with the total length of the key parts in key_infix.
8509
8509
 
8510
8510
  RETURN
8511
 
    TRUE  if the index passes the test
8512
 
    FALSE o/w
 
8511
    true  if the index passes the test
 
8512
    false o/w
8513
8513
*/
8514
8514
 
8515
8515
static bool
8542
8542
    if (!cur_range)
8543
8543
    {
8544
8544
      if (min_max_arg_part)
8545
 
        return FALSE; /* The current keypart has no range predicates at all. */
 
8545
        return false; /* The current keypart has no range predicates at all. */
8546
8546
      else
8547
8547
      {
8548
8548
        *first_non_infix_part= cur_part;
8549
 
        return TRUE;
 
8549
        return true;
8550
8550
      }
8551
8551
    }
8552
8552
 
8553
8553
    /* Check that the current range tree is a single point interval. */
8554
8554
    if (cur_range->prev || cur_range->next)
8555
 
      return FALSE; /* This is not the only range predicate for the field. */
 
8555
      return false; /* This is not the only range predicate for the field. */
8556
8556
    if ((cur_range->min_flag & NO_MIN_RANGE) ||
8557
8557
        (cur_range->max_flag & NO_MAX_RANGE) ||
8558
8558
        (cur_range->min_flag & NEAR_MIN) || (cur_range->max_flag & NEAR_MAX))
8559
 
      return FALSE;
 
8559
      return false;
8560
8560
 
8561
8561
    uint field_length= cur_part->store_length;
8562
8562
    if ((cur_range->maybe_null &&
8569
8569
      *key_infix_len+= field_length;
8570
8570
    }
8571
8571
    else
8572
 
      return FALSE;
 
8572
      return false;
8573
8573
  }
8574
8574
 
8575
8575
  if (!min_max_arg_part && (cur_part == last_part))
8576
8576
    *first_non_infix_part= last_part;
8577
8577
 
8578
 
  return TRUE;
 
8578
  return true;
8579
8579
}
8580
8580
 
8581
8581
 
8892
8892
    QUICK_GROUP_MIN_MAX_SELECT::QUICK_GROUP_MIN_MAX_SELECT()
8893
8893
    table             The table being accessed
8894
8894
    join              Descriptor of the current query
8895
 
    have_min          TRUE if the query selects a MIN function
8896
 
    have_max          TRUE if the query selects a MAX function
 
8895
    have_min          true if the query selects a MIN function
 
8896
    have_max          true if the query selects a MAX function
8897
8897
    min_max_arg_part  The only argument field of all MIN/MAX functions
8898
8898
    group_prefix_len  Length of all key parts in the group prefix
8899
8899
    prefix_key_parts  All key parts in the group prefix
8921
8921
  :join(join_arg), index_info(index_info_arg),
8922
8922
   group_prefix_len(group_prefix_len_arg),
8923
8923
   group_key_parts(group_key_parts_arg), have_min(have_min_arg),
8924
 
   have_max(have_max_arg), seen_first_key(FALSE),
 
8924
   have_max(have_max_arg), seen_first_key(false),
8925
8925
   min_max_arg_part(min_max_arg_part_arg), key_infix(key_infix_arg),
8926
8926
   key_infix_len(key_infix_len_arg), min_functions_it(NULL),
8927
8927
   max_functions_it(NULL)
9077
9077
    a quick range.
9078
9078
 
9079
9079
  RETURN
9080
 
    FALSE on success
9081
 
    TRUE  otherwise
 
9080
    false on success
 
9081
    true  otherwise
9082
9082
*/
9083
9083
 
9084
9084
bool QUICK_GROUP_MIN_MAX_SELECT::add_range(SEL_ARG *sel_range)
9088
9088
 
9089
9089
  /* Skip (-inf,+inf) ranges, e.g. (x < 5 or x > 4). */
9090
9090
  if ((range_flag & NO_MIN_RANGE) && (range_flag & NO_MAX_RANGE))
9091
 
    return FALSE;
 
9091
    return false;
9092
9092
 
9093
9093
  if (!(sel_range->min_flag & NO_MIN_RANGE) &&
9094
9094
      !(sel_range->max_flag & NO_MAX_RANGE))
9106
9106
                         make_keypart_map(sel_range->part),
9107
9107
                         range_flag);
9108
9108
  if (!range)
9109
 
    return TRUE;
 
9109
    return true;
9110
9110
  if (insert_dynamic(&min_max_ranges, (uchar*)&range))
9111
 
    return TRUE;
9112
 
  return FALSE;
 
9111
    return true;
 
9112
  return false;
9113
9113
}
9114
9114
 
9115
9115
 
9511
9511
    if ((result= quick_prefix_select->get_next_prefix(group_prefix_len,
9512
9512
                         make_prev_keypart_map(group_key_parts), cur_prefix)))
9513
9513
      DBUG_RETURN(result);
9514
 
    seen_first_key= TRUE;
 
9514
    seen_first_key= true;
9515
9515
  }
9516
9516
  else
9517
9517
  {
9520
9520
      result= file->index_first(record);
9521
9521
      if (result)
9522
9522
        DBUG_RETURN(result);
9523
 
      seen_first_key= TRUE;
 
9523
      seen_first_key= true;
9524
9524
    }
9525
9525
    else
9526
9526
    {
9570
9570
  ha_rkey_function find_flag;
9571
9571
  key_part_map keypart_map;
9572
9572
  QUICK_RANGE *cur_range;
9573
 
  bool found_null= FALSE;
 
9573
  bool found_null= false;
9574
9574
  int result= HA_ERR_KEY_NOT_FOUND;
9575
9575
 
9576
9576
  DBUG_ASSERT(min_max_ranges.elements > 0);
9630
9630
        satisfies some other condition.
9631
9631
      */
9632
9632
      memcpy(tmp_record, record, head->s->rec_buff_length);
9633
 
      found_null= TRUE;
 
9633
      found_null= true;
9634
9634
      continue;
9635
9635
    }
9636
9636
 
9987
9987
  table= quick->head;
9988
9988
  old_read_map=  dbug_tmp_use_all_columns(table, table->read_set);
9989
9989
  old_write_map= dbug_tmp_use_all_columns(table, table->write_set);
9990
 
  quick->dbug_dump(0, TRUE);
 
9990
  quick->dbug_dump(0, true);
9991
9991
  dbug_tmp_restore_column_map(table->read_set, old_read_map);
9992
9992
  dbug_tmp_restore_column_map(table->write_set, old_write_map);
9993
9993
 
10088
10088
  SYNOPSIS
10089
10089
    QUICK_GROUP_MIN_MAX_SELECT::dbug_dump()
10090
10090
    indent  Indentation offset
10091
 
    verbose If TRUE show more detailed output.
 
10091
    verbose If true show more detailed output.
10092
10092
 
10093
10093
  DESCRIPTION
10094
10094
    Print the contents of this quick select to DBUG_FILE. The method also