Browse Source

branches/innodb+: Merge revisions r5971:6130 from branches/zip.

------------------------------------------------------------------------
  r5971 | marko | 2009-09-23 23:03:51 +1000 (Wed, 23 Sep 2009) | 2 lines

  branches/zip: os_file_pwrite(): Make the code compile in InnoDB Hot Backup
  when the pwrite system call is not available.
  ------------------------------------------------------------------------
  r5972 | marko | 2009-09-24 05:44:52 +1000 (Thu, 24 Sep 2009) | 5 lines

  branches/zip: fil_node_open_file(): In InnoDB Hot Backup,
  determine the page size of single-file tablespaces before computing
    the file node size.  Otherwise, the space->size of compressed tablespaces
  would be computed with UNIV_PAGE_SIZE instead of key_block_size.
  This should fix Issue #313.
  ------------------------------------------------------------------------
  r5973 | marko | 2009-09-24 05:53:21 +1000 (Thu, 24 Sep 2009) | 2 lines

  branches/zip: recv_add_to_hash_table():
  Simplify obfuscated pointer arithmetics.
  ------------------------------------------------------------------------
  r5978 | marko | 2009-09-24 17:47:56 +1000 (Thu, 24 Sep 2009) | 1 line

  branches/zip: Fix warnings and errors when UNIV_HOTBACKUP is defined.
  ------------------------------------------------------------------------
  r5979 | marko | 2009-09-24 20:16:10 +1000 (Thu, 24 Sep 2009) | 4 lines

  branches/zip: ha_innodb.cc: Define MYSQL_PLUGIN_IMPORT when necessary.
  This preprocessor symbol has been recently introduced in MySQL 5.1.
  The InnoDB Plugin should remain source compatible with MySQL 5.1.24
  and later.
  ------------------------------------------------------------------------
  r5988 | calvin | 2009-09-26 05:14:43 +1000 (Sat, 26 Sep 2009) | 8 lines

  branches/zip: fix bug#47055 unconditional exit(1) on ERROR_WORKING_SET_QUOTA
  1453 (0x5AD) for InnoDB backend

  When error ERROR_WORKING_SET_QUOTA or ERROR_NO_SYSTEM_RESOURCES
  occurs, yields for 100ms and retries the operation.

  Approved by: Heikki (on IM)

  ------------------------------------------------------------------------
  r5992 | vasil | 2009-09-28 17:10:29 +1000 (Mon, 28 Sep 2009) | 4 lines

  branches/zip:

  Add ChangeLog entry for c5988.

  ------------------------------------------------------------------------
  r5994 | marko | 2009-09-28 18:33:59 +1000 (Mon, 28 Sep 2009) | 17 lines

  branches/zip: Try to prevent the reuse of tablespace identifiers after
  InnoDB has crashed during table creation.  Also, refuse to start if
  files with duplicate tablespace identifiers are encountered.

    fil_node_create(): Update fil_system->max_assigned_id.  This should
  prevent the reuse of a space->id when InnoDB does a full crash
  recovery and invokes fil_load_single_table_tablespaces().  Normally,
  fil_system->max_assigned_id is initialized from
  SELECT MAX(ID) FROM SYS_TABLES.

  fil_open_single_table_tablespace(): Return FALSE when
  fil_space_create() fails.

  fil_load_single_table_tablespace(): Exit if fil_space_create() fails
  and innodb_force_recovery=0.

  rb://173 approved by Heikki Tuuri.  This addresses Issue #335.
  ------------------------------------------------------------------------
  r5995 | marko | 2009-09-28 18:52:25 +1000 (Mon, 28 Sep 2009) | 17 lines

  branches/zip: Do not write to PAGE_INDEX_ID after page creation,
  not even when restoring an uncompressed page after a compression failure.

  btr_page_reorganize_low(): On compression failure, do not restore
  those page header fields that should not be affected by the
  reorganization.  Instead, compare the fields.

  page_zip_decompress(): Add the parameter ibool all, for copying all
  page header fields.  Pass the parameter all=TRUE on block read
  completion, redo log application, and page_zip_validate(); pass
  all=FALSE in all other cases.

  page_zip_reorganize(): Do not restore the uncompressed page on
  failure.  It will be restored (to pre-modification state) by the
  caller anyway.

  rb://167, Issue #346
  ------------------------------------------------------------------------
  r5996 | marko | 2009-09-28 22:46:02 +1000 (Mon, 28 Sep 2009) | 4 lines

  branches/zip: Address Issue #350 in comments.

  lock_rec_queue_validate(), lock_rec_queue_validate(): Note that
  this debug code may violate the latching order and cause deadlocks.
  ------------------------------------------------------------------------
  r5997 | marko | 2009-09-28 23:03:58 +1000 (Mon, 28 Sep 2009) | 12 lines

  branches/zip: Remove an assertion failure when the InnoDB data dictionary
  is inconsistent with the MySQL .frm file.

  ha_innobase::index_read(): When the index cannot be found,
  return an error.

  ha_innobase::change_active_index(): When prebuilt->index == NULL,
  set also prebuilt->index_usable = FALSE.  This is not needed for
  correctness, because prebuilt->index_usable is only checked by
  row_search_for_mysql(), which requires prebuilt->index != NULL.

  This addresses Issue #349.  Approved by Heikki Tuuri over IM.
  ------------------------------------------------------------------------
  r6005 | vasil | 2009-09-29 18:09:52 +1000 (Tue, 29 Sep 2009) | 4 lines

  branches/zip:

  ChangeLog: wrap around 78th column, not earlier.

  ------------------------------------------------------------------------
  r6006 | vasil | 2009-09-29 20:15:25 +1000 (Tue, 29 Sep 2009) | 4 lines

  branches/zip:

  Add ChangeLog entry for the release of 1.0.4.

  ------------------------------------------------------------------------
  r6007 | vasil | 2009-09-29 23:19:59 +1000 (Tue, 29 Sep 2009) | 6 lines

  branches/zip:

  Fix the year, should be 2009.

  Pointed by:	Calvin

  ------------------------------------------------------------------------
  r6026 | marko | 2009-09-30 17:18:24 +1000 (Wed, 30 Sep 2009) | 1 line

  branches/zip: Add some debug assertions for checking FSEG_MAGIC_N.
  ------------------------------------------------------------------------
  r6028 | marko | 2009-09-30 23:55:23 +1000 (Wed, 30 Sep 2009) | 3 lines

  branches/zip: recv_no_log_write: New debug flag for tracking down
  Mantis Issue #347.  No modifications should be made to the database
  while recv_apply_hashed_log_recs() is about to complete.
  ------------------------------------------------------------------------
  r6029 | calvin | 2009-10-01 06:32:02 +1000 (Thu, 01 Oct 2009) | 4 lines

    branches/zip: non-functional changes

  Fix typo.

  ------------------------------------------------------------------------
  r6031 | marko | 2009-10-01 21:24:33 +1000 (Thu, 01 Oct 2009) | 49 lines

  branches/zip: Clean up after a crash during DROP INDEX.
  When InnoDB crashes while dropping an index, ensure that
  the index will be completely dropped during crash recovery.

  row_merge_drop_index(): Before dropping an index, rename the index to
  start with TEMP_INDEX_PREFIX_STR and commit the change, so that
  row_merge_drop_temp_indexes() will drop the index after crash
  recovery if the server crashes while dropping the index.

  fseg_inode_try_get(): New function, forked from fseg_inode_get().
  Return NULL if the file segment index node is free.

  fseg_inode_get(): Assert that the file segment index node is not free.

  fseg_free_step(): If the file segment index node is already free,
  print a diagnostic message and return TRUE.

  fsp_free_seg_inode(): Write a nonzero number to FSEG_MAGIC_N, so that
  allocated-and-freed file segment index nodes can be better
  distinguished from uninitialized ones.

  This is rb://174, addressing Issue #348.

  Tested by restarting mysqld upon the completion of the added
  log_write_up_to() invocation below, during DROP INDEX.  The index was
  dropped after crash recovery, and re-issuing the DROP INDEX did not
  crash the server.
    
    Index: btr/btr0btr.c
    ===================================================================
    --- btr/btr0btr.c	(revision 6026)
    +++ btr/btr0btr.c	(working copy)
    @@ -42,6 +42,7 @@ Created 6/2/1994 Heikki Tuuri
     #include "ibuf0ibuf.h"
     #include "trx0trx.h"
    +#include "log0log.h"
     
     /*
     Latching strategy of the InnoDB B-tree
     --------------------------------------
    @@ -873,6 +874,8 @@ leaf_loop:
     
   		  goto leaf_loop;
   	  }
    +
    +	log_write_up_to(mtr.end_lsn, LOG_WAIT_ALL_GROUPS, TRUE);
     top_loop:
   	  mtr_start(&mtr);

  ------------------------------------------------------------------------
  r6033 | calvin | 2009-10-02 06:19:46 +1000 (Fri, 02 Oct 2009) | 4 lines

  branches/zip: fix a typo in error message

  Reported as bug#47763.

  ------------------------------------------------------------------------
  r6043 | inaam | 2009-10-06 01:45:35 +1100 (Tue, 06 Oct 2009) | 12 lines

  branches/zip  rb://176

  Do not invalidate buffer pool while an LRU batch is active. Added
  code to buf_pool_invalidate() to wait for the running batches to finish.

  This patch also resets the state of buf_pool struct at invalidation. This
  addresses the concern where buf_pool->freed_page_clock becomes non-zero
  because we read in a system tablespace page for file format info at
  startup.

  Approved by: Marko

  ------------------------------------------------------------------------
  r6044 | pekka | 2009-10-07 01:44:54 +1100 (Wed, 07 Oct 2009) | 5 lines

  branches/zip:
  Add os_file_is_same() function for Hot Backup (inside ifdef UNIV_HOTBACKUP).
  This is part of the fix for Issue #186.
  Note! The Windows implementation is incomplete.

  ------------------------------------------------------------------------
  r6046 | pekka | 2009-10-08 20:24:56 +1100 (Thu, 08 Oct 2009) | 3 lines

  branches/zip: Revert r6044 which added os_file_is_same() function
  (issue#186). This functionality is moved to Hot Backup source tree.

  ------------------------------------------------------------------------
  r6048 | vasil | 2009-10-09 16:42:55 +1100 (Fri, 09 Oct 2009) | 16 lines

  branches/zip:

  When scanning a directory readdir() is called and stat() after it,
  if a file is deleted between the two calls stat will fail and the
  whole precedure will fail. Change this behavior to continue with the
  next entry if stat() fails because of nonexistent file. This is
  transparent change as it will make it look as if the file was deleted
  before the readdir() call.

  This change is needed in order to fix
  https://svn.innodb.com/mantis/view.php?id=174
  in which we need to abort if os_file_readdir_next_file()
  encounters "real" errors.

  Approved by:	Marko, Pekka (rb://177)

  ------------------------------------------------------------------------
  r6049 | vasil | 2009-10-10 03:05:26 +1100 (Sat, 10 Oct 2009) | 7 lines

  branches/zip:

  Fix compilation warning in Hot Backup:

  innodb/fil/fil0fil.c: In function 'fil_load_single_table_tablespace':
  innodb/fil/fil0fil.c:3253: warning: format '%lld' expects type 'long long int', but argument 6 has type 'ib_int64_t'

  ------------------------------------------------------------------------
  r6064 | calvin | 2009-10-14 02:23:35 +1100 (Wed, 14 Oct 2009) | 4 lines

  branches/zip: non-functional changes

  Changes from MySQL to fix build issue.

  ------------------------------------------------------------------------
  r6065 | inaam | 2009-10-14 04:43:13 +1100 (Wed, 14 Oct 2009) | 7 lines

  branches/zip rb://182

  Call fsync() on datafiles after a batch of pages is written to disk
  even when skip_innodb_doublewrite is set.

  Approved by: Heikki

  ------------------------------------------------------------------------
  r6080 | sunny | 2009-10-15 09:29:01 +1100 (Thu, 15 Oct 2009) | 3 lines

  branches/zip: Change page_mem_alloc_free() to inline.
  Fix Bug #47058 - Failure to compile innodb_plugin on solaris 10u7 + spro cc/CC 5.10

  ------------------------------------------------------------------------
  r6084 | vasil | 2009-10-15 16:21:17 +1100 (Thu, 15 Oct 2009) | 4 lines

  branches/zip:

  Add ChangeLog entry for r6080.

  ------------------------------------------------------------------------
  r6095 | vasil | 2009-10-20 00:04:59 +1100 (Tue, 20 Oct 2009) | 7 lines

  branches/zip:

  Fix Bug#47808 innodb_information_schema.test fails when run under valgrind 

  by using the wait_until_rows_count macro that loops until the number of
  rows becomes 14 instead of sleep 0.1, which is obviously very fragile.

  ------------------------------------------------------------------------
  r6096 | vasil | 2009-10-20 00:06:09 +1100 (Tue, 20 Oct 2009) | 4 lines

  branches/zip:

  Add ChangeLog entry for r6095.

  ------------------------------------------------------------------------
  r6099 | jyang | 2009-10-22 13:58:39 +1100 (Thu, 22 Oct 2009) | 7 lines

  branches/zip: Port bug #46000 related changes from 5.1 to zip
  branch. Due to different code path for creating index in zip
  branch comparing to 5.1), the index reserved name check function
  is extended to be used in ha_innobase::add_index(). 
  rb://190  Approved by: Marko


  ------------------------------------------------------------------------
  r6100 | jyang | 2009-10-22 14:51:07 +1100 (Thu, 22 Oct 2009) | 6 lines

  branches/zip: As a request from mysql, WARN_LEVEL_ERROR cannot
  be used for push_warning_* call any more. Switch to 
  WARN_LEVEL_WARN. Bug #47233.
  rb://172 approved by Sunny Bains and Marko.


  ------------------------------------------------------------------------
  r6101 | jyang | 2009-10-23 19:45:50 +1100 (Fri, 23 Oct 2009) | 7 lines
    
  branches/zip: Update test result with the WARN_LEVEL_ERROR
  to WARN_LEVEL_WARN change. This is the same result as 
  submitted in rb://172 review, which approved by Sunny Bains
  and Marko.

  ------------------------------------------------------------------------
  r6102 | marko | 2009-10-26 18:32:23 +1100 (Mon, 26 Oct 2009) | 1 line

  branches/zip: row_prebuilt_struct::prebuilts: Unused field, remove.
  ------------------------------------------------------------------------
  r6103 | marko | 2009-10-27 00:46:18 +1100 (Tue, 27 Oct 2009) | 4 lines

  branches/zip: row_ins_alloc_sys_fields(): Zero out the system columns
  DB_TRX_ID, DB_ROLL_PTR and DB_ROW_ID, in order to avoid harmless
  Valgrind warnings about uninitialized data.  (The warnings were
  harmless, because the fields would be initialized at a later stage.)
  ------------------------------------------------------------------------
  r6105 | calvin | 2009-10-28 09:05:52 +1100 (Wed, 28 Oct 2009) | 6 lines

  branches/zip: backport r3848 from 6.0 branch

  ----
      branches/6.0: innobase_start_or_create_for_mysql(): Make the 10 MB
      minimum tablespace limit independent of UNIV_PAGE_SIZE. (Bug #41490)

  ------------------------------------------------------------------------
  r6107 | marko | 2009-10-29 01:10:34 +1100 (Thu, 29 Oct 2009) | 5 lines

  branches/zip: buf_page_set_old(): Improve UNIV_LRU_DEBUG diagnostics
  in order to catch the buf_pool->LRU_old corruption reported in Issue #381.

  buf_LRU_old_init(): Set the property from the tail towards the front
  of the buf_pool->LRU list, in order not to trip the debug check.
  ------------------------------------------------------------------------
  r6108 | calvin | 2009-10-29 16:58:04 +1100 (Thu, 29 Oct 2009) | 5 lines

  branches/zip: close file handle when building with UNIV_HOTBACKUP

  The change does not affect regular InnoDB engine. Confirmed by
  Marko.

  ------------------------------------------------------------------------
  r6109 | jyang | 2009-10-29 19:37:32 +1100 (Thu, 29 Oct 2009) | 7 lines

  branches/zip: In os_mem_alloc_large(), if we fail to attach
  the shared memory, reset memory pointer ptr to NULL, and
   allocate memory from conventional pool.
  Bug #48237 Error handling in os_mem_alloc_large appears to be incorrect
  rb://198  Approved by: Marko


  ------------------------------------------------------------------------
  r6110 | marko | 2009-10-29 21:44:57 +1100 (Thu, 29 Oct 2009) | 2 lines

  branches/zip: Makefile.am (INCLUDES): Merge a change from MySQL:
  Use $(srcdir)/include instead of $(top_srcdir)/storage/innobase/include.
  ------------------------------------------------------------------------
  r6111 | marko | 2009-10-29 22:04:11 +1100 (Thu, 29 Oct 2009) | 33 lines

  branches/zip: Fix corruption of buf_pool->LRU_old and improve debug assertions.
  This was reported as Issue #381.

  buf_page_set_old(): Assert that blocks may only be set old if
  buf_pool->LRU_old is initialized and buf_pool->LRU_old_len is nonzero.
  Assert that buf_pool->LRU_old points to the block at the old/new boundary.

  buf_LRU_old_adjust_len(): Invoke buf_page_set_old() after adjusting
  buf_pool->LRU_old and buf_pool->LRU_old_len, in order not to violate
  the added assertions.

  buf_LRU_old_init(): Replace buf_page_set_old() with a direct
  assignment to bpage->old, because these loops that initialize all the
  blocks would temporarily violate the assertions about
  buf_pool->LRU_old.

  buf_LRU_remove_block(): When setting buf_pool->LRU_old = NULL, also
  clear all bpage->old flags and set buf_pool->LRU_old_len = 0.

  buf_LRU_add_block_to_end_low(), buf_LRU_add_block_low(): Move the
  buf_page_set_old() call later in order not to violate the debug
  assertions.  If buf_pool->LRU_old is NULL, set old=FALSE.

  buf_LRU_free_block(): Replace the UNIV_LRU_DEBUG assertion with a
  dummy buf_page_set_old() call that performs more thorough checks.

  buf_LRU_validate(): Do not tolerate garbage in buf_pool->LRU_old_len
  even if buf_pool->LRU_old is NULL.  Check that bpage->old is monotonic.

  buf_relocate(): Make the UNIV_LRU_DEBUG checks stricter.

  buf0buf.h: Revise the documentation of buf_page_t::old and
  buf_pool_t::LRU_old_len.
  ------------------------------------------------------------------------
  r6112 | calvin | 2009-10-30 01:21:15 +1100 (Fri, 30 Oct 2009) | 4 lines

  branches/zip: consideration for icc compilers

  Proposed by MySQL, and approved by Marko.

  ------------------------------------------------------------------------
  r6113 | vasil | 2009-10-30 03:15:50 +1100 (Fri, 30 Oct 2009) | 93 lines

  branches/zip: Merge r5912:6112 from branches/5.1:

  (after this merge the innodb-autoinc test starts to fail, but
  I commit anyway because it would be easier to investigate the
  failure this way)

    ------------------------------------------------------------------------
    r5952 | calvin | 2009-09-22 19:45:07 +0300 (Tue, 22 Sep 2009) | 7 lines
    Changed paths:
       M /branches/5.1/handler/ha_innodb.cc
    
    branches/5.1: fix bug#42383: Can't create table 'test.bug39438'
    
    For embedded server, MySQL may pass in full path, which is
    currently disallowed. It is needed to relax the condition by
    accepting full paths in the embedded case.
    
    Approved by: Heikki (on IM)
    ------------------------------------------------------------------------
    r6032 | vasil | 2009-10-01 15:55:49 +0300 (Thu, 01 Oct 2009) | 8 lines
    Changed paths:
       M /branches/5.1/handler/ha_innodb.cc
    
    branches/5.1:
    
    Fix Bug#38996 Race condition in ANALYZE TABLE
    
    by serializing ANALYZE TABLE inside InnoDB.
    
    Approved by:	Heikki (rb://175)
    
    ------------------------------------------------------------------------
    r6045 | jyang | 2009-10-08 02:27:08 +0300 (Thu, 08 Oct 2009) | 7 lines
    Changed paths:
       M /branches/5.1/handler/ha_innodb.cc
       A /branches/5.1/mysql-test/innodb_bug47777.result
       A /branches/5.1/mysql-test/innodb_bug47777.test
    
    branches/5.1: Fix bug #47777. Treat the Geometry data same as
    Binary BLOB in ha_innobase::store_key_val_for_row(), since the
    Geometry data is stored as Binary BLOB in Innodb.
    
    Review: rb://180 approved by Marko Makela.
    
    
      ------------------------------------------------------------------------
    r6051 | sunny | 2009-10-12 07:05:00 +0300 (Mon, 12 Oct 2009) | 6 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: Ignore negative values supplied by the user when calculating the
    next value to store in dict_table_t. Setting autoincrement columns top negative
    values is undefined behavior and this change should bring the behavior of
    InnoDB closer to what users expect. Added several tests to check.
    rb://162
    
    ------------------------------------------------------------------------
    r6052 | sunny | 2009-10-12 07:09:56 +0300 (Mon, 12 Oct 2009) | 4 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: Reset the statement level autoinc counter on ROLLBACK. Fix
    the test results too.
    rb://164
    
    ------------------------------------------------------------------------
    r6053 | sunny | 2009-10-12 07:37:49 +0300 (Mon, 12 Oct 2009) | 6 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: Copy the maximum AUTOINC value from the old table to the new
    table when MySQL does a CREATE INDEX ON T. This is required because MySQL
    does a table copy, rename and drops the old table.
    Fix Bug#47125: auto_increment start value is ignored if an index is created and engine=innodb
    rb://168
    
    ------------------------------------------------------------------------
    r6076 | vasil | 2009-10-14 19:30:12 +0300 (Wed, 14 Oct 2009) | 4 lines
    Changed paths:
       M /branches/5.1/row/row0mysql.c
    
    branches/5.1:
      
  Fix typo.
      
    ------------------------------------------------------------------------

  ------------------------------------------------------------------------
  r6114 | vasil | 2009-10-30 03:43:51 +1100 (Fri, 30 Oct 2009) | 6 lines

  branches/zip:

  * Add ChangeLog entries for latest changes
  * Obey alphabetical order in the list of the files
  * White-space fixup

  ------------------------------------------------------------------------
  r6121 | sunny | 2009-10-30 10:42:11 +1100 (Fri, 30 Oct 2009) | 7 lines

  branches/zip: This test has been problematic for sometime now. The underlying
  bug is that the data dictionaries get out of sync. In the AUTOINC code we
  try and apply salve to the symptoms. In the past MySQL made some unrelated
  change and the dictionaries stopped getting out of sync and this test started
  to fail. Now, it seems they have reverted that changed and the test is
  passing again. I suspect this is not he last time that this test will change.

  ------------------------------------------------------------------------
  r6124 | jyang | 2009-10-30 19:02:31 +1100 (Fri, 30 Oct 2009) | 5 lines

  branches/zip: Correct the bug number for -r6109 change
  from # 48273 to #48237



  ------------------------------------------------------------------------
  r6126 | vasil | 2009-10-30 19:36:07 +1100 (Fri, 30 Oct 2009) | 45 lines

  branches/zip: Merge r6112:6125 from branches/5.1:

  (skipping r6122 and r6123, Jimmy says these are already present and need
  not be merged):

    ------------------------------------------------------------------------
    r6122 | jyang | 2009-10-30 05:18:38 +0200 (Fri, 30 Oct 2009) | 7 lines
    Changed paths:
       M /branches/5.1/handler/ha_innodb.cc
       M /branches/5.1/mysql-test/innodb_bug44369.result
       M /branches/5.1/mysql-test/innodb_bug44369.test
       M /branches/5.1/mysql-test/innodb_bug46000.result
       M /branches/5.1/mysql-test/innodb_bug46000.test
    
    branches/5.1: Chnage WARN_LEVEL_ERROR to WARN_LEVEL_WARN
    for push_warning_printf() call in innodb.
    Fix Bug#47233: Innodb calls push_warning(MYSQL_ERROR::WARN_LEVEL_ERROR)
    
    rb://170 approved by Marko.
    
    
    ------------------------------------------------------------------------
    r6123 | jyang | 2009-10-30 05:43:06 +0200 (Fri, 30 Oct 2009) | 8 lines
    Changed paths:
       M /branches/5.1/os/os0proc.c
    
    branches/5.1: In os_mem_alloc_large(), if we fail to attach
    the shared memory, reset memory pointer ptr to NULL, and
    allocate memory from conventional pool. This is a port
    from branches/zip.
    Bug #48237 Error handling in os_mem_alloc_large appears to be incorrect
    rb://198  Approved by: Marko
    
    
    ------------------------------------------------------------------------
    r6125 | vasil | 2009-10-30 10:31:23 +0200 (Fri, 30 Oct 2009) | 4 lines
    Changed paths:
       M /branches/5.1/handler/ha_innodb.cc
    
    branches/5.1:
    
    White-space fixup.
    
    ------------------------------------------------------------------------

  ------------------------------------------------------------------------
  r6130 | marko | 2009-11-02 20:42:56 +1100 (Mon, 02 Nov 2009) | 9 lines

  branches/zip: Free all resources at shutdown. Set pointers to NULL, so
  that Valgrind will not complain about freed data structures that are
  reachable via pointers.  This addresses Bug #45992 and Bug #46656.

  This patch is mostly based on changes copied from branches/embedded-1.0,
  mainly c5432, c3439, c3134, c2994, c2978, but also some other code was
  copied.  Some added cleanup code is specific to MySQL/InnoDB.

  rb://199 approved by Sunny Bains
    ------------------------------------------------------------------------
pull/73/head
sunny 16 years ago
parent
commit
00c16e8a30
  1. 142
      ChangeLog
  2. 2
      Makefile.am
  3. 21
      btr/btr0btr.c
  4. 15
      btr/btr0sea.c
  5. 48
      buf/buf0buf.c
  6. 42
      buf/buf0flu.c
  7. 69
      buf/buf0lru.c
  8. 71
      dict/dict0dict.c
  9. 95
      fil/fil0fil.c
  10. 64
      fsp/fsp0fsp.c
  11. 122
      handler/ha_innodb.cc
  12. 18
      handler/ha_innodb.h
  13. 12
      handler/handler0alter.cc
  14. 21
      ibuf/ibuf0ibuf.c
  15. 6
      include/btr0sea.h
  16. 5
      include/buf0buf.h
  17. 17
      include/buf0buf.ic
  18. 7
      include/dict0dict.h
  19. 15
      include/fil0fil.h
  20. 6
      include/ibuf0ibuf.h
  21. 6
      include/lock0lock.h
  22. 21
      include/log0log.h
  23. 23
      include/log0recv.h
  24. 7
      include/mem0mem.h
  25. 7
      include/mem0pool.h
  26. 10
      include/os0file.h
  27. 7
      include/page0page.h
  28. 2
      include/page0page.ic
  29. 12
      include/page0zip.h
  30. 6
      include/pars0pars.h
  31. 2
      include/row0ins.h
  32. 2
      include/row0mysql.h
  33. 2
      include/srv0srv.h
  34. 6
      include/thr0loc.h
  35. 7
      include/trx0i_s.h
  36. 6
      include/trx0purge.h
  37. 7
      include/trx0rseg.h
  38. 6
      include/trx0sys.h
  39. 2
      include/trx0types.h
  40. 7
      include/trx0undo.h
  41. 2
      include/univ.i
  42. 12
      include/usr0sess.h
  43. 26
      lock/lock0lock.c
  44. 138
      log/log0log.c
  45. 148
      log/log0recv.c
  46. 11
      mem/mem0dbg.c
  47. 12
      mem/mem0pool.c
  48. 3
      mtr/mtr0mtr.c
  49. 243
      mysql-test/innodb-autoinc.result
  50. 118
      mysql-test/innodb-autoinc.test
  51. 98
      mysql-test/innodb-zip.result
  52. 46
      mysql-test/innodb-zip.test
  53. 8
      mysql-test/innodb_bug44369.result
  54. 4
      mysql-test/innodb_bug44369.test
  55. 18
      mysql-test/innodb_bug46000.result
  56. 12
      mysql-test/innodb_bug46000.test
  57. 13
      mysql-test/innodb_bug47777.result
  58. 24
      mysql-test/innodb_bug47777.test
  59. 16
      mysql-test/innodb_information_schema.test
  60. 95
      os/os0file.c
  61. 1
      os/os0proc.c
  62. 4
      os/os0sync.c
  63. 1
      os/os0thread.c
  64. 2
      page/page0cur.c
  65. 4
      page/page0page.c
  66. 51
      page/page0zip.c
  67. 13
      pars/lexyy.c
  68. 13
      pars/pars0lex.l
  69. 8
      que/que0que.c
  70. 8
      row/row0ins.c
  71. 8
      row/row0merge.c
  72. 2
      row/row0mysql.c
  73. 17
      srv/srv0srv.c
  74. 105
      srv/srv0start.c
  75. 20
      sync/sync0arr.c
  76. 5
      sync/sync0sync.c
  77. 31
      thr/thr0loc.c
  78. 37
      trx/trx0i_s.c
  79. 38
      trx/trx0purge.c
  80. 43
      trx/trx0rseg.c
  81. 78
      trx/trx0sys.c
  82. 2
      trx/trx0trx.c
  83. 2
      trx/trx0undo.c
  84. 37
      usr/usr0sess.c
  85. 2
      ut/ut0mem.c

142
ChangeLog

@ -1,3 +1,141 @@
2009-01-01 The InnoDB Team
* btr/btr0sea.c, buf/buf0buf.c, dict/dict0dict.c, fil/fil0fil.c,
ibuf/ibuf0ibuf.c, include/btr0sea.h, include/dict0dict.h,
include/fil0fil.h, include/ibuf0ibuf.h, include/lock0lock.h,
include/log0log.h, include/log0recv.h, include/mem0mem.h,
include/mem0pool.h, include/os0file.h, include/pars0pars.h,
include/srv0srv.h, include/thr0loc.h, include/trx0i_s.h,
include/trx0purge.h, include/trx0rseg.h, include/trx0sys.h,
include/trx0undo.h, include/usr0sess.h, lock/lock0lock.c,
log/log0log.c, log/log0recv.c, mem/mem0dbg.c, mem/mem0pool.c,
os/os0file.c, os/os0sync.c, os/os0thread.c, pars/lexyy.c,
pars/pars0lex.l, que/que0que.c, srv/srv0srv.c, srv/srv0start.c,
sync/sync0arr.c, sync/sync0sync.c, thr/thr0loc.c, trx/trx0i_s.c,
trx/trx0purge.c, trx/trx0rseg.c, trx/trx0sys.c, trx/trx0undo.c,
usr/usr0sess.c, ut/ut0mem.c:
Fix Bug #45992 innodb memory not freed after shutdown
Fix Bug #46656 InnoDB plugin: memory leaks (Valgrind)
2009-10-29 The InnoDB Team
* handler/ha_innodb.cc, mysql-test/innodb-autoinc.result,
mysql-test/innodb-autoinc.test:
Fix Bug#47125 auto_increment start value is ignored if an index is
created and engine=innodb
2009-10-29 The InnoDB Team
* handler/ha_innodb.cc, mysql-test/innodb_bug47777.result,
mysql-test/innodb_bug47777.test:
Fix Bug#47777 innodb dies with spatial pk: Failing assertion: buf <=
original_buf + buf_len
2009-10-29 The InnoDB Team
* handler/ha_innodb.cc:
Fix Bug#38996 Race condition in ANALYZE TABLE
2009-10-29 The InnoDB Team
* handler/ha_innodb.cc:
Fix bug#42383: Can't create table 'test.bug39438'
2009-10-29 The InnoDB Team
* os/os0proc.c:
Fix Bug#48237 Error handling in os_mem_alloc_large appears to
be incorrect
2009-10-29 The InnoDB Team
* buf/buf0buf.c, buf/buf0lru.c, include/buf0buf.h, include/buf0buf.ic:
Fix corruption of the buf_pool->LRU_old list and improve debug
assertions.
2009-10-28 The InnoDB Team
* srv/srv0start.c:
Fix Bug#41490 After enlargement of InnoDB page size, the error message
become inaccurate
2009-10-26 The InnoDB Team
* row/row0ins.c:
When allocating a data tuple, zero out the system fields in order
to avoid Valgrind warnings about uninitialized fields in
dtuple_validate().
2009-10-22 The InnoDB Team
* handler/ha_innodb.cc, mysql-test/innodb-zip.result,
mysql-test/innodb-zip.test, mysql-test/innodb_bug44369.result,
mysql-test/innodb_bug44369.test:
Fix Bug#47233 Innodb calls push_warning(MYSQL_ERROR::WARN_LEVEL_ERROR)
2009-10-19 The InnoDB Team
* mysql-test/innodb_information_schema.test:
Fix Bug#47808 innodb_information_schema.test fails when run under
valgrind
2009-10-15 The InnoDB Team
* include/page0page.ic:
Fix Bug#47058 Failure to compile innodb_plugin on solaris 10u7 + spro
cc/CC 5.10
2009-10-05 The InnoDB Team
* buf/buf0buf.c:
Do not invalidate buffer pool while an LRU batch is active. Added code
to buf_pool_invalidate() to wait for the running batches to finish.
2009-10-01 The InnoDB Team
* handler/ha_innodb.cc:
Fix Bug#47763 typo in error message: Failed to open table %s after %lu
attemtps.
2009-10-01 The InnoDB Team
* fsp/fsp0fsp.c, row/row0merge.c:
Clean up after a crash during DROP INDEX. When InnoDB crashes
while dropping an index, ensure that the index will be completely
dropped during crash recovery. The MySQL .frm file may still
contain the dropped index, but there is little that we can do
about it.
2009-09-28 The InnoDB Team
* handler/ha_innodb.cc:
When a secondary index exists in the MySQL .frm file but not in
the InnoDB data dictionary, return an error instead of letting an
assertion fail in index_read.
2009-09-28 The InnoDB Team
* btr/btr0btr.c, buf/buf0buf.c, include/page0page.h,
include/page0zip.h, page/page0cur.c, page/page0page.c,
page/page0zip.c:
Do not write to PAGE_INDEX_ID when restoring an uncompressed page
after a compression failure. The field should only be written
when creating a B-tree page. This fix addresses a race condition
in a debug assertion.
2009-09-28 The InnoDB Team
* fil/fil0fil.c:
Try to prevent the reuse of tablespace identifiers after InnoDB
has crashed during table creation. Also, refuse to start if files
with duplicate tablespace identifiers are encountered.
2009-09-25 The InnoDB Team
* include/os0file.h, os/os0file.c:
Fix Bug#47055 unconditional exit(1) on ERROR_WORKING_SET_QUOTA
1453 (0x5AD) for InnoDB backend
2009-09-19 The InnoDB Team
* handler/ha_innodb.cc, mysql-test/innodb-consistent-master.opt,
@ -101,6 +239,10 @@
Fix Bug#46657 InnoDB plugin: invalid read in index_merge_innodb test
(Valgrind)
2009-08-11 The InnoDB Team
InnoDB Plugin 1.0.4 released
2009-07-20 The InnoDB Team
* buf/buf0rea.c, handler/ha_innodb.cc, include/srv0srv.h,

2
Makefile.am

@ -22,7 +22,7 @@ MYSQLLIBdir= $(pkglibdir)
pkgplugindir= $(pkglibdir)/plugin
INCLUDES= -I$(top_srcdir)/include -I$(top_builddir)/include \
-I$(top_srcdir)/regex \
-I$(top_srcdir)/storage/innobase/include \
-I$(srcdir)/include \
-I$(top_srcdir)/sql \
-I$(srcdir) @ZLIB_INCLUDES@

21
btr/btr0btr.c

@ -1014,7 +1014,26 @@ btr_page_reorganize_low(
(!page_zip_compress(page_zip, page, index, NULL))) {
/* Restore the old page and exit. */
buf_frame_copy(page, temp_page);
#if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG
/* Check that the bytes that we skip are identical. */
ut_a(!memcmp(page, temp_page, PAGE_HEADER));
ut_a(!memcmp(PAGE_HEADER + PAGE_N_RECS + page,
PAGE_HEADER + PAGE_N_RECS + temp_page,
PAGE_DATA - (PAGE_HEADER + PAGE_N_RECS)));
ut_a(!memcmp(UNIV_PAGE_SIZE - FIL_PAGE_DATA_END + page,
UNIV_PAGE_SIZE - FIL_PAGE_DATA_END + temp_page,
FIL_PAGE_DATA_END));
#endif /* UNIV_DEBUG || UNIV_ZIP_DEBUG */
memcpy(PAGE_HEADER + page, PAGE_HEADER + temp_page,
PAGE_N_RECS - PAGE_N_DIR_SLOTS);
memcpy(PAGE_DATA + page, PAGE_DATA + temp_page,
UNIV_PAGE_SIZE - PAGE_DATA - FIL_PAGE_DATA_END);
#if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG
ut_a(!memcmp(page, temp_page, UNIV_PAGE_SIZE));
#endif /* UNIV_DEBUG || UNIV_ZIP_DEBUG */
goto func_exit;
}

