Commit graph

219 commits

Author SHA1 Message Date
marko
2c4aaa9ec6 branches/zip: Minor cleanup.
row_create_index_graph_for_mysql(): Move from row0mysql.c to row0merge.c
and rename to row_merge_create_index_graph().  Also change the function
comment to say that the function will create and execute the query graph
for creating the index.

row_merge_create_index(): Remove redundant assignment to trx->error_state.
2007-12-19 15:05:13 +00:00
marko
9120973f56 branches/zip: row_merge_lock_table(): Set a more informative trx->op_info. 2007-12-17 20:51:34 +00:00
marko
71a4f691b2 branches/zip: Fast index creation: Remove the ROW_PREBUILT_OBSOLETE nonsense.
Active transactions must not switch table or index definitions on the fly,
for several reasons, including the following:

 * copied indexes do not carry any history or locking information;
   that is, rollbacks, read views, and record locking would be broken

 * huge potential for race conditions, inconsistent reads and writes,
   loss of data, and corruption

Instead of trying to track down if the table was changed during a transaction,
acquire appropriate locks that protect the creation and dropping of indexes.

innodb-index.test: Test the locking of CREATE INDEX and DROP INDEX.  Test
that consistent reads work across dropped indexes.

lock_rec_insert_check_and_lock(): Relax the lock_table_has() assertion.
When inserting a record into an index, the table must be at least IX-locked.
However, when an index is being created, an IS-lock on the table is
sufficient.

row_merge_lock_table(): Add the parameter enum lock_mode mode, which must
be LOCK_X or LOCK_S.

row_merge_drop_table(): Assert that n_mysql_handles_opened == 0.
Unconditionally drop the table.

ha_innobase::add_index(): Acquire an X or S lock on the table, as appropriate.
After acquiring an X lock, assert that n_mysql_handles_opened == 1.
Remove the comments about dropping tables in the background.

ha_innobase::final_drop_index(): Acquire an X lock on the table.

dict_table_t: Remove version_number, to_be_dropped, and prebuilts.
ins_node_t: Remove table_version_number.

enum lock_mode: Move the definition from lock0lock.h to lock0types.h.

ROW_PREBUILT_OBSOLETE, row_update_prebuilt(), row_prebuilt_table_obsolete():
Remove.

row_prebuilt_t: Remove the declaration from row0types.h.

row_drop_table_for_mysql_no_commit(): Always print a warning if a table
was added to the background drop queue.
2007-12-17 15:49:59 +00:00
marko
7c5511ef98 branches/zip: dict_table_copy_types(): Initialize all fields to the SQL NULL
value.  Document this change in behaviour, and make all callers invoke
the function right after dtuple_create().

dict_create_sys_fields_tuple(): Add a missing "break" statement to the loop
that checks if there are any column prefixes in the index.

row_get_prebuilt_insert_row(): Do not set the fields to the SQL NULL value,
now that dict_table_copy_types() takes care of it.
2007-12-07 09:12:57 +00:00
marko
a65020d27f branches/zip: When logging updates or deletes in the undo log, store long
enough prefixes of externally stored columns, so that purge will not have
to dereference any BLOB pointers, which may be invalid.  This will not be
necessary for logging inserts, because inserts are no-ops in purge, and
the record will remain locked during transaction rollback.

TODO: in dict_build_table_def_step() or dict_build_index_def_step(),
prevent the creation of tables with too many columns for which a
prefix index is defined.  This is because there is a size limit of undo
log records, and for each prefix-indexed column, the log must store
REC_MAX_INDEX_COL_LEN + BTR_EXTERN_FIELD_REF_SIZE bytes.

trx_undo_page_report_insert(): Assert that the index is clustered.

trx_undo_page_fetch_ext(): New function, for fetching the BLOB prefix
in trx_undo_page_report_modify().

trx_undo_page_report_modify(): Write long enough prefixes of the externally
stored columns to the undo log.

trx_undo_rec_get_partial_row(): Remove the parameter "ext".  Assert that
the undo log contains long enough prefixes of the externally stored columns.

