~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/optimizer/sum.cc

Split some classes from the range optimizer out in to their own header and implementation files.
Corrected the case on these classes also to adhere to the coding standards. Cleaned up any style
issues in any code I came across while moving code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
74
74
                           uint32_t range_fl, 
75
75
                           uint32_t prefix_len);
76
76
 
77
 
static int maxmin_in_range(bool max_fl, Field* field, COND *cond);
 
77
static int maxmin_in_range(bool max_fl, Field *field, COND *cond);
78
78
 
79
79
 
80
80
/*
92
92
    UINT64_MAX  Error: Could not calculate number of rows
93
93
    #                   Multiplication of number of rows in all tables
94
94
*/
95
 
 
96
95
static uint64_t get_exact_record_count(TableList *tables)
97
96
{
98
97
  uint64_t count= 1;
121
120
  table_map outer_tables= 0;
122
121
  table_map used_tables= 0;
123
122
  table_map where_tables= 0;
124
 
  Item *item;
 
123
  Item *item= NULL;
125
124
  int error;
126
125
 
127
126
  if (conds)
135
134
   */
136
135
  for (TableList *tl= tables; tl; tl= tl->next_leaf)
137
136
  {
138
 
    TableList *embedded;
139
 
    for (embedded= tl ; embedded; embedded= embedded->embedding)
 
137
    TableList *embedded= NULL;
 
138
    for (embedded= tl; embedded; embedded= embedded->embedding)
140
139
    {
141
140
      if (embedded->on_expr)
142
141
        break;
285
284
                   nullable column, test if there is an exact match for the key.
286
285
                 */
287
286
                if (! (range_fl & NEAR_MIN))
 
287
                {
288
288
                  /*
289
289
                     Closed interval: Either The MIN argument is non-nullable, or
290
290
                     we have a >= predicate for the MIN argument.
293
293
                                                       ref.key_buff,
294
294
                                                       make_prev_keypart_map(ref.key_parts),
295
295
                                                       HA_READ_KEY_OR_NEXT);
 
296
                }
296
297
                else
297
298
                {
298
299
                  /*
530
531
}
531
532
 
532
533
 
533
 
bool optimizer::simple_pred(Item_func *func_item, Item **args, bool *inv_order)
 
534
bool optimizer::simple_pred(Item_func *func_item, Item **args, bool &inv_order)
534
535
{
535
536
  Item *item= NULL;
536
 
  *inv_order= 0;
537
 
  switch (func_item->argument_count()) {
 
537
  inv_order= false;
 
538
  switch (func_item->argument_count()) 
 
539
  {
538
540
  case 0:
539
541
    /* MULT_EQUAL_FUNC */
540
542
    {
582
584
        return 0;
583
585
      }
584
586
      args[0]= item;
585
 
      *inv_order= 1;
 
587
      inv_order= true;
586
588
    }
587
589
    else
588
590
    {
643
645
  @retval
644
646
    1        We can use index to get MIN/MAX value
645
647
*/
646
 
 
647
648
static bool matching_cond(bool max_fl, 
648
649
                          table_reference_st *ref, 
649
650
                          KEY *keyinfo,
735
736
  bool inv;
736
737
 
737
738
  /* Test if this is a comparison of a field and constant */
738
 
  if (! optimizer::simple_pred((Item_func*) cond, args, &inv))
 
739
  if (! optimizer::simple_pred((Item_func*) cond, args, inv))
739
740
  {
740
741
    return 0;
741
742
  }
894
895
    1   Can use key to optimize MIN()/MAX().
895
896
    In this case ref, range_fl and prefix_len are updated
896
897
*/
897
 
 
898
 
 
899
898
static bool find_key_for_maxmin(bool max_fl, 
900
899
                                table_reference_st *ref,
901
900
                                Field* field,