~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field_iterator.cc

  • Committer: Jay Pipes
  • Date: 2008-12-18 15:55:03 UTC
  • mto: This revision was merged to the branch mainline in revision 717.
  • Revision ID: jpipes@serialcoder-20081218155503-u45ygyunrdyyvquq
Fix for Bug#308457.  Gave UTF8 enclosure and escape character on LOAD DATA INFILE and changed the error message to be more descriptive

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
 
82
79
  */
83
80
  if (table_ref->is_join_columns_complete)
84
81
  {
 
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)));
85
94
    field_it= &natural_join_it;
86
95
  }
87
96
  /* This is a base table or stored view. */
128
137
  if (table_ref->is_natural_join)
129
138
    return natural_join_it.column_ref()->table_name();
130
139
 
131
 
  assert(!strcmp(table_ref->getTableName(),
132
 
                 table_ref->table->getShare()->getTableName()));
133
 
  return table_ref->getTableName();
 
140
  assert(!strcmp(table_ref->table_name,
 
141
                      table_ref->table->s->table_name.str));
 
142
  return table_ref->table_name;
134
143
}
135
144
 
136
145
 
140
149
    return natural_join_it.column_ref()->db_name();
141
150
 
142
151
  /*
143
 
    Test that TableList::db is the same as TableShare::db to
144
 
    ensure consistency. 
 
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.
145
155
  */
146
 
  assert(!strcmp(table_ref->getSchemaName(), table_ref->table->getShare()->getSchemaName()));
147
 
  return table_ref->getSchemaName();
 
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;
148
161
}
149
162
 
150
163
 
200
213
    /* The field belongs to a stored table. */
201
214
    Field *tmp_field= table_field_it.field();
202
215
    nj_col= new Natural_join_column(tmp_field, table_ref);
203
 
    field_count= table_ref->table->getShare()->sizeFields();
 
216
    field_count= table_ref->table->s->fields;
204
217
  }
205
218
  else
206
219
  {
215
228
    assert(nj_col);
216
229
  }
217
230
  assert(!nj_col->table_field ||
218
 
              nj_col->table_ref->table == nj_col->table_field->getTable());
 
231
              nj_col->table_ref->table == nj_col->table_field->table);
219
232
 
220
233
  /*
221
234
    If the natural join column was just created add it to the list of
280
293
  nj_col= natural_join_it.column_ref();
281
294
  assert(nj_col &&
282
295
              (!nj_col->table_field ||
283
 
               nj_col->table_ref->table == nj_col->table_field->getTable()));
 
296
               nj_col->table_ref->table == nj_col->table_field->table));
284
297
  return nj_col;
285
298
}
286
299
 
287
 
} /* namespace drizzled */