~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field.cc

  • Committer: Brian Aker
  • Date: 2011-01-18 07:21:16 UTC
  • mfrom: (2079.3.3 session-fix)
  • Revision ID: brian@tangent.org-20110118072116-nuflltzguzhq9rgg
Merge in update so that test-run.pl runs all of test/suite and fix for
create table like and FK.

Show diffs side-by-side

added added

removed removed

Lines of Context:
827
827
             unsigned char *null_ptr_arg,
828
828
             unsigned char null_bit_arg,
829
829
             utype unireg_check_arg, 
830
 
             const char *field_name_arg) :
 
830
             const char *field_name_arg)
 
831
  :
831
832
    ptr(ptr_arg),
832
833
    null_ptr(null_ptr_arg),
833
834
    table(NULL),
834
835
    orig_table(NULL),
835
836
    field_name(field_name_arg),
836
 
    comment(NULL_LEX_STRING),
837
837
    key_start(0),
838
838
    part_of_key(0),
839
839
    part_of_key_not_clustered(0),
840
840
    part_of_sortkey(0),
841
841
    unireg_check(unireg_check_arg),
842
842
    field_length(length_arg),
843
 
    flags(null_ptr ? 0: NOT_NULL_FLAG),
844
 
    field_index(0),
845
843
    null_bit(null_bit_arg),
846
844
    is_created_from_null_item(false)
847
845
{
 
846
  flags= null_ptr ? 0: NOT_NULL_FLAG;
 
847
  comment.str= (char*) "";
 
848
  comment.length= 0;
 
849
  field_index= 0;
848
850
}
849
851
 
850
852
void Field::hash(uint32_t *nr, uint32_t *nr2)
997
999
  {
998
1000
    copy->blob_field=(Field_blob*) this;
999
1001
    copy->strip=0;
1000
 
    copy->length-= table->getShare()->sizeBlobPtr();
 
1002
    copy->length-= table->getShare()->blob_ptr_size;
1001
1003
    return copy->length;
1002
1004
  }
1003
1005
  else
1008
1010
  return copy->length+ store_length;
1009
1011
}
1010
1012
 
1011
 
bool Field::get_date(type::Time &ltime, uint32_t fuzzydate)
1012
 
{
1013
 
  char buff[type::Time::MAX_STRING_LENGTH];
1014
 
  String tmp(buff,sizeof(buff),&my_charset_bin),*res;
1015
 
 
1016
 
  assert(getTable() and getTable()->getSession());
1017
 
 
1018
 
  if (not (res=val_str_internal(&tmp)) or
1019
 
      str_to_datetime_with_warn(getTable()->getSession(),
1020
 
                                res->ptr(), res->length(),
1021
 
                                &ltime, fuzzydate) <= type::DRIZZLE_TIMESTAMP_ERROR)
1022
 
  {
1023
 
    return true;
1024
 
  }
1025
 
 
1026
 
  return false;
1027
 
}
1028
 
 
1029
 
bool Field::get_time(type::Time &ltime)
1030
 
{
1031
 
  char buff[type::Time::MAX_STRING_LENGTH];
1032
 
  String tmp(buff,sizeof(buff),&my_charset_bin),*res;
1033
 
 
1034
 
  if (not (res= val_str_internal(&tmp)) or
1035
 
      str_to_time_with_warn(getTable()->getSession(), res->ptr(), res->length(), &ltime))
1036
 
  {
1037
 
    return true;
1038
 
  }
1039
 
 
1040
 
  return false;
1041
 
}
1042
 
 
1043
 
int Field::store_time(type::Time &ltime, type::timestamp_t)
1044
 
