Commit graph

72 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
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
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
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
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
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
2de2d45fdf branches/zip: Remove the unused variable row_mysql_identically_false. 2007-09-27 08:56:33 +00:00
marko
5f3faa0991 branches/zip: Minor cleanup.
row_add_table_to_background_drop_list(): Replace the dict_table_t*
parameter with const char* (the table name).

row_check_table_for_mysql(): Replace prebuilt->table with table.
2007-09-11 05:09:19 +00:00
marko
84ff578142 branches/zip: Simplify crash recovery in fast index creation.
trx_t: Remove dict_undo_list and dict_redo_list.

innobase_create_temporary_tablename(): Replace TEMP_TABLE_PREFIX with
a table name suffix "#1" or "#2".  In this way, the user can restore
precious data, should anything go wrong.  It is possible to reach an
inconsistent state, because the creation, deletion and renaming of
single-table tablespaces are not transactional.

ut_print_namel(), fil_make_ibd_name(), innobase_rename_table(): Remove
the special treatment of TEMP_TABLE_PREFIX.

Introduce TEMP_INDEX_PREFIX == 0xff for temporary indexes.  This byte
cannot occur in index names since MySQL 4.1.  However, it might have
been possible to use this byte in MySQL 4.0.

recv_recovery_from_checkpoint_finish(): Call the new function
row_merge_drop_temp_indexes(), to drop all indexes whose name starts
with the byte 0xff.

row_merge_rename_indexes(): Renamed from row_merge_rename_index().
Remove the parameter "index".

row_drop_table_for_mysql(): Unconditionally call trx_commit_for_mysql().

row_drop_table_for_mysql_no_commit(): Correct the function commit,
based on the corrected comment of row_drop_table_for_mysql().  Rely on
table->to_be_dropped instead of TEMP_TABLE_PREFIX.

ha_innobase::add_index(): Simplify the control flow.
2007-09-05 10:18:03 +00:00
marko
140a706079 branches/zip: Merge 1783:1792 from trunk. 2007-09-03 08:44:39 +00:00
marko
31d63cd08f branches/zip: Merge 1664:1783 from trunk. 2007-08-30 09:21:25 +00:00
marko
c13f191357 branches/zip: Remove some checks if an index or a table is a temporary one
created in fast index creation.

dict_load_indexes(): Always complain if the first index is not clustered.

lock_table_enqueue_waiting(): Always complain about lock waits in
a dictionary operation.

row_merge_rename_tables(): Add an assertion that dict_sys->mutex is
being held.

row_undo_mod_del_unmark_sec_and_undo_update(): Make the test about
temporary indexes more readable.

row_create_table_for_mysql(): Do not retry creating a temporary table
in fast index creation.  Orphaned temporary tables will have to be dropped
in crash recovery.
2007-08-29 08:45:34 +00:00
marko
7274fd95af branches/zip: Fix a memory leak in fast index creation.
ha_innobase::add_index(): Add assertions about !trx->sync_cb and
!trx->dict_redo_list.  Remove a bogus comment.  Replace
row_lock_table_for_merge() with row_merge_lock_table().

row_merge_lock_table(): Renamed from row_lock_table_for_merge()
and moved from row0mysql.c to row0merge.c.  Always lock the table in
the mode LOCK_X.  Call que_graph_free() in order not to leak memory.
2007-08-21 12:10:14 +00:00
marko
fc02084a69 branches/zip: row_rename_table_for_mysql(): Rely on the diagnostic
printout of dict_table_rename_in_cache().  Correct the comment about
the SQL parser.  This function does not drop any table.
2007-08-20 09:45:27 +00:00
marko
8634d343f7 branches/zip: Rename mem_heap_calloc() and mem_calloc() to
mem_heap_zalloc() and mem_zalloc(), because calloc() in the C runtime
library takes two size parameters, not one.

mem_heap_zalloc(): Add debug assertions.  Document that the return value
is never NULL.
2007-08-16 13:25:56 +00:00
marko
dddb659202 branches/zip: row_mysql_handle_errors(): Replace the if-else with
switch-case.
2007-08-15 15:35:48 +00:00
marko
b008bc09a7 branches/zip: Fix two mistakes made in r1414
(merging branches/fast-index-creation):

row_truncate_table_for_mysql(), row_drop_table_for_mysql_no_commit():
Let ut_print_name() output to ef instead of stderr.
2007-08-13 17:15:31 +00:00
marko
e0009cd4db branches/zip: Add some const qualifiers to dict_index_t* and dict_table_t*.
innobase_create_key_def(), row_table_got_default_clust_index(),
row_get_mysql_key_number_for_index(): Add a const qualifier.

