Commit graph

269 commits

Author SHA1 Message Date
marko
ee152b828f branches/zip: Note that TRX_ID and ROLL_PTR only exist on B-tree leaf pages
of clustered indexes.  Previously, parts of the code assumed that these
columns would exist on all leaf pages.  Simplify the update-in-place of
these columns.

Add inline function dict_index_is_clust() to replace all tests
index->type & DICT_CLUSTERED.

Remove the redo log entry types MLOG_ZIP_WRITE_TRX_ID and
MLOG_ZIP_WRITE_ROLL_PTR, because the modifications to these columns
are covered by logical logging.

Fuse page_zip_write_trx_id() and page_zip_write_roll_ptr() into
page_zip_write_trx_id_and_roll_ptr().

page_zip_dir_add_slot(), page_zip_available(): Add flag "is_clustered",
so that no space will be reserved for TRX_ID and ROLL_PTR on leaf pages
of secondary indexes.

page_zip_apply_log(): Flag an error when val==0 is encoded with two bytes.

page_zip_write_rec(): Add debug assertions that there is enough space
available for the entry before copying the data bytes of the record.
2006-03-09 17:26:02 +00:00
marko
54eee4ada5 branches/zip: Fix a bug in optimistic update.
btr_cur_update_in_place(): Remove the page_zip_write_rec() call,
because row_upd_rec_in_place() already calls it.
2006-03-09 16:48:25 +00:00
marko
723a9fc1d9 branches/zip: Fix a bug in the insertion of a record.
page_dir_split_slot(): Do not pass page_zip to page_dir_slot_set_n_owned(),
because the caller will rewrite the dense page directory later.  At this
point of execution, the dense directory will not contain the newly inserted
record, which may end up being written to new_slot.
2006-03-09 13:35:04 +00:00
marko
16f3d27113 branches/zip: Fix various bugs.
btr_root_raise_and_insert(): Because btr_page_set_level() must not
change level from non-zero to zero on compressed pages, invoke
btr_page_set_level() with page_zip==NULL and compress the entire
root page after creating it from the scratch.

btr_attach_half_pages(): Simplify the computation of lower_page_zip
and upper_page_zip.  Invoke btr_node_ptr_set_child_page_no() with
the correct page_zip.

page0page.h: Add __attribute__((const)) to functions testing for
infimum or supremum.

page_zip_dir_delete(): Note that the third parameter may be NULL.
Correct offset errors.

page_zip_available(): Use n_heap instead of n_recs.

page_zip_dir_find(), page_zip_dir_find_free(): Fix off-by-one error.

page_zip_fields_encode(), page_zip_fields_decode(): Encode and decode
index->n_nullable for non-leaf pages.

page_zip_apply_log(): Write REC_NEW_HEAP_NO before calling
rec_offs_make_valid().

page_zip_write_node_ptr(): Correct off-by-one error.

page_cur_search_with_match(): Make use of page_is_leaf().

page_dir_add_slots(): Replaced with page_dir_add_slot().  Use memmove().
2006-03-08 22:19:20 +00:00
marko
eeedd93ac3 branches/zip: btr_page_reorganize_low(): Assert page_zip_validate()
before and after the operation.
2006-03-08 09:57:54 +00:00
marko
12cc5e832f branches/zip: Minor bug fix
buf_flush_init_for_writing(): Copy FIL_PAGE_LSN to the compressed page.

page_cur_insert_rec_low(): Add debug assertion.
2006-03-07 13:47:33 +00:00
marko
24bb11b9cd branches/zip: Fix errors in bit arithmetics.
page_zip_fixed_field_encode(), page_zip_fields_encode(),
page_zip_fields_decode(): Do not waste one bit when encoding quantities
larger than 127.

page_zip_apply_log(), page_zip_write_rec(): Decode and encode
heap_no >= 127 correctly.
2006-03-07 11:41:56 +00:00
marko
51b7897242 branches/zip: Correctly restore extra bytes in page_zip_apply_log().
page_zip_apply_log(): Correct an off-by-one error.