15
btr/btr0sea.c

@ -175,6 +175,21 @@ btr_search_sys_create(
btr_search_sys->hash_index = ha_create(hash_size, 0, 0);
}
/*****************************************************************//**
Frees the adaptive search system at a database shutdown. */
UNIV_INTERN
void
btr_search_sys_free(void)
/*=====================*/
{
mem_free(btr_search_latch_temp);
btr_search_latch_temp = NULL;
mem_heap_free(btr_search_sys->hash_index->heap);
hash_table_free(btr_search_sys->hash_index);
mem_free(btr_search_sys);
btr_search_sys = NULL;
}
/********************************************************************//**
Disable the adaptive hash search system and empty the index. */
UNIV_INTERN

48
buf/buf0buf.c

@ -1020,7 +1020,11 @@ buf_pool_free(void)
os_mem_free_large(chunk->mem, chunk->mem_size);
}
buf_pool->n_chunks = 0;
mem_free(buf_pool->chunks);
hash_table_free(buf_pool->page_hash);
hash_table_free(buf_pool->zip_hash);
mem_free(buf_pool);
buf_pool = NULL;
}
/********************************************************************//**
@ -1163,10 +1167,15 @@ buf_relocate(
#ifdef UNIV_LRU_DEBUG
/* buf_pool->LRU_old must be the first item in the LRU list
whose "old" flag is set. */
ut_a(buf_pool->LRU_old->old);
ut_a(!UT_LIST_GET_PREV(LRU, buf_pool->LRU_old)
|| !UT_LIST_GET_PREV(LRU, buf_pool->LRU_old)->old);
ut_a(!UT_LIST_GET_NEXT(LRU, buf_pool->LRU_old)
|| UT_LIST_GET_NEXT(LRU, buf_pool->LRU_old)->old);
} else {
/* Check that the "old" flag is consistent in
the block and its neighbours. */
buf_page_set_old(dpage, buf_page_is_old(dpage));
#endif /* UNIV_LRU_DEBUG */
}
@ -1894,7 +1903,7 @@ buf_zip_decompress(
switch (fil_page_get_type(frame)) {
case FIL_PAGE_INDEX:
if (page_zip_decompress(&block->page.zip,
block->frame)) {
block->frame, TRUE)) {
return(TRUE);
}
@ -3380,7 +3389,32 @@ void
buf_pool_invalidate(void)
/*=====================*/
{
ibool freed;
ibool freed;
enum buf_flush i;
buf_pool_mutex_enter();
for (i = BUF_FLUSH_LRU; i < BUF_FLUSH_N_TYPES; i++) {
/* As this function is called during startup and
during redo application phase during recovery, InnoDB
is single threaded (apart from IO helper threads) at
this stage. No new write batch can be in intialization
stage at this point. */
ut_ad(buf_pool->init_flush[i] == FALSE);
/* However, it is possible that a write batch that has
been posted earlier is still not complete. For buffer
pool invalidation to proceed we must ensure there is NO
write activity happening. */
if (buf_pool->n_flush[i] > 0) {
buf_pool_mutex_exit();
buf_flush_wait_batch_end(i);
buf_pool_mutex_enter();
}
}
buf_pool_mutex_exit();
ut_ad(buf_all_freed());
@ -3395,6 +3429,14 @@ buf_pool_invalidate(void)
ut_ad(UT_LIST_GET_LEN(buf_pool->LRU) == 0);
ut_ad(UT_LIST_GET_LEN(buf_pool->unzip_LRU) == 0);
buf_pool->freed_page_clock = 0;
buf_pool->LRU_old = NULL;
buf_pool->LRU_old_len = 0;
buf_pool->LRU_flush_ended = 0;
memset(&buf_pool->stat, 0x00, sizeof(buf_pool->stat));
buf_refresh_io_stats();
buf_pool_mutex_exit();
}

42
buf/buf0flu.c

@ -518,6 +518,28 @@ buf_flush_write_complete(
}
}
/********************************************************************//**
Flush a batch of writes to the datafiles that have already been
written by the OS. */
static
void
buf_flush_sync_datafiles(void)
/*==========================*/
{
/* Wake possible simulated aio thread to actually post the
writes to the operating system */
os_aio_simulated_wake_handler_threads();
/* Wait that all async writes to tablespaces have been posted to
the OS */
os_aio_wait_until_no_pending_writes();
/* Now we flush the data to disk (for example, with fsync) */
fil_flush_file_spaces(FIL_TABLESPACE);
return;
}
/********************************************************************//**
Flushes possible buffered writes from the doublewrite memory buffer to disk,
and also wakes up the aio thread if simulated aio is used. It is very
@ -535,8 +557,8 @@ buf_flush_buffered_writes(void)
ulint i;
if (!srv_use_doublewrite_buf || trx_doublewrite == NULL) {
os_aio_simulated_wake_handler_threads();
/* Sync the writes to the disk. */
buf_flush_sync_datafiles();
return;
}
@ -744,22 +766,10 @@ flush:
buf_LRU_stat_inc_io();
}
/* Wake possible simulated aio thread to actually post the
writes to the operating system */
os_aio_simulated_wake_handler_threads();
/* Wait that all async writes to tablespaces have been posted to
the OS */
os_aio_wait_until_no_pending_writes();
/* Now we flush the data to disk (for example, with fsync) */
fil_flush_file_spaces(FIL_TABLESPACE);
/* Sync the writes to the disk. */
buf_flush_sync_datafiles();
/* We can now reuse the doublewrite memory buffer: */
trx_doublewrite->first_free = 0;
mutex_exit(&(trx_doublewrite->mutex));

69
buf/buf0lru.c

@ -978,14 +978,14 @@ buf_LRU_old_adjust_len(void)
#ifdef UNIV_LRU_DEBUG
ut_a(!LRU_old->old);
#endif /* UNIV_LRU_DEBUG */
buf_page_set_old(LRU_old, TRUE);
old_len = ++buf_pool->LRU_old_len;
buf_page_set_old(LRU_old, TRUE);
} else if (old_len > new_len + BUF_LRU_OLD_TOLERANCE) {
buf_page_set_old(LRU_old, FALSE);
buf_pool->LRU_old = UT_LIST_GET_NEXT(LRU, LRU_old);
old_len = --buf_pool->LRU_old_len;
buf_page_set_old(LRU_old, FALSE);
} else {
return;
}
@ -1009,13 +1009,13 @@ buf_LRU_old_init(void)
the adjust function to move the LRU_old pointer to the right
position */
bpage = UT_LIST_GET_FIRST(buf_pool->LRU);
while (bpage != NULL) {
for (bpage = UT_LIST_GET_LAST(buf_pool->LRU); bpage != NULL;
bpage = UT_LIST_GET_PREV(LRU, bpage)) {
ut_ad(bpage->in_LRU_list);
ut_ad(buf_page_in_file(bpage));
buf_page_set_old(bpage, TRUE);
bpage = UT_LIST_GET_NEXT(LRU, bpage);
/* This loop temporarily violates the
assertions of buf_page_set_old(). */
bpage->old = TRUE;
}
buf_pool->LRU_old = UT_LIST_GET_FIRST(buf_pool->LRU);
@ -1091,10 +1091,19 @@ buf_LRU_remove_block(
buf_unzip_LRU_remove_block_if_needed(bpage);
/* If the LRU list is so short that LRU_old not defined, return */
/* If the LRU list is so short that LRU_old is not defined,
clear the "old" flags and return */
if (UT_LIST_GET_LEN(buf_pool->LRU) < BUF_LRU_OLD_MIN_LEN) {
for (bpage = UT_LIST_GET_FIRST(buf_pool->LRU); bpage != NULL;
bpage = UT_LIST_GET_NEXT(LRU, bpage)) {
/* This loop temporarily violates the
assertions of buf_page_set_old(). */
bpage->old = FALSE;
}
buf_pool->LRU_old = NULL;
buf_pool->LRU_old_len = 0;
return;
}
@ -1155,14 +1164,13 @@ buf_LRU_add_block_to_end_low(
UT_LIST_ADD_LAST(LRU, buf_pool->LRU, bpage);
ut_d(bpage->in_LRU_list = TRUE);
buf_page_set_old(bpage, TRUE);
if (UT_LIST_GET_LEN(buf_pool->LRU) > BUF_LRU_OLD_MIN_LEN) {
ut_ad(buf_pool->LRU_old);
/* Adjust the length of the old block list if necessary */
buf_page_set_old(bpage, TRUE);
buf_pool->LRU_old_len++;
buf_LRU_old_adjust_len();
@ -1171,8 +1179,9 @@ buf_LRU_add_block_to_end_low(
/* The LRU list is now long enough for LRU_old to become
defined: init it */
buf_pool->LRU_old_len++;
buf_LRU_old_init();
} else {
buf_page_set_old(bpage, buf_pool->LRU_old != NULL);
}
/* If this is a zipped block with decompressed frame as well
@ -1223,14 +1232,13 @@ buf_LRU_add_block_low(
ut_d(bpage->in_LRU_list = TRUE);
buf_page_set_old(bpage, old);
if (UT_LIST_GET_LEN(buf_pool->LRU) > BUF_LRU_OLD_MIN_LEN) {
ut_ad(buf_pool->LRU_old);
/* Adjust the length of the old block list if necessary */
buf_page_set_old(bpage, old);
buf_LRU_old_adjust_len();
} else if (UT_LIST_GET_LEN(buf_pool->LRU) == BUF_LRU_OLD_MIN_LEN) {
@ -1239,6 +1247,8 @@ buf_LRU_add_block_low(
defined: init it */
buf_LRU_old_init();
} else {
buf_page_set_old(bpage, buf_pool->LRU_old != NULL);
}
/* If this is a zipped block with decompressed frame as well
@ -1436,15 +1446,6 @@ alloc:
buf_pool->LRU_old = b;
}
#ifdef UNIV_LRU_DEBUG
ut_a(prev_b->old
|| !UT_LIST_GET_NEXT(LRU, b)
|| UT_LIST_GET_NEXT(LRU, b)->old);
} else {
ut_a(!prev_b->old
|| !UT_LIST_GET_NEXT(LRU, b)
|| !UT_LIST_GET_NEXT(LRU, b)->old);
#endif /* UNIV_LRU_DEBUG */
}
lru_len = UT_LIST_GET_LEN(buf_pool->LRU);
@ -1460,6 +1461,11 @@ alloc:
defined: init it */
buf_LRU_old_init();
}
#ifdef UNIV_LRU_DEBUG
/* Check that the "old" flag is consistent
in the block and its neighbours. */
buf_page_set_old(b, buf_page_is_old(b));
#endif /* UNIV_LRU_DEBUG */
} else {
ut_d(b->in_LRU_list = FALSE);
buf_LRU_add_block_low(b, buf_page_is_old(b));
@ -1948,19 +1954,24 @@ buf_LRU_validate(void)
}
if (buf_page_is_old(bpage)) {
old_len++;
}
const buf_page_t* prev
= UT_LIST_GET_PREV(LRU, bpage);
const buf_page_t* next
= UT_LIST_GET_NEXT(LRU, bpage);
if (!old_len++) {
ut_a(buf_pool->LRU_old == bpage);
} else {
ut_a(!prev || buf_page_is_old(prev));
}
if (buf_pool->LRU_old && (old_len == 1)) {
ut_a(buf_pool->LRU_old == bpage);
ut_a(!next || buf_page_is_old(next));
}
bpage = UT_LIST_GET_NEXT(LRU, bpage);
}
if (buf_pool->LRU_old) {
ut_a(buf_pool->LRU_old_len == old_len);
}
ut_a(buf_pool->LRU_old_len == old_len);
UT_LIST_VALIDATE(list, buf_page_t, buf_pool->free,
ut_ad(ut_list_node_313->in_free_list));