purge_node_t: Remove the field "ext".
2007-12-05 14:10:15 +00:00
marko
3044ef3523 branches/zip: row_build_index_entry(): Add assertions that prevent improper
prefix indexes from being built on externally stored columns.
2007-12-05 13:26:06 +00:00
marko
3978843916 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
771ed4070c branches/zip: row_ext_cache_fill(): Add a missing "else" that should have
been added in r2131.
2007-11-30 15:32:36 +00:00
marko
44387227d7 branches/zip: row_ext_cache_fill(): Add an assertion that some BLOB data
was actually fetched.  ext->len[i] == 0 is reserved to mean an uninitialized
BLOB pointer.
2007-11-30 08:48:36 +00:00
marko
5784e7debb branches/zip: row_ext_create(): Remove unused variables that were added
in r2131.
2007-11-29 12:54:43 +00:00
marko
603defd2de branches/zip: row_ext_create(): Remove the UNIV_INLINE that should
have been removed in r2131.
2007-11-29 12:52:49 +00:00
marko
8fb8584e75 branches/zip: row_ext: Fetch the BLOB prefixes already at row_ext_create().
Only add indexed BLOBs to row_ext.

trx_undo_rec_get_partial_row(): Move the BLOB fetching to row_ext_create().

row_build(): Pass only those BLOBs to row_ext_create() that are referenced by
ordering columns of some indexes, similar to trx_undo_rec_get_partial_row().

row_ext_create(): Add the parameter "tuple".  Move the implementation
from row0ext.ic to row0ext.c.

row_ext_lookup_ith(), row_ext_lookup(): Return a const pointer.  Remove
the parameters "field" and "f_len".  Make the row_ext_t* parameter const.

row_ext_t: Remove the field zip_size.

field_ref_zero[]: Declare in btr0types.h instead of btr0cur.h.

row_ext_lookup_low(): Rename to row_ext_cache_fill() and change the
signature.
2007-11-29 12:47:18 +00:00
marko
dae1fdd6b9 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
15d8cc6e64 branches/zip: row_vers_impl_x_locked_off_kernel(): In follow-up to r2119,
assert ut_a(entry) instead of playing it safe.
2007-11-28 13:09:50 +00:00
marko
06299dddd4 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
30358fe698 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
36874d65f0 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
e95893151b branches/zip: Merge 2015:2093 from trunk. 2007-11-16 13:57:27 +00:00
marko
23d99475e0 branches/zip: row_insert_for_mysql(), row_update_for_mysql(),
row_prebuilt_free(): Add UNIV_UNLIKELY hints around tests for
ROW_PREBUILT_OBSOLETE and some other tests.
2007-11-07 13:52:52 +00:00
vasil
f0e3f1f3fe branches/zip:
Bugfix: In row_raw_format() - fix the return value when printing in
hex; do not forget to count the 2 extra characters "0x" that we wrote
at the beginning of the output.
2007-11-06 16:39:51 +00:00
marko
1bfa27fb91 branches/zip: Remove warnings for BUILD/compile-... --warning-mode=pedantic.
ha_innobase::write_row(): The printf format %p expects const void*.

STRUCT_FLD: Do not use the GCC extension when __STRICT_ANSI__ is defined.

row_merge_read_clustered_index(): Compound initializers must not contain
variables.  Assign to struct fields instead.
2007-11-01 11:44:49 +00:00
marko
b1d3192f45 branches/zip: row_merge_drop_temp_indexes(): Use COMMIT WORK instead of
trx_commit_for_mysql().
2007-10-29 15:25:46 +00:00
vasil
0028e8d1ee branches/zip:
Add innodb_locks.lock_data column and some relevant tests.
For record locks this column represents the ordering fields of the
locked row in a human readable, SQL-valid, format.

Approved by:	Marko
2007-10-29 13:03:53 +00:00
vasil
806d940575 branches/zip:
Change mach_read_int_type() to return an integer type (ullint) instead
of array of bytes that later needs to be converted to an appropriate
integer type.

Approved by:	Sunny
2007-10-25 11:45:11 +00:00
marko
0d6bfafd6c branches/zip: Merge 1937:2015 from trunk. 2007-10-24 10:59:54 +00:00
marko
7ebd4af72f branches/zip: row_build_index_entry(): Correct a typo made in r2012. 2007-10-24 06:59:01 +00:00
marko
996edd8a91 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
1033dbfb60 branches/zip: row_rec_to_index_entry_low(): Remove a bogus assertion. 2007-10-22 10:23:13 +00:00
marko
1a1c987ba5 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
5e9ec7afb6 branches/zip: When seeking to a different B-tree page, update the cached
value of the block that the cursor points to.