page_zip_write_rec(): Correct a debug assertion.
Encode heap_no as soon as possible.
2006-03-07 09:41:31 +00:00
marko
63e9515826 branches/zip: Fix some bugs in the insertion of records.
row_upd_rec_in_place(), page_zip_write_rec(): Add parameter "index".

page_dir_set_n_heap(): Add a debug assertion that on compressed
pages, n_heap will always be incremented by one.  Improve code formatting.

page_zip_dir_add_slot(): New function, called from
page_cur_insert_rec_low() after page_mem_alloc_heap().

rec_set_n_owned_new(): Do not call page_zip_rec_set_owned()
on the supremum record.

rec_offs_make_valid(): Add debug assertions.

page_zip_dir_user_size(): Correct an off-by-one error in the debug assertion.

page_zip_apply_log(): Add parameter trx_id_col.  Skip trx_id and roll_ptr.

page_zip_decompress(): Simplify the handling of "storage" in the loop that
copies the uncompressed fields.

page_zip_write_rec(): Store trx_id and roll_ptr separately.

page_zip_write_trx_id(), page_zip_write_roll_ptr(): Fix off-by-one errors.

page_cur_insert_rec_low(): Call page_zip_dir_add_slot() after
page_mem_alloc_heap().  Remove some redundant assertions.
Pass page_zip to page_dir_split_slot().
2006-03-06 21:00:05 +00:00
marko
682d39515e branches/zip: Merge revisions 247:265 from trunk. 2006-03-03 14:43:05 +00:00
marko
748da76442 branches/zip: Bug fixes
rec_get_offsets_reverse(): Calculate extra_size correctly.

page_zip_apply_log(): Fix an off-by-one error in comparison.
Replace heap_status with hs where possible.
Increment the heap_no in heap_status correctly.

page_zip_decompress(): Eliminate the local variable "err".
Check for Z_STREAM_END only at the start of a record, so that
incomplete records will always be detected.

page_zip_write_rec(): Calculate the address of "storage" in the
same way as elsewhere.  Add TODO comments regarding the handling
of the uncompressed fields (BLOB pointers, trx_id, and roll_ptr).
2006-03-03 14:32:27 +00:00
marko
9d38a29b09 branches/zip: Merge table->zip to table->flags. Add dict_table_is_zip(). 2006-03-03 08:39:20 +00:00
marko
1b67f73d7c branches/zip: page_zip_write_rec(): Add a page_zip_validate() assertion. 2006-03-03 08:12:59 +00:00
marko
9a601a1c8b branches/zip: Fix some bugs in incremental compression.
btr_create(): page_zip_compress() returns FALSE on failure.

page_zip_write_header(): Write to page_zip->data[] instead of page_zip[].

buf_flush_init_for_writing(): Add parameter page_zip and set the fields
also in the header of the compressed page.

btr_cur_search_to_nth_level(): Add ut_ad() on page_zip_validate().
2006-03-02 14:05:32 +00:00
marko
d1c2a0f5c1 branches/zip: Identify records in the modification log by heap_no.
page_zip_compress(), page_zip_decompress(), page_zip_write_rec():
Note that the end marker of the modification log is 1 byte.

page_zip_find_heap_no(): Remove.

page_zip_apply_log(): Remove parameter "page".  Instead of a 2-byte offset
to the record, decode the heap number using a variable-length code.

page_zip_write_rec(): Check the range of heap_no with debug assertions.
Encode the heap number instead of an offset to the start of the record.
2006-03-01 13:39:56 +00:00
marko
c86de5b837 branches/zip: Move some private functions from page0zip.ic and page0zip.h
to page0zip.c.
2006-03-01 11:38:25 +00:00
marko
c1f7cc85eb branches/zip: Remove remaining references to relocated records in
function prototypes and comments.  These changes were accidentally
forgotten from revision 253.
2006-03-01 11:29:18 +00:00
marko
fb00d066bb branches/zip: In page_zip_compress(), do not touch page_zip unless the
operation succeeds.

page_zip_dir_set(): Remove, as the slots will be written to a temporary
buffer.

page_zip_dir_encode(): Replace page_zip with buf.  Make some assertions
more accurate.  Write the dense page directory to buf.

page_zip_compress(): Allocate a temporary buffer for the compressed page
except the page header.  Make some assertions more accurate.

