~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/ref.cc

  • Committer: Stewart Smith
  • Author(s): Marko Mäkelä, Stewart Smith
  • Date: 2010-11-17 05:52:09 UTC
  • mto: (2021.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 1971.
  • Revision ID: stewart@flamingspork.com-20101117055209-69m035q6h7e1txrc
Merge Revision revid:marko.makela@oracle.com-20100629113248-fvl48lnzr44z94gg from MySQL InnoDB

Original revid:marko.makela@oracle.com-20100629113248-fvl48lnzr44z94gg

Original Authors: Marko Mkel <marko.makela@oracle.com>
Original commit message:
Bug#52199 utf32: mbminlen=4, mbmaxlen=4, type->mbminlen=0, type->mbmaxlen=4

Merge and adjust a forgotten change to fix this bug.
rb://393 approved by Jimmy Yang
  ------------------------------------------------------------------------
  r3794 | marko | 2009-01-07 14:14:53 +0000 (Wed, 07 Jan 2009) | 18 lines

  branches/6.0: Allow the minimum length of a multi-byte character to be
  up to 4 bytes. (Bug #35391)

  dtype_t, dict_col_t: Replace mbminlen:2, mbmaxlen:3 with mbminmaxlen:5.
  In this way, the 5 bits can hold two values of 0..4, and the storage size
  of the fields will not cross the 64-bit boundary.  Encode the values as
  DATA_MBMAX * mbmaxlen + mbminlen.  Define the auxiliary macros
  DB_MBMINLEN(mbminmaxlen), DB_MBMAXLEN(mbminmaxlen), and
  DB_MINMAXLEN(mbminlen, mbmaxlen).

  Try to trim and pad UTF-16 and UTF-32 with spaces as appropriate.

  Alexander Barkov suggested the use of cs->cset->fill(cs, buff, len, 0x20).
  ha_innobase::store_key_val_for_row() now does that, but the added function
  row_mysql_pad_col() does not, because it doesn't have the MySQL TABLE object.

  rb://49 approved by Heikki Tuuri
  ------------------------------------------------------------------------

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
}