~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/optimizer/sum.cc

  • Committer: Monty Taylor
  • Date: 2010-04-22 02:46:23 UTC
  • mto: (1497.3.4 enable-dtrace)
  • mto: This revision was merged to the branch mainline in revision 1527.
  • Revision ID: mordred@inaugust.com-20100422024623-4urw8fi8eraci08p
Don't overwrite the pandora_vc_revinfo file if we don't have new
authoratative information.

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
{
136
135
  for (TableList *tl= tables; tl; tl= tl->next_leaf)
137
136
  {
138
137
    TableList *embedded= NULL;
139
 
    for (embedded= tl; embedded; embedded= embedded->getEmbedding())
 
138
    for (embedded= tl; embedded; embedded= embedded->embedding)
140
139
    {
141
140
      if (embedded->on_expr)
142
141
        break;
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.
262
261
                const_result= 0;
263
262
                break;
264
263
              }
265
 
              error= table->cursor->startIndexScan(static_cast<uint32_t>(ref.key), 1);
 
264
              error= table->cursor->ha_index_init(static_cast<uint32_t>(ref.key), 1);
266
265
 
267
266
              if (! ref.key_length)
268
267
              {
352
351
                table->key_read= 0;
353
352
                table->cursor->extra(HA_EXTRA_NO_KEYREAD);
354
353
              }
355
 
              table->cursor->endIndexScan();
 
354
              table->cursor->ha_index_end();
356
355
              if (error)
357
356
              {
358
357
                if (error == HA_ERR_KEY_NOT_FOUND || error == HA_ERR_END_OF_FILE)
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.
430
429
                const_result= 0;
431
430
                break;
432
431
              }
433
 
              error= table->cursor->startIndexScan(static_cast<uint32_t>(ref.key), 1);
 
432
              error= table->cursor->ha_index_init(static_cast<uint32_t>(ref.key), 1);
434
433
 
435
434
              if (! ref.key_length)
436
435
              {
460
459
                table->key_read= 0;
461
460
                table->cursor->extra(HA_EXTRA_NO_KEYREAD);
462
461
              }
463
 
              table->cursor->endIndexScan();
 
462
              table->cursor->ha_index_end();
464
463
              if (error)
465
464
              {
466
465
                if (error == HA_ERR_KEY_NOT_FOUND || error == HA_ERR_END_OF_FILE)
648
647
*/
649
648
static bool matching_cond(bool max_fl,
650
649
                          table_reference_st *ref,
651
 
                          KeyInfo *keyinfo,
652
 
                          KeyPartInfo *field_part,
 
650
                          KEY *keyinfo,
 
651
                          KEY_PART_INFO *field_part,
653
652
                          COND *cond,
654
653
                          key_part_map *key_part_used,
655
654
                          uint32_t *range_fl,
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;
749
748
 
750
749
  /* Check if field is part of the tested partial key */
751
750
  unsigned char *key_ptr= ref->key_buff;
752
 
  KeyPartInfo *part= NULL;
 
751
  KEY_PART_INFO *part= NULL;
753
752
  for (part= keyinfo->key_part; ; key_ptr+= part++->store_length)
754
753
 
755
754
  {
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
 
  KeyInfo *keyinfo,*keyinfo_end= NULL;
915
 
  for (keyinfo= table->key_info, keyinfo_end= keyinfo+table->getShare()->sizeKeys();
 
913
  KEY *keyinfo,*keyinfo_end= NULL;
 
914
  for (keyinfo= table->key_info, keyinfo_end= keyinfo+table->s->keys;
916
915
       keyinfo != keyinfo_end;
917
916
       keyinfo++,idx++)
918
917
  {
919
 
    KeyPartInfo *part= NULL;
920
 
    KeyPartInfo *part_end= NULL;
 
918
    KEY_PART_INFO *part= NULL;
 
919
    KEY_PART_INFO *part_end= NULL;
921
920
    key_part_map key_part_to_use= 0;
922
921
    /*
923
922
      Perform a check if index is not disabled by ALTER Table
939
938
      }
940
939
 
941
940
      /* Check whether the index component is partial */
942
 
      Field *part_field= table->getField(part->fieldnr-1);
 
941
      Field *part_field= table->field[part->fieldnr-1];
943
942
      part_field->setWriteSet();
944
943
 
945
944
      if ((part_field->flags & BLOB_FLAG) ||
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
  }