mariadb/trx/trx0rec.c
inaam 0757affd7b branches/innodb+: Merged revisions 5525:5971 from branches/zip
------------------------------------------------------------------------
  r5971 | marko | 2009-09-23 09:03:51 -0400 (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.
  ------------------------------------------------------------------------
  r5956 | calvin | 2009-09-22 19:30:10 -0400 (Tue, 22 Sep 2009) | 4 lines
  
  branches/zip: remove handler0vars.h from Makefile.am
  
  Left over from r5950.
  
  ------------------------------------------------------------------------
  r5951 | calvin | 2009-09-22 11:17:01 -0400 (Tue, 22 Sep 2009) | 4 lines
  
  branches/zip: adjust CMake file to work with old versions of MySQL
  
  Tested with MySQL 5.1.38 and 5.1.30.
  
  ------------------------------------------------------------------------
  r5950 | calvin | 2009-09-22 02:42:46 -0400 (Tue, 22 Sep 2009) | 17 lines
  
  branches/zip: adjust Windows loading method for 5.1.38
  
  Starting at 5.1.38, MySQL server exports symbols needed
  for dynamic plugin on Windows. There is no need for
  Windows specific loading. Also, the CMake files are
  simplified in 5.1.38.
  
  When WITH_INNOBASE_STORAGE_ENGINE is specified during
  configuration (win\configure.js), InnoDB is built as
  a static library. Otherwise, a dynamic InnoDB will be
  built (ha_innodb.dll).
  
  CMakeLists.txt requires minor changes in order to work
  with MySQL prior to 5.1.38. The changes will be in a
  separate patch.
  
  This patch addresses Mantis issue#286.
  ------------------------------------------------------------------------
  r5945 | calvin | 2009-09-21 10:53:22 -0400 (Mon, 21 Sep 2009) | 4 lines
  
  branches/zip: fix a type in r5935
  
  Should be innodb_open_files, spotted by Michael.
  
  ------------------------------------------------------------------------
  r5940 | vasil | 2009-09-21 01:26:04 -0400 (Mon, 21 Sep 2009) | 4 lines
  
  branches/zip:
  
  Add ChangeLog entries for c5938.
  
  ------------------------------------------------------------------------
  r5938 | calvin | 2009-09-19 03:14:25 -0400 (Sat, 19 Sep 2009) | 41 lines
  
  branches/zip: Merge revisions 2584:2956 from branches/6.0,
  except c2932.
  
  Bug#37232 and bug#31183 were fixed in the 6.0 branch only.
  They should be fixed in the plugin too, specially MySQL 6.0
  is discontinued at this point.
  
      ------------------------------------------------------------------------
      r2604 | inaam | 2008-08-21 09:37:06 -0500 (Thu, 21 Aug 2008) | 8 lines
  
      branches/6.0     bug#37232
  
      Relax locking behaviour for REPLACE INTO t SELECT ... FROM t1.
      Now SELECT on t1 is performed as a consistent read when the isolation
      level is set to READ COMMITTED.
  
      Reviewed by: Heikki
      ------------------------------------------------------------------------
      r2605 | inaam | 2008-08-21 09:59:33 -0500 (Thu, 21 Aug 2008) | 7 lines
  
      branches/6.0
  
      Added a comment to clarify why distinct calls to read MySQL binary
      log file name and log position do not entail any race condition.
  
      Suggested by: Heikki
      ------------------------------------------------------------------------
      r2956 | inaam | 2008-11-04 04:47:30 -0600 (Tue, 04 Nov 2008) | 11 lines
  
      branches/6.0  bug#31183
  
      If the system tablespace runs out of space because 'autoextend' is
      not specified with innodb_data_file_path there was no error message
      printed to the error log. The client would get 'table full' error.
      This patch prints an appropriate error message to the error log.
  
      rb://43
  
      Approved by: Marko
      ------------------------------------------------------------------------
  
  ------------------------------------------------------------------------
  r5935 | calvin | 2009-09-18 17:08:02 -0400 (Fri, 18 Sep 2009) | 6 lines
  
  branches/zip: fix bug#44338; minor non-functional changes
  
  Bug#44338 innodb has message about non-existing option 
  innodb_max_files_open. Change the option to innodb_open_files.
  The fix was committed into 6.0 branch.
  
  ------------------------------------------------------------------------
  r5934 | vasil | 2009-09-18 13:06:46 -0400 (Fri, 18 Sep 2009) | 4 lines
  
  branches/zip:
  
  Fix typo.
  
  ------------------------------------------------------------------------
  r5924 | vasil | 2009-09-18 00:59:30 -0400 (Fri, 18 Sep 2009) | 4 lines
  
  branches/zip:
  
  White space and formatting cleanup in the ChangeLog
  
  ------------------------------------------------------------------------
  r5922 | marko | 2009-09-17 02:32:08 -0400 (Thu, 17 Sep 2009) | 4 lines
  
  branches/zip: innodb-zip.test: Make the test work with zlib 1.2.3.3.
  Apparently, the definition of compressBound() has slightly changed.
  
  This has been filed as Mantis Issue #345.
  ------------------------------------------------------------------------
  r5920 | vasil | 2009-09-16 14:47:22 -0400 (Wed, 16 Sep 2009) | 4 lines
  
  branches/zip:
  
  Add ChangeLog entries for r5916.
  
  ------------------------------------------------------------------------
  r5919 | vasil | 2009-09-16 14:37:13 -0400 (Wed, 16 Sep 2009) | 4 lines
  
  branches/zip:
  
  Whitespace cleanup in the ChangeLog.
  
  ------------------------------------------------------------------------
  r5917 | marko | 2009-09-16 05:56:23 -0400 (Wed, 16 Sep 2009) | 1 line
  
  branches/zip: innobase_get_cset_width(): Cache the value of current_thd.
  ------------------------------------------------------------------------
  r5916 | marko | 2009-09-16 05:54:43 -0400 (Wed, 16 Sep 2009) | 128 lines
  
  branches/zip: Merge revisions 5622:5912 from branches/5.1, except r5700
  (changes to CMakeLists.txt)
  
    ------------------------------------------------------------------------
    r5622 | vasil | 2009-08-03 15:27:00 +0300 (Mon, 03 Aug 2009) | 20 lines
    Changed paths:
       M /branches/5.1/Makefile.am
  
    branches/5.1:
  
    Merge a change from MySQL:
  
      ------------------------------------------------------------
      revno: 2988
      committer: Satya B <satya.bn@sun.com>
      branch nick: mysql-5.1-bugteam
      timestamp: Wed 2009-07-01 11:06:05 +0530
      message:
        Fix build failure after applying Innodb snapshot 5.1-ss5282
  
        After applying Innodb snapshot 5.1-ss5282, build was broken
        because of missing header file.
  
        Adding the header file to Makefile.am after informing the
        innodb developers.
      modified:
        storage/innobase/Makefile.am
    ------------------------------------------------------------------------
    r5740 | jyang | 2009-09-03 06:33:47 +0300 (Thu, 03 Sep 2009) | 5 lines
    Changed paths:
       M /branches/5.1/handler/ha_innodb.cc
       M /branches/5.1/include/db0err.h
       A /branches/5.1/mysql-test/innodb_bug46000.result
       A /branches/5.1/mysql-test/innodb_bug46000.test
  
    branches/5.1: Disallow creating index with the name of
    "GEN_CLUST_INDEX" which is reserved for the default system
    primary index. (Bug #46000) rb://149 approved by Sunny Bains.
    ------------------------------------------------------------------------
    r5741 | jyang | 2009-09-03 07:16:01 +0300 (Thu, 03 Sep 2009) | 5 lines
    Changed paths:
       M /branches/5.1/dict/dict0dict.c
       M /branches/5.1/handler/ha_innodb.cc
       A /branches/5.1/mysql-test/innodb_bug44369.result
       A /branches/5.1/mysql-test/innodb_bug44369.test
       M /branches/5.1/row/row0mysql.c
  
    branches/5.1: Block creating table with column name conflicting
    with Innodb reserved key words. (Bug #44369) rb://151 approved
    by Sunny Bains.
    ------------------------------------------------------------------------
    r5757 | jyang | 2009-09-04 04:26:13 +0300 (Fri, 04 Sep 2009) | 3 lines
    Changed paths:
       M /branches/5.1/handler/ha_innodb.cc
       M /branches/5.1/include/db0err.h
       D /branches/5.1/mysql-test/innodb_bug46000.result
       D /branches/5.1/mysql-test/innodb_bug46000.test
  
    branches/5.1: Revert change in 5740. Making the fix in a subsequent
    check in.
    ------------------------------------------------------------------------
    r5760 | jyang | 2009-09-04 07:07:34 +0300 (Fri, 04 Sep 2009) | 3 lines
    Changed paths:
       M /branches/5.1/dict/dict0dict.c
       M /branches/5.1/handler/ha_innodb.cc
       D /branches/5.1/mysql-test/innodb_bug44369.result
       D /branches/5.1/mysql-test/innodb_bug44369.test
       M /branches/5.1/row/row0mysql.c
  
    branches/5.1: This is to revert change 5741. A return status for
    create_table_def() needs to be fixed.
    ------------------------------------------------------------------------
    r5797 | calvin | 2009-09-09 18:26:29 +0300 (Wed, 09 Sep 2009) | 3 lines
    Changed paths:
       M /branches/5.1/handler/ha_innodb.cc
  
    branches/5.1: merge change from 5.1.38
  
    HA_ERR_TOO_MANY_CONCURRENT_TRXS is added in 5.1.38.
    ------------------------------------------------------------------------
    r5799 | calvin | 2009-09-09 20:47:31 +0300 (Wed, 09 Sep 2009) | 10 lines
    Changed paths:
       M /branches/5.1/handler/ha_innodb.cc
  
    branches/5.1: fix bug#46256
  
    Allow tables to be dropped even if the collation is not found,
    but issue a warning.
  
    Could not find an easy way to add mysql-test since it requires
    changes to charsets and restarting the server. Tests were
    executed manually.
  
    Approved by: Heikki (on IM)
    ------------------------------------------------------------------------
    r5805 | vasil | 2009-09-10 08:41:48 +0300 (Thu, 10 Sep 2009) | 7 lines
    Changed paths:
       M /branches/5.1/handler/ha_innodb.cc
  
    branches/5.1:
  
    Fix a compilation warning caused by c5799:
  
    handler/ha_innodb.cc: In function 'void innobase_get_cset_width(ulint, ulint*, ulint*)':
    handler/ha_innodb.cc:830: warning: format '%d' expects type 'int', but argument 2 has type 'ulint'
    ------------------------------------------------------------------------
    r5834 | jyang | 2009-09-11 00:43:05 +0300 (Fri, 11 Sep 2009) | 5 lines
    Changed paths:
       M /branches/5.1/dict/dict0dict.c
       M /branches/5.1/handler/ha_innodb.cc
       A /branches/5.1/mysql-test/innodb_bug44369.result
       A /branches/5.1/mysql-test/innodb_bug44369.test
       M /branches/5.1/row/row0mysql.c
  
    branches/5.1: Block creating table with column name conflicting
    with Innodb reserved key words. (Bug #44369) rb://151 approved
    by Sunny Bains.
    ------------------------------------------------------------------------
    r5895 | jyang | 2009-09-15 03:39:21 +0300 (Tue, 15 Sep 2009) | 5 lines
    Changed paths:
       M /branches/5.1/handler/ha_innodb.cc
       A /branches/5.1/mysql-test/innodb_bug46000.result
       A /branches/5.1/mysql-test/innodb_bug46000.test
  
    branches/5.1: Disallow creating index with the name of
    "GEN_CLUST_INDEX" which is reserved for the default system
    primary index. (Bug #46000) rb://149 approved by Marko Makela.
    ------------------------------------------------------------------------
  ------------------------------------------------------------------------
  r5910 | marko | 2009-09-16 04:07:21 -0400 (Wed, 16 Sep 2009) | 9 lines
  
  branches/zip: Introduce UNIV_LOG_LSN_DEBUG and MLOG_LSN for redo log
  diagnostics.  This was written in order to better track down
  Issue #313 in InnoDB Hot Backup.
  
  MLOG_LSN: A new redo log entry type, for recording the current log
  sequence number (LSN).  This will be checked in an assertion in
  recv_parse_log_rec().
  
  rb://161, discussed with Sunny and Vasil.
  ------------------------------------------------------------------------
  r5899 | marko | 2009-09-15 07:26:01 -0400 (Tue, 15 Sep 2009) | 4 lines
  
  branches/zip: ut0ut.h: Do not #include "os0sync.h" #ifdef UNIV_HOTBACKUP.
  Since r5872, the InnoDB Hot Backup build was broken.
  Fix it by not defining any thread synchronization primitives in ut0ut.h.
  InnoDB Hot Backup is a single-threaded program.
  ------------------------------------------------------------------------
  r5898 | marko | 2009-09-15 06:18:50 -0400 (Tue, 15 Sep 2009) | 2 lines
  
  branches/zip: Add */.dirstamp to svn:ignore,
  for https://svn.innodb.com/svn/hotbackup/branches/3.5
  ------------------------------------------------------------------------
  r5897 | marko | 2009-09-15 04:29:00 -0400 (Tue, 15 Sep 2009) | 8 lines
  
  branches/zip: Avoid bogus messages about latching order violations when
  UNIV_SYNC_DEBUG is defined.
  
  sync_thread_levels_g(): Add the parameter "warn".  Do not print
  anything unless it is set.
  
  sync_thread_add_level(): Pass warn=TRUE to sync_thread_levels_g()
  when the check is within an assertion; FALSE if it is not.
  ------------------------------------------------------------------------
  r5893 | inaam | 2009-09-14 11:20:48 -0400 (Mon, 14 Sep 2009) | 10 lines
  
  branches/zip  rb://159
  
  In case of pages that are not made young the counter is incremented
  only when the page in question is 'old'. In case of pages that are
  made young the counter is incremented in case of all pages. For apple
  to apple comparison this patch changes the 'young-making' counter to
  consider only 'old' blocks.
  
  Approved by: Marko
  
  ------------------------------------------------------------------------
  r5889 | vasil | 2009-09-14 05:17:18 -0400 (Mon, 14 Sep 2009) | 5 lines
  
  branches/zip:
  
  Add missing return statement in the test program that could have
  caused a warning.
  
  ------------------------------------------------------------------------
  r5888 | vasil | 2009-09-14 04:38:45 -0400 (Mon, 14 Sep 2009) | 40 lines
  
  branches/zip:
  
  Back-merge c5880 and c5881 from branches/embedded-1.0:
  
    ------------------------------------------------------------------------
    r5880 | vasil | 2009-09-12 17:28:44 +0300 (Sat, 12 Sep 2009) | 18 lines
    Changed paths:
       M /branches/embedded-1.0/configure.in
       M /branches/embedded-1.0/include/os0sync.h
       M /branches/embedded-1.0/srv/srv0start.c
    
    branches/embedded-1.0:
    
    Clean up and simplify the code that surrounds the atomic ops:
    
    * Simplify the code that prints what atomics are used:
    Instead of repeating the same conditions on which each atomics are used
    use just one printf that prints a variable defined by the code which
    chooses what atomics to use.
    
    * In os0sync.h pick up each atomic variant only if it has been selected
    by autoconf (based on IB_ATOMIC_MODE_* macros). Define the startup message
    to be printed.
    
    * In configure.in: check what user has chosen and if he has chosen
    something that is not available, emit an error. If nothing has been chosen
    explicitly by the user, auto select an option according to the described
    logic in configure.in.
    
    ------------------------------------------------------------------------
    r5881 | vasil | 2009-09-12 20:08:27 +0300 (Sat, 12 Sep 2009) | 4 lines
    Changed paths:
       M /branches/embedded-1.0/configure.in
    
    branches/embedded-1.0:
    
    Fix syntax error in test program.
    
    ------------------------------------------------------------------------
  
  ------------------------------------------------------------------------
  r5875 | vasil | 2009-09-12 08:11:25 -0400 (Sat, 12 Sep 2009) | 4 lines
  
  branches/zip:
  
  Remove unnecessary macro.
  
  ------------------------------------------------------------------------
  r5872 | vasil | 2009-09-12 05:35:17 -0400 (Sat, 12 Sep 2009) | 5 lines
  
  branches/zip:
  
  Explicitly include os0sync.h to the places where HAVE_ATOMIC_BUILTINS and
  INNODB_RW_LOCKS_USE_ATOMICS are used to avoid potential problems.
  
  ------------------------------------------------------------------------
  r5871 | vasil | 2009-09-12 05:25:44 -0400 (Sat, 12 Sep 2009) | 6 lines
  
  branches/zip:
  
  Rename HAVE_SOLARIS_ATOMICS to HAVE_IB_SOLARIS_ATOMICS and 
  IB_HAVE_PAUSE_INSTRUCTION to HAVE_IB_PAUSE_INSTRUCTION so they
  all follow the same HAVE_IB_* convention.
  
  ------------------------------------------------------------------------
  r5870 | vasil | 2009-09-12 05:13:44 -0400 (Sat, 12 Sep 2009) | 7 lines
  
  branches/zip:
  
  Define HAVE_ATOMIC_BUILTINS and INNODB_RW_LOCKS_USE_ATOMICS in os0sync.h
  instead of in univ.i. The code expects os_*() macros to be present if
  HAVE_ATOMIC_BUILTINS and INNODB_RW_LOCKS_USE_ATOMICS are defined. So define
  them next to defining the os_*() macros.
  
  ------------------------------------------------------------------------
  r5869 | vasil | 2009-09-12 04:33:11 -0400 (Sat, 12 Sep 2009) | 15 lines
  
  branches/zip:
  
  Include ut0auxconf.h only if none of the macros it would define is defined.
  The check when to include this header was outdated from the time when there
  was only one macro involved.
  
  Move the atomics checks that are in univ.i outside of
  #if windows ... #else ... #endif
  This simplifies the code and removes some duplicates like defining
  HAVE_ATOMIC_BUILTINS if HAVE_WINDOWS_ATOMICS is defined in both branches.
  
  Do not define the same macro HAVE_ATOMIC_PTHREAD_T for different events.
  Instead define HAVE_IB_ATOMIC_PTHREAD_T_GCC and
  HAVE_IB_ATOMIC_PTHREAD_T_SOLARIS.
  
  ------------------------------------------------------------------------
  r5868 | vasil | 2009-09-12 04:01:17 -0400 (Sat, 12 Sep 2009) | 6 lines
  
  branches/zip:
  
  Move the check whether to include ut0auxconf.h before everything because
  we are now even checking for GCC atomics, we relied on MySQL to define
  this macro before.
  
  ------------------------------------------------------------------------
  r5867 | vasil | 2009-09-12 03:43:45 -0400 (Sat, 12 Sep 2009) | 4 lines
  
  branches/zip:
  
  Update comment to reflect reality.
  
  ------------------------------------------------------------------------
  r5866 | vasil | 2009-09-12 03:30:08 -0400 (Sat, 12 Sep 2009) | 5 lines
  
  branches/zip:
  
  Add the check for GCC atomics to ut0auxconf* (copied from plug.in) because
  we no longer rely on MySQL's HAVE_GCC_ATOMIC_BUILTINS.
  
  ------------------------------------------------------------------------
  r5865 | vasil | 2009-09-12 03:26:03 -0400 (Sat, 12 Sep 2009) | 10 lines
  
  branches/zip:
  
  Simplify the compile time checks by splittig them into 5 independent checks:
  
  * Whether GCC atomics are available
  * Whether pthread_t can be used by GCC atomics
  * Whether Solaris libc atomics are available
  * Whether pthread_t can be used by Solaris libs atomics
  * Checking the size of pthread_t
  
  ------------------------------------------------------------------------
  r5864 | vasil | 2009-09-12 03:22:55 -0400 (Sat, 12 Sep 2009) | 4 lines
  
  branches/zip:
  
  Include string.h which is needed for memset().
  
  ------------------------------------------------------------------------
  r5863 | vasil | 2009-09-12 03:07:08 -0400 (Sat, 12 Sep 2009) | 10 lines
  
  branches/zip:
  
  Check that pthread_t can indeed be passed to Solaris atomic functions, instead
  of assuming that it can be passed if 0 can be assigned to it. It could be that:
  * 0 can be assigned, but pthread_t cannot be passed and
  * 0 cannot be assigned but pthread_t can be passed
  
  Better to check what we are interested in, not something else and make
  assumptions.
  
  ------------------------------------------------------------------------
  r5858 | vasil | 2009-09-11 13:46:47 -0400 (Fri, 11 Sep 2009) | 4 lines
  
  branches/zip:
  
  Fix the indentation of the closing bracket.
  
  ------------------------------------------------------------------------
  r5826 | marko | 2009-09-10 07:29:46 -0400 (Thu, 10 Sep 2009) | 12 lines
  
  branches/zip: Roll back recovered dictionary transactions before
  dropping incomplete indexes (Issue #337).
  
  trx_rollback_or_clean_recovered(ibool all): New function, split from
  trx_rollback_or_clean_all_recovered().  all==FALSE will only roll back
  dictionary transactions.
  
  recv_recovery_from_checkpoint_finish(): Call
  trx_rollback_or_clean_recovered(FALSE) before
  row_merge_drop_temp_indexes().
  
  rb://158 approved by Sunny Bains
  ------------------------------------------------------------------------
  r5825 | marko | 2009-09-10 06:47:09 -0400 (Thu, 10 Sep 2009) | 20 lines
  
  branches/zip: Reduce mutex contention that was introduced when
  addressing Bug #45015 (Issue #316), in r5703.
  
  buf_page_set_accessed_make_young(): New auxiliary function, called by
  buf_page_get_zip(), buf_page_get_gen(),
  buf_page_optimistic_get_func(). Call ut_time_ms() outside of
  buf_pool_mutex. Use cached access_time.
  
  buf_page_set_accessed(): Add the parameter time_ms, so that
  ut_time_ms() need not be called while holding buf_pool_mutex.
  
  buf_page_optimistic_get_func(), buf_page_get_known_nowait(): Read
  buf_page_t::access_time without holding buf_pool_mutex. This should be
  OK, because the field is only used for heuristic purposes.
  
  buf_page_peek_if_too_old(): If buf_pool->freed_page_clock == 0, return
  FALSE, so that we will not waste time moving blocks in the LRU list in
  the warm-up phase or when the workload fits in the buffer pool.
  
  rb://156 approved by Sunny Bains
  ------------------------------------------------------------------------
  r5822 | marko | 2009-09-10 06:10:20 -0400 (Thu, 10 Sep 2009) | 1 line
  
  branches/zip: buf_page_release(): De-stutter the function comment.
  ------------------------------------------------------------------------
  r5804 | marko | 2009-09-10 01:29:31 -0400 (Thu, 10 Sep 2009) | 1 line
  
  branches/zip: trx_cleanup_at_db_startup(): Fix a typo in comment.
  ------------------------------------------------------------------------
  r5798 | calvin | 2009-09-09 11:28:10 -0400 (Wed, 09 Sep 2009) | 5 lines
  
  branches/zip:
  
  HA_ERR_TOO_MANY_CONCURRENT_TRXS is added in 5.1.38.
  But the plugin should still work with previous versions
  of MySQL.
  ------------------------------------------------------------------------
  r5792 | vasil | 2009-09-09 09:35:58 -0400 (Wed, 09 Sep 2009) | 32 lines
  
  branches/zip:
  
  Fix a bug in manipulating the variable innodb_old_blocks_pct:
  
  for any value assigned it got that value -1, except for 75. When
  assigned 75, it got 75.
  
    mysql> set global innodb_old_blocks_pct=15;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> show variables like 'innodb_old_blocks_pct';
    +-----------------------+-------+
    | Variable_name         | Value |
    +-----------------------+-------+
    | innodb_old_blocks_pct | 14    | 
    +-----------------------+-------+
    1 row in set (0.00 sec)
    
    mysql> set global innodb_old_blocks_pct=75;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> show variables like 'innodb_old_blocks_pct';
    +-----------------------+-------+
    | Variable_name         | Value |
    +-----------------------+-------+
    | innodb_old_blocks_pct | 75    | 
    +-----------------------+-------+
  
  After the fix it gets exactly what was assigned.
  
  Approved by:	Marko (via IM)
  
  ------------------------------------------------------------------------
  r5783 | marko | 2009-09-09 03:25:00 -0400 (Wed, 09 Sep 2009) | 1 line
  
  branches/zip: buf_page_is_accessed(): Correct the function comment.
  ------------------------------------------------------------------------
  r5782 | marko | 2009-09-09 03:00:59 -0400 (Wed, 09 Sep 2009) | 2 lines
  
  branches/zip: buf_page_peek_if_too_old(): Silence a compiler warning
  that was introduced in r5779 on 32-bit systems.
  ------------------------------------------------------------------------
  r5780 | marko | 2009-09-09 02:50:50 -0400 (Wed, 09 Sep 2009) | 1 line
  
  branches/zip: ut_time_ms(): Return ulint, not uint.
  ------------------------------------------------------------------------
  r5779 | marko | 2009-09-09 02:17:19 -0400 (Wed, 09 Sep 2009) | 2 lines
  
  branches/zip: buf_page_peek_if_too_old(): Make the bitmasking work when
  buf_pool->freed_page_clock is wider than 32 bits.
  ------------------------------------------------------------------------
  r5777 | marko | 2009-09-08 11:50:25 -0400 (Tue, 08 Sep 2009) | 2 lines
  
  branches/zip: Remove BUF_LRU_INITIAL_RATIO, which should have been removed
  together with buf_LRU_get_recent_limit().
  ------------------------------------------------------------------------
  r5775 | calvin | 2009-09-07 17:15:05 -0400 (Mon, 07 Sep 2009) | 13 lines
  
  branches/zip: Build InnoDB on Windows with UNIV_HOTBACKUP
  
  The changes are non-functional changes for normal InnoDB,
  but needed for building the Hot Backup on Windows (with
  UNIV_HOTBACKUP defined).
  
  - Define os_aio_use_native_aio for HB.
  - Do not acquire seek mutexes for backup since HB is single threaded.
  - Do not use srv_flush_log_at_trx_commit for HB build
  
  rb://155
  
  Approved by: Marko
  ------------------------------------------------------------------------
  r5752 | marko | 2009-09-03 10:55:51 -0400 (Thu, 03 Sep 2009) | 10 lines
  
  branches/zip: recv_recover_page_func(): Write the log sequence number
  to the compressed page, if there is one.  Previously, the function only
  wrote the LSN to the uncompressed page.
  
  It is not clear why recv_recover_page_func() is updating FIL_PAGE_LSN
  in the buffer pool.  The log sequence number will be stamped on the
  page when it is flushed to disk, in buf_flush_init_for_writing().
  I noticed this inconsistency when analyzing Issue #313, but this patch
  does not fix it.  That is no surprise, since FIL_PAGE_LSN should only
  matter on disk files, not in the buffer pool.
  ------------------------------------------------------------------------
  r5751 | marko | 2009-09-03 10:36:15 -0400 (Thu, 03 Sep 2009) | 7 lines
  
  branches/zip: row_merge(): Remove a bogus debug assertion
  that was triggered when creating an index on an empty table.
  
  row_merge_sort(): Add debug assertions and comments that justify
  the loop termination condition.
  
  The bogus assertion ut_ad(ihalf > 0) was reported by Michael.
  ------------------------------------------------------------------------
  r5748 | marko | 2009-09-03 07:05:44 -0400 (Thu, 03 Sep 2009) | 1 line
  
  branches/zip: MLOG_MULTI_REC_END: Correct the comment.
  ------------------------------------------------------------------------
  r5747 | marko | 2009-09-03 06:46:38 -0400 (Thu, 03 Sep 2009) | 2 lines
  
  branches/zip: recv_scan_log_recs(): Replace while with do...while,
  because the termination condition will always hold on the first iteration.
  ------------------------------------------------------------------------
  r5746 | marko | 2009-09-03 04:55:36 -0400 (Thu, 03 Sep 2009) | 2 lines
  
  branches/zip: log_reserve_and_write_fast(): Do not cache the log_sys pointer
  in a local variable.
  ------------------------------------------------------------------------
  r5745 | marko | 2009-09-03 04:38:22 -0400 (Thu, 03 Sep 2009) | 2 lines
  
  branches/zip: log_check_log_recs(): Enclose in #ifdef UNIV_LOG_DEBUG.
  Add const qualifiers.
  ------------------------------------------------------------------------
  r5744 | marko | 2009-09-03 04:28:35 -0400 (Thu, 03 Sep 2009) | 1 line
  
  branches/zip: ut_align(): Make ptr const, like in ut_align_down().
  ------------------------------------------------------------------------
  r5743 | marko | 2009-09-03 02:36:12 -0400 (Thu, 03 Sep 2009) | 3 lines
  
  branches/zip: log_reserve_and_write_fast(): Remove the redundant
  output parameter "success".
  Success is also indicated by a nonzero return value.
  ------------------------------------------------------------------------
  r5736 | marko | 2009-09-02 03:53:19 -0400 (Wed, 02 Sep 2009) | 1 line
  
  branches/zip: Enclose some timestamp functions in #ifndef UNIV_HOTBACKUP.
  ------------------------------------------------------------------------
  r5735 | marko | 2009-09-02 03:43:09 -0400 (Wed, 02 Sep 2009) | 2 lines
  
  branches/zip: univ.i: Do not undefine PACKAGE or VERSION.
  InnoDB source code does not refer to these macros.
  ------------------------------------------------------------------------
  r5734 | sunny | 2009-09-02 03:08:45 -0400 (Wed, 02 Sep 2009) | 2 lines
  
  branches/zip: Update ChangeLog with r5733 changes.
  
  ------------------------------------------------------------------------
  r5733 | sunny | 2009-09-02 03:05:15 -0400 (Wed, 02 Sep 2009) | 6 lines
  
  branches/zip: Fix a regression introduced by the fix for bug#26316. We check
  whether a transaction holds any AUTOINC locks before we acquire the kernel
  mutex and release those locks.
  
  Fix for rb://153. Approved by Marko.
  
  ------------------------------------------------------------------------
  r5716 | vasil | 2009-08-31 03:47:49 -0400 (Mon, 31 Aug 2009) | 9 lines
  
  branches/zip:
  
  Fix Bug#46718 InnoDB plugin incompatible with gcc 4.1 (at least: on PPC): "Undefined symbol"
  
  by implementing our own check in plug.in instead of using the result from
  the check from MySQL because it is insufficient.
  
  Approved by:	Marko (rb://154)
  
  ------------------------------------------------------------------------
  r5714 | marko | 2009-08-31 02:10:10 -0400 (Mon, 31 Aug 2009) | 5 lines
  
  branches/zip: buf_chunk_not_freed(): Do not acquire block->mutex unless
  block->page.state == BUF_BLOCK_FILE_PAGE.  Check that block->page.state
  makes sense.
  
  Approved by Sunny Bains over the IM.
  ------------------------------------------------------------------------
  r5709 | inaam | 2009-08-28 02:22:46 -0400 (Fri, 28 Aug 2009) | 5 lines
  
  branches/zip rb://152
  
  Disable display of deprecated parameter innodb_file_io_threads in
  'show variables'.
  
  ------------------------------------------------------------------------
  r5708 | inaam | 2009-08-27 18:43:32 -0400 (Thu, 27 Aug 2009) | 4 lines
  
  branches/zip
  
  Remove redundant TRUE : FALSE from the return statement
  
  ------------------------------------------------------------------------
  r5707 | inaam | 2009-08-27 12:20:35 -0400 (Thu, 27 Aug 2009) | 6 lines
  
  branches/zip
  
  Remove unused macros as we erased the random readahead code in r5703.
  Also fixed some comments.
  
  
  ------------------------------------------------------------------------
  r5706 | inaam | 2009-08-27 12:00:27 -0400 (Thu, 27 Aug 2009) | 20 lines
  
  branches/zip rb://147
  
  Done away with following two status variables:
  
  innodb_buffer_pool_read_ahead_rnd
  innodb_buffer_pool_read_ahead_seq
  
  Introduced two new status variables:
  innodb_buffer_pool_read_ahead = number of pages read as part of
  readahead since server startup
  innodb_buffer_pool_read_ahead_evicted = number of pages that are read
  in as readahead but were evicted before ever being accessed since
  server startup i.e.: a measure of how badly our readahead is
  performing
  
  SHOW INNODB STATUS will show two extra numbers in buffer pool section:
  pages read ahead/sec and pages evicted without access/sec
  
  Approved by: Marko
  
  ------------------------------------------------------------------------
  r5705 | marko | 2009-08-27 07:56:24 -0400 (Thu, 27 Aug 2009) | 11 lines
  
  branches/zip: dict_index_find_cols(): On column name lookup failure,
  return DB_CORRUPTION (HA_ERR_CRASHED) instead of abnormally
  terminating the server.  Also, disable the previously added diagnostic
  output to the error log, because mysql-test-run does not like extra
  output in the error log.  (Bug #44571)
  
  dict_index_add_to_cache(): Handle errors from dict_index_find_cols().
  
  mysql-test/innodb_bug44571.test: A test case for triggering the bug.
  
  rb://135 approved by Sunny Bains.
  ------------------------------------------------------------------------
  r5704 | marko | 2009-08-27 04:31:17 -0400 (Thu, 27 Aug 2009) | 32 lines
  
  branches/zip: Fix a critical bug in fast index creation that could
  corrupt the created indexes.
  
  row_merge(): Make "half" an in/out parameter. Determine the offset of
  half the output file. Copy the last blocks record-by-record instead of
  block-by-block, so that the records can be counted. Check that the
  input and output have matching n_rec.
  
  row_merge_sort(): Do not assume that two blocks of size N are merged
  into a block of size 2*N. The output block can be shorter than the
  input if the last page of each input block is almost empty. Use an
  accurate termination condition, based on the "half" computed by
  row_merge().
  
  row_merge_read(), row_merge_write(), row_merge_blocks(): Add debug output.
  
  merge_file_t, row_merge_file_create(): Add n_rec, the number of records
  in the merge file.
  
  row_merge_read_clustered_index(): Update n_rec.
  
  row_merge_blocks(): Update and check n_rec.
  
  row_merge_blocks_copy(): New function, for copying the last blocks in
  row_merge().  Update and check n_rec.
  
  This bug was discovered with a user-supplied test case that creates an
  index where the initial temporary file is 249 one-megabyte blocks and
  the merged files become smaller. In the test, possible merge record
  sizes are 10, 18, and 26 bytes.
  
  rb://150 approved by Sunny Bains.  This addresses Issue #320.
  ------------------------------------------------------------------------
  r5703 | marko | 2009-08-27 03:25:00 -0400 (Thu, 27 Aug 2009) | 41 lines
  
  branches/zip: Replace the constant 3/8 ratio that controls the LRU_old
  size with the settable global variable innodb_old_blocks_pct. The
  minimum and maximum values are 5 and 95 per cent, respectively. The
  default is 100*3/8, in line with the old behavior.
  
  ut_time_ms(): New utility function, to return the current time in
  milliseconds. TODO: Is there a more efficient timestamp function, such
  as rdtsc divided by a power of two?
  
  buf_LRU_old_threshold_ms: New variable, corresponding to
  innodb_old_blocks_time. The value 0 is the default behaviour: no
  timeout before making blocks 'new'.
  
  bpage->accessed, bpage->LRU_position, buf_pool->ulint_clock: Remove.
  
  bpage->access_time: New field, replacing bpage->accessed. Protected by
  buf_pool_mutex instead of bpage->mutex. Updated when a page is created
  or accessed the first time in the buffer pool.
  
  buf_LRU_old_ratio, innobase_old_blocks_pct: New variables,
  corresponding to innodb_old_blocks_pct
  
  buf_LRU_old_ratio_update(), innobase_old_blocks_pct_update(): Update
  functions for buf_LRU_old_ratio, innobase_old_blocks_pct.
  
  buf_page_peek_if_too_old(): Compare ut_time_ms() to bpage->access_time
  if buf_LRU_old_threshold_ms && bpage->old.  Else observe
  buf_LRU_old_ratio and bpage->freed_page_clock.
  
  buf_pool_t: Add n_pages_made_young, n_pages_not_made_young,
  n_pages_made_young_old, n_pages_not_made_young, for statistics.
  
  buf_print(): Display buf_pool->n_pages_made_young,
  buf_pool->n_pages_not_made_young.  This function is only for crash
  diagnostics.
  
  buf_print_io(): Display buf_pool->LRU_old_len and quantities derived
  from buf_pool->n_pages_made_young, buf_pool->n_pages_not_made_young.
  This function is invoked by SHOW ENGINE INNODB STATUS.
  
  rb://129 approved by Heikki Tuuri.  This addresses Bug #45015.
  ------------------------------------------------------------------------
  r5702 | marko | 2009-08-27 03:03:15 -0400 (Thu, 27 Aug 2009) | 1 line
  
  branches/zip: Document also the files affected by r5698 in the ChangeLog.
  ------------------------------------------------------------------------
  r5701 | marko | 2009-08-27 03:01:42 -0400 (Thu, 27 Aug 2009) | 1 line
  
  branches/zip: Document r5698 in the ChangeLog.
  ------------------------------------------------------------------------
  r5698 | inaam | 2009-08-26 10:34:35 -0400 (Wed, 26 Aug 2009) | 13 lines
  
  branches/zip  bug#42885  rb://148
  
  The call to put IO threads to sleep was most probably meant for Windows
  only as the comment in buf0rea.c suggests. However it was enabled on
  all platforms. This patch restricts the sleep call to windows. This
  approach of not putting threads to sleep makes even more sense because
  now we have multiple threads working in the background and it probably
  is not a good idea to put all of them to sleep because a user thread
  wants to post a batch for readahead.
  
  Approved by: Marko
  
  
  ------------------------------------------------------------------------
  r5697 | vasil | 2009-08-26 09:44:40 -0400 (Wed, 26 Aug 2009) | 4 lines
  
  branches/zip:
  
  Fix typo.
  
  ------------------------------------------------------------------------
  r5696 | vasil | 2009-08-26 09:15:59 -0400 (Wed, 26 Aug 2009) | 14 lines
  
  branches/zip:
  
  Merge a change from MySQL:
  
   http://lists.mysql.com/commits/80832
  
   2968 Jonathan Perkin	2009-08-14
        Build fixes for Windows, AIX, HP/UX and Sun Studio11, from Timothy Smith.
        modified:
          CMakeLists.txt
          cmd-line-utils/readline/util.c
          storage/innodb_plugin/handler/i_s.cc
          storage/innodb_plugin/include/univ.i
  
  ------------------------------------------------------------------------
  r5695 | marko | 2009-08-26 09:14:59 -0400 (Wed, 26 Aug 2009) | 1 line
  
  branches/zip: UNIV_DEBUG_LOCK_VALIDATE: Move the definition to univ.i.
  ------------------------------------------------------------------------
  r5694 | marko | 2009-08-26 07:25:26 -0400 (Wed, 26 Aug 2009) | 2 lines
  
  branches/zip: buf_page_t: Clarify that bpage->list may contain garbage.
  This comment was provoked by Inaam.
  ------------------------------------------------------------------------
  r5687 | vasil | 2009-08-20 05:20:22 -0400 (Thu, 20 Aug 2009) | 8 lines
  
  branches/zip:
  
  ChangeLog:
  Follow the convention from the rest of the ChangeLog: for bugfixes from
  bugs.mysql.com only the bug number and title goes in the ChangeLog. Detailed
  explanation on what is the problem and how it was fixed is present in
  the bugs database.
  
  ------------------------------------------------------------------------
  r5686 | vasil | 2009-08-20 05:15:05 -0400 (Thu, 20 Aug 2009) | 4 lines
  
  branches/zip:
  
  White-space fixup.
  
  ------------------------------------------------------------------------
  r5685 | sunny | 2009-08-20 04:18:29 -0400 (Thu, 20 Aug 2009) | 2 lines
  
  branches/zip: Update the ChangeLog with r5684 change.
  
  ------------------------------------------------------------------------
  r5684 | sunny | 2009-08-20 04:05:30 -0400 (Thu, 20 Aug 2009) | 10 lines
  
  branches/zip: Fix bug# 46650:  Innodb assertion autoinc_lock == lock in lock_table_remove_low on INSERT SELECT
  
  We only store the autoinc locks that are granted in the transaction's autoinc
  lock vector. A transacton, that has been rolled back due to a deadlock because
  of an AUTOINC lock attempt, will not have added that lock to the vector. We
  need to check for that when we remove that lock.
  
  rb://145
  Approved by Marko.
  
  ------------------------------------------------------------------------
  r5681 | sunny | 2009-08-14 02:16:24 -0400 (Fri, 14 Aug 2009) | 3 lines
  
  branches/zip: When building HotBackup srv_use_sys_malloc is #ifdef out. We
  move access to the this variable within a !UNIV_HOTBACKUP block.
  
  ------------------------------------------------------------------------
  r5671 | marko | 2009-08-13 04:46:33 -0400 (Thu, 13 Aug 2009) | 5 lines
  
  branches/zip: ha_innobase::add_index(): Fix Bug #46557:
  after a successful operation, read innodb_table->flags from
  the newly created table object, not from the old one that was just freed.
  
  Approved by Sunny.
  ------------------------------------------------------------------------
  r5670 | marko | 2009-08-12 09:16:37 -0400 (Wed, 12 Aug 2009) | 2 lines
  
  branches/zip: trx_undo_rec_copy(): Add const qualifier to undo_rec.
  This is a non-functional change.
  ------------------------------------------------------------------------
  r5663 | marko | 2009-08-11 07:42:37 -0400 (Tue, 11 Aug 2009) | 2 lines
  
  branches/zip: trx_general_rollback_for_mysql(): Remove the redundant
  parameter partial. If savept==NULL, partial==FALSE.
  ------------------------------------------------------------------------
  r5662 | marko | 2009-08-11 05:54:16 -0400 (Tue, 11 Aug 2009) | 1 line
  
  branches/zip: Bump the version number to 1.0.5 after releasing 1.0.4.
  ------------------------------------------------------------------------
  r5642 | calvin | 2009-08-06 19:04:03 -0400 (Thu, 06 Aug 2009) | 2 lines
  
  branches/zip: remove duplicate "the" in comments.
  
  ------------------------------------------------------------------------
  r5639 | marko | 2009-08-06 06:39:34 -0400 (Thu, 06 Aug 2009) | 3 lines
  
  branches/zip: mem_heap_block_free(): If innodb_use_sys_malloc is set,
  do not tell Valgrind that the memory is free, to avoid
  a bogus warning in Valgrind's built-in free() hook.
  ------------------------------------------------------------------------
  r5636 | marko | 2009-08-05 08:27:30 -0400 (Wed, 05 Aug 2009) | 2 lines
  
  branches/zip: lock_rec_validate_page(): Add the parameter zip_size.
  This should help track down Mantis Issue #289.
  ------------------------------------------------------------------------
  r5635 | marko | 2009-08-05 07:06:55 -0400 (Wed, 05 Aug 2009) | 2 lines
  
  branches/zip: Replace <number> with NUMBER in some comments,
  to avoid problems with Doxygen XML output.
  ------------------------------------------------------------------------
  r5629 | marko | 2009-08-04 07:42:44 -0400 (Tue, 04 Aug 2009) | 1 line
  
  branches/zip: mysql-test: Pass MTR's internal checks.
  ------------------------------------------------------------------------
  r5626 | vasil | 2009-08-04 01:53:31 -0400 (Tue, 04 Aug 2009) | 4 lines
  
  branches/zip:
  
  Revert the dummy change from c5625.
  
  ------------------------------------------------------------------------
  r5625 | vasil | 2009-08-04 01:52:48 -0400 (Tue, 04 Aug 2009) | 32 lines
  
  branches/zip: Merge 5518:5622 from branches/5.1, resolving conflict in r5622
  (after resolving the conflict Makefile.am was not changed so I have made
  a dummy change so I can commit and thus record that branches/5.1 has been
  merged in branches/zip up to 5622):
  
    ------------------------------------------------------------------------
    r5622 | vasil | 2009-08-03 15:27:00 +0300 (Mon, 03 Aug 2009) | 20 lines
    Changed paths:
       M /branches/5.1/Makefile.am
    
    branches/5.1:
    
    Merge a change from MySQL:
    
      ------------------------------------------------------------
      revno: 2988
      committer: Satya B <satya.bn@sun.com>
      branch nick: mysql-5.1-bugteam
      timestamp: Wed 2009-07-01 11:06:05 +0530
      message:
        Fix build failure after applying Innodb snapshot 5.1-ss5282
        
        After applying Innodb snapshot 5.1-ss5282, build was broken
        because of missing header file. 
        
        Adding the header file to Makefile.am after informing the 
        innodb developers.
      modified:
        storage/innobase/Makefile.am
    
    ------------------------------------------------------------------------
  
  ------------------------------------------------------------------------
  r5614 | vasil | 2009-07-31 11:09:07 -0400 (Fri, 31 Jul 2009) | 6 lines
  
  branches/zip:
  
  Add fsp0types.h to the list of noinst_HEADERS
  
  Suggested by:	Sergey Vojtovich <svoj@sun.com>
  
  ------------------------------------------------------------------------
  r5539 | vasil | 2009-07-21 06:28:27 -0400 (Tue, 21 Jul 2009) | 4 lines
  
  branches/zip:
  
  Add a test program to check whether the PAUSE instruction is available.
  
  ------------------------------------------------------------------------
  r5537 | vasil | 2009-07-21 05:31:26 -0400 (Tue, 21 Jul 2009) | 5 lines
  
  branches/zip:
  
  Fixups in ChangeLog: sort filenames alphabetically and wrap to 78 chars per
  line.
  
  ------------------------------------------------------------------------
  r5527 | sunny | 2009-07-20 17:56:30 -0400 (Mon, 20 Jul 2009) | 2 lines
  
  branches/zip: For HotBackup builds we don't want to hide the symbols.
  
  ------------------------------------------------------------------------
  r5525 | calvin | 2009-07-20 13:14:30 -0400 (Mon, 20 Jul 2009) | 2 lines
  
  branches/zip: add ChangeLog entry for r5524.
  
  ------------------------------------------------------------------------
2009-09-28 17:34:23 +00:00

1601 lines
44 KiB
C

/*****************************************************************************
Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA
*****************************************************************************/
/**************************************************//**
@file trx/trx0rec.c
Transaction undo log record
Created 3/26/1996 Heikki Tuuri
*******************************************************/
#include "trx0rec.h"
#ifdef UNIV_NONINL
#include "trx0rec.ic"
#endif
#include "fsp0fsp.h"
#include "mach0data.h"
#include "trx0undo.h"
#include "mtr0log.h"
#ifndef UNIV_HOTBACKUP
#include "dict0dict.h"
#include "ut0mem.h"
#include "row0ext.h"
#include "row0upd.h"
#include "que0que.h"
#include "trx0purge.h"
#include "trx0rseg.h"
#include "row0row.h"
/*=========== UNDO LOG RECORD CREATION AND DECODING ====================*/
/**********************************************************************//**
Writes the mtr log entry of the inserted undo log record on the undo log
page. */
UNIV_INLINE
void
trx_undof_page_add_undo_rec_log(
/*============================*/
page_t* undo_page, /*!< in: undo log page */
ulint old_free, /*!< in: start offset of the inserted entry */
ulint new_free, /*!< in: end offset of the entry */
mtr_t* mtr) /*!< in: mtr */
{
byte* log_ptr;
const byte* log_end;
ulint len;
log_ptr = mlog_open(mtr, 11 + 13 + MLOG_BUF_MARGIN);
if (log_ptr == NULL) {
return;
}
log_end = &log_ptr[11 + 13 + MLOG_BUF_MARGIN];
log_ptr = mlog_write_initial_log_record_fast(
undo_page, MLOG_UNDO_INSERT, log_ptr, mtr);
len = new_free - old_free - 4;
mach_write_to_2(log_ptr, len);
log_ptr += 2;
if (log_ptr + len <= log_end) {
memcpy(log_ptr, undo_page + old_free + 2, len);
mlog_close(mtr, log_ptr + len);
} else {
mlog_close(mtr, log_ptr);
mlog_catenate_string(mtr, undo_page + old_free + 2, len);
}
}
#endif /* !UNIV_HOTBACKUP */
/***********************************************************//**
Parses a redo log record of adding an undo log record.
@return end of log record or NULL */
UNIV_INTERN
byte*
trx_undo_parse_add_undo_rec(
/*========================*/
byte* ptr, /*!< in: buffer */
byte* end_ptr,/*!< in: buffer end */
page_t* page) /*!< in: page or NULL */
{
ulint len;
byte* rec;
ulint first_free;
if (end_ptr < ptr + 2) {
return(NULL);
}
len = mach_read_from_2(ptr);
ptr += 2;
if (end_ptr < ptr + len) {
return(NULL);
}
if (page == NULL) {
return(ptr + len);
}
first_free = mach_read_from_2(page + TRX_UNDO_PAGE_HDR
+ TRX_UNDO_PAGE_FREE);
rec = page + first_free;
mach_write_to_2(rec, first_free + 4 + len);
mach_write_to_2(rec + 2 + len, first_free);
mach_write_to_2(page + TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_FREE,
first_free + 4 + len);
ut_memcpy(rec + 2, ptr, len);
return(ptr + len);
}
#ifndef UNIV_HOTBACKUP
/**********************************************************************//**
Calculates the free space left for extending an undo log record.
@return bytes left */
UNIV_INLINE
ulint
trx_undo_left(
/*==========*/
const page_t* page, /*!< in: undo log page */
const byte* ptr) /*!< in: pointer to page */
{
/* The '- 10' is a safety margin, in case we have some small
calculation error below */
return(UNIV_PAGE_SIZE - (ptr - page) - 10 - FIL_PAGE_DATA_END);
}
/**********************************************************************//**
Set the next and previous pointers in the undo page for the undo record
that was written to ptr. Update the first free value by the number of bytes
written for this undo record.
@return offset of the inserted entry on the page if succeeded, 0 if fail */
static
ulint
trx_undo_page_set_next_prev_and_add(
/*================================*/
page_t* undo_page, /*!< in/out: undo log page */
byte* ptr, /*!< in: ptr up to where data has been
written on this undo page. */
mtr_t* mtr) /*!< in: mtr */
{
ulint first_free; /*!< offset within undo_page */
ulint end_of_rec; /*!< offset within undo_page */
byte* ptr_to_first_free;
/* pointer within undo_page
that points to the next free
offset value within undo_page.*/
ut_ad(ptr > undo_page);
ut_ad(ptr < undo_page + UNIV_PAGE_SIZE);
if (UNIV_UNLIKELY(trx_undo_left(undo_page, ptr) < 2)) {
return(0);
}
ptr_to_first_free = undo_page + TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_FREE;
first_free = mach_read_from_2(ptr_to_first_free);
/* Write offset of the previous undo log record */
mach_write_to_2(ptr, first_free);
ptr += 2;
end_of_rec = ptr - undo_page;
/* Write offset of the next undo log record */
mach_write_to_2(undo_page + first_free, end_of_rec);
/* Update the offset to first free undo record */
mach_write_to_2(ptr_to_first_free, end_of_rec);
/* Write this log entry to the UNDO log */
trx_undof_page_add_undo_rec_log(undo_page, first_free,
end_of_rec, mtr);
return(first_free);
}
/**********************************************************************//**
Reports in the undo log of an insert of a clustered index record.
@return offset of the inserted entry on the page if succeed, 0 if fail */
static
ulint
trx_undo_page_report_insert(
/*========================*/
page_t* undo_page, /*!< in: undo log page */
trx_t* trx, /*!< in: transaction */
dict_index_t* index, /*!< in: clustered index */
const dtuple_t* clust_entry, /*!< in: index entry which will be
inserted to the clustered index */
mtr_t* mtr) /*!< in: mtr */
{
ulint first_free;
byte* ptr;
ulint i;
ut_ad(dict_index_is_clust(index));
ut_ad(mach_read_from_2(undo_page + TRX_UNDO_PAGE_HDR
+ TRX_UNDO_PAGE_TYPE) == TRX_UNDO_INSERT);
first_free = mach_read_from_2(undo_page + TRX_UNDO_PAGE_HDR
+ TRX_UNDO_PAGE_FREE);
ptr = undo_page + first_free;
ut_ad(first_free <= UNIV_PAGE_SIZE);
if (trx_undo_left(undo_page, ptr) < 2 + 1 + 11 + 11) {
/* Not enough space for writing the general parameters */
return(0);
}
/* Reserve 2 bytes for the pointer to the next undo log record */
ptr += 2;
/* Store first some general parameters to the undo log */
*ptr++ = TRX_UNDO_INSERT_REC;
ptr += mach_dulint_write_much_compressed(ptr, trx->undo_no);
ptr += mach_dulint_write_much_compressed(ptr, index->table->id);
/*----------------------------------------*/
/* Store then the fields required to uniquely determine the record
to be inserted in the clustered index */
for (i = 0; i < dict_index_get_n_unique(index); i++) {
const dfield_t* field = dtuple_get_nth_field(clust_entry, i);
ulint flen = dfield_get_len(field);
if (trx_undo_left(undo_page, ptr) < 5) {
return(0);
}
ptr += mach_write_compressed(ptr, flen);
if (flen != UNIV_SQL_NULL) {
if (trx_undo_left(undo_page, ptr) < flen) {
return(0);
}
ut_memcpy(ptr, dfield_get_data(field), flen);
ptr += flen;
}
}
return(trx_undo_page_set_next_prev_and_add(undo_page, ptr, mtr));
}
/**********************************************************************//**
Reads from an undo log record the general parameters.
@return remaining part of undo log record after reading these values */
UNIV_INTERN
byte*
trx_undo_rec_get_pars(
/*==================*/
trx_undo_rec_t* undo_rec, /*!< in: undo log record */
ulint* type, /*!< out: undo record type:
TRX_UNDO_INSERT_REC, ... */
ulint* cmpl_info, /*!< out: compiler info, relevant only
for update type records */
ibool* updated_extern, /*!< out: TRUE if we updated an
externally stored fild */
undo_no_t* undo_no, /*!< out: undo log record number */
dulint* table_id) /*!< out: table id */
{
byte* ptr;
ulint type_cmpl;
ptr = undo_rec + 2;
type_cmpl = mach_read_from_1(ptr);
ptr++;
if (type_cmpl & TRX_UNDO_UPD_EXTERN) {
*updated_extern = TRUE;
type_cmpl -= TRX_UNDO_UPD_EXTERN;
} else {
*updated_extern = FALSE;
}
*type = type_cmpl & (TRX_UNDO_CMPL_INFO_MULT - 1);
*cmpl_info = type_cmpl / TRX_UNDO_CMPL_INFO_MULT;
*undo_no = mach_dulint_read_much_compressed(ptr);
ptr += mach_dulint_get_much_compressed_size(*undo_no);
*table_id = mach_dulint_read_much_compressed(ptr);
ptr += mach_dulint_get_much_compressed_size(*table_id);
return(ptr);
}
/**********************************************************************//**
Reads from an undo log record a stored column value.
@return remaining part of undo log record after reading these values */
static
byte*
trx_undo_rec_get_col_val(
/*=====================*/
byte* ptr, /*!< in: pointer to remaining part of undo log record */
byte** field, /*!< out: pointer to stored field */
ulint* len, /*!< out: length of the field, or UNIV_SQL_NULL */
ulint* orig_len)/*!< out: original length of the locally
stored part of an externally stored column, or 0 */
{
*len = mach_read_compressed(ptr);
ptr += mach_get_compressed_size(*len);
*orig_len = 0;
switch (*len) {
case UNIV_SQL_NULL:
*field = NULL;
break;
case UNIV_EXTERN_STORAGE_FIELD:
*orig_len = mach_read_compressed(ptr);
ptr += mach_get_compressed_size(*orig_len);
*len = mach_read_compressed(ptr);
ptr += mach_get_compressed_size(*len);
*field = ptr;
ptr += *len;
ut_ad(*orig_len >= BTR_EXTERN_FIELD_REF_SIZE);
ut_ad(*len > *orig_len);
ut_ad(*len >= REC_MAX_INDEX_COL_LEN
+ BTR_EXTERN_FIELD_REF_SIZE);
*len += UNIV_EXTERN_STORAGE_FIELD;
break;
default:
*field = ptr;
if (*len >= UNIV_EXTERN_STORAGE_FIELD) {
ptr += *len - UNIV_EXTERN_STORAGE_FIELD;
} else {
ptr += *len;
}
}
return(ptr);
}
/*******************************************************************//**
Builds a row reference from an undo log record.
@return pointer to remaining part of undo record */
UNIV_INTERN
byte*
trx_undo_rec_get_row_ref(
/*=====================*/
byte* ptr, /*!< in: remaining part of a copy of an undo log
record, at the start of the row reference;
NOTE that this copy of the undo log record must
be preserved as long as the row reference is
used, as we do NOT copy the data in the
record! */
dict_index_t* index, /*!< in: clustered index */
dtuple_t** ref, /*!< out, own: row reference */
mem_heap_t* heap) /*!< in: memory heap from which the memory
needed is allocated */
{
ulint ref_len;
ulint i;
ut_ad(index && ptr && ref && heap);
ut_a(dict_index_is_clust(index));
ref_len = dict_index_get_n_unique(index);
*ref = dtuple_create(heap, ref_len);
dict_index_copy_types(*ref, index, ref_len);
for (i = 0; i < ref_len; i++) {
dfield_t* dfield;
byte* field;
ulint len;
ulint orig_len;
dfield = dtuple_get_nth_field(*ref, i);
ptr = trx_undo_rec_get_col_val(ptr, &field, &len, &orig_len);
dfield_set_data(dfield, field, len);
}
return(ptr);
}
/*******************************************************************//**
Skips a row reference from an undo log record.
@return pointer to remaining part of undo record */
UNIV_INTERN
byte*
trx_undo_rec_skip_row_ref(
/*======================*/
byte* ptr, /*!< in: remaining part in update undo log
record, at the start of the row reference */
dict_index_t* index) /*!< in: clustered index */
{
ulint ref_len;
ulint i;
ut_ad(index && ptr);
ut_a(dict_index_is_clust(index));
ref_len = dict_index_get_n_unique(index);
for (i = 0; i < ref_len; i++) {
byte* field;
ulint len;
ulint orig_len;
ptr = trx_undo_rec_get_col_val(ptr, &field, &len, &orig_len);
}
return(ptr);
}
/**********************************************************************//**
Fetch a prefix of an externally stored column, for writing to the undo log
of an update or delete marking of a clustered index record.
@return ext_buf */
static
byte*
trx_undo_page_fetch_ext(
/*====================*/
byte* ext_buf, /*!< in: a buffer of
REC_MAX_INDEX_COL_LEN
+ BTR_EXTERN_FIELD_REF_SIZE */
ulint zip_size, /*!< compressed page size in bytes,
or 0 for uncompressed BLOB */
const byte* field, /*!< in: an externally stored column */
ulint* len) /*!< in: length of field;
out: used length of ext_buf */
{
/* Fetch the BLOB. */
ulint ext_len = btr_copy_externally_stored_field_prefix(
ext_buf, REC_MAX_INDEX_COL_LEN, zip_size, field, *len);
/* BLOBs should always be nonempty. */
ut_a(ext_len);
/* Append the BLOB pointer to the prefix. */
memcpy(ext_buf + ext_len,
field + *len - BTR_EXTERN_FIELD_REF_SIZE,
BTR_EXTERN_FIELD_REF_SIZE);
*len = ext_len + BTR_EXTERN_FIELD_REF_SIZE;
return(ext_buf);
}
/**********************************************************************//**
Writes to the undo log a prefix of an externally stored column.
@return undo log position */
static
byte*
trx_undo_page_report_modify_ext(
/*============================*/
byte* ptr, /*!< in: undo log position,
at least 15 bytes must be available */
byte* ext_buf, /*!< in: a buffer of
REC_MAX_INDEX_COL_LEN
+ BTR_EXTERN_FIELD_REF_SIZE,
or NULL when should not fetch
a longer prefix */
ulint zip_size, /*!< compressed page size in bytes,
or 0 for uncompressed BLOB */
const byte** field, /*!< in/out: the locally stored part of
the externally stored column */
ulint* len) /*!< in/out: length of field, in bytes */
{
if (ext_buf) {
/* If an ordering column is externally stored, we will
have to store a longer prefix of the field. In this
case, write to the log a marker followed by the
original length and the real length of the field. */
ptr += mach_write_compressed(ptr, UNIV_EXTERN_STORAGE_FIELD);
ptr += mach_write_compressed(ptr, *len);
*field = trx_undo_page_fetch_ext(ext_buf, zip_size,
*field, len);
ptr += mach_write_compressed(ptr, *len);
} else {
ptr += mach_write_compressed(ptr, UNIV_EXTERN_STORAGE_FIELD
+ *len);
}
return(ptr);
}
/**********************************************************************//**
Reports in the undo log of an update or delete marking of a clustered index
record.
@return byte offset of the inserted undo log entry on the page if
succeed, 0 if fail */
static
ulint
trx_undo_page_report_modify(
/*========================*/
page_t* undo_page, /*!< in: undo log page */
trx_t* trx, /*!< in: transaction */
dict_index_t* index, /*!< in: clustered index where update or
delete marking is done */
const rec_t* rec, /*!< in: clustered index record which
has NOT yet been modified */
const ulint* offsets, /*!< in: rec_get_offsets(rec, index) */
const upd_t* update, /*!< in: update vector which tells the
columns to be updated; in the case of
a delete, this should be set to NULL */
ulint cmpl_info, /*!< in: compiler info on secondary
index updates */
mtr_t* mtr) /*!< in: mtr */
{
dict_table_t* table;
ulint first_free;
byte* ptr;
const byte* field;
ulint flen;
ulint col_no;
ulint type_cmpl;
byte* type_cmpl_ptr;
ulint i;
trx_id_t trx_id;
ibool ignore_prefix = FALSE;
byte ext_buf[REC_MAX_INDEX_COL_LEN
+ BTR_EXTERN_FIELD_REF_SIZE];
ut_a(dict_index_is_clust(index));
ut_ad(rec_offs_validate(rec, index, offsets));
ut_ad(mach_read_from_2(undo_page + TRX_UNDO_PAGE_HDR
+ TRX_UNDO_PAGE_TYPE) == TRX_UNDO_UPDATE);
table = index->table;
first_free = mach_read_from_2(undo_page + TRX_UNDO_PAGE_HDR
+ TRX_UNDO_PAGE_FREE);
ptr = undo_page + first_free;
ut_ad(first_free <= UNIV_PAGE_SIZE);
if (trx_undo_left(undo_page, ptr) < 50) {
/* NOTE: the value 50 must be big enough so that the general
fields written below fit on the undo log page */
return(0);
}
/* Reserve 2 bytes for the pointer to the next undo log record */
ptr += 2;
/* Store first some general parameters to the undo log */
if (!update) {
type_cmpl = TRX_UNDO_DEL_MARK_REC;
} else if (rec_get_deleted_flag(rec, dict_table_is_comp(table))) {
type_cmpl = TRX_UNDO_UPD_DEL_REC;
/* We are about to update a delete marked record.
We don't typically need the prefix in this case unless
the delete marking is done by the same transaction
(which we check below). */
ignore_prefix = TRUE;
} else {
type_cmpl = TRX_UNDO_UPD_EXIST_REC;
}
type_cmpl |= cmpl_info * TRX_UNDO_CMPL_INFO_MULT;
type_cmpl_ptr = ptr;
*ptr++ = (byte) type_cmpl;
ptr += mach_dulint_write_much_compressed(ptr, trx->undo_no);
ptr += mach_dulint_write_much_compressed(ptr, table->id);
/*----------------------------------------*/
/* Store the state of the info bits */
*ptr++ = (byte) rec_get_info_bits(rec, dict_table_is_comp(table));
/* Store the values of the system columns */
field = rec_get_nth_field(rec, offsets,
dict_index_get_sys_col_pos(
index, DATA_TRX_ID), &flen);
ut_ad(flen == DATA_TRX_ID_LEN);
trx_id = trx_read_trx_id(field);
/* If it is an update of a delete marked record, then we are
allowed to ignore blob prefixes if the delete marking was done
by some other trx as it must have committed by now for us to
allow an over-write. */
if (ignore_prefix) {
ignore_prefix = ut_dulint_cmp(trx_id, trx->id) != 0;
}
ptr += mach_dulint_write_compressed(ptr, trx_id);
field = rec_get_nth_field(rec, offsets,
dict_index_get_sys_col_pos(
index, DATA_ROLL_PTR), &flen);
ut_ad(flen == DATA_ROLL_PTR_LEN);
ptr += mach_dulint_write_compressed(ptr, trx_read_roll_ptr(field));
/*----------------------------------------*/
/* Store then the fields required to uniquely determine the
record which will be modified in the clustered index */
for (i = 0; i < dict_index_get_n_unique(index); i++) {
field = rec_get_nth_field(rec, offsets, i, &flen);
/* The ordering columns must not be stored externally. */
ut_ad(!rec_offs_nth_extern(offsets, i));
ut_ad(dict_index_get_nth_col(index, i)->ord_part);
if (trx_undo_left(undo_page, ptr) < 5) {
return(0);
}
ptr += mach_write_compressed(ptr, flen);
if (flen != UNIV_SQL_NULL) {
if (trx_undo_left(undo_page, ptr) < flen) {
return(0);
}
ut_memcpy(ptr, field, flen);
ptr += flen;
}
}
/*----------------------------------------*/
/* Save to the undo log the old values of the columns to be updated. */
if (update) {
if (trx_undo_left(undo_page, ptr) < 5) {
return(0);
}
ptr += mach_write_compressed(ptr, upd_get_n_fields(update));
for (i = 0; i < upd_get_n_fields(update); i++) {
ulint pos = upd_get_nth_field(update, i)->field_no;
/* Write field number to undo log */
if (trx_undo_left(undo_page, ptr) < 5) {
return(0);
}
ptr += mach_write_compressed(ptr, pos);
/* Save the old value of field */
field = rec_get_nth_field(rec, offsets, pos, &flen);
if (trx_undo_left(undo_page, ptr) < 15) {
return(0);
}
if (rec_offs_nth_extern(offsets, pos)) {
ptr = trx_undo_page_report_modify_ext(
ptr,
dict_index_get_nth_col(index, pos)
->ord_part
&& !ignore_prefix
&& flen < REC_MAX_INDEX_COL_LEN
? ext_buf : NULL,
dict_table_zip_size(table),
&field, &flen);
/* Notify purge that it eventually has to
free the old externally stored field */
trx->update_undo->del_marks = TRUE;
*type_cmpl_ptr |= TRX_UNDO_UPD_EXTERN;
} else {
ptr += mach_write_compressed(ptr, flen);
}
if (flen != UNIV_SQL_NULL) {
if (trx_undo_left(undo_page, ptr) < flen) {
return(0);
}
ut_memcpy(ptr, field, flen);
ptr += flen;
}
}
}
/*----------------------------------------*/
/* In the case of a delete marking, and also in the case of an update
where any ordering field of any index changes, store the values of all
columns which occur as ordering fields in any index. This info is used
in the purge of old versions where we use it to build and search the
delete marked index records, to look if we can remove them from the
index tree. Note that starting from 4.0.14 also externally stored
fields can be ordering in some index. Starting from 5.2, we no longer
store REC_MAX_INDEX_COL_LEN first bytes to the undo log record,
but we can construct the column prefix fields in the index by
fetching the first page of the BLOB that is pointed to by the
clustered index. This works also in crash recovery, because all pages
(including BLOBs) are recovered before anything is rolled back. */
if (!update || !(cmpl_info & UPD_NODE_NO_ORD_CHANGE)) {
byte* old_ptr = ptr;
trx->update_undo->del_marks = TRUE;
if (trx_undo_left(undo_page, ptr) < 5) {
return(0);
}
/* Reserve 2 bytes to write the number of bytes the stored
fields take in this undo record */
ptr += 2;
for (col_no = 0; col_no < dict_table_get_n_cols(table);
col_no++) {
const dict_col_t* col
= dict_table_get_nth_col(table, col_no);
if (col->ord_part) {
ulint pos;
/* Write field number to undo log */
if (trx_undo_left(undo_page, ptr) < 5 + 15) {
return(0);
}
pos = dict_index_get_nth_col_pos(index,
col_no);
ptr += mach_write_compressed(ptr, pos);
/* Save the old value of field */
field = rec_get_nth_field(rec, offsets, pos,
&flen);
if (rec_offs_nth_extern(offsets, pos)) {
ptr = trx_undo_page_report_modify_ext(
ptr,
flen < REC_MAX_INDEX_COL_LEN
&& !ignore_prefix
? ext_buf : NULL,
dict_table_zip_size(table),
&field, &flen);
} else {
ptr += mach_write_compressed(
ptr, flen);
}
if (flen != UNIV_SQL_NULL) {
if (trx_undo_left(undo_page, ptr)
< flen) {
return(0);
}
ut_memcpy(ptr, field, flen);
ptr += flen;
}
}
}
mach_write_to_2(old_ptr, ptr - old_ptr);
}
/*----------------------------------------*/
/* Write pointers to the previous and the next undo log records */
if (trx_undo_left(undo_page, ptr) < 2) {
return(0);
}
mach_write_to_2(ptr, first_free);
ptr += 2;
mach_write_to_2(undo_page + first_free, ptr - undo_page);
mach_write_to_2(undo_page + TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_FREE,
ptr - undo_page);
/* Write to the REDO log about this change in the UNDO log */
trx_undof_page_add_undo_rec_log(undo_page, first_free,
ptr - undo_page, mtr);
return(first_free);
}
/**********************************************************************//**
Reads from an undo log update record the system field values of the old
version.
@return remaining part of undo log record after reading these values */
UNIV_INTERN
byte*
trx_undo_update_rec_get_sys_cols(
/*=============================*/
byte* ptr, /*!< in: remaining part of undo
log record after reading
general parameters */
trx_id_t* trx_id, /*!< out: trx id */
roll_ptr_t* roll_ptr, /*!< out: roll ptr */
ulint* info_bits) /*!< out: info bits state */
{
/* Read the state of the info bits */
*info_bits = mach_read_from_1(ptr);
ptr += 1;
/* Read the values of the system columns */
*trx_id = mach_dulint_read_compressed(ptr);
ptr += mach_dulint_get_compressed_size(*trx_id);
*roll_ptr = mach_dulint_read_compressed(ptr);
ptr += mach_dulint_get_compressed_size(*roll_ptr);
return(ptr);
}
/**********************************************************************//**
Reads from an update undo log record the number of updated fields.
@return remaining part of undo log record after reading this value */
UNIV_INLINE
byte*
trx_undo_update_rec_get_n_upd_fields(
/*=================================*/
byte* ptr, /*!< in: pointer to remaining part of undo log record */
ulint* n) /*!< out: number of fields */
{
*n = mach_read_compressed(ptr);
ptr += mach_get_compressed_size(*n);
return(ptr);
}
/**********************************************************************//**
Reads from an update undo log record a stored field number.
@return remaining part of undo log record after reading this value */
UNIV_INLINE
byte*
trx_undo_update_rec_get_field_no(
/*=============================*/
byte* ptr, /*!< in: pointer to remaining part of undo log record */
ulint* field_no)/*!< out: field number */
{
*field_no = mach_read_compressed(ptr);
ptr += mach_get_compressed_size(*field_no);
return(ptr);
}
/*******************************************************************//**
Builds an update vector based on a remaining part of an undo log record.
@return remaining part of the record, NULL if an error detected, which
means that the record is corrupted */
UNIV_INTERN
byte*
trx_undo_update_rec_get_update(
/*===========================*/
byte* ptr, /*!< in: remaining part in update undo log
record, after reading the row reference
NOTE that this copy of the undo log record must
be preserved as long as the update vector is
used, as we do NOT copy the data in the
record! */
dict_index_t* index, /*!< in: clustered index */
ulint type, /*!< in: TRX_UNDO_UPD_EXIST_REC,
TRX_UNDO_UPD_DEL_REC, or
TRX_UNDO_DEL_MARK_REC; in the last case,
only trx id and roll ptr fields are added to
the update vector */
trx_id_t trx_id, /*!< in: transaction id from this undo record */
roll_ptr_t roll_ptr,/*!< in: roll pointer from this undo record */
ulint info_bits,/*!< in: info bits from this undo record */
trx_t* trx, /*!< in: transaction */
mem_heap_t* heap, /*!< in: memory heap from which the memory
needed is allocated */
upd_t** upd) /*!< out, own: update vector */
{
upd_field_t* upd_field;
upd_t* update;
ulint n_fields;
byte* buf;
ulint i;
ut_a(dict_index_is_clust(index));
if (type != TRX_UNDO_DEL_MARK_REC) {
ptr = trx_undo_update_rec_get_n_upd_fields(ptr, &n_fields);
} else {
n_fields = 0;
}
update = upd_create(n_fields + 2, heap);
update->info_bits = info_bits;
/* Store first trx id and roll ptr to update vector */
upd_field = upd_get_nth_field(update, n_fields);
buf = mem_heap_alloc(heap, DATA_TRX_ID_LEN);
trx_write_trx_id(buf, trx_id);
upd_field_set_field_no(upd_field,
dict_index_get_sys_col_pos(index, DATA_TRX_ID),
index, trx);
dfield_set_data(&(upd_field->new_val), buf, DATA_TRX_ID_LEN);
upd_field = upd_get_nth_field(update, n_fields + 1);
buf = mem_heap_alloc(heap, DATA_ROLL_PTR_LEN);
trx_write_roll_ptr(buf, roll_ptr);
upd_field_set_field_no(
upd_field, dict_index_get_sys_col_pos(index, DATA_ROLL_PTR),
index, trx);
dfield_set_data(&(upd_field->new_val), buf, DATA_ROLL_PTR_LEN);
/* Store then the updated ordinary columns to the update vector */
for (i = 0; i < n_fields; i++) {
byte* field;
ulint len;
ulint field_no;
ulint orig_len;
ptr = trx_undo_update_rec_get_field_no(ptr, &field_no);
if (field_no >= dict_index_get_n_fields(index)) {
fprintf(stderr,
"InnoDB: Error: trying to access"
" update undo rec field %lu in ",
(ulong) field_no);
dict_index_name_print(stderr, trx, index);
fprintf(stderr, "\n"
"InnoDB: but index has only %lu fields\n"
"InnoDB: Submit a detailed bug report"
" to http://bugs.mysql.com\n"
"InnoDB: Run also CHECK TABLE ",
(ulong) dict_index_get_n_fields(index));
ut_print_name(stderr, trx, TRUE, index->table_name);
fprintf(stderr, "\n"
"InnoDB: n_fields = %lu, i = %lu, ptr %p\n",
(ulong) n_fields, (ulong) i, ptr);
return(NULL);
}
upd_field = upd_get_nth_field(update, i);
upd_field_set_field_no(upd_field, field_no, index, trx);
ptr = trx_undo_rec_get_col_val(ptr, &field, &len, &orig_len);
upd_field->orig_len = orig_len;
if (len == UNIV_SQL_NULL) {
dfield_set_null(&upd_field->new_val);
} else if (len < UNIV_EXTERN_STORAGE_FIELD) {
dfield_set_data(&upd_field->new_val, field, len);
} else {
len -= UNIV_EXTERN_STORAGE_FIELD;
dfield_set_data(&upd_field->new_val, field, len);
dfield_set_ext(&upd_field->new_val);
}
}
*upd = update;
return(ptr);
}
/*******************************************************************//**
Builds a partial row from an update undo log record. It contains the
columns which occur as ordering in any index of the table.
@return pointer to remaining part of undo record */
UNIV_INTERN
byte*
trx_undo_rec_get_partial_row(
/*=========================*/
byte* ptr, /*!< in: remaining part in update undo log
record of a suitable type, at the start of
the stored index columns;
NOTE that this copy of the undo log record must
be preserved as long as the partial row is
used, as we do NOT copy the data in the
record! */
dict_index_t* index, /*!< in: clustered index */
dtuple_t** row, /*!< out, own: partial row */
ibool ignore_prefix, /*!< in: flag to indicate if we
expect blob prefixes in undo. Used
only in the assertion. */
mem_heap_t* heap) /*!< in: memory heap from which the memory
needed is allocated */
{
const byte* end_ptr;
ulint row_len;
ut_ad(index);
ut_ad(ptr);
ut_ad(row);
ut_ad(heap);
ut_ad(dict_index_is_clust(index));
row_len = dict_table_get_n_cols(index->table);
*row = dtuple_create(heap, row_len);
dict_table_copy_types(*row, index->table);
end_ptr = ptr + mach_read_from_2(ptr);
ptr += 2;
while (ptr != end_ptr) {
dfield_t* dfield;
byte* field;
ulint field_no;
const dict_col_t* col;
ulint col_no;
ulint len;
ulint orig_len;
ptr = trx_undo_update_rec_get_field_no(ptr, &field_no);
col = dict_index_get_nth_col(index, field_no);
col_no = dict_col_get_no(col);
ptr = trx_undo_rec_get_col_val(ptr, &field, &len, &orig_len);
dfield = dtuple_get_nth_field(*row, col_no);
dfield_set_data(dfield, field, len);
if (len != UNIV_SQL_NULL
&& len >= UNIV_EXTERN_STORAGE_FIELD) {
dfield_set_len(dfield,
len - UNIV_EXTERN_STORAGE_FIELD);
dfield_set_ext(dfield);
/* If the prefix of this column is indexed,
ensure that enough prefix is stored in the
undo log record. */
ut_a(ignore_prefix
|| !col->ord_part
|| dfield_get_len(dfield)
>= REC_MAX_INDEX_COL_LEN
+ BTR_EXTERN_FIELD_REF_SIZE);
}
}
return(ptr);
}
#endif /* !UNIV_HOTBACKUP */
/***********************************************************************//**
Erases the unused undo log page end. */
static
void
trx_undo_erase_page_end(
/*====================*/
page_t* undo_page, /*!< in: undo page whose end to erase */
mtr_t* mtr) /*!< in: mtr */
{
ulint first_free;
first_free = mach_read_from_2(undo_page + TRX_UNDO_PAGE_HDR
+ TRX_UNDO_PAGE_FREE);
memset(undo_page + first_free, 0xff,
(UNIV_PAGE_SIZE - FIL_PAGE_DATA_END) - first_free);
mlog_write_initial_log_record(undo_page, MLOG_UNDO_ERASE_END, mtr);
}
/***********************************************************//**
Parses a redo log record of erasing of an undo page end.
@return end of log record or NULL */
UNIV_INTERN
byte*
trx_undo_parse_erase_page_end(
/*==========================*/
byte* ptr, /*!< in: buffer */
byte* end_ptr __attribute__((unused)), /*!< in: buffer end */
page_t* page, /*!< in: page or NULL */
mtr_t* mtr) /*!< in: mtr or NULL */
{
ut_ad(ptr && end_ptr);
if (page == NULL) {
return(ptr);
}
trx_undo_erase_page_end(page, mtr);
return(ptr);
}
#ifndef UNIV_HOTBACKUP
/***********************************************************************//**
Writes information to an undo log about an insert, update, or a delete marking
of a clustered index record. This information is used in a rollback of the
transaction and in consistent reads that must look to the history of this
transaction.
@return DB_SUCCESS or error code */
UNIV_INTERN
ulint
trx_undo_report_row_operation(
/*==========================*/
ulint flags, /*!< in: if BTR_NO_UNDO_LOG_FLAG bit is
set, does nothing */
ulint op_type, /*!< in: TRX_UNDO_INSERT_OP or
TRX_UNDO_MODIFY_OP */
que_thr_t* thr, /*!< in: query thread */
dict_index_t* index, /*!< in: clustered index */
const dtuple_t* clust_entry, /*!< in: in the case of an insert,
index entry to insert into the
clustered index, otherwise NULL */
const upd_t* update, /*!< in: in the case of an update,
the update vector, otherwise NULL */
ulint cmpl_info, /*!< in: compiler info on secondary
index updates */
const rec_t* rec, /*!< in: in case of an update or delete
marking, the record in the clustered
index, otherwise NULL */
roll_ptr_t* roll_ptr) /*!< out: rollback pointer to the
inserted undo log record,
ut_dulint_zero if BTR_NO_UNDO_LOG
flag was specified */
{
trx_t* trx;
trx_undo_t* undo;
ulint page_no;
trx_rseg_t* rseg;
mtr_t mtr;
ulint err = DB_SUCCESS;
mem_heap_t* heap = NULL;
ulint offsets_[REC_OFFS_NORMAL_SIZE];
ulint* offsets = offsets_;
rec_offs_init(offsets_);
ut_a(dict_index_is_clust(index));
if (flags & BTR_NO_UNDO_LOG_FLAG) {
*roll_ptr = ut_dulint_zero;
return(DB_SUCCESS);
}
ut_ad(thr);
ut_ad((op_type != TRX_UNDO_INSERT_OP)
|| (clust_entry && !update && !rec));
trx = thr_get_trx(thr);
rseg = trx->rseg;
mutex_enter(&(trx->undo_mutex));
/* If the undo log is not assigned yet, assign one */
if (op_type == TRX_UNDO_INSERT_OP) {
if (trx->insert_undo == NULL) {
err = trx_undo_assign_undo(trx, TRX_UNDO_INSERT);
}
undo = trx->insert_undo;
if (UNIV_UNLIKELY(!undo)) {
/* Did not succeed */
mutex_exit(&(trx->undo_mutex));
return(err);
}
} else {
ut_ad(op_type == TRX_UNDO_MODIFY_OP);
if (trx->update_undo == NULL) {
err = trx_undo_assign_undo(trx, TRX_UNDO_UPDATE);
}
undo = trx->update_undo;
if (UNIV_UNLIKELY(!undo)) {
/* Did not succeed */
mutex_exit(&(trx->undo_mutex));
return(err);
}
offsets = rec_get_offsets(rec, index, offsets,
ULINT_UNDEFINED, &heap);
}
page_no = undo->last_page_no;
mtr_start(&mtr);
for (;;) {
buf_block_t* undo_block;
page_t* undo_page;
ulint offset;
undo_block = buf_page_get_gen(undo->space, undo->zip_size,
page_no, RW_X_LATCH,
undo->guess_block, BUF_GET,
__FILE__, __LINE__, &mtr);
buf_block_dbg_add_level(undo_block, SYNC_TRX_UNDO_PAGE);
undo_page = buf_block_get_frame(undo_block);
if (op_type == TRX_UNDO_INSERT_OP) {
offset = trx_undo_page_report_insert(
undo_page, trx, index, clust_entry, &mtr);
} else {
offset = trx_undo_page_report_modify(
undo_page, trx, index, rec, offsets, update,
cmpl_info, &mtr);
}
if (UNIV_UNLIKELY(offset == 0)) {
/* The record did not fit on the page. We erase the
end segment of the undo log page and write a log
record of it: this is to ensure that in the debug
version the replicate page constructed using the log
records stays identical to the original page */
trx_undo_erase_page_end(undo_page, &mtr);
mtr_commit(&mtr);
} else {
/* Success */
mtr_commit(&mtr);
undo->empty = FALSE;
undo->top_page_no = page_no;
undo->top_offset = offset;
undo->top_undo_no = trx->undo_no;
undo->guess_block = undo_block;
UT_DULINT_INC(trx->undo_no);
mutex_exit(&trx->undo_mutex);
*roll_ptr = trx_undo_build_roll_ptr(
op_type == TRX_UNDO_INSERT_OP,
rseg->id, page_no, offset);
if (UNIV_LIKELY_NULL(heap)) {
mem_heap_free(heap);
}
return(DB_SUCCESS);
}
ut_ad(page_no == undo->last_page_no);
/* We have to extend the undo log by one page */
mtr_start(&mtr);
/* When we add a page to an undo log, this is analogous to
a pessimistic insert in a B-tree, and we must reserve the
counterpart of the tree latch, which is the rseg mutex. */
mutex_enter(&(rseg->mutex));
page_no = trx_undo_add_page(trx, undo, &mtr);
mutex_exit(&(rseg->mutex));
if (UNIV_UNLIKELY(page_no == FIL_NULL)) {
/* Did not succeed: out of space */
mutex_exit(&(trx->undo_mutex));
mtr_commit(&mtr);
if (UNIV_LIKELY_NULL(heap)) {
mem_heap_free(heap);
}
return(DB_OUT_OF_FILE_SPACE);
}
}
}
/*============== BUILDING PREVIOUS VERSION OF A RECORD ===============*/
/******************************************************************//**
Copies an undo record to heap. This function can be called if we know that
the undo log record exists.
@return own: copy of the record */
UNIV_INTERN
trx_undo_rec_t*
trx_undo_get_undo_rec_low(
/*======================*/
roll_ptr_t roll_ptr, /*!< in: roll pointer to record */
mem_heap_t* heap) /*!< in: memory heap where copied */
{
trx_undo_rec_t* undo_rec;
ulint rseg_id;
ulint page_no;
ulint offset;
const page_t* undo_page;
trx_rseg_t* rseg;
ibool is_insert;
mtr_t mtr;
trx_undo_decode_roll_ptr(roll_ptr, &is_insert, &rseg_id, &page_no,
&offset);
rseg = trx_rseg_get_on_id(rseg_id);
mtr_start(&mtr);
undo_page = trx_undo_page_get_s_latched(rseg->space, rseg->zip_size,
page_no, &mtr);
undo_rec = trx_undo_rec_copy(undo_page + offset, heap);
mtr_commit(&mtr);
return(undo_rec);
}
/******************************************************************//**
Copies an undo record to heap.
NOTE: the caller must have latches on the clustered index page and
purge_view.
@return DB_SUCCESS, or DB_MISSING_HISTORY if the undo log has been
truncated and we cannot fetch the old version */
UNIV_INTERN
ulint
trx_undo_get_undo_rec(
/*==================*/
roll_ptr_t roll_ptr, /*!< in: roll pointer to record */
trx_id_t trx_id, /*!< in: id of the trx that generated
the roll pointer: it points to an
undo log of this transaction */
trx_undo_rec_t** undo_rec, /*!< out, own: copy of the record */
mem_heap_t* heap) /*!< in: memory heap where copied */
{
#ifdef UNIV_SYNC_DEBUG
ut_ad(rw_lock_own(&(purge_sys->latch), RW_LOCK_SHARED));
#endif /* UNIV_SYNC_DEBUG */
if (!trx_purge_update_undo_must_exist(trx_id)) {
/* It may be that the necessary undo log has already been
deleted */
return(DB_MISSING_HISTORY);
}
*undo_rec = trx_undo_get_undo_rec_low(roll_ptr, heap);
return(DB_SUCCESS);
}
/*******************************************************************//**
Build a previous version of a clustered index record. This function checks
that the caller has a latch on the index page of the clustered index record
and an s-latch on the purge_view. This guarantees that the stack of versions
is locked all the way down to the purge_view.
@return DB_SUCCESS, or DB_MISSING_HISTORY if the previous version is
earlier than purge_view, which means that it may have been removed,
DB_ERROR if corrupted record */
UNIV_INTERN
ulint
trx_undo_prev_version_build(
/*========================*/
const rec_t* index_rec,/*!< in: clustered index record in the
index tree */
mtr_t* index_mtr __attribute__((unused)),
/*!< in: mtr which contains the latch to
index_rec page and purge_view */
const rec_t* rec, /*!< in: version of a clustered index record */
dict_index_t* index, /*!< in: clustered index */
ulint* offsets,/*!< in: rec_get_offsets(rec, index) */
mem_heap_t* heap, /*!< in: memory heap from which the memory
needed is allocated */
rec_t** old_vers)/*!< out, own: previous version, or NULL if
rec is the first inserted version, or if
history data has been deleted (an error),
or if the purge COULD have removed the version
though it has not yet done so */
{
trx_undo_rec_t* undo_rec = NULL;
dtuple_t* entry;
trx_id_t rec_trx_id;
ulint type;
undo_no_t undo_no;
dulint table_id;
trx_id_t trx_id;
roll_ptr_t roll_ptr;
roll_ptr_t old_roll_ptr;
upd_t* update;
byte* ptr;
ulint info_bits;
ulint cmpl_info;
ibool dummy_extern;
byte* buf;
ulint err;
#ifdef UNIV_SYNC_DEBUG
ut_ad(rw_lock_own(&(purge_sys->latch), RW_LOCK_SHARED));
#endif /* UNIV_SYNC_DEBUG */
ut_ad(mtr_memo_contains_page(index_mtr, index_rec, MTR_MEMO_PAGE_S_FIX)
|| mtr_memo_contains_page(index_mtr, index_rec,
MTR_MEMO_PAGE_X_FIX));
ut_ad(rec_offs_validate(rec, index, offsets));
if (!dict_index_is_clust(index)) {
fprintf(stderr, "InnoDB: Error: trying to access"
" update undo rec for non-clustered index %s\n"
"InnoDB: Submit a detailed bug report to"
" http://bugs.mysql.com\n"
"InnoDB: index record ", index->name);
rec_print(stderr, index_rec, index);
fputs("\n"
"InnoDB: record version ", stderr);
rec_print_new(stderr, rec, offsets);
putc('\n', stderr);
return(DB_ERROR);
}
roll_ptr = row_get_rec_roll_ptr(rec, index, offsets);
old_roll_ptr = roll_ptr;
*old_vers = NULL;
if (trx_undo_roll_ptr_is_insert(roll_ptr)) {
/* The record rec is the first inserted version */
return(DB_SUCCESS);
}
rec_trx_id = row_get_rec_trx_id(rec, index, offsets);
err = trx_undo_get_undo_rec(roll_ptr, rec_trx_id, &undo_rec, heap);
if (UNIV_UNLIKELY(err != DB_SUCCESS)) {
/* The undo record may already have been purged.
This should never happen in InnoDB. */
return(err);
}
ptr = trx_undo_rec_get_pars(undo_rec, &type, &cmpl_info,
&dummy_extern, &undo_no, &table_id);
ptr = trx_undo_update_rec_get_sys_cols(ptr, &trx_id, &roll_ptr,
&info_bits);
/* (a) If a clustered index record version is such that the
trx id stamp in it is bigger than purge_sys->view, then the
BLOBs in that version are known to exist (the purge has not
progressed that far);
(b) if the version is the first version such that trx id in it
is less than purge_sys->view, and it is not delete-marked,
then the BLOBs in that version are known to exist (the purge
cannot have purged the BLOBs referenced by that version
yet).
This function does not fetch any BLOBs. The callers might, by
possibly invoking row_ext_create() via row_build(). However,
they should have all needed information in the *old_vers
returned by this function. This is because *old_vers is based
on the transaction undo log records. The function
trx_undo_page_fetch_ext() will write BLOB prefixes to the
transaction undo log that are at least as long as the longest
possible column prefix in a secondary index. Thus, secondary
index entries for *old_vers can be constructed without
dereferencing any BLOB pointers. */
ptr = trx_undo_rec_skip_row_ref(ptr, index);
ptr = trx_undo_update_rec_get_update(ptr, index, type, trx_id,
roll_ptr, info_bits,
NULL, heap, &update);
if (ut_dulint_cmp(table_id, index->table->id) != 0) {
ptr = NULL;
fprintf(stderr,
"InnoDB: Error: trying to access update undo rec"
" for table %s\n"
"InnoDB: but the table id in the"
" undo record is wrong\n"
"InnoDB: Submit a detailed bug report"
" to http://bugs.mysql.com\n"
"InnoDB: Run also CHECK TABLE %s\n",
index->table_name, index->table_name);
}
if (ptr == NULL) {
/* The record was corrupted, return an error; these printfs
should catch an elusive bug in row_vers_old_has_index_entry */
fprintf(stderr,
"InnoDB: table %s, index %s, n_uniq %lu\n"
"InnoDB: undo rec address %p, type %lu cmpl_info %lu\n"
"InnoDB: undo rec table id %lu %lu,"
" index table id %lu %lu\n"
"InnoDB: dump of 150 bytes in undo rec: ",
index->table_name, index->name,
(ulong) dict_index_get_n_unique(index),
undo_rec, (ulong) type, (ulong) cmpl_info,
(ulong) ut_dulint_get_high(table_id),
(ulong) ut_dulint_get_low(table_id),
(ulong) ut_dulint_get_high(index->table->id),
(ulong) ut_dulint_get_low(index->table->id));
ut_print_buf(stderr, undo_rec, 150);
fputs("\n"
"InnoDB: index record ", stderr);
rec_print(stderr, index_rec, index);
fputs("\n"
"InnoDB: record version ", stderr);
rec_print_new(stderr, rec, offsets);
fprintf(stderr, "\n"
"InnoDB: Record trx id " TRX_ID_FMT
", update rec trx id " TRX_ID_FMT "\n"
"InnoDB: Roll ptr in rec %lu %lu, in update rec"
" %lu %lu\n",
TRX_ID_PREP_PRINTF(rec_trx_id),
TRX_ID_PREP_PRINTF(trx_id),
(ulong) ut_dulint_get_high(old_roll_ptr),
(ulong) ut_dulint_get_low(old_roll_ptr),
(ulong) ut_dulint_get_high(roll_ptr),
(ulong) ut_dulint_get_low(roll_ptr));
trx_purge_sys_print();
return(DB_ERROR);
}
if (row_upd_changes_field_size_or_external(index, offsets, update)) {
ulint n_ext;
/* We have to set the appropriate extern storage bits in the
old version of the record: the extern bits in rec for those
fields that update does NOT update, as well as the bits for
those fields that update updates to become externally stored
fields. Store the info: */
entry = row_rec_to_index_entry(ROW_COPY_DATA, rec, index,
offsets, &n_ext, heap);
n_ext += btr_push_update_extern_fields(entry, update, heap);
/* The page containing the clustered index record
corresponding to entry is latched in mtr. Thus the
following call is safe. */
row_upd_index_replace_new_col_vals(entry, index, update, heap);
buf = mem_heap_alloc(heap, rec_get_converted_size(index, entry,
n_ext));
*old_vers = rec_convert_dtuple_to_rec(buf, index,
entry, n_ext);
} else {
buf = mem_heap_alloc(heap, rec_offs_size(offsets));
*old_vers = rec_copy(buf, rec, offsets);
rec_offs_make_valid(*old_vers, index, offsets);
row_upd_rec_in_place(*old_vers, index, offsets, update, NULL);
}
return(DB_SUCCESS);
}
#endif /* !UNIV_HOTBACKUP */