row_ins_check_foreign_constraint(): Call btr_pcur_get_block() after
row_ins_foreign_check_on_constraint(), as it may reposition the cursor
on a different page.

row_ins_scan_sec_index_for_duplicate(): Call btr_pcur_get_block() on
every iteration of the loop.  Use do ... while instead of for (;;).
2007-10-22 08:34:12 +00:00
marko
cd12974298 branches/zip: Minor cleanup of B-tree cursor operations.
btr_pcur_get_rel_pos(): Add a const qualifier.

btr_pcur_get_btr_cur(), btr_pcur_get_page_cur(): btr_cur_get_page_cur():
Define as const-preserving macros.

btr_pcur_is_on_user_rec(), btr_pcur_is_after_last_on_page(),
btr_pcur_is_before_first_on_page(): Remove the unused parameter mtr.
Add a const qualifier.

btr_pcur_move_to_next_on_page(), btr_pcur_move_to_prev_on_page():
Remove the unused parameter mtr.

page_cur_search(): Add const qualifiers.

page_cur_get_page(), page_cur_is_before_first(), page_cur_is_after_last():
Add debug assertions.
2007-10-22 08:16:35 +00:00
marko
3980b139e0 branches/zip: Introduce two new dictionary operation modes for transactions.
enum trx_dict_op: dictionary operation modes

trx_get_dict_operation(), trx_set_dict_operation(): Accessors for
trx->dict_operation.

lock_table_enqueue_waiting(), lock_rec_enqueue_waiting(): Do not complain
about lock waits if the dictionary mode is TRX_DICT_OP_INDEX_MAY_WAIT.

row_merge_lock_table(): Remove the work-around for avoiding the warning
in lock_table_enqueue_waiting().

trx_undo_mark_as_dict_operation(): Do not write trx->table_id to the
undo log unless the dict_operation is TRX_DICT_OP_TABLE.

ha_innobase::add_index(): Set the dict_operation mode initially to
TRX_DICT_OP_INDEX_MAY_WAIT, then lock the table exclusively, and set the
mode to TRX_DICT_OP_INDEX, and optionally to TRX_DICT_OP_TABLE when
creating a temporary table.
2007-10-19 10:52:25 +00:00
marko
93157fcd32 branches/zip: row_merge_lock_table(): Clear the trx->dict_operation flag
for the duration of the lock_table() call in order to avoid a bogus warning.
2007-10-18 09:18:18 +00:00
marko
65d4e6308e branches/zip: Remove const warnings reported by GCC 4.2.1.
page_cur_set_before_first(), page_cur_set_after_last(),
page_cur_position(): Add const qualifiers to buf_block_t and rec.
A better solution would be to define a const_page_cur_t and a
set of accessors, but it would lead to severe code duplication.

page_rec_get_n_recs_before(): Add const qualifiers.

page_dir_get_nth_slot(): Define as a const-preserving macro.

page_dir_slot_get_rec(), page_dir_slot_get_n_owned(),
page_dir_find_owner_slot(), page_check_dir(): Add const qualifiers.

page_rec_get_next_low(): Add const qualifiers.

page_rec_get_next_const(), page_rec_get_prev_const(): New functions,
based on the const-less page_rec_get_next() and page_rec_get_prev().

page_cur_get_page(), page_cur_get_block(), page_cur_get_page_zip(),
page_cur_get_rec(): Define as const-preserving macros.

page_cur_try_search_shortcut(), page_cur_search_with_match():
Add const qualifiers.

buf_page_get_mutex(): Add a const qualifier to buf_page_t*.

