65
61
drizzle_reset_errors()
67
63
force Reset warnings even if it has been done before
70
66
Don't reset warnings if this has already been called for this query.
71
67
This may happen if one gets a warning during the parsing stage,
72
68
in which case push_warnings() has already called this function.
75
void drizzle_reset_errors(Session *session, bool force)
71
void drizzle_reset_errors(THD *thd, bool force)
77
if (session->query_id != session->warn_id || force)
73
if (thd->query_id != thd->warn_id || force)
79
session->warn_id= session->query_id;
80
free_root(&session->warn_root,MYF(0));
81
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(thd->warn_count, 0, sizeof(thd->warn_count));
83
session->total_warn_count= 0;
84
session->warn_list.empty();
85
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
92
88
Push the warning/error to error list if there is still room in the list
97
93
level Severity of warning (note, warning, error ...)
99
95
msg Clear error message
102
98
pointer on DRIZZLE_ERROR object
105
DRIZZLE_ERROR *push_warning(Session *session, DRIZZLE_ERROR::enum_warning_level level,
106
uint32_t code, const char *msg)
101
DRIZZLE_ERROR *push_warning(THD *thd, DRIZZLE_ERROR::enum_warning_level level,
102
uint code, const char *msg)
108
104
DRIZZLE_ERROR *err= 0;
110
106
if (level == DRIZZLE_ERROR::WARN_LEVEL_NOTE &&
111
!(session->options & OPTION_SQL_NOTES))
107
!(thd->options & OPTION_SQL_NOTES))
114
if (session->query_id != session->warn_id)
115
drizzle_reset_errors(session, 0);
116
session->got_warning= 1;
110
if (thd->query_id != thd->warn_id)
111
drizzle_reset_errors(thd, 0);
118
114
/* Abort if we are using strict mode and we are not using IGNORE */
119
115
if ((int) level >= (int) DRIZZLE_ERROR::WARN_LEVEL_WARN &&
120
session->really_abort_on_warning())
116
thd->really_abort_on_warning())
122
118
/* Avoid my_message() calling push_warning */
123
bool no_warnings_for_error= session->no_warnings_for_error;
125
session->no_warnings_for_error= 1;
127
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;
128
124
my_message(code, msg, MYF(0));
130
session->no_warnings_for_error= no_warnings_for_error;
126
thd->no_warnings_for_error= no_warnings_for_error;
131
127
/* Store error in error list (as my_message() didn't do it) */
132
128
level= DRIZZLE_ERROR::WARN_LEVEL_ERROR;
135
if (session->handle_error(code, msg, level))
131
if (thd->handle_error(code, msg, level))
138
if (session->warn_list.elements < session->variables.max_error_count)
134
if (thd->warn_list.elements < thd->variables.max_error_count)
140
136
/* We have to use warn_root, as mem_root is freed after each query */
141
if ((err= new (&session->warn_root) DRIZZLE_ERROR(session, code, level, msg)))
142
session->warn_list.push_back(err, &session->warn_root);
137
if ((err= new (&thd->warn_root) DRIZZLE_ERROR(thd, code, level, msg)))
138
thd->warn_list.push_back(err, &thd->warn_root);
144
session->warn_count[(uint32_t) level]++;
145
session->total_warn_count++;
140
thd->warn_count[(uint) level]++;
141
thd->total_warn_count++;
153
149
push_warning_printf()
154
session Thread handle
155
151
level Severity of warning (note, warning, error ...)
156
152
code Error number
157
153
msg Clear error message
160
void push_warning_printf(Session *session, DRIZZLE_ERROR::enum_warning_level level,
161
uint32_t code, const char *format, ...)
156
void push_warning_printf(THD *thd, DRIZZLE_ERROR::enum_warning_level level,
157
uint code, const char *format, ...)
164
160
char warning[ERRMSGSIZE+20];
166
162
va_start(args,format);
167
163
vsnprintf(warning, sizeof(warning), format, args);
169
push_warning(session, level, code, warning);
165
push_warning(thd, level, code, warning);
195
191
{ C_STRING_WITH_LEN("?") }
198
bool mysqld_show_warnings(Session *session, uint32_t levels_to_show)
194
bool mysqld_show_warnings(THD *thd, uint32_t levels_to_show)
200
196
List<Item> field_list;
202
198
field_list.push_back(new Item_empty_string("Level", 7));
203
199
field_list.push_back(new Item_return_int("Code",4, DRIZZLE_TYPE_LONG));
204
200
field_list.push_back(new Item_empty_string("Message",DRIZZLE_ERRMSG_SIZE));
206
if (session->protocol->send_fields(&field_list,
202
if (thd->protocol->send_fields(&field_list,
207
203
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
210
206
DRIZZLE_ERROR *err;
211
Select_Lex *sel= &session->lex->select_lex;
212
Select_Lex_Unit *unit= &session->lex->unit;
207
SELECT_LEX *sel= &thd->lex->select_lex;
208
SELECT_LEX_UNIT *unit= &thd->lex->unit;
214
Protocol *protocol=session->protocol;
210
Protocol *protocol=thd->protocol;
216
212
unit->set_limit(sel);
218
List_iterator_fast<DRIZZLE_ERROR> it(session->warn_list);
214
List_iterator_fast<DRIZZLE_ERROR> it(thd->warn_list);
219
215
while ((err= it++))
221
217
/* Skip levels that the user is not interested in */