~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/field.cc

  • Committer: Brian Aker
  • Date: 2011-02-12 06:56:00 UTC
  • mto: This revision was merged to the branch mainline in revision 2161.
  • Revision ID: brian@tangent.org-20110212065600-m6c68fybw51rflhj
Further strip out includes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
165
165
   have_privileges(0),
166
166
   any_privileges(0)
167
167
{
168
 
  Select_Lex *select= current_session->lex->current_select;
 
168
  Select_Lex *select= getSession().getLex()->current_select;
169
169
  collation.set(DERIVATION_IMPLICIT);
170
170
 
171
171
  if (select && select->parsing_place != IN_HAVING)
246
246
}
247
247
 
248
248
 
249
 
my_decimal *Item_field::val_decimal(my_decimal *decimal_value)
 
249
type::Decimal *Item_field::val_decimal(type::Decimal *decimal_value)
250
250
{
251
251
  if ((null_value= field->is_null()))
252
252
    return 0;
262
262
  return result_field->val_str(str,&str_value);
263
263
}
264
264
 
265
 
bool Item_field::get_date(DRIZZLE_TIME *ltime,uint32_t fuzzydate)
 
265
bool Item_field::get_date(type::Time &ltime,uint32_t fuzzydate)
266
266
{
267
267
  if ((null_value=field->is_null()) || field->get_date(ltime,fuzzydate))
268
268
  {
269
 
    memset(ltime, 0, sizeof(*ltime));
 
269
    ltime.reset();
270
270
    return 1;
271
271
  }
272
272
  return 0;
273
273
}
274
274
 
275
 
bool Item_field::get_date_result(DRIZZLE_TIME *ltime,uint32_t fuzzydate)
 
275
bool Item_field::get_date_result(type::Time &ltime,uint32_t fuzzydate)
276
276
{
277
277
  if ((null_value=result_field->is_null()) ||
278
278
      result_field->get_date(ltime,fuzzydate))
279
279
  {
280
 
    memset(ltime, 0, sizeof(*ltime));
 
280
    ltime.reset();
281
281
    return 1;
282
282
  }
283
283
  return 0;
284
284
}
285
285
 
286
 
bool Item_field::get_time(DRIZZLE_TIME *ltime)
 
286
bool Item_field::get_time(type::Time &ltime)
287
287
{
288
288
  if ((null_value=field->is_null()) || field->get_time(ltime))
289
289
  {
290
 
    memset(ltime, 0, sizeof(*ltime));
 
290
    ltime.reset();
291
291
    return 1;
292
292
  }
293
293
  return 0;
308
308
}
309
309
 
310
310
 
311
 
my_decimal *Item_field::val_decimal_result(my_decimal *decimal_value)
 
311
type::Decimal *Item_field::val_decimal_result(type::Decimal *decimal_value)
312
312
{
313
313
  if ((null_value= result_field->is_null()))
314
314
    return 0;
319
319
bool Item_field::val_bool_result()
320
320
{
321
321
  if ((null_value= result_field->is_null()))
 
322
  {
322
323
    return false;
 
324
  }
 
325
 
323
326
  switch (result_field->result_type()) {
324
327
  case INT_RESULT:
325
328
    return result_field->val_int() != 0;
326
329
 
327
330
  case DECIMAL_RESULT:
328
331
    {
329
 
      my_decimal decimal_value;
330
 
      my_decimal *val= result_field->val_decimal(&decimal_value);
 
332
      type::Decimal decimal_value;
 
333
      type::Decimal *val= result_field->val_decimal(&decimal_value);
331
334
      if (val)
332
 
        return !my_decimal_is_zero(val);
 
335
        return not val->isZero();
333
336
      return 0;
334
337
    }
335
338
 
366
369
    (In cases where we would choose wrong we would have to generate a
367
370
    ER_NON_UNIQ_ERROR).
368
371
  */
369
 
  return (!my_strcasecmp(system_charset_info, item_field->name,
370
 
                         field_name) &&
371
 
          (!item_field->table_name || !table_name ||
372
 
           (!my_strcasecmp(table_alias_charset, item_field->table_name,
373
 
                           table_name) &&
374
 
            (!item_field->db_name || !db_name ||
375
 
             (item_field->db_name && !strcasecmp(item_field->db_name,
376
 
                                             db_name))))));
 
372
  return (not my_strcasecmp(system_charset_info, item_field->name, field_name) &&
 
373
          (not item_field->table_name || not table_name ||
 
374
           (not my_strcasecmp(table_alias_charset, item_field->table_name, table_name) &&
 
375
            (not item_field->db_name || not db_name ||
 
376
             (item_field->db_name && not my_strcasecmp(system_charset_info, item_field->db_name, db_name))))));
377
377
}
378
378
 
379
379
 
380
380
table_map Item_field::used_tables() const
381
381
{
382
382
  if (field->getTable()->const_table)
 
383
  {
383
384
    return 0;                                   // const item
 
385
  }
 
386
 
384
387
  return (depended_from ? OUTER_REF_TABLE_BIT : field->getTable()->map);
385
388
}
386
389
 
538
541
        if (*from_field != view_ref_found)
539
542
        {
540
543
          prev_subselect_item->used_tables_cache|= (*from_field)->getTable()->map;
541
 
          prev_subselect_item->const_item_cache= 0;
 
544
          prev_subselect_item->const_item_cache= false;
542
545
          set_field(*from_field);
543
546
          if (!last_checked_context->select_lex->having_fix_field &&
544
547
              select->group_list.elements &&
626
629
      case it does not matter which used tables bits we set)
627
630
    */
628
631
    prev_subselect_item->used_tables_cache|= OUTER_REF_TABLE_BIT;
629
 
    prev_subselect_item->const_item_cache= 0;
 
632
    prev_subselect_item->const_item_cache= false;
630
633
  }
631
634
 
632
635
  assert(ref != 0);
637
640
    if (upward_lookup)
638
641
    {
639
642
      // We can't say exactly what absent table or field
640
 
      my_error(ER_BAD_FIELD_ERROR, MYF(0), full_name(), session->where);
 
643
      my_error(ER_BAD_FIELD_ERROR, MYF(0), full_name(), session->where());
641
644
    }
642
645
    else
643
646
    {
821
824
            {
822
825
              /* The column to which we link isn't valid. */
823
826
              my_error(ER_BAD_FIELD_ERROR, MYF(0), (*res)->name,
824
 
                       current_session->where);
 
827
                       session->where());
825
828
              return(1);
826
829
            }
827
830