dict_table_get_first_index(), dict_table_get_next_index(): Define
as a const-preserving macro.  Preserve the old function for UNIV_DEBUG,
but add a const qualifier to the parameter and cast away the constness.
2007-08-13 15:57:28 +00:00
marko
f68d3656dc branches/zip: Use mem_calloc and mem_heap_calloc when possible.
row_ext_create(): After a memset() inside UNIV_DEBUG, flag the memory
uninitialized with UNIV_MEM_ALLOC().
2007-08-13 14:07:59 +00:00
marko
d9db67696e branches/zip: row_rename_table_for_mysql(): Change the return type to ulint
and simplify error handling.
2007-08-13 12:46:13 +00:00
marko
dcd1b3cbef branches/zip: Fix errors made in r1672. 2007-08-03 07:35:05 +00:00
marko
c99c5c240a branches/zip: Add const qualifiers to the functions that read MySQL data.
row_mysql_read_true_varchar(), row_mysql_read_blob_ref(),
row_mysql_store_col_in_innobase_format(),
row_sel_convert_mysql_key_to_innobase(): Add const qualifiers.

row_sel_convert_mysql_key_to_innobase(): Document that the first parameter
is in/out.
2007-08-03 07:09:29 +00:00
marko
60c44c3a5f branches/zip: Ensure that the dictionary updates are atomic by keeping
the data dictionary locked across the operations.

dict_table_decrement_handle_count(), row_prebuilt_free(): Add the flag
dict_locked, to prevent the acquisition of dict_sys->mutex.

innobase_rename_table(): Rename commit_flag to lock_and_commit,
and do not acquire dict_sys->mutex or flush the log unless the flag is set.
Remove bogus comment about utility threads, because the threads will
be waken up by the upper-level function ha_innobase::rename_table().

ha_innobase::add_index(): After creating a primary key, hold dict_sys->mutex
across all dictionary operations.
2007-08-02 10:55:25 +00:00
marko
0a780db994 branches/zip: Merge 1575:1664 from trunk. 2007-08-01 11:18:43 +00:00
marko
02e0334ed6 branches/zip: row_prebuilt_free(), row_drop_tables_for_mysql_in_background():
Fix some printouts.
2007-06-21 13:25:03 +00:00
marko
632ec54002 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
b864484fb2 branches/zip: Remove reads of freed memory in fast index creation.
Because row_drop_table_for_mysql_no_commit() checks with dict_load_table()
if the table was successfully dropped, we cannot pass table->name to it.

row_merge_drop_table(): Pass a copy of table->name to
row_drop_table_for_mysql().

row_prebuilt_free(): Do not dereference prebuilt->table->name after a
successful invocation of row_add_table_to_background_drop_list().  The
table object may be freed at any time.  Remove the debug message
"Dropping table".
2007-06-13 13:40:29 +00:00
marko
a8a3521b09 branches/zip: Merge 1556:1571 from trunk. 2007-06-12 10:59:01 +00:00
marko
ae0ae671da branches/zip: Correctly print the names of temporary tables and indexes
during fast index creation.

TEMP_TABLE_PREFIX: Move the definition from dict0dict.h to ut0ut.h.

ut_print_namel(): Check if the name starts with TEMP_TABLE_PREFIX.

innobase_rename_table(): Print all names with ut_print_name().

row_prebuilt_free(): Replace assert() with ut_a().
2007-06-12 07:06:36 +00:00
marko
99efc2aeff branches/zip: Initialize some uninitialized variables in order to avoid
comparing uninitialized values.

dict_mem_table_create(): Initialize table->version_number.

ins_node_create(): Initialize node->table_version_number.

row_create_prebuilt(): Initialize all fields.  Initialize most fields
by memset(), so that any fields that are added will be initialized
automatically.
2007-06-11 14:39:04 +00:00
marko
1a8a63d0cd branches/zip: Reimplement merge sort in fast index creation.
The creation of the primary key does not work.  We will have to flag
externally stored columns and copy the externally stored part from
the old table.

row_build_index_for_mysql(): Rename to row_merge_build_indexes().
Move from row0mysql.c to row0merge.c.

Remove private declarations from row0merge.h.  Make many functions static
in row0merge.c.

cmp_rec_rec_simple(): A new comparison function.

dict_index_get_min_size(): New function.

OS_FILE_FROM_FD(fd): A macro for converting from int to os_file_t.

rec_convert_dtuple_to_rec_comp(): Make the interface lower-level.

rec_get_converted_size_comp(): Return also extra_size.

UT_SORT_FUNCTION_BODY(): Remove reference to an obsolete test program.

row_rec_to_index_entry_low(): New function.

