Commit graph

46 commits

Author SHA1 Message Date
marko
7a2e6b0ed0 branches/zip: Fix a bug in fast index creation that was introduced in r2131
when row_build() was changed to prefetch all externally stored column
prefixes that occur in ordering fields of an index.

row_build(): Add the parameter col_table for determining which
externally stored columns need to be fetched.

row_merge_read_clustered_index(): Pass new_table as the said parameter,
so that newly added indexes containing column prefix indexes of externally
stored columns will work.
2007-12-03 12:16:07 +00:00
marko
0eb1f4f6ba branches/zip: Remove the warnings about pointer targets differing
in signedness that were introduced in r2114.

row_upd_index_replace_new_col_vals_index_pos(),
row_upd_index_replace_new_col_vals(): Declare "data" as const byte*
instead of const char*, and add casts to the dtype_get_at_most_n_mbchars()
calls.
2007-11-29 09:04:42 +00:00
marko
ab8f5e79ad branches/zip: In purge, avoid dereferencing unset BLOB pointers of freshly
inserted, uncommitted clustered index records when determining if a
secondary index record that contains a column prefix of an externally
stored column is referencing the clustered index record.

field_ref_zero[]: A BLOB pointer full of zero, for use in comparisons.

btr_copy_externally_stored_field_prefix(): Assert that the BLOB pointer is set.

row_ext_lookup_ith(), row_ext_lookup(), row_ext_lookup_low(): Document
that field_ref_zero is returned when the BLOB cannot be fetched.

row_ext_lookup_low(): Return field_ref_zero and *len = 0 when the
BLOB pointer is unset.

row_build_index_entry(): Return NULL when a needed BLOB pointer cannot
be dereferenced (row_ext_lookup returns field_ref_zero).  Check the
return value for NULL in callers.

row_vers_impl_x_locked_off_kernel(): Avoid comparisons when
row_build_index_entry() returns NULL.

row_vers_old_has_index_entry(): Ignore records for which
row_build_index_entry() returns NULL.  The entry should never be NULL
in rollback, but it may be NULL in purge.

row_merge_buf_add(): Assert that row_ext_lookup() does not return
field_ref_zero.  The table will be locked during index creation.
2007-11-27 09:11:45 +00:00
marko
855ccbd407 branches/zip: Correct mistakes made in r2114.
row_upd_index_replace_new_col_vals(): Declare fetch_ext.

row_upd_index_replace_new_col_vals_index_pos(): Add a type conversion
to the initialization expression of fetch_ext, to avoid a warning about
comparison between signed and unsigned.
2007-11-23 12:51:29 +00:00
marko
a7135ea369 branches/zip: Fix a bug in the updates of index records that contain a
column prefix of an externally stored column.

row_upd_ext_fetch(): New function.

row_upd_index_replace_new_col_vals(),
row_upd_index_replace_new_col_vals_index_pos(): Fetch prefixes of
externally stored columns when they are needed for column prefix
indexes.  For memory allocation, add the parameter ext_heap.  Avoid
repeating the inner loop after finding a  matching upd_field->field_no.
2007-11-23 12:40:19 +00:00
marko
8bed4c4c3f branches/zip: Do not access the fields of dfield_t directly.
dfield_dup(): New function for duplicating the data pointed to by dfield_t.

dfield_set_len(), dfield_set_data(): Add Valgrind instrumentation.
2007-10-23 06:46:12 +00:00
marko
8c57916af9 branches/zip: Fix bugs that were introduced in r1591.
row_upd_rec_in_place(): Correct a debug assertion.

row_upd_index_parse(): Initialize new_val with dfield_set_data() or
dfield_set_null().  This ensures that new_val->ext is initialized.
2007-10-22 09:57:43 +00:00
marko
df4c733df7 branches/zip: Initialize dfield_t::ext as soon as possible. This should
fix the bugs introduced in r1591.

row_rec_to_index_entry_low(): Clear "n_ext".  Do not allow it to be NULL.
Add const qualifier to dict_index_t*.

row_rec_to_index_entry(): Add the parameters "offsets" and "n_ext".

btr_cur_optimistic_update(): Add an assertion that there are no externally
stored columns.  Remove the unreachable call to btr_cur_unmark_extern_fields()
and the preceding unnecessary call to rec_get_offsets().

btr_push_update_extern_fields(): Remove the parameters index, offsets.
Only report the additional externally stored columns of the update vector.

row_build(), trx_undo_rec_get_partial_row(): Flag externally stored columns
also with dfield_set_ext().

rec_copy_prefix_to_dtuple(): Assert that there are no externally stored
columns in the prefix.

row_build_row_ref(): Note and assert that the index is a secondary index,
and assert that there are no externally stored columns.

