~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/optimizer/sum.cc

  • Committer: Olaf van der Spek
  • Date: 2011-06-23 11:44:30 UTC
  • mto: This revision was merged to the branch mainline in revision 2348.
  • Revision ID: olafvdspek@gmail.com-20110623114430-no355yypk4y3icqb
Refactor

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008-2009 Sun Microsystems
 
4
 *  Copyright (C) 2008-2009 Sun Microsystems, Inc.
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
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"
 
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>
59
64
 
60
65
namespace drizzled
61
66
{
110
115
 
111
116
int optimizer::sum_query(TableList *tables, List<Item> &all_fields, COND *conds)
112
117
{
113
 
  List_iterator_fast<Item> it(all_fields);
 
118
  List<Item>::iterator it(all_fields.begin());
114
119
  int const_result= 1;
115
120
  bool recalc_const_item= false;
116
121
  uint64_t count= 1;
262
267
                break;
263
268
              }
264
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
              }
265
280
 
266
281
              if (! ref.key_length)
267
282
              {
541
556
    /* MULT_EQUAL_FUNC */
542
557
    {
543
558
      Item_equal *item_equal= (Item_equal *) func_item;
544
 
      Item_equal_iterator it(*item_equal);
 
559
      Item_equal_iterator it(item_equal->begin());
545
560
      args[0]= it++;
546
561
      if (it++)
547
562
      {
675
690
    }
676
691
 
677
692
    /* AND */
678
 
    List_iterator_fast<Item> li(*((Item_cond*) cond)->argument_list());
 
693
    List<Item>::iterator li(((Item_cond*) cond)->argument_list()->begin());
679
694
    Item *item;
680
695
    while ((item= li++))
681
696
    {
1057
1072
  /* If AND/OR condition */
1058
1073
  if (cond->type() == Item::COND_ITEM)
1059
1074
  {
1060
 
    List_iterator_fast<Item> li(*((Item_cond*) cond)->argument_list());
 
1075
    List<Item>::iterator li(((Item_cond*) cond)->argument_list()->begin());
1061
1076
    Item *item;
1062
1077
    while ((item= li++))
1063
1078
    {