@@ -309,10 +309,11 @@ void init_update_queries(void)
309
309
sql_command_flags[SQLCOM_CREATE_TABLE]= CF_CHANGES_DATA | CF_REEXECUTION_FRAGILE |
310
310
CF_AUTO_COMMIT_TRANS | CF_REPORT_PROGRESS |
311
311
CF_CAN_GENERATE_ROW_EVENTS;
312
- sql_command_flags[SQLCOM_CREATE_INDEX]= CF_CHANGES_DATA | CF_AUTO_COMMIT_TRANS | CF_REPORT_PROGRESS;
312
+ sql_command_flags[SQLCOM_CREATE_INDEX]= CF_CHANGES_DATA | CF_AUTO_COMMIT_TRANS |
313
+ CF_REPORT_PROGRESS | CF_ADMIN_COMMAND;
313
314
sql_command_flags[SQLCOM_ALTER_TABLE]= CF_CHANGES_DATA | CF_WRITE_LOGS_COMMAND |
314
315
CF_AUTO_COMMIT_TRANS | CF_REPORT_PROGRESS |
315
- CF_INSERTS_DATA;
316
+ CF_INSERTS_DATA | CF_ADMIN_COMMAND ;
316
317
sql_command_flags[SQLCOM_TRUNCATE]= CF_CHANGES_DATA | CF_WRITE_LOGS_COMMAND |
317
318
CF_AUTO_COMMIT_TRANS;
318
319
sql_command_flags[SQLCOM_DROP_TABLE]= CF_CHANGES_DATA | CF_AUTO_COMMIT_TRANS;
@@ -324,7 +325,8 @@ void init_update_queries(void)
324
325
sql_command_flags[SQLCOM_ALTER_DB_UPGRADE]= CF_AUTO_COMMIT_TRANS;
325
326
sql_command_flags[SQLCOM_ALTER_DB]= CF_CHANGES_DATA | CF_AUTO_COMMIT_TRANS;
326
327
sql_command_flags[SQLCOM_RENAME_TABLE]= CF_CHANGES_DATA | CF_AUTO_COMMIT_TRANS;
327
- sql_command_flags[SQLCOM_DROP_INDEX]= CF_CHANGES_DATA | CF_AUTO_COMMIT_TRANS | CF_REPORT_PROGRESS;
328
+ sql_command_flags[SQLCOM_DROP_INDEX]= CF_CHANGES_DATA | CF_AUTO_COMMIT_TRANS |
329
+ CF_REPORT_PROGRESS | CF_ADMIN_COMMAND;
328
330
sql_command_flags[SQLCOM_CREATE_VIEW]= CF_CHANGES_DATA | CF_REEXECUTION_FRAGILE |
329
331
CF_AUTO_COMMIT_TRANS;
330
332
sql_command_flags[SQLCOM_DROP_VIEW]= CF_CHANGES_DATA | CF_AUTO_COMMIT_TRANS;
@@ -492,10 +494,14 @@ void init_update_queries(void)
492
494
The following admin table operations are allowed
493
495
on log tables.
494
496
*/
495
- sql_command_flags[SQLCOM_REPAIR]= CF_WRITE_LOGS_COMMAND | CF_AUTO_COMMIT_TRANS | CF_REPORT_PROGRESS;
496
- sql_command_flags[SQLCOM_OPTIMIZE]|= CF_WRITE_LOGS_COMMAND | CF_AUTO_COMMIT_TRANS | CF_REPORT_PROGRESS;
497
- sql_command_flags[SQLCOM_ANALYZE]= CF_WRITE_LOGS_COMMAND | CF_AUTO_COMMIT_TRANS | CF_REPORT_PROGRESS;
498
- sql_command_flags[SQLCOM_CHECK]= CF_WRITE_LOGS_COMMAND | CF_AUTO_COMMIT_TRANS | CF_REPORT_PROGRESS;
497
+ sql_command_flags[SQLCOM_REPAIR]= CF_WRITE_LOGS_COMMAND | CF_AUTO_COMMIT_TRANS |
498
+ CF_REPORT_PROGRESS | CF_ADMIN_COMMAND;
499
+ sql_command_flags[SQLCOM_OPTIMIZE]|= CF_WRITE_LOGS_COMMAND | CF_AUTO_COMMIT_TRANS |
500
+ CF_REPORT_PROGRESS | CF_ADMIN_COMMAND;
501
+ sql_command_flags[SQLCOM_ANALYZE]= CF_WRITE_LOGS_COMMAND | CF_AUTO_COMMIT_TRANS |
502
+ CF_REPORT_PROGRESS | CF_ADMIN_COMMAND;
503
+ sql_command_flags[SQLCOM_CHECK]= CF_WRITE_LOGS_COMMAND | CF_AUTO_COMMIT_TRANS |
504
+ CF_REPORT_PROGRESS | CF_ADMIN_COMMAND;
499
505
sql_command_flags[SQLCOM_CHECKSUM]= CF_REPORT_PROGRESS;
500
506
501
507
sql_command_flags[SQLCOM_CREATE_USER]|= CF_AUTO_COMMIT_TRANS;
@@ -1304,10 +1310,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
1304
1310
m_key);
1305
1311
thd->set_command (command);
1306
1312
1307
- /*
1308
- Commands which always take a long time are logged into
1309
- the slow log only if opt_log_slow_admin_statements is set.
1310
- */
1311
1313
thd->enable_slow_log = true ;
1312
1314
thd->query_plan_flags = QPLAN_INIT;
1313
1315
thd->lex ->sql_command = SQLCOM_END; /* to avoid confusing VIEW detectors */
@@ -1718,7 +1720,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
1718
1720
1719
1721
status_var_increment (thd->status_var .com_other );
1720
1722
1721
- thd->enable_slow_log &= opt_log_slow_admin_statements;
1722
1723
thd->query_plan_flags |= QPLAN_ADMIN;
1723
1724
if (check_global_access (thd, REPL_SLAVE_ACL))
1724
1725
break ;
@@ -2018,31 +2019,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
2018
2019
}
2019
2020
2020
2021
2021
- static bool log_slow_enabled_statement (const THD *thd)
2022
- {
2023
- /*
2024
- TODO-10.4: Add classes Sql_cmd_create_index and Sql_cmd_drop_index
2025
- for symmetry with other admin commands, so these statements can be
2026
- handled by this command:
2027
- */
2028
- if (thd->lex ->m_sql_cmd )
2029
- return thd->lex ->m_sql_cmd ->log_slow_enabled_statement (thd);
2030
-
2031
- /*
2032
- Currently CREATE INDEX or DROP INDEX cause a full table rebuild
2033
- and thus classify as slow administrative statements just like
2034
- ALTER TABLE.
2035
- */
2036
- if ((thd->lex ->sql_command == SQLCOM_CREATE_INDEX ||
2037
- thd->lex ->sql_command == SQLCOM_DROP_INDEX) &&
2038
- !opt_log_slow_admin_statements)
2039
- return true ;
2040
-
2041
- return global_system_variables.sql_log_slow &&
2042
- thd->variables .sql_log_slow ;
2043
- }
2044
-
2045
-
2046
2022
/*
2047
2023
@note
2048
2024
This function must call delete_explain_query().
@@ -2075,12 +2051,20 @@ void log_slow_statement(THD *thd)
2075
2051
((thd->server_status &
2076
2052
(SERVER_QUERY_NO_INDEX_USED | SERVER_QUERY_NO_GOOD_INDEX_USED)) &&
2077
2053
opt_log_queries_not_using_indexes &&
2078
- !(sql_command_flags[ thd->lex -> sql_command ] & CF_STATUS_COMMAND ))) &&
2054
+ !(thd->query_plan_flags & QPLAN_STATUS ))) &&
2079
2055
thd->get_examined_row_count () >= thd->variables .min_examined_row_limit )
2080
2056
{
2081
2057
thd->status_var .long_query_count ++;
2082
2058
2083
- if (!log_slow_enabled_statement (thd))
2059
+ /*
2060
+ until opt_log_slow_admin_statements is removed, it
2061
+ duplicates slow_log_filter=admin
2062
+ */
2063
+ if ((thd->query_plan_flags & QPLAN_ADMIN) &&
2064
+ !opt_log_slow_admin_statements)
2065
+ goto end;
2066
+
2067
+ if (!global_system_variables.sql_log_slow || !thd->variables .sql_log_slow )
2084
2068
goto end;
2085
2069
2086
2070
/*
@@ -2953,6 +2937,11 @@ mysql_execute_command(THD *thd)
2953
2937
goto error;
2954
2938
}
2955
2939
2940
+ if (sql_command_flags[lex->sql_command ] & CF_STATUS_COMMAND)
2941
+ thd->query_plan_flags |= QPLAN_STATUS;
2942
+ if (sql_command_flags[lex->sql_command ] & CF_ADMIN_COMMAND)
2943
+ thd->query_plan_flags |= QPLAN_ADMIN;
2944
+
2956
2945
/* Start timeouts */
2957
2946
thd->set_query_timer ();
2958
2947
@@ -3574,7 +3563,6 @@ mysql_execute_command(THD *thd)
3574
3563
if (check_one_table_access (thd, INDEX_ACL, all_tables))
3575
3564
goto error; /* purecov: inspected */
3576
3565
WSREP_TO_ISOLATION_BEGIN (first_table->db , first_table->table_name , NULL )
3577
- thd->query_plan_flags |= QPLAN_ADMIN;
3578
3566
3579
3567
bzero ((char *) &create_info, sizeof (create_info));
3580
3568
create_info.db_type = 0 ;
@@ -5732,7 +5720,6 @@ mysql_execute_command(THD *thd)
5732
5720
case SQLCOM_REPAIR:
5733
5721
case SQLCOM_TRUNCATE:
5734
5722
case SQLCOM_ALTER_TABLE:
5735
- thd->query_plan_flags |= QPLAN_ADMIN;
5736
5723
DBUG_ASSERT (first_table == all_tables && first_table != 0 );
5737
5724
/* fall through */
5738
5725
case SQLCOM_SIGNAL:
0 commit comments