~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field_iterator.cc

  • Committer: Monty Taylor
  • Date: 2008-10-23 00:05:28 UTC
  • Revision ID: monty@inaugust.com-20081023000528-grdvrd8c4058nutm
Moved my_handler to myisam, which is where it actually belongs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems
5
 
 *
6
 
 *  This program is free software; you can redistribute it and/or modify
7
 
 *  it under the terms of the GNU General Public License as published by
8
 
 *  the Free Software Foundation; version 2 of the License.
9
 
 *
10
 
 *  This program is distributed in the hope that it will be useful,
11
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 *  GNU General Public License for more details.
14
 
 *
15
 
 *  You should have received a copy of the GNU General Public License
16
 
 *  along with this program; if not, write to the Free Software
17
 
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 
 */
19
 
 
20
 
#include "config.h"
 
1
#include <drizzled/server_includes.h>
21
2
#include <drizzled/field_iterator.h>
22
 
#include <drizzled/table_list.h>
23
 
#include <drizzled/session.h>
24
 
#include <drizzled/table.h>
25
 
 
26
 
namespace drizzled
27
 
{
28
3
 
29
4
const char *Field_iterator_table::name()
30
5
{
32
7
}
33
8
 
34
9
 
35
 
void Field_iterator_table::set(TableList *table)
36
 
{
37
 
  ptr= table->table->getFields();
 
10
 
 
11
void Field_iterator_table::set(TableList *table) 
 
12
 
13
  ptr= table->table->field; 
38
14
}
39
15
 
40
16
 
41
 
void Field_iterator_table::set_table(Table *table)
42
 
{
43
 
  ptr= table->getFields();
 
17
void Field_iterator_table::set_table(Table *table) 
 
18
 
19
  ptr= table->field; 
44
20
}
45
21
 
46
22
 
47
23
Item *Field_iterator_table::create_item(Session *session)
48
24
{
49
 
  Select_Lex *select= session->lex->current_select;
 
25
  SELECT_LEX *select= session->lex->current_select;
50
26
 
51
27
  Item_field *item= new Item_field(session, &select->context, *ptr);
52
28
 
 
29
#ifdef DEAD_CODE
 
30
 
 
31
  if (item && session->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY &&
 
32
      !session->lex->in_sum_func && select->cur_pos_in_select_list != UNDEF_POS)
 
33
  {
 
34
    select->non_agg_fields.push_back(item);
 
35
    item->marker= select->cur_pos_in_select_list;
 
36
  }
 
37
#endif
 
38
 
53
39
  return item;
54
40
}
55
41
 
67
53
  cur_column_ref= column_ref_it++;
68
54
  assert(!cur_column_ref || ! cur_column_ref->table_field ||
69
55
              cur_column_ref->table_ref->table ==
70
 
              cur_column_ref->table_field->getTable());
 
56
              cur_column_ref->table_field->table);
71
57
}
72
58
 
73
59
 
82
68
  */
83
69
  if (table_ref->is_join_columns_complete)
84
70
  {
 
71
    /* Necesary, but insufficient conditions. */
 
72
    assert(table_ref->is_natural_join ||
 
73
                table_ref->nested_join ||
 
74
                ((table_ref->join_columns && /* This is a merge view. */ (table_ref->field_translation && table_ref->join_columns->elements == (ulong)(table_ref->field_translation_end - table_ref->field_translation))) ||
 
75
                 /* This is stored table or a tmptable view. */
 
76
                 (!table_ref->field_translation && table_ref->join_columns->elements == table_ref->table->s->fields)));
85
77
    field_it= &natural_join_it;
86
78
  }
87
79
  /* This is a base table or stored view. */
129
121
    return natural_join_it.column_ref()->table_name();
130
122
 
131
123
  assert(!strcmp(table_ref->table_name,
132
 
                      table_ref->table->getShare()->getTableName()));
 
124
                      table_ref->table->s->table_name.str));
133
125
  return table_ref->table_name;
134
126
}
135
127
 
140
132
    return natural_join_it.column_ref()->db_name();
141
133
 
142
134
  /*
143
 
    Test that TableList::db is the same as TableShare::db to
144
 
    ensure consistency. 
 
135
    Test that TableList::db is the same as st_table_share::db to
 
136
    ensure consistency. An exception are I_S schema tables, which
 
137
    are inconsistent in this respect.
145
138
  */
146
 
  assert(!strcmp(table_ref->db, table_ref->table->getShare()->getSchemaName()));
 
139
  assert(!strcmp(table_ref->db, table_ref->table->s->db.str) ||
 
140
              (table_ref->schema_table &&
 
141
               table_ref->table->s->db.str[0] == 0));
 
142
 
147
143
  return table_ref->db;
148
144
}
149
145
 
200
196
    /* The field belongs to a stored table. */
201
197
    Field *tmp_field= table_field_it.field();
202
198
    nj_col= new Natural_join_column(tmp_field, table_ref);
203
 
    field_count= table_ref->table->getShare()->sizeFields();
 
199
    field_count= table_ref->table->s->fields;
204
200
  }
205
201
  else
206
202
  {
215
211
    assert(nj_col);
216
212
  }
217
213
  assert(!nj_col->table_field ||
218
 
              nj_col->table_ref->table == nj_col->table_field->getTable());
 
214
              nj_col->table_ref->table == nj_col->table_field->table);
219
215
 
220
216
  /*
221
217
    If the natural join column was just created add it to the list of
280
276
  nj_col= natural_join_it.column_ref();
281
277
  assert(nj_col &&
282
278
              (!nj_col->table_field ||
283
 
               nj_col->table_ref->table == nj_col->table_field->getTable()));
 
279
               nj_col->table_ref->table == nj_col->table_field->table));
284
280
  return nj_col;
285
281
}
286
282
 
287
 
} /* namespace drizzled */