Below is the list of changes that have just been committed into a local
5.1 repository of andrey. When andrey does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.2215 06/03/01 16:27:57 andrey@lmy004. +6 -0
fix for bug #16413 (Events: statements don't appear in the general query log)
WL#1034
mysql-test/t/events_logs_tests.test
1.4 06/03/01 16:27:47 andrey@lmy004. +15 -0
add test for general log
mysql-test/r/events_logs_tests.result
1.4 06/03/01 16:27:47 andrey@lmy004. +19 -0
update result file
sql/sp_head.h
1.82 06/03/01 16:27:46 andrey@lmy004. +2 -1
add a new flag for general log
sql/sp_head.cc
1.210 06/03/01 16:27:46 andrey@lmy004. +17 -5
save the OPTION_LOG_OFF and restore it after execution
sql/event_timed.cc
1.44 06/03/01 16:27:46 andrey@lmy004. +2 -0
ask the anonymous SP to log general statements
mysql-test/r/events_logs_tests.result
1.3 06/03/01 16:15:00 andrey@lmy004. +0 -0
Rename: mysql-test/r/events_slow_query.result -> mysql-test/r/events_logs_tests.result
mysql-test/t/events_logs_tests-master.opt
1.2 06/03/01 16:14:27 andrey@lmy004. +0 -0
Rename: mysql-test/t/events_slow_query-master.opt -> mysql-test/t/events_logs_tests-master.opt
mysql-test/t/events_logs_tests.test
1.3 06/03/01 16:14:08 andrey@lmy004. +0 -0
Rename: mysql-test/t/events_slow_query.test -> mysql-test/t/events_logs_tests.test
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: andrey
# Host: lmy004.
# Root: /work/mysql-5.1-bug17494
--- 1.2/mysql-test/r/events_slow_query.result 2006-03-01 03:49:21 +01:00
+++ 1.4/mysql-test/r/events_logs_tests.result 2006-03-01 16:27:47 +01:00
@@ -1,5 +1,24 @@
create database if not exists events_test;
use events_test;
+"Check General Query Log"
+SET GLOBAL event_scheduler=0;
+create event log_general on schedule every 1 minute do seLect 'alabala', sleep(3) from dual;
+TRUNCATE mysql.general_log;
+SELECT user_host, command_type, argument FROM mysql.general_log;
+user_host command_type argument
+root[root] @ localhost [] Query SELECT user_host, command_type, argument FROM mysql.general_log
+SET GLOBAL event_scheduler=1;
+"Wait the scheduler to start"
+"Should see 3 rows. The create, the seLect and the select from the general_log"
+SELECT user_host, command_type, argument FROM mysql.general_log;
+user_host command_type argument
+root[root] @ localhost [] Query SELECT user_host, command_type, argument FROM mysql.general_log
+root[root] @ localhost [] Query SET GLOBAL event_scheduler=1
+root[root] @ localhost [localhost] Query seLect 'alabala', sleep(3) from dual
+root[root] @ localhost [] Query SELECT user_host, command_type, argument FROM mysql.general_log
+DROP EVENT log_general;
+SET GLOBAL event_scheduler=0;
+"Check slow query log"
"Save the values"
SET @old_global_long_query_time:=(select get_value());
SET @old_session_long_query_time:=@@long_query_time;
--- 1.2/mysql-test/t/events_slow_query.test 2006-03-01 03:49:21 +01:00
+++ 1.4/mysql-test/t/events_logs_tests.test 2006-03-01 16:27:47 +01:00
@@ -1,6 +1,21 @@
create database if not exists events_test;
use events_test;
+--echo "Check General Query Log"
+SET GLOBAL event_scheduler=0;
+create event log_general on schedule every 1 minute do seLect 'alabala', sleep(3) from dual;
+TRUNCATE mysql.general_log;
+SELECT user_host, command_type, argument FROM mysql.general_log;
+SET GLOBAL event_scheduler=1;
+--echo "Wait the scheduler to start"
+--echo "Should see 3 rows. The create, the seLect and the select from the general_log"
+--sleep 2
+SELECT user_host, command_type, argument FROM mysql.general_log;
+DROP EVENT log_general;
+SET GLOBAL event_scheduler=0;
+--sleep 1
+
+--echo "Check slow query log"
--disable_query_log
DELIMITER |;
CREATE FUNCTION get_value()
--- 1.43/sql/event_timed.cc 2006-03-01 02:34:06 +01:00
+++ 1.44/sql/event_timed.cc 2006-03-01 16:27:46 +01:00
@@ -1164,6 +1164,8 @@ Event_timed::execute(THD *thd, MEM_ROOT
empty_item_list.empty();
if (thd->enable_slow_log)
sphead->m_flags|= sp_head::LOG_SLOW_STATEMENTS;
+ sphead->m_flags|= sp_head::LOG_GENERAL_LOG;
+
ret= sphead->execute_procedure(thd, &empty_item_list);
}
else
--- 1.209/sql/sp_head.cc 2006-03-01 03:49:21 +01:00
+++ 1.210/sql/sp_head.cc 2006-03-01 16:27:46 +01:00
@@ -1413,6 +1413,7 @@ sp_head::execute_procedure(THD *thd, Lis
sp_rcontext *save_spcont, *octx;
sp_rcontext *nctx = NULL;
bool save_enable_slow_log= false;
+ bool save_log_general= false;
DBUG_ENTER("sp_head::execute_procedure");
DBUG_PRINT("info", ("procedure %s", m_name.str));
@@ -1511,20 +1512,28 @@ sp_head::execute_procedure(THD *thd, Lis
DBUG_PRINT("info",(" %.*s: eval args done", m_name.length, m_name.str));
}
- if (thd->enable_slow_log && !(m_flags & LOG_SLOW_STATEMENTS))
+ if (!(m_flags & LOG_SLOW_STATEMENTS) && thd->enable_slow_log)
{
DBUG_PRINT("info", ("Disabling slow log for the execution"));
- save_enable_slow_log= thd->enable_slow_log;
+ save_enable_slow_log= true;
thd->enable_slow_log= FALSE;
}
+ if (!(m_flags & LOG_GENERAL_LOG) && !(thd->options & OPTION_LOG_OFF))
+ {
+ DBUG_PRINT("info", ("Disabling general log for the execution"));
+ save_log_general= true;
+ /* disable this bit */
+ thd->options |= OPTION_LOG_OFF;
+ }
thd->spcont= nctx;
if (!err_status)
err_status= execute(thd);
- if (save_enable_slow_log && !(m_flags & LOG_SLOW_STATEMENTS))
- thd->enable_slow_log= save_enable_slow_log;
-
+ if (save_log_general)
+ thd->options &= ~OPTION_LOG_OFF;
+ if (save_enable_slow_log)
+ thd->enable_slow_log= true;
/*
In the case when we weren't able to employ reuse mechanism for
OUT/INOUT paranmeters, we should reallocate memory. This
@@ -2303,6 +2312,9 @@ sp_instr_stmt::execute(THD *thd, uint *n
(the order of query cache and subst_spvars calls is irrelevant because
queries with SP vars can't be cached)
*/
+ if (unlikely((thd->options & OPTION_LOG_OFF)==0))
+ general_log_print(thd, COM_QUERY, "%s", thd->query);
+
if (query_cache_send_result_to_client(thd,
thd->query, thd->query_length) <= 0)
{
--- 1.81/sql/sp_head.h 2006-03-01 02:34:06 +01:00
+++ 1.82/sql/sp_head.h 2006-03-01 16:27:46 +01:00
@@ -125,7 +125,8 @@ public:
HAS_SET_AUTOCOMMIT_STMT= 64,// Is set if a procedure with 'set autocommit'
/* Is set if a procedure with COMMIT (implicit or explicit) | ROLLBACK */
HAS_COMMIT_OR_ROLLBACK= 128,
- LOG_SLOW_STATEMENTS= 256
+ LOG_SLOW_STATEMENTS= 256, // Used by events
+ LOG_GENERAL_LOG= 512 // Used by events
};
/* TYPE_ENUM_FUNCTION, TYPE_ENUM_PROCEDURE or TYPE_ENUM_TRIGGER */
| Thread |
|---|
| • bk commit into 5.1 tree (andrey:1.2215) BUG#16413 | ahristov | 1 Mar |