49
49
This is used to in group_concat() to register how many warnings we actually
50
50
got after the query has been executed.
52
void DRIZZLE_ERROR::set_msg(Session *thd, const char *msg_arg)
52
void DRIZZLE_ERROR::set_msg(Session *session, const char *msg_arg)
54
msg= strdup_root(&thd->warn_root, msg_arg);
54
msg= strdup_root(&session->warn_root, msg_arg);
68
68
in which case push_warnings() has already called this function.
71
void drizzle_reset_errors(Session *thd, bool force)
71
void drizzle_reset_errors(Session *session, bool force)
73
if (thd->query_id != thd->warn_id || force)
73
if (session->query_id != session->warn_id || force)
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));
75
session->warn_id= session->query_id;
76
free_root(&session->warn_root,MYF(0));
77
memset(session->warn_count, 0, sizeof(session->warn_count));
79
thd->total_warn_count= 0;
80
thd->warn_list.empty();
81
thd->row_count= 1; // by default point to row 1
79
session->total_warn_count= 0;
80
session->warn_list.empty();
81
session->row_count= 1; // by default point to row 1
98
98
pointer on DRIZZLE_ERROR object
101
DRIZZLE_ERROR *push_warning(Session *thd, DRIZZLE_ERROR::enum_warning_level level,
101
DRIZZLE_ERROR *push_warning(Session *session, DRIZZLE_ERROR::enum_warning_level level,
102
102
uint32_t code, const char *msg)
104
104
DRIZZLE_ERROR *err= 0;
106
106
if (level == DRIZZLE_ERROR::WARN_LEVEL_NOTE &&
107
!(thd->options & OPTION_SQL_NOTES))
107
!(session->options & OPTION_SQL_NOTES))
110
if (thd->query_id != thd->warn_id)
111
drizzle_reset_errors(thd, 0);
110
if (session->query_id != session->warn_id)
111
drizzle_reset_errors(session, 0);
112
session->got_warning= 1;
114
114
/* Abort if we are using strict mode and we are not using IGNORE */
115
115
if ((int) level >= (int) DRIZZLE_ERROR::WARN_LEVEL_WARN &&
116
thd->really_abort_on_warning())
116
session->really_abort_on_warning())
118
118
/* Avoid my_message() calling push_warning */
119
bool no_warnings_for_error= thd->no_warnings_for_error;
121
thd->no_warnings_for_error= 1;
123
thd->killed= Session::KILL_BAD_DATA;
119
bool no_warnings_for_error= session->no_warnings_for_error;
121
session->no_warnings_for_error= 1;
123
session->killed= Session::KILL_BAD_DATA;
124
124
my_message(code, msg, MYF(0));
126
thd->no_warnings_for_error= no_warnings_for_error;
126
session->no_warnings_for_error= no_warnings_for_error;
127
127
/* Store error in error list (as my_message() didn't do it) */
128
128
level= DRIZZLE_ERROR::WARN_LEVEL_ERROR;
131
if (thd->handle_error(code, msg, level))
131
if (session->handle_error(code, msg, level))
134
if (thd->warn_list.elements < thd->variables.max_error_count)
134
if (session->warn_list.elements < session->variables.max_error_count)
136
136
/* We have to use warn_root, as mem_root is freed after each query */
137
if ((err= new (&thd->warn_root) DRIZZLE_ERROR(thd, code, level, msg)))
138
thd->warn_list.push_back(err, &thd->warn_root);
137
if ((err= new (&session->warn_root) DRIZZLE_ERROR(session, code, level, msg)))
138
session->warn_list.push_back(err, &session->warn_root);
140
thd->warn_count[(uint) level]++;
141
thd->total_warn_count++;
140
session->warn_count[(uint) level]++;
141
session->total_warn_count++;
149
149
push_warning_printf()
150
session Thread handle
151
151
level Severity of warning (note, warning, error ...)
152
152
code Error number
153
153
msg Clear error message
156
void push_warning_printf(Session *thd, DRIZZLE_ERROR::enum_warning_level level,
156
void push_warning_printf(Session *session, DRIZZLE_ERROR::enum_warning_level level,
157
157
uint32_t code, const char *format, ...)
162
162
va_start(args,format);
163
163
vsnprintf(warning, sizeof(warning), format, args);
165
push_warning(thd, level, code, warning);
165
push_warning(session, level, code, warning);
199
199
field_list.push_back(new Item_return_int("Code",4, DRIZZLE_TYPE_LONG));
200
200
field_list.push_back(new Item_empty_string("Message",DRIZZLE_ERRMSG_SIZE));
202
if (thd->protocol->send_fields(&field_list,
202
if (session->protocol->send_fields(&field_list,
203
203
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
206
206
DRIZZLE_ERROR *err;
207
SELECT_LEX *sel= &thd->lex->select_lex;
208
SELECT_LEX_UNIT *unit= &thd->lex->unit;
207
SELECT_LEX *sel= &session->lex->select_lex;
208
SELECT_LEX_UNIT *unit= &session->lex->unit;
210
Protocol *protocol=thd->protocol;
210
Protocol *protocol=session->protocol;
212
212
unit->set_limit(sel);
214
List_iterator_fast<DRIZZLE_ERROR> it(thd->warn_list);
214
List_iterator_fast<DRIZZLE_ERROR> it(session->warn_list);
215
215
while ((err= it++))
217
217
/* Skip levels that the user is not interested in */