~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/field.cc

  • Committer: Brian Aker
  • Date: 2010-02-14 01:56:51 UTC
  • mto: (1273.16.5 fix_is)
  • mto: This revision was merged to the branch mainline in revision 1300.
  • Revision ID: brian@gaz-20100214015651-ror9j0xu7dccz0ct
Two fixes for "make dist"

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
#include <drizzled/item/outer_ref.h>
31
31
#include <drizzled/plugin/client.h>
32
32
 
33
 
#include <boost/dynamic_bitset.hpp>
34
 
 
35
33
namespace drizzled
36
34
{
37
35
 
86
84
 
87
85
bool Item_field::find_item_in_field_list_processor(unsigned char *arg)
88
86
{
89
 
  KeyPartInfo *first_non_group_part= *((KeyPartInfo **) arg);
90
 
  KeyPartInfo *last_part= *(((KeyPartInfo **) arg) + 1);
91
 
  KeyPartInfo *cur_part;
 
87
  KEY_PART_INFO *first_non_group_part= *((KEY_PART_INFO **) arg);
 
88
  KEY_PART_INFO *last_part= *(((KEY_PART_INFO **) arg) + 1);
 
89
  KEY_PART_INFO *cur_part;
92
90
 
93
91
  for (cur_part= first_non_group_part; cur_part != last_part; cur_part++)
94
92
  {
110
108
bool Item_field::register_field_in_read_map(unsigned char *arg)
111
109
{
112
110
  Table *table= (Table *) arg;
113
 
  if (field->getTable() == table || !table)
114
 
    field->getTable()->setReadSet(field->field_index);
 
111
  if (field->table == table || !table)
 
112
    field->table->setReadSet(field->field_index);
115
113
 
116
114
  return 0;
117
115
}
118
116
 
119
117
 
120
118
Item_field::Item_field(Field *f)
121
 
  :Item_ident(0, NULL, f->getTable()->getAlias(), f->field_name),
 
119
  :Item_ident(0, NULL, *f->table_name, f->field_name),
122
120
   item_equal(0), no_const_subst(0),
123
121
   have_privileges(0), any_privileges(0)
124
122
{
138
136
  Item_field (this is important in prepared statements).
139
137
*/
140
138
 
141
 
Item_field::Item_field(Session *,
142
 
                       Name_resolution_context *context_arg,
143
 
                       Field *f) :
144
 
  Item_ident(context_arg,
145
 
             f->getTable()->getShare()->getSchemaName(),
146
 
             f->getTable()->getAlias(),
147
 
             f->field_name),
148
 
   item_equal(0),
149
 
   no_const_subst(0),
150
 
   have_privileges(0),
151
 
   any_privileges(0)
 
139
Item_field::Item_field(Session *, Name_resolution_context *context_arg,
 
140
                       Field *f)
 
141
  :Item_ident(context_arg, f->table->s->db.str, *f->table_name, f->field_name),
 
142
   item_equal(0), no_const_subst(0),
 
143
   have_privileges(0), any_privileges(0)
152
144
{
153
145
  set_field(f);
154
146
}
156
148
 
157
149
Item_field::Item_field(Name_resolution_context *context_arg,
158
150
                       const char *db_arg,const char *table_name_arg,
159
 
                       const char *field_name_arg) :
160
 
  Item_ident(context_arg, db_arg,table_name_arg,field_name_arg),
161
 
   field(0),
162
 
   result_field(0),
163
 
   item_equal(0),
164
 
   no_const_subst(0),
165
 
   have_privileges(0),
166
 
   any_privileges(0)
 
151
                       const char *field_name_arg)
 
152
  :Item_ident(context_arg, db_arg,table_name_arg,field_name_arg),
 
153
   field(0), result_field(0), item_equal(0), no_const_subst(0),
 
154
   have_privileges(0), any_privileges(0)
167
155
{
168
156
  Select_Lex *select= current_session->lex->current_select;
169
157
  collation.set(DERIVATION_IMPLICIT);
170
 
 
171
158
  if (select && select->parsing_place != IN_HAVING)
172
159
      select->select_n_where_fields++;
173
160
}
176
163
  Constructor need to process subselect with temporary tables (see Item)
177
164
*/
178
165
 
179
 
Item_field::Item_field(Session *session, Item_field *item) :
180
 
  Item_ident(session, item),
181
 
  field(item->field),
182
 
  result_field(item->result_field),
183
 
  item_equal(item->item_equal),
184
 
  no_const_subst(item->no_const_subst),
185
 
  have_privileges(item->have_privileges),
186
 
  any_privileges(item->any_privileges)
 
166
Item_field::Item_field(Session *session, Item_field *item)
 
167
  :Item_ident(session, item),
 
168
   field(item->field),
 
169
   result_field(item->result_field),
 
170
   item_equal(item->item_equal),
 
171
   no_const_subst(item->no_const_subst),
 
172
   have_privileges(item->have_privileges),
 
173
   any_privileges(item->any_privileges)
187
174
{
188
175
  collation.set(DERIVATION_IMPLICIT);
189
176
}
194
181
  maybe_null=field->maybe_null();
195
182
  decimals= field->decimals();
196
183
  max_length= field_par->max_display_length();
197
 
  table_name= field_par->getTable()->getAlias();
 
184
  table_name= *field_par->table_name;
198
185
  field_name= field_par->field_name;
199
 
  db_name= field_par->getTable()->getShare()->getSchemaName();
200
 
  alias_name_used= field_par->getTable()->alias_name_used;
 
186
  db_name= field_par->table->s->db.str;
 
187
  alias_name_used= field_par->table->alias_name_used;
201
188
  unsigned_flag=test(field_par->flags & UNSIGNED_FLAG);
202
189
  collation.set(field_par->charset(), field_par->derivation());
203
190
  fixed= 1;
 
191
  if (field->table->s->tmp_table == SYSTEM_TMP_TABLE)
 
192
    any_privileges= 0;
204
193
}
205
194
 
206
195
 
367
356
           (!my_strcasecmp(table_alias_charset, item_field->table_name,
368
357
                           table_name) &&
369
358
            (!item_field->db_name || !db_name ||
370
 
             (item_field->db_name && !strcasecmp(item_field->db_name,
 
359
             (item_field->db_name && !strcmp(item_field->db_name,
371
360
                                             db_name))))));
372
361
}
373
362
 
374
363
 
375
364
table_map Item_field::used_tables() const
376
365
{
377
 
  if (field->getTable()->const_table)
 
366
  if (field->table->const_table)
378
367
    return 0;                                   // const item
379
 
  return (depended_from ? OUTER_REF_TABLE_BIT : field->getTable()->map);
 
368
  return (depended_from ? OUTER_REF_TABLE_BIT : field->table->map);
380
369
}
381
370
 
382
371
enum Item_result Item_field::result_type () const
532
521
      {
533
522
        if (*from_field != view_ref_found)
534
523
        {
535
 
          prev_subselect_item->used_tables_cache|= (*from_field)->getTable()->map;
 
524
          prev_subselect_item->used_tables_cache|= (*from_field)->table->map;
536
525
          prev_subselect_item->const_item_cache= 0;
537
526
          set_field(*from_field);
538
527
          if (!last_checked_context->select_lex->having_fix_field &&
699
688
    {
700
689
      Item_ref *rf;
701
690
      rf= new Item_ref(context,
702
 
                       (cached_table->getSchemaName()[0] ? cached_table->getSchemaName() : 0),
 
691
                       (cached_table->db[0] ? cached_table->db : 0),
703
692
                       (char*) cached_table->alias, (char*) field_name);
704
693
      if (!rf)
705
694
        return -1;
791
780
      {
792
781
        uint32_t counter;
793
782
        enum_resolution_type resolution;
794
 
        Item** res= find_item_in_list(session,
795
 
                                      this, session->lex->current_select->item_list,
 
783
        Item** res= find_item_in_list(this, session->lex->current_select->item_list,
796
784
                                      &counter, REPORT_EXCEPT_NOT_FOUND,
797
785
                                      &resolution);
798
786
        if (!res)
890
878
  }
891
879
  else if (session->mark_used_columns != MARK_COLUMNS_NONE)
892
880
  {
893
 
    Table *table= field->getTable();
894
 
    boost::dynamic_bitset<> *current_bitmap, *other_bitmap;
 
881
    Table *table= field->table;
 
882
    MyBitmap *current_bitmap, *other_bitmap;
895
883
    if (session->mark_used_columns == MARK_COLUMNS_READ)
896
884
    {
897
885
      current_bitmap= table->read_set;
902
890
      current_bitmap= table->write_set;
903
891
      other_bitmap=   table->read_set;
904
892
    }
905
 
    //if (! current_bitmap->testAndSet(field->field_index))
906
 
    if (! current_bitmap->test(field->field_index))
 
893
    if (! current_bitmap->testAndSet(field->field_index))
907
894
    {
908
 
      if (! other_bitmap->test(field->field_index))
 
895
      if (! other_bitmap->isBitSet(field->field_index))
909
896
      {
910
897
        /* First usage of column */
911
898
        table->used_fields++;                     // Used to optimize loops
1203
1190
    need to set no_errors to prevent warnings about type conversion
1204
1191
    popping up.
1205
1192
  */
1206
 
  Session *session= field->getTable()->in_use;
 
1193
  Session *session= field->table->in_use;
1207
1194
  int no_errors;
1208
1195
 
1209
1196
  no_errors= session->no_errors;
1240
1227
  Select_Lex *select= (Select_Lex*)select_arg;
1241
1228
  assert(fixed);
1242
1229
 
1243
 
  if (field->getTable() != select->context.table_list->table)
 
1230
  if (field->table != select->context.table_list->table)
1244
1231
  {
1245
1232
    List<Item> *all_fields= &select->join->all_fields;
1246
1233
    Item **ref_pointer_array= select->ref_pointer_array;
1259
1246
 
1260
1247
void Item_field::print(String *str, enum_query_type query_type)
1261
1248
{
1262
 
  if (field && field->getTable()->const_table)
 
1249
  if (field && field->table->const_table)
1263
1250
  {
1264
1251
    char buff[MAX_FIELD_WIDTH];
1265
1252
    String tmp(buff,sizeof(buff),str->charset());
1266
 
    field->val_str_internal(&tmp);
1267
 
    if (field->is_null())  {
1268
 
      str->append("NULL");
1269
 
    }
1270
 
    else {
1271
 
      str->append('\'');
1272
 
      str->append(tmp);
1273
 
      str->append('\'');
1274
 
    }
 
1253
    field->val_str(&tmp);
 
1254
    str->append('\'');
 
1255
    str->append(tmp);
 
1256
    str->append('\'');
1275
1257
    return;
1276
1258
  }
1277
1259
  Item_ident::print(str, query_type);