MCPcopy Create free account
hub / github.com/MariaDB/server / query_response_time_should_log

Function query_response_time_should_log

plugin/query_response_time/plugin.cc:175–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

173
174
175static bool query_response_time_should_log(MYSQL_THD thd)
176{
177 /*
178 We don't log sub statements and in this the time will be accounted
179 multiple times (both for the sub statement and the real statement.
180 */
181 if (!inited || thd->in_sub_stmt)
182 return 0;
183
184 const enum session_stat session_stat_val=
185 static_cast<session_stat>(THDVAR(thd, session_stats));
186
187 if (!((session_stat_val == session_stat_on) ||
188 (session_stat_val == session_stat_global &&
189 opt_query_response_time_stats)))
190 return 0;
191
192 if (!thd->lex)
193 {
194 /*
195 This can only happen for stored procedures/functions that failed
196 when calling sp_lex_keeper::validate_lex_and_exec_core(). In this
197 case the statement was never executed.
198 */
199 return 0;
200 }
201 if (thd->lex->sql_command == SQLCOM_CALL)
202 {
203 /*
204 For stored procedures we have already handled all statements.
205 Ignore the call which contains the time for all sub statements.
206 */
207 return 0;
208 }
209 if (thd->lex->sql_command == SQLCOM_FLUSH)
210 {
211 /*
212 Ignore FLUSH as we don't want FLUSH query_response_time to affect
213 statistics.
214 */
215 return 0;
216 }
217 return 1;
218}
219
220
221static void query_response_time_audit_notify(MYSQL_THD thd,

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected