From b0a1ae09ae12bb3eefda03ff91263a3c860fd49b Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Fri, 26 Feb 2010 09:22:48 -0300 Subject: [PATCH] Bug#49823: mysql_upgrade fatal error due to general_log / slow_low CSV NULL The problem was that the CSV storage engine does not support NULL fields, yet in some early 5.1 version the log tables (general_log and slow_log) were created with null fields. On top of this, when altering a CSV table column, all fields of the table must be NOT NULL otherwise the alteration fails. The solution is to ensure that during upgrade all columns of the log tables are NOT NULL. mysql-test/r/log_tables_upgrade.result: Add test case result for Bug#49823. mysql-test/std_data/bug49823.CSV: Sample data for test. mysql-test/std_data/bug49823.frm: Add a CSV table which mimics the general_log table, except that it contains a nullable column. mysql-test/t/log_tables_upgrade.test: Add test case for Bug#49823. scripts/mysql_system_tables_fix.sql: Ensure that all columns of the log tables are NOT NULL. --- mysql-test/r/log_tables_upgrade.result | 47 +++++++++++++++++++++++++ mysql-test/std_data/bug49823.CSM | Bin 0 -> 35 bytes mysql-test/std_data/bug49823.CSV | 1 + mysql-test/std_data/bug49823.frm | Bin 0 -> 8776 bytes mysql-test/t/log_tables_upgrade.test | 32 +++++++++++++++++ scripts/mysql_system_tables_fix.sql | 21 +++++++++-- 6 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 mysql-test/r/log_tables_upgrade.result create mode 100644 mysql-test/std_data/bug49823.CSM create mode 100644 mysql-test/std_data/bug49823.CSV create mode 100644 mysql-test/std_data/bug49823.frm create mode 100644 mysql-test/t/log_tables_upgrade.test diff --git a/mysql-test/r/log_tables_upgrade.result b/mysql-test/r/log_tables_upgrade.result new file mode 100644 index 00000000000..5d9be85a48a --- /dev/null +++ b/mysql-test/r/log_tables_upgrade.result @@ -0,0 +1,47 @@ +# +# Bug#49823: mysql_upgrade fatal error due to general_log / slow_low CSV NULL +# +USE test; +SET @saved_general_log = @@GLOBAL.general_log; +SET GLOBAL general_log = OFF; +USE mysql; +FLUSH TABLES; +REPAIR TABLE test.bug49823; +Table Op Msg_type Msg_text +test.bug49823 repair status OK +RENAME TABLE general_log TO renamed_general_log; +RENAME TABLE test.bug49823 TO general_log; +mtr.global_suppressions OK +mtr.test_suppressions OK +mysql.columns_priv OK +mysql.db OK +mysql.event OK +mysql.func OK +mysql.general_log +Error : You can't use locks with log tables. +status : OK +mysql.help_category OK +mysql.help_keyword OK +mysql.help_relation OK +mysql.help_topic OK +mysql.host OK +mysql.ndb_binlog_index OK +mysql.plugin OK +mysql.proc OK +mysql.procs_priv OK +mysql.renamed_general_log OK +mysql.servers OK +mysql.slow_log +Error : You can't use locks with log tables. +status : OK +mysql.tables_priv OK +mysql.time_zone OK +mysql.time_zone_leap_second OK +mysql.time_zone_name OK +mysql.time_zone_transition OK +mysql.time_zone_transition_type OK +mysql.user OK +DROP TABLE general_log; +RENAME TABLE renamed_general_log TO general_log; +SET GLOBAL general_log = @saved_general_log; +USE test; diff --git a/mysql-test/std_data/bug49823.CSM b/mysql-test/std_data/bug49823.CSM new file mode 100644 index 0000000000000000000000000000000000000000..ee345049d990841e6f2d1012dd718247cf02bd33 GIT binary patch literal 35 Ncmeyz$Up!v0stcb0RaF2 literal 0 HcmV?d00001 diff --git a/mysql-test/std_data/bug49823.CSV b/mysql-test/std_data/bug49823.CSV new file mode 100644 index 00000000000..ffc319e2446 --- /dev/null +++ b/mysql-test/std_data/bug49823.CSV @@ -0,0 +1 @@ +"2010-02-26 13:32:26","root[root] @ localhost []",2,1,"Query","SELECT 1" diff --git a/mysql-test/std_data/bug49823.frm b/mysql-test/std_data/bug49823.frm new file mode 100644 index 0000000000000000000000000000000000000000..527807da1c9506cd15e8f6e0f8e637953a3584b8 GIT binary patch literal 8776 zcmeI&KTE?v7zXesY0Y1PEv<^U#L=mK0!1C{CK;sibMaO~DT)_$}OoehD2s z-=ax7IAkp4xg~e+UEV(Vt-WuJBj$>ie=2+BgQ2ZZH< zPYO_g0u-PC1t>rP3Q&Lo6rcbFHderduClFWRcQ++4P4#cZQ*zElPEv|3Q&Lo6rcbF zC_n)UP=Ese3-nF-)4%rcuT`e%HgW!IWrg4@;#p8pL zYZq>u4`!+KLDTPaU;<}20PJ(Qkl{Iw^g{oo3w+7V49oL0 as have_mysql_upgrade; +--enable_query_log + +--echo # +--echo # Bug#49823: mysql_upgrade fatal error due to general_log / slow_low CSV NULL +--echo # + +USE test; + +let $MYSQLD_DATADIR= `SELECT @@datadir`; +copy_file std_data/bug49823.frm $MYSQLD_DATADIR/test/bug49823.frm; +copy_file std_data/bug49823.CSM $MYSQLD_DATADIR/test/bug49823.CSM; +copy_file std_data/bug49823.CSV $MYSQLD_DATADIR/test/bug49823.CSV; + +SET @saved_general_log = @@GLOBAL.general_log; +SET GLOBAL general_log = OFF; +USE mysql; +FLUSH TABLES; +REPAIR TABLE test.bug49823; +RENAME TABLE general_log TO renamed_general_log; +RENAME TABLE test.bug49823 TO general_log; +--exec $MYSQL_UPGRADE --skip-verbose --force 2>&1 +DROP TABLE general_log; +RENAME TABLE renamed_general_log TO general_log; +SET GLOBAL general_log = @saved_general_log; +USE test; diff --git a/scripts/mysql_system_tables_fix.sql b/scripts/mysql_system_tables_fix.sql index 4260aee9142..deeb4d4de82 100644 --- a/scripts/mysql_system_tables_fix.sql +++ b/scripts/mysql_system_tables_fix.sql @@ -221,12 +221,29 @@ ALTER TABLE func SET @old_log_state = @@global.general_log; SET GLOBAL general_log = 'OFF'; -ALTER TABLE general_log MODIFY COLUMN server_id INTEGER UNSIGNED NOT NULL; +ALTER TABLE general_log + MODIFY event_time TIMESTAMP NOT NULL, + MODIFY user_host MEDIUMTEXT NOT NULL, + MODIFY thread_id INTEGER NOT NULL, + MODIFY server_id INTEGER UNSIGNED NOT NULL, + MODIFY command_type VARCHAR(64) NOT NULL, + MODIFY argument MEDIUMTEXT NOT NULL; SET GLOBAL general_log = @old_log_state; SET @old_log_state = @@global.slow_query_log; SET GLOBAL slow_query_log = 'OFF'; -ALTER TABLE slow_log MODIFY COLUMN server_id INTEGER UNSIGNED NOT NULL; +ALTER TABLE slow_log + MODIFY start_time TIMESTAMP NOT NULL, + MODIFY user_host MEDIUMTEXT NOT NULL, + MODIFY query_time TIME NOT NULL, + MODIFY lock_time TIME NOT NULL, + MODIFY rows_sent INTEGER NOT NULL, + MODIFY rows_examined INTEGER NOT NULL, + MODIFY db VARCHAR(512) NOT NULL, + MODIFY last_insert_id INTEGER NOT NULL, + MODIFY insert_id INTEGER NOT NULL, + MODIFY server_id INTEGER UNSIGNED NOT NULL, + MODIFY sql_text MEDIUMTEXT NOT NULL; SET GLOBAL slow_query_log = @old_log_state; #