row_build_row_ref_fast(): Assert that there are no externally stored columns.

rec_offs_get_n_alloc(): Expose the function.

row_build_row_ref_in_tuple(): Assert that there are no externally stored
columns in a record of a secondary index.

row_build_row_ref_from_row(): Assert that there are no externally stored
columns.

row_upd_check_references_constraints(): Add the parameter offsets, to
avoid a redundant call to rec_get_offsets().

row_upd_del_mark_clust_rec(): Add the parameter offsets.  Remove
duplicated code.

row_ins_index_entry_set_vals(): Copy the external storage flag.

sel_pop_prefetched_row(): Assert that there are no externally stored
columns.

row_scan_and_check_index(): Copy offsets to a temporary heap across
the invocation of row_rec_to_index_entry().
2007-10-17 12:13:29 +00:00
marko
d49217dd23 branches/zip: btr_push_update_extern_fields(): Add parameter "index"
and use it for flagging externally stored columns in the data tuple.
The data tuple contains the same columns as the clustered index record,
but in a different order.  This error was introduced in r1591.

TODO: the assertion ut_ad(!dfield_is_ext()) may fail in
btr_cur_pessimistic_update().
2007-10-16 07:25:58 +00:00
marko
22b01120b8 branches/zip: Define the macro rec_offs_init() and use it for initializing
offsets_[] arrays, as suggested by Vasil.

rec_offs_set_n_alloc(): Declare as a public function.  Assert that
n_alloc > REC_OFFS_HEADER_SIZE.

rec_offs_get_n_alloc(): Assert that n_alloc > REC_OFFS_HEADER_SIZE.
2007-09-28 07:05:57 +00:00
marko
3131340b34 branches/zip: Simplify the locking of the data dictionary.
row_upd_index_is_referenced(), row_upd_check_references_constraints(),
row_purge_parse_undo_rec(): Remove duplicated code that calls
row_mysql_unfreeze_data_dictionary().

row_undo_ins_remove_clust_rec():
Assert that the data dictionary is X-latched.  Do not attempt to re-latch
the data dictionary, because doing so introduces race conditions.  This
re-latching was probably made unnecessary already in r1676, which keeps
the data dictionary X-latched in ha_innobase::add_index() for the complete
duration of the data dictionary operations.

row_undo_ins_parse_undo_rec(): Do not attempt to acquire the data dictionary
latch.  The data dictionary should be already X-latched when a transaction
that modifies system tables is rolled back.  This also holds in the rollback
during crash recovery: trx_rollback_active() will X-latch the data dictionary
when needed.
2007-08-29 06:36:10 +00:00
marko
061b72f106 branches/zip: Add const qualifiers to the upd_t* parameters of some functions. 2007-08-20 06:59:22 +00:00
marko
7f46c9bb44 branches/zip: row_upd_sec_index_entry(): Pass foreign=TRUE to
row_ins_index_entry().  The added parameter (whether to check
foreign key constraints) was incorrectly passed as FALSE in r1591.
2007-06-21 12:22:04 +00:00
marko
5288876e23 branches/zip: Make merge sort handle externally stored columns.
Some things still fail in innodb-index.test, and there seems to be
a race condition (data dictionary lock wait) when running with --valgrind.

dfield_t: Add an "external storage" flag, dfield->ext.

dfield_is_null(), dfield_is_ext(), dfield_set_ext(), dfield_set_null():
New functions.

dfield_copy(), dfield_copy_data(): Add const qualifiers, fix in/out comments.

data_write_sql_null(): Use memset().

big_rec_field_t: Replace byte* data with const void* data.

ut_ulint_sort(): Remove.

upd_field_t: Remove extern_storage.

upd_node_t: Replace ext_vec, n_ext_vec with n_ext.

row_merge_copy_blobs(): New function.

row_ins_index_entry(): Add the parameter "ibool foreign" for suppressing
foreign key checks during fast index creation or when inserting into
secondary indexes.

btr_page_insert_fits(): Add const qualifiers.

btr_cur_add_ext(), upd_ext_vec_contains(): Remove.

dfield_print_also_hex(), dfield_print(): Replace if...else if with switch.
Observe dfield_is_ext().
2007-06-21 09:43:15 +00:00
marko
d62b28beeb branches/zip: Add some const qualifiers, mainly to upd_t*.
upd_get_n_fields(), upd_get_nth_field(): Add const qualifiers.
2007-06-19 12:44:45 +00:00
marko
750e130ce9 branches/zip: btr_cur_pessimistic_update(): Add parameter heap.
Previously, when big_rec was returned, the fields would point to
freed memory.  The memory heap was allocated locally, and the data tuple
was allocated from the heap, and the big_rec would point to some fields
in the data tuple.

row_ins_clust_index_entry_by_modify(): Add parameter heap,
for the same reason.
2007-03-28 19:35:52 +00:00
marko
54c7dd7418 branches/zip: Merge revisions 1009:1165 from trunk. 2007-01-02 14:36:59 +00:00
marko
42dcad50b8 branches/zip: Remove all references to buf_block_align() except those
from the adaptive hash index [btr_search_guess_on_hash() and
btr_search_validate()].  Some references to buf_block_align() remain
in debug builds.

btr_store_big_rec_extern_fields(): Add the parameter rec_block.

page_rec_get_next_low(): Do not assume that the page has been
allocated from the buffer pool when printing the diagnostic information.

page_cur_insert_rec_low(): Replace the parameter page_zip_des_t* page_zip
with the parameter buf_block_t* block.
2006-10-24 14:06:31 +00:00
marko
9b0a89867e branches/zip: Remove all buf_block_align() calls from lock0lock.c.
Replace all page_t* parameters with buf_block_t*, and replace many
rec_t* parameters with heap_no.  This eliminates also many
rec_get_heap_no() calls, which became more expensive with the
introduction of ROW_FORMAT=COMPACT in MySQL/InnoDB 5.0.3.

page_rec_get_heap_no(), lock_get_min_heap_no(): New functions.
2006-10-24 06:45:52 +00:00
marko
98a829723c branches/zip: Add const qualifiers to function parameters, mostly dtuple_t. 2006-10-20 08:30:07 +00:00
marko
e8a779e73e branches/zip: Remove the casts introduced in r920 and r925. Replace the
accessors returning pointers with macros that preserve const qualifiers.
In UNIV_DEBUG builds, retain the accessors and cast away constness there.

dfield_get_type(), dfield_get_data(), dtuple_get_nth_field(),
dict_table_get_nth_col(), dict_table_get_sys_col(): Implement as macro
unless #ifdef UNIV_DEBUG.

rec_get_nth_field(): Replace with rec_get_nth_field_offs() that does not
do pointer arithmetics.  Implement rec_get_nth_field() as a macro.
2006-10-19 07:27:26 +00:00
marko
c659b59a5d branches/zip: Eliminate many buf_block_align() calls.
Replace page_t* or page_zip_des_t* parameters in some functions with
buf_block_t*.

buf_frame_get_page_zip(): Disable unless #ifdef UNIV_DEBUG || UNIV_ZIP_DEBUG.

btr_cur_t: Add buf_block_t* page_block.

btr_pcur_get_block(), btr_cur_get_block(), btr_cur_get_page_zip():
New functions.