71
dict/dict0dict.c

@ -4652,6 +4652,26 @@ dict_ind_init(void)
dict_ind_redundant->cached = dict_ind_compact->cached = TRUE;
}
/**********************************************************************//**
Frees dict_ind_redundant and dict_ind_compact. */
static
void
dict_ind_free(void)
/*===============*/
{
dict_table_t* table;
table = dict_ind_compact->table;
dict_mem_index_free(dict_ind_compact);
dict_ind_compact = NULL;
dict_mem_table_free(table);
table = dict_ind_redundant->table;
dict_mem_index_free(dict_ind_redundant);
dict_ind_redundant = NULL;
dict_mem_table_free(table);
}
#ifndef UNIV_HOTBACKUP
/**********************************************************************//**
Get index by name
@ -4777,4 +4797,55 @@ dict_table_check_for_dup_indexes(
}
}
#endif /* UNIV_DEBUG */
/**************************************************************************
Closes the data dictionary module. */
UNIV_INTERN
void
dict_close(void)
/*============*/
{
ulint i;
/* Free the hash elements. We don't remove them from the table
because we are going to destroy the table anyway. */
for (i = 0; i < hash_get_n_cells(dict_sys->table_hash); i++) {
dict_table_t* table;
table = HASH_GET_FIRST(dict_sys->table_hash, i);
while (table) {
dict_table_t* prev_table = table;
table = HASH_GET_NEXT(name_hash, prev_table);
#ifdef UNIV_DEBUG
ut_a(prev_table->magic_n == DICT_TABLE_MAGIC_N);
#endif
/* Acquire only because it's a pre-condition. */
mutex_enter(&dict_sys->mutex);
dict_table_remove_from_cache(prev_table);
mutex_exit(&dict_sys->mutex);
}
}
hash_table_free(dict_sys->table_hash);
/* The elements are the same instance as in dict_sys->table_hash,
therefore we don't delete the individual elements. */
hash_table_free(dict_sys->table_id_hash);
dict_ind_free();
mutex_free(&dict_sys->mutex);
rw_lock_free(&dict_operation_lock);
memset(&dict_operation_lock, 0x0, sizeof(dict_operation_lock));
mutex_free(&dict_foreign_err_mutex);
mem_free(dict_sys);
dict_sys = NULL;
}
#endif /* !UNIV_HOTBACKUP */

95
fil/fil0fil.c

