mirror of
https://github.com/MariaDB/server.git
synced 2025-12-06 05:42:06 +03:00
WL #562: Change format of slow log in 4.1
This commit is contained in:
@@ -1564,7 +1564,7 @@ bool MYSQL_LOG::write(THD *thd,const char *query, uint query_length,
|
|||||||
VOID(pthread_mutex_unlock(&LOCK_log));
|
VOID(pthread_mutex_unlock(&LOCK_log));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if ((specialflag & SPECIAL_LONG_LOG_FORMAT) || query_start_arg)
|
if (!(specialflag & SPECIAL_SHORT_LOG_FORMAT) || query_start_arg)
|
||||||
{
|
{
|
||||||
current_time=time(NULL);
|
current_time=time(NULL);
|
||||||
if (current_time != last_time)
|
if (current_time != last_time)
|
||||||
@@ -1617,7 +1617,7 @@ bool MYSQL_LOG::write(THD *thd,const char *query, uint query_length,
|
|||||||
// Save value if we do an insert.
|
// Save value if we do an insert.
|
||||||
if (thd->insert_id_used)
|
if (thd->insert_id_used)
|
||||||
{
|
{
|
||||||
if (specialflag & SPECIAL_LONG_LOG_FORMAT)
|
if (!(specialflag & SPECIAL_SHORT_LOG_FORMAT))
|
||||||
{
|
{
|
||||||
end=strmov(end,",insert_id=");
|
end=strmov(end,",insert_id=");
|
||||||
end=longlong10_to_str((longlong) thd->last_insert_id,end,-10);
|
end=longlong10_to_str((longlong) thd->last_insert_id,end,-10);
|
||||||
|
|||||||
@@ -262,6 +262,8 @@ my_bool opt_log_slave_updates= 0;
|
|||||||
my_bool opt_console= 0, opt_bdb, opt_innodb, opt_isam;
|
my_bool opt_console= 0, opt_bdb, opt_innodb, opt_isam;
|
||||||
my_bool opt_readonly, use_temp_pool, relay_log_purge;
|
my_bool opt_readonly, use_temp_pool, relay_log_purge;
|
||||||
my_bool opt_secure_auth= 0;
|
my_bool opt_secure_auth= 0;
|
||||||
|
my_bool opt_short_log_format= 0;
|
||||||
|
my_bool opt_log_queries_not_using_indexes= 0;
|
||||||
volatile bool mqh_used = 0;
|
volatile bool mqh_used = 0;
|
||||||
|
|
||||||
uint mysqld_port, test_flags, select_errors, dropping_tables, ha_open_options;
|
uint mysqld_port, test_flags, select_errors, dropping_tables, ha_open_options;
|
||||||
@@ -3455,7 +3457,7 @@ enum options
|
|||||||
OPT_SKIP_PRIOR, OPT_BIG_TABLES,
|
OPT_SKIP_PRIOR, OPT_BIG_TABLES,
|
||||||
OPT_STANDALONE, OPT_ONE_THREAD,
|
OPT_STANDALONE, OPT_ONE_THREAD,
|
||||||
OPT_CONSOLE, OPT_LOW_PRIORITY_UPDATES,
|
OPT_CONSOLE, OPT_LOW_PRIORITY_UPDATES,
|
||||||
OPT_SKIP_HOST_CACHE, OPT_LONG_FORMAT,
|
OPT_SKIP_HOST_CACHE, OPT_SHORT_LOG_FORMAT,
|
||||||
OPT_FLUSH, OPT_SAFE,
|
OPT_FLUSH, OPT_SAFE,
|
||||||
OPT_BOOTSTRAP, OPT_SKIP_SHOW_DB,
|
OPT_BOOTSTRAP, OPT_SKIP_SHOW_DB,
|
||||||
OPT_TABLE_TYPE, OPT_INIT_FILE,
|
OPT_TABLE_TYPE, OPT_INIT_FILE,
|
||||||
@@ -3562,7 +3564,8 @@ enum options
|
|||||||
OPT_DEFAULT_WEEK_FORMAT,
|
OPT_DEFAULT_WEEK_FORMAT,
|
||||||
OPT_GROUP_CONCAT_MAX_LEN,
|
OPT_GROUP_CONCAT_MAX_LEN,
|
||||||
OPT_DEFAULT_COLLATION,
|
OPT_DEFAULT_COLLATION,
|
||||||
OPT_SECURE_AUTH
|
OPT_SECURE_AUTH,
|
||||||
|
OPT_LOG_QUERIES_NOT_USING_INDEXES
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -3769,9 +3772,17 @@ Disable with --skip-bdb (will save memory).",
|
|||||||
"Log slow queries to this log file. Defaults logging to hostname-slow.log file.",
|
"Log slow queries to this log file. Defaults logging to hostname-slow.log file.",
|
||||||
(gptr*) &opt_slow_logname, (gptr*) &opt_slow_logname, 0, GET_STR, OPT_ARG,
|
(gptr*) &opt_slow_logname, (gptr*) &opt_slow_logname, 0, GET_STR, OPT_ARG,
|
||||||
0, 0, 0, 0, 0, 0},
|
0, 0, 0, 0, 0, 0},
|
||||||
{"log-long-format", OPT_LONG_FORMAT,
|
{"log-long-format", '0',
|
||||||
"Log some extra information to update log.", 0, 0, 0, GET_NO_ARG, NO_ARG,
|
"Log some extra information to update log. Please note that this option is deprecated; see --log-short-format option.",
|
||||||
0, 0, 0, 0, 0, 0},
|
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||||
|
{"log-short-format", OPT_SHORT_LOG_FORMAT,
|
||||||
|
"Don't log extra information to update and slow-query logs.",
|
||||||
|
(gptr*) &opt_short_log_format, (gptr*) &opt_short_log_format,
|
||||||
|
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||||
|
{"log-queries-not-using-indexes", OPT_LOG_QUERIES_NOT_USING_INDEXES,
|
||||||
|
"Log queries that are executed without benefit of any index.",
|
||||||
|
(gptr*) &opt_log_queries_not_using_indexes, (gptr*) &opt_log_queries_not_using_indexes,
|
||||||
|
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||||
{"log-slave-updates", OPT_LOG_SLAVE_UPDATES,
|
{"log-slave-updates", OPT_LOG_SLAVE_UPDATES,
|
||||||
"Tells the slave to log the updates from the slave thread to the binary log. You will need to turn it on if you plan to daisy-chain the slaves.",
|
"Tells the slave to log the updates from the slave thread to the binary log. You will need to turn it on if you plan to daisy-chain the slaves.",
|
||||||
(gptr*) &opt_log_slave_updates, (gptr*) &opt_log_slave_updates, 0, GET_BOOL,
|
(gptr*) &opt_log_slave_updates, (gptr*) &opt_log_slave_updates, 0, GET_BOOL,
|
||||||
@@ -5166,9 +5177,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
|||||||
case (int) OPT_SKIP_RESOLVE:
|
case (int) OPT_SKIP_RESOLVE:
|
||||||
opt_specialflag|=SPECIAL_NO_RESOLVE;
|
opt_specialflag|=SPECIAL_NO_RESOLVE;
|
||||||
break;
|
break;
|
||||||
case (int) OPT_LONG_FORMAT:
|
|
||||||
opt_specialflag|=SPECIAL_LONG_LOG_FORMAT;
|
|
||||||
break;
|
|
||||||
case (int) OPT_SKIP_NETWORKING:
|
case (int) OPT_SKIP_NETWORKING:
|
||||||
opt_disable_networking=1;
|
opt_disable_networking=1;
|
||||||
mysqld_port=0;
|
mysqld_port=0;
|
||||||
@@ -5508,6 +5516,10 @@ static void get_options(int argc,char **argv)
|
|||||||
keybuff_size= (((KEY_CACHE *) find_named(&key_caches, "default", 7,
|
keybuff_size= (((KEY_CACHE *) find_named(&key_caches, "default", 7,
|
||||||
¬_used))->size);
|
¬_used))->size);
|
||||||
}
|
}
|
||||||
|
if (opt_short_log_format)
|
||||||
|
opt_specialflag|= SPECIAL_SHORT_LOG_FORMAT;
|
||||||
|
if (opt_log_queries_not_using_indexes)
|
||||||
|
opt_specialflag|= SPECIAL_LOG_QUERIES_NOT_USING_INDEXES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1566,7 +1566,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
|||||||
thd->variables.long_query_time ||
|
thd->variables.long_query_time ||
|
||||||
((thd->lex.select_lex.options &
|
((thd->lex.select_lex.options &
|
||||||
(QUERY_NO_INDEX_USED | QUERY_NO_GOOD_INDEX_USED)) &&
|
(QUERY_NO_INDEX_USED | QUERY_NO_GOOD_INDEX_USED)) &&
|
||||||
(specialflag & SPECIAL_LONG_LOG_FORMAT)))
|
(specialflag & SPECIAL_LOG_QUERIES_NOT_USING_INDEXES)))
|
||||||
{
|
{
|
||||||
long_query_count++;
|
long_query_count++;
|
||||||
mysql_slow_log.write(thd, thd->query, thd->query_length, start_of_query);
|
mysql_slow_log.write(thd, thd->query, thd->query_length, start_of_query);
|
||||||
|
|||||||
@@ -107,8 +107,9 @@
|
|||||||
#define SPECIAL_NO_PRIOR 128 /* Don't prioritize threads */
|
#define SPECIAL_NO_PRIOR 128 /* Don't prioritize threads */
|
||||||
#define SPECIAL_BIG_SELECTS 256 /* Don't use heap tables */
|
#define SPECIAL_BIG_SELECTS 256 /* Don't use heap tables */
|
||||||
#define SPECIAL_NO_HOST_CACHE 512 /* Don't cache hosts */
|
#define SPECIAL_NO_HOST_CACHE 512 /* Don't cache hosts */
|
||||||
#define SPECIAL_LONG_LOG_FORMAT 1024
|
#define SPECIAL_SHORT_LOG_FORMAT 1024
|
||||||
#define SPECIAL_SAFE_MODE 2048
|
#define SPECIAL_SAFE_MODE 2048
|
||||||
|
#define SPECIAL_LOG_QUERIES_NOT_USING_INDEXES 4096 /* Log q not using indexes */
|
||||||
|
|
||||||
/* Extern defines */
|
/* Extern defines */
|
||||||
#define store_record(A,B) bmove_align((A)->B,(A)->record[0],(size_t) (A)->reclength)
|
#define store_record(A,B) bmove_align((A)->B,(A)->record[0],(size_t) (A)->reclength)
|
||||||
|
|||||||
Reference in New Issue
Block a user