btr_cur_position(): Add the parameter block.
2006-10-18 11:39:31 +00:00
marko
6bf52fdaca branches/zip: Introduce const qualifiers to many read-only parameters
and modify some functions to return const pointers.  Add const qualifiers
to local variable declarations or casts to remove the const qualifier
in those places where write access is needed.
2006-10-17 12:24:13 +00:00
marko
11cd834bb1 branches/zip: buf_block_get_page_zip(): Replace with buf_frame_get_page_zip(). 2006-10-09 15:37:19 +00:00
marko
77ebaf6f33 branches/zip: dtuple_convert_big_rec(): Do not store anything locally
of externally stored columns, and fix bugs introduced in r873.  (Bug #22496)

btr_page_get_sure_split_rec(), btr_page_insert_fits(),
rec_get_converted_size(), rec_convert_dtuple_to_rec(),
rec_convert_dtuple_to_rec_old(), rec_convert_dtuple_to_rec_new():
Add parameters ext and n_ext.  Flag external fields during the
conversion.

rec_set_field_extern_bits(), rec_set_field_extern_bits_new(),
rec_offs_set_nth_extern(), rec_set_nth_field_extern_bit_old():
Remove.  The bits are set by rec_convert_dtuple_to_rec().

page_cur_insert_rec_low(): Remove the parameters ext and n_ext.

btr_cur_add_ext(): New utility function for updating and sorting ext[].
Low-level functions now expect the array to be in ascending order
for performance reasons.  Used in btr_cur_optimistic_insert(),
btr_cur_pessimistic_insert(), and btr_cur_pessimistic_update().

btr_cur_optimistic_insert(): Remove some defensive code, because we cannot
compute the added parameters of rec_get_converted_size().

btr_push_update_extern_fields(): Sort the array.  Require the array to
be twice the maximum usage, so that ut_ulint_sort() can be used.

dtuple_convert_big_rec(): Allocate new space for the BLOB pointer,
to avoid overwriting prefix indexes to the same column.  Adapt
dtuple_convert_back_big_rec().

row_build_index_entry(): Fetch the columns also for prefix indexes of
the clustered index.

page_zip_apply_log(), page_zip_decompress_clust(): Allow externally
stored fields to lack a locally stored part.
2006-09-29 10:40:42 +00:00
marko
83ef74df8b branches/zip: Allow the locally stored part of externally stored columns
in the clustered index to be smaller than the indexed prefix in secondary
indexes.

row_ext_lookup(): Return NULL if the column is not stored externally.

trx_undo_rec_get_partial_row(): row_build(): Add parameter row_ext_t** ext.

row_build_index_entry(): Add the parameter row_ext_t* ext.
Invoke row_ext_lookup() to fetch prefixes of externally stored columns.

upd_node_t, undo_node_t, purge_node_t: Add the field row_ext_t* ext.
2006-09-26 11:50:54 +00:00
marko
ee923f5cbe branches/zip: Minor cleanup in update related code.
btr_push_update_extern_fields(): Instead of iterating all upd_get_n_fields(),
stop at the first match.

row_search_index_entry(): Simplify the return statements.

row_upd_sec_step(): Eliminate the local variable "err".

row_upd_clust_step(): Add a UNIV_UNLIKELY hint.
2006-09-25 12:17:33 +00:00
marko
35905f6266 branches/zip: Merge revisions 838:861 from trunk. 2006-09-22 10:22:03 +00:00
marko
9a16aac783 branches/zip: Merge revisions 804:838 from trunk. 2006-09-19 10:14:07 +00:00
marko
64f3cee67f branches/zip: Merge revisions 720:765 from trunk and reindent the code
as per revisions r763:765.
2006-08-29 09:30:31 +00:00
marko
5e0d677f0b branches/zip: Minor cleanup.
row_upd_sec_index_entry(): Remove redundant goto.  Replace duplicated
cleanup code with goto func_exit.

mtr_memo_slot_release(): Eliminate the #else branch of #ifdef UNIV_DEBUG
by reorganizing the code.
2006-08-07 08:12:39 +00:00
marko
645e56909f branches/zip: Merge revisions 583:634 from trunk. 2006-06-13 20:23:26 +00:00
marko
cfc945a954 branches/zip: Merge revisions 465:532 from trunk. 2006-05-08 06:18:59 +00:00
marko
450bbd7c3b branches/zip: Merge revisions 265:459 from trunk. 2006-04-12 09:32:17 +00:00
marko
df85f7287c branches/zip: Minor fixes
trx-undo_prev_version_build(): Pass offsets==NULL to
rec_set_field_extern_bits().

rec_set_field_extern_bits(), rec_set_field_extern_bits_new():
Accept offsets==NULL.

row_upd_rec_in_place(): Remove the bogus comment that the function
would only be invoked on a clustered index.  Remove the related
debug assertion.
2006-03-16 09:44:52 +00:00
marko
77aba5109d branches/zip: Implement in-place updates of BLOB pointers.
There are still some bugs in the code.

btr_store_big_rec_extern_fields(): Remove assertion on dict_table_is_zip()
to ease testing.

btr_free_externally_stored_field(): Test page_zip instead of
dict_table_is_zip().

page_zip_write_rec(): Add parameter "create".  Try to handle externally
stored columns.

rec_offs_any_extern(): Correct the function comment.

Add rec_offs_n_extern() and page_zip_get_n_prev_extern().

page_zip_dir_decode(): Replace assertion with if (...) return(FALSE).

page_zip_decompress(): Do not clear page_zip->n_blobs after counting the
BLOBs.

page_zip_write_blob_ptr(): Use page_zip_get_n_prev_extern().
Correct an off-by-one error in memcpy().
2006-03-13 15:02:16 +00:00
marko
0a6fe54501 branches/zip: Minor improvements.
btr_cur_pessimistic_update(): Remove extraneous page_zip_write_rec() call.

btr_cur_set_ownership_of_extern_field(): Simplify the logic.

row_upd_rec_in_place(): Make use of parameter "index" in debug assertions.

page_zip_write_rec(): Remove TODO comment about redo log record.
The write will already be covered by higher-level log entries.
2006-03-13 07:42:31 +00:00
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
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
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
6ce8427cb8 branches/zip: Merge revisions 79:200 from trunk. 2006-02-17 14:19:39 +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
42875604eb branches/zip: Remember to update page_zip when updating "extern" flags.
Add function parameters and TODO comments regarding that.
2005-11-18 07:40:34 +00:00
marko
88e6d6863d branches/zip:
Initial import of the zip-like compression of B-tree pages.
2005-10-27 11:48:10 +00:00
osku
c307820962 Import 5.0 code. 2005-10-27 07:29:40 +00:00