page_zip_compress(), page_zip_decompress(): Remove 2 bytes of empty space
adjacent to the area reserved for storing uncompressed columns.
2006-02-28 20:37:29 +00:00
marko
20acdb796f branches/zip: Fix a memory management bug.
page_zip_decompress(): Free index and heap at the end of the function.
Do not write the index to the MLOG_ZIP_DECOMPRESS record, since it can be
decoded from the compressed page.
2006-02-27 16:03:32 +00:00
marko
7c8b6bda4b branches/zip: Make page_delete_rec_list_start() work on compressed pages,
now that deletion of records on compressed pages is guaranteed to succeed.
2006-02-27 12:38:49 +00:00
marko
86ae15b86a branches/zip: Remove the possibility to relocate reallocated records
on a compressed page.

page_zip_get_n_relocated(), page_zip_set_n_relocated(),
page_zip_get_relocated(): Remove.

page0zip.c, page0zip.ic: Remove all references to n_relocated.

page_cur_insert_rec_low(): On pages that are compressed,
never relocate records that are allocated from the free list.
2006-02-27 10:26:59 +00:00
marko
79b18e208c branches/zip: Correct bugs found by running ibtestblob.
page_zip_compress(): Add assertions !c_stream.avail_in where appropriate.
Add assertions on c_stream.next_in.  Correct malformed assertion on
externs > c_stream.next_in.  Note that there may be trailing garbage after
the last record.

page_zip_fields_decode(): Correctly decode variable-length fields having
maximum length greater than 255 bytes.

page_zip_decompress(): Remove the special treatment of the case !n_dense.
Replace the Z_NO_FLUSH argument of inflate() with Z_SYNC_FLUSH.
Treat Z_OK return value the same as Z_BUF_ERROR: always check avail_out.
After decompressing all records, decompress any trailing garbage.
2006-02-27 09:53:58 +00:00
marko
82d38b63e3 branches/zip: Merge revisions 236:247 from trunk. 2006-02-27 09:33:26 +00:00
marko
f40121415d branches/zip: Merge revisions 200:236 from trunk. 2006-02-23 19:25:29 +00:00
marko
a1198681be branches/zip: Add TODO comments about the relocation log.
page_cur_insert_rec_low(): Note that the relocation log
on the compressed page needs to reflect some changes of extra_size.
2006-02-23 15:00:45 +00:00
marko
c952dc5b49 branches/zip: When allocating records from the free list,
do not allow extra_size to decrease on compressed pages.

Split page_mem_alloc() to page_mem_alloc_free() and page_mem_alloc_heap().

page_cur_insert_rec_low(): Remove parameter "tuple".  Implement some of the
logic from page_mem_alloc().

page_cur_tuple_insert(): Convert the tuple to a record and calculate offsets.

page_zip_validate(): Assert that the page is in compact format.
2006-02-23 14:45:12 +00:00
marko
4167b06c33 branches/zip: Minor cleanup.
Remove the declaration of the undefined function
page_zip_available_noninline().

Make page_zip_available() private to page0zip.c and page0zip.ic.
2006-02-22 13:49:05 +00:00
marko
c04ddfef05 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.
2006-02-22 13:02:40 +00:00
marko
331c8eaada branches/zip: Remove temporary hooks for testing BLOB compression.
dict_mem_table_create(): Initialize table->zip.

btr0cur.c: Distinguish compressed BLOBs based on page_zip or table->zip.
2006-02-21 14:43:23 +00:00
marko
69f236c29f branches/zip:
Fix the way how btr_free_externally_stored_field() is called in purge.

btr_free_externally_stored_field(): Add parameter field_ref that points
directly to the BLOB reference.  Use rec, offsets, page_zip, and i
only for the page_zip_write_blob_ptr() call.

row_purge_upd_exist_or_extern(): Do not assume that the undo log contains
the entire record.  Only pass the BLOB reference to
btr_free_externally_stored_field().
2006-02-21 14:15:11 +00:00
marko
748f0694f0 branches/zip: Fix bugs in the handling of externally stored columns.
btr_cur_pessimistic_insert(): Pass the "extern storage" flags to
btr_root_raise_and_insert() or btr_page_split_and_insert().

