• unknown's avatar
    Fix for BUG#35441 "Cannot change PAGE_CHECKSUM table option". · 2e22de68
    unknown authored
    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
    2e22de68
maria-page-checksum.result 20.9 KB