#include <field.h>
Inheritance diagram for Field_blob:


Public Member Functions | |
| Field_blob (char *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg, enum utype unireg_check_arg, const char *field_name_arg, TABLE_SHARE *share, uint blob_pack_length, CHARSET_INFO *cs) | |
| Field_blob (uint32 len_arg, bool maybe_null_arg, const char *field_name_arg, CHARSET_INFO *cs) | |
| Field_blob (uint32 len_arg, bool maybe_null_arg, const char *field_name_arg, CHARSET_INFO *cs, bool set_packlength) | |
| enum_field_types | type () const |
| enum ha_base_keytype | key_type () const |
| int | store (const char *to, uint length, CHARSET_INFO *charset) |
| int | store (double nr) |
| int | store (longlong nr, bool unsigned_val) |
| double | val_real (void) |
| longlong | val_int (void) |
| String * | val_str (String *, String *) |
| my_decimal * | val_decimal (my_decimal *) |
| int | cmp_max (const char *, const char *, uint max_length) |
| int | cmp (const char *a, const char *b) |
| int | cmp (const char *a, uint32 a_length, const char *b, uint32 b_length) |
| int | cmp_binary (const char *a, const char *b, uint32 max_length=~0L) |
| int | key_cmp (const byte *, const byte *) |
| int | key_cmp (const byte *str, uint length) |
| uint32 | key_length () const |
| void | sort_string (char *buff, uint length) |
| uint32 | pack_length () const |
| uint32 | sort_length () const |
| uint32 | max_data_length () const |
| void | reset (void) |
| void | reset_fields () |
| void | store_length (uint32 number) |
| uint32 | get_length (uint row_offset=0) |
| uint32 | get_length (const char *ptr) |
| void | put_length (char *pos, uint32 length) |
| void | get_ptr (char **str) |
| void | get_ptr (char **str, uint row_offset) |
| void | set_ptr (char *length, char *data) |
| void | set_ptr (uint32 length, char *data) |
| void | get_key_image (char *buff, uint length, imagetype type) |
| void | set_key_image (char *buff, uint length) |
| void | sql_type (String &str) const |
| bool | copy () |
| char * | pack (char *to, const char *from, uint max_length=~(uint) 0) |
| char * | pack_key (char *to, const char *from, uint max_length) |
| char * | pack_key_from_key_image (char *to, const char *from, uint max_length) |
| const char * | unpack (char *to, const char *from) |
| const char * | unpack_key (char *to, const char *from, uint max_length) |
| int | pack_cmp (const char *a, const char *b, uint key_length, my_bool insert_or_update) |
| int | pack_cmp (const char *b, uint key_length, my_bool insert_or_update) |
| uint | packed_col_length (const char *col_ptr, uint length) |
| uint | max_packed_col_length (uint max_length) |
| void | free () |
| void | clear_temporary () |
| uint | size_of () const |
| bool | has_charset (void) const |
| uint32 | max_length () |
Protected Attributes | |
| uint | packlength |
| String | value |
Friends | |
| void | field_conv (Field *to, Field *from) |
Definition at line 1143 of file field.h.
| Field_blob::Field_blob | ( | char * | ptr_arg, | |
| uchar * | null_ptr_arg, | |||
| uchar | null_bit_arg, | |||
| enum utype | unireg_check_arg, | |||
| const char * | field_name_arg, | |||
| TABLE_SHARE * | share, | |||
| uint | blob_pack_length, | |||
| CHARSET_INFO * | cs | |||
| ) |
Definition at line 6888 of file field.cc.
References st_table_share::blob_fields, BLOB_FLAG, and Field::flags.
06892 :Field_longstr(ptr_arg, BLOB_PACK_LENGTH_TO_MAX_LENGH(blob_pack_length), 06893 null_ptr_arg, null_bit_arg, unireg_check_arg, field_name_arg, 06894 cs), 06895 packlength(blob_pack_length) 06896 { 06897 flags|= BLOB_FLAG; 06898 share->blob_fields++; 06899 /* TODO: why do not fill table->s->blob_field array here? */ 06900 }
| Field_blob::Field_blob | ( | uint32 | len_arg, | |
| bool | maybe_null_arg, | |||
| const char * | field_name_arg, | |||
| CHARSET_INFO * | cs | |||
| ) | [inline] |
Definition at line 1151 of file field.h.
References BLOB_FLAG, and Field::flags.
01153 :Field_longstr((char*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0, 0, 01154 NONE, field_name_arg, cs), 01155 packlength(4) 01156 { 01157 flags|= BLOB_FLAG; 01158 }
| Field_blob::Field_blob | ( | uint32 | len_arg, | |
| bool | maybe_null_arg, | |||
| const char * | field_name_arg, | |||
| CHARSET_INFO * | cs, | |||
| bool | set_packlength | |||
| ) | [inline] |
Definition at line 1159 of file field.h.
References BLOB_FLAG, Field::char_length(), Field::flags, charset_info_st::mbmaxlen, and packlength.
01161 :Field_longstr((char*) 0,len_arg, maybe_null_arg ? (uchar*) "": 0, 0, 01162 NONE, field_name_arg, cs) 01163 { 01164 flags|= BLOB_FLAG; 01165 packlength= 4; 01166 if (set_packlength) 01167 { 01168 uint32 char_length= len_arg/cs->mbmaxlen; 01169 packlength= char_length <= 255 ? 1 : 01170 char_length <= 65535 ? 2 : 01171 char_length <= 16777215 ? 3 : 4; 01172 } 01173 }
Here is the call graph for this function:

| void Field_blob::clear_temporary | ( | ) | [inline] |
Definition at line 7145 of file field.cc.
References charset_info_st::coll, Field_str::field_charset, and my_collation_handler_st::strnncollsp.
07147 { 07148 return field_charset->coll->strnncollsp(field_charset, 07149 (const uchar*)a, a_length, 07150 (const uchar*)b, b_length, 07151 0); 07152 }
| int Field_blob::cmp | ( | const char * | a, | |
| const char * | b | |||
| ) | [inline, virtual] |
| int Field_blob::cmp_binary | ( | const char * | a, | |
| const char * | b, | |||
| uint32 | max_length = ~0L | |||
| ) | [virtual] |
Reimplemented from Field.
Definition at line 7168 of file field.cc.
References get_length(), int(), memcmp(), memcpy_fixed, min, and packlength.
07170 { 07171 char *a,*b; 07172 uint diff; 07173 uint32 a_length,b_length; 07174 memcpy_fixed(&a,a_ptr+packlength,sizeof(char*)); 07175 memcpy_fixed(&b,b_ptr+packlength,sizeof(char*)); 07176 a_length=get_length(a_ptr); 07177 if (a_length > max_length) 07178 a_length=max_length; 07179 b_length=get_length(b_ptr); 07180 if (b_length > max_length) 07181 b_length=max_length; 07182 diff=memcmp(a,b,min(a_length,b_length)); 07183 return diff ? diff : (int) (a_length - b_length); 07184 }
Here is the call graph for this function:

| int Field_blob::cmp_max | ( | const char * | , | |
| const char * | , | |||
| uint | max_length | |||
| ) | [virtual] |
Reimplemented from Field.
Definition at line 7155 of file field.cc.
References cmp(), get_length(), memcpy_fixed, packlength, and set_if_smaller.
Referenced by cmp().
07157 { 07158 char *blob1,*blob2; 07159 memcpy_fixed(&blob1,a_ptr+packlength,sizeof(char*)); 07160 memcpy_fixed(&blob2,b_ptr+packlength,sizeof(char*)); 07161 uint a_len= get_length(a_ptr), b_len= get_length(b_ptr); 07162 set_if_smaller(a_len, max_length); 07163 set_if_smaller(b_len, max_length); 07164 return Field_blob::cmp(blob1,a_len,blob2,b_len); 07165 }
Here is the call graph for this function:

Here is the caller graph for this function:

| bool Field_blob::copy | ( | ) | [inline] |
Definition at line 1228 of file field.h.
References Field_str::charset(), String::copy(), get_length(), get_ptr(), memcpy_fixed, packlength, Field::ptr, String::ptr(), reset(), and value.
01229 { char *tmp; 01230 get_ptr(&tmp); 01231 if (value.copy(tmp,get_length(),charset())) 01232 { 01233 Field_blob::reset(); 01234 return 1; 01235 } 01236 tmp=(char*) value.ptr(); memcpy_fixed(ptr+packlength,&tmp,sizeof(char*)); 01237 return 0; 01238 }
Here is the call graph for this function:

| void Field_blob::free | ( | ) | [inline, virtual] |
Definition at line 7189 of file field.cc.
References buffer, bzero, Field::char_length(), mySTL::construct(), Field_str::field_charset, float8store, get_length(), get_ptr(), HA_KEY_BLOB_LENGTH, int2store, Field::itMBR, charset_info_st::mbmaxlen, memcpy, my_charpos, and set_if_smaller.
07190 { 07191 uint32 blob_length= get_length(ptr); 07192 char *blob; 07193 07194 #ifdef HAVE_SPATIAL 07195 if (type == itMBR) 07196 { 07197 const char *dummy; 07198 MBR mbr; 07199 Geometry_buffer buffer; 07200 Geometry *gobj; 07201 07202 if (blob_length < SRID_SIZE) 07203 { 07204 bzero(buff, SIZEOF_STORED_DOUBLE*4); 07205 return; 07206 } 07207 get_ptr(&blob); 07208 gobj= Geometry::construct(&buffer, blob, blob_length); 07209 if (!gobj || gobj->get_mbr(&mbr, &dummy)) 07210 bzero(buff, SIZEOF_STORED_DOUBLE*4); 07211 else 07212 { 07213 float8store(buff, mbr.xmin); 07214 float8store(buff+8, mbr.xmax); 07215 float8store(buff+16, mbr.ymin); 07216 float8store(buff+24, mbr.ymax); 07217 } 07218 return; 07219 } 07220 #endif /*HAVE_SPATIAL*/ 07221 07222 get_ptr(&blob); 07223 uint char_length= length / field_charset->mbmaxlen; 07224 char_length= my_charpos(field_charset, blob, blob + blob_length, 07225 char_length); 07226 set_if_smaller(blob_length, char_length); 07227 07228 if ((uint32) length > blob_length) 07229 { 07230 /* 07231 Must clear this as we do a memcmp in opt_range.cc to detect 07232 identical keys 07233 */ 07234 bzero(buff+HA_KEY_BLOB_LENGTH+blob_length, (length-blob_length)); 07235 length=(uint) blob_length; 07236 } 07237 int2store(buff,length); 07238 memcpy(buff+HA_KEY_BLOB_LENGTH, blob, length); 07239 }
Here is the call graph for this function:

| uint32 Field_blob::get_length | ( | const char * | ptr | ) |
Definition at line 6935 of file field.cc.
References st_table_share::db_low_byte_first, longget, packlength, st_table::s, shortget, sint2korr, Field::table, uint3korr, and uint4korr.
06936 { 06937 switch (packlength) { 06938 case 1: 06939 return (uint32) (uchar) pos[0]; 06940 case 2: 06941 { 06942 uint16 tmp; 06943 #ifdef WORDS_BIGENDIAN 06944 if (table->s->db_low_byte_first) 06945 tmp=sint2korr(pos); 06946 else 06947 #endif 06948 shortget(tmp,pos); 06949 return (uint32) tmp; 06950 } 06951 case 3: 06952 return (uint32) uint3korr(pos); 06953 case 4: 06954 { 06955 uint32 tmp; 06956 #ifdef WORDS_BIGENDIAN 06957 if (table->s->db_low_byte_first) 06958 tmp=uint4korr(pos); 06959 else 06960 #endif 06961 longget(tmp,pos); 06962 return (uint32) tmp; 06963 } 06964 } 06965 return 0; // Impossible 06966 }
Definition at line 1203 of file field.h.
References Field::ptr.
Referenced by cmp_binary(), cmp_max(), copy(), get_key_image(), key_cmp(), pack(), pack_cmp(), pack_key(), sort_string(), unpack(), val_decimal(), val_int(), and val_real().
01204 { return get_length(ptr+row_offset); }
Here is the caller graph for this function:

| void Field_blob::get_ptr | ( | char ** | str, | |
| uint | row_offset | |||
| ) | [inline] |
Definition at line 1211 of file field.h.
References memcpy_fixed, packlength, and Field::ptr.
01212 { 01213 memcpy_fixed(str,ptr+packlength+row_offset,sizeof(char*)); 01214 }
| void Field_blob::get_ptr | ( | char ** | str | ) | [inline] |
Definition at line 1207 of file field.h.
References memcpy_fixed, packlength, and Field::ptr.
Referenced by copy(), get_key_image(), pack(), and pack_key().
01208 { 01209 memcpy_fixed(str,ptr+packlength,sizeof(char*)); 01210 }
Here is the caller graph for this function:

| bool Field_blob::has_charset | ( | void | ) | const [inline, virtual] |
Reimplemented from Field.
Definition at line 1253 of file field.h.
References Field_str::charset(), FALSE, my_charset_bin, and TRUE.
01254 { return charset() == &my_charset_bin ? FALSE : TRUE; }
Here is the call graph for this function:

Reimplemented from Field.
Definition at line 7249 of file field.cc.
References Field::char_length(), Field_str::charset(), cmp(), get_length(), HA_KEY_BLOB_LENGTH, charset_info_st::mbmaxlen, memcpy_fixed, my_charpos, packlength, set_if_smaller, and uint2korr.
07250 { 07251 char *blob1; 07252 uint blob_length=get_length(ptr); 07253 memcpy_fixed(&blob1,ptr+packlength,sizeof(char*)); 07254 CHARSET_INFO *cs= charset(); 07255 uint char_length= max_key_length / cs->mbmaxlen; 07256 char_length= my_charpos(cs, blob1, blob1+blob_length, char_length); 07257 set_if_smaller(blob_length, char_length); 07258 return Field_blob::cmp(blob1, blob_length, 07259 (char*) key_ptr+HA_KEY_BLOB_LENGTH, 07260 uint2korr(key_ptr)); 07261 }
Here is the call graph for this function:

Reimplemented from Field.
Definition at line 7263 of file field.cc.
References cmp(), HA_KEY_BLOB_LENGTH, and uint2korr.
07264 { 07265 return Field_blob::cmp((char*) a+HA_KEY_BLOB_LENGTH, uint2korr(a), 07266 (char*) b+HA_KEY_BLOB_LENGTH, uint2korr(b)); 07267 }
Here is the call graph for this function:

| uint32 Field_blob::key_length | ( | ) | const [inline, virtual] |
| enum ha_base_keytype Field_blob::key_type | ( | ) | const [inline, virtual] |
Reimplemented from Field.
Definition at line 1175 of file field.h.
References Field_str::binary(), HA_KEYTYPE_VARBINARY2, and HA_KEYTYPE_VARTEXT2.
01176 { return binary() ? HA_KEYTYPE_VARBINARY2 : HA_KEYTYPE_VARTEXT2; }
Here is the call graph for this function:

| uint32 Field_blob::max_data_length | ( | ) | const [inline] |
Definition at line 1196 of file field.h.
References packlength.
Referenced by store().
01197 { 01198 return (uint32) (((ulonglong) 1 << (packlength*8)) -1); 01199 }
Here is the caller graph for this function:

| uint32 Field_blob::max_length | ( | ) | [virtual] |
Reimplemented from Field_str.
Definition at line 9179 of file field.cc.
References DBUG_ASSERT, Field_str::field_charset, and charset_info_st::mbmaxlen.
09180 { 09181 switch (packlength) 09182 { 09183 case 1: 09184 return 255 * field_charset->mbmaxlen; 09185 case 2: 09186 return 65535 * field_charset->mbmaxlen; 09187 case 3: 09188 return 16777215 * field_charset->mbmaxlen; 09189 case 4: 09190 return (uint32) 4294967295U; 09191 default: 09192 DBUG_ASSERT(0); // we should never go here 09193 return 0; 09194 } 09195 }
Reimplemented from Field.
Definition at line 7514 of file field.cc.
07515 { 07516 return (max_length > 255 ? 2 : 1)+max_length; 07517 }
Reimplemented from Field.
Definition at line 7341 of file field.cc.
References get_length(), get_ptr(), memcpy, packlength, and store_length().
07342 { 07343 char *save=ptr; 07344 ptr=(char*) from; 07345 uint32 length=get_length(); // Length of from string 07346 if (length > max_length) 07347 { 07348 ptr=to; 07349 length=max_length; 07350 store_length(length); // Store max length 07351 ptr=(char*) from; 07352 } 07353 else 07354 memcpy(to,from,packlength); // Copy length 07355 if (length) 07356 { 07357 get_ptr((char**) &from); 07358 memcpy(to+packlength, from,length); 07359 } 07360 ptr=save; // Restore org row pointer 07361 return to+packlength+length; 07362 }
Here is the call graph for this function:

Reimplemented from Field.
Definition at line 7400 of file field.cc.
References charset_info_st::coll, Field_str::field_charset, get_length(), memcpy_fixed, packlength, my_collation_handler_st::strnncollsp, and uint2korr.
07402 { 07403 char *a; 07404 memcpy_fixed(&a,ptr+packlength,sizeof(char*)); 07405 if (!a) 07406 return key_length > 0 ? -1 : 0; 07407 uint a_length=get_length(ptr); 07408 uint b_length; 07409 07410 if (key_length > 255) 07411 { 07412 b_length=uint2korr(b); b+=2; 07413 } 07414 else 07415 b_length= (uint) (uchar) *b++; 07416 return field_charset->coll->strnncollsp(field_charset, 07417 (const uchar*) a, a_length, 07418 (const uchar*) b, b_length, 07419 insert_or_update); 07420 }
Here is the call graph for this function:

| int Field_blob::pack_cmp | ( | const char * | a, | |
| const char * | b, | |||
| uint | key_length, | |||
| my_bool | insert_or_update | |||
| ) | [virtual] |
Reimplemented from Field.
Definition at line 7379 of file field.cc.
References charset_info_st::coll, Field_str::field_charset, my_collation_handler_st::strnncollsp, and uint2korr.
07381 { 07382 uint a_length, b_length; 07383 if (key_length > 255) 07384 { 07385 a_length=uint2korr(a); a+=2; 07386 b_length=uint2korr(b); b+=2; 07387 } 07388 else 07389 { 07390 a_length= (uint) (uchar) *a++; 07391 b_length= (uint) (uchar) *b++; 07392 } 07393 return field_charset->coll->strnncollsp(field_charset, 07394 (const uchar*) a, a_length, 07395 (const uchar*) b, b_length, 07396 insert_or_update); 07397 }
| char * Field_blob::pack_key | ( | char * | to, | |
| const char * | from, | |||
| uint | max_length | |||
| ) | [virtual] |
Reimplemented from Field.
Definition at line 7424 of file field.cc.
References Field::char_length(), Field_str::field_charset, get_length(), get_ptr(), charset_info_st::mbmaxlen, memcpy, my_charpos, and set_if_smaller.
07425 { 07426 char *save=ptr; 07427 ptr=(char*) from; 07428 uint32 length=get_length(); // Length of from string 07429 uint char_length= ((field_charset->mbmaxlen > 1) ? 07430 max_length/field_charset->mbmaxlen : max_length); 07431 if (length) 07432 get_ptr((char**) &from); 07433 if (length > char_length) 07434 char_length= my_charpos(field_charset, from, from+length, char_length); 07435 set_if_smaller(length, char_length); 07436 *to++= (uchar) length; 07437 if (max_length > 255) // 2 byte length 07438 *to++= (uchar) (length >> 8); 07439 memcpy(to, from, length); 07440 ptr=save; // Restore org row pointer 07441 return to+length; 07442 }
Here is the call graph for this function:

| char * Field_blob::pack_key_from_key_image | ( | char * | to, | |
| const char * | from, | |||
| uint | max_length | |||
| ) | [virtual] |
Reimplemented from Field.
Definition at line 7491 of file field.cc.
References HA_KEY_BLOB_LENGTH, memcpy, and uint2korr.
07493 { 07494 uint length=uint2korr(from); 07495 if (length > max_length) 07496 length=max_length; 07497 *to++= (char) (length & 255); 07498 if (max_length > 255) 07499 *to++= (char) (length >> 8); 07500 if (length) 07501 memcpy(to, from+