@ -321,6 +321,17 @@ fil_get_space_id_for_table(
/*=======================*/
const char* name); /*!< in: table name in the standard
'databasename/tablename' format */
/*******************************************************************//**
Frees a space object from the tablespace memory cache. Closes the files in
the chain but does not delete them. There must not be any pending i/o's or
flushes on the files. */
static
ibool
fil_space_free(
/*===========*/
/* out: TRUE if success */
ulint id, /* in: space id */
ibool own_mutex);/* in: TRUE if own system->mutex */
/********************************************************************//**
Reads data from a space to a buffer. Remember that the possible incomplete
blocks at the end of file are ignored: they are not taken into account when
@ -594,6 +605,11 @@ fil_node_create(
UT_LIST_ADD_LAST(chain, space->chain, node);
if (id < SRV_LOG_SPACE_FIRST_ID && fil_system->max_assigned_id < id) {
fil_system->max_assigned_id = id;
}
mutex_exit(&fil_system->mutex);
}
@ -613,12 +629,10 @@ fil_node_open_file(
ulint size_high;
ibool ret;
ibool success;
#ifndef UNIV_HOTBACKUP
byte* buf2;
byte* page;
ulint space_id;
ulint flags;
#endif /* !UNIV_HOTBACKUP */
ut_ad(mutex_own(&(system->mutex)));
ut_a(node->n_pending == 0);
@ -654,9 +668,12 @@ fil_node_open_file(
size_bytes = (((ib_int64_t)size_high) << 32)
+ (ib_int64_t)size_low;
#ifdef UNIV_HOTBACKUP
node->size = (ulint) (size_bytes / UNIV_PAGE_SIZE);
/* TODO: adjust to zip_size, like below? */
#else
if (space->id == 0) {
node->size = (ulint) (size_bytes / UNIV_PAGE_SIZE);
os_file_close(node->handle);
goto add_size;
}
#endif /* UNIV_HOTBACKUP */
ut_a(space->purpose != FIL_LOG);
ut_a(space->id != 0);
@ -735,7 +752,10 @@ fil_node_open_file(
(size_bytes
/ dict_table_flags_to_zip_size(flags));
}
#endif
#ifdef UNIV_HOTBACKUP
add_size:
#endif /* UNIV_HOTBACKUP */
space->size += node->size;
}
@ -1135,7 +1155,7 @@ try_again:
mutex_exit(&fil_system->mutex);
fil_space_free(namesake_id);
fil_space_free(namesake_id, FALSE);
goto try_again;
}
@ -1260,17 +1280,21 @@ Frees a space object from the tablespace memory cache. Closes the files in
the chain but does not delete them. There must not be any pending i/o's or
flushes on the files.
@return TRUE if success */
UNIV_INTERN
static
ibool
fil_space_free(
/*===========*/
ulint id) /*!< in: space id */
/* out: TRUE if success */
ulint id, /* in: space id */
ibool own_mutex) /* in: TRUE if own system->mutex */
{
fil_space_t* space;
fil_space_t* namespace;
fil_node_t* fil_node;
mutex_enter(&fil_system->mutex);
if (!own_mutex) {
mutex_enter(&fil_system->mutex);
}
space = fil_space_get_by_id(id);
@ -1317,7 +1341,9 @@ fil_space_free(
ut_a(0 == UT_LIST_GET_LEN(space->chain));
mutex_exit(&fil_system->mutex);
if (!own_mutex) {
mutex_exit(&fil_system->mutex);
}
rw_lock_free(&(space->latch));
@ -1577,6 +1603,8 @@ fil_close_all_files(void)
space = UT_LIST_GET_FIRST(fil_system->space_list);
while (space != NULL) {
fil_space_t* prev_space = space;
node = UT_LIST_GET_FIRST(space->chain);
while (node != NULL) {
@ -1586,6 +1614,7 @@ fil_close_all_files(void)
node = UT_LIST_GET_NEXT(chain, node);
}
space = UT_LIST_GET_NEXT(space_list, space);
fil_space_free(prev_space->id, TRUE);
}
mutex_exit(&fil_system->mutex);
@ -2217,7 +2246,7 @@ try_again:
#endif
/* printf("Deleting tablespace %s id %lu\n", space->name, id); */
success = fil_space_free(id);
success = fil_space_free(id, FALSE);
if (success) {
success = os_file_delete(path);
@ -2923,7 +2952,6 @@ fil_open_single_table_tablespace(
byte* page;
ulint space_id;
ulint space_flags;
ibool ret = TRUE;
filepath = fil_make_ibd_name(name, FALSE);
@ -3001,7 +3029,7 @@ fil_open_single_table_tablespace(
(ulong) space_id, (ulong) space_flags,
(ulong) id, (ulong) flags);
ret = FALSE;
success = FALSE;
goto func_exit;
}
@ -3021,7 +3049,7 @@ func_exit:
os_file_close(file);
mem_free(filepath);
return(ret);
return(success);
}
#endif /* !UNIV_HOTBACKUP */
@ -3237,7 +3265,7 @@ fil_load_single_table_tablespace(
fprintf(stderr,
"InnoDB: Renaming tablespace %s of id %lu,\n"
"InnoDB: to %s_ibbackup_old_vers_<timestamp>\n"
"InnoDB: because its size %lld is too small"
"InnoDB: because its size %" PRId64 " is too small"
" (< 4 pages 16 kB each),\n"
"InnoDB: or the space id in the file header"
" is not sensible.\n"
@ -3299,7 +3327,17 @@ fil_load_single_table_tablespace(
if (!success) {
goto func_exit;
if (srv_force_recovery > 0) {
fprintf(stderr,
"InnoDB: innodb_force_recovery"
" was set to %lu. Continuing crash recovery\n"
"InnoDB: even though the tablespace creation"
" of this table failed.\n",
srv_force_recovery);
goto func_exit;
}
exit(1);
}
/* We do not use the size information we have about the file, because
@ -4738,3 +4776,26 @@ fil_page_get_type(
return(mach_read_from_2(page + FIL_PAGE_TYPE));
}
/********************************************************************
Initializes the tablespace memory cache. */
UNIV_INTERN
void
fil_close(void)
/*===========*/
{
/* The mutex should already have been freed. */
ut_ad(fil_system->mutex.magic_n == 0);
hash_table_free(fil_system->spaces);
hash_table_free(fil_system->name_hash);
ut_a(UT_LIST_GET_LEN(fil_system->LRU) == 0);
ut_a(UT_LIST_GET_LEN(fil_system->unflushed_spaces) == 0);
ut_a(UT_LIST_GET_LEN(fil_system->space_list) == 0);
mem_free(fil_system);
fil_system = NULL;
}

64
fsp/fsp0fsp.c

@ -231,10 +231,10 @@ the extent are free and which contain old tuple version to clean. */
/* Offset of the descriptor array on a descriptor page */
#define XDES_ARR_OFFSET (FSP_HEADER_OFFSET + FSP_HEADER_SIZE)
#ifndef UNIV_HOTBACKUP
/* Flag to indicate if we have printed the tablespace full error. */
static ibool fsp_tbs_full_error_printed = FALSE;
#ifndef UNIV_HOTBACKUP
/**********************************************************************//**
Returns an extent to the free list of a space. */
static
@ -1848,6 +1848,8 @@ fsp_seg_inode_page_find_used(
if (!ut_dulint_is_zero(mach_read_from_8(inode + FSEG_ID))) {
/* This is used */
ut_ad(mach_read_from_4(inode + FSEG_MAGIC_N)
== FSEG_MAGIC_N_VALUE);
return(i);
}
}
@ -1879,6 +1881,9 @@ fsp_seg_inode_page_find_free(
return(i);
}
ut_ad(mach_read_from_4(inode + FSEG_MAGIC_N)
== FSEG_MAGIC_N_VALUE);
}
return(ULINT_UNDEFINED);
@ -1997,6 +2002,8 @@ fsp_alloc_seg_inode(
page + FSEG_INODE_PAGE_NODE, mtr);
}
ut_ad(ut_dulint_is_zero(mach_read_from_8(inode + FSEG_ID))
|| mach_read_from_4(inode + FSEG_MAGIC_N) == FSEG_MAGIC_N_VALUE);
return(inode);
}
@ -2034,7 +2041,7 @@ fsp_free_seg_inode(
}
mlog_write_dulint(inode + FSEG_ID, ut_dulint_zero, mtr);
mlog_write_ulint(inode + FSEG_MAGIC_N, 0, MLOG_4BYTES, mtr);
mlog_write_ulint(inode + FSEG_MAGIC_N, 0xfa051ce3, MLOG_4BYTES, mtr);
if (ULINT_UNDEFINED
== fsp_seg_inode_page_find_used(page, zip_size, mtr)) {
@ -2050,11 +2057,11 @@ fsp_free_seg_inode(
/**********************************************************************//**
Returns the file segment inode, page x-latched.
@return segment inode, page x-latched */
@return segment inode, page x-latched; NULL if the inode is free */
static
fseg_inode_t*
fseg_inode_get(
/*===========*/
fseg_inode_try_get(
/*===============*/
fseg_header_t* header, /*!< in: segment header */
ulint space, /*!< in: space id */
ulint zip_size,/*!< in: compressed page size in bytes
@ -2070,11 +2077,37 @@ fseg_inode_get(
inode = fut_get_ptr(space, zip_size, inode_addr, RW_X_LATCH, mtr);
ut_ad(mach_read_from_4(inode + FSEG_MAGIC_N) == FSEG_MAGIC_N_VALUE);
if (UNIV_UNLIKELY
(ut_dulint_is_zero(mach_read_from_8(inode + FSEG_ID)))) {
inode = NULL;
} else {
ut_ad(mach_read_from_4(inode + FSEG_MAGIC_N)
== FSEG_MAGIC_N_VALUE);
}
return(inode);
}
/**********************************************************************//**
Returns the file segment inode, page x-latched.
@return segment inode, page x-latched */
static
fseg_inode_t*
fseg_inode_get(
/*===========*/
fseg_header_t* header, /*!< in: segment header */
ulint space, /*!< in: space id */
ulint zip_size,/*!< in: compressed page size in bytes
or 0 for uncompressed pages */
mtr_t* mtr) /*!< in: mtr handle */
{
fseg_inode_t* inode
= fseg_inode_try_get(header, space, zip_size, mtr);
ut_a(inode);
return(inode);
}
/**********************************************************************//**
Gets the page number from the nth fragment page slot.
@return page number, FIL_NULL if not in use */
@ -2089,6 +2122,7 @@ fseg_get_nth_frag_page_no(
ut_ad(inode && mtr);
ut_ad(n < FSEG_FRAG_ARR_N_SLOTS);
ut_ad(mtr_memo_contains_page(mtr, inode, MTR_MEMO_PAGE_X_FIX));
ut_ad(mach_read_from_4(inode + FSEG_MAGIC_N) == FSEG_MAGIC_N_VALUE);
return(mach_read_from_4(inode + FSEG_FRAG_ARR
+ n * FSEG_FRAG_SLOT_SIZE));
}
@ -2107,6 +2141,7 @@ fseg_set_nth_frag_page_no(
ut_ad(inode && mtr);
ut_ad(n < FSEG_FRAG_ARR_N_SLOTS);
ut_ad(mtr_memo_contains_page(mtr, inode, MTR_MEMO_PAGE_X_FIX));
ut_ad(mach_read_from_4(inode + FSEG_MAGIC_N) == FSEG_MAGIC_N_VALUE);
mlog_write_ulint(inode + FSEG_FRAG_ARR + n * FSEG_FRAG_SLOT_SIZE,
page_no, MLOG_4BYTES, mtr);
@ -2467,6 +2502,8 @@ fseg_fill_free_list(
xdes_set_state(descr, XDES_FSEG, mtr);
seg_id = mtr_read_dulint(inode + FSEG_ID, mtr);
ut_ad(mach_read_from_4(inode + FSEG_MAGIC_N)
== FSEG_MAGIC_N_VALUE);
mlog_write_dulint(descr + XDES_ID, seg_id, mtr);
flst_add_last(inode + FSEG_FREE, descr + XDES_FLST_NODE, mtr);
@ -2495,6 +2532,7 @@ fseg_alloc_free_extent(
fil_addr_t first;
ut_ad(!((page_offset(inode) - FSEG_ARR_OFFSET) % FSEG_INODE_SIZE));
ut_ad(mach_read_from_4(inode + FSEG_MAGIC_N) == FSEG_MAGIC_N_VALUE);
if (flst_get_len(inode + FSEG_FREE, mtr) > 0) {
/* Segment free list is not empty, allocate from it */
@ -3152,6 +3190,8 @@ fseg_mark_page_used(
ut_ad(seg_inode && mtr);
ut_ad(!((page_offset(seg_inode) - FSEG_ARR_OFFSET) % FSEG_INODE_SIZE));
ut_ad(mach_read_from_4(seg_inode + FSEG_MAGIC_N)
== FSEG_MAGIC_N_VALUE);
descr = xdes_get_descriptor(space, zip_size, page, mtr);
@ -3389,6 +3429,8 @@ fseg_free_extent(
ut_a(xdes_get_state(descr, mtr) == XDES_FSEG);
ut_a(0 == ut_dulint_cmp(mtr_read_dulint(descr + XDES_ID, mtr),
mtr_read_dulint(seg_inode + FSEG_ID, mtr)));
ut_ad(mach_read_from_4(seg_inode + FSEG_MAGIC_N)
== FSEG_MAGIC_N_VALUE);
first_page_in_extent = page - (page % FSP_EXTENT_SIZE);
@ -3479,7 +3521,13 @@ fseg_free_step(
ut_a(descr);
ut_a(xdes_get_bit(descr, XDES_FREE_BIT,
header_page % FSP_EXTENT_SIZE, mtr) == FALSE);
inode = fseg_inode_get(header, space, zip_size, mtr);
inode = fseg_inode_try_get(header, space, zip_size, mtr);
if (UNIV_UNLIKELY(inode == NULL)) {
fprintf(stderr, "double free of inode from %u:%u\n",
(unsigned) space, (unsigned) header_page);
return(TRUE);
}
descr = fseg_get_first_extent(inode, space, zip_size, mtr);
@ -3603,6 +3651,7 @@ fseg_get_first_extent(
ut_ad(inode && mtr);
ut_ad(space == page_get_space_id(page_align(inode)));
ut_ad(mach_read_from_4(inode + FSEG_MAGIC_N) == FSEG_MAGIC_N_VALUE);
first = fil_addr_null;
@ -3817,6 +3866,7 @@ fseg_print_low(
(ulong) reserved, (ulong) used, (ulong) n_full,
(ulong) n_frag, (ulong) n_free, (ulong) n_not_full,
(ulong) n_used);
ut_ad(mach_read_from_4(inode + FSEG_MAGIC_N) == FSEG_MAGIC_N_VALUE);
}
#ifdef UNIV_BTR_PRINT

122
handler/ha_innodb.cc

@ -107,7 +107,10 @@ extern "C" {
#include "i_s.h"
#ifndef MYSQL_SERVER
/* This is needed because of Bug #3596. Let us hope that pthread_mutex_t
# ifndef MYSQL_PLUGIN_IMPORT
# define MYSQL_PLUGIN_IMPORT /* nothing */
# endif /* MYSQL_PLUGIN_IMPORT */
/* This is needed because of Bug #3596. Let us hope that pthread_mutex_t
is defined the same in both builds: the MySQL server and the InnoDB plugin. */
extern MYSQL_PLUGIN_IMPORT pthread_mutex_t LOCK_thread_count;
@ -126,6 +129,7 @@ static ulong commit_threads = 0;
static pthread_mutex_t commit_threads_m;
static pthread_cond_t commit_cond;
static pthread_mutex_t commit_cond_m;
static pthread_mutex_t analyze_mutex;
static bool innodb_inited = 0;
#define INSIDE_HA_INNOBASE_CC
@ -230,21 +234,6 @@ static handler *innobase_create_handler(handlerton *hton,
TABLE_SHARE *table,
MEM_ROOT *mem_root);
/***********************************************************************
This function checks each index name for a table against reserved
system default primary index name 'GEN_CLUST_INDEX'. If a name matches,
this function pushes an error message to the client, and returns true. */
static
bool
innobase_index_name_is_reserved(
/*============================*/
/* out: true if index name matches a
reserved name */
const trx_t* trx, /* in: InnoDB transaction handle */
const TABLE* form, /* in: information on table
columns and indexes */
const char* norm_name); /* in: table name */
/* "GEN_CLUST_INDEX" is the name reserved for Innodb default
system primary index. */
static const char innobase_index_reserve_name[]= "GEN_CLUST_INDEX";
@ -2267,6 +2256,7 @@ innobase_change_buffering_inited_ok:
pthread_mutex_init(&prepare_commit_mutex, MY_MUTEX_INIT_FAST);
pthread_mutex_init(&commit_threads_m, MY_MUTEX_INIT_FAST);
pthread_mutex_init(&commit_cond_m, MY_MUTEX_INIT_FAST);
pthread_mutex_init(&analyze_mutex, MY_MUTEX_INIT_FAST);
pthread_cond_init(&commit_cond, NULL);
innodb_inited= 1;
#ifdef MYSQL_DYNAMIC_PLUGIN
@ -2321,6 +2311,7 @@ innobase_end(
pthread_mutex_destroy(&prepare_commit_mutex);
pthread_mutex_destroy(&commit_threads_m);
pthread_mutex_destroy(&commit_cond_m);
pthread_mutex_destroy(&analyze_mutex);
pthread_cond_destroy(&commit_cond);
}
@ -2599,6 +2590,8 @@ innobase_rollback(
innobase_release_stat_resources(trx);
trx->n_autoinc_rows = 0; /* Reset the number AUTO-INC rows required */
/* If we had reserved the auto-inc lock for some table (if
we come here to roll back the latest SQL statement) we
release it now before a possibly lengthy rollback */
@ -3160,7 +3153,7 @@ retry:
if (is_part) {
sql_print_error("Failed to open table %s after "
"%lu attemtps.\n", norm_name,
"%lu attempts.\n", norm_name,
retries);
}
@ -3759,7 +3752,10 @@ ha_innobase::store_key_val_for_row(
} else if (mysql_type == MYSQL_TYPE_TINY_BLOB
|| mysql_type == MYSQL_TYPE_MEDIUM_BLOB
|| mysql_type == MYSQL_TYPE_BLOB
|| mysql_type == MYSQL_TYPE_LONG_BLOB) {
|| mysql_type == MYSQL_TYPE_LONG_BLOB
/* MYSQL_TYPE_GEOMETRY data is treated
as BLOB data in innodb. */
|| mysql_type == MYSQL_TYPE_GEOMETRY) {
CHARSET_INFO* cs;
ulint key_len;
@ -5061,6 +5057,11 @@ ha_innobase::index_read(
index = prebuilt->index;
if (UNIV_UNLIKELY(index == NULL)) {
prebuilt->index_usable = FALSE;
DBUG_RETURN(HA_ERR_CRASHED);
}
/* Note that if the index for which the search template is built is not
necessarily prebuilt->index, but can also be the clustered index */
@ -5220,6 +5221,7 @@ ha_innobase::change_active_index(
if (UNIV_UNLIKELY(!prebuilt->index)) {
sql_print_warning("InnoDB: change_active_index(%u) failed",
keynr);
prebuilt->index_usable = FALSE;
DBUG_RETURN(1);
}
@ -5683,7 +5685,7 @@ create_table_def(
number fits in one byte in prtype */
push_warning_printf(
(THD*) trx->mysql_thd,
MYSQL_ERROR::WARN_LEVEL_ERROR,
MYSQL_ERROR::WARN_LEVEL_WARN,
ER_CANT_CREATE_TABLE,
"In InnoDB, charset-collation codes"
" must be below 256."
@ -5717,7 +5719,7 @@ create_table_def(
if (dict_col_name_is_reserved(field->field_name)){
push_warning_printf(
(THD*) trx->mysql_thd,
MYSQL_ERROR::WARN_LEVEL_ERROR,
MYSQL_ERROR::WARN_LEVEL_WARN,
ER_CANT_CREATE_TABLE,
"Error creating table '%s' with "
"column name '%s'. '%s' is a "
@ -5951,7 +5953,7 @@ create_options_are_valid(
/* Valid value. */
break;
default:
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_ILLEGAL_HA_CREATE_OPTION,
"InnoDB: invalid"
" KEY_BLOCK_SIZE = %lu."
@ -5965,7 +5967,7 @@ create_options_are_valid(
/* If KEY_BLOCK_SIZE was specified, check for its
dependencies. */
if (kbs_specified && !srv_file_per_table) {
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_ILLEGAL_HA_CREATE_OPTION,
"InnoDB: KEY_BLOCK_SIZE"
" requires innodb_file_per_table.");
@ -5973,7 +5975,7 @@ create_options_are_valid(
}
if (kbs_specified && srv_file_format < DICT_TF_FORMAT_ZIP) {
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_ILLEGAL_HA_CREATE_OPTION,
"InnoDB: KEY_BLOCK_SIZE"
" requires innodb_file_format >"
@ -5997,7 +5999,7 @@ create_options_are_valid(
if (!srv_file_per_table) {
push_warning_printf(
thd,
MYSQL_ERROR::WARN_LEVEL_ERROR,
MYSQL_ERROR::WARN_LEVEL_WARN,
ER_ILLEGAL_HA_CREATE_OPTION,
"InnoDB: ROW_FORMAT=%s"
" requires innodb_file_per_table.",
@ -6009,7 +6011,7 @@ create_options_are_valid(
if (srv_file_format < DICT_TF_FORMAT_ZIP) {
push_warning_printf(
thd,
MYSQL_ERROR::WARN_LEVEL_ERROR,
MYSQL_ERROR::WARN_LEVEL_WARN,
ER_ILLEGAL_HA_CREATE_OPTION,
"InnoDB: ROW_FORMAT=%s"
" requires innodb_file_format >"
@ -6026,7 +6028,7 @@ create_options_are_valid(
&& form->s->row_type == ROW_TYPE_DYNAMIC) {
push_warning_printf(
thd,
MYSQL_ERROR::WARN_LEVEL_ERROR,
MYSQL_ERROR::WARN_LEVEL_WARN,
ER_ILLEGAL_HA_CREATE_OPTION,
"InnoDB: cannot specify"
" ROW_FORMAT = DYNAMIC with"
@ -6050,7 +6052,7 @@ create_options_are_valid(
if (kbs_specified) {
push_warning_printf(
thd,
MYSQL_ERROR::WARN_LEVEL_ERROR,
MYSQL_ERROR::WARN_LEVEL_WARN,
ER_ILLEGAL_HA_CREATE_OPTION,
"InnoDB: cannot specify"
" ROW_FORMAT = %s with"
@ -6063,7 +6065,7 @@ create_options_are_valid(
default:
push_warning(thd,
MYSQL_ERROR::WARN_LEVEL_ERROR,
MYSQL_ERROR::WARN_LEVEL_WARN,
ER_ILLEGAL_HA_CREATE_OPTION,
"InnoDB: invalid ROW_FORMAT specifier.");
ret = FALSE;
@ -6127,13 +6129,15 @@ ha_innobase::create(
1. <database_name>/<table_name>: for normal table creation
2. full path: for temp table creation, or sym link
When srv_file_per_table is on, check for full path pattern, i.e.
When srv_file_per_table is on and mysqld_embedded is off,
check for full path pattern, i.e.
X:\dir\..., X is a driver letter, or
\\dir1\dir2\..., UNC path
returns error if it is in full path format, but not creating a temp.
table. Currently InnoDB does not support symbolic link on Windows. */
if (srv_file_per_table
&& !mysqld_embedded
&& (!create_info->options & HA_LEX_CREATE_TMP_TABLE)) {
if ((name[1] == ':')
@ -6337,7 +6341,8 @@ ha_innobase::create(
/* Check for name conflicts (with reserved name) for
any user indices to be created. */
if (innobase_index_name_is_reserved(trx, form, norm_name)) {
if (innobase_index_name_is_reserved(trx, form->key_info,
form->s->keys)) {
error = -1;
goto cleanup;
}
@ -6424,18 +6429,22 @@ ha_innobase::create(
setup at this stage and so we use thd. */
/* We need to copy the AUTOINC value from the old table if
this is an ALTER TABLE. */
this is an ALTER TABLE or CREATE INDEX because CREATE INDEX
does a table copy too. */
if (((create_info->used_fields & HA_CREATE_USED_AUTO)
|| thd_sql_command(thd) == SQLCOM_ALTER_TABLE)
&& create_info->auto_increment_value != 0) {
/* Query was ALTER TABLE...AUTO_INCREMENT = x; or
CREATE TABLE ...AUTO_INCREMENT = x; Find out a table
definition from the dictionary and get the current value
of the auto increment field. Set a new value to the
auto increment field if the value is greater than the
maximum value in the column. */
|| thd_sql_command(thd) == SQLCOM_ALTER_TABLE
|| thd_sql_command(thd) == SQLCOM_CREATE_INDEX)
&& create_info->auto_increment_value > 0) {
/* Query was one of :
CREATE TABLE ...AUTO_INCREMENT = x; or
ALTER TABLE...AUTO_INCREMENT = x; or
CREATE INDEX x on t(...);
Find out a table definition from the dictionary and get
the current value of the auto increment field. Set a new
value to the auto increment field if the value is greater
than the maximum value in the column. */
auto_inc_value = create_info->auto_increment_value;
@ -7289,9 +7298,15 @@ ha_innobase::analyze(
THD* thd, /*!< in: connection thread handle */
HA_CHECK_OPT* check_opt) /*!< in: currently ignored */
{
/* Serialize ANALYZE TABLE inside InnoDB, see
Bug#38996 Race condition in ANALYZE TABLE */
pthread_mutex_lock(&analyze_mutex);
/* Simply call ::info() with all the flags */
info(HA_STATUS_TIME | HA_STATUS_CONST | HA_STATUS_VARIABLE);
pthread_mutex_unlock(&analyze_mutex);
return(0);
}
@ -8767,6 +8782,7 @@ ha_innobase::get_auto_increment(
AUTOINC counter after attempting to insert the row. */
if (innobase_autoinc_lock_mode != AUTOINC_OLD_STYLE_LOCKING) {
ulonglong need;
ulonglong current;
ulonglong next_value;
ulonglong col_max_value;
@ -8775,11 +8791,12 @@ ha_innobase::get_auto_increment(
col_max_value = innobase_get_int_col_max_value(
table->next_number_field);
current = *first_value > col_max_value ? autoinc : *first_value;
need = *nb_reserved_values * increment;
/* Compute the last value in the interval */
next_value = innobase_next_autoinc(
*first_value, need, offset, col_max_value);
current, need, offset, col_max_value);
prebuilt->autoinc_last_value = next_value;
@ -9798,36 +9815,39 @@ static int show_innodb_vars(THD *thd, SHOW_VAR *var, char *buff)
/***********************************************************************
This function checks each index name for a table against reserved
system default primary index name 'GEN_CLUST_INDEX'. If a name matches,
this function pushes an error message to the client, and returns true. */
static
this function pushes an warning message to the client, and returns true. */
extern "C" UNIV_INTERN
bool
innobase_index_name_is_reserved(
/*============================*/
/* out: true if an index name
matches the reserved name */
const trx_t* trx, /* in: InnoDB transaction handle */
const TABLE* form, /* in: information on table
columns and indexes */
const char* norm_name) /* in: table name */
const KEY* key_info, /* in: Indexes to be created */
ulint num_of_keys) /* in: Number of indexes to
be created. */
{
KEY* key;
const KEY* key;
uint key_num; /* index number */
for (key_num = 0; key_num < form->s->keys; key_num++) {
key = form->key_info + key_num;
for (key_num = 0; key_num < num_of_keys; key_num++) {
key = &key_info[key_num];
if (innobase_strcasecmp(key->name,
innobase_index_reserve_name) == 0) {
/* Push warning to mysql */
push_warning_printf((THD*) trx->mysql_thd,
MYSQL_ERROR::WARN_LEVEL_ERROR,
ER_CANT_CREATE_TABLE,
MYSQL_ERROR::WARN_LEVEL_WARN,
ER_WRONG_NAME_FOR_INDEX,
"Cannot Create Index with name "
"'%s'. The name is reserved "
"for the system default primary "
"index.",
innobase_index_reserve_name);
my_error(ER_WRONG_NAME_FOR_INDEX, MYF(0),
innobase_index_reserve_name);
return(true);
}
}

18
handler/ha_innodb.h

@ -282,3 +282,21 @@ trx_t*
innobase_trx_allocate(
/*==================*/
MYSQL_THD thd); /*!< in: user thread handle */
/*********************************************************************//**
This function checks each index name for a table against reserved
system default primary index name 'GEN_CLUST_INDEX'. If a name
matches, this function pushes an warning message to the client,
and returns true. */
extern "C"
bool
innobase_index_name_is_reserved(
/*============================*/
/* out: true if the index name
matches the reserved name */
const trx_t* trx, /* in: InnoDB transaction handle */
const KEY* key_info, /* in: Indexes to be created */
ulint num_of_keys); /* in: Number of indexes to
be created. */

12
handler/handler0alter.cc

@ -628,7 +628,7 @@ ha_innobase::add_index(
ulint num_created = 0;
ibool dict_locked = FALSE;
ulint new_primary;
ulint error;
int error;
DBUG_ENTER("ha_innobase::add_index");
ut_a(table);
@ -656,9 +656,13 @@ ha_innobase::add_index(
innodb_table = indexed_table
= dict_table_get(prebuilt->table->name, FALSE);
/* Check that index keys are sensible */
error = innobase_check_index_keys(key_info, num_of_keys);
/* Check if the index name is reserved. */
if (innobase_index_name_is_reserved(trx, key_info, num_of_keys)) {
error = -1;
} else {
/* Check that index keys are sensible */
error = innobase_check_index_keys(key_info, num_of_keys);
}
if (UNIV_UNLIKELY(error)) {
err_exit:

21
ibuf/ibuf0ibuf.c

@ -436,6 +436,27 @@ ibuf_count_set(
}
#endif
/******************************************************************//**
Closes insert buffer and frees the data structures. */
UNIV_INTERN
void
ibuf_close(void)
/*============*/
{
mutex_free(&ibuf_pessimistic_insert_mutex);
memset(&ibuf_pessimistic_insert_mutex,
0x0, sizeof(ibuf_pessimistic_insert_mutex));
mutex_free(&ibuf_mutex);
memset(&ibuf_mutex, 0x0, sizeof(ibuf_mutex));
mutex_free(&ibuf_bitmap_mutex);
memset(&ibuf_bitmap_mutex, 0x0, sizeof(ibuf_mutex));
mem_free(ibuf);
ibuf = NULL;
}
/******************************************************************//**
Updates the size information of the ibuf, assuming the segment size has not
changed. */

6
include/btr0sea.h

@ -41,6 +41,12 @@ void
btr_search_sys_create(
/*==================*/
ulint hash_size); /*!< in: hash index hash table size */
/*****************************************************************//**
Frees the adaptive search system at a database shutdown. */
UNIV_INTERN
void
btr_search_sys_free(void);
/*=====================*/
/********************************************************************//**
Disable the adaptive hash search system and empty the index. */

5
include/buf0buf.h

@ -1158,7 +1158,7 @@ struct buf_page_struct{
debugging */
#endif /* UNIV_DEBUG */
unsigned old:1; /*!< TRUE if the block is in the old
blocks in the LRU list */
blocks in buf_pool->LRU_old */
unsigned freed_page_clock:31;/*!< the value of
buf_pool->freed_page_clock
when this block was the last
@ -1446,8 +1446,7 @@ struct buf_pool_struct{
the block to which LRU_old points
onward, including that block;
see buf0lru.c for the restrictions
on this value; not defined if
LRU_old == NULL;
on this value; 0 if LRU_old == NULL;
NOTE: LRU_old_len must be adjusted
whenever LRU_old shrinks or grows! */

17
include/buf0buf.ic

@ -466,10 +466,19 @@ buf_page_set_old(
ut_ad(bpage->in_LRU_list);
#ifdef UNIV_LRU_DEBUG
if (UT_LIST_GET_PREV(LRU, bpage) && UT_LIST_GET_NEXT(LRU, bpage)
&& UT_LIST_GET_PREV(LRU, bpage)->old
== UT_LIST_GET_NEXT(LRU, bpage)->old) {
ut_a(UT_LIST_GET_PREV(LRU, bpage)->old == old);
ut_a((buf_pool->LRU_old_len == 0) == (buf_pool->LRU_old == NULL));
/* If a block is flagged "old", the LRU_old list must exist. */
ut_a(!old || buf_pool->LRU_old);
if (UT_LIST_GET_PREV(LRU, bpage) && UT_LIST_GET_NEXT(LRU, bpage)) {
const buf_page_t* prev = UT_LIST_GET_PREV(LRU, bpage);
const buf_page_t* next = UT_LIST_GET_NEXT(LRU, bpage);
if (prev->old == next->old) {
ut_a(prev->old == old);
} else {
ut_a(!prev->old);
ut_a(buf_pool->LRU_old == (old ? bpage : next));
}
}
#endif /* UNIV_LRU_DEBUG */

7
include/dict0dict.h

@ -1151,6 +1151,13 @@ void
dict_ind_init(void);
/*===============*/
/**********************************************************************//**
Closes the data dictionary module. */
UNIV_INTERN
void
dict_close(void);
/*============*/
#ifndef UNIV_NONINL
#include "dict0dict.ic"
#endif

15
include/fil0fil.h

@ -224,15 +224,6 @@ fil_space_create(
0 for uncompressed tablespaces */
ulint purpose);/*!< in: FIL_TABLESPACE, or FIL_LOG if log */
/*******************************************************************//**
Frees a space object from a the tablespace memory cache. Closes the files in
the chain but does not delete them.
@return TRUE if success */
UNIV_INTERN
ibool
fil_space_free(
/*===========*/
ulint id); /*!< in: space id */
/*******************************************************************//**
Returns the size of the space in pages. The tablespace must be cached in the
memory cache.
@return space size, 0 if space not found */
@ -278,6 +269,12 @@ fil_init(
ulint hash_size, /*!< in: hash table size */
ulint max_n_open); /*!< in: max number of open files */
/*******************************************************************//**
Initializes the tablespace memory cache. */
UNIV_INTERN
void
fil_close(void);
/*===========*/
/*******************************************************************//**
Opens all log files and system tablespace data files. They stay open until the
database server shutdown. This should be called at a server startup after the
space objects for the log and the system tablespace have been created. The

6
include/ibuf0ibuf.h

@ -380,6 +380,12 @@ ulint
ibuf_rec_get_counter(
/*=================*/
const rec_t* rec); /*!< in: ibuf record */
/******************************************************************//**
Closes insert buffer and frees the data structures. */
UNIV_INTERN
void
ibuf_close(void);
/*============*/
#define IBUF_HEADER_PAGE_NO FSP_IBUF_HEADER_PAGE_NO
#define IBUF_TREE_ROOT_PAGE_NO FSP_IBUF_TREE_ROOT_PAGE_NO

6
include/lock0lock.h

@ -59,6 +59,12 @@ lock_sys_create(
/*============*/
ulint n_cells); /*!< in: number of slots in lock hash table */
/*********************************************************************//**
Closes the lock system at database shutdown. */
UNIV_INTERN
void
lock_sys_close(void);
/*================*/
/*********************************************************************//**
Checks if some transaction has an implicit x-lock on a record in a clustered
index.
@return transaction which has the x-lock, or NULL */

21
include/log0log.h

@ -572,6 +572,18 @@ UNIV_INTERN
void
log_refresh_stats(void);
/*===================*/
/**********************************************************
Shutdown the log system but do not release all the memory. */
UNIV_INTERN
void
log_shutdown(void);
/*==============*/
/**********************************************************
Free the log system data structures. */
UNIV_INTERN
void
log_mem_free(void);
/*==============*/
extern log_t* log_sys;
@ -584,7 +596,7 @@ extern log_t* log_sys;
#define LOG_RECOVER 98887331
/* The counting of lsn's starts from this value: this must be non-zero */
#define LOG_START_LSN ((ib_uint64_t) (16 * OS_FILE_LOG_BLOCK_SIZE))
#define LOG_START_LSN ((ib_uint64_t) (16 * OS_FILE_LOG_BLOCK_SIZE))
#define LOG_BUFFER_SIZE (srv_log_buffer_size * UNIV_PAGE_SIZE)
#define LOG_ARCHIVE_BUF_SIZE (srv_log_buffer_size * UNIV_PAGE_SIZE / 4)
@ -721,9 +733,12 @@ struct log_group_struct{
ulint lsn_offset; /*!< the offset of the above lsn */
ulint n_pending_writes;/*!< number of currently pending flush
writes for this log group */
byte** file_header_bufs_ptr;/*!< unaligned buffers */
byte** file_header_bufs;/*!< buffers for each file
header in the group */
#ifdef UNIV_LOG_ARCHIVE
/*-----------------------------*/
byte** archive_file_header_bufs_ptr;/*!< unaligned buffers */
byte** archive_file_header_bufs;/*!< buffers for each file
header in the group */
ulint archive_space_id;/*!< file space which
@ -742,10 +757,12 @@ struct log_group_struct{
completion function then sets the new
value to ..._file_no */
ulint next_archived_offset; /*!< like the preceding field */
#endif /* UNIV_LOG_ARCHIVE */
/*-----------------------------*/
ib_uint64_t scanned_lsn; /*!< used only in recovery: recovery scan
succeeded up to this lsn in this log
group */
byte* checkpoint_buf_ptr;/*!< unaligned checkpoint header */
byte* checkpoint_buf; /*!< checkpoint header is written from
this buffer to the group */
UT_LIST_NODE_T(log_group_t)
@ -763,6 +780,7 @@ struct log_struct{
#ifndef UNIV_HOTBACKUP
mutex_t mutex; /*!< mutex protecting the log */
#endif /* !UNIV_HOTBACKUP */
byte* buf_ptr; /* unaligned log buffer */
byte* buf; /*!< log buffer */
ulint buf_size; /*!< log buffer size in bytes */
ulint max_buf_free; /*!< recommended maximum value of
@ -899,6 +917,7 @@ struct log_struct{
should wait for this without owning
the log mutex */
#endif /* !UNIV_HOTBACKUP */
byte* checkpoint_buf_ptr;/* unaligned checkpoint header */
byte* checkpoint_buf; /*!< checkpoint header is read to this
buffer */
/* @} */

23
include/log0recv.h

@ -239,6 +239,18 @@ UNIV_INTERN
void
recv_sys_create(void);
/*=================*/
/**********************************************************//**
Release recovery system mutexes. */
UNIV_INTERN
void
recv_sys_close(void);
/*================*/
/********************************************************//**
Frees the recovery system memory. */
UNIV_INTERN
void
recv_sys_mem_free(void);
/*===================*/
/********************************************************//**
Inits the recovery system for a recovery operation. */
UNIV_INTERN
@ -246,6 +258,12 @@ void
recv_sys_init(
/*==========*/
ulint available_memory); /*!< in: available memory in bytes */
/********************************************************//**
Reset the state of the recovery system variables. */
UNIV_INTERN
void
recv_sys_var_init(void);
/*===================*/
/*******************************************************************//**
Empties the hash table of stored log records, applying them to appropriate
pages. */
@ -433,6 +451,11 @@ are allowed yet: the variable name is misleading. */
extern ibool recv_no_ibuf_operations;
/** TRUE when recv_init_crash_recovery() has been called. */
extern ibool recv_needed_recovery;
#ifdef UNIV_DEBUG
/** TRUE if writing to the redo log (mtr_commit) is forbidden.
Protected by log_sys->mutex. */
extern ibool recv_no_log_write;
#endif /* UNIV_DEBUG */
/** TRUE if buf_page_is_corrupted() should check if the log sequence
number (FIL_PAGE_LSN) is in the future. Initially FALSE, and set by

7
include/mem0mem.h

@ -82,6 +82,13 @@ void
mem_init(
/*=====*/
ulint size); /*!< in: common pool size in bytes */
/******************************************************************//**
Closes the memory system. */
UNIV_INTERN
void
mem_close(void);
/*===========*/
/**************************************************************//**
Use this macro instead of the corresponding function! Macro for memory
heap creation. */

7
include/mem0pool.h

@ -62,6 +62,13 @@ mem_pool_create(
/*============*/
ulint size); /*!< in: pool size in bytes */
/********************************************************************//**
Frees a memory pool. */
UNIV_INTERN
void
mem_pool_free(
/*==========*/
mem_pool_t* pool); /*!< in, own: memory pool */
/********************************************************************//**
Allocates memory from a pool. NOTE: This low-level function should only be
used in mem0mem.*!
@return own: allocated memory buffer */

10
include/os0file.h

@ -151,7 +151,8 @@ log. */
to become available again */
#define OS_FILE_SHARING_VIOLATION 76
#define OS_FILE_ERROR_NOT_SPECIFIED 77
#define OS_FILE_AIO_INTERRUPTED 78
#define OS_FILE_INSUFFICIENT_RESOURCE 78
#define OS_FILE_AIO_INTERRUPTED 79
/* @} */
/** Types for aio operations @{ */
@ -614,6 +615,13 @@ os_aio_init(
ulint n_write_segs, /*<! in: number of writer threads */
ulint n_slots_sync); /*<! in: number of slots in the sync aio
array */
/***********************************************************************
Frees the asynchronous io system. */
UNIV_INTERN
void
os_aio_free(void);
/*=============*/
/*******************************************************************//**
Requests an asynchronous i/o operation.
@return TRUE if request was queued successfully, FALSE if fail */

7
include/page0page.h

@ -76,8 +76,11 @@ typedef byte page_header_t;
header which are set in a page create */
/*----*/
#define PAGE_LEVEL 26 /* level of the node in an index tree; the
leaf level is the level 0 */
#define PAGE_INDEX_ID 28 /* index id where the page belongs */
leaf level is the level 0. This field should
not be written to after page creation. */
#define PAGE_INDEX_ID 28 /* index id where the page belongs.
This field should not be written to after
page creation. */
#define PAGE_BTR_SEG_LEAF 36 /* file segment header for the leaf pages in
a B-tree: defined only on the root page of a
B-tree, but not in the root of an ibuf tree */

2
include/page0page.ic

@ -907,7 +907,7 @@ page_get_data_size(
/************************************************************//**
Allocates a block of memory from the free list of an index page. */
UNIV_INTERN
UNIV_INLINE
void
page_mem_alloc_free(
/*================*/

12
include/page0zip.h

@ -127,8 +127,12 @@ page_zip_decompress(
/*================*/
page_zip_des_t* page_zip,/*!< in: data, ssize;
out: m_start, m_end, m_nonempty, n_blobs */
page_t* page) /*!< out: uncompressed page, may be trashed */
__attribute__((nonnull));
page_t* page, /*!< out: uncompressed page, may be trashed */
ibool all) /*!< in: TRUE=decompress the whole page;
FALSE=verify but do not copy some
page header fields that should not change
after page creation */
__attribute__((nonnull(1,2)));
#ifdef UNIV_DEBUG
/**********************************************************************//**
@ -385,8 +389,8 @@ IMPORTANT: if page_zip_reorganize() is invoked on a leaf page of a
non-clustered index, the caller must update the insert buffer free
bits in the same mini-transaction in such a way that the modification
will be redo-logged.
@return TRUE on success, FALSE on failure; page and page_zip will be
left intact on failure. */
@return TRUE on success, FALSE on failure; page_zip will be left
intact on failure, but page will be overwritten. */
UNIV_INTERN
ibool
page_zip_reorganize(

6
include/pars0pars.h

@ -583,6 +583,12 @@ pars_info_get_bound_id(
pars_info_t* info, /*!< in: info struct */
const char* name); /*!< in: bound id name to find */
/******************************************************************//**
Release any resources used by the lexer. */
UNIV_INTERN
void
pars_lexer_close(void);
/*==================*/
/** Extra information supplied for pars_sql(). */
struct pars_info_struct {

2
include/row0ins.h

@ -45,7 +45,7 @@ row_ins_check_foreign_constraint(
/*=============================*/
ibool check_ref,/*!< in: TRUE If we want to check that
the referenced table is ok, FALSE if we
want to to check the foreign key table */
want to check the foreign key table */
dict_foreign_t* foreign,/*!< in: foreign constraint; NOTE that the
tables mentioned in it must be in the
dictionary cache if they exist at all */

2
include/row0mysql.h

@ -756,8 +756,6 @@ struct row_prebuilt_struct {
store it here so that we can return
it to MySQL */
/*----------------------*/
UT_LIST_NODE_T(row_prebuilt_t) prebuilts;
/*!< list node of table->prebuilts */
ulint magic_n2; /*!< this should be the same as
magic_n */
};

2
include/srv0srv.h

@ -416,7 +416,7 @@ void
srv_init(void);
/*==========*/
/*********************************************************************//**
Frees the OS fast mutex created in srv_boot(). */
Frees the data structures created in srv_init(). */
UNIV_INTERN
void
srv_free(void);

6
include/thr0loc.h

@ -39,6 +39,12 @@ UNIV_INTERN
void
thr_local_init(void);
/*================*/
/****************************************************************//**
Close the thread local storage module. */
UNIV_INTERN
void
thr_local_close(void);
/*=================*/
/*******************************************************************//**
Creates a local storage struct for the calling new thread. */
UNIV_INTERN

7
include/trx0i_s.h

@ -141,6 +141,13 @@ void
trx_i_s_cache_init(
/*===============*/
trx_i_s_cache_t* cache); /*!< out: cache to init */
/*******************************************************************//**
Free the INFORMATION SCHEMA trx related cache. */
UNIV_INTERN
void
trx_i_s_cache_free(
/*===============*/
trx_i_s_cache_t* cache); /*!< in/out: cache to free */
/*******************************************************************//**
Issue a shared/read lock on the tables cache. */

6
include/trx0purge.h

@ -71,6 +71,12 @@ void
trx_purge_sys_create(void);
/*======================*/
/********************************************************************//**
Frees the global purge system control structure. */
UNIV_INTERN
void
trx_purge_sys_close(void);
/*======================*/
/************************************************************************
Adds the update undo log as the first log in the history list. Removes the
update undo log segment from the rseg slot if it is too big for reuse. */
UNIV_INTERN

7
include/trx0rseg.h

@ -125,6 +125,13 @@ trx_rseg_create(
ulint max_size, /*!< in: max size in pages */
ulint* id, /*!< out: rseg id */
mtr_t* mtr); /*!< in: mtr */
/***************************************************************************
Free's an instance of the rollback segment in memory. */
UNIV_INTERN
void
trx_rseg_mem_free(
/*==============*/
trx_rseg_t* rseg); /* in, own: instance to free */
/* Number of undo log slots in a rollback segment file copy */

6
include/trx0sys.h

@ -334,6 +334,12 @@ void
trx_sys_file_format_tag_init(void);
/*==============================*/
/*****************************************************************//**
Shutdown/Close the transaction system. */
UNIV_INTERN
void
trx_sys_close(void);
/*===============*/
/*****************************************************************//**
Get the name representation of the file format from its id.
@return pointer to the name */
UNIV_INTERN

2
include/trx0types.h

@ -70,7 +70,7 @@ typedef struct trx_named_savept_struct trx_named_savept_t;
enum trx_rb_ctx {
RB_NONE = 0, /*!< no rollback */
RB_NORMAL, /*!< normal rollback */
RB_RECOVERY, /*!< rolling back an incomplete transaction,
RB_RECOVERY /*!< rolling back an incomplete transaction,
in crash recovery */
};

7
include/trx0undo.h

@ -333,6 +333,13 @@ trx_undo_parse_discard_latest(
byte* end_ptr,/*!< in: buffer end */
page_t* page, /*!< in: page or NULL */
mtr_t* mtr); /*!< in: mtr or NULL */
/************************************************************************
Frees an undo log memory copy. */
UNIV_INTERN
void
trx_undo_mem_free(
/*==============*/
trx_undo_t* undo); /* in: the undo object to be freed */
/* Types of an undo log segment */
#define TRX_UNDO_INSERT 1 /* contains undo entries for inserts */

2
include/univ.i

@ -240,7 +240,7 @@ by one. */
/* Linkage specifier for non-static InnoDB symbols (variables and functions)
that are only referenced from within InnoDB, not from MySQL */
#if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(UNIV_HOTBACKUP)
#if defined(__GNUC__) && (__GNUC__ >= 4) || defined(__INTEL_COMPILER)
# define UNIV_INTERN __attribute__((visibility ("hidden")))
#else
# define UNIV_INTERN

12
include/usr0sess.h

@ -44,14 +44,12 @@ sess_t*
sess_open(void);
/*============*/
/*********************************************************************//**
Closes a session, freeing the memory occupied by it, if it is in a state
where it should be closed.
@return TRUE if closed */
Closes a session, freeing the memory occupied by it. */
UNIV_INTERN
ibool
sess_try_close(
/*===========*/
sess_t* sess); /*!< in, own: session object */
void
sess_close(
/*=======*/
sess_t* sess); /* in, own: session object */
/* The session handle. All fields are protected by the kernel mutex */
struct sess_struct{

26
lock/lock0lock.c

@ -577,6 +577,23 @@ lock_sys_create(
ut_a(lock_latest_err_file);
}
/*********************************************************************//**
Closes the lock system at database shutdown. */
UNIV_INTERN
void
lock_sys_close(void)
/*================*/
{
if (lock_latest_err_file != NULL) {
fclose(lock_latest_err_file);
lock_latest_err_file = NULL;
}
hash_table_free(lock_sys->rec_hash);
mem_free(lock_sys);
lock_sys = NULL;
}
/*********************************************************************//**
Gets the size of a lock struct.
@return size in bytes */
@ -4633,6 +4650,10 @@ lock_rec_queue_validate(
next function call: we have to release lock table mutex
to obey the latching order */
/* If this thread is holding the file space latch
(fil_space_t::latch), the following check WILL break
latching order and may cause a deadlock of threads. */
impl_trx = lock_sec_rec_some_has_impl_off_kernel(
rec, index, offsets);
@ -4756,6 +4777,11 @@ loop:
lock_mutex_exit_kernel();
/* If this thread is holding the file space
latch (fil_space_t::latch), the following
check WILL break the latching order and may
cause a deadlock of threads. */
lock_rec_queue_validate(block, rec, index, offsets);
lock_mutex_enter_kernel();

138
log/log0log.c

@ -241,6 +241,7 @@ log_reserve_and_open(
ut_a(len < log->buf_size / 2);
loop:
mutex_enter(&(log->mutex));
ut_ad(!recv_no_log_write);
/* Calculate an upper limit for the space the string may take in the
log buffer */
@ -309,6 +310,7 @@ log_write_low(
ut_ad(mutex_own(&(log->mutex)));
part_loop:
ut_ad(!recv_no_log_write);
/* Calculate a part length */
data_len = (log->buf_free % OS_FILE_LOG_BLOCK_SIZE) + str_len;
@ -377,6 +379,7 @@ log_close(void)
ib_uint64_t checkpoint_age;
ut_ad(mutex_own(&(log->mutex)));
ut_ad(!recv_no_log_write);
lsn = log->lsn;
@ -668,8 +671,6 @@ log_calc_max_ages(void)
ulint archive_margin;
ulint smallest_archive_margin;
ut_ad(!mutex_own(&(log_sys->mutex)));
mutex_enter(&(log_sys->mutex));
group = UT_LIST_GET_FIRST(log_sys->log_groups);
@ -770,8 +771,6 @@ void
log_init(void)
/*==========*/
{
byte* buf;
log_sys = mem_alloc(sizeof(log_t));
mutex_create(&log_sys->mutex, SYNC_LOG);
@ -786,8 +785,8 @@ log_init(void)
ut_a(LOG_BUFFER_SIZE >= 16 * OS_FILE_LOG_BLOCK_SIZE);
ut_a(LOG_BUFFER_SIZE >= 4 * UNIV_PAGE_SIZE);
buf = mem_alloc(LOG_BUFFER_SIZE + OS_FILE_LOG_BLOCK_SIZE);
log_sys->buf = ut_align(buf, OS_FILE_LOG_BLOCK_SIZE);
log_sys->buf_ptr = mem_alloc(LOG_BUFFER_SIZE + OS_FILE_LOG_BLOCK_SIZE);
log_sys->buf = ut_align(log_sys->buf_ptr, OS_FILE_LOG_BLOCK_SIZE);
log_sys->buf_size = LOG_BUFFER_SIZE;
@ -832,9 +831,9 @@ log_init(void)
rw_lock_create(&log_sys->checkpoint_lock, SYNC_NO_ORDER_CHECK);
log_sys->checkpoint_buf
= ut_align(mem_alloc(2 * OS_FILE_LOG_BLOCK_SIZE),
OS_FILE_LOG_BLOCK_SIZE);
log_sys->checkpoint_buf_ptr = mem_alloc(2 * OS_FILE_LOG_BLOCK_SIZE);
log_sys->checkpoint_buf = ut_align(log_sys->checkpoint_buf_ptr,
OS_FILE_LOG_BLOCK_SIZE);
memset(log_sys->checkpoint_buf, '\0', OS_FILE_LOG_BLOCK_SIZE);
/*----------------------------*/
@ -917,23 +916,33 @@ log_group_init(
group->lsn_offset = LOG_FILE_HDR_SIZE;
group->n_pending_writes = 0;
group->file_header_bufs_ptr = mem_alloc(sizeof(byte*) * n_files);
group->file_header_bufs = mem_alloc(sizeof(byte*) * n_files);
#ifdef UNIV_LOG_ARCHIVE
group->archive_file_header_bufs_ptr = mem_alloc(
sizeof(byte*) * n_files);
group->archive_file_header_bufs = mem_alloc(sizeof(byte*) * n_files);
#endif /* UNIV_LOG_ARCHIVE */
for (i = 0; i < n_files; i++) {
*(group->file_header_bufs + i) = ut_align(
mem_alloc(LOG_FILE_HDR_SIZE + OS_FILE_LOG_BLOCK_SIZE),
group->file_header_bufs_ptr[i] = mem_alloc(
LOG_FILE_HDR_SIZE + OS_FILE_LOG_BLOCK_SIZE);
group->file_header_bufs[i] = ut_align(
group->file_header_bufs_ptr[i],
OS_FILE_LOG_BLOCK_SIZE);
memset(*(group->file_header_bufs + i), '\0',
LOG_FILE_HDR_SIZE);
#ifdef UNIV_LOG_ARCHIVE
*(group->archive_file_header_bufs + i) = ut_align(
mem_alloc(LOG_FILE_HDR_SIZE + OS_FILE_LOG_BLOCK_SIZE),
group->archive_file_header_bufs_ptr[i] = mem_alloc(
LOG_FILE_HDR_SIZE + OS_FILE_LOG_BLOCK_SIZE);
group->archive_file_header_bufs[i] = ut_align(
group->archive_file_header_bufs_ptr[i],
OS_FILE_LOG_BLOCK_SIZE);
memset(*(group->archive_file_header_bufs + i), '\0',
LOG_FILE_HDR_SIZE);
#endif /* UNIV_LOG_ARCHIVE */
@ -946,8 +955,9 @@ log_group_init(
group->archived_offset = 0;
#endif /* UNIV_LOG_ARCHIVE */
group->checkpoint_buf = ut_align(
mem_alloc(2 * OS_FILE_LOG_BLOCK_SIZE), OS_FILE_LOG_BLOCK_SIZE);
group->checkpoint_buf_ptr = mem_alloc(2 * OS_FILE_LOG_BLOCK_SIZE);
group->checkpoint_buf = ut_align(group->checkpoint_buf_ptr,
OS_FILE_LOG_BLOCK_SIZE);
memset(group->checkpoint_buf, '\0', OS_FILE_LOG_BLOCK_SIZE);
@ -1117,6 +1127,7 @@ log_io_complete(
}
mutex_enter(&(log_sys->mutex));
ut_ad(!recv_no_log_write);
ut_a(group->n_pending_writes > 0);
ut_a(log_sys->n_pending_writes > 0);
@ -1148,6 +1159,7 @@ log_group_file_header_flush(
ulint dest_offset;
ut_ad(mutex_own(&(log_sys->mutex)));
ut_ad(!recv_no_log_write);
ut_a(nth_file < group->n_files);
buf = *(group->file_header_bufs + nth_file);
@ -1219,6 +1231,7 @@ log_group_write_buf(
ulint i;
ut_ad(mutex_own(&(log_sys->mutex)));
ut_ad(!recv_no_log_write);
ut_a(len % OS_FILE_LOG_BLOCK_SIZE == 0);
ut_a(((ulint) start_lsn) % OS_FILE_LOG_BLOCK_SIZE == 0);
@ -1361,6 +1374,7 @@ loop:
#endif
mutex_enter(&(log_sys->mutex));
ut_ad(!recv_no_log_write);
if (flush_to_disk
&& log_sys->flushed_to_disk_lsn >= lsn) {
@ -1974,6 +1988,7 @@ log_checkpoint(
mutex_enter(&(log_sys->mutex));
ut_ad(!recv_no_log_write);
oldest_lsn = log_buf_pool_get_oldest_modification();
mutex_exit(&(log_sys->mutex));
@ -2086,6 +2101,7 @@ loop:
do_checkpoint = FALSE;
mutex_enter(&(log->mutex));
ut_ad(!recv_no_log_write);
if (log->check_flush_or_checkpoint == FALSE) {
mutex_exit(&(log->mutex));
@ -3035,6 +3051,7 @@ loop:
#endif /* UNIV_LOG_ARCHIVE */
mutex_enter(&(log_sys->mutex));
ut_ad(!recv_no_log_write);
if (log_sys->check_flush_or_checkpoint) {
@ -3356,4 +3373,95 @@ log_refresh_stats(void)
log_sys->n_log_ios_old = log_sys->n_log_ios;
log_sys->last_printout_time = time(NULL);
}
/**********************************************************************
Closes a log group. */
static
void
log_group_close(
/*===========*/
log_group_t* group) /* in,own: log group to close */
{
ulint i;
for (i = 0; i < group->n_files; i++) {
mem_free(group->file_header_bufs_ptr[i]);
#ifdef UNIV_LOG_ARCHIVE
mem_free(group->archive_file_header_bufs_ptr[i]);
#endif /* UNIV_LOG_ARCHIVE */
}
mem_free(group->file_header_bufs_ptr);
mem_free(group->file_header_bufs);
#ifdef UNIV_LOG_ARCHIVE
mem_free(group->archive_file_header_bufs_ptr);
mem_free(group->archive_file_header_bufs);
#endif /* UNIV_LOG_ARCHIVE */
mem_free(group->checkpoint_buf_ptr);
mem_free(group);
}
/**********************************************************
Shutdown the log system but do not release all the memory. */
UNIV_INTERN
void
log_shutdown(void)
/*==============*/
{
log_group_t* group;
group = UT_LIST_GET_FIRST(log_sys->log_groups);
while (UT_LIST_GET_LEN(log_sys->log_groups) > 0) {
log_group_t* prev_group = group;
group = UT_LIST_GET_NEXT(log_groups, group);
UT_LIST_REMOVE(log_groups, log_sys->log_groups, prev_group);
log_group_close(prev_group);
}
mem_free(log_sys->buf_ptr);
log_sys->buf_ptr = NULL;
log_sys->buf = NULL;
mem_free(log_sys->checkpoint_buf_ptr);
log_sys->checkpoint_buf_ptr = NULL;
log_sys->checkpoint_buf = NULL;
os_event_free(log_sys->no_flush_event);
os_event_free(log_sys->one_flushed_event);
rw_lock_free(&log_sys->checkpoint_lock);
mutex_free(&log_sys->mutex);
#ifdef UNIV_LOG_ARCHIVE
rw_lock_free(&log_sys->archive_lock);
os_event_create(log_sys->archiving_on);
#endif /* UNIV_LOG_ARCHIVE */
#ifdef UNIV_LOG_DEBUG
recv_sys_debug_free();
#endif
recv_sys_close();
}
/**********************************************************
Free the log system data structures. */
UNIV_INTERN
void
log_mem_free(void)
/*==============*/
{
if (log_sys != NULL) {
recv_sys_mem_free();
mem_free(log_sys);
log_sys = NULL;
}
}
#endif /* !UNIV_HOTBACKUP */

148
log/log0recv.c

@ -69,20 +69,25 @@ UNIV_INTERN recv_sys_t* recv_sys = NULL;
/** TRUE when applying redo log records during crash recovery; FALSE
otherwise. Note that this is FALSE while a background thread is
rolling back incomplete transactions. */
UNIV_INTERN ibool recv_recovery_on = FALSE;
UNIV_INTERN ibool recv_recovery_on;
#ifdef UNIV_LOG_ARCHIVE
/** TRUE when applying redo log records from an archived log file */
UNIV_INTERN ibool recv_recovery_from_backup_on = FALSE;
UNIV_INTERN ibool recv_recovery_from_backup_on;
#endif /* UNIV_LOG_ARCHIVE */
#ifndef UNIV_HOTBACKUP
/** TRUE when recv_init_crash_recovery() has been called. */
UNIV_INTERN ibool recv_needed_recovery = FALSE;
UNIV_INTERN ibool recv_needed_recovery;
# ifdef UNIV_DEBUG
/** TRUE if writing to the redo log (mtr_commit) is forbidden.
Protected by log_sys->mutex. */
UNIV_INTERN ibool recv_no_log_write = FALSE;
# endif /* UNIV_DEBUG */
/** TRUE if buf_page_is_corrupted() should check if the log sequence
number (FIL_PAGE_LSN) is in the future. Initially FALSE, and set by
recv_recovery_from_checkpoint_start_func(). */
UNIV_INTERN ibool recv_lsn_checks_on = FALSE;
UNIV_INTERN ibool recv_lsn_checks_on;
/** There are two conditions under which we scan the logs, the first
is normal startup and the second is when we do a recovery from an
@ -92,7 +97,7 @@ startup. If we find log entries that were written after the last checkpoint
we know that the server was not cleanly shutdown. We must then initialize
the crash recovery environment before attempting to store these entries in
the log hash table. */
static ibool recv_log_scan_is_startup_type = FALSE;
static ibool recv_log_scan_is_startup_type;
/** If the following is TRUE, the buffer pool file pages must be invalidated
after recovery and no ibuf operations are allowed; this becomes TRUE if
@ -103,7 +108,7 @@ buffer pool before the pages have been recovered to the up-to-date state.
TRUE means that recovery is running and no operations on the log files
are allowed yet: the variable name is misleading. */
UNIV_INTERN ibool recv_no_ibuf_operations = FALSE;
UNIV_INTERN ibool recv_no_ibuf_operations;
/** TRUE when the redo log is being backed up */
# define recv_is_making_a_backup FALSE
/** TRUE when recovering from a backed up redo log file */
@ -111,24 +116,24 @@ UNIV_INTERN ibool recv_no_ibuf_operations = FALSE;
#else /* !UNIV_HOTBACKUP */
# define recv_needed_recovery FALSE
/** TRUE when the redo log is being backed up */
UNIV_INTERN ibool recv_is_making_a_backup = FALSE;
UNIV_INTERN ibool recv_is_making_a_backup = FALSE;
/** TRUE when recovering from a backed up redo log file */
UNIV_INTERN ibool recv_is_from_backup = FALSE;
# define buf_pool_get_curr_size() (5 * 1024 * 1024)
#endif /* !UNIV_HOTBACKUP */
/** The following counter is used to decide when to print info on
log scan */
static ulint recv_scan_print_counter = 0;
static ulint recv_scan_print_counter;
/** The type of the previous parsed redo log record */
static ulint recv_previous_parsed_rec_type = 999999;
static ulint recv_previous_parsed_rec_type;
/** The offset of the previous parsed redo log record */
static ulint recv_previous_parsed_rec_offset = 0;
static ulint recv_previous_parsed_rec_offset;
/** The 'multi' flag of the previous parsed redo log record */
static ulint recv_previous_parsed_rec_is_multi = 0;
static ulint recv_previous_parsed_rec_is_multi;
/** Maximum page number encountered in the redo log */
UNIV_INTERN ulint recv_max_parsed_page_no = 0;
UNIV_INTERN ulint recv_max_parsed_page_no;
/** This many frames must be left free in the buffer pool when we scan
the log and store the scanned log records in the buffer pool: we will
@ -136,7 +141,7 @@ use these free frames to read in pages when we start applying the
log records to the database.
This is the default value. If the actual size of the buffer pool is
larger than 10 MB we'll set this value to 512. */
UNIV_INTERN ulint recv_n_pool_free_frames = 256;
UNIV_INTERN ulint recv_n_pool_free_frames;
/** The maximum lsn we see for a page during the recovery process. If this
is bigger than the lsn we are able to scan up to, that is an indication that
@ -167,7 +172,8 @@ recv_sys_create(void)
return;
}
recv_sys = mem_alloc(sizeof(recv_sys_t));
recv_sys = mem_alloc(sizeof(*recv_sys));
memset(recv_sys, 0x0, sizeof(*recv_sys));
mutex_create(&recv_sys->mutex, SYNC_RECV);
@ -176,6 +182,106 @@ recv_sys_create(void)
}
/********************************************************//**
Release recovery system mutexes. */
UNIV_INTERN
void
recv_sys_close(void)
/*================*/
{
if (recv_sys != NULL) {
if (recv_sys->addr_hash != NULL) {
hash_table_free(recv_sys->addr_hash);
}
if (recv_sys->heap != NULL) {
mem_heap_free(recv_sys->heap);
}
if (recv_sys->buf != NULL) {
ut_free(recv_sys->buf);
}
if (recv_sys->last_block_buf_start != NULL) {
mem_free(recv_sys->last_block_buf_start);
}
mutex_free(&recv_sys->mutex);
mem_free(recv_sys);
recv_sys = NULL;
}
}
/********************************************************//**
Frees the recovery system memory. */
UNIV_INTERN
void
recv_sys_mem_free(void)
/*===================*/
{
if (recv_sys != NULL) {
if (recv_sys->addr_hash != NULL) {
hash_table_free(recv_sys->addr_hash);
}
if (recv_sys->heap != NULL) {
mem_heap_free(recv_sys->heap);
}
if (recv_sys->buf != NULL) {
ut_free(recv_sys->buf);
}
if (recv_sys->last_block_buf_start != NULL) {
mem_free(recv_sys->last_block_buf_start);
}
mem_free(recv_sys);
recv_sys = NULL;
}
}
/************************************************************
Reset the state of the recovery system variables. */
UNIV_INTERN
void
recv_sys_var_init(void)
/*===================*/
{
recv_lsn_checks_on = FALSE;
recv_n_pool_free_frames = 256;
recv_recovery_on = FALSE;
#ifdef UNIV_LOG_ARCHIVE
recv_recovery_from_backup_on = FALSE;
#endif /* UNIV_LOG_ARCHIVE */
recv_needed_recovery = FALSE;
recv_lsn_checks_on = FALSE;
recv_log_scan_is_startup_type = FALSE;
recv_no_ibuf_operations = FALSE;
recv_scan_print_counter = 0;
recv_previous_parsed_rec_type = 999999;
recv_previous_parsed_rec_offset = 0;
recv_previous_parsed_rec_is_multi = 0;
recv_max_parsed_page_no = 0;
recv_n_pool_free_frames = 256;
recv_max_page_lsn = 0;
}
/************************************************************
Inits the recovery system for a recovery operation. */
UNIV_INTERN
void
@ -264,8 +370,8 @@ recv_sys_empty_hash(void)
Frees the recovery system. */
static
void
recv_sys_free(void)
/*===============*/
recv_sys_debug_free(void)
/*=====================*/
{
mutex_enter(&(recv_sys->mutex));
@ -274,8 +380,10 @@ recv_sys_free(void)
ut_free(recv_sys->buf);
mem_free(recv_sys->last_block_buf_start);
recv_sys->addr_hash = NULL;
recv_sys->buf = NULL;
recv_sys->heap = NULL;
recv_sys->addr_hash = NULL;
recv_sys->last_block_buf_start = NULL;
mutex_exit(&(recv_sys->mutex));
@ -1293,7 +1401,7 @@ recv_add_to_hash_table(
sizeof(recv_data_t) + len);
*prev_field = recv_data;
ut_memcpy(((byte*)recv_data) + sizeof(recv_data_t), body, len);
memcpy(recv_data + 1, body, len);
prev_field = &(recv_data->next);
@ -1724,6 +1832,7 @@ loop:
/* Flush all the file pages to disk and invalidate them in
the buffer pool */
ut_d(recv_no_log_write = TRUE);
mutex_exit(&(recv_sys->mutex));
mutex_exit(&(log_sys->mutex));
@ -1737,6 +1846,7 @@ loop:
mutex_enter(&(log_sys->mutex));
mutex_enter(&(recv_sys->mutex));
ut_d(recv_no_log_write = FALSE);
recv_no_ibuf_operations = FALSE;
}
@ -3161,7 +3271,7 @@ recv_recovery_from_checkpoint_finish(void)
recv_recovery_on = FALSE;
#ifndef UNIV_LOG_DEBUG
recv_sys_free();
recv_sys_debug_free();
#endif
/* Roll back any recovered data dictionary transactions, so
that the data dictionary tables will be free of any locks.

11
mem/mem0dbg.c

@ -170,6 +170,17 @@ mem_init(
mem_comm_pool = mem_pool_create(size);
}
/******************************************************************//**
Closes the memory system. */
UNIV_INTERN
void
mem_close(void)
/*===========*/
{
mem_pool_free(mem_comm_pool);
mem_comm_pool = NULL;
}
#endif /* !UNIV_HOTBACKUP */
#ifdef UNIV_MEM_DEBUG

12
mem/mem0pool.c

@ -260,6 +260,18 @@ mem_pool_create(
return(pool);
}
/********************************************************************//**
Frees a memory pool. */
UNIV_INTERN
void
mem_pool_free(
/*==========*/
mem_pool_t* pool) /*!< in, own: memory pool */
{
ut_free(pool->buf);
ut_free(pool);
}
/********************************************************************//**
Fills the specified free list.
@return TRUE if we were able to insert a block to the free list */

3
mtr/mtr0mtr.c

@ -35,6 +35,7 @@ Created 11/26/1995 Heikki Tuuri
#include "log0log.h"
#ifndef UNIV_HOTBACKUP
# include "log0recv.h"
/*****************************************************************//**
Releases the item in the slot given. */
UNIV_INLINE
@ -181,6 +182,8 @@ mtr_commit(
ut_d(mtr->state = MTR_COMMITTING);
#ifndef UNIV_HOTBACKUP
/* This is a dirty read, for debugging. */
ut_ad(!recv_no_log_write);
write_log = mtr->modifications && mtr->n_log_recs;
if (write_log) {

243
mysql-test/innodb-autoinc.result

@ -867,6 +867,7 @@ INSERT INTO t2 SELECT NULL FROM t1;
Got one of the listed errors
DROP TABLE t1;
DROP TABLE t2;
SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (null);
INSERT INTO t1 VALUES (null);
@ -874,18 +875,254 @@ ALTER TABLE t1 CHANGE c1 d1 INT NOT NULL AUTO_INCREMENT;
SELECT * FROM t1;
d1
1
3
2
SELECT * FROM t1;
d1
1
3
2
INSERT INTO t1 VALUES(null);
Got one of the listed errors
ALTER TABLE t1 AUTO_INCREMENT = 3;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`d1` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`d1`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES(null);
SELECT * FROM t1;
d1
1
2
3
4
DROP TABLE t1;
SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
SHOW VARIABLES LIKE "%auto_inc%";
Variable_name Value
auto_increment_increment 1
auto_increment_offset 1
CREATE TABLE t1 (c1 TINYINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1, NULL);
INSERT INTO t1 VALUES (-1, 'innodb');
INSERT INTO t1 VALUES (-127, 'innodb');
INSERT INTO t1 VALUES (NULL, NULL);
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` tinyint(4) NOT NULL AUTO_INCREMENT,
`c2` varchar(10) DEFAULT NULL,
PRIMARY KEY (`c1`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1
SELECT * FROM t1;
c1 c2
-127 innodb
-1 innodb
1 NULL
2 NULL
DROP TABLE t1;
CREATE TABLE t1 (c1 TINYINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1, NULL);
INSERT INTO t1 VALUES (-1, 'innodb');
Warnings:
Warning 1264 Out of range value for column 'c1' at row 1
INSERT INTO t1 VALUES (-127, 'innodb');
Warnings:
Warning 1264 Out of range value for column 'c1' at row 1
INSERT INTO t1 VALUES (NULL, NULL);
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
`c2` varchar(10) DEFAULT NULL,
PRIMARY KEY (`c1`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1
SELECT * FROM t1;
c1 c2
1 NULL
2 innodb
3 innodb
4 NULL
DROP TABLE t1;
CREATE TABLE t1 (c1 SMALLINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1, NULL);
INSERT INTO t1 VALUES (-1, 'innodb');
INSERT INTO t1 VALUES (-32767, 'innodb');
INSERT INTO t1 VALUES (NULL, NULL);
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` smallint(6) NOT NULL AUTO_INCREMENT,
`c2` varchar(10) DEFAULT NULL,
PRIMARY KEY (`c1`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1
SELECT * FROM t1;
c1 c2
-32767 innodb
-1 innodb
1 NULL
2 NULL
DROP TABLE t1;
CREATE TABLE t1 (c1 SMALLINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1, NULL);
INSERT INTO t1 VALUES (-1, 'innodb');
Warnings:
Warning 1264 Out of range value for column 'c1' at row 1
INSERT INTO t1 VALUES (-32757, 'innodb');
Warnings:
Warning 1264 Out of range value for column 'c1' at row 1
INSERT INTO t1 VALUES (NULL, NULL);
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
`c2` varchar(10) DEFAULT NULL,
PRIMARY KEY (`c1`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1
SELECT * FROM t1;
c1 c2
1 NULL
2 innodb
3 innodb
4 NULL
DROP TABLE t1;
CREATE TABLE t1 (c1 MEDIUMINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1, NULL);
INSERT INTO t1 VALUES (-1, 'innodb');
INSERT INTO t1 VALUES (-8388607, 'innodb');
INSERT INTO t1 VALUES (NULL, NULL);
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` mediumint(9) NOT NULL AUTO_INCREMENT,
`c2` varchar(10) DEFAULT NULL,
PRIMARY KEY (`c1`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1
SELECT * FROM t1;
c1 c2
-8388607 innodb
-1 innodb
1 NULL
2 NULL
DROP TABLE t1;
CREATE TABLE t1 (c1 MEDIUMINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1, NULL);
INSERT INTO t1 VALUES (-1, 'innodb');
Warnings:
Warning 1264 Out of range value for column 'c1' at row 1
INSERT INTO t1 VALUES (-8388607, 'innodb');
Warnings:
Warning 1264 Out of range value for column 'c1' at row 1
INSERT INTO t1 VALUES (NULL, NULL);
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`c2` varchar(10) DEFAULT NULL,
PRIMARY KEY (`c1`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1
SELECT * FROM t1;
c1 c2
1 NULL
2 innodb
3 innodb
4 NULL
DROP TABLE t1;
CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1, NULL);
INSERT INTO t1 VALUES (-1, 'innodb');
INSERT INTO t1 VALUES (-2147483647, 'innodb');
INSERT INTO t1 VALUES (NULL, NULL);
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) NOT NULL AUTO_INCREMENT,
`c2` varchar(10) DEFAULT NULL,
PRIMARY KEY (`c1`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1
SELECT * FROM t1;
c1 c2
-2147483647 innodb
-1 innodb
1 NULL
2 NULL
DROP TABLE t1;
CREATE TABLE t1 (c1 INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1, NULL);
INSERT INTO t1 VALUES (-1, 'innodb');
Warnings:
Warning 1264 Out of range value for column 'c1' at row 1
INSERT INTO t1 VALUES (-2147483647, 'innodb');
Warnings:
Warning 1264 Out of range value for column 'c1' at row 1
INSERT INTO t1 VALUES (NULL, NULL);
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(10) unsigned NOT NULL AUTO_INCREMENT,
`c2` varchar(10) DEFAULT NULL,
PRIMARY KEY (`c1`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1
SELECT * FROM t1;
c1 c2
1 NULL
2 innodb
3 innodb
4 NULL
DROP TABLE t1;
CREATE TABLE t1 (c1 BIGINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1, NULL);
INSERT INTO t1 VALUES (-1, 'innodb');
INSERT INTO t1 VALUES (-9223372036854775807, 'innodb');
INSERT INTO t1 VALUES (NULL, NULL);
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` bigint(20) NOT NULL AUTO_INCREMENT,
`c2` varchar(10) DEFAULT NULL,
PRIMARY KEY (`c1`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1
SELECT * FROM t1;
c1 c2
-9223372036854775807 innodb
-1 innodb
1 NULL
2 NULL
DROP TABLE t1;
CREATE TABLE t1 (c1 BIGINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1, NULL);
INSERT INTO t1 VALUES (-1, 'innodb');
Warnings:
Warning 1264 Out of range value for column 'c1' at row 1
INSERT INTO t1 VALUES (-9223372036854775807, 'innodb');
Warnings:
Warning 1264 Out of range value for column 'c1' at row 1
INSERT INTO t1 VALUES (NULL, NULL);
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`c2` varchar(10) DEFAULT NULL,
PRIMARY KEY (`c1`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1
SELECT * FROM t1;
c1 c2
1 NULL
2 innodb
3 innodb
4 NULL
DROP TABLE t1;
CREATE TABLE T1 (c1 INT AUTO_INCREMENT, c2 INT, PRIMARY KEY(c1)) AUTO_INCREMENT=10 ENGINE=InnoDB;
CREATE INDEX i1 on T1(c2);
SHOW CREATE TABLE T1;
Table Create Table
T1 CREATE TABLE `T1` (
`c1` int(11) NOT NULL AUTO_INCREMENT,
`c2` int(11) DEFAULT NULL,
PRIMARY KEY (`c1`),
KEY `i1` (`c2`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1
INSERT INTO T1 (c2) values (0);
SELECT * FROM T1;
c1 c2
10 0
DROP TABLE T1;

118
mysql-test/innodb-autoinc.test

@ -482,6 +482,7 @@ DROP TABLE t2;
# 44030: Error: (1500) Couldn't read the MAX(ID) autoinc value from
# the index (PRIMARY)
# This test requires a restart of the server
SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (null);
INSERT INTO t1 VALUES (null);
@ -495,6 +496,123 @@ SELECT * FROM t1;
-- error ER_AUTOINC_READ_FAILED,1467
INSERT INTO t1 VALUES(null);
ALTER TABLE t1 AUTO_INCREMENT = 3;
SHOW CREATE TABLE t1;
INSERT INTO t1 VALUES(null);
SELECT * FROM t1;
DROP TABLE t1;
# If the user has specified negative values for an AUTOINC column then
# InnoDB should ignore those values when setting the table's max value.
SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
SHOW VARIABLES LIKE "%auto_inc%";
# TINYINT
CREATE TABLE t1 (c1 TINYINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1, NULL);
INSERT INTO t1 VALUES (-1, 'innodb');
INSERT INTO t1 VALUES (-127, 'innodb');
INSERT INTO t1 VALUES (NULL, NULL);
SHOW CREATE TABLE t1;
SELECT * FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (c1 TINYINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1, NULL);
INSERT INTO t1 VALUES (-1, 'innodb');
INSERT INTO t1 VALUES (-127, 'innodb');
INSERT INTO t1 VALUES (NULL, NULL);
SHOW CREATE TABLE t1;
SELECT * FROM t1;
DROP TABLE t1;
#
# SMALLINT
#
CREATE TABLE t1 (c1 SMALLINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1, NULL);
INSERT INTO t1 VALUES (-1, 'innodb');
INSERT INTO t1 VALUES (-32767, 'innodb');
INSERT INTO t1 VALUES (NULL, NULL);
SHOW CREATE TABLE t1;
SELECT * FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (c1 SMALLINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1, NULL);
INSERT INTO t1 VALUES (-1, 'innodb');
INSERT INTO t1 VALUES (-32757, 'innodb');
INSERT INTO t1 VALUES (NULL, NULL);
SHOW CREATE TABLE t1;
SELECT * FROM t1;
DROP TABLE t1;
#
# MEDIUMINT
#
CREATE TABLE t1 (c1 MEDIUMINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1, NULL);
INSERT INTO t1 VALUES (-1, 'innodb');
INSERT INTO t1 VALUES (-8388607, 'innodb');
INSERT INTO t1 VALUES (NULL, NULL);
SHOW CREATE TABLE t1;
SELECT * FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (c1 MEDIUMINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1, NULL);
INSERT INTO t1 VALUES (-1, 'innodb');
INSERT INTO t1 VALUES (-8388607, 'innodb');
INSERT INTO t1 VALUES (NULL, NULL);
SHOW CREATE TABLE t1;
SELECT * FROM t1;
DROP TABLE t1;
#
# INT
#
CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1, NULL);
INSERT INTO t1 VALUES (-1, 'innodb');
INSERT INTO t1 VALUES (-2147483647, 'innodb');
INSERT INTO t1 VALUES (NULL, NULL);
SHOW CREATE TABLE t1;
SELECT * FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (c1 INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1, NULL);
INSERT INTO t1 VALUES (-1, 'innodb');
INSERT INTO t1 VALUES (-2147483647, 'innodb');
INSERT INTO t1 VALUES (NULL, NULL);
SHOW CREATE TABLE t1;
SELECT * FROM t1;
DROP TABLE t1;
#
# BIGINT
#
CREATE TABLE t1 (c1 BIGINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1, NULL);
INSERT INTO t1 VALUES (-1, 'innodb');
INSERT INTO t1 VALUES (-9223372036854775807, 'innodb');
INSERT INTO t1 VALUES (NULL, NULL);
SHOW CREATE TABLE t1;
SELECT * FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (c1 BIGINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1, NULL);
INSERT INTO t1 VALUES (-1, 'innodb');
INSERT INTO t1 VALUES (-9223372036854775807, 'innodb');
INSERT INTO t1 VALUES (NULL, NULL);
SHOW CREATE TABLE t1;
SELECT * FROM t1;
DROP TABLE t1;
#
# End negative number check
##
# 47125: auto_increment start value is ignored if an index is created
# and engine=innodb
#
CREATE TABLE T1 (c1 INT AUTO_INCREMENT, c2 INT, PRIMARY KEY(c1)) AUTO_INCREMENT=10 ENGINE=InnoDB;
CREATE INDEX i1 on T1(c2);
SHOW CREATE TABLE T1;
INSERT INTO T1 (c2) values (0);
SELECT * FROM T1;
DROP TABLE T1;

98
mysql-test/innodb-zip.result

@ -196,15 +196,15 @@ drop table t1;
set innodb_strict_mode = on;
create table t1 (id int primary key) engine = innodb key_block_size = 0;
ERROR HY000: Can't create table 'test.t1' (errno: 1478)
show errors;
show warnings;
Level Code Message
Error 1478 InnoDB: invalid KEY_BLOCK_SIZE = 0. Valid values are [1, 2, 4, 8, 16]
Warning 1478 InnoDB: invalid KEY_BLOCK_SIZE = 0. Valid values are [1, 2, 4, 8, 16]
Error 1005 Can't create table 'test.t1' (errno: 1478)
create table t2 (id int primary key) engine = innodb key_block_size = 9;
ERROR HY000: Can't create table 'test.t2' (errno: 1478)
show errors;
show warnings;
Level Code Message
Error 1478 InnoDB: invalid KEY_BLOCK_SIZE = 9. Valid values are [1, 2, 4, 8, 16]
Warning 1478 InnoDB: invalid KEY_BLOCK_SIZE = 9. Valid values are [1, 2, 4, 8, 16]
Error 1005 Can't create table 'test.t2' (errno: 1478)
create table t3 (id int primary key) engine = innodb key_block_size = 1;
create table t4 (id int primary key) engine = innodb key_block_size = 2;
@ -233,30 +233,30 @@ key_block_size = 8 row_format = compressed;
create table t2 (id int primary key) engine = innodb
key_block_size = 8 row_format = redundant;
ERROR HY000: Can't create table 'test.t2' (errno: 1478)
show errors;
show warnings;
Level Code Message
Error 1478 InnoDB: cannot specify ROW_FORMAT = REDUNDANT with KEY_BLOCK_SIZE.
Warning 1478 InnoDB: cannot specify ROW_FORMAT = REDUNDANT with KEY_BLOCK_SIZE.
Error 1005 Can't create table 'test.t2' (errno: 1478)
create table t3 (id int primary key) engine = innodb
key_block_size = 8 row_format = compact;
ERROR HY000: Can't create table 'test.t3' (errno: 1478)
show errors;
show warnings;
Level Code Message
Error 1478 InnoDB: cannot specify ROW_FORMAT = COMPACT with KEY_BLOCK_SIZE.
Warning 1478 InnoDB: cannot specify ROW_FORMAT = COMPACT with KEY_BLOCK_SIZE.
Error 1005 Can't create table 'test.t3' (errno: 1478)
create table t4 (id int primary key) engine = innodb
key_block_size = 8 row_format = dynamic;
ERROR HY000: Can't create table 'test.t4' (errno: 1478)
show errors;
show warnings;
Level Code Message
Error 1478 InnoDB: cannot specify ROW_FORMAT = DYNAMIC with KEY_BLOCK_SIZE.
Warning 1478 InnoDB: cannot specify ROW_FORMAT = DYNAMIC with KEY_BLOCK_SIZE.
Error 1005 Can't create table 'test.t4' (errno: 1478)
create table t5 (id int primary key) engine = innodb
key_block_size = 8 row_format = default;
ERROR HY000: Can't create table 'test.t5' (errno: 1478)
show errors;
show warnings;
Level Code Message
Error 1478 InnoDB: cannot specify ROW_FORMAT = COMPACT with KEY_BLOCK_SIZE.
Warning 1478 InnoDB: cannot specify ROW_FORMAT = COMPACT with KEY_BLOCK_SIZE.
Error 1005 Can't create table 'test.t5' (errno: 1478)
SELECT table_schema, table_name, row_format
FROM information_schema.tables WHERE engine='innodb';
@ -266,26 +266,26 @@ drop table t1;
create table t1 (id int primary key) engine = innodb
key_block_size = 9 row_format = redundant;
ERROR HY000: Can't create table 'test.t1' (errno: 1478)
show errors;
show warnings;
Level Code Message
Error 1478 InnoDB: invalid KEY_BLOCK_SIZE = 9. Valid values are [1, 2, 4, 8, 16]
Error 1478 InnoDB: cannot specify ROW_FORMAT = REDUNDANT with KEY_BLOCK_SIZE.
Warning 1478 InnoDB: invalid KEY_BLOCK_SIZE = 9. Valid values are [1, 2, 4, 8, 16]
Warning 1478 InnoDB: cannot specify ROW_FORMAT = REDUNDANT with KEY_BLOCK_SIZE.
Error 1005 Can't create table 'test.t1' (errno: 1478)
create table t2 (id int primary key) engine = innodb
key_block_size = 9 row_format = compact;
ERROR HY000: Can't create table 'test.t2' (errno: 1478)
show errors;
show warnings;
Level Code Message
Error 1478 InnoDB: invalid KEY_BLOCK_SIZE = 9. Valid values are [1, 2, 4, 8, 16]
Error 1478 InnoDB: cannot specify ROW_FORMAT = COMPACT with KEY_BLOCK_SIZE.
Warning 1478 InnoDB: invalid KEY_BLOCK_SIZE = 9. Valid values are [1, 2, 4, 8, 16]
Warning 1478 InnoDB: cannot specify ROW_FORMAT = COMPACT with KEY_BLOCK_SIZE.
Error 1005 Can't create table 'test.t2' (errno: 1478)
create table t2 (id int primary key) engine = innodb
key_block_size = 9 row_format = dynamic;
ERROR HY000: Can't create table 'test.t2' (errno: 1478)
show errors;
show warnings;
Level Code Message
Error 1478 InnoDB: invalid KEY_BLOCK_SIZE = 9. Valid values are [1, 2, 4, 8, 16]
Error 1478 InnoDB: cannot specify ROW_FORMAT = DYNAMIC with KEY_BLOCK_SIZE.
Warning 1478 InnoDB: invalid KEY_BLOCK_SIZE = 9. Valid values are [1, 2, 4, 8, 16]
Warning 1478 InnoDB: cannot specify ROW_FORMAT = DYNAMIC with KEY_BLOCK_SIZE.
Error 1005 Can't create table 'test.t2' (errno: 1478)
SELECT table_schema, table_name, row_format
FROM information_schema.tables WHERE engine='innodb';
@ -293,45 +293,45 @@ table_schema table_name row_format
set global innodb_file_per_table = off;
create table t1 (id int primary key) engine = innodb key_block_size = 1;
ERROR HY000: Can't create table 'test.t1' (errno: 1478)
show errors;
show warnings;
Level Code Message
Error 1478 InnoDB: KEY_BLOCK_SIZE requires innodb_file_per_table.
Warning 1478 InnoDB: KEY_BLOCK_SIZE requires innodb_file_per_table.
Error 1005 Can't create table 'test.t1' (errno: 1478)
create table t2 (id int primary key) engine = innodb key_block_size = 2;
ERROR HY000: Can't create table 'test.t2' (errno: 1478)
show errors;
show warnings;
Level Code Message
Error 1478 InnoDB: KEY_BLOCK_SIZE requires innodb_file_per_table.
Warning 1478 InnoDB: KEY_BLOCK_SIZE requires innodb_file_per_table.
Error 1005 Can't create table 'test.t2' (errno: 1478)
create table t3 (id int primary key) engine = innodb key_block_size = 4;
ERROR HY000: Can't create table 'test.t3' (errno: 1478)
show errors;
show warnings;
Level Code Message
Error 1478 InnoDB: KEY_BLOCK_SIZE requires innodb_file_per_table.
Warning 1478 InnoDB: KEY_BLOCK_SIZE requires innodb_file_per_table.
Error 1005 Can't create table 'test.t3' (errno: 1478)
create table t4 (id int primary key) engine = innodb key_block_size = 8;
ERROR HY000: Can't create table 'test.t4' (errno: 1478)
show errors;
show warnings;
Level Code Message
Error 1478 InnoDB: KEY_BLOCK_SIZE requires innodb_file_per_table.
Warning 1478 InnoDB: KEY_BLOCK_SIZE requires innodb_file_per_table.
Error 1005 Can't create table 'test.t4' (errno: 1478)
create table t5 (id int primary key) engine = innodb key_block_size = 16;
ERROR HY000: Can't create table 'test.t5' (errno: 1478)
show errors;
show warnings;
Level Code Message
Error 1478 InnoDB: KEY_BLOCK_SIZE requires innodb_file_per_table.
Warning 1478 InnoDB: KEY_BLOCK_SIZE requires innodb_file_per_table.
Error 1005 Can't create table 'test.t5' (errno: 1478)
create table t6 (id int primary key) engine = innodb row_format = compressed;
ERROR HY000: Can't create table 'test.t6' (errno: 1478)
show errors;
show warnings;
Level Code Message
Error 1478 InnoDB: ROW_FORMAT=COMPRESSED requires innodb_file_per_table.
Warning 1478 InnoDB: ROW_FORMAT=COMPRESSED requires innodb_file_per_table.
Error 1005 Can't create table 'test.t6' (errno: 1478)
create table t7 (id int primary key) engine = innodb row_format = dynamic;
ERROR HY000: Can't create table 'test.t7' (errno: 1478)
show errors;
show warnings;
Level Code Message
Error 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_per_table.
Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_per_table.
Error 1005 Can't create table 'test.t7' (errno: 1478)
create table t8 (id int primary key) engine = innodb row_format = compact;
create table t9 (id int primary key) engine = innodb row_format = redundant;
@ -345,45 +345,45 @@ set global innodb_file_per_table = on;
set global innodb_file_format = `0`;
create table t1 (id int primary key) engine = innodb key_block_size = 1;
ERROR HY000: Can't create table 'test.t1' (errno: 1478)
show errors;
show warnings;
Level Code Message
Error 1478 InnoDB: KEY_BLOCK_SIZE requires innodb_file_format > Antelope.
Warning 1478 InnoDB: KEY_BLOCK_SIZE requires innodb_file_format > Antelope.
Error 1005 Can't create table 'test.t1' (errno: 1478)
create table t2 (id int primary key) engine = innodb key_block_size = 2;
ERROR HY000: Can't create table 'test.t2' (errno: 1478)
show errors;
show warnings;
Level Code Message
Error 1478 InnoDB: KEY_BLOCK_SIZE requires innodb_file_format > Antelope.
Warning 1478 InnoDB: KEY_BLOCK_SIZE requires innodb_file_format > Antelope.
Error 1005 Can't create table 'test.t2' (errno: 1478)
create table t3 (id int primary key) engine = innodb key_block_size = 4;
ERROR HY000: Can't create table 'test.t3' (errno: 1478)
show errors;
show warnings;
Level Code Message
Error 1478 InnoDB: KEY_BLOCK_SIZE requires innodb_file_format > Antelope.
Warning 1478 InnoDB: KEY_BLOCK_SIZE requires innodb_file_format > Antelope.
Error 1005 Can't create table 'test.t3' (errno: 1478)
create table t4 (id int primary key) engine = innodb key_block_size = 8;
ERROR HY000: Can't create table 'test.t4' (errno: 1478)
show errors;
show warnings;
Level Code Message
Error 1478 InnoDB: KEY_BLOCK_SIZE requires innodb_file_format > Antelope.
Warning 1478 InnoDB: KEY_BLOCK_SIZE requires innodb_file_format > Antelope.
Error 1005 Can't create table 'test.t4' (errno: 1478)
create table t5 (id int primary key) engine = innodb key_block_size = 16;
ERROR HY000: Can't create table 'test.t5' (errno: 1478)
show errors;
show warnings;
Level Code Message
Error 1478 InnoDB: KEY_BLOCK_SIZE requires innodb_file_format > Antelope.
Warning 1478 InnoDB: KEY_BLOCK_SIZE requires innodb_file_format > Antelope.
Error 1005 Can't create table 'test.t5' (errno: 1478)
create table t6 (id int primary key) engine = innodb row_format = compressed;
ERROR HY000: Can't create table 'test.t6' (errno: 1478)
show errors;
show warnings;
Level Code Message
Error 1478 InnoDB: ROW_FORMAT=COMPRESSED requires innodb_file_format > Antelope.
Warning 1478 InnoDB: ROW_FORMAT=COMPRESSED requires innodb_file_format > Antelope.
Error 1005 Can't create table 'test.t6' (errno: 1478)
create table t7 (id int primary key) engine = innodb row_format = dynamic;
ERROR HY000: Can't create table 'test.t7' (errno: 1478)
show errors;
show warnings;
Level Code Message
Error 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_format > Antelope.
Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_format > Antelope.
Error 1005 Can't create table 'test.t7' (errno: 1478)
create table t8 (id int primary key) engine = innodb row_format = compact;
create table t9 (id int primary key) engine = innodb row_format = redundant;

46
mysql-test/innodb-zip.test

@ -174,11 +174,11 @@ set innodb_strict_mode = on;
--error ER_CANT_CREATE_TABLE
create table t1 (id int primary key) engine = innodb key_block_size = 0;
show errors;
show warnings;
--error ER_CANT_CREATE_TABLE
create table t2 (id int primary key) engine = innodb key_block_size = 9;
show errors;
show warnings;
create table t3 (id int primary key) engine = innodb key_block_size = 1;
@ -204,22 +204,22 @@ key_block_size = 8 row_format = compressed;
--error ER_CANT_CREATE_TABLE
create table t2 (id int primary key) engine = innodb
key_block_size = 8 row_format = redundant;
show errors;
show warnings;
--error ER_CANT_CREATE_TABLE
create table t3 (id int primary key) engine = innodb
key_block_size = 8 row_format = compact;
show errors;
show warnings;
--error ER_CANT_CREATE_TABLE
create table t4 (id int primary key) engine = innodb
key_block_size = 8 row_format = dynamic;
show errors;
show warnings;
--error ER_CANT_CREATE_TABLE
create table t5 (id int primary key) engine = innodb
key_block_size = 8 row_format = default;
show errors;
show warnings;
SELECT table_schema, table_name, row_format
FROM information_schema.tables WHERE engine='innodb';
@ -229,17 +229,17 @@ drop table t1;
--error ER_CANT_CREATE_TABLE
create table t1 (id int primary key) engine = innodb
key_block_size = 9 row_format = redundant;
show errors;
show warnings;
--error ER_CANT_CREATE_TABLE
create table t2 (id int primary key) engine = innodb
key_block_size = 9 row_format = compact;
show errors;
show warnings;
--error ER_CANT_CREATE_TABLE
create table t2 (id int primary key) engine = innodb
key_block_size = 9 row_format = dynamic;
show errors;
show warnings;
SELECT table_schema, table_name, row_format
FROM information_schema.tables WHERE engine='innodb';
@ -249,25 +249,25 @@ set global innodb_file_per_table = off;
--error ER_CANT_CREATE_TABLE
create table t1 (id int primary key) engine = innodb key_block_size = 1;
show errors;
show warnings;
--error ER_CANT_CREATE_TABLE
create table t2 (id int primary key) engine = innodb key_block_size = 2;
show errors;
show warnings;
--error ER_CANT_CREATE_TABLE
create table t3 (id int primary key) engine = innodb key_block_size = 4;
show errors;
show warnings;
--error ER_CANT_CREATE_TABLE
create table t4 (id int primary key) engine = innodb key_block_size = 8;
show errors;
show warnings;
--error ER_CANT_CREATE_TABLE
create table t5 (id int primary key) engine = innodb key_block_size = 16;
show errors;
show warnings;
--error ER_CANT_CREATE_TABLE
create table t6 (id int primary key) engine = innodb row_format = compressed;
show errors;
show warnings;
--error ER_CANT_CREATE_TABLE
create table t7 (id int primary key) engine = innodb row_format = dynamic;
show errors;
show warnings;
create table t8 (id int primary key) engine = innodb row_format = compact;
create table t9 (id int primary key) engine = innodb row_format = redundant;
@ -281,25 +281,25 @@ set global innodb_file_format = `0`;
--error ER_CANT_CREATE_TABLE
create table t1 (id int primary key) engine = innodb key_block_size = 1;
show errors;
show warnings;
--error ER_CANT_CREATE_TABLE
create table t2 (id int primary key) engine = innodb key_block_size = 2;
show errors;
show warnings;
--error ER_CANT_CREATE_TABLE
create table t3 (id int primary key) engine = innodb key_block_size = 4;
show errors;
show warnings;
--error ER_CANT_CREATE_TABLE
create table t4 (id int primary key) engine = innodb key_block_size = 8;
show errors;
show warnings;
--error ER_CANT_CREATE_TABLE
create table t5 (id int primary key) engine = innodb key_block_size = 16;
show errors;
show warnings;
--error ER_CANT_CREATE_TABLE
create table t6 (id int primary key) engine = innodb row_format = compressed;
show errors;
show warnings;
--error ER_CANT_CREATE_TABLE
create table t7 (id int primary key) engine = innodb row_format = dynamic;
show errors;
show warnings;
create table t8 (id int primary key) engine = innodb row_format = compact;
create table t9 (id int primary key) engine = innodb row_format = redundant;

8
mysql-test/innodb_bug44369.result

@ -2,13 +2,13 @@ create table bug44369 (DB_ROW_ID int) engine=innodb;
ERROR HY000: Can't create table 'test.bug44369' (errno: -1)
create table bug44369 (db_row_id int) engine=innodb;
ERROR HY000: Can't create table 'test.bug44369' (errno: -1)
show errors;
show warnings;
Level Code Message
Error 1005 Error creating table 'test/bug44369' with column name 'db_row_id'. 'db_row_id' is a reserved name. Please try to re-create the table with a different column name.
Warning 1005 Error creating table 'test/bug44369' with column name 'db_row_id'. 'db_row_id' is a reserved name. Please try to re-create the table with a different column name.
Error 1005 Can't create table 'test.bug44369' (errno: -1)
create table bug44369 (db_TRX_Id int) engine=innodb;
ERROR HY000: Can't create table 'test.bug44369' (errno: -1)
show errors;
show warnings;
Level Code Message
Error 1005 Error creating table 'test/bug44369' with column name 'db_TRX_Id'. 'db_TRX_Id' is a reserved name. Please try to re-create the table with a different column name.
Warning 1005 Error creating table 'test/bug44369' with column name 'db_TRX_Id'. 'db_TRX_Id' is a reserved name. Please try to re-create the table with a different column name.
Error 1005 Can't create table 'test.bug44369' (errno: -1)

4
mysql-test/innodb_bug44369.test

@ -13,9 +13,9 @@ create table bug44369 (DB_ROW_ID int) engine=innodb;
--error ER_CANT_CREATE_TABLE
create table bug44369 (db_row_id int) engine=innodb;
show errors;
show warnings;
--error ER_CANT_CREATE_TABLE
create table bug44369 (db_TRX_Id int) engine=innodb;
show errors;
show warnings;

18
mysql-test/innodb_bug46000.result

@ -1,17 +1,19 @@
create table bug46000(`id` int,key `GEN_CLUST_INDEX`(`id`))engine=innodb;
ERROR HY000: Can't create table 'test.bug46000' (errno: -1)
ERROR 42000: Incorrect index name 'GEN_CLUST_INDEX'
create table bug46000(`id` int, key `GEN_clust_INDEX`(`id`))engine=innodb;
ERROR HY000: Can't create table 'test.bug46000' (errno: -1)
show errors;
ERROR 42000: Incorrect index name 'GEN_CLUST_INDEX'
show warnings;
Level Code Message
Error 1005 Cannot Create Index with name 'GEN_CLUST_INDEX'. The name is reserved for the system default primary index.
Warning 1280 Cannot Create Index with name 'GEN_CLUST_INDEX'. The name is reserved for the system default primary index.
Error 1280 Incorrect index name 'GEN_CLUST_INDEX'
Error 1005 Can't create table 'test.bug46000' (errno: -1)
create table bug46000(id int) engine=innodb;
create index GEN_CLUST_INDEX on bug46000(id);
ERROR HY000: Can't create table '#sql-temporary' (errno: -1)
show errors;
ERROR 42000: Incorrect index name 'GEN_CLUST_INDEX'
show warnings;
Level Code Message
Error 1005 Cannot Create Index with name 'GEN_CLUST_INDEX'. The name is reserved for the system default primary index.
Error 1005 Can't create table '#sql-temporary' (errno: -1)
Warning 1280 Cannot Create Index with name 'GEN_CLUST_INDEX'. The name is reserved for the system default primary index.
Error 1280 Incorrect index name 'GEN_CLUST_INDEX'
Error 1030 Got error -1 from storage engine
create index idx on bug46000(id);
drop table bug46000;

12
mysql-test/innodb_bug46000.test

@ -7,24 +7,22 @@
# This 'create table' operation should fail because of
# using the reserve name as its index name.
--error ER_CANT_CREATE_TABLE
--error ER_WRONG_NAME_FOR_INDEX
create table bug46000(`id` int,key `GEN_CLUST_INDEX`(`id`))engine=innodb;
# Mixed upper/lower case of the reserved key words
--error ER_CANT_CREATE_TABLE
--error ER_WRONG_NAME_FOR_INDEX
create table bug46000(`id` int, key `GEN_clust_INDEX`(`id`))engine=innodb;
show errors;
show warnings;
create table bug46000(id int) engine=innodb;
# This 'create index' operation should fail.
--replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/
--error ER_CANT_CREATE_TABLE
--error ER_WRONG_NAME_FOR_INDEX
create index GEN_CLUST_INDEX on bug46000(id);
--replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/
show errors;
show warnings;
# This 'create index' operation should succeed, no
# temp table left from last failed create index

13
mysql-test/innodb_bug47777.result

@ -0,0 +1,13 @@
create table bug47777(c2 linestring not null, primary key (c2(1))) engine=innodb;
insert into bug47777 values (geomfromtext('linestring(1 2,3 4,5 6,7 8,9 10)'));
select count(*) from bug47777 where c2 =geomfromtext('linestring(1 2,3 4,5 6,7 8,9 10)');
count(*)
1
update bug47777 set c2=GeomFromText('POINT(1 1)');
select count(*) from bug47777 where c2 =geomfromtext('linestring(1 2,3 4,5 6,7 8,9 10)');
count(*)
0
select count(*) from bug47777 where c2 = GeomFromText('POINT(1 1)');
count(*)
1
drop table bug47777;

24
mysql-test/innodb_bug47777.test

@ -0,0 +1,24 @@
# This is the test for bug 47777. GEOMETRY
# data is treated as BLOB data in innodb.
# Consequently, its key value generation/storing
# should follow the process for the BLOB
# datatype as well.
--source include/have_innodb.inc
create table bug47777(c2 linestring not null, primary key (c2(1))) engine=innodb;
insert into bug47777 values (geomfromtext('linestring(1 2,3 4,5 6,7 8,9 10)'));
# Verify correct row get inserted.
select count(*) from bug47777 where c2 =geomfromtext('linestring(1 2,3 4,5 6,7 8,9 10)');
# Update table bug47777 should be successful.
update bug47777 set c2=GeomFromText('POINT(1 1)');
# Verify the row get updated successfully. The original
# c2 value should be changed to GeomFromText('POINT(1 1)').
select count(*) from bug47777 where c2 =geomfromtext('linestring(1 2,3 4,5 6,7 8,9 10)');
select count(*) from bug47777 where c2 = GeomFromText('POINT(1 1)');
drop table bug47777;

16
mysql-test/innodb_information_schema.test

@ -109,14 +109,18 @@ SELECT * FROM ```t'\"_str` WHERE c1 = '3' FOR UPDATE;
-- send
SELECT * FROM ```t'\"_str` WHERE c1 = '4' FOR UPDATE;
# Give time to the above 2 queries to execute before continuing.
# Without this sleep it sometimes happens that the SELECT from innodb_locks
# executes before some of them, resulting in less than expected number
# of rows being selected from innodb_locks.
-- sleep 0.1
-- enable_result_log
-- connection con_verify_innodb_locks
# Wait for the above queries to execute before continuing.
# Without this, it sometimes happens that the SELECT from innodb_locks
# executes before some of them, resulting in less than expected number
# of rows being selected from innodb_locks. If there is a bug and there
# are no 14 rows in innodb_locks then this test will fail with timeout.
let $count = 14;
let $table = INFORMATION_SCHEMA.INNODB_LOCKS;
-- source include/wait_until_rows_count.inc
# the above enables the query log, re-disable it
-- disable_query_log
SELECT lock_mode, lock_type, lock_table, lock_index, lock_rec, lock_data
FROM INFORMATION_SCHEMA.INNODB_LOCKS ORDER BY lock_data;

95
os/os0file.c

@ -398,6 +398,12 @@ os_file_get_last_error(
" software or another instance\n"
"InnoDB: of MySQL."
" Please close it to get rid of this error.\n");
} else if (err == ERROR_WORKING_SET_QUOTA
|| err == ERROR_NO_SYSTEM_RESOURCES) {
fprintf(stderr,
"InnoDB: The error means that there are no"
" sufficient system resources or quota to"
" complete the operation.\n");
} else {
fprintf(stderr,
"InnoDB: Some operating system error numbers"
@ -419,6 +425,9 @@ os_file_get_last_error(
} else if (err == ERROR_SHARING_VIOLATION
|| err == ERROR_LOCK_VIOLATION) {
return(OS_FILE_SHARING_VIOLATION);
} else if (err == ERROR_WORKING_SET_QUOTA
|| err == ERROR_NO_SYSTEM_RESOURCES) {
return(OS_FILE_INSUFFICIENT_RESOURCE);
} else {
return(100 + err);
}
@ -552,6 +561,10 @@ os_file_handle_error_cond_exit(
os_thread_sleep(10000000); /* 10 sec */
return(TRUE);
} else if (err == OS_FILE_INSUFFICIENT_RESOURCE) {
os_thread_sleep(100000); /* 100 ms */
return(TRUE);
} else {
if (name) {
fprintf(stderr, "InnoDB: File name %s\n", name);
@ -915,6 +928,23 @@ next_file:
ret = stat(full_path, &statinfo);
if (ret) {
if (errno == ENOENT) {
/* readdir() returned a file that does not exist,
it must have been deleted in the meantime. Do what
would have happened if the file was deleted before
readdir() - ignore and go to the next entry.
If this is the last entry then info->name will still
contain the name of the deleted file when this
function returns, but this is not an issue since the
caller shouldn't be looking at info when end of
directory is returned. */
ut_free(full_path);
goto next_file;
}
os_file_handle_error_no_exit(full_path, "stat");
ut_free(full_path);
@ -2128,7 +2158,9 @@ os_file_pread(
offset */
{
off_t offs;
#if defined(HAVE_PREAD) && !defined(HAVE_BROKEN_PREAD)
ssize_t n_bytes;
#endif /* HAVE_PREAD && !HAVE_BROKEN_PREAD */
ut_a((offset & 0xFFFFFFFFUL) == offset);
@ -2167,16 +2199,20 @@ os_file_pread(
{
off_t ret_offset;
ssize_t ret;
#ifndef UNIV_HOTBACKUP
ulint i;
#endif /* !UNIV_HOTBACKUP */
os_mutex_enter(os_file_count_mutex);
os_n_pending_reads++;
os_mutex_exit(os_file_count_mutex);
#ifndef UNIV_HOTBACKUP
/* Protect the seek / read operation with a mutex */
i = ((ulint) file) % OS_FILE_N_SEEK_MUTEXES;
os_mutex_enter(os_file_seek_mutexes[i]);
#endif /* !UNIV_HOTBACKUP */
ret_offset = lseek(file, offs, SEEK_SET);
@ -2186,7 +2222,9 @@ os_file_pread(
ret = read(file, buf, (ssize_t)n);
}
#ifndef UNIV_HOTBACKUP
os_mutex_exit(os_file_seek_mutexes[i]);
#endif /* !UNIV_HOTBACKUP */
os_mutex_enter(os_file_count_mutex);
os_n_pending_reads--;
@ -3220,6 +3258,34 @@ skip_native_aio:
return(array);
}
/************************************************************************//**
Frees an aio wait array. */
static
void
os_aio_array_free(
/*==============*/
os_aio_array_t* array) /*!< in, own: array to free */
{
#ifdef WIN_ASYNC_IO
ulint i;
for (i = 0; i < array->n_slots; i++) {
os_aio_slot_t* slot = os_aio_array_get_nth_slot(array, i);
os_event_free(slot->event);
}
#endif /* WIN_ASYNC_IO */
#ifdef __WIN__
ut_free(array->native_events);
#endif /* __WIN__ */
os_mutex_free(array->mutex);
os_event_free(array->not_full);
os_event_free(array->is_empty);
ut_free(array->slots);
ut_free(array);
}
/***********************************************************************
Initializes the asynchronous io system. Creates one array each for ibuf
and log i/o. Also creates one array each for read and write where each
@ -3313,6 +3379,35 @@ err_exit:
}
/***********************************************************************
Frees the asynchronous io system. */
UNIV_INTERN
void
os_aio_free(void)
/*=============*/
{
ulint i;
os_aio_array_free(os_aio_ibuf_array);
os_aio_ibuf_array = NULL;
os_aio_array_free(os_aio_log_array);
os_aio_log_array = NULL;
os_aio_array_free(os_aio_read_array);
os_aio_read_array = NULL;
os_aio_array_free(os_aio_write_array);
os_aio_write_array = NULL;
os_aio_array_free(os_aio_sync_array);
os_aio_sync_array = NULL;
for (i = 0; i < os_aio_n_segments; i++) {
os_event_free(os_aio_segment_wait_events[i]);
}
ut_free(os_aio_segment_wait_events);
os_aio_segment_wait_events = 0;
os_aio_n_segments = 0;
}
#ifdef WIN_ASYNC_IO
/************************************************************************//**
Wakes up all async i/o threads in the array in Windows async i/o at

1
os/os0proc.c

@ -97,6 +97,7 @@ os_mem_alloc_large(
fprintf(stderr, "InnoDB: HugeTLB: Warning: Failed to"
" attach shared memory segment, errno %d\n",
errno);
ptr = NULL;
}
/* Remove the shared memory segment so that it will be

4
os/os0sync.c

@ -86,6 +86,9 @@ os_sync_init(void)
UT_LIST_INIT(os_event_list);
UT_LIST_INIT(os_mutex_list);
os_sync_mutex = NULL;
os_sync_mutex_inited = FALSE;
os_sync_mutex = os_mutex_create(NULL);
os_sync_mutex_inited = TRUE;
@ -713,6 +716,7 @@ os_fast_mutex_free(
os_mutex_enter(os_sync_mutex);
}
ut_ad(os_fast_mutex_count > 0);
os_fast_mutex_count--;
if (UNIV_LIKELY(os_sync_mutex_inited)) {

1
os/os0thread.c

@ -233,6 +233,7 @@ os_thread_exit(
#ifdef __WIN__
ExitThread((DWORD)exit_value);
#else
pthread_detach(pthread_self());
pthread_exit(exit_value);
#endif
}

2
page/page0cur.c

@ -1195,7 +1195,7 @@ page_cur_insert_rec_zip_reorg(
}
/* Out of space: restore the page */
if (!page_zip_decompress(page_zip, page)) {
if (!page_zip_decompress(page_zip, page, FALSE)) {
ut_error; /* Memory corrupted? */
}
ut_ad(page_validate(page, index));

4
page/page0page.c

@ -679,7 +679,7 @@ page_copy_rec_list_end(
if (UNIV_UNLIKELY
(!page_zip_decompress(new_page_zip,
new_page))) {
new_page, FALSE))) {
ut_error;
}
ut_ad(page_validate(new_page, index));
@ -792,7 +792,7 @@ page_copy_rec_list_start(
if (UNIV_UNLIKELY
(!page_zip_decompress(new_page_zip,
new_page))) {
new_page, FALSE))) {
ut_error;
}
ut_ad(page_validate(new_page, index));

51
page/page0zip.c

@ -2821,7 +2821,11 @@ page_zip_decompress(
/*================*/
page_zip_des_t* page_zip,/*!< in: data, ssize;
out: m_start, m_end, m_nonempty, n_blobs */
page_t* page) /*!< out: uncompressed page, may be trashed */
page_t* page, /*!< out: uncompressed page, may be trashed */
ibool all) /*!< in: TRUE=decompress the whole page;
FALSE=verify but do not copy some
page header fields that should not change
after page creation */
{
z_stream d_stream;
dict_index_t* index = NULL;
@ -2851,13 +2855,36 @@ page_zip_decompress(
heap = mem_heap_create(n_dense * (3 * sizeof *recs) + UNIV_PAGE_SIZE);
recs = mem_heap_alloc(heap, n_dense * (2 * sizeof *recs));
if (all) {
/* Copy the page header. */
memcpy(page, page_zip->data, PAGE_DATA);
} else {
/* Check that the bytes that we skip are identical. */
#if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG
ut_a(!memcmp(FIL_PAGE_TYPE + page,
FIL_PAGE_TYPE + page_zip->data,
PAGE_HEADER - FIL_PAGE_TYPE));
ut_a(!memcmp(PAGE_HEADER + PAGE_LEVEL + page,
PAGE_HEADER + PAGE_LEVEL + page_zip->data,
PAGE_DATA - (PAGE_HEADER + PAGE_LEVEL)));
#endif /* UNIV_DEBUG || UNIV_ZIP_DEBUG */
/* Copy the mutable parts of the page header. */
memcpy(page, page_zip->data, FIL_PAGE_TYPE);
memcpy(PAGE_HEADER + page, PAGE_HEADER + page_zip->data,
PAGE_LEVEL - PAGE_N_DIR_SLOTS);
#if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG
/* Check that the page headers match after copying. */
ut_a(!memcmp(page, page_zip->data, PAGE_DATA));
#endif /* UNIV_DEBUG || UNIV_ZIP_DEBUG */
}
#ifdef UNIV_ZIP_DEBUG
/* Clear the page. */
memset(page, 0x55, UNIV_PAGE_SIZE);
/* Clear the uncompressed page, except the header. */
memset(PAGE_DATA + page, 0x55, UNIV_PAGE_SIZE - PAGE_DATA);
#endif /* UNIV_ZIP_DEBUG */
UNIV_MEM_INVALID(page, UNIV_PAGE_SIZE);
/* Copy the page header. */
memcpy(page, page_zip->data, PAGE_DATA);
UNIV_MEM_INVALID(PAGE_DATA + page, UNIV_PAGE_SIZE - PAGE_DATA);
/* Copy the page directory. */
if (UNIV_UNLIKELY(!page_zip_dir_decode(page_zip, page, recs,
@ -3098,7 +3125,7 @@ page_zip_validate_low(
#endif /* UNIV_DEBUG_VALGRIND */
temp_page_zip = *page_zip;
valid = page_zip_decompress(&temp_page_zip, temp_page);
valid = page_zip_decompress(&temp_page_zip, temp_page, TRUE);
if (!valid) {
fputs("page_zip_validate(): failed to decompress\n", stderr);
goto func_exit;
@ -4376,8 +4403,8 @@ IMPORTANT: if page_zip_reorganize() is invoked on a leaf page of a
non-clustered index, the caller must update the insert buffer free
bits in the same mini-transaction in such a way that the modification
will be redo-logged.
@return TRUE on success, FALSE on failure; page and page_zip will be
left intact on failure. */
@return TRUE on success, FALSE on failure; page_zip will be left
intact on failure, but page will be overwritten. */
UNIV_INTERN
ibool
page_zip_reorganize(
@ -4442,9 +4469,6 @@ page_zip_reorganize(
if (UNIV_UNLIKELY(!page_zip_compress(page_zip, page, index, mtr))) {
/* Restore the old page and exit. */
buf_frame_copy(page, temp_page);
#ifndef UNIV_HOTBACKUP
buf_block_free(temp_block);
#endif /* !UNIV_HOTBACKUP */
@ -4605,7 +4629,8 @@ corrupt:
memcpy(page_zip->data + page_zip_get_size(page_zip)
- trailer_size, ptr + 8 + size, trailer_size);
if (UNIV_UNLIKELY(!page_zip_decompress(page_zip, page))) {
if (UNIV_UNLIKELY(!page_zip_decompress(page_zip, page,
TRUE))) {
goto corrupt;
}

13
pars/lexyy.c

@ -2778,3 +2778,16 @@ static void yyfree (void * ptr )
/**********************************************************************
Release any resources used by the lexer. */
UNIV_INTERN
void
pars_lexer_close(void)
/*==================*/
{
yylex_destroy();
free(stringbuf);
stringbuf = NULL;
stringbuf_len_alloc = stringbuf_len = 0;
}

13
pars/pars0lex.l

@ -661,3 +661,16 @@ In the state 'id', only two actions are possible (defined below). */
}
%%
/**********************************************************************
Release any resources used by the lexer. */
UNIV_INTERN
void
pars_lexer_close(void)
/*==================*/
{
yylex_destroy();
free(stringbuf);
stringbuf = NULL;
stringbuf_len_alloc = stringbuf_len = 0;
}

8
que/que0que.c

@ -518,6 +518,7 @@ que_graph_free_recursive(
upd_node_t* upd;
tab_node_t* cre_tab;
ind_node_t* cre_ind;
purge_node_t* purge;
if (node == NULL) {
@ -579,6 +580,13 @@ que_graph_free_recursive(
mem_heap_free(ins->entry_sys_heap);
break;
case QUE_NODE_PURGE:
purge = node;
mem_heap_free(purge->heap);
break;
case QUE_NODE_UPDATE:
upd = node;

8
row/row0ins.c

@ -141,7 +141,7 @@ row_ins_alloc_sys_fields(
dfield = dtuple_get_nth_field(row, dict_col_get_no(col));
ptr = mem_heap_alloc(heap, DATA_ROW_ID_LEN);
ptr = mem_heap_zalloc(heap, DATA_ROW_ID_LEN);
dfield_set_data(dfield, ptr, DATA_ROW_ID_LEN);
@ -152,7 +152,7 @@ row_ins_alloc_sys_fields(
col = dict_table_get_sys_col(table, DATA_TRX_ID);
dfield = dtuple_get_nth_field(row, dict_col_get_no(col));
ptr = mem_heap_alloc(heap, DATA_TRX_ID_LEN);
ptr = mem_heap_zalloc(heap, DATA_TRX_ID_LEN);
dfield_set_data(dfield, ptr, DATA_TRX_ID_LEN);
@ -163,7 +163,7 @@ row_ins_alloc_sys_fields(
col = dict_table_get_sys_col(table, DATA_ROLL_PTR);
dfield = dtuple_get_nth_field(row, dict_col_get_no(col));
ptr = mem_heap_alloc(heap, DATA_ROLL_PTR_LEN);
ptr = mem_heap_zalloc(heap, DATA_ROLL_PTR_LEN);
dfield_set_data(dfield, ptr, DATA_ROLL_PTR_LEN);
}
@ -1191,7 +1191,7 @@ row_ins_check_foreign_constraint(
/*=============================*/
ibool check_ref,/*!< in: TRUE if we want to check that
the referenced table is ok, FALSE if we
want to to check the foreign key table */
want to check the foreign key table */
dict_foreign_t* foreign,/*!< in: foreign constraint; NOTE that the
tables mentioned in it must be in the
dictionary cache if they exist at all */

8
row/row0merge.c

@ -1965,7 +1965,15 @@ row_merge_drop_index(
static const char str1[] =
"PROCEDURE DROP_INDEX_PROC () IS\n"
"BEGIN\n"
/* Rename the index, so that it will be dropped by
row_merge_drop_temp_indexes() at crash recovery
if the server crashes before this trx is committed. */
"UPDATE SYS_INDEXES SET NAME=CONCAT('"
TEMP_INDEX_PREFIX_STR "', NAME) WHERE ID = :indexid;\n"
"COMMIT WORK;\n"
/* Drop the field definitions of the index. */
"DELETE FROM SYS_FIELDS WHERE INDEX_ID = :indexid;\n"
/* Drop the index definition and the B-tree. */
"DELETE FROM SYS_INDEXES WHERE ID = :indexid\n"
" AND TABLE_ID = :tableid;\n"
"END;\n";

2
row/row0mysql.c

@ -2068,7 +2068,7 @@ Scans a table create SQL string and adds to the data dictionary
the foreign key constraints declared in the string. This function
should be called after the indexes for a table have been created.
Each foreign key constraint must be accompanied with indexes in
bot participating tables. The indexes are allowed to contain more
both participating tables. The indexes are allowed to contain more
fields than mentioned in the constraint. Check also that foreign key
constraints which reference this table are ok.
@return error code or DB_SUCCESS */

17
srv/srv0srv.c

@ -1012,13 +1012,26 @@ srv_init(void)
}
/*********************************************************************//**
Frees the OS fast mutex created in srv_init(). */
Frees the data structures created in srv_init(). */
UNIV_INTERN
void
srv_free(void)
/*==========*/
{
os_fast_mutex_free(&srv_conc_mutex);
mem_free(srv_conc_slots);
srv_conc_slots = NULL;
mem_free(srv_sys->threads);
mem_free(srv_sys);
srv_sys = NULL;
mem_free(kernel_mutex_temp);
kernel_mutex_temp = NULL;
mem_free(srv_mysql_table);
srv_mysql_table = NULL;
trx_i_s_cache_free(trx_i_s_cache);
}
/*********************************************************************//**
@ -1030,6 +1043,8 @@ srv_general_init(void)
/*==================*/
{
ut_mem_init();
/* Reset the system variables in the recovery module. */
recv_sys_var_init();
os_sync_init();
sync_init();
mem_init(srv_mem_pool_size);

105
srv/srv0start.c

@ -103,6 +103,7 @@ Created 2/16/1996 Heikki Tuuri
# include "row0row.h"
# include "row0mysql.h"
# include "btr0pcur.h"
# include "thr0loc.h"
# include "os0sync.h" /* for INNODB_RW_LOCKS_USE_ATOMICS */
/** Log sequence number immediately after startup */
@ -495,6 +496,8 @@ io_handler_thread(
mutex_exit(&ios_mutex);
}
thr_local_free(os_thread_get_curr_id());
/* We count the number of threads in os_thread_exit(). A created
thread should always use that to exit and not use return() to exit.
The thread actually never comes here because it is exited in an
@ -531,32 +534,6 @@ srv_normalize_path_for_win(
#endif
}
/*********************************************************************//**
Adds a slash or a backslash to the end of a string if it is missing
and the string is not empty.
@return string which has the separator if the string is not empty */
UNIV_INTERN
char*
srv_add_path_separator_if_needed(
/*=============================*/
char* str) /*!< in: null-terminated character string */
{
char* out_str;
ulint len = ut_strlen(str);
if (len == 0 || str[len - 1] == SRV_PATH_SEPARATOR) {
return(str);
}
out_str = ut_malloc(len + 2);
memcpy(out_str, str, len);
out_str[len] = SRV_PATH_SEPARATOR;
out_str[len + 1] = 0;
return(out_str);
}
#ifndef UNIV_HOTBACKUP
/*********************************************************************//**
Calculates the low 32 bits when a file size which is given as a number
@ -605,19 +582,24 @@ open_or_create_log_file(
ulint size;
ulint size_high;
char name[10000];
ulint dirnamelen;
UT_NOT_USED(create_new_db);
*log_file_created = FALSE;
srv_normalize_path_for_win(srv_log_group_home_dirs[k]);
srv_log_group_home_dirs[k] = srv_add_path_separator_if_needed(
srv_log_group_home_dirs[k]);
ut_a(strlen(srv_log_group_home_dirs[k])
< (sizeof name) - 10 - sizeof "ib_logfile");
sprintf(name, "%s%s%lu", srv_log_group_home_dirs[k],
"ib_logfile", (ulong) i);
dirnamelen = strlen(srv_log_group_home_dirs[k]);
ut_a(dirnamelen < (sizeof name) - 10 - sizeof "ib_logfile");
memcpy(name, srv_log_group_home_dirs[k], dirnamelen);
/* Add a path separator if needed. */
if (dirnamelen && name[dirnamelen - 1] != SRV_PATH_SEPARATOR) {
name[dirnamelen++] = SRV_PATH_SEPARATOR;
}
sprintf(name + dirnamelen, "%s%lu", "ib_logfile", (ulong) i);
files[i] = os_file_create(name, OS_FILE_CREATE, OS_FILE_NORMAL,
OS_LOG_FILE, &ret);
@ -780,14 +762,22 @@ open_or_create_data_files(
*create_new_db = FALSE;
srv_normalize_path_for_win(srv_data_home);
srv_data_home = srv_add_path_separator_if_needed(srv_data_home);
for (i = 0; i < srv_n_data_files; i++) {
ulint dirnamelen;
srv_normalize_path_for_win(srv_data_file_names[i]);
dirnamelen = strlen(srv_data_home);
ut_a(strlen(srv_data_home) + strlen(srv_data_file_names[i])
ut_a(dirnamelen + strlen(srv_data_file_names[i])
< (sizeof name) - 1);
sprintf(name, "%s%s", srv_data_home, srv_data_file_names[i]);
memcpy(name, srv_data_home, dirnamelen);
/* Add a path separator if needed. */
if (dirnamelen && name[dirnamelen - 1] != SRV_PATH_SEPARATOR) {
name[dirnamelen++] = SRV_PATH_SEPARATOR;
}
strcpy(name + dirnamelen, srv_data_file_names[i]);
if (srv_data_file_is_raw_partition[i] == 0) {
@ -1009,7 +999,7 @@ skip_size_check:
return(DB_SUCCESS);
}
/****************************************************************//**
/********************************************************************
Starts InnoDB and creates a new database if database files
are not found and the user wants.
@return DB_SUCCESS or error code */
@ -1120,7 +1110,7 @@ innobase_start_or_create_for_mysql(void)
if (srv_start_has_been_called) {
fprintf(stderr,
"InnoDB: Error:startup called second time"
"InnoDB: Error: startup called second time"
" during the process lifetime.\n"
"InnoDB: In the MySQL Embedded Server Library"
" you cannot call server_init()\n"
@ -1393,7 +1383,7 @@ innobase_start_or_create_for_mysql(void)
sum_of_new_sizes += srv_data_file_sizes[i];
}
if (sum_of_new_sizes < 640) {
if (sum_of_new_sizes < 10485760 / UNIV_PAGE_SIZE) {
fprintf(stderr,
"InnoDB: Error: tablespace size must be"
" at least 10 MB\n");
@ -1976,8 +1966,10 @@ innobase_shutdown_for_mysql(void)
/* All the threads have exited or are just exiting;
NOTE that the threads may not have completed their
exit yet. Should we use pthread_join() to make sure
they have exited? Now we just sleep 0.1 seconds and
hope that is enough! */
they have exited? If we did, we would have to
remove the pthread_detach() from
os_thread_exit(). Now we just sleep 0.1
seconds and hope that is enough! */
os_mutex_exit(os_sync_mutex);
@ -2016,37 +2008,41 @@ innobase_shutdown_for_mysql(void)
srv_misc_tmpfile = 0;
}
/* This must be disabled before closing the buffer pool
and closing the data dictionary. */
btr_search_disable();
ibuf_close();
log_shutdown();
lock_sys_close();
thr_local_close();
trx_sys_file_format_close();
trx_sys_close();
mutex_free(&srv_monitor_file_mutex);
mutex_free(&srv_dict_tmpfile_mutex);
mutex_free(&srv_misc_tmpfile_mutex);
dict_close();
btr_search_sys_free();
/* 3. Free all InnoDB's own mutexes and the os_fast_mutexes inside
them */
os_aio_free();
sync_close();
srv_free();
fil_close();
/* 4. Free the os_conc_mutex and all os_events and os_mutexes */
srv_free();
os_sync_free();
/* Check that all read views are closed except read view owned
by a purge. */
if (UT_LIST_GET_LEN(trx_sys->view_list) > 1) {
fprintf(stderr,
"InnoDB: Error: all read views were not closed"
" before shutdown:\n"
"InnoDB: %lu read views open \n",
UT_LIST_GET_LEN(trx_sys->view_list) - 1);
}
/* 5. Free all allocated memory and the os_fast_mutex created in
ut0mem.c */
/* 5. Free all allocated memory */
pars_lexer_close();
log_mem_free();
buf_pool_free();
ut_free_all_mem();
mem_close();
if (os_thread_count != 0
|| os_event_count != 0
@ -2077,6 +2073,7 @@ innobase_shutdown_for_mysql(void)
}
srv_was_started = FALSE;
srv_start_has_been_called = FALSE;
return((int) DB_SUCCESS);
}

20
sync/sync0arr.c

@ -227,24 +227,21 @@ sync_array_create(
SYNC_ARRAY_MUTEX: determines the type
of mutex protecting the data structure */
{
ulint sz;
sync_array_t* arr;
sync_cell_t* cell_array;
sync_cell_t* cell;
ulint i;
ut_a(n_cells > 0);
/* Allocate memory for the data structures */
arr = ut_malloc(sizeof(sync_array_t));
memset(arr, 0x0, sizeof(*arr));
cell_array = ut_malloc(sizeof(sync_cell_t) * n_cells);
sz = sizeof(sync_cell_t) * n_cells;
arr->array = ut_malloc(sz);
memset(arr->array, 0x0, sz);
arr->n_cells = n_cells;
arr->n_reserved = 0;
arr->array = cell_array;
arr->protection = protection;
arr->sg_count = 0;
arr->res_count = 0;
/* Then create the mutex to protect the wait array complex */
if (protection == SYNC_ARRAY_OS_MUTEX) {
@ -255,13 +252,6 @@ sync_array_create(
ut_error;
}
for (i = 0; i < n_cells; i++) {
cell = sync_array_get_nth_cell(arr, i);
cell->wait_object = NULL;
cell->waiting = FALSE;
cell->signal_count = 0;
}
return(arr);
}

5
sync/sync0sync.c

@ -1377,7 +1377,12 @@ sync_close(void)
mutex_free(&mutex_list_mutex);
#ifdef UNIV_SYNC_DEBUG
mutex_free(&sync_thread_mutex);
/* Switch latching order checks on in sync0sync.c */
sync_order_checks_on = FALSE;
#endif /* UNIV_SYNC_DEBUG */
sync_initialized = FALSE;
}
/*******************************************************************//**

31
thr/thr0loc.c

@ -246,3 +246,34 @@ thr_local_init(void)
mutex_create(&thr_local_mutex, SYNC_THR_LOCAL);
}
/********************************************************************
Close the thread local storage module. */
UNIV_INTERN
void
thr_local_close(void)
/*=================*/
{
ulint i;
ut_a(thr_local_hash != NULL);
/* Free the hash elements. We don't remove them from the table
because we are going to destroy the table anyway. */
for (i = 0; i < hash_get_n_cells(thr_local_hash); i++) {
thr_local_t* local;
local = HASH_GET_FIRST(thr_local_hash, i);
while (local) {
thr_local_t* prev_local = local;
local = HASH_GET_NEXT(hash, prev_local);
ut_a(prev_local->magic_n == THR_LOCAL_MAGIC_N);
mem_free(prev_local);
}
}
hash_table_free(thr_local_hash);
thr_local_hash = NULL;
}

37
trx/trx0i_s.c

@ -237,6 +237,27 @@ table_cache_init(
}
}
/*******************************************************************//**
Frees a table cache. */
static
void
table_cache_free(
/*=============*/
i_s_table_cache_t* table_cache) /*!< in/out: table cache */
{
ulint i;
for (i = 0; i < MEM_CHUNKS_IN_TABLE_CACHE; i++) {
/* the memory is actually allocated in
table_cache_create_empty_row() */
if (table_cache->chunks[i].base) {
mem_free(table_cache->chunks[i].base);
table_cache->chunks[i].base = NULL;
}
}
}
/*******************************************************************//**
Returns an empty row from a table cache. The row is allocated if no more
empty rows are available. The number of used rows is incremented.
@ -1251,6 +1272,22 @@ trx_i_s_cache_init(
cache->is_truncated = FALSE;
}
/*******************************************************************//**
Free the INFORMATION SCHEMA trx related cache. */
UNIV_INTERN
void
trx_i_s_cache_free(
/*===============*/
trx_i_s_cache_t* cache) /*!< in, own: cache to free */
{
hash_table_free(cache->locks_hash);
ha_storage_free(cache->storage);
table_cache_free(&cache->innodb_trx);
table_cache_free(&cache->innodb_locks);
table_cache_free(&cache->innodb_lock_waits);
memset(cache, 0, sizeof *cache);
}
/*******************************************************************//**
Issue a shared/read lock on the tables cache. */
UNIV_INTERN

38
trx/trx0purge.c

@ -249,6 +249,44 @@ trx_purge_sys_create(void)
purge_sys->heap);
}
/************************************************************************
Frees the global purge system control structure. */
UNIV_INTERN
void
trx_purge_sys_close(void)
/*======================*/
{
ut_ad(!mutex_own(&kernel_mutex));
que_graph_free(purge_sys->query);
ut_a(purge_sys->sess->trx->is_purge);
purge_sys->sess->trx->conc_state = TRX_NOT_STARTED;
sess_close(purge_sys->sess);
purge_sys->sess = NULL;
if (purge_sys->view != NULL) {
/* Because acquiring the kernel mutex is a pre-condition
of read_view_close(). We don't really need it here. */
mutex_enter(&kernel_mutex);
read_view_close(purge_sys->view);
purge_sys->view = NULL;
mutex_exit(&kernel_mutex);
}
trx_undo_arr_free(purge_sys->arr);
rw_lock_free(&purge_sys->latch);
mutex_free(&purge_sys->mutex);
mem_heap_free(purge_sys->heap);
mem_free(purge_sys);
purge_sys = NULL;
}
/*================ UNDO LOG HISTORY LIST =============================*/
/********************************************************************//**

43
trx/trx0rseg.c

@ -132,6 +132,49 @@ trx_rseg_header_create(
}
/***********************************************************************//**
Free's an instance of the rollback segment in memory. */
UNIV_INTERN
void
trx_rseg_mem_free(
/*==============*/
trx_rseg_t* rseg) /* in, own: instance to free */
{
trx_undo_t* undo;
mutex_free(&rseg->mutex);
/* There can't be any active transactions. */
ut_a(UT_LIST_GET_LEN(rseg->update_undo_list) == 0);
ut_a(UT_LIST_GET_LEN(rseg->insert_undo_list) == 0);
undo = UT_LIST_GET_FIRST(rseg->update_undo_cached);
while (undo != NULL) {
trx_undo_t* prev_undo = undo;
undo = UT_LIST_GET_NEXT(undo_list, undo);
UT_LIST_REMOVE(undo_list, rseg->update_undo_cached, prev_undo);
trx_undo_mem_free(prev_undo);
}
undo = UT_LIST_GET_FIRST(rseg->insert_undo_cached);
while (undo != NULL) {
trx_undo_t* prev_undo = undo;
undo = UT_LIST_GET_NEXT(undo_list, undo);
UT_LIST_REMOVE(undo_list, rseg->insert_undo_cached, prev_undo);
trx_undo_mem_free(prev_undo);
}
trx_sys_set_nth_rseg(trx_sys, rseg->id, NULL);
mem_free(rseg);
}
/***************************************************************************
Creates and initializes a rollback segment object. The values for the
fields are read from the header. The object is inserted to the rseg
list of the trx system object and a pointer is inserted in the rseg

78
trx/trx0sys.c

@ -40,6 +40,7 @@ Created 3/26/1996 Heikki Tuuri
#include "trx0purge.h"
#include "log0log.h"
#include "os0file.h"
#include "read0read.h"
/** The file format tag structure with id and name. */
struct file_format_struct {
@ -1533,3 +1534,80 @@ trx_sys_file_format_id_to_name(
}
#endif /* !UNIV_HOTBACKUP */
/*********************************************************************
Shutdown/Close the transaction system. */
UNIV_INTERN
void
trx_sys_close(void)
/*===============*/
{
trx_rseg_t* rseg;
read_view_t* view;
ut_ad(trx_sys != NULL);
/* Check that all read views are closed except read view owned
by a purge. */
if (UT_LIST_GET_LEN(trx_sys->view_list) > 1) {
fprintf(stderr,
"InnoDB: Error: all read views were not closed"
" before shutdown:\n"
"InnoDB: %lu read views open \n",
UT_LIST_GET_LEN(trx_sys->view_list) - 1);
}
sess_close(trx_dummy_sess);
trx_dummy_sess = NULL;
trx_purge_sys_close();
mutex_enter(&kernel_mutex);
/* Free the double write data structures. */
ut_a(trx_doublewrite != NULL);
ut_free(trx_doublewrite->write_buf_unaligned);
trx_doublewrite->write_buf_unaligned = NULL;
mem_free(trx_doublewrite->buf_block_arr);
trx_doublewrite->buf_block_arr = NULL;
mutex_free(&trx_doublewrite->mutex);
mem_free(trx_doublewrite);
trx_doublewrite = NULL;
/* There can't be any active transactions. */
rseg = UT_LIST_GET_FIRST(trx_sys->rseg_list);
while (rseg != NULL) {
trx_rseg_t* prev_rseg = rseg;
rseg = UT_LIST_GET_NEXT(rseg_list, prev_rseg);
UT_LIST_REMOVE(rseg_list, trx_sys->rseg_list, prev_rseg);
trx_rseg_mem_free(prev_rseg);
}
view = UT_LIST_GET_FIRST(trx_sys->view_list);
while (view != NULL) {
read_view_t* prev_view = view;
view = UT_LIST_GET_NEXT(view_list, prev_view);
/* Views are allocated from the trx_sys->global_read_view_heap.
So, we simply remove the element here. */
UT_LIST_REMOVE(view_list, trx_sys->view_list, prev_view);
}
ut_a(UT_LIST_GET_LEN(trx_sys->trx_list) == 0);
ut_a(UT_LIST_GET_LEN(trx_sys->rseg_list) == 0);
ut_a(UT_LIST_GET_LEN(trx_sys->view_list) == 0);
ut_a(UT_LIST_GET_LEN(trx_sys->mysql_trx_list) == 0);
mem_free(trx_sys);
trx_sys = NULL;
mutex_exit(&kernel_mutex);
}

2
trx/trx0trx.c

@ -803,7 +803,7 @@ trx_commit_off_kernel(
in exactly the same order as commit lsn's, if the transactions
have different rollback segments. To get exactly the same
order we should hold the kernel mutex up to this point,
adding to to the contention of the kernel mutex. However, if
adding to the contention of the kernel mutex. However, if
a transaction T2 is able to see modifications made by
a transaction T1, T2 will always get a bigger transaction
number and a bigger commit lsn than T1. */

2
trx/trx0undo.c

@ -1522,7 +1522,7 @@ trx_undo_mem_init_for_reuse(
/********************************************************************//**
Frees an undo log memory copy. */
static
UNIV_INTERN
void
trx_undo_mem_free(
/*==============*/

37
usr/usr0sess.c

@ -31,14 +31,6 @@ Created 6/25/1996 Heikki Tuuri
#include "trx0trx.h"
/*********************************************************************//**
Closes a session, freeing the memory occupied by it. */
static
void
sess_close(
/*=======*/
sess_t* sess); /*!< in, own: session object */
/*********************************************************************//**
Opens a session.
@return own: session object */
@ -64,35 +56,16 @@ sess_open(void)
/*********************************************************************//**
Closes a session, freeing the memory occupied by it. */
static
UNIV_INTERN
void
sess_close(
/*=======*/
sess_t* sess) /*!< in, own: session object */
{
ut_ad(mutex_own(&kernel_mutex));
ut_ad(sess->trx == NULL);
mem_free(sess);
}
/*********************************************************************//**
Closes a session, freeing the memory occupied by it, if it is in a state
where it should be closed.
@return TRUE if closed */
UNIV_INTERN
ibool
sess_try_close(
/*===========*/
sess_t* sess) /*!< in, own: session object */
{
ut_ad(mutex_own(&kernel_mutex));
ut_ad(!mutex_own(&kernel_mutex));
if (UT_LIST_GET_LEN(sess->graphs) == 0) {
sess_close(sess);
ut_a(UT_LIST_GET_LEN(sess->graphs) == 0);
return(TRUE);
}
return(FALSE);
trx_free_for_background(sess->trx);
mem_free(sess);
}

2
ut/ut0mem.c

@ -433,6 +433,8 @@ ut_free_all_mem(void)
" total allocated memory is %lu\n",
(ulong) ut_total_allocated_memory);
}
ut_mem_block_list_inited = FALSE;
}
#endif /* !UNIV_HOTBACKUP */

Loading…
Cancel
Save