You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

381 lines
12 KiB

branches/innodb+: Merge revisions 2835:2862 from branches/zip: ------------------------------------------------------------------------ r2838 | vasil | 2008-10-21 12:49:27 +0300 (Tue, 21 Oct 2008) | 61 lines branches/zip: Merge 2744:2837 from branches/5.1 (skipping r2782 and r2826): ------------------------------------------------------------------------ r2832 | vasil | 2008-10-21 10:08:30 +0300 (Tue, 21 Oct 2008) | 10 lines Changed paths: M /branches/5.1/handler/ha_innodb.cc branches/5.1: In ha_innobase::info(): Replace sql_print_warning() which prints to mysqld error log with push_warning_printf() which sends the error message to the client. Suggested by: Marko, Sunny, Michael Objected by: Inaam ------------------------------------------------------------------------ r2837 | vasil | 2008-10-21 12:07:44 +0300 (Tue, 21 Oct 2008) | 32 lines Changed paths: M /branches/5.1/mysql-test/innodb-semi-consistent.result M /branches/5.1/mysql-test/innodb-semi-consistent.test M /branches/5.1/mysql-test/innodb.result M /branches/5.1/mysql-test/innodb.test branches/5.1: Merge a change from MySQL (this fixes the failing innodb and innodb-semi-consistent tests): revno: 2757 committer: Georgi Kodinov <kgeorge@mysql.com> branch nick: B39812-5.1-5.1.29-rc timestamp: Fri 2008-10-03 15:24:19 +0300 message: Bug #39812: Make statement replication default for 5.1 (to match 5.0) Make STMT replication default for 5.1. Add a default of MIXED into the config files Fix the tests that needed MIXED replication mode. modified: mysql-test/include/mix1.inc mysql-test/r/innodb-semi-consistent.result mysql-test/r/innodb.result mysql-test/r/innodb_mysql.result mysql-test/r/tx_isolation_func.result mysql-test/t/innodb-semi-consistent.test mysql-test/t/innodb.test mysql-test/t/tx_isolation_func.test sql/mysqld.cc support-files/my-huge.cnf.sh support-files/my-innodb-heavy-4G.cnf.sh support-files/my-large.cnf.sh support-files/my-medium.cnf.sh support-files/my-small.cnf.sh ------------------------------------------------------------------------ ------------------------------------------------------------------------ r2847 | marko | 2008-10-22 10:07:37 +0300 (Wed, 22 Oct 2008) | 6 lines branches/zip: page_zip_rec_needs_ext(): Fix a bug that was introduced in the fix of Mantis issue #73. With key_block_size=16, we will also have to check the available space on the uncompressed page. Otherwise, the clustered index record can be almost 16 kilobytes in size, and the undo log record will not fit. ------------------------------------------------------------------------ r2850 | marko | 2008-10-22 13:52:12 +0300 (Wed, 22 Oct 2008) | 2 lines branches/zip: ibuf_insert_to_index_page(): Discard the local variable block. page_cur is always positioned on block, the function parameter. ------------------------------------------------------------------------ r2853 | sunny | 2008-10-23 01:52:09 +0300 (Thu, 23 Oct 2008) | 2 lines branches/zip: Add missing UNIV_INTERN. ------------------------------------------------------------------------ r2855 | sunny | 2008-10-23 09:29:46 +0300 (Thu, 23 Oct 2008) | 36 lines branches/zip: Merge revisions 2837:2852 from branches/5.1: ------------------------------------------------------------------------ r2849 | sunny | 2008-10-22 12:01:18 +0300 (Wed, 22 Oct 2008) | 8 lines Changed paths: M /branches/5.1/handler/ha_innodb.cc M /branches/5.1/include/row0mysql.h M /branches/5.1/row/row0mysql.c branches/5.1: Return the actual error code encountered when allocating a new autoinc value. The change in behavior (bug) was introduced in 5.1.22 when we introduced the new AUTOINC locking model. rb://31 Bug#40224 New AUTOINC changes mask reporting of deadlock/timeout errors ------------------------------------------------------------------------ r2852 | sunny | 2008-10-23 01:42:24 +0300 (Thu, 23 Oct 2008) | 9 lines Changed paths: M /branches/5.1/handler/ha_innodb.cc M /branches/5.1/handler/ha_innodb.h branches/5.1: Backport r2724 from branches/zip Check column value against the col max value before updating the table's global autoinc counter value. This is part of simplifying the AUTOINC sub-system. We extract the type info from MySQL data structures at runtime. This fixes Bug#37788 InnoDB Plugin: AUTO_INCREMENT wrong for compressed tables ------------------------------------------------------------------------ ------------------------------------------------------------------------ r2856 | sunny | 2008-10-23 10:07:05 +0300 (Thu, 23 Oct 2008) | 1 line Reverting test file changes from r2855 ------------------------------------------------------------------------ r2857 | sunny | 2008-10-23 10:24:33 +0300 (Thu, 23 Oct 2008) | 30 lines branches/zip: Merge revisions 2852:2854 from branches/5.1: ------------------------------------------------------------------------ r2854 | sunny | 2008-10-23 08:30:32 +0300 (Thu, 23 Oct 2008) | 13 lines Changed paths: M /branches/5.1/dict/dict0dict.c M /branches/5.1/dict/dict0mem.c M /branches/5.1/handler/ha_innodb.cc M /branches/5.1/handler/ha_innodb.h M /branches/5.1/include/dict0dict.h M /branches/5.1/include/dict0mem.h M /branches/5.1/row/row0mysql.c branches/5.1: Backport changes from branches/zip r2725 Simplify the autoinc initialization code. This removes the non-determinism related to reading the table's autoinc value for the first time. This change has also reduced the sizeof dict_table_t by sizeof(ibool) bytes because we don't need the dict_table_t::autoinc_inited field anymore. Bug#39830 Table autoinc value not updated on first insert. Bug#35498 Cannot get table test/table1 auto-inccounter value in ::info Bug#36411 Failed to read auto-increment value from storage engine" in 5.1.24 auto-inc rb://16 ------------------------------------------------------------------------ ------------------------------------------------------------------------ r2858 | vasil | 2008-10-23 11:33:43 +0300 (Thu, 23 Oct 2008) | 4 lines branches/zip: Update the ChangeLog ------------------------------------------------------------------------ r2861 | marko | 2008-10-23 12:27:15 +0300 (Thu, 23 Oct 2008) | 24 lines branches/zip: Clean up the file format stamping. trx_sys_file_format_max_upgrade(): Rename from trx_sys_file_format_max_update(). Improve the documentation. Add a const qualifier to the parameter "name". Replace the parameter "flags" with "format_id", because this function should deal with file format identifiers, not with table flags. trx_sys_file_format_max_write(), trx_sys_file_format_max_set(): Add a const qualifier to the parameter "name". ha_innodb.cc: Correct the spelling in some comments: "side effect". Remove redundant prototypes for some static callback functions. innodb_file_format_name_update(), innodb_file_format_check_update(): Correct the function signature. Use appropriate pointer type conversions. MYSQL_SYSVAR_STR(file_format), MYSQL_SYSVAR_STR(file_format_check): Remove the type conversions from the callback function pointers. When the function signatures match, no type conversion is needed. The type conversions would only prevent compilation warnings for any mismatch. Approved by Sunny in rb://25. ------------------------------------------------------------------------ r2862 | marko | 2008-10-23 12:37:42 +0300 (Thu, 23 Oct 2008) | 8 lines branches/zip: Non-functional changes: ibuf_get_volume_buffered(): Declare with static linkage. This function is private to ibuf0ibuf.c. btr_cur_pessimistic_delete(): Use the cached result of btr_cur_get_index(cursor). ------------------------------------------------------------------------
17 years ago
branches/innodb+: Merge revisions 2835:2862 from branches/zip: ------------------------------------------------------------------------ r2838 | vasil | 2008-10-21 12:49:27 +0300 (Tue, 21 Oct 2008) | 61 lines branches/zip: Merge 2744:2837 from branches/5.1 (skipping r2782 and r2826): ------------------------------------------------------------------------ r2832 | vasil | 2008-10-21 10:08:30 +0300 (Tue, 21 Oct 2008) | 10 lines Changed paths: M /branches/5.1/handler/ha_innodb.cc branches/5.1: In ha_innobase::info(): Replace sql_print_warning() which prints to mysqld error log with push_warning_printf() which sends the error message to the client. Suggested by: Marko, Sunny, Michael Objected by: Inaam ------------------------------------------------------------------------ r2837 | vasil | 2008-10-21 12:07:44 +0300 (Tue, 21 Oct 2008) | 32 lines Changed paths: M /branches/5.1/mysql-test/innodb-semi-consistent.result M /branches/5.1/mysql-test/innodb-semi-consistent.test M /branches/5.1/mysql-test/innodb.result M /branches/5.1/mysql-test/innodb.test branches/5.1: Merge a change from MySQL (this fixes the failing innodb and innodb-semi-consistent tests): revno: 2757 committer: Georgi Kodinov <kgeorge@mysql.com> branch nick: B39812-5.1-5.1.29-rc timestamp: Fri 2008-10-03 15:24:19 +0300 message: Bug #39812: Make statement replication default for 5.1 (to match 5.0) Make STMT replication default for 5.1. Add a default of MIXED into the config files Fix the tests that needed MIXED replication mode. modified: mysql-test/include/mix1.inc mysql-test/r/innodb-semi-consistent.result mysql-test/r/innodb.result mysql-test/r/innodb_mysql.result mysql-test/r/tx_isolation_func.result mysql-test/t/innodb-semi-consistent.test mysql-test/t/innodb.test mysql-test/t/tx_isolation_func.test sql/mysqld.cc support-files/my-huge.cnf.sh support-files/my-innodb-heavy-4G.cnf.sh support-files/my-large.cnf.sh support-files/my-medium.cnf.sh support-files/my-small.cnf.sh ------------------------------------------------------------------------ ------------------------------------------------------------------------ r2847 | marko | 2008-10-22 10:07:37 +0300 (Wed, 22 Oct 2008) | 6 lines branches/zip: page_zip_rec_needs_ext(): Fix a bug that was introduced in the fix of Mantis issue #73. With key_block_size=16, we will also have to check the available space on the uncompressed page. Otherwise, the clustered index record can be almost 16 kilobytes in size, and the undo log record will not fit. ------------------------------------------------------------------------ r2850 | marko | 2008-10-22 13:52:12 +0300 (Wed, 22 Oct 2008) | 2 lines branches/zip: ibuf_insert_to_index_page(): Discard the local variable block. page_cur is always positioned on block, the function parameter. ------------------------------------------------------------------------ r2853 | sunny | 2008-10-23 01:52:09 +0300 (Thu, 23 Oct 2008) | 2 lines branches/zip: Add missing UNIV_INTERN. ------------------------------------------------------------------------ r2855 | sunny | 2008-10-23 09:29:46 +0300 (Thu, 23 Oct 2008) | 36 lines branches/zip: Merge revisions 2837:2852 from branches/5.1: ------------------------------------------------------------------------ r2849 | sunny | 2008-10-22 12:01:18 +0300 (Wed, 22 Oct 2008) | 8 lines Changed paths: M /branches/5.1/handler/ha_innodb.cc M /branches/5.1/include/row0mysql.h M /branches/5.1/row/row0mysql.c branches/5.1: Return the actual error code encountered when allocating a new autoinc value. The change in behavior (bug) was introduced in 5.1.22 when we introduced the new AUTOINC locking model. rb://31 Bug#40224 New AUTOINC changes mask reporting of deadlock/timeout errors ------------------------------------------------------------------------ r2852 | sunny | 2008-10-23 01:42:24 +0300 (Thu, 23 Oct 2008) | 9 lines Changed paths: M /branches/5.1/handler/ha_innodb.cc M /branches/5.1/handler/ha_innodb.h branches/5.1: Backport r2724 from branches/zip Check column value against the col max value before updating the table's global autoinc counter value. This is part of simplifying the AUTOINC sub-system. We extract the type info from MySQL data structures at runtime. This fixes Bug#37788 InnoDB Plugin: AUTO_INCREMENT wrong for compressed tables ------------------------------------------------------------------------ ------------------------------------------------------------------------ r2856 | sunny | 2008-10-23 10:07:05 +0300 (Thu, 23 Oct 2008) | 1 line Reverting test file changes from r2855 ------------------------------------------------------------------------ r2857 | sunny | 2008-10-23 10:24:33 +0300 (Thu, 23 Oct 2008) | 30 lines branches/zip: Merge revisions 2852:2854 from branches/5.1: ------------------------------------------------------------------------ r2854 | sunny | 2008-10-23 08:30:32 +0300 (Thu, 23 Oct 2008) | 13 lines Changed paths: M /branches/5.1/dict/dict0dict.c M /branches/5.1/dict/dict0mem.c M /branches/5.1/handler/ha_innodb.cc M /branches/5.1/handler/ha_innodb.h M /branches/5.1/include/dict0dict.h M /branches/5.1/include/dict0mem.h M /branches/5.1/row/row0mysql.c branches/5.1: Backport changes from branches/zip r2725 Simplify the autoinc initialization code. This removes the non-determinism related to reading the table's autoinc value for the first time. This change has also reduced the sizeof dict_table_t by sizeof(ibool) bytes because we don't need the dict_table_t::autoinc_inited field anymore. Bug#39830 Table autoinc value not updated on first insert. Bug#35498 Cannot get table test/table1 auto-inccounter value in ::info Bug#36411 Failed to read auto-increment value from storage engine" in 5.1.24 auto-inc rb://16 ------------------------------------------------------------------------ ------------------------------------------------------------------------ r2858 | vasil | 2008-10-23 11:33:43 +0300 (Thu, 23 Oct 2008) | 4 lines branches/zip: Update the ChangeLog ------------------------------------------------------------------------ r2861 | marko | 2008-10-23 12:27:15 +0300 (Thu, 23 Oct 2008) | 24 lines branches/zip: Clean up the file format stamping. trx_sys_file_format_max_upgrade(): Rename from trx_sys_file_format_max_update(). Improve the documentation. Add a const qualifier to the parameter "name". Replace the parameter "flags" with "format_id", because this function should deal with file format identifiers, not with table flags. trx_sys_file_format_max_write(), trx_sys_file_format_max_set(): Add a const qualifier to the parameter "name". ha_innodb.cc: Correct the spelling in some comments: "side effect". Remove redundant prototypes for some static callback functions. innodb_file_format_name_update(), innodb_file_format_check_update(): Correct the function signature. Use appropriate pointer type conversions. MYSQL_SYSVAR_STR(file_format), MYSQL_SYSVAR_STR(file_format_check): Remove the type conversions from the callback function pointers. When the function signatures match, no type conversion is needed. The type conversions would only prevent compilation warnings for any mismatch. Approved by Sunny in rb://25. ------------------------------------------------------------------------ r2862 | marko | 2008-10-23 12:37:42 +0300 (Thu, 23 Oct 2008) | 8 lines branches/zip: Non-functional changes: ibuf_get_volume_buffered(): Declare with static linkage. This function is private to ibuf0ibuf.c. btr_cur_pessimistic_delete(): Use the cached result of btr_cur_get_index(cursor). ------------------------------------------------------------------------
17 years ago
branches/zip: Try to synchronize the updates of uncompressed and compressed pages. btr_root_raise_and_insert(): Distinguish root_page_zip and new_page_zip. btr_cur_set_ownership_of_extern_field(): Do not log the write on the uncompressed page if it will be logged for page_zip. lock_rec_insert_check_and_lock(), lock_sec_rec_modify_check_and_lock(): Update the max_trx_id field also on the compressed page. mlog_write_ulint(): Add UNIV_UNLIKELY hints. Remove trailing white space. mlog_log_string(): Remove trailing white space. rec_set_field_extern_bits(): Remove parameter mtr, as the write will either occur in the heap, or it will be logged at a higher level. recv_parse_or_apply_log_rec_body(), page_zip_write_header(): Add log record type MLOG_ZIP_WRITE_HEADER. page_header_set_field(): Pass mtr=NULL to page_zip_write_header(). page_header_reset_last_insert(): Pass mtr to page_zip_write_header(). btr_page_set_index_id(), btr_page_set_level(), btr_page_set_next(), btr_page_set_prev(): Pass mtr to page_zip_write_header(). row_upd_rec_sys_fields(): Pass mtr=NULL to page_zip_write_trx_id() and page_zip_write_roll_ptr(), since the write will be logged at a higher level. page_zip_write_header(): Add parameter mtr. page_zip_write_header_log(): New function. Remove rec_set_nth_field_extern_bit(). Make rec_set_nth_field_extern_bit_old() static. Rename rec_set_nth_field_extern_bit_new() to rec_set_field_extern_bits_new() and make it static. row_ins_index_entry_low(): Remove bogus TODO comment.
20 years ago
branches/zip: Try to synchronize the updates of uncompressed and compressed pages. btr_root_raise_and_insert(): Distinguish root_page_zip and new_page_zip. btr_cur_set_ownership_of_extern_field(): Do not log the write on the uncompressed page if it will be logged for page_zip. lock_rec_insert_check_and_lock(), lock_sec_rec_modify_check_and_lock(): Update the max_trx_id field also on the compressed page. mlog_write_ulint(): Add UNIV_UNLIKELY hints. Remove trailing white space. mlog_log_string(): Remove trailing white space. rec_set_field_extern_bits(): Remove parameter mtr, as the write will either occur in the heap, or it will be logged at a higher level. recv_parse_or_apply_log_rec_body(), page_zip_write_header(): Add log record type MLOG_ZIP_WRITE_HEADER. page_header_set_field(): Pass mtr=NULL to page_zip_write_header(). page_header_reset_last_insert(): Pass mtr to page_zip_write_header(). btr_page_set_index_id(), btr_page_set_level(), btr_page_set_next(), btr_page_set_prev(): Pass mtr to page_zip_write_header(). row_upd_rec_sys_fields(): Pass mtr=NULL to page_zip_write_trx_id() and page_zip_write_roll_ptr(), since the write will be logged at a higher level. page_zip_write_header(): Add parameter mtr. page_zip_write_header_log(): New function. Remove rec_set_nth_field_extern_bit(). Make rec_set_nth_field_extern_bit_old() static. Rename rec_set_nth_field_extern_bit_new() to rec_set_field_extern_bits_new() and make it static. row_ins_index_entry_low(): Remove bogus TODO comment.
20 years ago
branches/zip: Try to synchronize the updates of uncompressed and compressed pages. btr_root_raise_and_insert(): Distinguish root_page_zip and new_page_zip. btr_cur_set_ownership_of_extern_field(): Do not log the write on the uncompressed page if it will be logged for page_zip. lock_rec_insert_check_and_lock(), lock_sec_rec_modify_check_and_lock(): Update the max_trx_id field also on the compressed page. mlog_write_ulint(): Add UNIV_UNLIKELY hints. Remove trailing white space. mlog_log_string(): Remove trailing white space. rec_set_field_extern_bits(): Remove parameter mtr, as the write will either occur in the heap, or it will be logged at a higher level. recv_parse_or_apply_log_rec_body(), page_zip_write_header(): Add log record type MLOG_ZIP_WRITE_HEADER. page_header_set_field(): Pass mtr=NULL to page_zip_write_header(). page_header_reset_last_insert(): Pass mtr to page_zip_write_header(). btr_page_set_index_id(), btr_page_set_level(), btr_page_set_next(), btr_page_set_prev(): Pass mtr to page_zip_write_header(). row_upd_rec_sys_fields(): Pass mtr=NULL to page_zip_write_trx_id() and page_zip_write_roll_ptr(), since the write will be logged at a higher level. page_zip_write_header(): Add parameter mtr. page_zip_write_header_log(): New function. Remove rec_set_nth_field_extern_bit(). Make rec_set_nth_field_extern_bit_old() static. Rename rec_set_nth_field_extern_bit_new() to rec_set_field_extern_bits_new() and make it static. row_ins_index_entry_low(): Remove bogus TODO comment.
20 years ago
branches/zip: Try to synchronize the updates of uncompressed and compressed pages. btr_root_raise_and_insert(): Distinguish root_page_zip and new_page_zip. btr_cur_set_ownership_of_extern_field(): Do not log the write on the uncompressed page if it will be logged for page_zip. lock_rec_insert_check_and_lock(), lock_sec_rec_modify_check_and_lock(): Update the max_trx_id field also on the compressed page. mlog_write_ulint(): Add UNIV_UNLIKELY hints. Remove trailing white space. mlog_log_string(): Remove trailing white space. rec_set_field_extern_bits(): Remove parameter mtr, as the write will either occur in the heap, or it will be logged at a higher level. recv_parse_or_apply_log_rec_body(), page_zip_write_header(): Add log record type MLOG_ZIP_WRITE_HEADER. page_header_set_field(): Pass mtr=NULL to page_zip_write_header(). page_header_reset_last_insert(): Pass mtr to page_zip_write_header(). btr_page_set_index_id(), btr_page_set_level(), btr_page_set_next(), btr_page_set_prev(): Pass mtr to page_zip_write_header(). row_upd_rec_sys_fields(): Pass mtr=NULL to page_zip_write_trx_id() and page_zip_write_roll_ptr(), since the write will be logged at a higher level. page_zip_write_header(): Add parameter mtr. page_zip_write_header_log(): New function. Remove rec_set_nth_field_extern_bit(). Make rec_set_nth_field_extern_bit_old() static. Rename rec_set_nth_field_extern_bit_new() to rec_set_field_extern_bits_new() and make it static. row_ins_index_entry_low(): Remove bogus TODO comment.
20 years ago
branches/zip: Try to synchronize the updates of uncompressed and compressed pages. btr_root_raise_and_insert(): Distinguish root_page_zip and new_page_zip. btr_cur_set_ownership_of_extern_field(): Do not log the write on the uncompressed page if it will be logged for page_zip. lock_rec_insert_check_and_lock(), lock_sec_rec_modify_check_and_lock(): Update the max_trx_id field also on the compressed page. mlog_write_ulint(): Add UNIV_UNLIKELY hints. Remove trailing white space. mlog_log_string(): Remove trailing white space. rec_set_field_extern_bits(): Remove parameter mtr, as the write will either occur in the heap, or it will be logged at a higher level. recv_parse_or_apply_log_rec_body(), page_zip_write_header(): Add log record type MLOG_ZIP_WRITE_HEADER. page_header_set_field(): Pass mtr=NULL to page_zip_write_header(). page_header_reset_last_insert(): Pass mtr to page_zip_write_header(). btr_page_set_index_id(), btr_page_set_level(), btr_page_set_next(), btr_page_set_prev(): Pass mtr to page_zip_write_header(). row_upd_rec_sys_fields(): Pass mtr=NULL to page_zip_write_trx_id() and page_zip_write_roll_ptr(), since the write will be logged at a higher level. page_zip_write_header(): Add parameter mtr. page_zip_write_header_log(): New function. Remove rec_set_nth_field_extern_bit(). Make rec_set_nth_field_extern_bit_old() static. Rename rec_set_nth_field_extern_bit_new() to rec_set_field_extern_bits_new() and make it static. row_ins_index_entry_low(): Remove bogus TODO comment.
20 years ago
branches/zip: Try to synchronize the updates of uncompressed and compressed pages. btr_root_raise_and_insert(): Distinguish root_page_zip and new_page_zip. btr_cur_set_ownership_of_extern_field(): Do not log the write on the uncompressed page if it will be logged for page_zip. lock_rec_insert_check_and_lock(), lock_sec_rec_modify_check_and_lock(): Update the max_trx_id field also on the compressed page. mlog_write_ulint(): Add UNIV_UNLIKELY hints. Remove trailing white space. mlog_log_string(): Remove trailing white space. rec_set_field_extern_bits(): Remove parameter mtr, as the write will either occur in the heap, or it will be logged at a higher level. recv_parse_or_apply_log_rec_body(), page_zip_write_header(): Add log record type MLOG_ZIP_WRITE_HEADER. page_header_set_field(): Pass mtr=NULL to page_zip_write_header(). page_header_reset_last_insert(): Pass mtr to page_zip_write_header(). btr_page_set_index_id(), btr_page_set_level(), btr_page_set_next(), btr_page_set_prev(): Pass mtr to page_zip_write_header(). row_upd_rec_sys_fields(): Pass mtr=NULL to page_zip_write_trx_id() and page_zip_write_roll_ptr(), since the write will be logged at a higher level. page_zip_write_header(): Add parameter mtr. page_zip_write_header_log(): New function. Remove rec_set_nth_field_extern_bit(). Make rec_set_nth_field_extern_bit_old() static. Rename rec_set_nth_field_extern_bit_new() to rec_set_field_extern_bits_new() and make it static. row_ins_index_entry_low(): Remove bogus TODO comment.
20 years ago
  1. /******************************************************
  2. Compressed page interface
  3. (c) 2005 Innobase Oy
  4. Created June 2005 by Marko Makela
  5. *******************************************************/
  6. #ifdef UNIV_MATERIALIZE
  7. # undef UNIV_INLINE
  8. # define UNIV_INLINE
  9. #endif
  10. #include "page0zip.h"
  11. #include "page0page.h"
  12. /* The format of compressed pages is as follows.
  13. The header and trailer of the uncompressed pages, excluding the page
  14. directory in the trailer, are copied as is to the header and trailer
  15. of the compressed page.
  16. At the end of the compressed page, there is a dense page directory
  17. pointing to every user record contained on the page, including deleted
  18. records on the free list. The dense directory is indexed in the
  19. collation order, i.e., in the order in which the record list is
  20. linked on the uncompressed page. The infimum and supremum records are
  21. excluded. The two most significant bits of the entries are allocated
  22. for the delete-mark and an n_owned flag indicating the last record in
  23. a chain of records pointed to from the sparse page directory on the
  24. uncompressed page.
  25. The data between PAGE_ZIP_START and the last page directory entry will
  26. be written in compressed format, starting at offset PAGE_DATA.
  27. Infimum and supremum records are not stored. We exclude the
  28. REC_N_NEW_EXTRA_BYTES in every record header. These can be recovered
  29. from the dense page directory stored at the end of the compressed
  30. page.
  31. The fields node_ptr (in non-leaf B-tree nodes; level>0), trx_id and
  32. roll_ptr (in leaf B-tree nodes; level=0), and BLOB pointers of
  33. externally stored columns are stored separately, in ascending order of
  34. heap_no and column index, starting backwards from the dense page
  35. directory.
  36. The compressed data stream may be followed by a modification log
  37. covering the compressed portion of the page, as follows.
  38. MODIFICATION LOG ENTRY FORMAT
  39. - write record:
  40. - (heap_no - 1) << 1 (1..2 bytes)
  41. - extra bytes backwards
  42. - data bytes
  43. - clear record:
  44. - (heap_no - 1) << 1 | 1 (1..2 bytes)
  45. The integer values are stored in a variable-length format:
  46. - 0xxxxxxx: 0..127
  47. - 1xxxxxxx xxxxxxxx: 0..32767
  48. The end of the modification log is marked by a 0 byte.
  49. In summary, the compressed page looks like this:
  50. (1) Uncompressed page header (PAGE_DATA bytes)
  51. (2) Compressed index information
  52. (3) Compressed page data
  53. (4) Page modification log (page_zip->m_start..page_zip->m_end)
  54. (5) Empty zero-filled space
  55. (6) BLOB pointers (on leaf pages)
  56. - BTR_EXTERN_FIELD_REF_SIZE for each externally stored column
  57. - in descending collation order
  58. (7) Uncompressed columns of user records, n_dense * uncompressed_size bytes,
  59. - indexed by heap_no
  60. - DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN for leaf pages of clustered indexes
  61. - REC_NODE_PTR_SIZE for non-leaf pages
  62. - 0 otherwise
  63. (8) dense page directory, stored backwards
  64. - n_dense = n_heap - 2
  65. - existing records in ascending collation order
  66. - deleted records (free list) in link order
  67. */
  68. /* Start offset of the area that will be compressed */
  69. #define PAGE_ZIP_START PAGE_NEW_SUPREMUM_END
  70. /* Size of an compressed page directory entry */
  71. #define PAGE_ZIP_DIR_SLOT_SIZE 2
  72. /* Mask of record offsets */
  73. #define PAGE_ZIP_DIR_SLOT_MASK 0x3fff
  74. /* 'owned' flag */
  75. #define PAGE_ZIP_DIR_SLOT_OWNED 0x4000
  76. /* 'deleted' flag */
  77. #define PAGE_ZIP_DIR_SLOT_DEL 0x8000
  78. /**************************************************************************
  79. Determine the size of a compressed page in bytes. */
  80. UNIV_INLINE
  81. ulint
  82. page_zip_get_size(
  83. /*==============*/
  84. /* out: size in bytes */
  85. const page_zip_des_t* page_zip) /* in: compressed page */
  86. {
  87. ulint size;
  88. if (UNIV_UNLIKELY(!page_zip->ssize)) {
  89. return(0);
  90. }
  91. size = (PAGE_ZIP_MIN_SIZE >> 1) << page_zip->ssize;
  92. ut_ad(size >= PAGE_ZIP_MIN_SIZE);
  93. ut_ad(size <= UNIV_PAGE_SIZE);
  94. return(size);
  95. }
  96. /**************************************************************************
  97. Set the size of a compressed page in bytes. */
  98. UNIV_INLINE
  99. void
  100. page_zip_set_size(
  101. /*==============*/
  102. page_zip_des_t* page_zip, /* in/out: compressed page */
  103. ulint size) /* in: size in bytes */
  104. {
  105. if (size) {
  106. int ssize;
  107. ut_ad(ut_is_2pow(size));
  108. for (ssize = 1; size > (ulint) (512 << ssize); ssize++);
  109. page_zip->ssize = ssize;
  110. } else {
  111. page_zip->ssize = 0;
  112. }
  113. ut_ad(page_zip_get_size(page_zip) == size);
  114. }
  115. /**************************************************************************
  116. Determine if a record is so big that it needs to be stored externally. */
  117. UNIV_INLINE
  118. ibool
  119. page_zip_rec_needs_ext(
  120. /*===================*/
  121. /* out: FALSE if the entire record
  122. can be stored locally on the page */
  123. ulint rec_size, /* in: length of the record in bytes */
  124. ulint comp, /* in: nonzero=compact format */
  125. ulint n_fields, /* in: number of fields in the record;
  126. ignored if zip_size == 0 */
  127. ulint zip_size) /* in: compressed page size in bytes, or 0 */
  128. {
  129. ut_ad(rec_size > comp ? REC_N_NEW_EXTRA_BYTES : REC_N_OLD_EXTRA_BYTES);
  130. ut_ad(ut_is_2pow(zip_size));
  131. ut_ad(comp || !zip_size);
  132. #if UNIV_PAGE_SIZE > REC_MAX_DATA_SIZE
  133. if (UNIV_UNLIKELY(rec_size >= REC_MAX_DATA_SIZE)) {
  134. return(TRUE);
  135. }
  136. #endif
  137. if (UNIV_UNLIKELY(zip_size)) {
  138. ut_ad(comp);
  139. /* On a compressed page, there is a two-byte entry in
  140. the dense page directory for every record. But there
  141. is no record header. There should be enough room for
  142. one record on an empty leaf page. Subtract 1 byte for
  143. the encoded heap number. Check also the available space
  144. on the uncompressed page. */
  145. return(rec_size - (REC_N_NEW_EXTRA_BYTES - 2)
  146. >= (page_zip_empty_size(n_fields, zip_size) - 1)
  147. || rec_size >= page_get_free_space_of_empty(TRUE) / 2);
  148. }
  149. return(rec_size >= page_get_free_space_of_empty(comp) / 2);
  150. }
  151. #ifdef UNIV_DEBUG
  152. /**************************************************************************
  153. Validate a compressed page descriptor. */
  154. UNIV_INLINE
  155. ibool
  156. page_zip_simple_validate(
  157. /*=====================*/
  158. /* out: TRUE if ok */
  159. const page_zip_des_t* page_zip)/* in: compressed page descriptor */
  160. {
  161. ut_ad(page_zip);
  162. ut_ad(page_zip->data);
  163. ut_ad(page_zip->ssize < PAGE_ZIP_NUM_SSIZE);
  164. ut_ad(page_zip_get_size(page_zip)
  165. > PAGE_DATA + PAGE_ZIP_DIR_SLOT_SIZE);
  166. ut_ad(page_zip->m_start <= page_zip->m_end);
  167. ut_ad(page_zip->m_end < page_zip_get_size(page_zip));
  168. ut_ad(page_zip->n_blobs
  169. < page_zip_get_size(page_zip) / BTR_EXTERN_FIELD_REF_SIZE);
  170. return(TRUE);
  171. }
  172. #endif /* UNIV_DEBUG */
  173. /**************************************************************************
  174. Determine if the length of the page trailer. */
  175. UNIV_INLINE
  176. ibool
  177. page_zip_get_trailer_len(
  178. /*=====================*/
  179. /* out: length of the page trailer,
  180. in bytes, not including the terminating
  181. zero byte of the modification log */
  182. const page_zip_des_t* page_zip,/* in: compressed page */
  183. ibool is_clust,/* in: TRUE if clustered index */
  184. ulint* entry_size)/* out: size of the uncompressed
  185. portion of a user record */
  186. {
  187. ulint uncompressed_size;
  188. ut_ad(page_zip_simple_validate(page_zip));
  189. UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip));
  190. if (UNIV_UNLIKELY(!page_is_leaf(page_zip->data))) {
  191. uncompressed_size = PAGE_ZIP_DIR_SLOT_SIZE
  192. + REC_NODE_PTR_SIZE;
  193. ut_ad(!page_zip->n_blobs);
  194. } else if (UNIV_UNLIKELY(is_clust)) {
  195. uncompressed_size = PAGE_ZIP_DIR_SLOT_SIZE
  196. + DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN;
  197. } else {
  198. uncompressed_size = PAGE_ZIP_DIR_SLOT_SIZE;
  199. ut_ad(!page_zip->n_blobs);
  200. }
  201. if (entry_size) {
  202. *entry_size = uncompressed_size;
  203. }
  204. return((page_dir_get_n_heap(page_zip->data) - 2)
  205. * uncompressed_size
  206. + page_zip->n_blobs * BTR_EXTERN_FIELD_REF_SIZE);
  207. }
  208. /**************************************************************************
  209. Determine how big record can be inserted without recompressing the page. */
  210. UNIV_INLINE
  211. lint
  212. page_zip_max_ins_size(
  213. /*==================*/
  214. /* out: a positive number
  215. indicating the maximum size of
  216. a record whose insertion is
  217. guaranteed to succeed, or
  218. zero or negative */
  219. const page_zip_des_t* page_zip,/* in: compressed page */
  220. ibool is_clust)/* in: TRUE if clustered index */
  221. {
  222. ulint uncompressed_size;
  223. ulint trailer_len;
  224. trailer_len = page_zip_get_trailer_len(page_zip, is_clust,
  225. &uncompressed_size);
  226. /* When a record is created, a pointer may be added to
  227. the dense directory.
  228. Likewise, space for the columns that will not be
  229. compressed will be allocated from the page trailer.
  230. Also the BLOB pointers will be allocated from there, but
  231. we may as well count them in the length of the record. */
  232. trailer_len += uncompressed_size;
  233. return((lint) page_zip_get_size(page_zip)
  234. - trailer_len - page_zip->m_end
  235. - (REC_N_NEW_EXTRA_BYTES - 2));
  236. }
  237. /**************************************************************************
  238. Determine if enough space is available in the modification log. */
  239. UNIV_INLINE
  240. ibool
  241. page_zip_available(
  242. /*===============*/
  243. /* out: TRUE if enough space
  244. is available */
  245. const page_zip_des_t* page_zip,/* in: compressed page */
  246. ibool is_clust,/* in: TRUE if clustered index */
  247. ulint length, /* in: combined size of the record */
  248. ulint create) /* in: nonzero=add the record to
  249. the heap */
  250. {
  251. ulint uncompressed_size;
  252. ulint trailer_len;
  253. ut_ad(length > REC_N_NEW_EXTRA_BYTES);
  254. trailer_len = page_zip_get_trailer_len(page_zip, is_clust,
  255. &uncompressed_size);
  256. /* Subtract the fixed extra bytes and add the maximum
  257. space needed for identifying the record (encoded heap_no). */
  258. length -= REC_N_NEW_EXTRA_BYTES - 2;
  259. if (UNIV_UNLIKELY(create)) {
  260. /* When a record is created, a pointer may be added to
  261. the dense directory.
  262. Likewise, space for the columns that will not be
  263. compressed will be allocated from the page trailer.
  264. Also the BLOB pointers will be allocated from there, but
  265. we may as well count them in the length of the record. */
  266. trailer_len += uncompressed_size;
  267. }
  268. return(UNIV_LIKELY(length
  269. + trailer_len
  270. + page_zip->m_end
  271. < page_zip_get_size(page_zip)));
  272. }
  273. /**************************************************************************
  274. Initialize a compressed page descriptor. */
  275. UNIV_INLINE
  276. void
  277. page_zip_des_init(
  278. /*==============*/
  279. page_zip_des_t* page_zip) /* in/out: compressed page
  280. descriptor */
  281. {
  282. memset(page_zip, 0, sizeof *page_zip);
  283. }
  284. /**************************************************************************
  285. Write a log record of writing to the uncompressed header portion of a page. */
  286. UNIV_INTERN
  287. void
  288. page_zip_write_header_log(
  289. /*======================*/
  290. const byte* data,/* in: data on the uncompressed page */
  291. ulint length, /* in: length of the data */
  292. mtr_t* mtr); /* in: mini-transaction */
  293. /**************************************************************************
  294. Write data to the uncompressed header portion of a page. The data must
  295. already have been written to the uncompressed page.
  296. However, the data portion of the uncompressed page may differ from
  297. the compressed page when a record is being inserted in
  298. page_cur_insert_rec_zip(). */
  299. UNIV_INLINE
  300. void
  301. page_zip_write_header(
  302. /*==================*/
  303. page_zip_des_t* page_zip,/* in/out: compressed page */
  304. const byte* str, /* in: address on the uncompressed page */
  305. ulint length, /* in: length of the data */
  306. mtr_t* mtr) /* in: mini-transaction, or NULL */
  307. {
  308. ulint pos;
  309. ut_ad(buf_frame_get_page_zip(str) == page_zip);
  310. ut_ad(page_zip_simple_validate(page_zip));
  311. UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip));
  312. pos = page_offset(str);
  313. ut_ad(pos < PAGE_DATA);
  314. memcpy(page_zip->data + pos, str, length);
  315. /* The following would fail in page_cur_insert_rec_zip(). */
  316. /* ut_ad(page_zip_validate(page_zip, str - pos)); */
  317. if (UNIV_LIKELY_NULL(mtr)) {
  318. page_zip_write_header_log(str, length, mtr);
  319. }
  320. }
  321. #ifdef UNIV_MATERIALIZE
  322. # undef UNIV_INLINE
  323. # define UNIV_INLINE UNIV_INLINE_ORIGINAL
  324. #endif