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

Method convert_str_value

sql/item.cc:2052–2091  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2050*/
2051
2052bool Item_param::convert_str_value(THD *thd)
2053{
2054 bool rc= FALSE;
2055 if (state == STRING_VALUE || state == LONG_DATA_VALUE)
2056 {
2057 if (value.cs_info.final_character_set_of_str_value == NULL ||
2058 value.cs_info.character_set_of_placeholder == NULL)
2059 return true;
2060 /*
2061 Check is so simple because all charsets were set up properly
2062 in setup_one_conversion_function, where typecode of
2063 placeholder was also taken into account: the variables are different
2064 here only if conversion is really necessary.
2065 */
2066 if (value.cs_info.final_character_set_of_str_value !=
2067 value.cs_info.character_set_of_placeholder)
2068 {
2069 rc= thd->convert_string(&str_value,
2070 value.cs_info.character_set_of_placeholder,
2071 value.cs_info.final_character_set_of_str_value);
2072 }
2073 else
2074 str_value.set_charset(value.cs_info.final_character_set_of_str_value);
2075 /* Here str_value is guaranteed to be in final_character_set_of_str_value */
2076
2077 max_length= str_value.numchars() * str_value.charset()->mbmaxlen;
2078
2079 /* For the strings converted to numeric form within some functions */
2080 decimals= NOT_FIXED_DEC;
2081 /*
2082 str_value_ptr is returned from val_str(). It must be not alloced
2083 to prevent it's modification by val_str() invoker.
2084 */
2085 str_value_ptr.set(str_value.ptr(), str_value.length(),
2086 str_value.charset());
2087 /* Synchronize item charset with value charset */
2088 collation.set(str_value.charset(), DERIVATION_COERCIBLE);
2089 }
2090 return rc;
2091}
2092
2093
2094bool Item_param::basic_const_item() const

Callers

nothing calls this directly

Calls 7

convert_stringMethod · 0.80
numcharsMethod · 0.80
set_charsetMethod · 0.45
charsetMethod · 0.45
setMethod · 0.45
ptrMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected