Commit graph

265 commits

Author SHA1 Message Date
marko
68a1ee9960 branches/zip: Add some Doxygen comments for many structs, typedefs,
#defines and global variables.  Many are still missing.
2009-05-26 12:28:49 +00:00
marko
11ff89d994 branches/zip: Add @file comments, and convert decorative
/*********************************
comments to Doxygen /** style like this:
/*****************************//**

This conversion was performed by the following command:

perl -i -e 'while(<ARGV>){if (m|^/\*{30}\**$|) {
s|\*{4}$|//**| if ++$com>1; $_ .= "\@file $ARGV\n" if $com==2}
print; if(eof){$.=0;undef $com}}' */*[ch] include/univ.i
2009-05-25 09:52:29 +00:00
marko
d075e80c49 branches/zip: Split some long lines that were introduced in r5091. 2009-05-25 08:09:45 +00:00
marko
e49dee377b branches/zip: Convert the function comments to Doxygen format.
This patch was created by running the following commands:

for i in */*[ch]; do doxygenify.pl $i; done
perl -i -pe 's#\*{3} \*/$#****/#' */*[ch]

where doxygenify.pl is
https://svn.innodb.com/svn/misc/trunk/tools/doxygenify.pl r510

Verified the consistency as follows:

(0) not too many /* in: */ or /* out: */ comments left in the code:
grep -l '/\*\s*\(in\|out\)[,:/]' */*[ch]

(1) no difference when ignoring blank lines, after stripping all
C90-style /* comments */, including multi-line ones, before and after
applying this patch:

perl -i -e 'undef $/;while(<ARGV>){s#/\*(.*?)\*/##gs;print}' */*[ch]
diff -I'^\s*$' --exclude .svn -ru TREE1 TREE2

(2) after stripping @return comments and !<, generated a diff and omitted
the hunks where /* out: */ function return comments were removed:

perl -i -e'undef $/;while(<ARGV>){s#!<##g;s#\n\@return\t.*?\*/# \*/#gs;print}'\
 */*[ch]
svn diff|
perl -e 'undef $/;$_=<>;s#\n-\s*/\* out[:,]([^\n]*?)(\n-[^\n]*?)*\*/##gs;print'

Some unintended changes were left.  These will be removed in a
subsequent patch.
2009-05-25 05:30:14 +00:00
marko
6e042881e1 branches/zip: page_cur_lcg_prng(): Add missing parameter list. 2009-05-20 08:35:33 +00:00
marko
cea9a03ab6 branches/zip: Fix some function comments. 2009-05-20 08:19:40 +00:00
marko
b04cffec7d branches/zip: Add missing function comments. 2009-05-20 04:42:12 +00:00
marko
9649c3e3b3 branches/zip: Write PAGE_MAX_TRX_ID to the redo log. Otherwise,
transactions that are started before the rollback of incomplete
transactions has finished may have an inconsistent view of the
secondary indexes.

dict_index_is_sec_or_ibuf(): Auxiliary function for controlling
updates and checks of PAGE_MAX_TRX_ID: check whether an index is a
secondary index or the insert buffer tree.

page_set_max_trx_id(), page_update_max_trx_id(),
lock_rec_insert_check_and_lock(),
lock_sec_rec_modify_check_and_lock(), btr_cur_ins_lock_and_undo(),
btr_cur_upd_lock_and_undo(): Add the parameter mtr.

page_set_max_trx_id(): Allow mtr to be NULL.  When mtr==NULL, do not
attempt to write to the redo log.  This only occurs when creating a
page or reorganizing a compressed page.  In these cases, the
PAGE_MAX_TRX_ID will be set correctly during the application of redo
log records, even though there is no explicit log record about it.

btr_discard_only_page_on_level(): Preserve PAGE_MAX_TRX_ID.  This
function should be unreachable, though.

btr_cur_pessimistic_update(): Update PAGE_MAX_TRX_ID.

Add some assertions for checking that PAGE_MAX_TRX_ID is set on all
secondary index leaf pages.

rb://115 tested by Michael, fixes Issue #211
2009-05-19 18:59:07 +00:00
marko
e9a3aa18c8 branches/zip: Introduce the logical type names trx_id_t, roll_ptr_t,
and undo_no_t. Each type is still defined as dulint.

This is an initial step towards replacing dulint with a 64-bit data type.
Because modern compilers have no trouble supporting 64-bit arithmetics
even on 32-bit targets, the dulint struct is a relic that should go.

The last remaining major use of dulint is dictionary IDs
(table, index, and row ids).

rb://114 approved by Sunny Bains
2009-04-23 05:32:36 +00:00
vasil
395bee3fce branches/zip:
When using the random function, first take the modulus by the number of pages
and then typecast to ulint.
2009-04-14 10:32:11 +00:00
vasil
7565147d08 branches/zip:
Fix Bug#43660 SHOW INDEXES/ANALYZE does NOT update cardinality for
indexes of InnoDB table

by replacing the pseudo random number generator with a better one (LCG).

This also fixes Mantis Issue#212.

Approved by:	Heikki (rb://110)
2009-04-07 05:35:23 +00:00
marko
d90bea085a branches/zip: Remove unneeded definitions and dependencies
from UNIV_HOTBACKUP builds.
2009-03-23 14:21:34 +00:00
marko
412893d6f3 branches/zip: Define and use PAGE_ZIP_MATCH.
In UNIV_HOTBACKUP builds, assume fixed allocation.
2009-03-23 09:07:20 +00:00
marko
68247c5fa6 branches/zip: page_validate(): Always report the space id and the
name of the index.

In Hot Backup, do not invoke comparison functions, as MySQL collations
will be unavailable.
2009-03-20 10:52:14 +00:00
marko
184ee4885c branches/zip: Non-functional change for reducing dependencies in InnoDB Hot Backup:
Replace srv_sys->dummy_ind1 and srv_sys->dummy_ind2 with
dict_ind_redundant and dict_ind_compact, initialized in dict_init().
2009-03-20 10:33:33 +00:00
vasil
dcf56b04fd branches/zip:
* Remove old Innobase copyright lines from C source files
* Add a reference to the GPLv2 license as recommended by the lawyers
at Oracle Legal

[Step 24/28]
2009-02-17 10:01:41 +00:00
vasil
1c46e6ef6d branches/zip:
* Remove old Innobase copyright lines from C source files
* Add a reference to the GPLv2 license as recommended by the lawyers
at Oracle Legal

[Step 23/28]
2009-02-17 09:53:58 +00:00
marko
0bd67bdba1 branches/zip: Remove some redundant #include directives. 2009-01-23 12:07:38 +00:00
marko
9dba446469 branches/zip: page_cur_insert_rec_zip(): When allocating insert_buf from
the free list, zero out the node pointer field of the deleted record if
the new record would not overwrite it.  This fixes a harmless content
mismatch reported by page_zip_validate() that was reported as Issue #147.

rb://66 approved by Heikki Tuuri
2008-12-22 14:40:17 +00:00
marko
de011c2198 branches/zip: page_cur_insert_rec_zip(): When allocating insert_buf
from the free list, zero out the DB_TRX_ID and DB_ROLL_PTR of the
deleted record if the new record would not overwrite these
fields. This fixes a harmless content mismatch reported by
page_zip_validate() that was reported as Issue #111.
rb://55 approved by Sunny Bains.
2008-12-02 08:16:05 +00:00
marko
05c33d6d3f branches/zip: When invoking page_zip_copy_recs(), update the lock table
and the adaptive hash index.  This should fix Issue #95 and Issue #87.

page_zip_copy_recs(): Copy PAGE_MAX_TRX_ID as well, to have similar behavior
to page_copy_rec_list_start() and page_copy_rec_list_end().

btr_root_raise_and_insert(), btr_page_split_and_insert(), btr_lift_page_up():
Update the lock table and the adaptive hash index.
2008-10-15 06:32:40 +00:00
marko
25408c8e48 branches/zip: page_cur_delete_rec(): Remove the bogus page_zip_validate_low()
assertion that was added in r2781 and explain why it was bogus.
2008-10-13 18:29:12 +00:00
marko
7124a823ac branches/zip: Add missing NULL check to the assertion added in r2781. 2008-10-13 17:35:30 +00:00
marko
126cc7025d branches/zip: page_cur_delete_rec(): Call page_zip_validate_low(). 2008-10-13 09:40:57 +00:00
marko
d546c0cfb5 branches/zip: page_copy_rec_list_end(): Remove the call
page_zip_validate_low(new_page_zip, new_page, TRUE) because it would
cause bogus failures in btr_compress(), as noted in Issue #79.
2008-10-08 09:55:48 +00:00
marko
278a68a0ca branches/zip: Improve page_zip_validate() instrumentation.
btr_lift_page_up(): Invoke page_zip_validate() on every page whose level
is adjusted.

btr_compress(): Invoke page_zip_validate() on merge_page at the end.

page_zip_copy_recs(): Relax the page_zip_validate(...) to
page_zip_validate_low(..., sloppy = TRUE) to avoid bogus assertion failures.

page_copy_rec_list_end(), page_delete_rec_list_start():
Invoke page_zip_validate_low(sloppy = TRUE).
2008-10-07 12:51:32 +00:00
marko
80e6e2c25a branches/zip: Improve the diagnostics of issue #79.
page_zip_fail_func(): Display the timestamp.

page_zip_validate_low(): Display information about ignored min_rec_flag
differences.
2008-10-06 12:26:27 +00:00
marko
5f3fbb7b84 branches/zip: Relax the page_zip_validate() check during crash recovery:
ignore intermittent differences in the "predefined minimum record" flag.

page_zip_validate_low(): Renamed from page_zip_validate(), with an
additional parameter: ibool sloppy.  Ignore REC_INFO_MIN_REC_FLAG when
sloppy == TRUE.

page_zip_validate(): Wrapper for page_zip_validate_low().  Pass
sloppy = recv_recovery_is_on().

recv_recover_page(): After applying the changes from the redo log to a
compressed B-tree page, invoke page_zip_validate_low() in strict mode.
2008-10-06 07:13:52 +00:00
marko
d487e7d14f branches/zip: page_zip_validate(): On page header mismatch,
dump the data structures.  This was forgotten in r2698.
2008-10-01 19:03:45 +00:00
marko
b479f9004a branches/zip: page_zip_validate(): Explain how the v-bits can be viewed. 2008-09-29 10:26:41 +00:00
marko
da27322bfd branches/zip: page_zip_validate(): On failure, dump all data structures.
page_zip_hexdump_func(): New function, to dump a block of data.
ut_print_buf() would dump everything on a single line, which is hard
to read.

page_zip_hexdump(): Wrapper macro for page_zip_hexdump_func().

page_zip_validate(): dump page_zip, page_zip->data, page, temp_page if !valid.
2008-09-29 08:26:42 +00:00
marko
e24dfa77b8 branches/zip: Non-functional change:
page_zip_copy_recs(): Rename from page_zip_copy().
Update the function comment.
2008-09-25 12:17:52 +00:00
marko
5855ced44c branches/zip: page_zip_copy(): Skip PAGE_MAX_TRX_ID, because
page_copy_rec_list_end(), page_copy_rec_list_start() and friends do
not copy it either.
2008-09-25 06:29:08 +00:00
marko
0ad7c61b45 branches/zip: page_zip_copy(): Copy only those B-tree page header
fields that are related to the records stored in the page.

page_zip_copy() is a fall-back method in certain B-tree operations
(tree compression, splitting or merging nodes).  The contents of a
page may fit in the compressed page frame when it has been modified in
a certain sequence, but not when the page is recompressed.  Sometimes,
copying all or part of the records to an empty page could fail because
of compression overflow.  In such cases, we copy the compressed and
uncompressed pages bit for bit and delete any unwanted records from
the copy.  (Deletion is guaranteed to succeed.)  The method
page_zip_copy() is invoked very rarely.

In one case, page_zip_copy() was called in btr_lift_page_up() to move
the records to the root page of the B-tree.  Because page_zip_copy()
copied all B-tree page header fields, it overwrote the file segment
header fields PAGE_BTR_SEG_LEAF and PAGE_BTR_SEG_TOP.  This is the
probable cause of the corruption that was reported as Mantis issue #63
and others.
2008-09-25 06:15:36 +00:00
marko
6378cae6bb branches/zip: Prevent infinite B-tree page splits by ensuring that
there will always be enough space for two node pointer records in an
empty B-tree page.  This was reported as Mantis issue #73.

page_zip_rec_needs_ext(): Add the parameter n_fields, for accurate
estimation of the compressed size of the data dictionary information.
Given that this function is only invoked for records on leaf pages,
require that there be enough space for one record in the compressed
page.  We check elsewhere that there will be enough room for two node
pointer records on higher-level pages.

btr_cur_optimistic_insert(): Ensure that there will be enough room for
two node pointer records on an empty non-leaf page.  The rule for
leaf-page records will be enforced by the callers of
page_zip_rec_needs_ext().

btr_cur_pessimistic_insert(): Remove the insufficient check that the
leaf page record should be compressible by itself.  Instead, now we
require that two node pointer records fit on a non-leaf page, and one
record will fit in uncompressed form on the leaf page.

page_zip_write_header(), page_zip_write_rec(): Re-enable the debug
assertions that were violated by the insufficient check in
btr_cur_pessimistic_insert().

innodb_bug36172.test: Use a larger compressed page size.
2008-09-17 06:23:52 +00:00
marko
18700aa8cb branches/zip: page_zip_reorganize(): Compressed pages are always in compact
format.  Replace dict_table_is_comp(index->table) with TRUE.
2008-08-27 06:23:59 +00:00
marko
cd124b7524 branches/zip: Always display a newline after ut_print_buf(stderr, ...). 2008-08-06 08:10:21 +00:00
marko
038f4dcfc8 branches/zip: Disable two debug assertions that attempt to call
buf_block_align() on a non-file page frame that was created in
btr_cur_pessimistic_insert(), to see if a record fits on a compressed
page by itself.  These assertions caused an assertion failure in
buf_block_align() in innodb_bug36172.test.

page_zip_write_rec(), page_zip_write_header(): Remove the assertion
that calls buf_frame_get_page_zip().
2008-08-06 06:20:05 +00:00
marko
095c759f57 branches/zip: page_copy_rec_list_start(): Remove the bogus assertion that was
added in r2554.  When this function is called on an empty new_block, "ret"
will always point to the page infimum.
2008-08-04 07:09:34 +00:00
marko
e1c9387bab branches/zip: page_copy_rec_list_start(): Add the assertion
ut_a(ret_pos > 0) that was added to page_copy_rec_list_end() in r2552,
as suggested by Sunny in Mantis issue#52.
2008-08-04 06:59:39 +00:00
marko
20852452a0 branches/zip: page_copy_rec_list_end(): Add the assertion ut_a(ret_pos > 0)
that was suggested by Sunny in Mantis issue#52.
2008-08-01 13:02:46 +00:00
marko
f29b8ee0c3 branches/zip: Rename the INFORMATION_SCHEMA tables
INNODB_ZIP and INNODB_ZIP_RESET to
INNODB_COMPRESSION and INNODB_COMPRESSION_RESET,
and remove the statistics of the buddy system.

This change was discussed with Ken.  It makes the tables shorter
and easier to understand.  The removed data will be represented in
the tables INNODB_COMPRESSION_BUDDY and INNODB_COMPRESSION_BUDDY_RESET
that will be added later.

i_s_innodb_zip, i_s_innodb_zip_reset, i_s_zip_fields_info[],
i_s_zip_fill_low(), i_s_zip_fill(), i_s_zip_reset_fill(),
i_s_zip_init(), i_s_zip_reset_init(): Replace "zip" with "compression".

i_s_compression_fields_info[]: Remove "used", "free",
"relocated", "relocated_usec".  In "compressed_usec" and "decompressed_usec",
replace microseconds with seconds ("usec" with "sec").

page_zip_decompress(): Correct a typo in the function comment.

PAGE_ZIP_SSIZE_BITS, PAGE_ZIP_NUM_SSIZE: New constants.

page_zip_stat_t, page_zip_stat: Statistics of the compression, grouped
by page size.

page_zip_simple_validate(): Assert that page_zip->ssize is reasonable.
2008-03-28 09:28:54 +00:00
marko
99b93f4da1 branches/zip: Fix most MSVC (Windows) compilation warnings.
lock_get_table(), locks_row_eq_lock(), buf_page_get_mutex(): Add return
after ut_error.  On Windows, ut_error is not declared as "noreturn".

Add explicit type casts when assigning ulint to byte to get rid of
"possible loss of precision" warnings.

struct i_s_table_cache_struct: Declare rows_used, rows_allocd as ulint
instead of ullint.  32 bits should be enough.

fill_innodb_trx_from_cache(), i_s_zip_fill_low(): Cast 64-bit unsigned
integers to longlong when calling Field::store(longlong, bool is_unsigned).
Otherwise, the compiler would implicitly convert them to double and
invoke Field::store(double) instead.

recv_truncate_group(), recv_copy_group(), recv_calc_lsn_on_data_add():
Cast ib_uint64_t expressions to ulint to get rid of "possible loss of
precision" warnings.  (There should not be any loss of precision in
these cases.)

log_close(), log_checkpoint_margin(): Declare some variables as ib_uint64_t
instead of ulint, so that there won't be any potential loss of precision.

mach_write_ull(): Cast the second argument of mach_write_to_4() to ulint.

OS_FILE_FROM_FD(): Cast the return value of _get_osfhandle() to HANDLE.

row_merge_dict_table_get_index(): Cast the parameter of mem_free() to (void*)
in order to get rid of the bogus MSVC warning C4090, which has been reported
as MSVC bug 101661:
<http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=101661>

row_mysql_read_blob_ref(): To get rid of a bogus MSVC warning C4090,
drop a const qualifier.
2008-03-04 08:57:07 +00:00
marko
9d58e3ff99 branches/zip: Improve the LRU algorithm with a separate unzip_LRU list of
blocks that contains uncompressed and compressed frames.  This patch was
designed by Heikki and Inaam, implemented by Inaam, and refined and reviewed
by Marko and Sunny.

buf_buddy_n_frames, buf_buddy_min_n_frames, buf_buddy_max_n_frames: Remove.

buf_page_belongs_to_unzip_LRU(): New predicate:
bpage->zip.data && buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE.

buf_pool_t, buf_block_t: Add the linked list unzip_LRU.  A block in the
regular LRU list is in unzip_LRU iff buf_page_belongs_to_unzip_LRU() holds.

buf_LRU_free_block(): Add a third return value to refine the case
"cannot free the block".

buf_LRU_search_and_free_block(): Update the documentation to reflect the
implementation.

buf_LRU_stat_t, buf_LRU_stat_cur, buf_LRU_stat_sum, buf_LRU_stat_arr[]:
Statistics for the unzip_LRU algorithm.

buf_LRU_stat_update(): New function: Update the statistics.  Called once
per second by srv_error_monitor_thread().

buf_LRU_validate(): Validate the unzip_LRU list as well.

buf_LRU_evict_from_unzip_LRU(): New predicate: Use the unzip_LRU before
falling back to the regular LRU?

buf_LRU_free_from_unzip_LRU_list(), buf_LRU_free_from_common_LRU_list():
Subfunctions of buf_LRU_search_and_free_block().

buf_LRU_search_and_free_block(): Reimplement.  Try to evict an uncompressed
page from the unzip_LRU list before falling back to evicting an entire block
from the common LRU list.

buf_unzip_LRU_remove_block_if_needed(): New function.

buf_unzip_LRU_add_block(): New function: Add a block to the unzip_LRU list.
2008-03-03 12:48:38 +00:00
marko
5377a7dd94 branches/zip: Add duration statistics to INFORMATION_SCHEMA.INNODB_ZIP.
buf_buddy_relocated_duration[],
page_zip_compress_duration[]
page_zip_decompress_duration[]: Record the total duration of the operations.

buf_buddy_relocate(), page_zip_compress(), page_zip_decompress():
Add ut_time_us() instrumentation.

i_s_zip_fields_info[], i_s_zip_fill_low(): Move the columns containing
cumulated statistics last.  Add relocated_usec, compressed_usec, and
decompressed_usec.
2008-02-27 14:34:44 +00:00
marko
d18f396b04 Do not enable page_zip_compress_log by default. This was accidentally
set in r2318.
2008-02-22 21:03:31 +00:00
marko
2d88188caf branches/zip: Enable excessive binary logging of page_zip_compress(),
for the purpose of comparing different compression algorithms.

PAGE_ZIP_COMPRESS_DBG: New preprocessor condition, to see if deflate()
is wrapped.

page_zip_compress_log: Log file counter.  If set to nonzero, logging
is enabled.

page_zip_compress_deflate(): Add the parameter logfile.

FILE_LOGFILE, LOGFILE: Macros for declaring and passing the parameter logfile.

page_zip_compress(): Open and close the logfile if needed.  Write the
uncompressed page and the size of the compressed data.  The data passed
to deflate() is written by the wrapper page_zip_compress_deflate().
2008-02-19 14:42:52 +00:00
marko
2c2b06ad75 branches/zip: Introduce UNIV_INTERN, a linkage specifier for InnoDB-global
symbols.  Use it for all definitions of non-static variables and functions.

lexyy.c, make_flex.sh: Declare yylex as UNIV_INTERN, not static.  It is
referenced from pars0grm.c.

Actually, according to
	nm .libs/ha_innodb.so|grep -w '[ABCE-TVXYZ]'
the following symbols are still global:

* The vtable for class ha_innodb
* pars0grm.c: The function yyparse() and the variables yychar, yylval, yynerrs

The required changes to the Bison-generated file pars0grm.c will be addressed
in a separate commit, which will add a script similar to make_flex.sh.

The class ha_innodb is renamed from class ha_innobase by a #define.  Thus,
there will be no clash with the builtin InnoDB.  However, there will be some
overhead for invoking virtual methods of class ha_innodb.  Ideas for making
the vtable hidden are welcome.  -fvisibility=hidden is not available in GCC 3.
2008-02-06 14:17:36 +00:00
marko
5c4f00c37d branches/zip: page_zip_reorganize(): Drop the adaptive search index before
attempting to reorganize the page, not after the reorganization has succeeded.
2008-01-07 13:40:12 +00:00
marko
bb4c7d88d3 branches/zip: page0zip.c: Add page_zip_fail() diagnostics to hopefully all
decompression failures.

page_zip_fields_decode(): Add page_zip_fail() diagnostics.

page_zip_apply_log(): Remove double space in page_zip_fail() printout.

page_zip_decompress_node_ptrs(), page_zip_decompress_sec(),
page_zip_decompress_clust_ext(), page_zip_decompress_clust(),
page_zip_decompress(): Add page_zip_fail() diagnostics for inflate()
failures and other errors.
2008-01-03 10:13:11 +00:00