749
748
bool Field::is_null(ptrdiff_t row_offset) const
752
(null_ptr[row_offset] & null_bit ? true : false) :
750
return null_ptr ? (null_ptr[row_offset] & null_bit ? true : false) : table->null_row;
756
753
bool Field::is_real_null(ptrdiff_t row_offset) const
758
return null_ptr ? (null_ptr[row_offset] & null_bit ? true : false) : false;
755
return null_ptr && (null_ptr[row_offset] & null_bit);
761
758
bool Field::is_null_in_record(const unsigned char *record) const
765
return test(record[(uint32_t) (null_ptr -table->getInsertRecord())] & null_bit);
760
return null_ptr && test(record[(uint32_t) (null_ptr -table->getInsertRecord())] & null_bit);
768
763
bool Field::is_null_in_record_with_offset(ptrdiff_t with_offset) const
772
return test(null_ptr[with_offset] & null_bit);
765
return null_ptr && test(null_ptr[with_offset] & null_bit);
775
768
void Field::set_null(ptrdiff_t row_offset)
883
877
const charset_info_st * const cs)
887
880
enum_check_fields old_check_level= table->in_use->count_cuted_fields;
888
881
table->in_use->count_cuted_fields= check_level;
889
res= store(to, length, cs);
882
int res= store(to, length, cs);
890
883
table->in_use->count_cuted_fields= old_check_level;
902
895
unsigned char *Field::pack(unsigned char *to, const unsigned char *from)
904
unsigned char *result= this->pack(to, from, UINT32_MAX, table->getShare()->db_low_byte_first);
897
return this->pack(to, from, UINT32_MAX, table->getShare()->db_low_byte_first);
908
900
const unsigned char *Field::unpack(unsigned char* to,
940
932
const unsigned char *Field::unpack(unsigned char* to, const unsigned char *from)
942
const unsigned char *result= unpack(to, from, 0U, table->getShare()->db_low_byte_first);
934
return unpack(to, from, 0, table->getShare()->db_low_byte_first);
946
937
type::Decimal *Field::val_decimal(type::Decimal *) const
948
939
/* This never have to be called */
1015
1006
bool Field::get_date(type::Time <ime, uint32_t fuzzydate) const
1017
1008
char buff[type::Time::MAX_STRING_LENGTH];
1018
String tmp(buff,sizeof(buff),&my_charset_bin),*res;
1009
String tmp(buff,sizeof(buff),&my_charset_bin);
1020
1011
assert(getTable() and getTable()->getSession());
1022
if (not (res= val_str_internal(&tmp)) or
1023
str_to_datetime_with_warn(getTable()->getSession(),
1024
res->ptr(), res->length(),
1025
<ime, fuzzydate) <= type::DRIZZLE_TIMESTAMP_ERROR)
1013
String* res= val_str_internal(&tmp);
1014
return not res or str_to_datetime_with_warn(getTable()->getSession(), res->ptr(), res->length(), <ime, fuzzydate) <= type::DRIZZLE_TIMESTAMP_ERROR;
1033
1017
bool Field::get_time(type::Time <ime) const
1035
1019
char buff[type::Time::MAX_STRING_LENGTH];
1036
String tmp(buff,sizeof(buff),&my_charset_bin),*res;
1038
if (not (res= val_str_internal(&tmp)) or
1039
str_to_time_with_warn(getTable()->getSession(), res->ptr(), res->length(), <ime))
1020
String tmp(buff,sizeof(buff),&my_charset_bin);
1022
String* res= val_str_internal(&tmp);
1023
return not res or str_to_time_with_warn(getTable()->getSession(), res->ptr(), res->length(), <ime);
1047
1026
int Field::store_time(type::Time <ime, type::timestamp_t)
1051
1029
ltime.convert(tmp);
1053
1030
return store(tmp.ptr(), tmp.length(), &my_charset_bin);
1061
1038
Field *Field::new_field(memory::Root *root, Table *new_table, bool)
1064
if (!(tmp= (Field*) root->memdup_root((char*) this,size_of())))
1040
Field* tmp= (Field*) root->memdup_root((char*) this,size_of());
1067
1041
if (tmp->table->maybe_null)
1068
1042
tmp->flags&= ~NOT_NULL_FLAG;
1069
1043
tmp->table= new_table;
1081
1055
unsigned char *new_null_ptr,
1082
1056
uint32_t new_null_bit)
1085
if ((tmp= new_field(root, new_table, table == new_table)))
1088
tmp->null_ptr= new_null_ptr;
1089
tmp->null_bit= new_null_bit;
1058
Field *tmp= new_field(root, new_table, table == new_table);
1060
tmp->null_ptr= new_null_ptr;
1061
tmp->null_bit= new_null_bit;
1094
1065
Field *Field::clone(memory::Root *root, Table *new_table)
1097
if ((tmp= (Field*) root->memdup_root((char*) this,size_of())))
1099
tmp->init(new_table);
1100
tmp->move_field_offset((ptrdiff_t) (new_table->getInsertRecord() -
1101
new_table->getDefaultValues()));
1067
Field *tmp= (Field*) root->memdup_root((char*) this,size_of());
1068
tmp->init(new_table);
1069
tmp->move_field_offset((ptrdiff_t) (new_table->getInsertRecord() - new_table->getDefaultValues()));
1107
1073
uint32_t Field::is_equal(CreateField *new_field_ptr)
1109
return (new_field_ptr->sql_type == real_type());
1075
return new_field_ptr->sql_type == real_type();
1112
1078
bool Field::eq_def(Field *field)
1114
if (real_type() != field->real_type() || charset() != field->charset() ||
1115
pack_length() != field->pack_length())
1080
return real_type() == field->real_type() && charset() == field->charset() && pack_length() == field->pack_length();
1120
1083
bool Field_enum::eq_def(Field *field)
1130
1093
for (uint32_t i=0 ; i < from_lib->count ; i++)
1132
1095
if (my_strnncoll(field_charset,
1133
(const unsigned char*)typelib->type_names[i],
1134
strlen(typelib->type_names[i]),
1135
(const unsigned char*)from_lib->type_names[i],
1136
strlen(from_lib->type_names[i])))
1096
(const unsigned char*)typelib->type_names[i], strlen(typelib->type_names[i]),
1097
(const unsigned char*)from_lib->type_names[i], strlen(from_lib->type_names[i])))
1143
1104
uint32_t calc_pack_length(enum_field_types type,uint32_t length)
1146
1108
case DRIZZLE_TYPE_VARCHAR: return (length + (length < 256 ? 1: 2));
1147
1109
case DRIZZLE_TYPE_UUID: return field::Uuid::max_string_length();
1148
1110
case DRIZZLE_TYPE_MICROTIME: return field::Microtime::max_string_length();
1168
1130
uint32_t pack_length_to_packflag(uint32_t type)
1171
case 1: return 1 << FIELDFLAG_PACK_SHIFT;
1174
case 4: return f_settype(DRIZZLE_TYPE_LONG);
1175
case 8: return f_settype(DRIZZLE_TYPE_LONGLONG);
1134
case 1: return 1 << FIELDFLAG_PACK_SHIFT;
1137
case 4: return f_settype(DRIZZLE_TYPE_LONG);
1138
case 8: return f_settype(DRIZZLE_TYPE_LONGLONG);
1177
1141
return 0; // This shouldn't happen