Commit 2e22de68 authored by unknown's avatar unknown

Fix for BUG#35441 "Cannot change PAGE_CHECKSUM table option".

A big test was written and is committed, which found 3 bugs in total:
- ALTER TABLE PAGE_CHECKSUM=0 sometimes had no effect
- ALTER TABLE ENGINE=MARIA sometimes changed page checksumming in
the table
- SHOW CREATE TABLE and 'maria_chk -dv' disagreed on the presence
of page checksumming.
They are all fixed here. Side-effect is that SHOW CREATE TABLE now
always prints a PAGE_CHECKSUM clause for Maria tables.


mysql-test/mysql-test-run.pl:
  allow calling maria_chk and maria_pack in tests
mysql-test/r/maria.result:
  PAGE_CHECKSUM=0 is now always printed
mysql-test/t/create.test:
  PAGE_CHECKSUM= is now always present in SHOW CREATE TABLE of Maria tables
mysql-test/t/disabled.def:
  better bug number
sql/sql_table.cc:
  If ALTER TABLE PAGE_CHECKSUM=#, it affects the engine's data (structure
  of data pages) so a full table rebuild is needed. We already did
  so for ROW_FORMAT=#, following same logic. This fixes disagreements
  between SHOW CREATE TABLE and 'maria_chk -dv' regarding the
  presence of page checksums after certain ALTER TABLE (as seen
  with the attached testcase).
storage/maria/ha_maria.cc:
  In ALTER TABLE PAGE_CHECKSUM=0, ha_maria::update_create_info() started
  with create_info->page_checksum=HA_CHOICE_NO and wrongly set it
  to the table's original setting, which is HA_CHOICE_YES if the table
  had page checksums, in which case the ALTER left page checksum
  in the table.
  The fix for this bug is: only if create_info->page_checksum is
  undefined (no clause in the ALTER TABLE, or we are in SHOW CREATE TABLE)
  we may set HA_CHOICE_YES.
  The second bug in this file was that the code left HA_CHOICE_UNDEF if
  the table didn't have page checksums originally, leading ALTER TABLE
  ENGINE=MARIA to change the table's page checksum to the value of
  maria_page_checksum.
  This is fixed by setting create_info->page_checksum to HA_CHOICE_NO
  if UNDEF and table does not have page checksum.
  The side-effect of this last fix, because ha_maria::update_create_info()
  is also called by SHOW CREATE TABLE, is that:
  SET GLOBAL maria_page_checksum=0;
  CREATE TABLE t(a INT) ENGINE=MARIA;
  SHOW CREATE TABLE t;
  which used to not show a PAGE_CHECKSUM= clause, now shows PAGE_CHECKSUM=0.
  I consider this side-effect good:
  - clearer for users: it eliminates the differences between the
  above and this:
  SET GLOBAL maria_page_checksum=0;
  CREATE TABLE t(a INT) ENGINE=MARIA PAGE_CHECKSUM=0;
  SHOW CREATE TABLE t;
  which already showed PAGE_CHECKSUM=0; difference which is not easy
  to explain.
  - if using mysqldump to copy from one server to another, it eliminates
  the dependency on the value of maria_page_checksum being the same on
  original server and new server.
mysql-test/r/maria-page-checksum.result:
  Result. If you undo the code fixes and run the test, the new result
  file will show bugs at:
  error lineno 56 : expected PAGE_CHECKSUM=1, got Page checksums are not used
  error lineno 73 : expected PAGE_CHECKSUM=0, got ) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
  error lineno 110 : expected PAGE_CHECKSUM=1, got Page checksums are not used
  error lineno 164 : expected PAGE_CHECKSUM=1, got Page checksums are not used
  error lineno 181 : expected PAGE_CHECKSUM=0, got ) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
  error lineno 218 : expected PAGE_CHECKSUM=1, got Page checksums are not used
  error lineno 253 : expected PAGE_CHECKSUM=0, got ) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
  error lineno 307 : expected PAGE_CHECKSUM=0, got ) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
  error lineno 361 : expected PAGE_CHECKSUM=0, got ) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
  error lineno 415 : expected PAGE_CHECKSUM=0, got ) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
  error lineno 488 : expected PAGE_CHECKSUM=1, got Page checksums are not used
  error lineno 505 : expected PAGE_CHECKSUM=0, got ) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
  error lineno 542 : expected PAGE_CHECKSUM=1, got Page checksums are not used
  error lineno 577 : expected PAGE_CHECKSUM=0, got ) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
  error lineno 631 : expected PAGE_CHECKSUM=0, got ) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
  (lineno is line number in the result file)
