~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field_iterator.cc

  • Committer: Brian Aker
  • Date: 2010-12-08 22:35:56 UTC
  • mfrom: (1819.9.158 update-innobase)
  • Revision ID: brian@tangent.org-20101208223556-37mi4omqg7lkjzf3
Merge in Stewart's changes, 1.3 changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include <drizzled/server_includes.h>
 
20
#include "config.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
 
26
29
const char *Field_iterator_table::name()
27
30
{
28
31
  return (*ptr)->field_name;
31
34
 
32
35
void Field_iterator_table::set(TableList *table)
33
36
{
34
 
  ptr= table->table->field;
 
37
  ptr= table->table->getFields();
35
38
}
36
39
 
37
40
 
38
41
void Field_iterator_table::set_table(Table *table)
39
42
{
40
 
  ptr= table->field;
 
43
  ptr= table->getFields();
41
44
}
42
45
 
43
46
 
44
47
Item *Field_iterator_table::create_item(Session *session)
45
48
{
46
 
  SELECT_LEX *select= session->lex->current_select;
 
49
  Select_Lex *select= session->lex->current_select;
47
50
 
48
51
  Item_field *item= new Item_field(session, &select->context, *ptr);
49
52
 
64
67
  cur_column_ref= column_ref_it++;
65
68
  assert(!cur_column_ref || ! cur_column_ref->table_field ||
66
69
              cur_column_ref->table_ref->table ==
67
 
              cur_column_ref->table_field->table);
 
70
              cur_column_ref->table_field->getTable());
68
71
}
69
72
 
70
73
 
79
82
  */
80
83
  if (table_ref->is_join_columns_complete)
81
84
  {
82
 
    /* Necesary, but insufficient conditions. */
83
 
    assert(table_ref->is_natural_join ||
84
 
                table_ref->nested_join ||
85
 
                ((table_ref->join_columns && /* This is a merge view. */
86
 
                  (table_ref->field_translation &&
87
 
                   table_ref->join_columns->elements ==
88
 
                   (ulong)(table_ref->field_translation_end -
89
 
                           table_ref->field_translation))) ||
90
 
                 /* This is stored table or a tmptable view. */
91
 
                 (!table_ref->field_translation &&
92
 
                  table_ref->join_columns->elements ==
93
 
                  table_ref->table->s->fields)));
94
85
    field_it= &natural_join_it;
95
86
  }
96
87
  /* This is a base table or stored view. */
137
128
  if (table_ref->is_natural_join)
138
129
    return natural_join_it.column_ref()->table_name();
139
130
 
140
 
  assert(!strcmp(table_ref->table_name,
141
 
                      table_ref->table->s->table_name.str));
142
 
  return table_ref->table_name;
 
131
  assert(!strcmp(table_ref->getTableName(),
 
132
                 table_ref->table->getShare()->getTableName()));
 
133
  return table_ref->getTableName();
143
134
}
144
135
 
145
136
 
149
140
    return natural_join_it.column_ref()->db_name();
150
141
 
151
142
  /*
152
 
    Test that TableList::db is the same as st_table_share::db to
153
 
    ensure consistency. An exception are I_S schema tables, which
154
 
    are inconsistent in this respect.
 
143
    Test that TableList::db is the same as TableShare::db to
 
144
    ensure consistency. 
155
145
  */
156
 
  assert(!strcmp(table_ref->db, table_ref->table->s->db.str) ||
157
 
              (table_ref->schema_table &&
158
 
               table_ref->table->s->db.str[0] == 0));
159
 
 
160
 
  return table_ref->db;
 
146
  assert(!strcmp(table_ref->getSchemaName(), table_ref->table->getShare()->getSchemaName()));
 
147
  return table_ref->getSchemaName();
161
148
}
162
149
 
163
150
 
213
200
    /* The field belongs to a stored table. */
214
201
    Field *tmp_field= table_field_it.field();
215
202
    nj_col= new Natural_join_column(tmp_field, table_ref);
216
 
    field_count= table_ref->table->s->fields;
 
203
    field_count= table_ref->table->getShare()->sizeFields();
217
204
  }
218
205
  else
219
206
  {
228
215
    assert(nj_col);
229
216
  }
230
217
  assert(!nj_col->table_field ||
231
 
              nj_col->table_ref->table == nj_col->table_field->table);
 
218
              nj_col->table_ref->table == nj_col->table_field->getTable());
232
219
 
233
220
  /*
234
221
    If the natural join column was just created add it to the list of
293
280
  nj_col= natural_join_it.column_ref();
294
281
  assert(nj_col &&
295
282
              (!nj_col->table_field ||
296
 
               nj_col->table_ref->table == nj_col->table_field->table));
 
283
               nj_col->table_ref->table == nj_col->table_field->getTable()));
297
284
  return nj_col;
298
285
}
299
286
 
 
287
} /* namespace drizzled */