rec_get_next_ptr_const(): Const variant of rec_get_next_ptr().
2007-10-18 07:12:05 +00:00
marko
aea22cad48 branches/zip: row_scan_and_check_index(): Remove the compiler warning
that tmp_heap is possibly uninitialized.  This was introduced in r1990.
2007-10-17 12:19:35 +00:00
marko
e7267909d7 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
c6f5ea288a 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
9364a4daf6 branches/zip: row_ins_foreign_report_add_err(): Note that the dtuple_print()
call may display uninitialized values of DB_TRX_ID and DB_ROLL_PTR.
2007-10-10 11:39:26 +00:00
marko
f3d0ad8160 branches/zip: Use static linkage for row_ins(). 2007-10-05 06:23:37 +00:00
marko
3877f6910f 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
a1e57e698b branches/zip: Merge 1862:1894 from trunk, except 1866. 2007-09-27 11:17:45 +00:00
marko
55f4395272 branches/zip: row_mysql_store_blob_ref(): Change the type of the parameter
"data" from byte* to const void*.
2007-09-27 10:59:54 +00:00
marko
df88e3c988 branches/zip: row_sel_field_store_in_mysql_format(): Replace
if-else with switch.
2007-09-27 09:05:05 +00:00
marko
2de2d45fdf branches/zip: Remove the unused variable row_mysql_identically_false. 2007-09-27 08:56:33 +00:00
marko
028d25db86 branches/zip: Simplify the reporting of duplicate key values.
Since r1905, innobase_rec_to_mysql() does not require a clustered index record.

row_merge_dup_t: Remove old_table.

row_merge_dup_report(): Do not fetch the clustered index record.  Simply
convert the tuple by innobase_rec_to_mysql().

row_merge_blocks(), row_merge(), row_merge_sort(): Add a TABLE* parameter
for reporting duplicate key values during file sort.

row_merge_read_clustered_index(): Replace UNIV_PAGE_SIZE with the more
appropriate sizeof(mrec_buf_t).
2007-09-27 08:28:25 +00:00
marko
e25d62f27a branches/zip: Double the size of mrec_buf_t to UNIV_PAGE_SIZE.
This should have been done in r1903, where the minimum size of
row_merge_block_t was noted to be UNIV_PAGE_SIZE.
2007-09-27 06:13:33 +00:00
marko
51436aa102 branches/zip: Document the minimum size of row_merge_block_t as UNIV_PAGE_SIZE.
row_merge_buf_add(): Add ut_ad(data_size < sizeof(row_merge_block_t))
and document why it may fail if sizeof row_merge_block_t < UNIV_PAGE_SIZE.
2007-09-26 13:52:08 +00:00
marko
c6d6f1fa8b branches/zip: row_merge_build_indexes(): Call innobase_rec_reset() only once.
row_merge_dup_report(): Do not call innobase_rec_reset().
2007-09-26 13:47:32 +00:00
marko
34ab0c0523 branches/zip: Implement the reporting of duplicate key values to MySQL.
innobase_rec_to_mysql(): New function, for converting an InnoDB clustered
index record to MySQL table->record[0].  TODO: convert integer fields.
Currently, integer fields are in big-endian byte order instead of
host byte order, and signed integer fields are offset by 0x80000000.

innobase_rec_reset(): New function, for resetting table->record[0].

row_merge_build_indexes(): Add the parameter TABLE* table (the MySQL table
handle) for reporting duplicate key values.

dtuple_from_fields(): New function, to convert an array of dfield_t* to
dtuple_t.

dtuple_get_n_ext(): New function, to compute the number of externally stored
fields.

row_merge_dup_t: Structure for counting and reporting duplicate records.

row_merge_dup_report(): Function for counting and reporting duplicate records.

row_merge_tuple_cmp(), row_merge_tuple_sort(): Replace the ulint* n_dup
parameter with row_merge_dup_t* dup.

row_merge_buf_sort(): Add the parameter row_merge_dup_t* dup, which is
NULL when sorting a non-unique index.

row_merge_buf_write(), row_merge_heap_create(), row_merge_read_rec(),
row_merge_cmp(), row_merge_read_clustered_index(), row_merge_blocks(),
row_merge(), row_merge_sort(): Add const qualifiers.

row_merge_read_clustered_index(): Use a common error handling branch err_exit.
Invoke row_merge_buf_sort() differently on unique indexes.

row_merge_blocks(): note TODO: We could invoke innobase_rec_to_mysql()
to report duplicate key values when creating a clustered index.
2007-09-26 11:56:26 +00:00
marko
3ad7bd739d branches/zip: Add some const qualifiers to input parameters.
rec_get_converted_size_comp(), rec_convert_dtuple_to_rec_comp(),
rec_convert_dtuple_to_rec_new(), rec_convert_dtuple_to_rec(): Add a
const qualifier to dict_index_t*.

row_search_on_row_ref(): Add const qualifiers to the dict_table_t*
and dtuple_t* parameters.  Note that pcur is an "out" parameter
and mtr is "in/out".
2007-09-26 09:12:23 +00:00