mysql-test/t/maria-page-checksum.test:
  Test for the 3 bugs
parent 86fc80d5
......@@ -2178,6 +2178,22 @@ sub environment_setup () {
"$glob_basedir/storage/myisam/myisampack",
"$glob_basedir/myisam/myisampack"));
# ----------------------------------------------------
# Setup env so childs can execute maria_pack and maria_chk
# ----------------------------------------------------
$ENV{'MARIA_CHK'}= mtr_native_path(mtr_exe_exists(
vs_config_dirs('storage/maria', 'maria_chk'),
vs_config_dirs('maria', 'maria_chk'),
"$path_client_bindir/maria_chk",
"$glob_basedir/storage/maria/maria_chk",
"$glob_basedir/maria/maria_chk"));
$ENV{'MARIA_PACK'}= mtr_native_path(mtr_exe_exists(
vs_config_dirs('storage/maria', 'maria_pack'),
vs_config_dirs('maria', 'maria_pack'),
"$path_client_bindir/maria_pack",
"$glob_basedir/storage/maria/maria_pack",
"$glob_basedir/maria/maria_pack"));
# ----------------------------------------------------
# We are nice and report a bit about our settings
# ----------------------------------------------------
......
This diff is collapsed.
This diff is collapsed.
......@@ -1332,11 +1332,11 @@ drop function f1;
# Bug#25629 CREATE TABLE LIKE does not work with INFORMATION_SCHEMA
#
create table t1 like information_schema.processlist;
--replace_result ENGINE=MyISAM "" ENGINE=MARIA "" " PAGE_CHECKSUM=1" ""
--replace_result ENGINE=MyISAM "" ENGINE=MARIA "" " PAGE_CHECKSUM=1" "" " PAGE_CHECKSUM=0" ""
show create table t1;
drop table t1;
create temporary table t1 like information_schema.processlist;
--replace_result ENGINE=MyISAM "" ENGINE=MARIA "" " PAGE_CHECKSUM=1" ""
--replace_result ENGINE=MyISAM "" ENGINE=MARIA "" " PAGE_CHECKSUM=1" "" " PAGE_CHECKSUM=0" ""
show create table t1;
drop table t1;
create table t1 like information_schema.character_sets;
......
......@@ -24,4 +24,4 @@ wait_timeout : Bug#32801 wait_timeout.test fails randomly
ctype_create : Bug#32965 main.ctype_create fails
status : Bug#32966 main.status fails
ps_ddl : Bug#12093 2007-12-14 pending WL#4165 / WL#4166
maria-preload : Bug#35030 unrepeatable output of SHOW STATUS
maria-preload : Bug#34911 unrepeatable output of SHOW STATUS
This diff is collapsed.
......@@ -5161,6 +5161,7 @@ compare_tables(TABLE *table,
create_info->used_fields & HA_CREATE_USED_CHARSET ||
create_info->used_fields & HA_CREATE_USED_DEFAULT_CHARSET ||
create_info->used_fields & HA_CREATE_USED_ROW_FORMAT ||
create_info->used_fields & HA_CREATE_USED_PAGE_CHECKSUM ||
(alter_info->flags & (ALTER_RECREATE | ALTER_FOREIGN_KEY)) ||
order_num ||
!table->s->mysql_version ||
......
......@@ -2343,8 +2343,10 @@ void ha_maria::update_create_info(HA_CREATE_INFO *create_info)
Show always page checksums, as this can be forced with
maria_page_checksums variable
*/
if (file->s->options & HA_OPTION_PAGE_CHECKSUM)
create_info->page_checksum= HA_CHOICE_YES;
if (create_info->page_checksum == HA_CHOICE_UNDEF)
create_info->page_checksum=
(file->s->options & HA_OPTION_PAGE_CHECKSUM) ? HA_CHOICE_YES :
HA_CHOICE_NO;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment