~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/ref.cc

  • Committer: lbieber
  • Date: 2010-10-01 13:06:31 UTC
  • mfrom: (1802.2.2 drizzle-bug-651948)
  • mto: This revision was merged to the branch mainline in revision 1805.
  • Revision ID: lbieber@orisndriz08-20101001130631-xubscnhmj7r5dn6g
Merge Andrew - Fix bug 651948 - Index lengths not retrieved using drizzledump

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
132
132
      {
133
133
        /* The current reference cannot be resolved in this query. */
134
134
        my_error(ER_BAD_FIELD_ERROR,MYF(0),
135
 
                 full_name(), session->where());
 
135
                 this->full_name(), current_session->where);
136
136
        goto error;
137
137
      }
138
138
 
247
247
                       cached_table->select_lex != outer_context->select_lex);
248
248
            }
249
249
            prev_subselect_item->used_tables_cache|= from_field->getTable()->map;
250
 
            prev_subselect_item->const_item_cache= false;
 
250
            prev_subselect_item->const_item_cache= 0;
251
251
            break;
252
252
          }
253
253
        }
255
255
 
256
256
        /* Reference is not found => depend on outer (or just error). */
257
257
        prev_subselect_item->used_tables_cache|= OUTER_REF_TABLE_BIT;
258
 
        prev_subselect_item->const_item_cache= false;
 
258
        prev_subselect_item->const_item_cache= 0;
259
259
 
260
260
        outer_context= outer_context->outer_context;
261
261
      } while (outer_context);
285
285
      {
286
286
        /* The item was not a table field and not a reference */
287
287
        my_error(ER_BAD_FIELD_ERROR, MYF(0),
288
 
                 full_name(), session->where());
 
288
                 this->full_name(), current_session->where);
289
289
        goto error;
290
290
      }
291
291
      /* Should be checked in resolve_ref_in_select_and_group(). */
430
430
}
431
431
 
432
432
 
433
 
type::Decimal *Item_ref::val_decimal_result(type::Decimal *decimal_value)
 
433
my_decimal *Item_ref::val_decimal_result(my_decimal *decimal_value)
434
434
{
435
435
  if (result_field)
436
436
  {
451
451
    switch (result_field->result_type()) {
452
452
    case INT_RESULT:
453
453
      return result_field->val_int() != 0;
454
 
 
455
454
    case DECIMAL_RESULT:
456
 
      {
457
 
        type::Decimal decimal_value;
458
 
        type::Decimal *val= result_field->val_decimal(&decimal_value);
459
 
        if (val)
460
 
          return not val->isZero();
461
 
        return 0;
462
 
      }
463
 
 
 
455
    {
 
456
      my_decimal decimal_value;
 
457
      my_decimal *val= result_field->val_decimal(&decimal_value);
 
458
      if (val)
 
459
        return !my_decimal_is_zero(val);
 
460
      return 0;
 
461
    }
464
462
    case REAL_RESULT:
465
463
    case STRING_RESULT:
466
464
      return result_field->val_real() != 0.0;
467
 
 
468
465
    case ROW_RESULT:
 
466
    default:
469
467
      assert(0);
470
468
    }
471
469
  }
472
 
 
473
470
  return val_bool();
474
471
}
475
472
 
517
514
}
518
515
 
519
516
 
520
 
bool Item_ref::get_date(type::Time &ltime,uint32_t fuzzydate)
 
517
bool Item_ref::get_date(DRIZZLE_TIME *ltime,uint32_t fuzzydate)
521
518
{
522
519
  return (null_value=(*ref)->get_date_result(ltime,fuzzydate));
523
520
}
524
521
 
525
522
 
526
 
type::Decimal *Item_ref::val_decimal(type::Decimal *decimal_value)
 
523
my_decimal *Item_ref::val_decimal(my_decimal *decimal_value)
527
524
{
528
 
  type::Decimal *val= (*ref)->val_decimal_result(decimal_value);
 
525
  my_decimal *val= (*ref)->val_decimal_result(decimal_value);
529
526
  null_value= (*ref)->null_value;
530
527
  return val;
531
528
}