~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/optimizer/sum.cc

Merge Joe, plus I updated the tests.

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
56
56
#include "drizzled/item/sum.h"
57
57
#include "drizzled/item/cmpfunc.h"
58
58
#include "drizzled/optimizer/sum.h"
59
 
#include "drizzled/plugin/storage_engine.h"
60
59
 
61
60
namespace drizzled
62
61
{
240
239
 
241
240
              ref.key_buff= key_buff;
242
241
              Item_field *item_field= (Item_field*) (expr->real_item());
243
 
              Table *table= item_field->field->getTable();
 
242
              Table *table= item_field->field->table;
244
243
 
245
244
              /*
246
245
                 Look for a partial key that can be used for optimization.
408
407
 
409
408
              ref.key_buff= key_buff;
410
409
              Item_field *item_field= (Item_field*) (expr->real_item());
411
 
              Table *table= item_field->field->getTable();
 
410
              Table *table= item_field->field->table;
412
411
 
413
412
              /*
414
413
                 Look for a partial key that can be used for optimization.
663
662
 
664
663
  field->setWriteSet();
665
664
 
666
 
  if (! (cond->used_tables() & field->getTable()->map))
 
665
  if (! (cond->used_tables() & field->table->map))
667
666
  {
668
667
    /* Condition doesn't restrict the used table */
669
668
    return 1;
908
907
    return 0; // Not key field
909
908
  }
910
909
 
911
 
  Table *table= field->getTable();
 
910
  Table *table= field->table;
912
911
  uint32_t idx= 0;
913
912
 
914
913
  KeyInfo *keyinfo,*keyinfo_end= NULL;
1029
1028
                           uint32_t range_fl,
1030
1029
                           uint32_t prefix_len)
1031
1030
{
1032
 
  if (key_cmp_if_same(field->getTable(), ref->key_buff, ref->key, prefix_len))
 
1031
  if (key_cmp_if_same(field->table, ref->key_buff, ref->key, prefix_len))
1033
1032
  {
1034
1033
    return 1;
1035
1034
  }
1070
1069
    return 0;
1071
1070
  }
1072
1071
 
1073
 
  if (cond->used_tables() != field->getTable()->map)
 
1072
  if (cond->used_tables() != field->table->map)
1074
1073
  {
1075
1074
    return 0;
1076
1075
  }