#include "mysql_priv.h"#include "sql_select.h"#include <m_ctype.h>#include <errno.h>Include dependency graph for field.cc:

Go to the source code of this file.
Defines | |
| #define | MAX_EXPONENT 1024 |
| #define | DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE 320 |
| #define | BLOB_PACK_LENGTH_TO_MAX_LENGH(arg) ((ulong) ((LL(1) << min(arg, 4) * 8) - LL(1))) |
| #define | ASSERT_COLUMN_MARKED_FOR_READ DBUG_ASSERT(!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))) |
| #define | ASSERT_COLUMN_MARKED_FOR_WRITE DBUG_ASSERT(!table || (!table->write_set || bitmap_is_set(table->write_set, field_index))) |
| #define | FIELDTYPE_TEAR_FROM (MYSQL_TYPE_BIT + 1) |
| #define | FIELDTYPE_TEAR_TO (MYSQL_TYPE_NEWDECIMAL - 1) |
| #define | FIELDTYPE_NUM (FIELDTYPE_TEAR_FROM + (255 - FIELDTYPE_TEAR_TO)) |
| #define | test_if_minus(cs, s, e) (*s == '-') |
| #define | FLT_EXP_DIG (sizeof(float)*8-FLT_MANT_DIG) |
| #define | DBL_EXP_DIG (sizeof(double)*8-DBL_MANT_DIG) |
Functions | |
| int | field_type2index (enum_field_types field_type) |
| enum_field_types | get_blob_type_from_length (ulong length) |
| uint32 | calc_pack_length (enum_field_types type, uint32 length) |
| uint | pack_length_to_packflag (uint type) |
| Field * | make_field (TABLE_SHARE *share, char *ptr, uint32 field_length, uchar *null_pos, uchar null_bit, uint pack_flag, enum_field_types field_type, CHARSET_INFO *field_charset, Field::geometry_type geom_type, Field::utype unireg_check, TYPELIB *interval, const char *field_name) |
Variables | |
| const char | field_separator = ',' |
| static enum_field_types | field_types_merge_rules [FIELDTYPE_NUM][FIELDTYPE_NUM] |
| static Item_result | field_types_result_type [FIELDTYPE_NUM] |
| #define ASSERT_COLUMN_MARKED_FOR_READ DBUG_ASSERT(!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))) |
Definition at line 53 of file field.cc.
Referenced by Field_double::cmp(), Field_year::send_binary(), Field_float::send_binary(), Field_long::send_binary(), Field_medium::send_binary(), Field_bit::val_decimal(), Field_blob::val_decimal(), Field_varstring::val_decimal(), Field_string::val_decimal(), Field_real::val_decimal(), Field_new_decimal::val_decimal(), Field_str::val_decimal(), Field_num::val_decimal(), Field_bit::val_int(), Field_enum::val_int(), Field_blob::val_int(), Field_varstring::val_int(), Field_string::val_int(), Field_datetime::val_int(), Field_newdate::val_int(), Field_date::val_int(), Field_year::val_int(), Field_time::val_int(), Field_timestamp::val_int(), Field_double::val_int(), Field_long::val_int(), Field_medium::val_int(), Field_short::val_int(), Field_tiny::val_int(), Field_new_decimal::val_int(), Field_decimal::val_int(), Field::val_int_as_str(), Field_blob::val_real(), Field_varstring::val_real(), Field_string::val_real(), Field_newdate::val_real(), Field_date::val_real(), Field_time::val_real(), Field_timestamp::val_real(), Field_double::val_real(), Field_float::val_real(), Field_long::val_real(), Field_medium::val_real(), Field_short::val_real(), Field_tiny::val_real(), Field_new_decimal::val_real(), Field_decimal::val_real(), and Field_timestamp::val_str().
| #define ASSERT_COLUMN_MARKED_FOR_WRITE DBUG_ASSERT(!table || (!table->write_set || bitmap_is_set(table->write_set, field_index))) |
Definition at line 54 of file field.cc.
Referenced by Field_bit_as_char::store(), Field_bit::store(), Field_set::store(), Field_enum::store(), Field_blob::store(), Field_varstring::store(), Field_str::store(), Field_string::store(), Field_datetime::store(), Field_newdate::store(), Field_date::store(), Field_year::store(), Field_time::store(), Field_timestamp::store(), Field_double::store(), Field_float::store(), Field_long::store(), Field_medium::store(), Field_short::store(), Field_tiny::store(), Field_new_decimal::store(), Field_decimal::store(), Field_new_decimal::store_decimal(), Field_str::store_decimal(), Field_num::store_decimal(), Field_datetime::store_time(), Field_newdate::store_time(), Field::store_time(), and Field_new_decimal::store_value().
| #define BLOB_PACK_LENGTH_TO_MAX_LENGH | ( | arg | ) | ((ulong) ((LL(1) << min(arg, 4) * 8) - LL(1))) |
| #define DBL_EXP_DIG (sizeof(double)*8-DBL_MANT_DIG) |
| #define DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE 320 |
Definition at line 49 of file field.cc.
Referenced by Field_str::store(), Field_decimal::store(), and Field_double::val_int().
| #define FIELDTYPE_NUM (FIELDTYPE_TEAR_FROM + (255 - FIELDTYPE_TEAR_TO)) |
| #define FIELDTYPE_TEAR_FROM (MYSQL_TYPE_BIT + 1) |
Definition at line 63 of file field.cc.
Referenced by field_type2index(), and Field::result_merge_type().
| #define FIELDTYPE_TEAR_TO (MYSQL_TYPE_NEWDECIMAL - 1) |
Definition at line 64 of file field.cc.
Referenced by field_type2index(), Field::field_type_merge(), and Field::result_merge_type().
| #define MAX_EXPONENT 1024 |
| uint32 calc_pack_length | ( | enum_field_types | type, | |
| uint32 | length | |||
| ) |
Definition at line 8853 of file field.cc.
Referenced by compress_isam_file(), create_field::create_length_to_internal_length(), make_field(), prepare_blob_field(), and prepare_create_field().
08854 { 08855 switch (type) { 08856 case MYSQL_TYPE_VAR_STRING: 08857 case MYSQL_TYPE_STRING: 08858 case FIELD_TYPE_DECIMAL: return (length); 08859 case MYSQL_TYPE_VARCHAR: return (length + (length < 256 ? 1: 2)); 08860 case FIELD_TYPE_YEAR: 08861 case FIELD_TYPE_TINY : return 1; 08862 case FIELD_TYPE_SHORT : return 2; 08863 case FIELD_TYPE_INT24: 08864 case FIELD_TYPE_NEWDATE: 08865 case FIELD_TYPE_TIME: return 3; 08866 case FIELD_TYPE_TIMESTAMP: 08867 case FIELD_TYPE_DATE: 08868 case FIELD_TYPE_LONG : return 4; 08869 case FIELD_TYPE_FLOAT : return sizeof(float); 08870 case FIELD_TYPE_DOUBLE: return sizeof(double); 08871 case FIELD_TYPE_DATETIME: 08872 case FIELD_TYPE_LONGLONG: return 8; /* Don't crash if no longlong */ 08873 case FIELD_TYPE_NULL : return 0; 08874 case FIELD_TYPE_TINY_BLOB: return 1+portable_sizeof_char_ptr; 08875 case FIELD_TYPE_BLOB: return 2+portable_sizeof_char_ptr; 08876 case FIELD_TYPE_MEDIUM_BLOB: return 3+portable_sizeof_char_ptr; 08877 case FIELD_TYPE_LONG_BLOB: return 4+portable_sizeof_char_ptr; 08878 case FIELD_TYPE_GEOMETRY: return 4+portable_sizeof_char_ptr; 08879 case FIELD_TYPE_SET: 08880 case FIELD_TYPE_ENUM: 08881 case FIELD_TYPE_NEWDECIMAL: 08882 abort(); return 0; // This shouldn't happen 08883 case FIELD_TYPE_BIT: return length / 8; 08884 default: 08885 return 0; 08886 } 08887 }
Here is the caller graph for this function:

| int field_type2index | ( | enum_field_types | field_type | ) | [inline] |
Definition at line 66 of file field.cc.
References FIELDTYPE_TEAR_FROM, and FIELDTYPE_TEAR_TO.
Referenced by Field::field_type_merge(), and Field::result_merge_type().
00067 { 00068 return (field_type < FIELDTYPE_TEAR_FROM ? 00069 field_type : 00070 ((int)FIELDTYPE_TEAR_FROM) + (field_type - FIELDTYPE_TEAR_TO) - 1); 00071 }
Here is the caller graph for this function:

| enum_field_types get_blob_type_from_length | ( | ulong | length | ) |
Definition at line 8834 of file field.cc.
References FIELD_TYPE_BLOB, FIELD_TYPE_LONG_BLOB, FIELD_TYPE_MEDIUM_BLOB, and FIELD_TYPE_TINY_BLOB.
Referenced by prepare_blob_field().
08835 { 08836 enum_field_types type; 08837 if (length < 256) 08838 type= FIELD_TYPE_TINY_BLOB; 08839 else if (length < 65536) 08840 type= FIELD_TYPE_BLOB; 08841 else if (length < 256L*256L*256L) 08842 type= FIELD_TYPE_MEDIUM_BLOB; 08843 else 08844 type= FIELD_TYPE_LONG_BLOB; 08845 return type; 08846 }
Here is the caller graph for this function:

| Field* make_field | ( | TABLE_SHARE * | share, | |
| char * | ptr, | |||
| uint32 | field_length, | |||
| uchar * | null_pos, | |||
| uchar | null_bit, | |||
| uint | pack_flag, | |||
| enum_field_types | field_type, | |||
| CHARSET_INFO * | field_charset, | |||
| Field::geometry_type | geom_type, | |||
| Field::utype | unireg_check, | |||
| TYPELIB * | interval, | |||
| const char * | field_name | |||
| ) |
Definition at line 8903 of file field.cc.
References calc_pack_length(), f_bit_as_char, f_decimals, f_is_alpha, f_is_blob, f_is_dec, f_is_enum, f_is_geom, f_is_packed, f_is_zerofill, f_maybe_null, f_packtype, FIELD_TYPE_BIT, FIELD_TYPE_DATE, FIELD_TYPE_DATETIME, FIELD_TYPE_DECIMAL, FIELD_TYPE_DOUBLE, FIELD_TYPE_FLOAT, FIELD_TYPE_INT24, FIELD_TYPE_LONG, FIELD_TYPE_LONGLONG, FIELD_TYPE_NEWDATE, FIELD_TYPE_NEWDECIMAL, FIELD_TYPE_NULL, FIELD_TYPE_SHORT, FIELD_TYPE_TIME, FIELD_TYPE_TIMESTAMP, FIELD_TYPE_TINY, FIELD_TYPE_YEAR, HA_VARCHAR_PACKLENGTH, interval, LINT_INIT, MYSQL_TYPE_STRING, MYSQL_TYPE_VAR_STRING, and MYSQL_TYPE_VARCHAR.
Referenced by sp_head::create_result_field(), create_virtual_tmp_table(), and make_empty_rec().
08912 { 08913 uchar *bit_ptr; 08914 uchar bit_offset; 08915 LINT_INIT(bit_ptr); 08916 LINT_INIT(bit_offset); 08917 if (field_type == FIELD_TYPE_BIT && !f_bit_as_char(pack_flag)) 08918 { 08919 bit_ptr= null_pos; 08920 bit_offset= null_bit; 08921 if (f_maybe_null(pack_flag)) // if null field 08922 { 08923 bit_ptr+= (null_bit == 7); // shift bit_ptr and bit_offset 08924 bit_offset= (bit_offset + 1) & 7; 08925 } 08926 } 08927 08928 if (!f_maybe_null(pack_flag)) 08929 { 08930 null_pos=0; 08931 null_bit=0; 08932 } 08933 else 08934 { 08935 null_bit= ((uchar) 1) << null_bit; 08936 } 08937 08938 switch (field_type) { 08939 case FIELD_TYPE_DATE: 08940 case FIELD_TYPE_NEWDATE: 08941 case FIELD_TYPE_TIME: 08942 case FIELD_TYPE_DATETIME: 08943 case FIELD_TYPE_TIMESTAMP: 08944 field_charset= &my_charset_bin; 08945 default: break; 08946 } 08947 08948 if (f_is_alpha(pack_flag)) 08949 { 08950 if (!f_is_packed(pack_flag)) 08951 { 08952 if (field_type == MYSQL_TYPE_STRING || 08953 field_type == FIELD_TYPE_DECIMAL || // 3.23 or 4.0 string 08954 field_type == MYSQL_TYPE_VAR_STRING) 08955 return new Field_string(ptr,field_length,null_pos,null_bit, 08956 unireg_check, field_name, 08957 field_charset); 08958 if (field_type == MYSQL_TYPE_VARCHAR) 08959 return new Field_varstring(ptr,field_length, 08960 HA_VARCHAR_PACKLENGTH(field_length), 08961 null_pos,null_bit, 08962 unireg_check, field_name, 08963 share, 08964 field_charset); 08965 return 0; // Error 08966 } 08967 08968 uint pack_length=calc_pack_length((enum_field_types) 08969 f_packtype(pack_flag), 08970 field_length); 08971 08972 #ifdef HAVE_SPATIAL 08973 if (f_is_geom(pack_flag)) 08974 return new Field_geom(ptr,null_pos,null_bit, 08975 unireg_check, field_name, share, 08976 pack_length, geom_type); 08977 #endif 08978 if (f_is_blob(pack_flag)) 08979 return new Field_blob(ptr,null_pos,null_bit, 08980 unireg_check, field_name, share, 08981 pack_length, field_charset); 08982 if (interval) 08983 { 08984 if (f_is_enum(pack_flag)) 08985 return new Field_enum(ptr,field_length,null_pos,null_bit, 08986 unireg_check, field_name, 08987 pack_length, interval, field_charset); 08988 else 08989 return new Field_set(ptr,field_length,null_pos,null_bit, 08990 unireg_check, field_name, 08991 pack_length, interval, field_charset); 08992 } 08993 } 08994 08995 switch (field_type) { 08996 case FIELD_TYPE_DECIMAL: 08997 return new Field_decimal(ptr,field_length,null_pos,null_bit, 08998 unireg_check, field_name, 08999 f_decimals(pack_flag), 09000 f_is_zerofill(pack_flag) != 0, 09001 f_is_dec(pack_flag) == 0); 09002 case FIELD_TYPE_NEWDECIMAL: 09003 return new Field_new_decimal(ptr,field_length,null_pos,null_bit, 09004 unireg_check, field_name, 09005 f_decimals(pack_flag), 09006 f_is_zerofill(pack_flag) != 0, 09007 f_is_dec(pack_flag) == 0); 09008 case FIELD_TYPE_FLOAT: 09009 return new Field_float(ptr,field_length,null_pos,null_bit, 09010 unireg_check, field_name, 09011 f_decimals(pack_flag), 09012 f_is_zerofill(pack_flag) != 0, 09013 f_is_dec(pack_flag)== 0); 09014 case FIELD_TYPE_DOUBLE: 09015 return new Field_double(ptr,field_length,null_pos,null_bit, 09016 unireg_check, field_name, 09017 f_decimals(pack_flag), 09018 f_is_zerofill(pack_flag) != 0, 09019 f_is_dec(pack_flag)== 0); 09020 case FIELD_TYPE_TINY: 09021 return new Field_tiny(ptr,field_length,null_pos,null_bit, 09022 unireg_check, field_name, 09023 f_is_zerofill(pack_flag) != 0, 09024 f_is_dec(pack_flag) == 0); 09025 case FIELD_TYPE_SHORT: 09026 return new Field_short(ptr,field_length,null_pos,null_bit, 09027 unireg_check, field_name, 09028 f_is_zerofill(pack_flag) != 0, 09029 f_is_dec(pack_flag) == 0); 09030 case FIELD_TYPE_INT24: 09031 return new Field_medium(ptr,field_length,null_pos,null_bit, 09032 unireg_check, field_name, 09033 f_is_zerofill(pack_flag) != 0, 09034 f_is_dec(pack_flag) == 0); 09035 case FIELD_TYPE_LONG: 09036 return new Field_long(ptr,field_length,null_pos,null_bit, 09037 unireg_check, field_name, 09038 f_is_zerofill(pack_flag) != 0, 09039 f_is_dec(pack_flag) == 0); 09040 case FIELD_TYPE_LONGLONG: 09041 return new Field_longlong(ptr,field_length,null_pos,null_bit, 09042 unireg_check, field_name, 09043 f_is_zerofill(pack_flag) != 0, 09044 f_is_dec(pack_flag) == 0); 09045 case FIELD_TYPE_TIMESTAMP: 09046 return new Field_timestamp(ptr,field_length, null_pos, null_bit, 09047 unireg_check, field_name, share, 09048 field_charset); 09049 case FIELD_TYPE_YEAR: 09050 return new Field_year(ptr,field_length,null_pos,null_bit, 09051 unireg_check, field_name); 09052 case FIELD_TYPE_DATE: 09053 return new Field_date(ptr,null_pos,null_bit, 09054 unireg_check, field_name, field_charset); 09055 case FIELD_TYPE_NEWDATE: 09056 return new Field_newdate(ptr,null_pos,null_bit, 09057 unireg_check, field_name, field_charset); 09058 case FIELD_TYPE_TIME: 09059 return new Field_time(ptr,null_pos,null_bit, 09060 unireg_check, field_name, field_charset); 09061 case FIELD_TYPE_DATETIME: 09062 return new Field_datetime(ptr,null_pos,null_bit, 09063 unireg_check, field_name, field_charset); 09064 case FIELD_TYPE_NULL: 09065 return new Field_null(ptr, field_length, unireg_check, field_name, 09066 field_charset); 09067 case FIELD_TYPE_BIT: 09068 return f_bit_as_char(pack_flag) ? 09069 new Field_bit_as_char(ptr, field_length, null_pos, null_bit, 09070 unireg_check, field_name) : 09071 new Field_bit(ptr, field_length, null_pos, null_bit, bit_ptr, 09072 bit_offset, unireg_check, field_name); 09073 09074 default: // Impossible (Wrong version) 09075 break; 09076 } 09077 return 0; 09078 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 8890 of file field.cc.
References f_settype, FIELD_TYPE_INT24, FIELD_TYPE_LONG, FIELD_TYPE_LONGLONG, FIELD_TYPE_SHORT, and FIELD_TYPE_TINY.
Referenced by prepare_create_field().
08891 { 08892 switch (type) { 08893 case 1: return f_settype((uint) FIELD_TYPE_TINY); 08894 case 2: return f_settype((uint) FIELD_TYPE_SHORT); 08895 case 3: return f_settype((uint) FIELD_TYPE_INT24); 08896 case 4: return f_settype((uint) FIELD_TYPE_LONG); 08897 case 8: return f_settype((uint) FIELD_TYPE_LONGLONG); 08898 } 08899 return 0; // This shouldn't happen 08900 }
Here is the caller graph for this function:

| const char field_separator = ',' |
enum_field_types field_types_merge_rules[FIELDTYPE_NUM][FIELDTYPE_NUM] [static] |
Item_result field_types_result_type[FIELDTYPE_NUM] [static] |
1.4.7

