~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/optimizer/sum.cc

  • Committer: Monty Taylor
  • Date: 2010-08-12 20:27:32 UTC
  • mto: (1720.1.5 build)
  • mto: This revision was merged to the branch mainline in revision 1722.
  • Revision ID: mordred@inaugust.com-20100812202732-9kzchbkvkyki4n3u
Merged libdrizzle directly into tree.

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, Inc.
 
4
 *  Copyright (C) 2008-2009 Sun Microsystems
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
 
 
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>
 
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"
63
59
 
64
60
namespace drizzled
65
61
{
114
110
 
115
111
int optimizer::sum_query(TableList *tables, List<Item> &all_fields, COND *conds)
116
112
{
117
 
  List<Item>::iterator it(all_fields.begin());
 
113
  List_iterator_fast<Item> it(all_fields);
118
114
  int const_result= 1;
119
115
  bool recalc_const_item= false;
120
116
  uint64_t count= 1;
266
262
                break;
267
263
              }
268
264
              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
 
              }
279
265
 
280
266
              if (! ref.key_length)
281
267
              {
689
675
    }
690
676
 
691
677
    /* AND */
692
 
    List<Item>::iterator li(((Item_cond*) cond)->argument_list()->begin());
 
678
    List_iterator_fast<Item> li(*((Item_cond*) cond)->argument_list());
693
679
    Item *item;
694
680
    while ((item= li++))
695
681
    {
1071
1057
  /* If AND/OR condition */
1072
1058
  if (cond->type() == Item::COND_ITEM)
1073
1059
  {
1074
 
    List<Item>::iterator li(((Item_cond*) cond)->argument_list()->begin());
 
1060
    List_iterator_fast<Item> li(*((Item_cond*) cond)->argument_list());
1075
1061
    Item *item;
1076
1062
    while ((item= li++))
1077
1063
    {