60
49
This is used to in group_concat() to register how many warnings we actually
61
50
got after the query has been executed.
63
void DRIZZLE_ERROR::set_msg(Session *session, const char *msg_arg)
52
void MYSQL_ERROR::set_msg(THD *thd, const char *msg_arg)
65
msg= strdup_root(&session->warn_root, msg_arg);
54
msg= strdup_root(&thd->warn_root, msg_arg);
69
58
Reset all warnings for the thread
72
drizzle_reset_errors()
74
63
force Reset warnings even if it has been done before
77
66
Don't reset warnings if this has already been called for this query.
78
67
This may happen if one gets a warning during the parsing stage,
79
68
in which case push_warnings() has already called this function.
82
void drizzle_reset_errors(Session *session, bool force)
71
void mysql_reset_errors(THD *thd, bool force)
84
if (session->query_id != session->warn_id || force)
73
if (thd->query_id != thd->warn_id || force)
86
session->warn_id= session->query_id;
87
free_root(&session->warn_root,MYF(0));
88
memset(session->warn_count, 0, sizeof(session->warn_count));
75
thd->warn_id= thd->query_id;
76
free_root(&thd->warn_root,MYF(0));
77
memset((char*) thd->warn_count, 0, sizeof(thd->warn_count));
90
session->total_warn_count= 0;
91
session->warn_list.empty();
92
session->row_count= 1; // by default point to row 1
79
thd->total_warn_count= 0;
80
thd->warn_list.empty();
81
thd->row_count= 1; // by default point to row 1
99
88
Push the warning/error to error list if there is still room in the list
103
session Thread handle
104
93
level Severity of warning (note, warning, error ...)
106
95
msg Clear error message
109
pointer on DRIZZLE_ERROR object
98
pointer on MYSQL_ERROR object
112
DRIZZLE_ERROR *push_warning(Session *session, DRIZZLE_ERROR::enum_warning_level level,
113
uint32_t code, const char *msg)
101
MYSQL_ERROR *push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level,
102
uint code, const char *msg)
115
DRIZZLE_ERROR *err= 0;
117
if (level == DRIZZLE_ERROR::WARN_LEVEL_NOTE &&
118
!(session->options & OPTION_SQL_NOTES))
106
if (level == MYSQL_ERROR::WARN_LEVEL_NOTE &&
107
!(thd->options & OPTION_SQL_NOTES))
121
if (session->query_id != session->warn_id)
122
drizzle_reset_errors(session, 0);
123
session->got_warning= 1;
110
if (thd->query_id != thd->warn_id)
111
mysql_reset_errors(thd, 0);
125
114
/* Abort if we are using strict mode and we are not using IGNORE */
126
if ((int) level >= (int) DRIZZLE_ERROR::WARN_LEVEL_WARN &&
127
session->really_abort_on_warning())
115
if ((int) level >= (int) MYSQL_ERROR::WARN_LEVEL_WARN &&
116
thd->really_abort_on_warning())
129
118
/* Avoid my_message() calling push_warning */
130
bool no_warnings_for_error= session->no_warnings_for_error;
132
session->no_warnings_for_error= 1;
134
session->killed= Session::KILL_BAD_DATA;
119
bool no_warnings_for_error= thd->no_warnings_for_error;
121
thd->no_warnings_for_error= 1;
123
thd->killed= THD::KILL_BAD_DATA;
135
124
my_message(code, msg, MYF(0));
137
session->no_warnings_for_error= no_warnings_for_error;
126
thd->no_warnings_for_error= no_warnings_for_error;
138
127
/* Store error in error list (as my_message() didn't do it) */
139
level= DRIZZLE_ERROR::WARN_LEVEL_ERROR;
128
level= MYSQL_ERROR::WARN_LEVEL_ERROR;
142
if (session->handle_error(code, msg, level))
131
if (thd->handle_error(code, msg, level))
145
if (session->warn_list.elements < session->variables.max_error_count)
134
if (thd->warn_list.elements < thd->variables.max_error_count)
147
136
/* We have to use warn_root, as mem_root is freed after each query */
148
if ((err= new (&session->warn_root) DRIZZLE_ERROR(session, code, level, msg)))
149
session->warn_list.push_back(err, &session->warn_root);
137
if ((err= new (&thd->warn_root) MYSQL_ERROR(thd, code, level, msg)))
138
thd->warn_list.push_back(err, &thd->warn_root);
151
session->warn_count[(uint32_t) level]++;
152
session->total_warn_count++;
140
thd->warn_count[(uint) level]++;
141
thd->total_warn_count++;
160
149
push_warning_printf()
161
session Thread handle
162
151
level Severity of warning (note, warning, error ...)
163
152
code Error number
164
153
msg Clear error message
167
void push_warning_printf(Session *session, DRIZZLE_ERROR::enum_warning_level level,
168
uint32_t code, const char *format, ...)
156
void push_warning_printf(THD *thd, MYSQL_ERROR::enum_warning_level level,
157
uint code, const char *format, ...)
171
160
char warning[ERRMSGSIZE+20];
173
162
va_start(args,format);
174
163
vsnprintf(warning, sizeof(warning), format, args);
176
push_warning(session, level, code, warning);
165
push_warning(thd, level, code, warning);
202
191
{ C_STRING_WITH_LEN("?") }
205
bool mysqld_show_warnings(Session *session,
206
bitset<DRIZZLE_ERROR::NUM_ERRORS> &levels_to_show)
194
bool mysqld_show_warnings(THD *thd, ulong levels_to_show)
208
196
List<Item> field_list;
210
198
field_list.push_back(new Item_empty_string("Level", 7));
211
199
field_list.push_back(new Item_return_int("Code",4, DRIZZLE_TYPE_LONG));
212
field_list.push_back(new Item_empty_string("Message",DRIZZLE_ERRMSG_SIZE));
214
if (session->client->sendFields(&field_list))
218
Select_Lex *sel= &session->lex->select_lex;
219
Select_Lex_Unit *unit= &session->lex->unit;
200
field_list.push_back(new Item_empty_string("Message",MYSQL_ERRMSG_SIZE));
202
if (thd->protocol->send_fields(&field_list,
203
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
207
SELECT_LEX *sel= &thd->lex->select_lex;
208
SELECT_LEX_UNIT *unit= &thd->lex->unit;
210
Protocol *protocol=thd->protocol;
222
212
unit->set_limit(sel);
224
List_iterator_fast<DRIZZLE_ERROR> it(session->warn_list);
214
List_iterator_fast<MYSQL_ERROR> it(thd->warn_list);
225
215
while ((err= it++))
227
217
/* Skip levels that the user is not interested in */
228
if (! levels_to_show.test(err->level))
218
if (!(levels_to_show & ((ulong) 1 << err->level)))
230
220
if (++idx <= unit->offset_limit_cnt)
232
222
if (idx > unit->select_limit_cnt)
234
session->client->store(warning_level_names[err->level].str,
235
warning_level_names[err->level].length);
236
session->client->store((uint32_t) err->code);
237
session->client->store(err->msg, strlen(err->msg));
238
if (session->client->flush())
224
protocol->prepare_for_resend();
225
protocol->store(warning_level_names[err->level].str,
226
warning_level_names[err->level].length, system_charset_info);
227
protocol->store((uint32_t) err->code);
228
protocol->store(err->msg, strlen(err->msg), system_charset_info);
229
if (protocol->write())