btr_copy_externally_stored_field(): Include local_len in the returned length.
2006-02-21 10:24:32 +00:00
marko
6ce8427cb8 branches/zip: Merge revisions 79:200 from trunk. 2006-02-17 14:19:39 +00:00
marko
4ef9ca6fb2 branches/zip:
btr_cur_optimistic_insert(): Replace page_cur_insert_rec_low()
with page_cur_tuple_insert().

btr_cur_pessimistic_update(): Add the columns of big_rec_vec to ext_vect,
so that the "extern storage" bits will be set correctly in
btr_cur_insert_if_possible().
2006-02-17 14:14:07 +00:00
marko
b815ca5d21 lock_rec_move(): Compute receiver_heap_no correctly. 2006-02-17 13:44:16 +00:00
marko
c531f9972b branches/zip: row_purge_upd_exist_or_extern(): use the offsets correctly 2006-02-16 13:47:20 +00:00
marko
ee5a92aaef branches/zip: Implement the compression of BLOB columns.
This has not been extensively tested yet, because some other part of the
code breaks in "ibtestblob".

btr_free_page_low(): Add parameters "space" and "page_no", because they
are omitted from compressed BLOB pages.

btr0cur.c: Implement the compression and decompression of BLOB columns,
enabled at compile-time (#define ZIP_BLOB TRUE) for now.

btr_rec_free_externally_stored_fields(),
btr_copy_externally_stored_field(): Made static

mlog_log_string(): New function, split from mlog_write_string(), allows
to avoid a dummy memcpy() of compressed BLOB pages.
2006-02-16 12:58:18 +00:00
marko
d8e3b8114c branches/zip: Remove in-place updates of the "external storage"
flag of records.  The flags may only be updated in heap-allocated
copies of records.

btr_root_raise_and_insert(),
btr_page_split_and_insert(),
btr_cur_insert_if_possible(),
btr_cur_optimistic_insert(),
btr_cur_pessimistic_insert(),
page_cur_tuple_insert(),
page_cur_insert_rec_low(): Add parameters "ext" and "n_ext".

dtuple_convert_big_rec(): Make parameter "ext" const.
2006-02-13 14:28:00 +00:00
marko
062c64e87e branches/zip: Prepare for in-place updates of B-tree node pointers,
BLOB pointers, trx_id, and roll_ptr.

btr_empty(), btr_create(), page_create(): Add parameter "index", as some
index information will be encoded on the compressed page.

Define REC_NODE_PTR_SIZE as 4.

Allow btr_page_reorganize() and btr_page_reorganize_low() to fail.

Define the error code DB_ZIP_OVERFLOW.

Make row_ins_index_entry_low() static.

page0zip: Encode the index, log reorganized records, and store uncompressed
fields separately from the compressed data stream.
2006-02-10 15:06:17 +00:00
marko
c0ac96d9b4 branches/zip: Prepare for upcoming implementation of page_zip_compress()
that will require complete index information.

dict_create_index_step(): invoke dict_index_add_to_cache() before btr_create()

dict_index_remove_from_cache(): make public

dict_index_get_if_in_cache_low(): new function, for holding dict_sys->mutex

buf_flush_init_for_writing(): remove the temporary hook to page_zip_compress()

page_create(): add temporary hook to page_zip_compress()
2006-02-03 14:44:29 +00:00
marko
05fbb8ca9d branches/zip:
buf_flush_init_for_writing(): The reported dense page directory size was
4 bytes too much.  Subtract 2 (infimum and supremum) from n_heap.

page_zip_decompress(): When decompressing the last user record, only set
heap_no and the status bits if there is data to decode, i.e., there
are user records on the page.
2005-11-30 23:09:36 +00:00
marko
77c570dc4d branches/zip: Minor improvements for debugging and testing purposes.
buf_flush_init_for_writing(): Improve the diagnostics and make the
condition for skipping pages accurate.

univ.i: Introduce UNIV_ZIP_DEBUG for enabling some page_zip_validate() tests.

page0zip.h, page0zip.c: Define and use page_zip_validate() in
page_zip_compress() and page_zip_write() if UNIV_ZIP_DEBUG or UNIV_DEBUG
is defined.
2005-11-30 13:57:54 +00:00
marko
ad69a82677 branches/zip: Merge revisions 72:79 from trunk. 2005-11-30 13:29:31 +00:00
marko
e12d8a0f10 branches/zip: Merge revisions 9:72 from trunk. 2005-11-29 12:30:46 +00:00
marko
1a1d2cd325 branches/zip: More fixes to problems found in speedc test runs.
Before the speedc test was interrupted, 121,765 B-tree pages were written.

buf_flush_init_for_writing(): Do not compress other than B-tree pages
outside the system tablespace.  Report non-B-tree pages.

page_zip_decompress(): Clear the unused heap space on the uncompressed page,
so that the whole buffer for the uncompressed page will be initialized and
page_zip_validate() will always succeed.
2005-11-29 10:24:45 +00:00
marko
941127fd9d branches/zip: Fixes to allow the speedc test to run without assertion failures.
page_zip_dir_decode(): Correct the handling of the free list.

page_zip_set_extra_bytes(): Remove off-by-one error in the first loop.

page_zip_apply_log(): Replace parameter end with size, and let end=data+size.

page_zip_decompress(): Properly handle pages where the first user record has
more than REC_N_NEW_EXTRA_BYTES extra bytes.

page_delete_rec_list_end(): Remove page_zip_temp.  This operation will be
done completely in-place on page_zip.  If page_zip is specified, clear the
data bytes and the info and status bits of deleted records and clear the
removed directory slots.

page_dir_delete_slot(): Clear the last directory slot, which will be removed.
2005-11-28 11:32:52 +00:00
marko
4fc27c2723 branches/zip: Minor fixes. Now one non-trivial page compresses and
decompresses properly.

page_mem_free(): Adjust the temporary condition for zeroing data.

page_zip_compress(): Do not accept Z_STREAM_END from non-final deflate().
Tighten the assertion on c_stream.avail_in.

page_zip_dir_sort(): Note that the high bound is not inclusive.

page_zip_dir_decode(): Remove off-by-one error in page_zip_dir_sort() call.

page_zip_set_extra_bytes(): Add the termination condition that was forgotten
from the second for loop.  Simplify the code a little.

page_zip_decompress(): Do not accept Z_STREAM_END from non-final inflate().
Tighten the assertion on d_stream.avail_out.  Increment heap_status correctly.
2005-11-25 14:17:40 +00:00
marko
49ef38ef28 branches/zip: Minor fixes to get a page with one record compress/decompress.
A page with multiple records or deleted records still does not compress
or decompress properly.

buf_flush_init_for_writing(): Initialize block->page_zip properly so that all
assertions in page0zip can be enabled.

page_zip_decompress(): Note that corrupt data should not lead to assertions.

page_zip_dir_set(): Correct the interface.  Fix off-by-one error.
page_zip_dir_get(): Fix off-by-one error.

page0zip.c: Replace n_heap with n_dense and add comments about
the infimum and supremum records whenever we subtract 2 from heap_no.
Fix some programming errors.
2005-11-25 12:34:38 +00:00
marko
5ef5378f2e branches/zip: Minor fixes. Compression/decompression still fails.
buf0flu.c: Allocate the temporary buffer from buf_frame_alloc().

page_zip_simple_validate(): Do not assert page_zip->m_start >= PAGE_DATA.

page_zip_compress(): Replace some assertions with page_zip_simple_validate(),
and do not assert anything about page_zip->data contents.

page_zip_validate(): Do not compare the page trailer bytes.

page_zip_write(): Assert that the entire page headers match and
that page_zip->m_start >= PAGE_DATA.
2005-11-25 07:51:28 +00:00
marko
b348fcafa5 branches/zip: Implement a more compact page format.
Add a hook to buf0flu.c for testing compression and decompression.
TODO: adapt page_zip_write() calls.
2005-11-24 14:13:10 +00:00
marko
554299f38e branches/zip: Split page_zip_apply_log() from page_zip_decompress(). 2005-11-18 07:42:02 +00:00