~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/optimizer/sum.cc

  • Committer: Lee Bieber
  • Date: 2011-03-13 16:37:38 UTC
  • mfrom: (2227.4.18 session2)
  • Revision ID: kalebral@gmail.com-20110313163738-7ti21zk40o2xi3ew
Merge Olaf - Refactor Session

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>
59
63
 
60
64
namespace drizzled
61
65
{
110
114
 
111
115
int optimizer::sum_query(TableList *tables, List<Item> &all_fields, COND *conds)
112
116
{
113
 
  List_iterator_fast<Item> it(all_fields);
 
117
  List<Item>::iterator it(all_fields.begin());
114
118
  int const_result= 1;
115
119
  bool recalc_const_item= false;
116
120
  uint64_t count= 1;
262
266
                break;
263
267
              }
264
268
              error= table->cursor->startIndexScan(static_cast<uint32_t>(ref.key), 1);
 
269
              if (error)
 
270
              {
 
271
                if (table->key_read)
 
272
                {
 
273
                  table->key_read= 0;
 
274
                  table->cursor->extra(HA_EXTRA_NO_KEYREAD);
 
275
                }
 
276
                table->print_error(error, MYF(0));
 
277
                return error;
 
278
              }
265
279
 
266
280
              if (! ref.key_length)
267
281
              {
541
555
    /* MULT_EQUAL_FUNC */
542
556
    {
543
557
      Item_equal *item_equal= (Item_equal *) func_item;
544
 
      Item_equal_iterator it(*item_equal);
 
558
      Item_equal_iterator it(item_equal->begin());
545
559
      args[0]= it++;
546
560
      if (it++)
547
561
      {
675
689
    }
676
690
 
677
691
    /* AND */
678
 
    List_iterator_fast<Item> li(*((Item_cond*) cond)->argument_list());
 
692
    List<Item>::iterator li(((Item_cond*) cond)->argument_list()->begin());
679
693
    Item *item;
680
694
    while ((item= li++))
681
695
    {
1057
1071
  /* If AND/OR condition */
1058
1072
  if (cond->type() == Item::COND_ITEM)
1059
1073
  {
1060
 
    List_iterator_fast<Item> li(*((Item_cond*) cond)->argument_list());
 
1074
    List<Item>::iterator li(((Item_cond*) cond)->argument_list()->begin());
1061
1075
    Item *item;
1062
1076
    while ((item= li++))
1063
1077
    {