~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field_iterator.cc

  • Committer: devananda
  • Date: 2009-07-01 17:38:47 UTC
  • mto: (1093.1.7 captain)
  • mto: This revision was merged to the branch mainline in revision 1095.
  • Revision ID: devananda.vdv@gmail.com-20090701173847-3n3mbtessg5ff35e
refactored function/benchmark into plugin/benchmark

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 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 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
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include <config.h>
 
20
#include <drizzled/server_includes.h>
21
21
#include <drizzled/field_iterator.h>
22
22
#include <drizzled/table_list.h>
23
23
#include <drizzled/session.h>
24
24
#include <drizzled/table.h>
25
25
 
26
 
namespace drizzled
27
 
{
28
 
 
29
26
const char *Field_iterator_table::name()
30
27
{
31
28
  return (*ptr)->field_name;
34
31
 
35
32
void Field_iterator_table::set(TableList *table)
36
33
{
37
 
  ptr= table->table->getFields();
 
34
  ptr= table->table->field;
38
35
}
39
36
 
40
37
 
41
38
void Field_iterator_table::set_table(Table *table)
42
39
{
43
 
  ptr= table->getFields();
 
40
  ptr= table->field;
44
41
}
45
42
 
46
43
 
47
44
Item *Field_iterator_table::create_item(Session *session)
48
45
{
49
 
  Select_Lex *select= session->getLex()->current_select;
 
46
  Select_Lex *select= session->lex->current_select;
50
47
 
51
48
  Item_field *item= new Item_field(session, &select->context, *ptr);
52
49
 
57
54
void Field_iterator_natural_join::set(TableList *table_ref)
58
55
{
59
56
  assert(table_ref->join_columns);
60
 
  column_ref_it= table_ref->join_columns->begin();
 
57
  column_ref_it.init(*(table_ref->join_columns));
61
58
  cur_column_ref= column_ref_it++;
62
59
}
63
60
 
67
64
  cur_column_ref= column_ref_it++;
68
65
  assert(!cur_column_ref || ! cur_column_ref->table_field ||
69
66
              cur_column_ref->table_ref->table ==
70
 
              cur_column_ref->table_field->getTable());
 
67
              cur_column_ref->table_field->table);
71
68
}
72
69
 
73
70
 
128
125
  if (table_ref->is_natural_join)
129
126
    return natural_join_it.column_ref()->table_name();
130
127
 
131
 
  assert(!strcmp(table_ref->getTableName(),
132
 
                 table_ref->table->getShare()->getTableName()));
133
 
  return table_ref->getTableName();
 
128
  assert(!strcmp(table_ref->table_name,
 
129
                      table_ref->table->s->table_name.str));
 
130
  return table_ref->table_name;
134
131
}
135
132
 
136
133
 
141
138
 
142
139
  /*
143
140
    Test that TableList::db is the same as TableShare::db to
144
 
    ensure consistency. 
 
141
    ensure consistency. An exception are I_S schema tables, which
 
142
    are inconsistent in this respect.
145
143
  */
146
 
  assert(!strcmp(table_ref->getSchemaName(), table_ref->table->getShare()->getSchemaName()));
147
 
  return table_ref->getSchemaName();
 
144
  assert(!strcmp(table_ref->db, table_ref->table->s->db.str) ||
 
145
              (table_ref->schema_table &&
 
146
               table_ref->table->s->db.str[0] == 0));
 
147
 
 
148
  return table_ref->db;
148
149
}
149
150
 
150
151
 
200
201
    /* The field belongs to a stored table. */
201
202
    Field *tmp_field= table_field_it.field();
202
203
    nj_col= new Natural_join_column(tmp_field, table_ref);
203
 
    field_count= table_ref->table->getShare()->sizeFields();
 
204
    field_count= table_ref->table->s->fields;
204
205
  }
205
206
  else
206
207
  {
215
216
    assert(nj_col);
216
217
  }
217
218
  assert(!nj_col->table_field ||
218
 
              nj_col->table_ref->table == nj_col->table_field->getTable());
 
219
              nj_col->table_ref->table == nj_col->table_field->table);
219
220
 
220
221
  /*
221
222
    If the natural join column was just created add it to the list of
280
281
  nj_col= natural_join_it.column_ref();
281
282
  assert(nj_col &&
282
283
              (!nj_col->table_field ||
283
 
               nj_col->table_ref->table == nj_col->table_field->getTable()));
 
284
               nj_col->table_ref->table == nj_col->table_field->table));
284
285
  return nj_col;
285
286
}
286
287
 
287
 
} /* namespace drizzled */