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 /sql/log.cc | |
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 'sql/log.cc')
-rw-r--r-- | sql/log.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/sql/log.cc b/sql/log.cc index 6ef1c1ea912..02de7084222 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -305,6 +305,9 @@ bool Log_to_csv_event_handler::open_log_table(uint log_table_type) table->table->use_all_columns(); table->table->locked_by_logger= TRUE; table->table->no_replicate= TRUE; + + /* Honor next number columns if present */ + table->table->next_number_field= table->table->found_next_number_field; } /* restore thread settings */ if (curr) @@ -438,6 +441,7 @@ bool Log_to_csv_event_handler:: CHARSET_INFO *client_cs) { TABLE *table= general_log.table; + int field_index; /* "INSERT INTO general_log" can generate warning sometimes. @@ -488,6 +492,12 @@ bool Log_to_csv_event_handler:: table->field[4]->set_notnull(); table->field[5]->set_notnull(); + /* Set any extra columns to their default values */ + for (field_index= 6 ; field_index < table->s->fields ; field_index++) + { + table->field[field_index]->set_default(); + } + /* log table entries are not replicated at the moment */ tmp_disable_binlog(current_thd); @@ -1329,6 +1339,7 @@ void Log_to_csv_event_handler:: /* close the table */ log_thd->store_globals(); table->table->file->ha_rnd_end(); + table->table->file->ha_release_auto_increment(); /* discard logger mark before unlock*/ table->table->locked_by_logger= FALSE; close_thread_tables(log_thd, lock_in_use); |