1 diff -r 0b1f42e1aacf sql/event_scheduler.cc
2 --- a/sql/event_scheduler.cc Thu Dec 04 08:55:22 2008 -0800
3 +++ b/sql/event_scheduler.cc Thu Dec 04 08:55:29 2008 -0800
5 thd->client_capabilities|= CLIENT_MULTI_RESULTS;
6 pthread_mutex_lock(&LOCK_thread_count);
7 thd->thread_id= thd->variables.pseudo_thread_id= thread_id++;
8 + thd->write_to_slow_log = TRUE;
9 pthread_mutex_unlock(&LOCK_thread_count);
12 diff -r 0b1f42e1aacf sql/filesort.cc
13 --- a/sql/filesort.cc Thu Dec 04 08:55:22 2008 -0800
14 +++ b/sql/filesort.cc Thu Dec 04 08:55:29 2008 -0800
17 status_var_increment(thd->status_var.filesort_scan_count);
19 + thd->query_plan_flags|= QPLAN_FILESORT;
20 #ifdef CAN_TRUST_RANGE
21 if (select && select->quick && select->quick->records > 0L)
27 + thd->query_plan_flags|= QPLAN_FILESORT_DISK;
28 if (table_sort.buffpek && table_sort.buffpek_len < maxbuffer)
30 x_free(table_sort.buffpek);
32 DBUG_ENTER("merge_buffers");
34 status_var_increment(current_thd->status_var.filesort_merge_passes);
35 + current_thd->query_plan_fsort_passes++;
36 if (param->not_killable)
38 killed= ¬_killable;
39 diff -r 0b1f42e1aacf sql/log.cc
40 --- a/sql/log.cc Thu Dec 04 08:55:22 2008 -0800
41 +++ b/sql/log.cc Thu Dec 04 08:55:29 2008 -0800
43 /* fill in user_host value: the format is "%s[%s] @ %s [%s]" */
44 user_host_len= (strxnmov(user_host_buff, MAX_USER_HOST_SIZE,
45 sctx->priv_user ? sctx->priv_user : "", "[",
46 - sctx->user ? sctx->user : "", "] @ ",
47 + sctx->user ? sctx->user : (thd->slave_thread ? "SQL_SLAVE" : ""), "] @ ",
48 sctx->host ? sctx->host : "", " [",
49 sctx->ip ? sctx->ip : "", "]", NullS) -
52 query= command_name[thd->command].str;
53 query_length= command_name[thd->command].length;
58 + thd->sent_row_count= thd->examined_row_count= 0;
59 + thd->query_plan_flags= QPLAN_NONE;
60 + thd->query_plan_fsort_passes= 0;
63 for (current_handler= slow_log_handler_list; *current_handler ;)
64 error= (*current_handler++)->log_slow(thd, current_time, thd->start_time,
65 @@ -2242,16 +2249,31 @@
66 if (my_b_write(&log_file, (uchar*) "\n", 1))
70 /* For slow query log */
71 sprintf(query_time_buff, "%.6f", ulonglong2double(query_utime)/1000000.0);
72 sprintf(lock_time_buff, "%.6f", ulonglong2double(lock_utime)/1000000.0);
73 if (my_b_printf(&log_file,
74 - "# Query_time: %s Lock_time: %s"
75 - " Rows_sent: %lu Rows_examined: %lu\n",
76 + "# Thread_id: %lu Schema: %s\n" \
77 + "# Query_time: %s Lock_time: %s Rows_sent: %lu Rows_examined: %lu\n",
78 + (ulong) thd->thread_id, (thd->db ? thd->db : ""),
79 query_time_buff, lock_time_buff,
80 (ulong) thd->sent_row_count,
81 (ulong) thd->examined_row_count) == (uint) -1)
83 + if ((thd->variables.log_slow_verbosity & SLOG_V_QUERY_PLAN) &&
84 + my_b_printf(&log_file,
85 + "# QC_Hit: %s Full_scan: %s Full_join: %s Tmp_table: %s Tmp_table_on_disk: %s\n" \
86 + "# Filesort: %s Filesort_on_disk: %s Merge_passes: %lu\n",
87 + ((thd->query_plan_flags & QPLAN_QC) ? "Yes" : "No"),
88 + ((thd->query_plan_flags & QPLAN_FULL_SCAN) ? "Yes" : "No"),
89 + ((thd->query_plan_flags & QPLAN_FULL_JOIN) ? "Yes" : "No"),
90 + ((thd->query_plan_flags & QPLAN_TMP_TABLE) ? "Yes" : "No"),
91 + ((thd->query_plan_flags & QPLAN_TMP_DISK) ? "Yes" : "No"),
92 + ((thd->query_plan_flags & QPLAN_FILESORT) ? "Yes" : "No"),
93 + ((thd->query_plan_flags & QPLAN_FILESORT_DISK) ? "Yes" : "No"),
94 + thd->query_plan_fsort_passes) == (uint) -1)
96 if (thd->db && strcmp(thd->db, db))
98 if (my_b_printf(&log_file,"use %s;\n",thd->db) == (uint) -1)
99 diff -r 0b1f42e1aacf sql/mysql_priv.h
100 --- a/sql/mysql_priv.h Thu Dec 04 08:55:22 2008 -0800
101 +++ b/sql/mysql_priv.h Thu Dec 04 08:55:29 2008 -0800
103 #define WEEK_FIRST_WEEKDAY 4
105 #define STRING_BUFFER_USUAL_SIZE 80
115 +#define SLOG_V_QUERY_PLAN 1 << 1
117 +#define SLOG_V_INVALID 1 << 31
118 +#define SLOG_V_NONE 1 << 0
120 +static const struct msl_opts slog_verb[]=
124 + { SLOG_V_QUERY_PLAN, "query_plan" },
126 + /* End of baisc flags */
130 + /* Complex flags */
132 + { SLOG_V_QUERY_PLAN, "standard" },
133 + { SLOG_V_INVALID, "full" },
135 + /* End of complex flags */
137 + { SLOG_V_INVALID, (char *)0 }
140 +#define QPLAN_NONE 0
141 +#define QPLAN_QC 1 << 0
142 +#define QPLAN_QC_NO 1 << 1
143 +#define QPLAN_FULL_SCAN 1 << 2
144 +#define QPLAN_FULL_JOIN 1 << 3
145 +#define QPLAN_TMP_TABLE 1 << 4
146 +#define QPLAN_TMP_DISK 1 << 5
147 +#define QPLAN_FILESORT 1 << 6
148 +#define QPLAN_FILESORT_DISK 1 << 7
150 +#define QPLAN_MAX 1 << 31
152 +#define SLOG_F_QC_NO QPLAN_QC_NO
153 +#define SLOG_F_FULL_SCAN QPLAN_FULL_SCAN
154 +#define SLOG_F_FULL_JOIN QPLAN_FULL_JOIN
155 +#define SLOG_F_TMP_TABLE QPLAN_TMP_TABLE
156 +#define SLOG_F_TMP_DISK QPLAN_TMP_DISK
157 +#define SLOG_F_FILESORT QPLAN_FILESORT
158 +#define SLOG_F_FILESORT_DISK QPLAN_FILESORT_DISK
159 +#define SLOG_F_INVALID 1 << 31
160 +#define SLOG_F_NONE 0
162 +static const struct msl_opts slog_filter[]=
164 + { SLOG_F_QC_NO, "qc_miss" },
165 + { SLOG_F_FULL_SCAN, "full_scan" },
166 + { SLOG_F_FULL_JOIN, "full_join" },
167 + { SLOG_F_TMP_TABLE, "tmp_table" },
168 + { SLOG_F_TMP_DISK, "tmp_table_on_disk" },
169 + { SLOG_F_FILESORT, "filesort" },
170 + { SLOG_F_FILESORT_DISK, "filesort_on_disk" },
171 + { SLOG_F_INVALID, (char *)0 }
175 Some defines for exit codes for ::is_equal class functions.
176 --- mysql-5.1.49/sql/mysqld.cc~ 2010-07-24 15:19:16.000000000 +0300
177 +++ mysql-5.1.49/sql/mysqld.cc 2010-07-24 15:22:23.181784212 +0300
178 @@ -5553,6 +5553,9 @@
179 OPT_SECURE_FILE_PRIV,
180 OPT_MIN_EXAMINED_ROW_LIMIT,
181 OPT_LOG_SLOW_SLAVE_STATEMENTS,
182 + OPT_LOG_SLOW_RATE_LIMIT,
183 + OPT_LOG_SLOW_VERBOSITY,
184 + OPT_LOG_SLOW_FILTER,
185 #if defined(ENABLED_DEBUG_SYNC)
186 OPT_DEBUG_SYNC_TIMEOUT,
187 #endif /* defined(ENABLED_DEBUG_SYNC) */
188 @@ -6819,6 +6819,17 @@
189 "The minimum percentage of warm blocks in key cache.",
190 &dflt_key_cache_var.param_division_limit, NULL, NULL,
191 (GET_ULONG | GET_ASK_ADDR) , REQUIRED_ARG, 100, 1, 100, 0, 1, 0},
192 + {"log_slow_filter", OPT_LOG_SLOW_FILTER,
193 + "Log only the queries that followed certain execution plan. Multiple flags allowed in a comma-separated string. [qc_miss, full_scan, full_join, tmp_table, tmp_table_on_disk, filesort, filesort_on_disk]",
194 + 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, SLOG_F_NONE, 0, 0},
195 + {"log_slow_rate_limit", OPT_LOG_SLOW_RATE_LIMIT,
196 + "Rate limit statement writes to slow log to only those from every (1/log_slow_rate_limit) session.",
197 + (uchar**) &global_system_variables.log_slow_rate_limit,
198 + (uchar**) &max_system_variables.log_slow_rate_limit, 0, GET_ULONG,
199 + REQUIRED_ARG, 1, 1, ~0L, 0, 1L, 0},
200 + {"log_slow_verbosity", OPT_LOG_SLOW_VERBOSITY,
201 + "Choose how verbose the messages to your slow log will be. Multiple flags allowed in a comma-separated string. [microtime, query_plan, innodb]",
202 + 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, SLOG_V_NONE, 0, 0},
203 {"long_query_time", OPT_LONG_QUERY_TIME,
204 "Log all queries that have taken more than long_query_time seconds to "
205 "execute. The argument will be treated as a decimal value with "
206 @@ -7556,6 +7570,10 @@
207 global_system_variables.old_passwords= 0;
208 global_system_variables.old_alter_table= 0;
209 global_system_variables.binlog_format= BINLOG_FORMAT_UNSPEC;
211 + global_system_variables.log_slow_verbosity= SLOG_V_NONE;
212 + global_system_variables.log_slow_filter= SLOG_F_NONE;
215 Default behavior for 4.1 and 5.0 is to treat NULL values as unequal
216 when collecting index statistics for MyISAM tables.
217 @@ -8007,6 +8025,24 @@
219 opt_noacl=opt_bootstrap=1;
221 + case OPT_LOG_SLOW_FILTER:
222 + if ((global_system_variables.log_slow_filter=
223 + msl_flag_resolve_by_name(slog_filter, argument,
224 + SLOG_F_NONE, SLOG_F_INVALID)) == SLOG_F_INVALID)
226 + fprintf(stderr,"Invalid argument to log_slow_filter\n");
230 + case OPT_LOG_SLOW_VERBOSITY:
231 + if ((global_system_variables.log_slow_verbosity=
232 + msl_flag_resolve_by_name(slog_verb, argument,
233 + SLOG_V_NONE, SLOG_V_INVALID)) == SLOG_V_INVALID)
235 + fprintf(stderr,"Invalid argument to log_slow_verbosity\n");
240 server_id_supplied = 1;
242 diff -r 0b1f42e1aacf sql/set_var.cc
243 --- a/sql/set_var.cc Thu Dec 04 08:55:22 2008 -0800
244 +++ b/sql/set_var.cc Thu Dec 04 08:55:29 2008 -0800
249 +static sys_var_thd_ulong sys_log_slow_rate_limit(&vars, "log_slow_rate_limit",
250 + &SV::log_slow_rate_limit);
251 +static sys_var_thd_msl_flag sys_log_slow_filter(&vars, "log_slow_filter",
252 + &SV::log_slow_filter,
257 +static sys_var_thd_msl_flag sys_log_slow_verbosity(&vars, "log_slow_verbosity",
258 + &SV::log_slow_verbosity,
263 static sys_var_long_ptr_global
264 sys_max_prepared_stmt_count(&vars, "max_prepared_stmt_count",
265 &max_prepared_stmt_count,
266 @@ -3631,6 +3645,192 @@
270 +/* Slow log stuff */
272 +ulong msl_option_resolve_by_name(const struct msl_opts *opts, const char *name, ulong len)
276 + for (i=0; opts[i].name; i++)
278 + if (!my_strnncoll(&my_charset_latin1,
279 + (const uchar *)name, len,
280 + (const uchar *)opts[i].name, strlen(opts[i].name)))
281 + return opts[i].val;
283 + return opts[i].val;
286 +ulong msl_flag_resolve_by_name(const struct msl_opts *opts, const char *names_list,
287 + const ulong none_val, const ulong invalid_val)
290 + ulong val= none_val;
295 + for (p= e= names_list; ; e++)
299 + if (*e != ',' && *e)
301 + for (i=0; opts[i].name; i++)
303 + if (!my_strnncoll(&my_charset_latin1,
304 + (const uchar *)p, e - p,
305 + (const uchar *)opts[i].name, strlen(opts[i].name)))
307 + val= val | opts[i].val;
311 + if (opts[i].val == invalid_val)
312 + return invalid_val;
320 +const char *msl_option_get_name(const struct msl_opts *opts, ulong val)
322 + for (ulong i=0; opts[i].name && opts[i].name[0]; i++)
324 + if (opts[i].val == val)
325 + return opts[i].name;
327 + return "*INVALID*";
330 +char *msl_flag_get_name(const struct msl_opts *opts, char *buf, ulong val)
335 + for (ulong i=0; opts[i].name && opts[i].name[0]; i++)
337 + if (opts[i].val & val)
338 + offset+= snprintf(buf+offset, STRING_BUFFER_USUAL_SIZE - offset - 1,
339 + "%s%s", (offset ? "," : ""), opts[i].name);
344 +/****************************************************************************
345 + Functions to handle log_slow_verbosity
346 +****************************************************************************/
348 +/* Based upon sys_var::check_enum() */
350 +bool sys_var_thd_msl_option::check(THD *thd, set_var *var)
352 + char buff[STRING_BUFFER_USUAL_SIZE];
353 + String str(buff, sizeof(buff), &my_charset_latin1), *res;
355 + if (var->value->result_type() == STRING_RESULT)
357 + ulong verb= this->invalid_val;
358 + if (!(res=var->value->val_str(&str)) ||
359 + (var->save_result.ulong_value=
360 + (ulong) (verb= msl_option_resolve_by_name(this->opts, res->ptr(), res->length()))) == this->invalid_val)
366 + my_error(ER_WRONG_ARGUMENTS, MYF(0), var->var->name);
370 +uchar *sys_var_thd_msl_option::value_ptr(THD *thd, enum_var_type type,
374 + val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
375 + thd->variables.*offset);
376 + const char *verbosity= msl_option_get_name(this->opts, val);
377 + return (uchar *) verbosity;
381 +void sys_var_thd_msl_option::set_default(THD *thd, enum_var_type type)
383 + if (type == OPT_GLOBAL)
384 + global_system_variables.*offset= (ulong) this->default_val;
386 + thd->variables.*offset= (ulong) (global_system_variables.*offset);
390 +bool sys_var_thd_msl_option::update(THD *thd, set_var *var)
392 + if (var->type == OPT_GLOBAL)
393 + global_system_variables.*offset= var->save_result.ulong_value;
395 + thd->variables.*offset= var->save_result.ulong_value;
399 +/****************************************************************************
400 + Functions to handle log_slow_filter
401 +****************************************************************************/
403 +/* Based upon sys_var::check_enum() */
405 +bool sys_var_thd_msl_flag::check(THD *thd, set_var *var)
407 + char buff[2 * STRING_BUFFER_USUAL_SIZE];
408 + String str(buff, sizeof(buff), &my_charset_latin1), *res;
410 + if (var->value->result_type() == STRING_RESULT)
412 + ulong filter= this->none_val;
413 + if (!(res=var->value->val_str(&str)) ||
414 + (var->save_result.ulong_value=
415 + (ulong) (filter= msl_flag_resolve_by_name(this->flags, res->ptr(), this->none_val,
416 + this->invalid_val))) == this->invalid_val)
422 + my_error(ER_WRONG_ARGUMENTS, MYF(0), var->var->name);
426 +uchar *sys_var_thd_msl_flag::value_ptr(THD *thd, enum_var_type type,
430 + val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
431 + thd->variables.*offset);
432 + msl_flag_get_name(this->flags, this->flags_string, val);
433 + return (uchar *) this->flags_string;
437 +void sys_var_thd_msl_flag::set_default(THD *thd, enum_var_type type)
439 + if (type == OPT_GLOBAL)
440 + global_system_variables.*offset= (ulong) this->default_val;
442 + thd->variables.*offset= (ulong) (global_system_variables.*offset);
446 +bool sys_var_thd_msl_flag::update(THD *thd, set_var *var)
448 + if (var->type == OPT_GLOBAL)
449 + global_system_variables.*offset= var->save_result.ulong_value;
451 + thd->variables.*offset= var->save_result.ulong_value;
456 /****************************************************************************
457 Functions to handle table_type
458 ****************************************************************************/
459 diff -r 0b1f42e1aacf sql/set_var.h
460 --- a/sql/set_var.h Thu Dec 04 08:55:22 2008 -0800
461 +++ b/sql/set_var.h Thu Dec 04 08:55:29 2008 -0800
462 @@ -1057,6 +1057,68 @@
463 bool update(THD *thd, set_var *var);
466 +class sys_var_thd_msl_option :public sys_var_thd
470 + const ulong none_val;
471 + const ulong default_val;
472 + const ulong invalid_val;
473 + const struct msl_opts *opts;
475 + sys_var_thd_msl_option(sys_var_chain *chain, const char *name_arg,
476 + ulong SV::*offset_arg,
477 + const ulong none_val_arg,
478 + const ulong default_val_arg,
479 + const ulong invalid_val_arg,
480 + const struct msl_opts *opts_arg)
481 + :sys_var_thd(name_arg), offset(offset_arg), none_val(none_val_arg),
482 + default_val(default_val_arg), invalid_val(invalid_val_arg),
484 + { chain_sys_var(chain); }
485 + bool check(THD *thd, set_var *var);
486 + SHOW_TYPE show_type() { return SHOW_CHAR; }
487 + bool check_update_type(Item_result type)
489 + return type != STRING_RESULT; /* Only accept strings */
491 + void set_default(THD *thd, enum_var_type type);
492 + bool update(THD *thd, set_var *var);
493 + uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
497 +class sys_var_thd_msl_flag :public sys_var_thd
500 + char flags_string[2 * STRING_BUFFER_USUAL_SIZE];
502 + const ulong none_val;
503 + const ulong default_val;
504 + const ulong invalid_val;
505 + const struct msl_opts *flags;
507 + sys_var_thd_msl_flag(sys_var_chain *chain, const char *name_arg,
508 + ulong SV::*offset_arg,
509 + const ulong none_val_arg,
510 + const ulong default_val_arg,
511 + const ulong invalid_val_arg,
512 + const struct msl_opts *flags_arg)
513 + :sys_var_thd(name_arg), offset(offset_arg), none_val(none_val_arg),
514 + default_val(default_val_arg), invalid_val(invalid_val_arg),
516 + { chain_sys_var(chain); }
517 + bool check(THD *thd, set_var *var);
518 + SHOW_TYPE show_type() { return SHOW_CHAR; }
519 + bool check_update_type(Item_result type)
521 + return type != STRING_RESULT; /* Only accept strings */
523 + void set_default(THD *thd, enum_var_type type);
524 + bool update(THD *thd, set_var *var);
525 + uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
530 Handler for setting the system variable --read-only.
531 @@ -1323,3 +1385,10 @@
532 bool process_key_caches(process_key_cache_t func);
533 void delete_elements(I_List<NAMED_LIST> *list,
534 void (*free_element)(const char*, uchar*));
536 +/* Slow log functions */
537 +ulong msl_option_resolve_by_name(const struct msl_opts *opts, const char *name, ulong len);
538 +ulong msl_flag_resolve_by_name(const struct msl_opts *opts, const char *names_list,
539 + const ulong none_val, const ulong invalid_val);
540 +const char *msl_option_get_name(const struct msl_opts *opts, ulong val);
541 +char *msl_flag_get_name(const struct msl_opts *opts, char *buf, ulong val);
542 diff -r 0b1f42e1aacf sql/slave.cc
543 --- a/sql/slave.cc Thu Dec 04 08:55:22 2008 -0800
544 +++ b/sql/slave.cc Thu Dec 04 08:55:29 2008 -0800
545 @@ -1561,6 +1561,7 @@
546 + MAX_LOG_EVENT_HEADER; /* note, incr over the global not session var */
547 thd->slave_thread = 1;
548 thd->enable_slow_log= opt_log_slow_slave_statements;
549 + thd->write_to_slow_log= opt_log_slow_slave_statements;
550 set_slave_thread_options(thd);
551 thd->client_capabilities = CLIENT_LOCAL_FILES;
552 pthread_mutex_lock(&LOCK_thread_count);
553 diff -r 0b1f42e1aacf sql/sql_cache.cc
554 --- a/sql/sql_cache.cc Thu Dec 04 08:55:22 2008 -0800
555 +++ b/sql/sql_cache.cc Thu Dec 04 08:55:29 2008 -0800
556 @@ -1465,6 +1465,7 @@
558 thd->limit_found_rows = query->found_rows();
559 thd->status_var.last_query_cost= 0.0;
560 + thd->query_plan_flags|= QPLAN_QC;
561 thd->main_da.disable_status();
563 BLOCK_UNLOCK_RD(query_block);
564 @@ -1473,6 +1474,7 @@
566 STRUCT_UNLOCK(&structure_guard_mutex);
568 + thd->query_plan_flags|= QPLAN_QC_NO;
569 DBUG_RETURN(0); // Query was not cached
572 diff -r 0b1f42e1aacf sql/sql_class.h
573 --- a/sql/sql_class.h Thu Dec 04 08:55:22 2008 -0800
574 +++ b/sql/sql_class.h Thu Dec 04 08:55:29 2008 -0800
576 DATE_TIME_FORMAT *datetime_format;
577 DATE_TIME_FORMAT *time_format;
578 my_bool sysdate_is_now;
580 + ulong log_slow_rate_limit;
581 + ulong log_slow_filter;
582 + ulong log_slow_verbosity;
587 @@ -1339,6 +1344,11 @@
589 thr_lock_type update_lock_default;
592 + bool write_to_slow_log;
594 + ulong query_plan_flags;
595 + ulong query_plan_fsort_passes;
597 /* <> 0 if we are inside of trigger or stored function. */
599 diff -r 0b1f42e1aacf sql/sql_connect.cc
600 --- a/sql/sql_connect.cc Thu Dec 04 08:55:22 2008 -0800
601 +++ b/sql/sql_connect.cc Thu Dec 04 08:55:29 2008 -0800
602 @@ -1124,6 +1124,15 @@
604 prepare_new_connection_state(thd);
607 + If rate limiting of slow log writes is enabled, decide whether to log this
608 + new thread's queries or not. Uses extremely simple algorithm. :)
610 + thd->write_to_slow_log= FALSE;
611 + if (thd->variables.log_slow_rate_limit <= 1 ||
612 + (thd->thread_id % thd->variables.log_slow_rate_limit) == 0)
613 + thd->write_to_slow_log= TRUE;
615 while (!net->error && net->vio != 0 &&
616 !(thd->killed == THD::KILL_CONNECTION))
618 diff -r 0b1f42e1aacf sql/sql_parse.cc
619 --- a/sql/sql_parse.cc Thu Dec 04 08:55:22 2008 -0800
620 +++ b/sql/sql_parse.cc Thu Dec 04 08:55:29 2008 -0800
621 @@ -1692,6 +1692,27 @@
622 if (unlikely(thd->in_sub_stmt))
623 DBUG_VOID_RETURN; // Don't set time for sub stmt
625 + /* Follow the slow log filter configuration. */
626 + if (thd->variables.log_slow_filter != SLOG_F_NONE &&
627 + (!(thd->variables.log_slow_filter & thd->query_plan_flags) ||
628 + ((thd->variables.log_slow_filter & SLOG_F_QC_NO) &&
629 + (thd->query_plan_flags & QPLAN_QC))))
633 + Low long_query_time value most likely means user is debugging stuff and even
634 + though some thread's queries are not supposed to be logged b/c of the rate
635 + limit, if one of them takes long enough (>= 1 second) it will be sensible
636 + to make an exception and write to slow log anyway.
638 + if (thd->write_to_slow_log != TRUE && thd->variables.long_query_time < 1000000 &&
639 + (ulong) (thd->start_utime - thd->utime_after_lock) >= 1000000)
640 + thd->write_to_slow_log= TRUE;
642 + /* Do not log this thread's queries due to rate limiting. */
643 + if (thd->write_to_slow_log != TRUE)
647 Do not log administrative statements unless the appropriate option is
648 set; do not log into slow log if reading from backup.
649 @@ -5773,6 +5794,9 @@
650 thd->total_warn_count=0; // Warnings for this query
652 thd->sent_row_count= thd->examined_row_count= 0;
654 + thd->query_plan_flags= QPLAN_NONE;
655 + thd->query_plan_fsort_passes= 0;
658 Because we come here only for start of top-statements, binlog format is
659 diff -r 0b1f42e1aacf sql/sql_select.cc
660 --- a/sql/sql_select.cc Thu Dec 04 08:55:22 2008 -0800
661 +++ b/sql/sql_select.cc Thu Dec 04 08:55:29 2008 -0800
662 @@ -6480,7 +6480,10 @@
664 join->thd->server_status|=SERVER_QUERY_NO_INDEX_USED;
667 status_var_increment(join->thd->status_var.select_scan_count);
668 + join->thd->query_plan_flags|= QPLAN_FULL_SCAN;
673 @@ -6494,7 +6497,10 @@
675 join->thd->server_status|=SERVER_QUERY_NO_INDEX_USED;
678 status_var_increment(join->thd->status_var.select_full_join_count);
679 + join->thd->query_plan_flags|= QPLAN_FULL_JOIN;
683 if (!table->no_keyread)
684 @@ -9638,6 +9644,7 @@
685 (ulong) rows_limit,test(group)));
687 status_var_increment(thd->status_var.created_tmp_tables);
688 + thd->query_plan_flags|= QPLAN_TMP_TABLE;
690 if (use_temp_pool && !(test_flags & TEST_KEEP_TMP_TABLES))
691 temp_pool_slot = bitmap_lock_set_next(&temp_pool);
692 @@ -10508,6 +10515,7 @@
695 status_var_increment(table->in_use->status_var.created_tmp_disk_tables);
696 + table->in_use->query_plan_flags|= QPLAN_TMP_DISK;
697 share->db_record_offset= 1;