Commit graph

342 commits

Author SHA1 Message Date
vasil
c368f38f4d branches/zip:
Fix "Bug#40360 Binlog related errors with binlog off" in InnoDB code in order
to have a Bug#40360-free InnoDB Plugin 1.0.2.

The fix does check whether binary logging is enabled in MySQL by accessing the
opt_bin_log global variable that is defined in sql/mysqld.cc.

In case MySQL does develop another solution to this via Bug#40360 then we can
revert this patch (except the mysql-tests).

The windows-plugin part of this fix will be committed as a separate commit to
ease eventual merge into branches/5.1 [note from the future: the separate
commit went into r2936].

Approved by:	Marko (https://svn.innodb.com/rb/r/39)
2008-10-30 10:17:23 +00:00
marko
bd3514db33 branches/zip: Merge revisions 2854:2929 from branches/5.1,
except r2924, which was merged from branches/zip r2866 to branches/5.1
and except r2879 which was merged separately by Calvin:

  ------------------------------------------------------------------------
  r2902 | vasil | 2008-10-28 12:10:25 +0200 (Tue, 28 Oct 2008) | 10 lines

  branches/5.1:

  Fix Bug#38189 innodb_stats_on_metadata missing

  Make the variable innodb_stats_on_metadata visible to the users and
  also settable at runtime. Previously it was only "visible" as a command
  line startup option to mysqld.

  Approved by:    Marko (https://svn.innodb.com/rb/r/36)
  ------------------------------------------------------------------------
  r2929 | marko | 2008-10-29 21:26:14 +0200 (Wed, 29 Oct 2008) | 13 lines

  branches/5.1: dtype_get_sql_null_size(): return the correct storage
  size of a SQL NULL column. (Bug #40369)

  When MySQL Bug #20877 was fixed in r834, this function was
  accidentally modified to return 0 or 1. Apparently, the only impact of
  this bug is that fixed-length columns cannot be updated in-place from
  or to SQL NULL, even in ROW_FORMAT=REDUNDANT.  After this fix,
  fixed-length columns in ROW_FORMAT=REDUNDANT will have a constant
  storage size as they should, no matter if NULL or non-NULL.  The bug
  caused fixed-length NULL columns to occupy 1 byte.

  rb://37 approved by Heikki over IM.
  ------------------------------------------------------------------------
2008-10-29 19:39:24 +00:00
marko
e2656dba61 branches/zip: ha_innodb.cc: Make some functions static, so that they will
not be compiled as weak global symbols.  These functions must not be
redirected to the built-in InnoDB.
2008-10-29 09:43:23 +00:00
calvin
b7d0a7770a branches/zip: fix issue #102 - Windows plugin: resolve dbug functions
during run-time.

Implement wrapper functions in the plugin. The plugin will get the
function entries from mysqld.exe during the init, and invoke the
corresponding functions (in mysqld.exe). The list of functions are:

	_db_pargs_
	_db_doprnt_
	_db_enter_
	_db_return_
	_db_dump_

rb://38

Approved by:	Marko
2008-10-29 06:29:01 +00:00
calvin
191409aaa7 branches/zip: fix a problem introduced in r2917 - dyn is not
initialized. Move the check into for().
2008-10-28 22:08:11 +00:00
marko
b80665e409 branches/zip: innodb_plugin_init(): Do not copy session variables,
even when the variable is a global variable in the built-in InnoDB.
2008-10-28 21:53:23 +00:00
calvin
fd6831625c branches/zip: implement the delayloading of externals for the plugin
on Windows, which includes:

 * Load mysqld.map and insert all symbol/address pairs into hash for
   quick access
 * Resolves all external data variables. The delayloading mechanism
   in MSVC does not support automatic imports of data variables.
   A workaround is to explicitly handle the data import using the delay
   loader during the initialization of the plugin.
 * Resolves all external functions during run-time, by implementing
   the delayed loading helper function delayLoadHelper2, which is
   called by run-time as well as HrLoadAllImportsForDll. 

The delay loader reuses the hash implementation in InnoDB. The normal
hash_create (in hash0hash.c) creates hash tables in buffer pool. But
the delay loader is invoked before the engine is initialized, and 
buffer pools are not ready yet. Instead, the delay loader has its own
implementation of hash_create() and hash_table_free(), called
wdl_hash_create() and wdl_hash_table_free().

This patch should be used with other two patches in order to build
a dynamically linked plugin on Windows:
 * patch for tmpfile functions (r2886)
 * patch for "build" files (to be committed)
 
The list of file changed:

handler/handler0vars.h: new file, defines a list of external data
variables (no external functions).

handler/win_delay_loader.cc: new file, the implementation of the delay
loader for Windows plugin.

handler/ha_innodb.cc: add a header file, and changes for copying the
system variables.

handler/handler0alter.cc: add a header file

handler/i_s.cc: add a header file

rb://27

Reviewed by:	Sunny, Marko
Approved by:	Sunny
2008-10-27 20:48:29 +00:00
calvin
ed35fc5852 branches/zip: This patch is to solve the issue that file handles can
not cross DLL/EXE boundaries on Windows. In builtin InnoDB, it makes
call to MySQL server for creating tmp files. innobase_mysql_tmpfile
is now rewritten for the plugin. 

rb://5

Approved by:	Marko
2008-10-27 20:39:11 +00:00
marko
d8fd1aec8d branches/zip: Clean up the file format stamping.
trx_sys_file_format_max_upgrade(): Rename from
trx_sys_file_format_max_update().  Improve the documentation.  Add a
const qualifier to the parameter "name".  Replace the parameter
"flags" with "format_id", because this function should deal with file
format identifiers, not with table flags.

trx_sys_file_format_max_write(), trx_sys_file_format_max_set(): Add a
const qualifier to the parameter "name".

ha_innodb.cc: Correct the spelling in some comments: "side effect".
Remove redundant prototypes for some static callback functions.

innodb_file_format_name_update(), innodb_file_format_check_update():
Correct the function signature.  Use appropriate pointer type conversions.

MYSQL_SYSVAR_STR(file_format), MYSQL_SYSVAR_STR(file_format_check):
Remove the type conversions from the callback function pointers.  When
the function signatures match, no type conversion is needed.  The type
conversions would only prevent compilation warnings for any mismatch.

Approved by Sunny in rb://25.
2008-10-23 08:27:15 +00:00
sunny
119142d2d1 branches/zip:
Merge revisions 2852:2854 from branches/5.1:

  ------------------------------------------------------------------------
  r2854 | sunny | 2008-10-23 08:30:32 +0300 (Thu, 23 Oct 2008) | 13 lines
  Changed paths:
     M /branches/5.1/dict/dict0dict.c
     M /branches/5.1/dict/dict0mem.c
     M /branches/5.1/handler/ha_innodb.cc
     M /branches/5.1/handler/ha_innodb.h
     M /branches/5.1/include/dict0dict.h
     M /branches/5.1/include/dict0mem.h
     M /branches/5.1/row/row0mysql.c
  
  branches/5.1: Backport changes from branches/zip r2725
  
  Simplify the autoinc initialization code. This removes the
  non-determinism related to reading the table's autoinc value for the first
  time. This change has also reduced the sizeof dict_table_t by sizeof(ibool)
  bytes because we don't need the dict_table_t::autoinc_inited field anymore.
  
  Bug#39830 Table autoinc value not updated on first insert.
  Bug#35498 Cannot get table test/table1 auto-inccounter value in ::info
  Bug#36411 Failed to read auto-increment value from storage engine" in 5.1.24 auto-inc
  rb://16
  
  
  ------------------------------------------------------------------------
2008-10-23 06:24:33 +00:00
sunny
f9c42d81e7 branches/zip:
Merge revisions 2837:2852 from branches/5.1:

  ------------------------------------------------------------------------
  r2849 | sunny | 2008-10-22 12:01:18 +0300 (Wed, 22 Oct 2008) | 8 lines
  Changed paths:
     M /branches/5.1/handler/ha_innodb.cc
     M /branches/5.1/include/row0mysql.h
     M /branches/5.1/row/row0mysql.c
  
  branches/5.1: Return the actual error code encountered when allocating
  a new autoinc value. The change in behavior (bug) was introduced in 5.1.22
  when we introduced the new AUTOINC locking model.
  
  rb://31
  
  Bug#40224 New AUTOINC changes mask reporting of deadlock/timeout errors
  
  ------------------------------------------------------------------------
  r2852 | sunny | 2008-10-23 01:42:24 +0300 (Thu, 23 Oct 2008) | 9 lines
  Changed paths:
     M /branches/5.1/handler/ha_innodb.cc
     M /branches/5.1/handler/ha_innodb.h
  
  branches/5.1: Backport r2724 from branches/zip
  
  Check column value against the col max value before updating the table's
  global autoinc counter value. This is part of simplifying the AUTOINC
  sub-system. We extract the type info from MySQL data structures at runtime.
  
  This fixes Bug#37788 InnoDB Plugin: AUTO_INCREMENT wrong for compressed tables
  
  
  ------------------------------------------------------------------------
2008-10-23 05:29:46 +00:00
sunny
2a71ad87b5 branches/zip: Add missing UNIV_INTERN. 2008-10-22 21:52:09 +00:00
vasil
49589d0ae2 branches/zip:
Merge 2744:2837 from branches/5.1 (skipping r2782 and r2826):

  ------------------------------------------------------------------------
  r2832 | vasil | 2008-10-21 10:08:30 +0300 (Tue, 21 Oct 2008) | 10 lines
  Changed paths:
     M /branches/5.1/handler/ha_innodb.cc
  
  branches/5.1:
  
  In ha_innobase::info():
  
  Replace sql_print_warning() which prints to mysqld error log with
  push_warning_printf() which sends the error message to the client.
  
  Suggested by:	Marko, Sunny, Michael
  Objected by:	Inaam
  
  ------------------------------------------------------------------------
  r2837 | vasil | 2008-10-21 12:07:44 +0300 (Tue, 21 Oct 2008) | 32 lines
  Changed paths:
     M /branches/5.1/mysql-test/innodb-semi-consistent.result
     M /branches/5.1/mysql-test/innodb-semi-consistent.test
     M /branches/5.1/mysql-test/innodb.result
     M /branches/5.1/mysql-test/innodb.test
  
  branches/5.1:
  
  Merge a change from MySQL (this fixes the failing innodb and
  innodb-semi-consistent tests):
  
    revno: 2757
    committer: Georgi Kodinov <kgeorge@mysql.com>
    branch nick: B39812-5.1-5.1.29-rc
    timestamp: Fri 2008-10-03 15:24:19 +0300
    message:
      Bug #39812: Make statement replication default for 5.1 (to match 5.0)
      
      Make STMT replication default for 5.1.
      Add a default of MIXED into the config files
      Fix the tests that needed MIXED replication mode.
    modified:
      mysql-test/include/mix1.inc
      mysql-test/r/innodb-semi-consistent.result
      mysql-test/r/innodb.result
      mysql-test/r/innodb_mysql.result
      mysql-test/r/tx_isolation_func.result
      mysql-test/t/innodb-semi-consistent.test
      mysql-test/t/innodb.test
      mysql-test/t/tx_isolation_func.test
      sql/mysqld.cc
      support-files/my-huge.cnf.sh
      support-files/my-innodb-heavy-4G.cnf.sh
      support-files/my-large.cnf.sh
      support-files/my-medium.cnf.sh
      support-files/my-small.cnf.sh
  
  
  ------------------------------------------------------------------------
2008-10-21 08:49:27 +00:00
marko
41953325b9 branches/zip: Fix some locking issues, mainly in fast index creation.
This should hopefully address Issue #85.

ha_innobase::add_index(): Lock the data dictionary before invoking
row_merge_rename_indexes() or row_merge_drop_indexes(), because neither
function will commit the transaction.

ha_innobase::final_drop_index(): Commit the transactions before
unlocking the data dictionary.

row_merge_drop_index(), row_merge_drop_indexes(), row_merge_rename_tables(),
row_merge_rename_indexes(): Note and assert that the data dictionary must
have been exclusively locked by the caller, because the transaction will
not be committed.

row_drop_database_for_mysql(): Commit the transaction immediately after
dropping each table.  When MySQL is holding open handles to some tables,
it can otherwise occur than the data dictionary is unlocked while the
transaction has not been committed.  This bug was introduced in r2739,
which changed the semantics of row_drop_table_for_mysql().

row_drop_database_for_mysql(): Postpone mem_free(table_name), so that
an error printout will not dereference freed memory.
2008-10-10 11:44:27 +00:00
marko
77a229843f branches/zip: Merge revisions 2722:2744 from branches/5.1:
------------------------------------------------------------------------
  r2742 | inaam | 2008-10-08 22:02:15 +0300 (Wed, 08 Oct 2008) | 11 lines

  branches/5.1:

  Fix Bug#39939 DROP TABLE/DISCARD TABLESPACE takes long time in
  buf_LRU_invalidate_tablespace()

  Improve implementation of buf_LRU_invalidate_tablespace by attempting
  hash index drop in batches instead of doing it one by one.

  Reviewed by: Heikki, Sunny, Marko
  Approved by: Heikki
  ------------------------------------------------------------------------
  r2744 | marko | 2008-10-09 10:53:09 +0300 (Thu, 09 Oct 2008) | 5 lines

  branches/5.1: ha_innobase::delete_all_rows(): In response to a user asking
  <http://forums.innodb.com/read.php?4,215,215> why DELETE FROM t is not
  mapped to TRUNCATE TABLE t as it is in MyISAM, note in a comment that
  DELETE is transactional while TRUNCATE is not.
  ------------------------------------------------------------------------
2008-10-09 08:48:58 +00:00
sunny
581de59921 branches/zip: Check for autoinc next value overflow explicitly when offset
is > 1. This is safer and easier to understand.
2008-10-05 23:44:30 +00:00
sunny
f1591a52a1 branches/zip: Fix the handler class method return type. Change ulong to ulint
so that it conforms to InnoDB's internal error/return code type.
2008-10-04 06:34:54 +00:00
sunny
0eff3d3ca6 branches/zip: Simplify the autoinc initialization code. This removes the
non-determinism related to reading the table's autoinc value for the first
time. This change has also reduced the sizeof dict_table_t by sizeof(ibool)
bytes because we don't need the dict_table_t::autoinc_inited field anymore.

This also fixes Bug#39830 Table autoinc value not updated on first insert.
rb://16
2008-10-04 06:24:56 +00:00
sunny
b5020016ee branches/zip: Check column value against the col max value before updating
the table's global autoinc counter value. This is part of simplifying the
AUTOINC sub-system. We extract the type info from MySQL data structures at
runtime.

This fixes Bug#37788 InnoDB Plugin: AUTO_INCREMENT wrong for compressed tables
2008-10-04 03:47:18 +00:00
sunny
cb0cacc2d8 branches/zip: Merge revisions 2702:2722 from branches/5.1:
------------------------------------------------------------------------
  r2702 | sunny | 2008-09-30 11:41:56 +0300 (Tue, 30 Sep 2008) | 13 lines
  Changed paths:
     M /branches/5.1/handler/ha_innodb.cc
  
  branches/5.1: Since handler::get_auto_increment() doesn't allow us
  to return the cause of failure we have to inform MySQL using the
  sql_print_warning() function to return the cause for autoinc failure.
  Previously we simply printed the error code, this patch prints the
  text string representing the following two error codes:
  
  DB_LOCK_WAIT_TIMEOUT
  DB_DEADLOCK.
  
  Bug#35498 Cannot get table test/table1 auto-inccounter value in ::info
  
  Approved by Marko.
  
  ------------------------------------------------------------------------
  r2709 | vasil | 2008-10-01 10:13:13 +0300 (Wed, 01 Oct 2008) | 10 lines
  Changed paths:
     M /branches/5.1/include/lock0lock.h
     M /branches/5.1/lock/lock0lock.c
     A /branches/5.1/mysql-test/innodb_bug38231.result
     A /branches/5.1/mysql-test/innodb_bug38231.test
     M /branches/5.1/row/row0mysql.c
  
  branches/5.1:
  
  Fix Bug#38231 Innodb crash in lock_reset_all_on_table() on TRUNCATE + LOCK / UNLOCK
  
  In TRUNCATE TABLE and discard tablespace: do not remove table-level S
  and X locks and do not assert on such locks not being wait locks.
  Leave such locks alone.
  
  Approved by:	Heikki (rb://14)
  
  ------------------------------------------------------------------------
  r2710 | vasil | 2008-10-01 14:13:58 +0300 (Wed, 01 Oct 2008) | 6 lines
  Changed paths:
     M /branches/5.1/include/sync0sync.ic
  
  branches/5.1:
  
  Silence a compilation warning in UNIV_DEBUG.
  
  Approved by:	Marko (via IM)
  
  ------------------------------------------------------------------------
  r2719 | vasil | 2008-10-03 18:17:28 +0300 (Fri, 03 Oct 2008) | 49 lines
  Changed paths:
     M /branches/5.1/handler/ha_innodb.cc
     A /branches/5.1/mysql-test/innodb_bug39438-master.opt
     A /branches/5.1/mysql-test/innodb_bug39438.result
     A /branches/5.1/mysql-test/innodb_bug39438.test
  
  branches/5.1:
  
  Fix Bug#39438 Testcase for Bug#39436 crashes on 5.1 in fil_space_get_latch
  
  In ha_innobase::info() - do not try to get the free space for a tablespace
  which has been discarded with ALTER TABLE ... DISCARD TABLESPACE or if the
  .ibd file is missing for some other reason.
  
  ibd_file_missing and tablespace_discarded are manipulated only in
  row_discard_tablespace_for_mysql() and in row_import_tablespace_for_mysql()
  and the manipulation is protected/surrounded by
  row_mysql_lock_data_dictionary()/row_mysql_unlock_data_dictionary() thus we
  do the same in ha_innobase::info() when checking the values of those members
  to avoid race conditions. I have tested the code-path with UNIV_DEBUG and
  UNIV_SYNC_DEBUG.
  
  Looks like it is not possible to avoid mysqld printing warnings in the
  mysql-test case and thus this test innodb_bug39438 must be added to the
  list of exceptional test cases that are allowed to print warnings. For this,
  the following patch must be applied to the mysql source tree:
  
    --- cut ---
    === modified file 'mysql-test/lib/mtr_report.pl'
    --- mysql-test/lib/mtr_report.pl	2008-08-12 10:26:23 +0000
    +++ mysql-test/lib/mtr_report.pl	2008-10-01 11:57:41 +0000
    @@ -412,7 +412,10 @@
     
                     # When trying to set lower_case_table_names = 2
                     # on a case sensitive file system. Bug#37402.
    -                /lower_case_table_names was set to 2, even though your the file system '.*' is case sensitive.  Now setting lower_case_table_names to 0 to avoid future problems./
    +                /lower_case_table_names was set to 2, even though your the file system '.*' is case sensitive.  Now setting lower_case_table_names to 0 to avoid future problems./ or
    +
    +                # this test is expected to print warnings
    +                ($testname eq 'main.innodb_bug39438')
     		)
                 {
                   next;                       # Skip these lines
    
    --- cut ---
  
  The mysql-test is currently somewhat disabled (see inside
  innodb_bug39438.test), after the above patch has been applied to the mysql
  source tree, the test can be enabled.
  
  rb://20
  
  Reviewed by:	Inaam, Calvin
  Approved by:	Heikki
  
  ------------------------------------------------------------------------
  r2720 | vasil | 2008-10-03 19:52:39 +0300 (Fri, 03 Oct 2008) | 8 lines
  Changed paths:
     M /branches/5.1/handler/ha_innodb.cc
  
  branches/5.1:
  
  Print a warning if an attempt is made to get the free space for a table
  whose .ibd file is missing or the tablespace has been discarded. This is a
  followup to r2719.
  
  Suggested by:	Inaam
  
  ------------------------------------------------------------------------
  r2721 | sunny | 2008-10-04 02:08:23 +0300 (Sat, 04 Oct 2008) | 6 lines
  Changed paths:
     M /branches/5.1/handler/ha_innodb.cc
  
  branches/5.1: We need to send the messages to the client because
  handler::get_auto_increment() doesn't allow a way to return the
  specific error for why it failed.
  
  rb://18
  
  ------------------------------------------------------------------------
  r2722 | sunny | 2008-10-04 02:48:04 +0300 (Sat, 04 Oct 2008) | 18 lines
  Changed paths:
     M /branches/5.1/dict/dict0mem.c
     M /branches/5.1/handler/ha_innodb.cc
     M /branches/5.1/include/dict0mem.h
     M /branches/5.1/include/row0mysql.h
     M /branches/5.1/mysql-test/innodb-autoinc.result
     M /branches/5.1/mysql-test/innodb-autoinc.test
     M /branches/5.1/row/row0mysql.c
  
  branches/5.1: This bug has always existed but was masked by other errors. The
  fix for bug# 38839 triggered this bug. When the offset and increment are > 1
  we need to calculate the next value taking into consideration the two
  variables. Previously we simply assumed they were 1 particularly offset was
  never used. MySQL does its own calculation and that's probably why it seemed
  to work in the past. We would return what we thought was the correct next
  value and then MySQL would recalculate the actual value from that and return
  it to the caller (e.g., handler::write_row()). Several new tests have been
  added that try and catch some edge cases. The tests exposed a wrap around
  error in MySQL next value calculation which was filed as bug#39828. The tests
  will need to be updated once MySQL fix that bug.
  
  One good side effect of this fix is that dict_table_t size has been
  reduced by 8 bytes because we have moved the autoinc_increment field to
  the row_prebuilt_t structure. See review-board for a detailed discussion.
  
  rb://3
  
  ------------------------------------------------------------------------
2008-10-04 03:22:36 +00:00
marko
be56c64772 branches/zip: Make innodb_lock_wait_timeout a settable session variable
(Bug #36285, rb://9).

innodb-index.test, innodb-index.result: Set innodb_lock_wait_timeout as
a session variable instead of relying on the global value.

innodb-index-master.opt: Remove.

innodb-timeout.test: Test that setting the innodb_lock_wait_timeout
works as advertised.

thd_lock_wait_timeout(): New function, to retrieve the lock wait timeout
for a given MySQL client connection (thd), or the global value (thd==NULL).

srv_lock_wait_timeout, innobase_lock_wait_timeout: Remove.

Replace MYSQL_SYSVAR_LONG(lock_wait_timeout)
with MYSQL_THDVAR_ULONG(lock_wait_timeout).
2008-10-03 09:24:23 +00:00
marko
3b90e70d74 branches/zip: Merge revisions 2630:2702 from branches/5.1:
------------------------------------------------------------------------
  r2702 | sunny | 2008-09-30 11:41:56 +0300 (Tue, 30 Sep 2008) | 13 lines

  branches/5.1: Since handler::get_auto_increment() doesn't allow us
  to return the cause of failure we have to inform MySQL using the
  sql_print_warning() function to return the cause for autoinc failure.
  Previously we simply printed the error code, this patch prints the
  text string representing the following two error codes:

  DB_LOCK_WAIT_TIMEOUT
  DB_DEADLOCK.

  Bug#35498 Cannot get table test/table1 auto-inccounter value in ::info

  Approved by Marko.
  ------------------------------------------------------------------------
  rb://18
2008-10-01 05:37:35 +00:00
marko
3ab2bac4b8 branches/zip: thd_is_strict(): Add missing UNIV_INTERN qualifier as well. 2008-09-25 09:14:27 +00:00
marko
0e7c8d7fac branches/zip: thd_is_strict(): Add missing extern "C" qualifier. 2008-09-25 08:15:18 +00:00
marko
d36b83e65b branches/zip: Map current_thd to NULL in the Windows plugin, and use
ha_thd() whenever possible.

EQ_CURRENT_THD(thd): New predicate, for use in assertions.

innobase_drop_database(): Tolerate current_thd == NULL, so that the
Windows plugin will work.  In the Windows plugin, it will be
impossible to skip foreign key checks in this function.  However,
DROP DATABASE will drop each table (that MySQL knows about) individually
before calling this function.  Thus, the foreign key checks can be disabled
also in the Windows plugin, unless some .frm files are missing.
2008-09-18 13:14:29 +00:00
marko
75fe6fa6a4 branches/zip: When creating an index in innodb_strict_mode, check that
the maximum record size will never exceed the B-tree page size limit.
For uncompressed tables, there should always be enough space for two
records in an empty B-tree page.  For compressed tables, there should
be enough space for storing two node pointer records or one data
record in an empty page in uncompressed format.

dict_build_table_def_step(): Remove the inaccurate check for table row
size.

dict_index_too_big_for_tree(): New function: check if the index
records would be too big for a B-tree page.

dict_index_add_to_cache(): Add the parameter "strict".  Invoke
dict_index_too_big_for_tree() if it is set.

trx_is_strict(), thd_is_strict(): New functions, for determining if
innodb_strict_mode is enabled for the current transaction.

dict_create_index_step(): Pass the new parameter strict of
dict_index_add_to_cache() as trx_is_strict(trx).  All other callers
pass it as FALSE.

innodb.test: Enable innodb_strict_mode before attempting to create a
table with a too big record size.

innodb-zip.test: Remove the test of inserting random data.  Add tests
for checking that the maximum record lengths are enforced at table
creation time.
2008-09-18 12:31:17 +00:00
marko
7d0834170d branches/zip: Merge r2617:r2630 from branches/5.1:
bug#39483 InnoDB hang on adaptive hash because of out of order ::open()
call by MySQL

Forward port of r2629

Under some conditions MySQL calls ::open with search_latch leading
to a deadlock as we try to acquire dict_sys->mutex inside ::open
breaking the latching order. The fix is to release search_latch.

Reviewed by: Heikki
2008-09-17 10:54:28 +00:00
marko
c1cc5b1316 branches/zip: innobase_convert_from_id(), innobase_convert_from_table_id():
Add the parameter struct charset_info_st* cs, so that the call
thd_charset(current_thd) can be avoided.  The macro current_thd has no
defined value in the Windows plugin.
2008-09-17 10:07:36 +00:00
marko
5dc842cf08 branches/zip: Non-functional change: Move the declarations of the
functions innobase_convert_from_table_id(), innobase_convert_from_id(),
innobase_casedn_str(), and innobase_get_charset() to ha_prototypes.h.
2008-09-17 10:03:43 +00:00
marko
34426c473e branches/zip: Add some tests for innodb_strict_mode.
ha_innodb.cc: Declare strict_mode as PLUGIN_VAR_OPCMDARG, because we
do want to be able to disable innodb_strict_mode.  This is a non-functional
change, because PLUGIN_VAR_NOCMDARG seems to accept an argument as well.

innodb-zip.test: Do not store innodb_strict_mode.  It is a session variable.
Add a test case for innodb_strict_mode=off.
2008-09-17 08:12:03 +00:00
vasil
0749ae93df branches/zip:
Merge 2605:2617 from branches/5.1:

  ------------------------------------------------------------------------
  r2609 | sunny | 2008-08-24 01:19:05 +0300 (Sun, 24 Aug 2008) | 12 lines
  Changed paths:
     M /branches/5.1/handler/ha_innodb.cc
     M /branches/5.1/mysql-test/innodb-autoinc.result
     M /branches/5.1/mysql-test/innodb-autoinc.test
  
  branches/5.1: Fix for MySQL Bug#38839. Reset the statement level last
  value field in prebuilt. This field tracks the last value in an autoincrement
  interval. We use this value to check whether we need to update a table's
  AUTOINC counter, if the value written to a table is less than this value
  then we avoid updating the table's AUTOINC value in order to reduce
  mutex contention. If it's not reset (e.g., after a DELETE statement) then
  there is the possibility of missing updates to the table's AUTOINC counter
  resulting in a subsequent duplicate row error message under certain 
  conditions (see the test case for details).
  
  Bug #38839 - auto increment does not work properly with InnoDB after update
  
  ------------------------------------------------------------------------
  r2617 | vasil | 2008-09-09 15:46:17 +0300 (Tue, 09 Sep 2008) | 47 lines
  Changed paths:
     M /branches/5.1/mysql-test/innodb.result
  
  branches/5.1:
  
  Merge a change from MySQL (fix the failing innodb test):
  
    ------------------------------------------------------------
    revno: 2646.12.1
    committer: Mattias Jonsson <mattiasj@mysql.com>
    branch nick: wl4176_2-51-bugteam
    timestamp: Mon 2008-08-11 20:02:03 +0200
    message:
      Bug#20129: ALTER TABLE ... REPAIR PARTITION ... complains that
      partition is corrupt
      
      The main problem was that ALTER TABLE t ANALYZE/CHECK/OPTIMIZE/REPAIR
      PARTITION took another code path (over mysql_alter_table instead of
      mysql_admin_table) which differs in two ways:
      1) alter table opens the tables in a different way than admin tables do
         resulting in returning with error before it tried the command
      2) alter table does not start to send any diagnostic rows to the client
         which the lower admin functions continue to use -> resulting in
         assertion crash
      
      The fix:
      Remapped ALTER TABLE t ANALYZE/CHECK/OPTIMIZE/REPAIR PARTITION to use
      the same code path as ANALYZE/CHECK/OPTIMIZE/REPAIR TABLE t.
      Adding check in mysql_admin_table to setup the partition list for
      which partitions that should be used.
      
      
      Partitioned tables will still not work with
      REPAIR TABLE/PARTITION USE_FRM, since that requires moving partitions
      to tables, REPAIR TABLE t USE_FRM, and check that the data still
      fulfills the partitioning function and then move the table back to
      being a partition.
      
      NOTE: I have removed the following functions from the handler
      interface:
      analyze_partitions, check_partitions, optimize_partitions,
      repair_partitions
      Since they are not longer needed.
      THIS ALTERS THE STORAGE ENGINE API
  
  I have verified that OPTIMIZE TABLE actually rebuilds the table
  and calls ANALYZE.
  
  Approved by:	Heikki
2008-09-09 12:00:34 +00:00
marko
f19cbe507d branches/zip: ha_innobase::prepare_drop_index(): When there is a
foreign key constraint, find a truly equivalent index for it.
If none is available, refuse to drop the index.  MySQL can drop
an index when creating a "stronger" index.

This was reported as Mantis issue #70 and MySQL Bug #38786.

innodb-index.test: Add a test case.

dict_foreign_find_equiv_index(): New function, to replace the
incorrectly written function dict_table_find_equivalent_index().

dict_table_replace_index_in_foreign_list(): Simplify the implementation.
2008-09-09 11:05:56 +00:00
marko
2323c4d2dd branches/zip: thd_is_select(): Add the missing UNIV_INTERN to the definition.
This function was introduced in r2606, when merging r2603 from branches/5.1.
2008-08-21 14:59:44 +00:00
vasil
22ecced647 branches/zip:
Merge 2537:2605 from branches/5.1:

  ------------------------------------------------------------------------
  r2545 | vasil | 2008-07-25 17:24:23 +0300 (Fri, 25 Jul 2008) | 37 lines
  Changed paths:
     M /branches/5.1/handler/ha_innodb.cc
  
  branches/5.1:
  
  Fix Bug#38185 ha_innobase::info can hold locks even when called with HA_STATUS_NO_LOCK
  
  The fix is to call fsp_get_available_space_in_free_extents() from
  ha_innobase::info() only if HA_STATUS_NO_LOCK is not present in the flag
  *AND*
  change get_schema_tables_record() in MySQL's sql/sql_show.cc to call
  ::info() *without* HA_STATUS_NO_LOCK whenever a user issues SELECT FROM
  information_schema.tables;
  
  Without the change to sql/sql_show.cc this patch would lead to Bug#32440
  resurfacing. I.e. delete_length would never be updated in ::info() and
  will remain 0 forever, resulting in the free space not being shown
  anywhere.
  
  This is the change to sql/sql_show.cc for reference, it needs to be
  committed to the MySQL repo before or at the same time with this change
  to ha_innodb.cc:
  
   --- patch begins here ---
   --- sql/sql_show.cc.orig	2008-07-23 09:32:14.000000000 +0300
   +++ sql/sql_show.cc	2008-07-23 09:32:19.000000000 +0300
   @@ -3549,8 +3549,7 @@ static int get_schema_tables_record(THD 
    
        if(file)
        {
   -      file->info(HA_STATUS_VARIABLE | HA_STATUS_TIME | HA_STATUS_AUTO |
   -                 HA_STATUS_NO_LOCK);
   +      file->info(HA_STATUS_VARIABLE | HA_STATUS_TIME | HA_STATUS_AUTO);
          enum row_type row_type = file->get_row_type();
          switch (row_type) {
          case ROW_TYPE_NOT_USED:
   --- patch ends here ---
  
  Approved by:	Heikki
  
  ------------------------------------------------------------------------
  r2603 | marko | 2008-08-21 16:25:05 +0300 (Thu, 21 Aug 2008) | 10 lines
  Changed paths:
     M /branches/5.1/handler/ha_innodb.cc
     M /branches/5.1/include/ha_prototypes.h
     M /branches/5.1/row/row0sel.c
  
  branches/5.1: Identify SELECT statements by thd_sql_command() == SQLCOM_SELECT
  instead of parsing the query string.  This fixes MySQL Bug #37885 without
  us having to implement lexical analysis of SQL comments in yet another place.
  
  thd_is_select(): A new predicate.
  
  row_search_for_mysql(): Use thd_is_select().
  
  Approved by Heikki.
  
  ------------------------------------------------------------------------
2008-08-21 14:23:46 +00:00
vasil
9bbd5454db branches/zip:
The cardinality of every index (the number of different key values) is
calculated when the table is opened, at SHOW TABLE STATUS,
ANALYZE TABLE and on other circumstances (like when the table has
changed too much). Note that if the mysql client is running with the
auto-rehash setting turned on (default) this causes all tables to be
opened when it starts.

Previously InnoDB sampled 8 random pages from the index to get an
estimate of the cardinality. Now the number of sampled pages can be
changed via the global parameter innodb_stats_sample_pages which can
be tuned at runtime. The default value for this parameter is 8.

If the value of this parameter is changed, there may be serious problems:

- small values (say, 1) can cause an error in table stats;
- values much larger than 8 (say, 100), can cause a big slowdown in
  table opening time, SHOW TABLE status, etc.
- query plans may be different from the old ones.

Approved by:	Heikki
2008-08-07 13:47:44 +00:00
calvin
b4d2512bbd branches/zip:
Add a space in a warning message. No functional change to the code.
The original message is "invalid innodb_file_format_checkvalue;...".
The new one is "invalid innodb_file_format_check value;..."
2008-07-03 06:41:16 +00:00
vasil
8093d7a5f8 branches/zip: Merge 2489:2524 from branches/5.1:
------------------------------------------------------------------------
  r2519 | sunny | 2008-06-26 16:55:43 +0300 (Thu, 26 Jun 2008) | 5 lines
  
  branches/5.1: Add test cases and fix a bug where the last AUTOINC cached value
  was not reset to 0 when the table was truncated.
  
  Bug #37531 : After truncate, auto_increment behaves incorrectly for InnoDB
  
  ------------------------------------------------------------------------
  r2520 | vasil | 2008-06-26 17:38:02 +0300 (Thu, 26 Jun 2008) | 7 lines
  
  branches/5.1:
   
  Fix Bug#36941 Performance problem in ha_print_info (SHOW INNODB STATUS)
  by disabling some of the code in ha_print_info() in production builds.
   
  Approved by:	Heikki (via IM)
  
  ------------------------------------------------------------------------
  r2521 | vasil | 2008-06-26 17:39:01 +0300 (Thu, 26 Jun 2008) | 8 lines
  
  branches/5.1:
   
  Fix Bug#36942 Performance problem in lock_get_n_rec_locks (SHOW INNODB STATUS)
  by not calling lock_get_n_rec_locks() from lock_print_info_summary() on
  production builds.
   
  Approved by:	Heikki (via IM)
  
  ------------------------------------------------------------------------
  r2524 | vasil | 2008-07-01 10:37:34 +0300 (Tue, 01 Jul 2008) | 29 lines
  
  branches/5.1:
  
  Merge a change from MySQL (this fixes the failing innodb-replace test):
  
    revno: 2659
    committer: Mattias Jonsson <mattiasj@mysql.com>
    branch nick: b31210-51-bugteam
    timestamp: Tue 2008-06-03 13:25:41 +0200
    message:
      Bug#31210: INSERT DELAYED crashes server when used on partitioned tables
        
      Problem was an unclear error message since it could suggest that
      MyISAM did not support INSERT DELAYED.
      Changed the error message to say that DELAYED is not supported by the
      table, instead of the table's storage engine.
      The confusion is that a partitioned table is in somewhat sense using
      the partitioning storage engine, which in turn uses the ordinary
      storage engine. By saying that the table does not support DELAYED we
      do not give any extra informantion about the storage engine or if it
      is partitioned.
    modified:
      mysql-test/r/innodb-replace.result
      mysql-test/t/innodb-replace.test
      mysql-test/t/merge.test
      mysql-test/t/partition_hash.test
      sql/share/errmsg.txt
      sql/sql_insert.cc


------------------------------------------------------------------------
2008-07-01 06:53:40 +00:00
vasil
4c37fb93be branches/zip:
Rewrite the function innodb_plugin_init() to support parameters in
different order (in static and dynamic InnoDB) and to support more
parameters in the static InnoDB.
 
The previous implementation traversed both lists at the same time,
skipping parameters in the dynamic list that do not exist in the static
list. E.g. both lists were allowed to be static=(a, b, c),
dynamic=(a, b, c) or static=(a, b, c), dynamic=(a, b, x, c).
 
With the new implementation they are allowed to be
static=(a, b, c), dynamic=(b, a, c) or
static=(a, b, x, c), dynamic=(b, a, c) in addition.

The new implementation has complexity O(N^2) while the old one was O(N),
but this is acceptable sacrifice provided that innodb_plugin_init() is
called once per InnoDB lifetime and that N=39 currently, and N is not
going to increase much in the future, N=number of the InnoDB parameters.

Suggested by:	Sunny
Approved by:	Sunny
2008-06-19 14:24:45 +00:00
vasil
63ad8ddbd6 branches/zip:
Fix the rpl_ddl mysql-test that produces a warnings:

  master.err: rpl.rpl_ddl: 080611 16:27:01 [Warning] MySQL is closing a connection that has an active InnoDB transaction.  13 row modifications will roll back.

the bug was introduced in r2256, which adds "prebuilt->trx->active_trans = 1;"
in ::add_index() and ::final_drop_index() but never calls innobase_commit() or
innobase_rollback() to set back active_trans to 0.

Also, per Heikki's suggestion we remove the calls to trans_register_ha() from
::add_index() and ::final_drop_index(). Following is the IM discussion that
took place about this:

  --- cut ---
  (17:59:05) vasil: 
          unsigned        active_trans:2; /* 1 - if a transaction in MySQL
                                          is active. 2 - if prepare_commit_mutex
                                          was taken */
  
  (17:59:13) vasil: what about 0?
  (17:59:26) Heikki: Hmm
  (17:59:42) Heikki: Maybe in the other cases :)
  (18:01:00) vasil: 
     2   1369  handler/ha_innodb.cc <<<unknown>>>
               if (trx->active_trans == 0) {
     3   1372  handler/ha_innodb.cc <<<unknown>>>
               trx->active_trans = 1;
  
  (18:01:05) vasil: yes, it can be 0
  (18:01:38) Heikki: Maybe no active transaction => the value is 0
  (18:02:03) vasil: probably yes
  (18:09:09) vasil: 
          /* The flag trx->active_trans is set to 1 in
  
          1. ::external_lock(),
          2. ::start_stmt(),
          3. innobase_query_caching_of_table_permitted(),
          4. innobase_savepoint(),
          5. ::init_table_handle_for_HANDLER(),
          6. innobase_start_trx_and_assign_read_view(),
          7. ::transactional_table_lock()
  
          and it is only set to 0 in a commit or a rollback.
  (18:09:14) vasil: this is no longer true
  (18:09:35) vasil: it is also set to 1 in ::final_drop_index
  (18:09:56) vasil: and in ::add_index()
  (18:12:31) Heikki: Please correct the comment :(
  (18:13:01) vasil: it is not only the comment, I am trying to understand what's wrong
  (18:13:28) Heikki: What is the symptom?
  (18:14:37) vasil: can you find this email and the subsequent one:
  
  From: Vasil Dimov <vasil.dimov@oracle.com>
  To: InnoDB Dev <innodb_dev_ww@oracle.com>
  Subject: Re: innodb - marko - r2256 - in branches/zip: handler include lock
          trx
  Date: Wed, 11 Jun 2008 16:33:47 +0300
  
  (18:15:02) vasil: the symptom is 
  
  master.err: rpl.rpl_ddl: 080611 16:27:01 [Warning] MySQL is closing a connection that has
  +an active InnoDB transaction.  13 row modifications will roll back.
  
  (18:16:22) vasil: My understanding till now is that active_trans is set to 1 in ::add_index() and forgotten like this, never set to 0; I wonder if it should be set to 0 somewhere at the end or not set to 1 at all... or there is more...
  (18:16:31) Heikki: Vasil, ok the problem is that Marko forgets to commit the transaction
  (18:16:55) Heikki: An active transaction has to be committed or rolled back
  (18:17:09) vasil: but i can find this in ::add_index():
  
          /* Commit the data dictionary transaction in order to release
          the table locks on the system tables.  Unfortunately, this
          means that if MySQL crashes while creating a new primary key
          inside row_merge_build_indexes(), indexed_table will not be
          dropped on crash recovery.  Thus, it will become orphaned. */
          trx_commit_for_mysql(trx);
  
  (18:17:27) vasil: but this function does not set active_trans to 0
  (18:17:43) Heikki: Let me look
  (18:19:20) vasil: it is only set to 0 in innobase_commit() and in innobase_rollback()
  (18:20:10) Heikki: Ok
  (18:20:59) Heikki: Hmm...
  (18:21:08) vasil: innobase_commit() calls innobase_commit_low() calls trx_commit_for_mysql()
  innobase_commit() sets active_trans=0
  (18:21:26) Heikki: active_trans is strictly a ha_innodb.cc variable
  (18:21:53) Heikki: It is intended to be used in transactions visible to MySQL
  (18:22:25) Heikki: I think Marko should call innobase_commit()
  (18:23:51) vasil: but still set active_trans=1 inside :add_index() inside handler/handler0alter.cc?
  (18:24:12) Heikki: Hmm
  (18:24:56) Heikki: I think the transaction is NOT really visible to MySQL
  (18:24:57) vasil: 
  > Author: marko
  > Date: 2008-01-25 16:26:07 +0200 (Fri, 25 Jan 2008)
  > New Revision: 2256
  >
  > Log:
  > branches/zip: Fast index creation: Release locks on system tables before
  > creating indexes.  Lock the user table inside the user transaction.
  >
  > enum trx_dict_op: Remove TRX_OP_INDEX_MAY_WAIT.
  >
  > ha_innobase::add_index(): Lock the user tables within prebuilt->trx.
  > Commit the data dictionary transaction before creating indexes.
  >
  > ha_innobase::final_drop_index(): Lock the user table within prebuilt->trx.
  
  (18:26:41) Heikki: Let me look at the old ::create_table()
  (18:27:25) Heikki: Ok, in the old code, the transactions are internal to InnoDB, not visible to MySQL
  (18:27:46) Heikki: I think it is an error to set active_trans=1 inside :add_index() i
  (18:28:11) Heikki: MySQL is not really interested in HOW the engine adds the index. In a transaction or not.
  (18:28:26) vasil: this is the change inside drop_index(), that is supposed to "Lock the user table within prebuilt->trx":
  (18:28:37) vasil: 
  @@ -1093,27 +1101,25 @@ ha_innobase::final_drop_index(
    /* Create a background transaction for the operations on
    the data dictionary tables. */
    trx = trx_allocate_for_mysql();
    trx_start_if_not_started(trx);
   
    trans_register_ha(user_thd, FALSE, ht);
  + prebuilt->trx->active_trans = 1;
   
    trx->mysql_thd = user_thd;
    trx->mysql_query_str = thd_query(user_thd);
   
    /* Flag this transaction as a dictionary operation, so that
  - the data dictionary will be locked in crash recovery.  Prevent
  - warnings if row_merge_lock_table() results in a lock wait,
  - i.e., when another transaction is holding a conflicting lock
  - on the table, e.g., because of SELECT ... FOR UPDATE. */
  - trx_set_dict_operation(trx, TRX_DICT_OP_INDEX_MAY_WAIT);
  + the data dictionary will be locked in crash recovery. */
  + trx_set_dict_operation(trx, TRX_DICT_OP_INDEX);
   
    /* Lock the table exclusively, to ensure that no active
    transaction depends on an index that is being dropped. */
    err = convert_error_code_to_mysql(
  -  row_merge_lock_table(trx, prebuilt->table, LOCK_X),
  +  row_merge_lock_table(prebuilt->trx, prebuilt->table, LOCK_X),
     user_thd);
   
    if (UNIV_UNLIKELY(err)) {
   
     /* Unmark the indexes to be dropped. */
     row_mysql_lock_data_dictionary(trx);
  @@ -1125,14 +1131,12 @@ ha_innobase::final_drop_index(
     }
   
     row_mysql_unlock_data_dictionary(trx);
     goto func_exit;
    }
   
  - trx_set_dict_operation(trx, TRX_DICT_OP_INDEX);
  -
    /* Drop indexes marked to be dropped */
   
    row_mysql_lock_data_dictionary(trx);
   
    index = dict_table_get_first_index(prebuilt->table);
   
  @@ -1159,12 +1163,13 @@ ha_innobase::final_drop_index(
    dict_table_check_for_dup_indexes(prebuilt->table);
   #endif
    row_mysql_unlock_data_dictionary(trx);
   
   func_exit:
    trx_commit_for_mysql(trx);
  + trx_commit_for_mysql(prebuilt->trx);
   
    /* Flush the log to reduce probability that the .frm files and
    the InnoDB data dictionary get out-of-sync if the user runs
    with innodb_flush_log_at_trx_commit = 0 */
   
    log_buffer_flush_to_disk();
  
  (18:28:43) Heikki: Let me look
  (18:29:05) vasil: this is the change inside drop_index(), that is supposed to "Lock the user table within prebuilt->trx"
  (18:29:26) Heikki:   trans_register_ha(user_thd, FALSE, ht);
  + prebuilt->trx->active_trans = 1;
  (18:29:34) Heikki: I think the above code should be removed
  (18:29:53) Heikki: MySQL is not interested in InnoDB's transaction in this case
  (18:30:33) Heikki: Alternatively, we should use innobase_commit() instead of trx_commit_...
  (18:31:01) vasil: but there are many places in ::add_index() where it could return before reaching the trx_commit...
  (18:31:12) vasil: leaving active_traans=1
  (18:31:56) Heikki: Does Marko handle the errors with trx_rollback()?
  (18:32:08) vasil: let me see..
  (18:32:30) Heikki: It is risky to leave error handling to MySQL :(
  (18:32:35) vasil: 
   651         if (UNIV_UNLIKELY(error)) {
   652 err_exit:
   653                 mem_heap_free(heap);
   654                 trx_general_rollback_for_mysql(trx, FALSE, NULL);
   655                 trx_free_for_mysql(trx);
   656                 trx_commit_for_mysql(prebuilt->trx);
   657                 DBUG_RETURN(error);
   658         }
  
  (18:32:43) Heikki: Ok
  (18:33:25) Heikki: Please remove the ha_register... and active_trx =1 ....
  (18:33:42) Heikki: Then check if it prints something
  (18:34:08) Heikki: I believe MySQL is not interested in how the engine does the index build
  (18:34:11) vasil: why remove ha_register?
  (18:34:28) Heikki: Because there is no transaction visible to MySQL
  (18:34:53) vasil: the ha_register call was there from before
  (18:35:09) Heikki: Registers that InnoDB takes part in an SQL statement, so that MySQL knows to
  roll back the statement if the statement results in an error. This MUST be
  called for every SQL statement that may be rolled back by MySQL. Calling this
  several times to register the same statement is allowed, too. 
  (18:36:01) Heikki: Hmm
  (18:36:17) Heikki: Obviously, MySQL does NOT call commit at the end
  (18:36:36) Heikki: Because then innobase_commit() would set active_trx=0!
  (18:37:00) Heikki: Ok, maybe MySQL thinks CREATE INDEX is NOT a transactional statement
  (18:37:21) Heikki: Then, .._register_.. should be removed
  (18:37:51) Heikki: It is logical this way. If it also passes test, even better
  (18:38:21) vasil: ha_registrer in add_index() was added in r1845 and in drop_index() in r2128, let me read the comments..
  (18:38:55) vasil: 
  ------------------------------------------------------------------------
  r1845 | marko | 2007-09-13 13:31:54 +0300 (Thu, 13 Sep 2007) | 3 lines
  
  branches/zip: Move the code related to fast index creation
  (smart ALTER TABLE) from ha_innodb.cc to a separate module, handler0alter.cc.
  
  (18:39:05) Heikki: One thing you must check is that MySQL does write the CREATE INDEX in the binlog, even if we remove the _register_
  (18:39:41) Heikki: I assume Marko did not know if MySQL thinks CREATE INDEX is transactional or not
  (18:39:49) Heikki: He thought it is transactional
  (18:39:53) vasil: 
  ------------------------------------------------------------------------
  r2128 | marko | 2007-11-29 12:34:55 +0200 (Thu, 29 Nov 2007) | 5 lines
  
  branches/zip: ha_innobase::final_drop_index(): Allocate a separate transaction
  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.
  
  (18:40:10) Heikki: Ok
  (18:40:17) vasil: how do you know CREATE INDEX is not transactional?
  (18:40:33) Heikki: You cannot roll it back
  (18:40:44) vasil: ok
  (18:41:03) Heikki: MySQL devs probably thought this way
  (18:44:15) vasil: hmm
  (18:44:21) vasil: about r1845
  (18:45:00) vasil: the comments says "move the code" but it is actually "move and change the code"
  (18:45:28) Heikki: Well
  (18:45:29) vasil: the code that is deleted from ha_innodb is this:
  (18:45:32) vasil: 
  -       update_thd(ha_thd());
  -
  -       heap = mem_heap_create(1024);
  -
  -       /* In case MySQL calls this in the middle of a SELECT query, release
  -       possible adaptive hash latch to avoid deadlocks of threads. */
  -       trx_search_latch_release_if_reserved(check_trx_exists(user_thd));
  -
  -       trx = trx_allocate_for_mysql();
  -       trx_start_if_not_started(trx);
  -
  -       innobase_register_stmt(ht, user_thd);
  -
  -       trx->mysql_thd = user_thd;
  
  (18:45:38) vasil: (in add_index)
  (18:45:48) inaam left the room.
  (18:45:52) vasil: but the new one in handler0alter is this:
  (18:46:16) vasil: 
  +       update_thd(ha_thd());
  +
  +       heap = mem_heap_create(1024);
  +
  +       /* In case MySQL calls this in the middle of a SELECT query, release
  +       possible adaptive hash latch to avoid deadlocks of threads. */
  +       trx_search_latch_release_if_reserved(check_trx_exists(user_thd));
  +
  +       trx = trx_allocate_for_mysql();
  +       trx_start_if_not_started(trx);
  +
  +       trans_register_ha(user_thd, FALSE, ht);
  +
  +       trx->mysql_thd = user_thd;
  
  (18:46:48) vasil: innobase_register_stmt(ht, user_thd); was substituted with trans_register_ha(user_thd, FALSE, ht); during the move
  (18:46:49) Heikki: I do not see how MySQL could call it in the middle of a SELECT query!
  (18:46:59) Heikki: Yes
  (18:47:21) Heikki: Did Marko change innobase_register_stmt() code too?
  (18:48:05) vasil: not in this commit r1845
  (18:48:54) Heikki: Anyway, please test a version where you remove the register thing
  (18:49:08) vasil: and active_trans=1?
  (18:49:15) Heikki: Remove that, too
  (18:49:35) Heikki: innobase_register_stmt(
  /*===================*/
          handlerton*     hton,   /* in: Innobase hton */
          THD*    thd)    /* in: MySQL thd (connection) object */
  {
          DBUG_ASSERT(hton == innodb_hton_ptr);
          /* Register the statement */
          trans_register_ha(thd, FALSE, hton);
  }
  
  (18:50:23) Heikki: looks pretty much the same as what Marko has in the later version
  (18:50:43) vasil: innobase_register_stmt() was added in add_index() in r1584
  (18:50:47) vasil: 
  r1584 | marko | 2007-06-18 15:46:42 +0300 (Mon, 18 Jun 2007) | 12 lines
  
  branches/zip: ha_innobase::add_index(): Split some assertions.
  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.
  
  (18:51:56) Heikki: But it does not seem to invoke it now, because active_trans is left 1!
  (18:54:15) Heikki: Apparently, there has been confusion also among MySQL devs whether CREATE INDEX is transactional or not
  (18:54:45) vasil: :-(
  (18:54:53) Heikki: The most robust way is to handle all commits and rollbacks internally inside InnoDB and not tell MySQL anything about InnoDB's internal transactions
  (18:55:01) Heikki: That is my idea
  (18:55:20) Heikki: Then MySQL cannot spoil the logic of the code
  (18:55:59) vasil: mysql_alter_table() is ~1100 lines
  (18:56:08) vasil: and you suggest what?
  (18:56:43) Heikki: I suggest removing the ..._register_... thing and active_trans = 1
  (18:57:08) Heikki: Those things tell MySQL that there is a transaction going on
  (18:57:14) Heikki: Better not to tell
  (18:57:29) vasil: and possibly ignoring the above comment in r1584, "Call innobase_register_stmt() in order to work around a MySQL bug
  in mysql_alter_table()........."
  (18:57:32) vasil: ?
  (18:57:36) Heikki: Yes
  (18:57:38) vasil: ok
  (18:57:44) vasil: same for drop_index?
  (18:57:48) Heikki: Yes
  (18:58:51) vasil: testing
  Index: handler/handler0alter.cc
  ===================================================================
  --- handler/handler0alter.cc (revision 2498)
  +++ handler/handler0alter.cc (working copy)
  @@ -632,14 +632,14 @@ ha_innobase::add_index(
   
    /* Create a background transaction for the operations on
    the data dictionary tables. */
    trx = trx_allocate_for_mysql();
    trx_start_if_not_started(trx);
   
  - trans_register_ha(user_thd, FALSE, ht);
  - prebuilt->trx->active_trans = 1;
  + //trans_register_ha(user_thd, FALSE, ht);
  + //prebuilt->trx->active_trans = 1;
   
    trx->mysql_thd = user_thd;
    trx->mysql_query_str = thd_query(user_thd);
   
    innodb_table = indexed_table
     = dict_table_get(prebuilt->table->name, FALSE);
  @@ -1081,14 +1081,14 @@ ha_innobase::final_drop_index(
   
    /* Create a background transaction for the operations on
    the data dictionary tables. */
    trx = trx_allocate_for_mysql();
    trx_start_if_not_started(trx);
   
  - trans_register_ha(user_thd, FALSE, ht);
  - prebuilt->trx->active_trans = 1;
  + //trans_register_ha(user_thd, FALSE, ht);
  + //prebuilt->trx->active_trans = 1;
   
    trx->mysql_thd = user_thd;
    trx->mysql_query_str = thd_query(user_thd);
   
    /* Flag this transaction as a dictionary operation, so that
    the data dictionary will be locked in crash recovery. */
  
  (18:59:07) vasil: not warnings
  (18:59:22) Heikki: Did it create the indexes
  (18:59:36) vasil: I did test only removing active_trans=1 and it removed the warnings too
  (18:59:38) vasil: dunno
  (18:59:54) Heikki: That is the most important thing to check :)
  (19:00:10) vasil: :)
  (19:00:38) vasil: it is some mysqltest that is 610 lines
  (19:00:48) vasil: and it happens at the end
  (19:01:02) vasil: lets see how may add index statements...
  (19:01:11) vasil: 0
  (19:01:26) Heikki: Mostly I am concerned that MySQL might work wrong without that _register_ thing
  (19:03:28) vasil: could be
  (19:03:49) Heikki: You need to check it still calls ::add_index()
  (19:05:15) vasil: well, the change we made is inside ::add_index() how could it result in mysql stopping to call ::add_index()?
  (19:05:39) vasil: if it calls it twice...
  (19:05:43) Heikki: :-D
  (19:08:34) vasil: I guess it must have created the index, because the test is doing SHOW INDEX after CREATE INDEX and after DROP INDEX
  (19:08:43) vasil: the test would have failed if the index was not created
  (19:09:10) Heikki: You need to check that a query using that index will have the right EXPLAIN and result
  (19:15:04) vasil: this is with the patch:
  +CREATE TABLE t (a INT) ENGINE=innodb;
  +CREATE INDEX ti ON t(a);
  +INSERT INTO t VALUES (1), (2), (3);
  +EXPLAIN SELECT * FROM t WHERE a=2;
  +id select_type table type possible_keys key key_len ref rows Extra
  +1 SIMPLE t ref ti ti 5 const 1 Using where; Using index
  +SELECT * FROM t WHERE a=2;
  +a
  +2
  
  (19:15:15) Heikki: :)
  (19:15:46) vasil: this is with the original code:
  +CREATE TABLE t (a INT) ENGINE=innodb;
  +CREATE INDEX ti ON t(a);
  +INSERT INTO t VALUES (1), (2), (3);
  +EXPLAIN SELECT * FROM t WHERE a=2;
  +id select_type table type possible_keys key key_len ref rows Extra
  +1 SIMPLE t ref ti ti 5 const 1 Using where; Using index
  +SELECT * FROM t WHERE a=2;
  +a
  +2
  
  (19:15:59) vasil: it is the same
  (19:16:06) vasil: do you think this is sufficient?
  (19:16:20) Heikki: No, you need to do some manual tests, too
  (19:16:28) vasil: this is manual test
  (19:16:37) Heikki: Several of them
  (19:16:46) vasil: what should they do?
  (19:17:13) Heikki: Test tables of different sizes, different indexes
  (19:17:27) Heikki: CREATE several indexes at a time
  (19:19:14) Heikki: Dinner time -->
  --- cut ---

Approved by:	Heikki
2008-06-19 14:19:04 +00:00
vasil
b21c94dc01 branches/zip: Merge 2437:2485 from branches/5.1:
(r2478 was skipped for the obvious reason)

  ------------------------------------------------------------------------
  r2464 | vasil | 2008-05-19 17:59:42 +0300 (Mon, 19 May 2008) | 9 lines
  
  branches/5.1:
  
  Fix Bug#36600 SHOW STATUS takes a lot of CPU in buf_get_latched_pages_number
  
  by removing the Innodb_buffer_pool_pages_latched variable from
  SHOW STATUS output in non-UNIV_DEBUG compilation.
   
  Approved by:	Heikki
  
  ------------------------------------------------------------------------
  r2466 | calvin | 2008-05-20 01:37:14 +0300 (Tue, 20 May 2008) | 12 lines
  
  branches/5.1:
  
  Fix Bug#11894 innodb_file_per_table crashes w/ Windows .sym symbolic
  link hack
  
  The crash was due to un-handled error 3 (path not found). In the case
  of file per table, change the call to os_file_handle_error_no_exit()
  from os_file_handle_error(). Also, checks for full path pattern during
  table create (Windows only), which is used in symbolic link and temp
  table creation.
  
  Approved by:	Heikki
  ------------------------------------------------------------------------
  r2478 | sunny | 2008-05-23 08:29:08 +0300 (Fri, 23 May 2008) | 3 lines
  
  branches/5.1: Fix for bug# 36793. This is a back port from branches/zip. This
  code has been tested on a big-endian machine too.
  
  ------------------------------------------------------------------------
  r2480 | vasil | 2008-05-27 11:40:07 +0300 (Tue, 27 May 2008) | 11 lines
  
  branches/5.1:
  
  Fix Bug#36819 ut_usectime does not handle errors from gettimeofday
  
  by retrying gettimeofday() several times if it fails in ut_usectime().
  If it fails on all calls then return error to the caller to be handled
  at higher level.
  
  Update the variable innodb_row_lock_time_max in SHOW STATUS output only
  if ut_usectime() was successful.
  
  ------------------------------------------------------------------------
  r2482 | sunny | 2008-05-28 12:18:35 +0300 (Wed, 28 May 2008) | 5 lines
  
  branches/5.1: Fix for Bug#35602, "Failed to read auto-increment value from
  storage engine". The test for REPLACE was an error of ommission since it's
  classified as a simple INSERT. For REPLACE statements we don't acquire
  the special AUTOINC lock for AUTOINC_NEW_STYLE_LOCKING with this fix.
  
  ------------------------------------------------------------------------
  r2485 | vasil | 2008-05-28 16:01:14 +0300 (Wed, 28 May 2008) | 9 lines
  
  branches/5.1:
  
  Fix Bug#36149 Read buffer overflow in srv0start.c found during "make test"
  
  Use strncmp(3) instead of memcmp(3) to avoid reading past end of the string
  if it is empty (*str == '\0'). This bug is _not_ a buffer overflow.
  
  Discussed with:	Sunny (via IM)
  
  ------------------------------------------------------------------------
2008-06-06 15:24:58 +00:00
vasil
273876856d branches/zip:
Non-functional change - conform to our coding style and make more readbale
(hopefully) by not using variables with names "v" and "w".
2008-05-19 08:35:38 +00:00
sunny
1cd233d2d7 branches/zip: Non functional change to error message. 2008-05-06 22:29:53 +00:00
calvin
fc02f76d78 branches/zip:
Implement the system tablespace tagging described on the wiki:
https://svn.innodb.com/innobase/InnoDB_version_and_feature_compatibility

A brief description of the changes:

* The file format tag will be saved in the trx system page, starting at
  (UNIV_PAGE_SIZE - 16) for 8 bytes.
* The configuration parameter innodb_file_format_check is introduced.
  This variable can be set to on/off and any of the supported file
  formats in the configuration file, but can only be set to any of
  the supported file formats during runtime. The default is on.
* During table create/open, check the current file format against
  the max in file_format_max. If the current file format is newer,
  update file_format_max and tag the system tablespace with the
  newer one in a normal mtr.
* During startup, write the tag to the error log and check it against
  DICT_TF_FORMAT_MAX. Refuse to start with error, if
  -- DICT_TF_FORMAT_MAX < the tag, and
  -- innodb_file_format_check is ON
  Print out a warning , if
  -- DICT_TF_FORMAT_MAX < the tag, but
  -- innodb_file_format_check is off
* The system tablespace tag is re-settable using:
  set innodb_file_format_check = <file_format>

Approved by:	Sunny
2008-05-06 15:00:25 +00:00
vasil
3bad6e2511 branches/zip:
Add InnoDB version in these places:
 
* In INFORMATION_SCHEMA.PLUGINS.PLUGIN_VERSION, only 1.2 out of 1.2.3
  because MySQL supports only one dot there
 
* At startup:
  "080501 12:28:06 InnoDB Plugin 1.0.1 started; log sequence number 46509"

* In a server variable innodb_version;
  mysql> select @@innodb_version;
  +------------------+
  | @@innodb_version |
  +------------------+
  | 1.0.1            |
  +------------------+

Approved by:	Sunny
2008-05-06 11:10:09 +00:00
vasil
2daf8121c0 branches/zip:
Allow InnoDB I_S plugins to be installed when InnoDB storage engine is
not installed but show empty tables when SELECTing from them in this
case. Set srv_was_started to FALSE at the end of
innobase_shutdown_for_mysql() so the I_S plugins can detect if InnoDB is
uninstalled.
 
This is needed to workaround the MySQL
Bug#36399 Double free bug when INFORMATION_SCHEMA plugin init function fails
and is more flexible as it allows I_S plugins to be installed before the
InnoDB plugin and detects if the latter is uninstalled after this.

Approved by:	Heikki
2008-05-06 10:01:41 +00:00
vasil
d1e11ffc45 branches/zip:
Change an error message.

Suggested by:	Ken
2008-05-04 07:06:59 +00:00
vasil
9dd184effe branches/zip: Merge 2423:2437 from branches/5.1:
------------------------------------------------------------------------
  r2429 | vasil | 2008-04-30 11:19:06 +0300 (Wed, 30 Apr 2008) | 10 lines
  
  branches/5.1:
  
  * Use INNODB_CFLAGS insead of cluttering CFLAGS with InnoDB specific
    flags. CFLAGS are used to compile every file in the MySQL source tree.
  
  * Add INNODB_DYNAMIC_CFLAGS to the flags of the dynamic plugin and use
    -prefer-non-pic to make the dynamic plugin faster on i386.
  
  Approved by:	Sunny
  
  ------------------------------------------------------------------------
  r2430 | vasil | 2008-04-30 11:48:35 +0300 (Wed, 30 Apr 2008) | 8 lines
  
  branches/5.1:
  
  Use CFLAGS instead of INNODB_CFLAGS to avoid having incompatible flags
  inserted in CFLAGS and INNODB_CFLAGS and to avoid compiling mysql and
  innodb with different flags.
  
  Discussed with:	Sunny
  
  ------------------------------------------------------------------------
  r2431 | vasil | 2008-04-30 11:54:49 +0300 (Wed, 30 Apr 2008) | 4 lines
  
  branches/5.1:
  
  Fix r2430, it should be CFLAGS="$CFLAGS ..." not CFLAGS="..."
  
  ------------------------------------------------------------------------
  r2432 | vasil | 2008-04-30 11:58:38 +0300 (Wed, 30 Apr 2008) | 4 lines
  
  branches/5.1:
  
  Non-functional change: use tabs for indentation in plug.in.
  
  ------------------------------------------------------------------------
  r2433 | vasil | 2008-04-30 12:02:35 +0300 (Wed, 30 Apr 2008) | 5 lines
  
  branches/5.1:
  
  Add vim modeline to hint it that plug.in is a config file
  so it can be colorized.
  
  ------------------------------------------------------------------------
  r2434 | vasil | 2008-04-30 18:45:44 +0300 (Wed, 30 Apr 2008) | 17 lines
  
  branches/5.1:
  
  Merge changes from MySQL:
  
    ChangeSet@1.2645, 2007-12-19 13:24:43+00:00, jperkin@chorlton.adsl.perkin.org.uk +14 -0
      Add new pkgplugindir handling to seperate plugins from libraries,
      and allow override for binary distributions.  Extend mysql_config
      to print compiled-in plugin location for third-party plugins to
      use.  Resolves bug#31736.
  
  and
  
    ChangeSet@1.2646, 2008-01-02 13:00:46+00:00, jperkin@chorlton.adsl.perkin.org.uk +11 -0
      Use pkglibdir to simplify pkgplugindir, and fix the path in a
      couple of Makefiles.  Continuation of the fix for bug#31736.
  
  
  ------------------------------------------------------------------------
  r2435 | vasil | 2008-04-30 19:04:36 +0300 (Wed, 30 Apr 2008) | 10 lines
  
  branches/5.1:
  
  Merge change from MySQL:
  
    ChangeSet@1.2563, 2008-03-18 19:42:04+04:00, gluh@mysql.com +1 -0
      Bug#35406 5.1-opt crashes on select from I_S.REFERENTIAL_CONSTRAINTS
      added intialization of f_key_info.referenced_key_name for the case when
      referenced table is dropped
  
  
  ------------------------------------------------------------------------
  r2436 | vasil | 2008-04-30 19:15:46 +0300 (Wed, 30 Apr 2008) | 7 lines
  
  branches/5.1:
  
  Non-functional white space change in Makefile.am:
  Use tabs for indentation and be consistent about spaces around the
  equal sign.
  
  
  ------------------------------------------------------------------------
  r2437 | vasil | 2008-04-30 20:36:11 +0300 (Wed, 30 Apr 2008) | 8 lines
  
  branches/5.1:
  
  Fix Bug#36434 ha_innodb.so is installed in the wrong directory
  
  Change pkglib_LTLIBRARIES with pkgplugin_LTLIBRARIES which has been
  forgotten in this commit: http://lists.mysql.com/commits/40206
  
  
  ------------------------------------------------------------------------
2008-04-30 16:59:16 +00:00
vasil
55db138b95 branches/zip: Merge 2384:2423 from branches/5.1:
------------------------------------------------------------------------
  r2386 | vasil | 2008-03-27 07:45:02 +0200 (Thu, 27 Mar 2008) | 22 lines
  
  branches/5.1:
  
  Merge change from MySQL (this fixes the failing innodb test):
  
  ChangeSet@1.1810.3601.4, 2008-02-07 02:33:21+04:00, gshchepa@host.loc +9 -0
    Fixed bug#30059.
    Server handles truncation for assignment of too-long values
    into CHAR/VARCHAR/TEXT columns in a different ways when the
    truncated characters are spaces:
    1. CHAR(N) columns silently ignore end-space truncation;
    2. TEXT columns post a truncation warning/error in the
       non-strict/strict mode.
    3. VARCHAR columns always post a truncation note in
       any mode.
  
    Space truncation processing has been synchronised over
    CHAR/VARCHAR/TEXT columns: current behavior of VARCHAR
    columns has been propagated as standard.
  
    Binary-encoded string/BLOB columns are not affected.
  
  
  ------------------------------------------------------------------------
  r2387 | vasil | 2008-03-27 08:49:05 +0200 (Thu, 27 Mar 2008) | 8 lines
  
  branches/5.1:
  
  Check whether *trx->mysql_query_str is != NULL in addition to
  trx->mysql_query_str. This adds more safety.
  
  This may or may not fix Bug#35226 RBR event crashes slave.
  
  
  ------------------------------------------------------------------------
  r2388 | vasil | 2008-03-27 14:02:34 +0200 (Thu, 27 Mar 2008) | 7 lines
  
  branches/5.1:
  
  Swap the order in which mysql_thd, mysql_query_str and *mysql_query_str
  are checked for non-NULL.
  
  Suggested by:	Marko
  
  ------------------------------------------------------------------------
  r2419 | vasil | 2008-04-23 19:08:06 +0300 (Wed, 23 Apr 2008) | 9 lines
  
  branches/5.1:
  
  Change the fix for Bug#32440 to show bytes instead of kilobytes in
  INFORMATION_SCHEMA.TABLES.DATA_FREE.
  
  Suggested by:	Domas Mituzas <domas@mysql.com>
  Approved by:	Heikki
  
  
  ------------------------------------------------------------------------
  r2420 | calvin | 2008-04-24 15:25:30 +0300 (Thu, 24 Apr 2008) | 4 lines
  
  branches/5.1: Fix bug#29507 TRUNCATE shows to many rows effected
  
  In InnoDB, the row count is only a rough estimate used by SQL
  optimization. InnoDB is now return row count 0 for TRUNCATE operation.
  ------------------------------------------------------------------------
  r2421 | calvin | 2008-04-24 15:32:30 +0300 (Thu, 24 Apr 2008) | 6 lines
  
  branches/5.1: Fix bug#35537 - Innodb doesn't increment handler_update
  and handler_delete
  
  Add the calls to ha_statistic_increment() in ha_innobase::delete_row()
  and ha_innobase::update_row().
  
  ------------------------------------------------------------------------
  r2422 | vasil | 2008-04-24 16:00:30 +0300 (Thu, 24 Apr 2008) | 11 lines
  
  branches/5.1:
  
  Fix Bug#36169 create innodb compressed table with too large row size crashed
  
  Sometimes it is possible that
  row_drop_table_for_mysql(index->table_name, trx, FALSE); is invoked in
  row_create_index_for_mysql() when the index object is freed so copy the
  table name to a safe place beforehand and use the copy.
  
  Approved by:	Sunny
  
  ------------------------------------------------------------------------
2008-04-30 05:42:56 +00:00
vasil
03a3d076d6 branches/zip:
Fix Mantis issue#34 https://svn.innodb.com/mantis/view.php?id=34
"I_S plugins should refuse to load if the storage engine plugin is not loaded"
and MySQL Bug#36310 http://bugs.mysql.com/36310
"InnoDB plugin crash"

* Make srv_was_started public
* Set srv_was_started at the end of innobase_start_or_create_for_mysql()
  so it is not set to TRUE if innodb encounters some startup error
* Refuse to start any of the I_S plugins if srv_was_started is not TRUE

Approved by:	Heikki
2008-04-29 14:57:06 +00:00
sunny
a0c86c47e4 branches/zip: Remove spaces and fix an uninitialized variable compiler warning. 2008-04-11 09:58:17 +00:00