128
type::timestamp_t str_to_datetime_with_warn(Session *session, const char *str, uint32_t length, type::Time *l_time, uint32_t flags)
128
type::timestamp_t str_to_datetime_with_warn(Session& session, str_ref str, type::Time& l_time, uint32_t flags)
130
130
type::cut_t was_cut= type::VALID;
131
type::timestamp_t ts_type= l_time->store(str, length, (flags | (session->variables.sql_mode & (MODE_INVALID_DATES | MODE_NO_ZERO_DATE))), was_cut);
131
type::timestamp_t ts_type= l_time.store(str.data(), str.size(), (flags | (session.variables.sql_mode & (MODE_INVALID_DATES | MODE_NO_ZERO_DATE))), was_cut);
132
132
if (was_cut || ts_type <= type::DRIZZLE_TIMESTAMP_ERROR)
133
make_truncated_value_warning(session, DRIZZLE_ERROR::WARN_LEVEL_WARN, str, length, ts_type, NULL);
133
make_truncated_value_warning(session, DRIZZLE_ERROR::WARN_LEVEL_WARN, str, ts_type, NULL);
139
bool str_to_time_with_warn(Session *session, const char *str, uint32_t length, type::Time *l_time)
138
bool str_to_time_with_warn(Session& session, str_ref str, type::Time& l_time)
142
bool ret_val= l_time->store(str, length, warning, type::DRIZZLE_TIMESTAMP_TIME);
141
bool ret_val= l_time.store(str.data(), str.size(), warning, type::DRIZZLE_TIMESTAMP_TIME);
143
142
if (ret_val || warning)
144
make_truncated_value_warning(session, DRIZZLE_ERROR::WARN_LEVEL_WARN, str, length, type::DRIZZLE_TIMESTAMP_TIME, NULL);
143
make_truncated_value_warning(session, DRIZZLE_ERROR::WARN_LEVEL_WARN, str, type::DRIZZLE_TIMESTAMP_TIME, NULL);
149
void make_truncated_value_warning(Session *session,
150
DRIZZLE_ERROR::enum_warning_level level,
153
type::timestamp_t time_type,
154
const char *field_name)
148
void make_truncated_value_warning(Session& session, DRIZZLE_ERROR::enum_warning_level level, str_ref str_arg, type::timestamp_t time_type, const char *field_name)
156
150
char warn_buff[DRIZZLE_ERRMSG_SIZE];
157
const char *type_str;
158
151
charset_info_st *cs= &my_charset_utf8_general_ci;
160
153
String str(buff,(uint32_t) sizeof(buff), system_charset_info);
161
str.copy(str_val, str_length, system_charset_info);
162
str[str_length]= 0; // Ensure we have end 0 for snprintf
154
str.copy(str_arg.data(), str_arg.size(), system_charset_info);
155
assert(not str[str_arg.size()]); // Ensure we have end 0 for snprintf
157
const char *type_str;
165
160
case type::DRIZZLE_TIMESTAMP_DATE:
166
161
type_str= "date";
181
175
cs->cset->snprintf(cs, warn_buff, sizeof(warn_buff),
182
176
ER(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD),
183
177
type_str, str.c_ptr(), field_name,
184
(uint32_t) session->row_count);
178
(uint32_t) session.row_count);
180
else if (time_type > type::DRIZZLE_TIMESTAMP_ERROR)
182
cs->cset->snprintf(cs, warn_buff, sizeof(warn_buff), ER(ER_TRUNCATED_WRONG_VALUE), type_str, str.c_ptr());
188
if (time_type > type::DRIZZLE_TIMESTAMP_ERROR)
190
cs->cset->snprintf(cs, warn_buff, sizeof(warn_buff),
191
ER(ER_TRUNCATED_WRONG_VALUE),
192
type_str, str.c_ptr());
196
cs->cset->snprintf(cs, warn_buff, sizeof(warn_buff),
197
ER(ER_WRONG_VALUE), type_str, str.c_ptr());
186
cs->cset->snprintf(cs, warn_buff, sizeof(warn_buff), ER(ER_WRONG_VALUE), type_str, str.c_ptr());
200
push_warning(session, level,
201
ER_TRUNCATED_WRONG_VALUE, warn_buff);
188
push_warning(&session, level, ER_TRUNCATED_WRONG_VALUE, warn_buff);