Fix for BUG#11704: "Found locks from different thread" warnings:
The source of warnings was this scenario in OPTIMIZE:
thr1: lock table with TL_WRITE_ONLY (InnoDB converts lock to
TL_WRITE_ALLOW_WRITE)
thr2: (UPDATE command) obtains a TL_WRITE_ALLOW_WRITE lock
thr1: call mysql_lock_abort(). This function sets type of thr'1 lock
to TL_WRITE_ONLY
thr2: try to release thr2's lock. See two locks: TL_WRITE_ONLY,
TL_WRITE_ALLOW_WRITE and produce a warning.
The fix: Make InnoDB not to convert TL_WRITE_ONLY locks to
TL_WRITE_ALLOW_WRITE in OPTIMIZE TABLE.
Do not pad VARBINARY or BINARY columns. (Bug #14189)
innodb.test, innodb.result: Add test cases for foreign key constraints
between VARBINARY and BINARY columns, and between VARCHAR BINARY and
CHAR BINARY columns.
innobase_init(): Assert that
DATA_MYSQL_BINARY_CHARSET_COLL == my_charset_bin.number.
dtype_get_pad_char(): Do not pad VARBINARY or BINARY columns.
row_ins_cascade_calc_update_vec(): Refuse ON UPDATE CASCADE
when trying to change the length of a VARBINARY column
that refers to or is referenced by a BINARY column. BINARY
columns are no longer padded on comparison, and thus they
cannot be padded on storage either.
In row_ins_set_detailed(), truncate the tmpfile by os_file_set_eof(), because
trx_set_detailed_error_from_file() does not call ftell() to determine
the actual length of the file. This bug resulted in trash being appended
to foreign key error messages.
Work around Bug #12071: Do not call os_file_create_tmpfile() at runtime.
Instead, create all tempfiles at startup and guard access to them with
mutexes.
Note that buf_block_t::index should be protected by btr_search_latch
or an s-latch or x-latch on the index page.
btr_search_drop_page_hash_index(): Read block->index while holding
btr_search_latch and use the cached value in the loop. Remove some
redundant assertions.
Mostly fix bug #13778, when FOREIGN_KEY_CHECKS=0 we still need to check
that datatypes between foreign key references are compatible.
Add test cases (also for bug #9802).