Bug #27857 | Log tables supplies the wrong value for generating AUTO_INCREMENT numbers | ||
---|---|---|---|
Submitted: | 16 Apr 2007 17:59 | Modified: | 11 Jul 2007 16:45 |
Reporter: | Tobias Asplund | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Logging | Severity: | S3 (Non-critical) |
Version: | 5.1.18 | OS: | Linux |
Assigned to: | Marc ALFF | CPU Architecture: | Any |
[16 Apr 2007 17:59]
Tobias Asplund
[16 Apr 2007 18:11]
MySQL Verification Team
Thank you for the bug report. Verified as described.
[14 Jun 2007 4:05]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/28708 ChangeSet@1.2551, 2007-06-13 22:05:22-06:00, malff@weblab.(none) +3 -0 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.
[20 Jun 2007 19:54]
Bugs System
Pushed into 5.1.20-beta
[11 Jul 2007 16:45]
Paul DuBois
Noted in 5.1.20 changelog. The server made strong assumptions about the structure of the general_log and slow_log log tables: It supported only the table structure defined in the mysql database creation scripts. The server also allowed limited ALTER TABLE operations on the log tables, but adding an AUTO_INCREMENT column did not properly initialize the column, and subsequent inserts into the table could fail to generate correct sequence numbers. Now an ALTER TABLE statement that adds an AUTO_INCREMENT column populates the column correctly. In addition, when the server writes a log table row, it will set columns not present in the original table structure to their default values.