row0merge.c: Implement merge sort based on file streams instead of
fixed-size blocks.  Sort the small blocks as arrays of dfield_t*,
because it is faster than invoking rec_get_offsets() for every
comparison.
2007-06-08 07:37:07 +00:00
marko
b2c09f8a34 branches/zip: Minor cleanup.
row_merge_mark_prebuilt_obsolete(): Rename to row_prebuilt_table_obsolete()
and move from row0merge.c to row0mysql.c.  Remove the parameter trx.

row_merge_print_table(): Remove.
2007-06-04 07:51:10 +00:00
marko
eddd2aed6a branches/zip: Minor cleanup.
row_remove_indexes_for_mysql(): Rename to row_merge_drop_indexes(),
move from row0mysql.c to row0merge.c and make the return type void.

row_merge_remove_index(): Rename to row_merge_drop_index() and make
the return type void.
2007-06-04 07:49:31 +00:00
marko
ad0a869520 branches/zip: Correct the terminology: s/cluster index/clustered index/.
row_merge_read_clustered_index(): Simplify the loop that scans the
clustered index.
2007-05-22 06:48:53 +00:00
marko
88df83bb3b branches/zip: Merge revisions 1402:1493 from trunk.
Remove mysql.patch, because the configuration parameter interface has changed.
2007-05-14 09:07:15 +00:00
marko
a294481681 branches/zip: Make use of the function dict_index_is_unique(). 2007-04-16 09:21:39 +00:00
marko
7dd753edd8 branches/zip: Minor cleanup of merge_file_t and merge_block_header_t.
Replace byte offsets of type dulint with block offsets of type ulint.
Avoid references to MERGE_BLOCK_SIZE.

Improve the language of some comments.

row_merge_insert_index_tuples(), row_merge_sort_linked_list_in_disk():
Make the offset a ulint.

row_merge_read(), row_merge_write(): Helper functions.  Return the
status of os_file_read() and os_file_write().  TO DO: check the status
in the callers.
2007-04-12 10:32:16 +00:00
marko
5378db6e10 branches/zip: More cleanup of fast index creation.
innobase_create_temporary_tablename(): Add static qualifier.  Allocate
the memory from heap.  Return a fixed identifier.

ha_innobase::add_index(): Allocate all memory from a single heap.
Simplify error handling.  Use a fixed prefix for temporary table names,
because only one add_index() can be active for a given table.

mem_heap_empty_noninline(): New function, to be called from ha_innodb.cc.

row_build_index_for_mysql(): Remove the parameter new_primary.
2007-04-12 05:14:41 +00:00
marko
d33e525a08 branches/zip: Initial clean up of the merge sort subsystem.
Define the merge_rec_ structures in row0merge.c instead of
row0merge.h.  They are not used in the interface defined in row0merge.h.

row_merge_create_file_structure(): Rename to row_merge_file_create().
Input a pointer to a pre-allocated block of memory.

row_merge_read_clustered_index(): Replace merge_file_t** with merge_file_t*.

row_merge_sort_and_insert_thread(): Remove the declaration.
This function was never defined or called.

row_merge_is_index_usable(): Correct the formatting.

row_build_index_for_mysql(): Allocate an array of merge_file_t instead
of an array of pointers to merge_file_t.
2007-04-11 08:16:14 +00:00
marko
fc65b08f53 branches/zip: Merge branches/fast-index-creation -r1413.
Fix some bugs.  The tests innodb and innodb-index fail, but that might
be due to an old MySQL source tree being used.
2007-04-04 11:05:33 +00:00
marko
4d6805f2a8 branches/zip: Merge revisions 1322:1402 from trunk. 2007-04-02 05:39:41 +00:00
marko
d753d3e83c branches/zip: Make TRUNCATE TABLE recreate single-table tablespaces.
dict_truncate_index_tree(): Add the parameter space for specifying the
new tablespace identifier of a single-table tablespace that has been
recreated.  When SYS_INDEXES.PAGE_NO == FIL_NULL, do not abort but
create the index tree.

fil_discard_tablespace(): Pass the return code from fil_delete_tablespace().

row_truncate_table_for_mysql(): Attempt to discard and recreate
single-table tablespaces.  Reassign the tablespace identifier both in
the data dictionary (SYS_TABLES and SYS_INDEXES) and in the data
dictionary cache.
2007-03-29 08:51:13 +00:00
marko
5fc003b65d branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. 2007-01-18 18:29:12 +00:00
marko
8f65d7a661 branches/zip: Merge revisions 1165:1206 from trunk. 2007-01-18 12:58:39 +00:00
marko
229d901921 branches/zip: Fix compilation errors when UNIV_HOTBACKUP is defined. 2006-11-30 15:25:52 +00:00