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

Function make_truncated_value_warning

sql/sql_time.cc:1088–1125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1086
1087
1088void make_truncated_value_warning(THD *thd,
1089 Sql_condition::enum_warning_level level,
1090 ErrConvString val, timestamp_type time_type,
1091 const char *field_name)
1092{
1093 char warn_buff[MYSQL_ERRMSG_SIZE];
1094 const char *type_str;
1095 CHARSET_INFO *cs= system_charset_info;
1096
1097 switch (time_type) {
1098 case MYSQL_TIMESTAMP_DATE:
1099 type_str= "date";
1100 break;
1101 case MYSQL_TIMESTAMP_TIME:
1102 type_str= "time";
1103 break;
1104 case MYSQL_TIMESTAMP_DATETIME: // FALLTHROUGH
1105 default:
1106 type_str= "datetime";
1107 break;
1108 }
1109 if (field_name)
1110 cs->cset->snprintf(cs, warn_buff, sizeof(warn_buff),
1111 ER(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD),
1112 type_str, val.ptr(), field_name,
1113 (ulong) thd->get_stmt_da()->current_row_for_warning());
1114 else
1115 {
1116 if (time_type > MYSQL_TIMESTAMP_ERROR)
1117 cs->cset->snprintf(cs, warn_buff, sizeof(warn_buff),
1118 ER(ER_TRUNCATED_WRONG_VALUE),
1119 type_str, val.ptr());
1120 else
1121 cs->cset->snprintf(cs, warn_buff, sizeof(warn_buff),
1122 ER(ER_WRONG_VALUE), type_str, val.ptr());
1123 }
1124 push_warning(thd, level, ER_TRUNCATED_WRONG_VALUE, warn_buff);
1125}
1126
1127
1128/* Daynumber from year 0 to 9999-12-31 */

Calls 4

push_warningFunction · 0.85
get_stmt_daMethod · 0.80
ptrMethod · 0.45

Tested by

no test coverage detected