diff options
author | unknown <malff/marcsql@weblab.(none)> | 2007-06-13 22:05:22 -0600 |
---|---|---|
committer | unknown <malff/marcsql@weblab.(none)> | 2007-06-13 22:05:22 -0600 |
commit | 8b8b28881f3561275658bac76cc150636ecffa1d (patch) | |
tree | 4891c6081abc746f7a7839a325d1240327ceee5d /mysql-test/t/log_tables.test | |
parent | 4b435ac7c703f2dbd50efc17248961e03c9284c0 (diff) | |
download | mariadb-git-8b8b28881f3561275658bac76cc150636ecffa1d.tar.gz |
Bug#27857 (Log tables supplies the wrong value for generating AUTO_INCREMENT
numbers)
Before this patch, the code in the class Log_to_csv_event_handler, which is
used by the global LOGGER object to write to the tables mysql.slow_log and
mysql_general_log, was supporting only records of the format defined for
these tables in the database creation scripts.
Also before this patch, the server would allow, with certain limitations,
to perform ALTER TABLE on the LOG TABLES.
As implemented, the behavior of the server, with regards to LOG TABLES,
is inconsistent:
- either ALTER TABLES on LOG TABLES should be prohibited,
and the code writing to these tables can make assumptions on the record
format,
- or ALTER TABLE on LOG TABLES is permitted, in which case the code
writing a record to these tables should be more flexible and honor
new fields.
In particular, adding an AUTO_INCREMENT column to the logs,
does not work as expected (per the bug report).
Given that the ALTER TABLE on log tables statement has been explicitly
implemented to check that the log should be off to perform the operation,
and that current test cases already cover this, the user expectation is
already set that this is a "feature" and should be supported.
With this patch, the server will:
- populate AUTO INCREMENT columns if present,
- populate any additional column with it's default value
when writing a record to the LOG TABLES.
Tests are provided, that detail the precise sequence of statements
a SUPER user might want to perform to add more columns to the log tables.
mysql-test/r/log_tables.result:
Test case for bug#27857
mysql-test/t/log_tables.test:
Test case for bug#27857
sql/log.cc:
Set extra fields in log tables with default values.
Diffstat (limited to 'mysql-test/t/log_tables.test')
-rw-r--r-- | mysql-test/t/log_tables.test | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/mysql-test/t/log_tables.test b/mysql-test/t/log_tables.test index b02a47dde6b..e8eff7cba0a 100644 --- a/mysql-test/t/log_tables.test +++ b/mysql-test/t/log_tables.test @@ -400,6 +400,76 @@ show tables like "%log%"; drop table slow_log_new, general_log_new; use test; +# +# Bug#27857 (Log tables supplies the wrong value for generating +# AUTO_INCREMENT numbers) +# + +SET GLOBAL LOG_OUTPUT = 'TABLE'; + +## test the general log + +SET GLOBAL general_log = 0; +FLUSH LOGS; + +TRUNCATE TABLE mysql.general_log; +ALTER TABLE mysql.general_log ENGINE = MyISAM; +ALTER TABLE mysql.general_log + ADD COLUMN seq BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY; + +SET GLOBAL general_log = 1; +FLUSH LOGS; + +--replace_column 1 EVENT_TIME 2 USER_HOST 3 THREAD_ID 4 SERVER_ID +SELECT * FROM mysql.general_log; +--replace_column 1 EVENT_TIME 2 USER_HOST 3 THREAD_ID 4 SERVER_ID +SELECT * FROM mysql.general_log; +SELECT "My own query 1"; +SELECT "My own query 2"; +--replace_column 1 EVENT_TIME 2 USER_HOST 3 THREAD_ID 4 SERVER_ID +SELECT * FROM mysql.general_log; + +SET GLOBAL general_log = 0; +FLUSH LOGS; + +ALTER TABLE mysql.general_log DROP COLUMN seq; +ALTER TABLE mysql.general_log ENGINE = CSV; + +## test the slow query log + +SET @old_long_query_time:=@@long_query_time; + +SET GLOBAL slow_query_log = 0; +FLUSH LOGS; + +TRUNCATE TABLE mysql.slow_log; +ALTER TABLE mysql.slow_log ENGINE = MyISAM; + +ALTER TABLE mysql.slow_log + ADD COLUMN seq BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY; + +SET SESSION long_query_time = 1; +SET GLOBAL slow_query_log = 1; +FLUSH LOGS; + +## FLUSH LOGS above might be slow, so the following is +## logged as either seq 1-4 or seq 2-5 +SELECT "My own slow query", sleep(2); +SELECT "My own slow query", sleep(2); +SELECT "My own slow query", sleep(2); +SELECT "My own slow query", sleep(2); + +## So we look for seq 2-4 +--replace_column 1 START_TIME 2 USER_HOST 3 QUERY_TIME +SELECT * FROM mysql.slow_log WHERE seq >= 2 LIMIT 3; + +SET GLOBAL slow_query_log = 0; +SET SESSION long_query_time =@old_long_query_time; +FLUSH LOGS; + +ALTER TABLE mysql.slow_log DROP COLUMN seq; +ALTER TABLE mysql.slow_log ENGINE = CSV; + # kill all connections disconnect con1; disconnect con2; |