{
1045
 
  String tmp;
1046
 
 
1047
 
  ltime.convert(tmp);
1048
 
 
1049
 
  return store(tmp.ptr(), tmp.length(), &my_charset_bin);
 
1013
bool Field::get_date(type::Time *ltime,uint32_t fuzzydate)
 
1014
{
 
1015
  char buff[40];
 
1016
  String tmp(buff,sizeof(buff),&my_charset_bin),*res;
 
1017
  if (!(res=val_str_internal(&tmp)) || str_to_datetime_with_warn(res->ptr(), res->length(),
 
1018
                                                                 ltime, fuzzydate) <= DRIZZLE_TIMESTAMP_ERROR)
 
1019
  {
 
1020
    return 1;
 
1021
  }
 
1022
 
 
1023
  return 0;
 
1024
}
 
1025
 
 
1026
bool Field::get_time(type::Time *ltime)
 
1027
{
 
1028
  char buff[40];
 
1029
  String tmp(buff,sizeof(buff),&my_charset_bin),*res;
 
1030
 
 
1031
  if (!(res=val_str_internal(&tmp)) || str_to_time_with_warn(res->ptr(), res->length(), ltime))
 
1032
  {
 
1033
    return 1;
 
1034
  }
 
1035
 
 
1036
  return 0;
 
1037
}
 
1038
 
 
1039
int Field::store_time(type::Time *ltime, enum enum_drizzle_timestamp_type)
 
1040
{
 
1041
  char buff[MAX_DATE_STRING_REP_LENGTH];
 
1042
  uint32_t length= (uint32_t) my_TIME_to_str(ltime, buff);
 
1043
  return store(buff, length, &my_charset_bin);
1050
1044
}
1051
1045
 
1052
1046
bool Field::optimize_range(uint32_t idx, uint32_t)
1201
1195
                                 drizzled::error_t code,
1202
1196
                                 const char *str, 
1203
1197
                                 uint32_t str_length,
1204
 
                                 type::timestamp_t ts_type, 
 
1198
                                 enum enum_drizzle_timestamp_type ts_type, 
1205
1199
                                 int cuted_increment)
1206
1200
{
1207
 
  Session *session= (getTable() and getTable()->getSession()) ? getTable()->getSession() : current_session;
1208
 
 
1209
 
  if ((session->abortOnWarning() and
 
1201
  Session *session= table ? table->in_use : current_session;
 
1202
  if ((session->really_abort_on_warning() &&
1210
1203
       level >= DRIZZLE_ERROR::WARN_LEVEL_WARN) ||
1211
1204
      set_warning(level, code, cuted_increment))
1212
1205
    make_truncated_value_warning(session, level, str, str_length, ts_type,
1216
1209
void Field::set_datetime_warning(DRIZZLE_ERROR::enum_warning_level level, 
1217
1210
                                 drizzled::error_t code,
1218
1211
                                 int64_t nr, 
1219
 
                                 type::timestamp_t ts_type,
 
1212
                                 enum enum_drizzle_timestamp_type ts_type,
1220
1213
                                 int cuted_increment)
1221
1214
{
1222
 
  Session *session= (getTable() and getTable()->getSession()) ? getTable()->getSession() : current_session;
1223
 
 
1224
 
  if (session->abortOnWarning() or
 
1215
  Session *session= table ? table->in_use : current_session;
 
1216
  if (session->really_abort_on_warning() ||
1225
1217
      set_warning(level, code, cuted_increment))
1226
1218
  {
1227
 
    char str_nr[DECIMAL_LONGLONG_DIGITS];
 
1219
    char str_nr[22];
1228
1220
    char *str_end= internal::int64_t10_to_str(nr, str_nr, -10);
1229
1221
    make_truncated_value_warning(session, level, str_nr, (uint32_t) (str_end - str_nr),
1230
1222
                                 ts_type, field_name);
1234
1226
void Field::set_datetime_warning(DRIZZLE_ERROR::enum_warning_level level,
1235
1227
                                 const drizzled::error_t code,
1236
1228
                                 double nr, 
1237
 
                                 type::timestamp_t ts_type)
 
1229
                                 enum enum_drizzle_timestamp_type ts_type)
1238
1230
{
1239
 
  Session *session= (getTable() and getTable()->getSession()) ? getTable()->getSession() : current_session;
1240
 
 
1241
 
  if (session->abortOnWarning() or
 
1231
  Session *session= table ? table->in_use : current_session;
 
1232
  if (session->really_abort_on_warning() ||
1242
1233
      set_warning(level, code, 1))
1243
1234
  {
1244
1235
    /* DBL_DIG is enough to print '-[digits].E+###' */