665
666
unsigned char *Field::pack(unsigned char *to, const unsigned char *from)
667
unsigned char *result= this->pack(to, from, UINT32_MAX, table->s->db_low_byte_first);
668
unsigned char *result= this->pack(to, from, UINT32_MAX, table->getShare()->db_low_byte_first);
703
704
const unsigned char *Field::unpack(unsigned char* to, const unsigned char *from)
705
const unsigned char *result= unpack(to, from, 0U, table->s->db_low_byte_first);
706
const unsigned char *result= unpack(to, from, 0U, table->getShare()->db_low_byte_first);
717
718
void Field::make_field(SendField *field)
719
if (orig_table && orig_table->s->getSchemaName() && *orig_table->s->getSchemaName())
720
if (orig_table && orig_table->getShare()->getSchemaName() && *orig_table->getShare()->getSchemaName())
721
field->db_name= orig_table->s->getSchemaName();
722
field->org_table_name= orig_table->s->table_name.str;
722
field->db_name= orig_table->getMutableShare()->getSchemaName();
723
field->org_table_name= orig_table->getMutableShare()->getTableName();
725
726
field->org_table_name= field->db_name= "";
844
845
Field *Field::clone(memory::Root *root, Table *new_table)
847
if ((tmp= (Field*) memdup_root(root,(char*) this,size_of())))
848
if ((tmp= (Field*) root->memdup_root((char*) this,size_of())))
849
850
tmp->init(new_table);
850
851
tmp->move_field_offset((ptrdiff_t) (new_table->record[0] -
851
new_table->s->default_values));
852
new_table->getDefaultValues()));
917
918
return 0; // This shouldn't happen
920
Field *make_field(TableShare *share,
923
uint32_t field_length,
925
unsigned char *null_pos,
926
unsigned char null_bit,
928
enum_field_types field_type,
929
const CHARSET_INFO * field_charset,
930
Field::utype unireg_check,
932
const char *field_name)
935
root= current_mem_root();
944
null_bit= ((unsigned char) 1) << null_bit;
949
case DRIZZLE_TYPE_DATE:
950
case DRIZZLE_TYPE_DATETIME:
951
case DRIZZLE_TYPE_TIMESTAMP:
952
field_charset= &my_charset_bin;
956
if (field_type == DRIZZLE_TYPE_VARCHAR ||
957
field_type == DRIZZLE_TYPE_BLOB ||
958
field_type == DRIZZLE_TYPE_ENUM)
960
if (field_type == DRIZZLE_TYPE_VARCHAR)
961
return new (root) Field_varstring(ptr,field_length,
962
HA_VARCHAR_PACKLENGTH(field_length),
968
if (field_type == DRIZZLE_TYPE_BLOB)
970
return new (root) Field_blob(ptr,
975
calc_pack_length(DRIZZLE_TYPE_LONG, 0),
981
return new (root) Field_enum(ptr,
986
get_enum_pack_length(interval->count),
994
case DRIZZLE_TYPE_DECIMAL:
995
return new (root) Field_decimal(ptr,
1003
false /* is_unsigned */);
1004
case DRIZZLE_TYPE_DOUBLE:
1005
return new (root) Field_double(ptr,
1013
false /* is_unsigned */);
1014
case DRIZZLE_TYPE_LONG:
1015
return new (root) Field_long(ptr,
1022
false /* is_unsigned */);
1023
case DRIZZLE_TYPE_LONGLONG:
1024
return new (root) Field_int64_t(ptr,
1031
false /* is_unsigned */);
1032
case DRIZZLE_TYPE_TIMESTAMP:
1033
return new (root) Field_timestamp(ptr,
1041
case DRIZZLE_TYPE_DATE:
1042
return new (root) Field_date(ptr,
1047
case DRIZZLE_TYPE_DATETIME:
1048
return new (root) Field_datetime(ptr,
1053
case DRIZZLE_TYPE_NULL:
1054
return new (root) Field_null(ptr,
1058
default: // Impossible (Wrong version)
1064
921
/*****************************************************************************
1065
922
Warning handling
1066
923
*****************************************************************************/