MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / init

Method init

sql/sql_table.cc:817–1169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

815
816
817bool Create_field::init(THD *thd, const char *fld_name,
818 enum_field_types fld_type, const char *fld_length,
819 const char *fld_decimals, uint fld_type_modifier,
820 Item *fld_default_value, Item *fld_on_update_value,
821 LEX_STRING *fld_comment, const char *fld_change,
822 List<String> *fld_interval_list,
823 const CHARSET_INFO *fld_charset, uint fld_geom_type)
824{
825 uint sign_len, allowed_type_modifier= 0;
826 ulong max_field_charlength= MAX_FIELD_CHARLENGTH;
827
828 DBUG_ENTER("Create_field::init()");
829
830 field_name= fld_name;
831 flags= fld_type_modifier;
832 charset= fld_charset;
833
834
835 if (fld_default_value != NULL && fld_default_value->type() == Item::FUNC_ITEM)
836 {
837 // We have a function default for insertions.
838 def= NULL;
839 }
840 else
841 {
842 // No function default for insertions. Either NULL or a constant.
843 def= fld_default_value;
844 }
845
846 decimals= fld_decimals ? (uint)atoi(fld_decimals) : 0;
847 if (is_temporal_real_type(fld_type))
848 {
849 flags|= BINARY_FLAG;
850 charset= &my_charset_numeric;
851 if (decimals > DATETIME_MAX_DECIMALS)
852 {
853 my_error(ER_TOO_BIG_PRECISION, MYF(0),
854 decimals, fld_name, DATETIME_MAX_DECIMALS);
855 DBUG_RETURN(TRUE);
856 }
857 }
858 else if (decimals >= NOT_FIXED_DEC)
859 {
860 my_error(ER_TOO_BIG_SCALE, MYF(0), decimals, fld_name,
861 static_cast<ulong>(NOT_FIXED_DEC - 1));
862 DBUG_RETURN(TRUE);
863 }
864
865 sql_type= fld_type;
866 length= 0;
867 change= fld_change;
868 interval= 0;
869 pack_length= key_length= 0;
870 geom_type= (geometry_type) fld_geom_type;
871 interval_list.empty();
872
873 comment= *fld_comment;
874 /*

Callers 1

fill_field_definitionFunction · 0.45

Calls 15

atoiFunction · 0.85
is_temporal_real_typeFunction · 0.85
my_errorFunction · 0.85
is_timestamp_typeFunction · 0.85
my_decimal_trimFunction · 0.85
push_warning_printfFunction · 0.85
get_set_pack_lengthFunction · 0.85
get_enum_pack_lengthFunction · 0.85
is_strict_modeMethod · 0.80
typeMethod · 0.45

Tested by

no test coverage detected