~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/optimizer/sum.cc

  • Committer: Mark Atwood
  • Date: 2011-08-12 04:08:33 UTC
  • mfrom: (2385.2.17 refactor5)
  • Revision ID: me@mark.atwood.name-20110812040833-u6j85nc6ahuc0dtz
mergeĀ lp:~olafvdspek/drizzle/refactor5

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
  (assuming a index for column d of table t2 is defined)
52
52
*/
53
53
 
54
 
#include "config.h"
55
 
#include "drizzled/sql_select.h"
56
 
#include "drizzled/item/sum.h"
57
 
#include "drizzled/item/cmpfunc.h"
58
 
#include "drizzled/optimizer/sum.h"
59
 
#include "drizzled/plugin/storage_engine.h"
 
54
#include <config.h>
 
55
 
 
56
#include <drizzled/sql_select.h>
 
57
#include <drizzled/item/sum.h>
 
58
#include <drizzled/item/cmpfunc.h>
 
59
#include <drizzled/optimizer/sum.h>
 
60
#include <drizzled/plugin/storage_engine.h>
 
61
#include <drizzled/table_list.h>
 
62
#include <drizzled/key.h>
 
63
#include <drizzled/error.h>
60
64
 
61
65
namespace drizzled
62
66
{
111
115
 
112
116
int optimizer::sum_query(TableList *tables, List<Item> &all_fields, COND *conds)
113
117
{
114
 
  List_iterator_fast<Item> it(all_fields);
 
118
  List<Item>::iterator it(all_fields.begin());
115
119
  int const_result= 1;
116
120
  bool recalc_const_item= false;
117
121
  uint64_t count= 1;
263
267
                break;
264
268
              }
265
269
              error= table->cursor->startIndexScan(static_cast<uint32_t>(ref.key), 1);
 
270
              if (error)
 
271
              {
 
272
                if (table->key_read)
 
273
                {
 
274
                  table->key_read= 0;
 
275
                  table->cursor->extra(HA_EXTRA_NO_KEYREAD);
 
276
                }
 
277
                table->print_error(error, MYF(0));
 
278
                return error;
 
279
              }
266
280
 
267
281
              if (! ref.key_length)
268
282
              {
542
556
    /* MULT_EQUAL_FUNC */
543
557
    {
544
558
      Item_equal *item_equal= (Item_equal *) func_item;
545
 
      Item_equal_iterator it(*item_equal);
 
559
      Item_equal_iterator it(item_equal->begin());
546
560
      args[0]= it++;
547
561
      if (it++)
548
562
      {
676
690
    }
677
691
 
678
692
    /* AND */
679
 
    List_iterator_fast<Item> li(*((Item_cond*) cond)->argument_list());
 
693
    List<Item>::iterator li(((Item_cond*) cond)->argument_list()->begin());
680
694
    Item *item;
681
695
    while ((item= li++))
682
696
    {
1058
1072
  /* If AND/OR condition */
1059
1073
  if (cond->type() == Item::COND_ITEM)
1060
1074
  {
1061
 
    List_iterator_fast<Item> li(*((Item_cond*) cond)->argument_list());
1062
 
    Item *item;
1063
 
    while ((item= li++))
 
1075
    List<Item>::iterator li(((Item_cond*) cond)->argument_list()->begin());
 
1076
    while (Item* item= li++)
1064
1077
    {
1065
1078
      if (maxmin_in_range(max_fl, field, item))
1066
 
      {
1067
1079
        return 1;
1068
 
      }
1069
1080
    }
1070
1081
    return 0;
1071
1082
  }
1106
1117
  case Item_func::EQ_FUNC:
1107
1118
  case Item_func::EQUAL_FUNC:
1108
1119
    break;
1109
 
  default:                                        // Keep compiler happy
1110
 
    assert(1);                               // Impossible
1111
 
    break;
 
1120
  default:
 
1121
    ; // assert(false); // Impossible; Olaf: Not really, assert is hit. BUG?
1112
1122
  }
1113
1123
  return 0;
1114
1124
}