* Change terminology:
wait lock -> requested lock
waited lock -> blocking lock
new: requesting transaction (the trx what owns the requested lock)
new: blocking transaction (the trx that owns the blocking lock)
* Add transaction ids to INFORMATION_SCHEMA.INNODB_LOCK_WAITS. This is
somewhat redundant because transaction ids can be found in INNODB_LOCKS
(which can be joined with INNODB_LOCK_WAITS) but would help users to
write shorter joins (one table less) in some cases where they want to
find which transaction is blocking which.
Suggested by: Ken
Approved by: Heikki
for dropping the index trees, and set the dictionary operation flag, similar
to what ha_innobase::add_index() does. This should ensure correct crash
recovery.
Fix the size of the static buffer for lock_table and lock_index.
I was not realizing that NAME_LEN contains the mbmaxlen multiplier and thus
a quote, when converted to 2 quotes, will take 2 bytes while there are 3
bytes reserved.
Spotted by: Marko
Pointyhat to: Vasil
Bugfix1: Set innodb_locks.lock_index to NOT NULL.
If a column in INFORMATION_SCHEMA table has the flag
MY_I_S_MAYBE_NULL and it is not explicitly marked as NOT NULL
with the method ::set_notnull() then it is always rendered as
NULL by MySQL.
Bugfix2: Avoid crashes if lock_index is NULL. It is NULL for table
level locks.
Pointyhat to: Marko
innodb_information_schema.test. Add tests that display most columns from
INFORMATION_SCHEMA.INNODB_LOCKS. Test that quoting of table names works
and respects SQL_MODE='ANSI_QUOTES'.
innobase_print_identifier(): Remove.
innobase_convert_identifier(): New function,
based on innobase_print_identifier().
innobase_convert_name(): New function, similar to ut_print_namel(), but
using a memory buffer.
ut_print_namel(): Use innobase_convert_name().
fill_innodb_locks_from_cache(): Convert lock_table and lock_index by
calling innobase_convert_name().
Implement a limit on the memory used by the INNODB_TRX, INNODB_LOCKS and
INNODB_LOCK_WAITS tables. The maximum allowed memory is defined with the
macro TRX_I_S_MEM_LIMIT.
Approved by: Marko (via IM)
Add the query in information_schema.innodb_trx.trx_query. Add it even
though it is available in information_schema.processlist.info to make
inconsistencies between those two tables obvious.
It is rather confusting to see a transaction shown in innodb_trx and
innodb_locks that holds a lock on one table and the corresponding query
in processlist executing INSERT on another table. We do not want users
to contact us asking to explain that. It is caused by the fact that the
data for innodb_* tables and processlist is fetched at different time.
Approved by: Marko
Introduce a generic soultion to the common problem that MySQL do not add
functions needed by us in a reasonable time.
Start with a function that retrieves THD::thread_id, this is needed for
the information_schema.innodb_trx.mysql_thread_id column.
Approved by: Marko
a compressed table in the system tablespace.
db0err.h: Introduce the error code DB_TABLE_ZIP_NO_IBD. Replace the
#define directives with an enum, to ease future code merges. These
error codes are never written out to files or displayed to the user.
Thus they need not remain constant.
dict_build_table_def_step(): Return DB_TABLE_ZIP_NO_IBD instead of DB_ERROR.
create_table_def(): Report ER_ILLEGAL_HA_CREATE_OPTION "KEY_BLOCK_SIZE"
when the table creation fails with DB_TABLE_ZIP_NO_IBD.
redefined so that the dynamic plugin can replace the builtin InnoDB
in MySQL 5.1.
ha_innodb.cc, handler0alter.cc: #include "univ.i" before any other InnoDB
header files or before defining any symbols
innodb_redefine.h: New file, to contain a mapping of symbols. The idea
is that this file will be replaced in the build process; because this
is a large file that can be generated automatically, it does not make sense
to keep it under version control.
univ.i: #include "innodb_redefine.h" and #define ha_innobase ha_innodb
Makefile.am (ha_innodb_la_CXXFLAGS): Remove -Dha_innobase=ha_innodb
NOTE: there are still some issues in the source code. One known issue is
the #undef mutex_free in sync0sync.h, which will cause the plugin to call the
function mutex_free in the builtin InnoDB. The preprocessor symbols defined
in innodb_redefine.h must not be undefined or redefined anywhere in the code.
plugin "InnoDB", not "InnoDBzip".
We can disable the builtin InnoDB by mysqld --skip-innodb. If the
builtin InnoDB is not disabled, installing the InnoDB plugin by the same
name will not work.
innodb_plugin_init(): Ignore differences in the PLUGIN_VAR_READONLY flag.
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.
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
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.
to replace a built-in instance of InnoDB in mysqld. This is work in
progress, with several limitations:
* Other plugins defined in the builtin InnoDB are not disabled.
However, InnoDB in MySQL 5.1 only defines the storage engine plugin,
no INFORMATION_SCHEMA plugins.
* The global C symbols in ha_innodb.so except innodb_hton_ptr and
builtin_innobase_plugin will have to be redefined, e.g., by objcopy.
* The storage engine cannot be called "InnoDB" to avoid a conflict with
the builtin name. Here we call it InnoDBzip.
innobase_hton_name[]: Rename to "InnoDBzip" when building a dynamic plugin.
innodb_plugin_init(): New function for the dynamic plugin, to copy
and redirect configuration parameters from the builtin InnoDB.
innodb_dynamic: New configuration parameter. This has to be added
to the builtin InnoDB in MySQL 5.1. Also, innodb_hton_ptr must be made
global there.
innobase_init(): Interpret the parameter innodb_dynamic.
Makefile.am: Redefine class ha_innobase to ha_innodb by a preprocessor
define. Apparently, C++ classes cannot be easily renamed by objcopy.
INNODB_ZIP and INNODB_ZIP_RESET from ha_innodb.cc to i_s.cc.
plugin_author, END_OF_ST_FIELD_INFO, i_s_info: New common constants.
trx_i_s_common_deinit(): Renamed to i_s_common_deinit().
ha_innobase::update_thd(void): New function, to call the inline function
ha_innobase::update_thd(THD*).
check_trx_exists(): Make static. handler0alter.cc does not need to call
this function.
innobase_col_to_mysql(): New function, adapted from
row_sel_field_store_in_mysql_format().
innobase_rec_to_mysql(): Correct the function comment, which was still
saying "clustered index record", although we can convert any record.
Make use of innobase_col_to_mysql(). Always call field->reset(),
so that innobase_col_to_mysql() will not have to pad anything.
dtuple_create_for_mysql(), dtuple_free_for_mysql(): Remove.
ha_innobase::records_in_range(): Use mem_heap_create(), mem_heap_free(),
and dtuple_create() instead of the removed functions above. Since r1587,
InnoDB C++ functions can invoke inlined C functions.
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.
innodb_lock_waits. See
https://svn.innodb.com/innobase/InformationSchema/TransactionsAndLocks
for design notes.
Things that need to be resolved before this goes live:
* MySQL must add thd_get_thread_id() function to their code
http://bugs.mysql.com/30930
* Allocate memory from mem_heap instead of using mem_alloc()
* Copy table name and index name into the cache because they may be
freed later which will result in referencing freed memory
Approved by: Marko
existed before the fast-index-creation code was merged, in r1414.
Do not call row_prebuilt_table_obsolete(innodb_table) until after
the table has been renamed to a temporary name. Otherwise, the
following could happen when creating a clustered index on table T:
(a1) copy T to T#1
(a2) mark T obsolete
(b1) add the name of T to the background drop list
(a3) rename T to T#2 and T#1 to T
(b2) drop the table on the background
These steps are executed by two threads, a and b.
If b1 is executed after a3, all is fine: the name T#2 will be added
to the background drop list. If b1 is executed before a3, the name
T will be added, and T#2 will survive.
fast index creation.
innobase_convert_tablename(): New function, to remove the filename
encoding of a database and table name.
ha_innobase::add_index(): Invoke innobase_convert_tablename() before
calling my_error().
innodb-index.result: Update the error messages.
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.
#ifdef ROW_MERGE_IS_INDEX_USABLE, to avoid growing the memory
footprint until MySQL implements and calls the virtual method
handler::is_index_available() or something equivalent.
in fast index creation. The prefix was previously TEMP_TABLE_PREFIX == '/',
which may occur in index names.
ut_print_namel(): Do not assume that all '/' are separators between
database and table names.
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.
innodb-index.test: Add some test cases for FOREIGN KEY constraints.
row_merge_rename_tables(): New function,
adapted from row_rename_table_for_mysql().
ha_innobase::add_index(): Use row_merge_rename_tables().
have been set.
ha_innobase::add_index(), ha_innobase::prepare_drop_index(),
ha_innobase::final_drop_index(): Return HA_ERR_WRONG_COMMAND if
newraw or innodb_force_recovery have been set.
(PRIMARY KEY or UNIQUE INDEX on NOT NULL columns).
innodb-index.test: Remove the --replace_regex directives. Replace correct
values to the "Duplicate entry" messages. This will cause the test to
fail until we somehow return the duplicate key values to MySQL.
Add test cases for creating or dropping UNIQUE INDEX or PRIMARY KEY.
innobase_copy_index_def(): Allow the function to copy a clustered index
definition to a secondary one (UNIQUE INDEX).
innobase_create_key_def(): Check the NOT NULL flag from the correct
place. Copy the clustered index if it is a UNIQUE INDEX.
ha_innobase::prepare_drop_index(): Refuse to drop the clustered index.
ha_innobase::add_index(), ha_innobase::prepare_drop_index():
Remove the redundant thd_test_options() calls.
The options are tested in check_trx_exists().
ha_innobase::prepare_drop_index(): key cannot be NULL; remove the tests.
Move the condition for checking foreign keys outside of the loop.
Remove the redundant error log printout about foreign key dependency.
It was only set by ha_innobase::prepare_drop_index(), which can return
the appropriate MySQL error code (HA_ERR_DROP_INDEX_FK) directly.
ha_innobase::add_index(): Correct the function comment.
ha_innobase::prepare_drop_index(): Correct the function comment.
Return MySQL error codes directly.
ha_innobase::final_drop_index(): Correct the function comment.
trx_t: Change the type of error_info from void* to const dict_index_t*.
trx_get_error_info(): Add const qualifier to trx_t*. Make this an
inline function.
key name "PRIMARY". If the table has a generated clustered index,
also check for a UNIQUE INDEX containing no NULL columns.
innobase_create_index_def(): Add the parameter key_primary.
innobase_create_key_def(): Check if the first index is a UNIQUE index
consisting of NOT NULL columns.
Fixing this bug revealed another one: FOREIGN KEY constraints
will be lost when a PRIMARY KEY is created. This is the reason why
innodb.test will fail.
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.
row_merge_create_temporary_table(): Add the parameter index_defs.
DB_PRIMARY_KEY_IS_NULL: New error code, mapped to ER_PRIMARY_CANT_HAVE_NULL.
row_merge_read_clustered_index(): Replace the parameter "table" with the
two parameters "old_table" and "new_table". Detect NULL values of columns
that are supposed to be NOT NULL.
row_merge_col_prtype(): New auxiliary function, used by
row_merge_create_temporary_table() to flag NOT NULL any columns
contained in an added PRIMARY KEY.
innobase_copy_index_field_def(): Remove parameter heap. The field->name
will not be deallocated before the copied index has been added to the
data dictionary cache.
innobase_copy_index_def(): Add const qualifier to dict_index_t*.
Add an assertion !dict_index_is_clust(index).
ha_innobase::add_index(): Add the missing user_thd parameter to the
convert_error_code_to_mysql() call that was forgotten from r1686.
merge_index_field_struct: Add const qualifier to field_name.
merge_index_def_struct: Add const qualifier to name.
row_merge_build_indexes(): Improve the function comment.
row_merge_drop_table(): Remove bogus assertion ut_a(table->to_be_dropped).
goto err_exit. The error handling should be rewritten. Many of the
error messages contain parameters, but this code is only returning
the error number to MySQL.
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.
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.
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().
ha_innobase::add_index(): Do commit the transaction, because the error
handler (label err1) in mysql_alter_table() won't commit it as of now.
This was detected in a failure of type_bit_innodb.
now that all of InnoDB code is built from a single Makefile and it should
not be possible to build the modules with mutually incompatible options.
#define INSIDE_HA_INNOBASE_CC: Remove.
srv_sizeof_trx_t_in_ha_innodb_cc: Remove.
dict_table_get_low_noninlined(): Remove. This function was unused.
Remove all _noninline functions. Remove the _noninline suffix from
all function calls in ha_innodb.cc.
Remove the variable parent_trx.
Call innobase_register_stmt() in order to work around a MySQL bug
in mysql_alter_table(), which, as of
ChangeSet@1.2482.61.2, 2007-06-07 16:37:15+02:00, joerg@trift2. +8 -0
commits the transaction before calling ha_innobase::add_index().
Without re-registering the statement, the ha_commit_stmt(thd)
in mysql_alter_table() would not invoke innobase_commit.
occur in mysql-test-run, but mysql-test-run reports some warnings for
some tests and incorrect results for innodb-index.test.
innobase_start_trx_and_assign_read_view(): Use thd instead of current_thd.
ha_innobase::add_index(): Use ha_thd() instead of current_thd.
Commit the transaction at the end.
row_merge_rename_index(): Really change the name of the index. This was
broken in r1430.
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().
temporary tablespaces in fast index creation. The tablespaces must
reside in the same directory as the persistent tablespaces, so that
they can be renamed without copying. Namespace collisions are avoided
by replacing the ".ibd" file name suffix with ".ib1" or ".ib2".
fil_make_ibd_name(): Treat names starting with TEMP_TABLE_PREFIX
specially. Document the dependence on
innobase_create_temporary_tablename().
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.
in fast index creation.
innobase_create_index_def(), innobase_copy_index_def(): Copy to pre-allocated
space.
innobase_create_key_def(): Change the return type from merge_index_def_t**
to merge_index_def_t*.
innobase_create_index_def(): Add parameter new_primary.
innobase_copy_index_def(): Simplify the documented algorithm,
and try to implement it properly.
innodb-index.test: Replace CHECKSUM TABLE with something more stable and
useful. The test passes on an older BitKeeper snapshot:
ChangeSet@1.2475.18.9, 2007-05-08 11:16:41+02:00, jbruehe@mysql.com +1 -0
Raise version number after cloning 5.1.18-beta
But it fails on a newer one where the statement
alter table t1 add primary key (a), add key (b(20));
results in fast index creation:
ChangeSet@1.2500.1.40, 2007-06-01 20:06:13+04:00, kostja@bodhi.(none) +2 -0
Merge bodhi.(none):/opt/local/work/mysql-5.0-runtime
into bodhi.(none):/opt/local/work/mysql-5.1-runtime
MERGE: 1.1810.2984.14