summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt3
-rw-r--r--COPYING1
-rw-r--r--COPYING.Google30
-rw-r--r--ChangeLog287
-rw-r--r--Makefile.am4
-rw-r--r--Makefile.in20
-rw-r--r--README2
-rw-r--r--btr/btr0btr.c137
-rw-r--r--btr/btr0cur.c165
-rw-r--r--btr/btr0pcur.c20
-rw-r--r--btr/btr0sea.c177
-rw-r--r--buf/buf0buddy.c22
-rw-r--r--buf/buf0buf.c298
-rw-r--r--buf/buf0flu.c305
-rw-r--r--buf/buf0lru.c69
-rw-r--r--buf/buf0rea.c20
-rwxr-xr-xcompile-innodb15
-rwxr-xr-xcompile-innodb-debug15
-rw-r--r--data/data0data.c34
-rw-r--r--data/data0type.c20
-rw-r--r--dict/dict0boot.c20
-rw-r--r--dict/dict0crea.c22
-rw-r--r--dict/dict0dict.c46
-rw-r--r--dict/dict0load.c28
-rw-r--r--dict/dict0mem.c23
-rw-r--r--dyn/dyn0dyn.c20
-rw-r--r--eval/eval0eval.c20
-rw-r--r--eval/eval0proc.c20
-rw-r--r--fil/fil0fil.c86
-rw-r--r--fsp/fsp0fsp.c28
-rw-r--r--fut/fut0fut.c20
-rw-r--r--fut/fut0lst.c20
-rw-r--r--ha/ha0ha.c56
-rw-r--r--ha/ha0storage.c21
-rw-r--r--ha/hash0hash.c24
-rw-r--r--handler/ha_innodb.cc602
-rw-r--r--handler/ha_innodb.h39
-rw-r--r--handler/handler0alter.cc30
-rw-r--r--handler/handler0vars.h21
-rw-r--r--handler/i_s.cc20
-rw-r--r--handler/i_s.h20
-rw-r--r--handler/innodb_patch_info.h18
-rw-r--r--handler/mysql_addons.cc46
-rw-r--r--handler/win_delay_loader.cc24
-rw-r--r--ibuf/ibuf0ibuf.c907
-rw-r--r--include/btr0btr.h21
-rw-r--r--include/btr0btr.ic20
-rw-r--r--include/btr0cur.h26
-rw-r--r--include/btr0cur.ic20
-rw-r--r--include/btr0pcur.h20
-rw-r--r--include/btr0pcur.ic20
-rw-r--r--include/btr0sea.h25
-rw-r--r--include/btr0sea.ic20
-rw-r--r--include/btr0types.h20
-rw-r--r--include/buf0buddy.h20
-rw-r--r--include/buf0buddy.ic23
-rw-r--r--include/buf0buf.h66
-rw-r--r--include/buf0buf.ic76
-rw-r--r--include/buf0flu.h27
-rw-r--r--include/buf0flu.ic33
-rw-r--r--include/buf0lru.h32
-rw-r--r--include/buf0lru.ic20
-rw-r--r--include/buf0rea.h20
-rw-r--r--include/buf0types.h20
-rw-r--r--include/data0data.h20
-rw-r--r--include/data0data.ic20
-rw-r--r--include/data0type.h20
-rw-r--r--include/data0type.ic20
-rw-r--r--include/data0types.h20
-rw-r--r--include/db0err.h20
-rw-r--r--include/dict0boot.h20
-rw-r--r--include/dict0boot.ic20
-rw-r--r--include/dict0crea.h20
-rw-r--r--include/dict0crea.ic20
-rw-r--r--include/dict0dict.h29
-rw-r--r--include/dict0dict.ic45
-rw-r--r--include/dict0load.h20
-rw-r--r--include/dict0load.ic20
-rw-r--r--include/dict0mem.h21
-rw-r--r--include/dict0mem.ic20
-rw-r--r--include/dict0types.h20
-rw-r--r--include/dyn0dyn.h20
-rw-r--r--include/dyn0dyn.ic20
-rw-r--r--include/eval0eval.h20
-rw-r--r--include/eval0eval.ic20
-rw-r--r--include/eval0proc.h20
-rw-r--r--include/eval0proc.ic20
-rw-r--r--include/fil0fil.h37
-rw-r--r--include/fsp0fsp.h20
-rw-r--r--include/fsp0fsp.ic20
-rw-r--r--include/fut0fut.h20
-rw-r--r--include/fut0fut.ic20
-rw-r--r--include/fut0lst.h20
-rw-r--r--include/fut0lst.ic20
-rw-r--r--include/ha0ha.h44
-rw-r--r--include/ha0ha.ic34
-rw-r--r--include/ha0storage.h20
-rw-r--r--include/ha0storage.ic20
-rw-r--r--include/ha_prototypes.h30
-rw-r--r--include/handler0alter.h20
-rw-r--r--include/hash0hash.h65
-rw-r--r--include/hash0hash.ic23
-rw-r--r--include/ibuf0ibuf.h73
-rw-r--r--include/ibuf0ibuf.ic72
-rw-r--r--include/ibuf0types.h21
-rw-r--r--include/lock0iter.h20
-rw-r--r--include/lock0lock.h20
-rw-r--r--include/lock0lock.ic20
-rw-r--r--include/lock0priv.h20
-rw-r--r--include/lock0priv.ic20
-rw-r--r--include/lock0types.h20
-rw-r--r--include/log0log.h26
-rw-r--r--include/log0log.ic20
-rw-r--r--include/log0recv.h37
-rw-r--r--include/log0recv.ic25
-rw-r--r--include/mach0data.h20
-rw-r--r--include/mach0data.ic20
-rw-r--r--include/mem0dbg.h20
-rw-r--r--include/mem0dbg.ic20
-rw-r--r--include/mem0mem.h20
-rw-r--r--include/mem0mem.ic20
-rw-r--r--include/mem0pool.h20
-rw-r--r--include/mem0pool.ic20
-rw-r--r--include/mtr0log.h20
-rw-r--r--include/mtr0log.ic24
-rw-r--r--include/mtr0mtr.h26
-rw-r--r--include/mtr0mtr.ic27
-rw-r--r--include/mtr0types.h20
-rw-r--r--include/mysql_addons.h51
-rw-r--r--include/os0file.h20
-rw-r--r--include/os0proc.h28
-rw-r--r--include/os0proc.ic20
-rw-r--r--include/os0sync.h45
-rw-r--r--include/os0sync.ic20
-rw-r--r--include/os0thread.h20
-rw-r--r--include/os0thread.ic20
-rw-r--r--include/page0cur.h20
-rw-r--r--include/page0cur.ic20
-rw-r--r--include/page0page.h20
-rw-r--r--include/page0page.ic20
-rw-r--r--include/page0types.h20
-rw-r--r--include/page0zip.h20
-rw-r--r--include/page0zip.ic23
-rw-r--r--include/pars0grm.h40
-rw-r--r--include/pars0opt.h20
-rw-r--r--include/pars0opt.ic20
-rw-r--r--include/pars0pars.h20
-rw-r--r--include/pars0pars.ic20
-rw-r--r--include/pars0sym.h20
-rw-r--r--include/pars0sym.ic20
-rw-r--r--include/pars0types.h20
-rw-r--r--include/que0que.h20
-rw-r--r--include/que0que.ic20
-rw-r--r--include/que0types.h20
-rw-r--r--include/read0read.h20
-rw-r--r--include/read0read.ic20
-rw-r--r--include/read0types.h20
-rw-r--r--include/rem0cmp.h20
-rw-r--r--include/rem0cmp.ic20
-rw-r--r--include/rem0rec.h31
-rw-r--r--include/rem0rec.ic39
-rw-r--r--include/rem0types.h20
-rw-r--r--include/row0ext.h20
-rw-r--r--include/row0ext.ic20
-rw-r--r--include/row0ins.h20
-rw-r--r--include/row0ins.ic20
-rw-r--r--include/row0merge.h20
-rw-r--r--include/row0mysql.h46
-rw-r--r--include/row0mysql.ic20
-rw-r--r--include/row0purge.h20
-rw-r--r--include/row0purge.ic20
-rw-r--r--include/row0row.h20
-rw-r--r--include/row0row.ic20
-rw-r--r--include/row0sel.h27
-rw-r--r--include/row0sel.ic20
-rw-r--r--include/row0types.h20
-rw-r--r--include/row0uins.h24
-rw-r--r--include/row0uins.ic20
-rw-r--r--include/row0umod.h20
-rw-r--r--include/row0umod.ic20
-rw-r--r--include/row0undo.h20
-rw-r--r--include/row0undo.ic20
-rw-r--r--include/row0upd.h35
-rw-r--r--include/row0upd.ic24
-rw-r--r--include/row0vers.h20
-rw-r--r--include/row0vers.ic20
-rw-r--r--include/srv0que.h21
-rw-r--r--include/srv0srv.h37
-rw-r--r--include/srv0srv.ic20
-rw-r--r--include/srv0start.h54
-rw-r--r--include/sync0arr.h20
-rw-r--r--include/sync0arr.ic20
-rw-r--r--include/sync0rw.h200
-rw-r--r--include/sync0rw.ic685
-rw-r--r--include/sync0sync.h43
-rw-r--r--include/sync0sync.ic76
-rw-r--r--include/sync0types.h21
-rw-r--r--include/thr0loc.h20
-rw-r--r--include/thr0loc.ic20
-rw-r--r--include/trx0i_s.h20
-rw-r--r--include/trx0purge.h20
-rw-r--r--include/trx0purge.ic20
-rw-r--r--include/trx0rec.h21
-rw-r--r--include/trx0rec.ic20
-rw-r--r--include/trx0roll.h34
-rw-r--r--include/trx0roll.ic20
-rw-r--r--include/trx0rseg.h20
-rw-r--r--include/trx0rseg.ic20
-rw-r--r--include/trx0sys.h20
-rw-r--r--include/trx0sys.ic21
-rw-r--r--include/trx0trx.h29
-rw-r--r--include/trx0trx.ic20
-rw-r--r--include/trx0types.h21
-rw-r--r--include/trx0undo.h20
-rw-r--r--include/trx0undo.ic20
-rw-r--r--include/trx0xa.h18
-rw-r--r--include/univ.i49
-rw-r--r--include/usr0sess.h20
-rw-r--r--include/usr0sess.ic20
-rw-r--r--include/usr0types.h20
-rw-r--r--include/ut0auxconf.h19
-rw-r--r--include/ut0byte.h20
-rw-r--r--include/ut0byte.ic20
-rw-r--r--include/ut0dbg.h24
-rw-r--r--include/ut0list.h19
-rw-r--r--include/ut0list.ic18
-rw-r--r--include/ut0lst.h20
-rw-r--r--include/ut0mem.h37
-rw-r--r--include/ut0mem.ic20
-rw-r--r--include/ut0rnd.h20
-rw-r--r--include/ut0rnd.ic20
-rw-r--r--include/ut0sort.h20
-rw-r--r--include/ut0ut.h22
-rw-r--r--include/ut0ut.ic20
-rw-r--r--include/ut0vec.h18
-rw-r--r--include/ut0vec.ic18
-rw-r--r--include/ut0wqueue.h19
-rw-r--r--lock/lock0iter.c27
-rw-r--r--lock/lock0lock.c35
-rw-r--r--log/log0log.c24
-rw-r--r--log/log0recv.c76
-rw-r--r--mach/mach0data.c20
-rw-r--r--mem/mem0dbg.c28
-rw-r--r--mem/mem0mem.c23
-rw-r--r--mem/mem0pool.c35
-rw-r--r--mtr/mtr0log.c20
-rw-r--r--mtr/mtr0mtr.c38
-rw-r--r--mysql-test/innodb-autoinc.result300
-rw-r--r--mysql-test/innodb-autoinc.test145
-rw-r--r--mysql-test/innodb-semi-consistent-master.opt2
-rw-r--r--mysql-test/innodb-semi-consistent.result5
-rw-r--r--mysql-test/innodb-semi-consistent.test7
-rw-r--r--mysql-test/innodb-use-sys-malloc-master.opt2
-rw-r--r--mysql-test/innodb-use-sys-malloc.result48
-rw-r--r--mysql-test/innodb-use-sys-malloc.test48
-rw-r--r--mysql-test/innodb-zip.result2
-rw-r--r--mysql-test/innodb-zip.test16
-rw-r--r--mysql-test/innodb.result2
-rw-r--r--mysql-test/innodb_bug34300.test4
-rw-r--r--mysql-test/innodb_bug36169.test7
-rw-r--r--mysql-test/innodb_bug41904.result4
-rw-r--r--mysql-test/innodb_bug41904.test14
-rw-r--r--mysql-test/innodb_xtradb_bug317074.result2
-rw-r--r--mysql-test/innodb_xtradb_bug317074.test38
-rw-r--r--mysql-test/patches/bug35261.diff85
-rw-r--r--mysql-test/patches/bug41893.diff87
-rw-r--r--mysql-test/patches/information_schema.diff137
-rw-r--r--mysql-test/patches/innodb_file_per_table.diff47
-rw-r--r--mysql-test/patches/innodb_lock_wait_timeout.diff55
-rw-r--r--mysql-test/patches/partition_innodb.diff59
-rw-r--r--os/os0file.c20
-rw-r--r--os/os0proc.c69
-rw-r--r--os/os0sync.c20
-rw-r--r--os/os0thread.c20
-rw-r--r--page/page0cur.c74
-rw-r--r--page/page0page.c20
-rw-r--r--page/page0zip.c20
-rw-r--r--pars/lexyy.c18
-rwxr-xr-xpars/make_bison.sh14
-rwxr-xr-xpars/make_flex.sh14
-rw-r--r--pars/pars0grm.c40
-rw-r--r--pars/pars0grm.y25
-rw-r--r--pars/pars0lex.l25
-rw-r--r--pars/pars0opt.c20
-rw-r--r--pars/pars0pars.c33
-rw-r--r--pars/pars0sym.c20
-rw-r--r--plug.in91
-rw-r--r--que/que0que.c20
-rw-r--r--read/read0read.c20
-rw-r--r--rem/rem0cmp.c20
-rw-r--r--rem/rem0rec.c31
-rw-r--r--row/row0ext.c20
-rw-r--r--row/row0ins.c20
-rw-r--r--row/row0merge.c51
-rw-r--r--row/row0mysql.c54
-rw-r--r--row/row0purge.c44
-rw-r--r--row/row0row.c20
-rw-r--r--row/row0sel.c155
-rw-r--r--row/row0uins.c24
-rw-r--r--row/row0umod.c30
-rw-r--r--row/row0undo.c20
-rw-r--r--row/row0upd.c84
-rw-r--r--row/row0vers.c124
-rwxr-xr-xsetup.sh24
-rw-r--r--srv/srv0que.c20
-rw-r--r--srv/srv0srv.c65
-rw-r--r--srv/srv0start.c128
-rw-r--r--sync/sync0arr.c142
-rw-r--r--sync/sync0rw.c714
-rw-r--r--sync/sync0sync.c92
-rw-r--r--thr/thr0loc.c24
-rw-r--r--trx/trx0i_s.c28
-rw-r--r--trx/trx0purge.c20
-rw-r--r--trx/trx0rec.c20
-rw-r--r--trx/trx0roll.c71
-rw-r--r--trx/trx0rseg.c20
-rw-r--r--trx/trx0sys.c20
-rw-r--r--trx/trx0trx.c52
-rw-r--r--trx/trx0undo.c22
-rw-r--r--usr/usr0sess.c20
-rw-r--r--ut/ut0auxconf.c13
-rw-r--r--ut/ut0byte.c20
-rw-r--r--ut/ut0dbg.c20
-rw-r--r--ut/ut0list.c18
-rw-r--r--ut/ut0mem.c75
-rw-r--r--ut/ut0rnd.c20
-rw-r--r--ut/ut0ut.c22
-rw-r--r--ut/ut0vec.c18
-rw-r--r--ut/ut0wqueue.c18
-rw-r--r--win-plugin/win-plugin.diff12
330 files changed, 9913 insertions, 3857 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1fcc92212bb..61f0fec9a3f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,7 +15,7 @@
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
-ADD_DEFINITIONS(-DMYSQL_SERVER -D_WIN32 -D_LIB)
+ADD_DEFINITIONS(-D_WIN32 -D_LIB)
# Bug 19424 - InnoDB: Possibly a memory overrun of the buffer being freed (64-bit Visual C)
# Removing Win64 compiler optimizations for all innodb/mem/* files.
@@ -69,6 +69,7 @@ SET(INNOBASE_SOURCES btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c btr/btr0sea.c
IF(NOT SOURCE_SUBLIBS)
ADD_LIBRARY(innobase ${INNOBASE_SOURCES})
ADD_DEPENDENCIES(innobase GenError)
+ SET_TARGET_PROPERTIES(innobase PROPERTIES COMPILE_FLAGS "-DMYSQL_SERVER")
IF(INNODB_DYNAMIC_PLUGIN)
# The dynamic plugin requires CMake 2.6.0 or later. Otherwise, the /DELAYLOAD property
diff --git a/COPYING b/COPYING
index 2cf699059db..6b106e18fdb 100644
--- a/COPYING
+++ b/COPYING
@@ -349,4 +349,3 @@ into proprietary programs. If your program is a subroutine library,
you may consider it more useful to permit linking proprietary
applications with the library. If this is what you want to do, use the
GNU Library General Public License instead of this License.
-
diff --git a/COPYING.Google b/COPYING.Google
new file mode 100644
index 00000000000..5ade2b0e381
--- /dev/null
+++ b/COPYING.Google
@@ -0,0 +1,30 @@
+Portions of this software contain modifications contributed by Google, Inc.
+These contributions are used with the following license:
+
+Copyright (c) 2008, Google Inc. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials
+ provided with the distribution.
+ * Neither the name of the Google Inc. nor the names of its
+ contributors may be used to endorse or promote products
+ derived from this software without specific prior written
+ permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/ChangeLog b/ChangeLog
index 0a4b01ef406..f662b02eea5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,290 @@
+2009-03-05 The InnoDB Team
+
+ * handler/ha_innodb.cc, mysql-test/innodb-autoinc.result,
+ mysql-test/innodb-autoinc.test:
+ Fix Bug#43203 Overflow from auto incrementing causes server segv
+
+2009-02-25 The InnoDB Team
+
+ * handler/ha_innodb.cc, mysql-test/innodb-autoinc.result,
+ mysql-test/innodb-autoinc.test:
+ Fix Bug#42714 AUTO_INCREMENT errors in 5.1.31
+
+2009-02-23 The InnoDB Team
+
+ * btr/btr0cur.c:
+ Fix Bug#43043 Crash on BLOB delete operation
+
+2009-02-20 The InnoDB Team
+
+ * handler/ha_innodb.cc:
+ Make innodb_use_sys_malloc=ON the default.
+
+2009-02-20 The InnoDB Team
+
+ * handler/ha_innodb.cc, mysql-test/innodb-autoinc.result,
+ mysql-test/innodb-autoinc.test:
+ Fix Bug#42400 InnoDB autoinc code can't handle floating-point columns
+
+2009-02-18 The InnoDB Team
+
+ * include/ut0mem.h, os/os0proc.c, ut/ut0mem.c:
+ Protect ut_total_allocated_memory with ut_list_mutex in
+ os_mem_alloc_large() and os_mem_free_large(). The lack of this mutex
+ protection could cause an assertion failure during fast index
+ creation. Also, add UNIV_MEM_ALLOC and UNIV_MEM_FREE instrumentation
+ to os_mem_alloc_large() and os_mem_free_large(), so that Valgrind can
+ detect more errors.
+
+2009-02-11 The InnoDB Team
+
+ * handler/ha_innodb.cc:
+ Make innodb_thread_concurrency=0 the default. The old default value
+ was 8. A non-zero setting may be useful when InnoDB is showing severe
+ scalability problems under multiple concurrent connections.
+
+2009-02-10 The InnoDB Team
+
+ * handler/ha_innodb.cc, handler/ha_innodb.h:
+ Fix Bug#41676 Table names are case insensitive in locking
+
+2009-02-10 The InnoDB Team
+
+ * mem/mem0dbg.c, mem/mem0mem.c, mem/mem0pool.c:
+ When innodb_use_sys_malloc is set, ignore
+ innodb_additional_mem_pool_size, because nothing will be allocated
+ from mem_comm_pool.
+
+2009-02-10 The InnoDB Team
+
+ * ut/ut0mem.c:
+ Map ut_malloc_low(), ut_realloc(), and ut_free() directly to malloc(),
+ realloc(), and free() when innodb_use_sys_malloc is set. As a side
+ effect, ut_total_allocated_memory ("Total memory allocated" in the
+ "BUFFER POOL AND MEMORY" section of SHOW ENGINE INNODB STATUS) will
+ exclude any memory allocated by these functions when
+ innodb_use_sys_malloc is set.
+
+2009-02-10 The InnoDB Team
+
+ * btr/btr0cur.c, btr/btr0sea.c, buf/buf0buf.c, handler/ha_innodb.cc,
+ include/buf0buf.ic, include/os0sync.h, include/srv0srv.h,
+ include/sync0rw.h, include/sync0rw.ic, include/sync0sync.h,
+ include/sync0sync.ic, include/univ.i, row/row0sel.c, srv/srv0srv.c,
+ srv/srv0start.c, sync/sync0arr.c, sync/sync0rw.c, sync/sync0sync.c:
+ On those platforms that support it, implement the synchronization
+ primitives of InnoDB mutexes and read/write locks with GCC atomic
+ builtins instead of Pthreads mutexes and InnoDB mutexes. These changes
+ are based on a patch supplied by Mark Callaghan of Google under a BSD
+ license.
+
+2009-01-30 The InnoDB Team
+
+ * btr/btr0cur.c, btr/btr0sea.c, buf/buf0buf.c, handler/ha_innodb.cc,
+ include/btr0sea.h, include/buf0buf.h, include/sync0sync.h,
+ sync/sync0sync.c:
+ Make the configuration parameter innodb_adaptive_hash_index dynamic,
+ so that it can be changed at runtime.
+
+2009-01-29 The InnoDB Team
+
+ * handler/ha_innodb.cc, ibuf/ibuf0ibuf.c, include/ibuf0ibuf.h,
+ include/ibuf0ibuf.ic:
+ Implement the settable global variable innodb_change_buffering,
+ with the allowed values 'none' and 'inserts'. The default value
+ 'inserts' enables the buffering of inserts to non-unique secondary
+ index trees when the B-tree leaf page is not in the buffer pool.
+
+2009-01-27 The InnoDB Team
+
+ * buf/buf0lru.c:
+ Fix a race condition in buf_LRU_invalidate_tablespace(): The
+ compressed page size (zip_size) was read while the block descriptor
+ was no longer protected by a mutex. This could lead to corruption
+ when a table is dropped on a busy system that contains compressed
+ tables.
+
+2009-01-26 The InnoDB Team
+
+ * btr/btr0sea.c, buf/buf0buf.c, include/buf0buf.h, include/buf0buf.ic,
+ include/mtr0log.ic, include/row0upd.ic, mtr/mtr0mtr.c:
+ Implement buf_block_align() with pointer arithmetics, as it is in the
+ built-in InnoDB distributed with MySQL. Do not acquire the buffer pool
+ mutex before buf_block_align(). This removes a scalability bottleneck
+ in the adaptive hash index lookup. In CHECK TABLE, check that
+ buf_pool->page_hash is consistent with buf_block_align().
+
+2009-01-23 The InnoDB Team
+
+ * btr/btr0sea.c:
+ Fix Bug#42279 Race condition in btr_search_drop_page_hash_when_freed()
+
+2009-01-23 The InnoDB Team
+
+ * buf/buf0buf.c, include/buf0buf.h:
+ Remove the unused mode BUF_GET_NOWAIT of buf_page_get_gen()
+
+2009-01-20 The InnoDB Team
+
+ * include/rem0rec.h, include/rem0rec.ic:
+ Fix Bug#41571 MySQL segfaults after innodb recovery
+
+2009-01-20 The InnoDB Team
+
+ * lock/lock0lock.c:
+ Fix Bug#42152 Race condition in lock_is_table_exclusive()
+
+2009-01-14 The InnoDB Team
+
+ * include/trx0roll.h, trx/trx0roll.c, trx/trx0trx.c:
+ Fix Bug#38187 Error 153 when creating savepoints
+
+2009-01-14 The InnoDB Team
+
+ * dict/dict0load.c:
+ Fix Bug#42075 dict_load_indexes failure in dict_load_table will
+ corrupt the dictionary cache
+
+2009-01-13 The InnoDB Team
+
+ * buf/buf0buddy.c, dict/dict0dict.c, dict/dict0mem.c, fil/fil0fil.c,
+ ha/ha0storage.c, handler/ha_innodb.cc, handler/win_delay_loader.cc,
+ include/buf0buf.ic, include/dict0dict.ic, include/hash0hash.h,
+ thr/thr0loc.c, trx/trx0i_s.c:
+ Add the parameter ASSERTION to HASH_SEARCH() macro, and use it for
+ light validation of the traversed items in hash table lookups when
+ UNIV_DEBUG is enabled.
+
+2009-01-09 The InnoDB Team
+
+ * buf/buf0flu.c, include/buf0flu.h, include/buf0flu.ic:
+ Remove unused code from the functions
+ buf_flush_insert_into_flush_list() and
+ buf_flush_insert_sorted_into_flush_list().
+
+2009-01-09 The InnoDB Team
+
+ * buf/buf0flu.c:
+ Simplify the functions buf_flush_try_page() and buf_flush_batch(). Add
+ debug assertions and an explanation to buf_flush_write_block_low().
+
+2009-01-07 The InnoDB Team
+
+ * row/row0merge.c:
+ Fix a bug in recovery when dropping temporary indexes.
+
+2009-01-07 The InnoDB Team
+
+ * handler/ha_innodb.cc, handler/ha_innodb.h, handler/handler0alter.cc:
+ Fix Bug#41680 calls to trx_allocate_for_mysql are not consistent
+
+2009-01-07 The InnoDB Team
+
+ * mysql-test/innodb_bug41904.result, mysql-test/innodb_bug41904.test,
+ row/row0merge.c:
+ Fix Bug#41904 create unique index problem
+
+2009-01-02 The InnoDB Team
+
+ * handler/ha_innodb.cc, include/srv0srv.h, mem/mem0pool.c,
+ mysql-test/innodb-use-sys-malloc-master.opt,
+ mysql-test/innodb-use-sys-malloc.result,
+ mysql-test/innodb-use-sys-malloc.test, srv/srv0srv.c, srv/srv0start.c:
+ Implement the configuration parameter innodb_use_sys_malloc (false by
+ default), for disabling InnoDB's internal memory allocator and using
+ system malloc/free instead. The "BUFFER POOL AND MEMORY" section of
+ SHOW ENGINE INNODB STATUS will report "in additional pool allocated
+ allocated 0" when innodb_use_sys_malloc is set.
+
+2008-12-30 The InnoDB Team
+
+ * btr/btr0btr.c:
+ When setting the PAGE_LEVEL of a compressed B-tree page from or to 0,
+ compress the page at the same time. This is necessary, because the
+ column information stored on the compressed page will differ between
+ leaf and non-leaf pages. Leaf pages are identified by PAGE_LEVEL=0.
+ This bug can make InnoDB crash when all rows of a compressed table are
+ deleted.
+
+2008-12-17 The InnoDB Team
+
+ * include/row0sel.h, include/row0upd.h, pars/pars0pars.c,
+ row/row0mysql.c, row/row0sel.c, row/row0upd.c:
+ Remove update-in-place select from the internal SQL interpreter. It
+ was only used for updating the InnoDB internal data dictionary when
+ renaming or dropping tables. It could have caused deadlocks when
+ acquiring latches on insert buffer bitmap pages.
+
+2008-12-17 The InnoDB Team
+
+ * btr/btr0sea.c, buf/buf0buf.c, buf/buf0lru.c, ha/ha0ha.c,
+ ha/hash0hash.c, include/buf0buf.h, include/ha0ha.h, include/ha0ha.ic,
+ include/hash0hash.h, include/univ.i:
+ Introduce the preprocessor symbol UNIV_AHI_DEBUG for enabling adaptive
+ hash index debugging independently of UNIV_DEBUG.
+
+2008-12-16 The InnoDB Team
+
+ * btr/btr0cur.c:
+ Do not update the free bits in the insert buffer bitmap when inserting
+ or deleting from the insert buffer B-tree. Assert that records in the
+ insert buffer B-tree are never updated.
+
+2008-12-12 The InnoDB Team
+
+ * buf/buf0buf.c, fil/fil0fil.c, fsp/fsp0fsp.c, ibuf/ibuf0ibuf.c,
+ include/fil0fil.h, include/ibuf0ibuf.h, include/ibuf0ibuf.ic,
+ include/ibuf0types.h:
+ Clean up the insert buffer subsystem so that only one insert
+ buffer B-tree exists.
+ Originally, there were provisions in InnoDB for multiple insert
+ buffer B-trees, apparently one for each tablespace.
+ When Heikki Tuuri implemented multiple InnoDB tablespaces in
+ MySQL/InnoDB 4.1, he made the insert buffer live only in the
+ system tablespace (space 0) but left the provisions in the code.
+
+2008-12-11 The InnoDB Team
+
+ * include/srv0srv.h, os/os0proc.c, srv/srv0srv.c:
+ Fix the issue that the InnoDB plugin fails if innodb_buffer_pool_size
+ is defined bigger than 4096M on 64-bit Windows. This bug should not
+ have affected other 64-bit systems.
+
+2008-12-09 The InnoDB Team
+
+ * handler/ha_innodb.cc:
+ Fix Bug#40386 Not flushing query cache after truncate.
+
+2008-12-09 The InnoDB Team
+
+ * handler/ha_innodb.cc, srv/srv0srv.c, trx/trx0trx.c:
+ Fix Bug#40760 "set global innodb_thread_concurrency = 0;" is not safe
+
+2008-12-04 The InnoDB Team
+
+ * handler/ha_innodb.cc, handler/mysql_addons.cc,
+ include/mysql_addons.h, trx/trx0i_s.c, win-plugin/win-plugin.diff:
+ Remove dependencies to MySQL internals (defining MYSQL_SERVER).
+
+2008-12-02 The InnoDB Team
+
+ * page/page0cur.c:
+ When allocating space for a record from the free list of previously
+ purged records, zero out the DB_TRX_ID and DB_ROLL_PTR of the purged
+ record if the new record would not overwrite these fields. This fixes
+ a harmless content mismatch reported by page_zip_validate().
+
+2008-12-02 The InnoDB Team
+
+ * row/row0merge.c:
+ Replace the WHILE 1 with WHILE 1=1 in the SQL procedure, so that the
+ loop will actually be entered and temporary indexes be dropped during
+ crash recovery.
+
+2008-12-01 The InnoDB Team
+
+ InnoDB Plugin 1.0.2 released
+
2008-10-31 The InnoDB Team
* dict/dict0mem.c, include/dict0mem.h, include/lock0lock.h,
diff --git a/Makefile.am b/Makefile.am
index 93086d41262..45efa967e34 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -183,8 +183,8 @@ EXTRA_LTLIBRARIES= ha_innodb.la
pkgplugin_LTLIBRARIES= @plugin_innobase_shared_target@
ha_innodb_la_LDFLAGS= -module -rpath $(pkgplugindir)
-ha_innodb_la_CXXFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
-ha_innodb_la_CFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
+ha_innodb_la_CXXFLAGS= $(AM_CFLAGS) $(INNODB_DYNAMIC_CFLAGS)
+ha_innodb_la_CFLAGS= $(AM_CFLAGS) $(INNODB_DYNAMIC_CFLAGS)
ha_innodb_la_SOURCES= $(libinnobase_a_SOURCES)
EXTRA_DIST= CMakeLists.txt plug.in \
diff --git a/Makefile.in b/Makefile.in
index 31bed1810b9..ec0330a78ce 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# Makefile.in generated by automake 1.10.2 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -310,6 +310,7 @@ GETCONF = @GETCONF@
GREP = @GREP@
GXX = @GXX@
HOSTNAME = @HOSTNAME@
+INNODB_DYNAMIC_CFLAGS = @INNODB_DYNAMIC_CFLAGS@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -449,7 +450,6 @@ host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
-innodb_system_libs = @innodb_system_libs@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
@@ -701,13 +701,19 @@ libinnobase_a_CFLAGS = $(AM_CFLAGS)
EXTRA_LTLIBRARIES = ha_innodb.la
pkgplugin_LTLIBRARIES = @plugin_innobase_shared_target@
ha_innodb_la_LDFLAGS = -module -rpath $(pkgplugindir)
-ha_innodb_la_CXXFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
-ha_innodb_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
+ha_innodb_la_CXXFLAGS = $(AM_CFLAGS) $(INNODB_DYNAMIC_CFLAGS)
+ha_innodb_la_CFLAGS = $(AM_CFLAGS) $(INNODB_DYNAMIC_CFLAGS)
ha_innodb_la_SOURCES = $(libinnobase_a_SOURCES)
EXTRA_DIST = CMakeLists.txt plug.in \
pars/make_bison.sh pars/make_flex.sh \
pars/pars0grm.y pars/pars0lex.l
+check_have_atomic_pthread_t:
+ if $(COMPILE) ut/ut0auxconf.c -o /dev/null ; then \
+ echo '#define HAVE_ATOMIC_PTHREAD_T' > include/ut0auxconf.h ; \
+ fi
+
+# This is temprary fix for http://bugs.mysql.com/43740
all: all-am
.SUFFIXES:
@@ -716,8 +722,8 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
- && exit 0; \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
@@ -2954,7 +2960,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
- $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
mkid -fID $$unique
tags: TAGS
diff --git a/README b/README
index 9ff536c083a..16d9eb6e258 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-This is the source of the InnoDB Plugin 1.0.2 for MySQL 5.1
+This is the source of the InnoDB Plugin 1.0.3 for MySQL 5.1
===========================================================
Instructions for compiling the plugin:
diff --git a/btr/btr0btr.c b/btr/btr0btr.c
index 423146ba71f..2029a95cc19 100644
--- a/btr/btr0btr.c
+++ b/btr/btr0btr.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/******************************************************
The B-tree
-(c) 1994-1996 Innobase Oy
-
Created 6/2/1994 Heikki Tuuri
*******************************************************/
@@ -263,7 +279,7 @@ btr_get_next_user_rec(
/******************************************************************
Creates a new index page (not the root, and also not
-used in page reorganization). */
+used in page reorganization). @see btr_page_empty(). */
static
void
btr_page_create(
@@ -1065,19 +1081,21 @@ btr_parse_page_reorganize(
}
/*****************************************************************
-Empties an index page. */
+Empties an index page. @see btr_page_create().*/
static
void
btr_page_empty(
/*===========*/
buf_block_t* block, /* in: page to be emptied */
page_zip_des_t* page_zip,/* out: compressed page, or NULL */
- mtr_t* mtr, /* in: mtr */
- dict_index_t* index) /* in: index of the page */
+ dict_index_t* index, /* in: index of the page */
+ ulint level, /* in: the B-tree level of the page */
+ mtr_t* mtr) /* in: mtr */
{
page_t* page = buf_block_get_frame(block);
ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
+ ut_ad(page_zip == buf_block_get_page_zip(block));
#ifdef UNIV_ZIP_DEBUG
ut_a(!page_zip || page_zip_validate(page_zip, page));
#endif /* UNIV_ZIP_DEBUG */
@@ -1088,10 +1106,10 @@ btr_page_empty(
segment headers, next page-field, etc.) is preserved intact */
if (UNIV_LIKELY_NULL(page_zip)) {
- page_create_zip(block, index,
- btr_page_get_level(page, mtr), mtr);
+ page_create_zip(block, index, level, mtr);
} else {
page_create(block, mtr, dict_table_is_comp(index->table));
+ btr_page_set_level(page, NULL, level, mtr);
}
block->check_index_page_at_flush = TRUE;
@@ -1153,7 +1171,6 @@ btr_root_raise_and_insert(
ut_ad(mtr_memo_contains(mtr, dict_index_get_lock(index),
MTR_MEMO_X_LOCK));
ut_ad(mtr_memo_contains(mtr, root_block, MTR_MEMO_PAGE_X_FIX));
- btr_search_drop_page_hash_index(root_block);
/* Allocate a new page to the tree. Root splitting is done by first
moving the root records to the new page, emptying the root, putting
@@ -1226,12 +1243,7 @@ btr_root_raise_and_insert(
| REC_INFO_MIN_REC_FLAG);
/* Rebuild the root page to get free space */
- if (UNIV_LIKELY_NULL(root_page_zip)) {
- page_create_zip(root_block, index, level + 1, mtr);
- } else {
- page_create(root_block, mtr, dict_table_is_comp(index->table));
- btr_page_set_level(root, NULL, level + 1, mtr);
- }
+ btr_page_empty(root_block, root_page_zip, index, level + 1, mtr);
/* Set the next node and previous node fields, although
they should already have been set. The previous node field
@@ -1241,8 +1253,6 @@ btr_root_raise_and_insert(
btr_page_set_next(root, root_page_zip, FIL_NULL, mtr);
btr_page_set_prev(root, root_page_zip, FIL_NULL, mtr);
- root_block->check_index_page_at_flush = TRUE;
-
page_cursor = btr_cur_get_page_cur(cursor);
/* Insert node pointer to the root */
@@ -1700,6 +1710,8 @@ btr_attach_half_pages(
/* Get the level of the split pages */
level = btr_page_get_level(buf_block_get_frame(block), mtr);
+ ut_ad(level
+ == btr_page_get_level(buf_block_get_frame(new_block), mtr));
/* Build the node pointer (= node key and page address) for the upper
half */
@@ -1756,11 +1768,9 @@ btr_attach_half_pages(
btr_page_set_prev(lower_page, lower_page_zip, prev_page_no, mtr);
btr_page_set_next(lower_page, lower_page_zip, upper_page_no, mtr);
- btr_page_set_level(lower_page, lower_page_zip, level, mtr);
btr_page_set_prev(upper_page, upper_page_zip, lower_page_no, mtr);
btr_page_set_next(upper_page, upper_page_zip, next_page_no, mtr);
- btr_page_set_level(upper_page, upper_page_zip, level, mtr);
}
/*****************************************************************
@@ -2364,11 +2374,7 @@ btr_lift_page_up(
btr_search_drop_page_hash_index(block);
/* Make the father empty */
- btr_page_empty(father_block, father_page_zip, mtr, index);
- /* Set the level before inserting records, because
- page_zip_compress() requires that the first user record
- on a non-leaf page has the min_rec_mark set. */
- btr_page_set_level(father_page, father_page_zip, page_level, mtr);
+ btr_page_empty(father_block, father_page_zip, index, page_level, mtr);
/* Copy the records to the father page one by one. */
if (0
@@ -2415,7 +2421,7 @@ btr_lift_page_up(
/* Free the file page */
btr_page_free(index, block, mtr);
- /* We play safe and reset the free bits for the father */
+ /* We play it safe and reset the free bits for the father */
if (!dict_index_is_clust(index)) {
ibuf_reset_free_bits(father_block);
}
@@ -2716,7 +2722,10 @@ err_exit:
}
/*****************************************************************
-Discards a page that is the only page on its level. */
+Discards a page that is the only page on its level. This will empty
+the whole B-tree, leaving just an empty root page. This function
+should never be reached, because btr_compress(), which is invoked in
+delete operations, calls btr_lift_page_up() to flatten the B-tree. */
static
void
btr_discard_only_page_on_level(
@@ -2725,60 +2734,52 @@ btr_discard_only_page_on_level(
buf_block_t* block, /* in: page which is the only on its level */
mtr_t* mtr) /* in: mtr */
{
- btr_cur_t father_cursor;
- buf_block_t* father_block;
- page_t* father_page;
- page_zip_des_t* father_page_zip;
- page_t* page = buf_block_get_frame(block);
- ulint page_level;
+ ulint page_level = 0;
- ut_ad(btr_page_get_prev(page, mtr) == FIL_NULL);
- ut_ad(btr_page_get_next(page, mtr) == FIL_NULL);
- ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
- btr_search_drop_page_hash_index(block);
+ while (buf_block_get_page_no(block) != dict_index_get_page(index)) {
+ btr_cur_t cursor;
+ buf_block_t* father;
+ const page_t* page = buf_block_get_frame(block);
- btr_page_get_father(index, block, mtr, &father_cursor);
- father_block = btr_cur_get_block(&father_cursor);
- father_page_zip = buf_block_get_page_zip(father_block);
- father_page = buf_block_get_frame(father_block);
+ ut_a(page_get_n_recs(page) == 1);
+ ut_a(page_level == btr_page_get_level(page, mtr));
+ ut_a(btr_page_get_prev(page, mtr) == FIL_NULL);
+ ut_a(btr_page_get_next(page, mtr) == FIL_NULL);
- page_level = btr_page_get_level(page, mtr);
+ ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
+ btr_search_drop_page_hash_index(block);
- lock_update_discard(father_block, PAGE_HEAP_NO_SUPREMUM, block);
+ btr_page_get_father(index, block, mtr, &cursor);
+ father = btr_cur_get_block(&cursor);
- btr_page_set_level(father_page, father_page_zip, page_level, mtr);
+ lock_update_discard(father, PAGE_HEAP_NO_SUPREMUM, block);
- /* Free the file page */
- btr_page_free(index, block, mtr);
+ /* Free the file page */
+ btr_page_free(index, block, mtr);
- if (UNIV_LIKELY(buf_block_get_page_no(father_block)
- == dict_index_get_page(index))) {
- /* The father is the root page */
+ block = father;
+ page_level++;
+ }
+
+ /* block is the root page, which must be empty, except
+ for the node pointer to the (now discarded) block(s). */
#ifdef UNIV_BTR_DEBUG
- if (!dict_index_is_ibuf(index)) {
- const page_t* root
- = buf_block_get_frame(father_block);
- const ulint space
- = dict_index_get_space(index);
- ut_a(btr_root_fseg_validate(
- FIL_PAGE_DATA + PAGE_BTR_SEG_LEAF
- + root, space));
- ut_a(btr_root_fseg_validate(
- FIL_PAGE_DATA + PAGE_BTR_SEG_TOP
- + root, space));
- }
+ if (!dict_index_is_ibuf(index)) {
+ const page_t* root = buf_block_get_frame(block);
+ const ulint space = dict_index_get_space(index);
+ ut_a(btr_root_fseg_validate(FIL_PAGE_DATA + PAGE_BTR_SEG_LEAF
+ + root, space));
+ ut_a(btr_root_fseg_validate(FIL_PAGE_DATA + PAGE_BTR_SEG_TOP
+ + root, space));
+ }
#endif /* UNIV_BTR_DEBUG */
- btr_page_empty(father_block, father_page_zip, mtr, index);
- /* We play safe and reset the free bits for the father */
- if (!dict_index_is_clust(index)) {
- ibuf_reset_free_bits(father_block);
- }
- } else {
- ut_ad(page_get_n_recs(father_page) == 1);
+ btr_page_empty(block, buf_block_get_page_zip(block), index, 0, mtr);
- btr_discard_only_page_on_level(index, father_block, mtr);
+ /* We play it safe and reset the free bits for the root */
+ if (!dict_index_is_clust(index)) {
+ ibuf_reset_free_bits(block);
}
}
diff --git a/btr/btr0cur.c b/btr/btr0cur.c
index 0981344f90c..3d6c3d90bda 100644
--- a/btr/btr0cur.c
+++ b/btr/btr0cur.c
@@ -1,3 +1,28 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 2008, Google Inc.
+
+Portions of this file contain modifications contributed and copyrighted by
+Google, Inc. Those modifications are gratefully acknowledged and are described
+briefly in the InnoDB documentation. The contributions by Google are
+incorporated with their permission, and subject to the conditions contained in
+the file COPYING.Google.
+
+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
+
+*****************************************************************************/
+
/******************************************************
The index tree cursor
@@ -12,8 +37,6 @@ many pages in the tablespace before we start the operation, because
if leaf splitting has been started, it is difficult to undo, except
by crashing the database and doing a roll-forward.
-(c) 1994-2001 Innobase Oy
-
Created 10/16/1994 Heikki Tuuri
*******************************************************/
@@ -318,10 +341,8 @@ btr_cur_search_to_nth_level(
ulint low_bytes;
ulint height;
ulint savepoint;
- ulint rw_latch;
ulint page_mode;
ulint insert_planned;
- ulint buf_mode;
ulint estimate;
ulint ignore_sec_unique;
ulint root_height = 0; /* remove warning */
@@ -367,13 +388,16 @@ btr_cur_search_to_nth_level(
#ifdef UNIV_SEARCH_PERF_STAT
info->n_searches++;
#endif
- if (btr_search_latch.writer == RW_LOCK_NOT_LOCKED
+ if (rw_lock_get_writer(&btr_search_latch) == RW_LOCK_NOT_LOCKED
&& latch_mode <= BTR_MODIFY_LEAF && info->last_hash_succ
&& !estimate
#ifdef PAGE_CUR_LE_OR_EXTENDS
&& mode != PAGE_CUR_LE_OR_EXTENDS
#endif /* PAGE_CUR_LE_OR_EXTENDS */
- && !UNIV_UNLIKELY(btr_search_disabled)
+ /* If !has_search_latch, we do a dirty read of
+ btr_search_enabled below, and btr_search_guess_on_hash()
+ will have to check it again. */
+ && UNIV_LIKELY(btr_search_enabled)
&& btr_search_guess_on_hash(index, info, tuple, mode,
latch_mode, cursor,
has_search_latch, mtr)) {
@@ -429,8 +453,6 @@ btr_cur_search_to_nth_level(
low_bytes = 0;
height = ULINT_UNDEFINED;
- rw_latch = RW_NO_LATCH;
- buf_mode = BUF_GET;
/* We use these modified search modes on non-leaf levels of the
B-tree. These let us end up in the right B-tree leaf. In that leaf
@@ -459,9 +481,28 @@ btr_cur_search_to_nth_level(
for (;;) {
ulint zip_size;
buf_block_t* block;
-retry_page_get:
+ ulint rw_latch;
+ ulint buf_mode;
+
zip_size = dict_table_zip_size(index->table);
+ rw_latch = RW_NO_LATCH;
+ buf_mode = BUF_GET;
+
+ if (height == 0 && latch_mode <= BTR_MODIFY_LEAF) {
+
+ rw_latch = latch_mode;
+ if (insert_planned
+ && ibuf_should_try(index, ignore_sec_unique)) {
+
+ /* Try insert to the insert buffer if the
+ page is not in the buffer pool */
+
+ buf_mode = BUF_GET_IF_IN_POOL;
+ }
+ }
+
+retry_page_get:
block = buf_page_get_gen(space, zip_size, page_no,
rw_latch, guess, buf_mode,
__FILE__, __LINE__, mtr);
@@ -473,9 +514,8 @@ retry_page_get:
ut_ad(insert_planned);
ut_ad(cursor->thr);
- if (ibuf_should_try(index, ignore_sec_unique)
- && ibuf_insert(tuple, index, space, zip_size,
- page_no, cursor->thr)) {
+ if (ibuf_insert(tuple, index, space, zip_size,
+ page_no, cursor->thr)) {
/* Insertion to the insert buffer succeeded */
cursor->flag = BTR_CUR_INSERT_TO_IBUF;
if (UNIV_LIKELY_NULL(heap)) {
@@ -493,17 +533,16 @@ retry_page_get:
}
page = buf_block_get_frame(block);
-#ifdef UNIV_ZIP_DEBUG
+
+ block->check_index_page_at_flush = TRUE;
+
if (rw_latch != RW_NO_LATCH) {
+#ifdef UNIV_ZIP_DEBUG
const page_zip_des_t* page_zip
= buf_block_get_page_zip(block);
ut_a(!page_zip || page_zip_validate(page_zip, page));
- }
#endif /* UNIV_ZIP_DEBUG */
- block->check_index_page_at_flush = TRUE;
-
- if (rw_latch != RW_NO_LATCH) {
buf_block_dbg_add_level(block, SYNC_TREE_NODE);
}
@@ -575,20 +614,6 @@ retry_page_get:
height--;
- if ((height == 0) && (latch_mode <= BTR_MODIFY_LEAF)) {
-
- rw_latch = latch_mode;
-
- if (insert_planned
- && ibuf_should_try(index, ignore_sec_unique)) {
-
- /* Try insert to the insert buffer if the
- page is not in the buffer pool */
-
- buf_mode = BUF_GET_IF_IN_POOL;
- }
- }
-
guess = NULL;
node_ptr = page_cur_get_rec(page_cursor);
@@ -609,7 +634,11 @@ retry_page_get:
cursor->up_bytes = up_bytes;
#ifdef BTR_CUR_ADAPT
- if (!UNIV_UNLIKELY(btr_search_disabled)) {
+ /* We do a dirty read of btr_search_enabled here. We
+ will properly check btr_search_enabled again in
+ btr_search_build_page_hash_index() before building a
+ page hash index, while holding btr_search_latch. */
+ if (UNIV_LIKELY(btr_search_enabled)) {
btr_search_info_update(index, cursor);
}
@@ -1218,7 +1247,9 @@ fail_err:
buf_block_get_page_no(block), max_size,
rec_size + PAGE_DIR_SLOT_SIZE, index->type);
#endif
- if (!dict_index_is_clust(index) && leaf) {
+ if (leaf
+ && !dict_index_is_clust(index)
+ && !dict_index_is_ibuf(index)) {
/* Update the free bits of the B-tree page in the
insert buffer bitmap. */
@@ -1599,6 +1630,7 @@ btr_cur_update_alloc_zip(
{
ut_a(page_zip == buf_block_get_page_zip(block));
ut_ad(page_zip);
+ ut_ad(!dict_index_is_ibuf(index));
if (page_zip_available(page_zip, dict_index_is_clust(index),
length, 0)) {
@@ -1675,6 +1707,9 @@ btr_cur_update_in_place(
rec = btr_cur_get_rec(cursor);
index = cursor->index;
ut_ad(!!page_rec_is_comp(rec) == dict_table_is_comp(index->table));
+ /* The insert buffer tree should never be updated in place. */
+ ut_ad(!dict_index_is_ibuf(index));
+
trx = thr_get_trx(thr);
offsets = rec_get_offsets(rec, index, offsets, ULINT_UNDEFINED, &heap);
#ifdef UNIV_DEBUG
@@ -1811,6 +1846,8 @@ btr_cur_optimistic_update(
index = cursor->index;
ut_ad(!!page_rec_is_comp(rec) == dict_table_is_comp(index->table));
ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
+ /* The insert buffer tree should never be updated in place. */
+ ut_ad(!dict_index_is_ibuf(index));
heap = mem_heap_create(1024);
offsets = rec_get_offsets(rec, index, NULL, ULINT_UNDEFINED, &heap);
@@ -2074,6 +2111,8 @@ btr_cur_pessimistic_update(
#ifdef UNIV_ZIP_DEBUG
ut_a(!page_zip || page_zip_validate(page_zip, page));
#endif /* UNIV_ZIP_DEBUG */
+ /* The insert buffer tree should never be updated in place. */
+ ut_ad(!dict_index_is_ibuf(index));
optim_err = btr_cur_optimistic_update(flags, cursor, update,
cmpl_info, thr, mtr);
@@ -2723,7 +2762,10 @@ btr_cur_optimistic_delete(
delete; cursor stays valid: if deletion
succeeds, on function exit it points to the
successor of the deleted record */
- mtr_t* mtr) /* in: mtr */
+ mtr_t* mtr) /* in: mtr; if this function returns
+ TRUE on a leaf page of a secondary
+ index, the mtr must be committed
+ before latching any further pages */
{
buf_block_t* block;
rec_t* rec;
@@ -2773,10 +2815,12 @@ btr_cur_optimistic_delete(
#endif /* UNIV_ZIP_DEBUG */
if (dict_index_is_clust(cursor->index)
+ || dict_index_is_ibuf(cursor->index)
|| !page_is_leaf(page)) {
/* The insert buffer does not handle
- inserts to clustered indexes or to non-leaf
- pages of secondary index B-trees. */
+ inserts to clustered indexes, to
+ non-leaf pages of secondary index B-trees,
+ or to the insert buffer. */
} else if (page_zip) {
ibuf_update_free_bits_zip(block, mtr);
} else {
@@ -4078,6 +4122,44 @@ next_zip_page:
}
/***********************************************************************
+Check the FIL_PAGE_TYPE on an uncompressed BLOB page. */
+static
+void
+btr_check_blob_fil_page_type(
+/*=========================*/
+ ulint space_id, /* in: space id */
+ ulint page_no, /* in: page number */
+ const page_t* page, /* in: page */
+ ibool read) /* in: TRUE=read, FALSE=purge */
+{
+ ulint type = fil_page_get_type(page);
+
+ ut_a(space_id == page_get_space_id(page));
+ ut_a(page_no == page_get_page_no(page));
+
+ if (UNIV_UNLIKELY(type != FIL_PAGE_TYPE_BLOB)) {
+ ulint flags = fil_space_get_flags(space_id);
+
+ if (UNIV_LIKELY
+ ((flags & DICT_TF_FORMAT_MASK) == DICT_TF_FORMAT_51)) {
+ /* Old versions of InnoDB did not initialize
+ FIL_PAGE_TYPE on BLOB pages. Do not print
+ anything about the type mismatch when reading
+ a BLOB page that is in Antelope format.*/
+ return;
+ }
+
+ ut_print_timestamp(stderr);
+ fprintf(stderr,
+ " InnoDB: FIL_PAGE_TYPE=%lu"
+ " on BLOB %s space %lu page %lu flags %lx\n",
+ (ulong) type, read ? "read" : "purge",
+ (ulong) space_id, (ulong) page_no, (ulong) flags);
+ ut_error;
+ }
+}
+
+/***********************************************************************
Frees the space in an externally stored field to the file space
management if the field in data is owned by the externally stored field,
in a rollback we may have the additional condition that the field must
@@ -4230,8 +4312,9 @@ btr_free_externally_stored_field(
MLOG_4BYTES, &mtr);
}
} else {
- ut_a(fil_page_get_type(page) == FIL_PAGE_TYPE_BLOB);
ut_a(!page_zip);
+ btr_check_blob_fil_page_type(space_id, page_no, page,
+ FALSE);
next_page_no = mach_read_from_4(
page + FIL_PAGE_DATA
@@ -4241,9 +4324,6 @@ btr_free_externally_stored_field(
because we did not store it on the page (we save the
space overhead from an index page header. */
- ut_a(space_id == page_get_space_id(page));
- ut_a(page_no == page_get_page_no(page));
-
btr_page_free_low(index, ext_block, 0, &mtr);
mlog_write_ulint(field_ref + BTR_EXTERN_PAGE_NO,
@@ -4381,9 +4461,8 @@ btr_copy_blob_prefix(
buf_block_dbg_add_level(block, SYNC_EXTERN_STORAGE);
page = buf_block_get_frame(block);
- /* Unfortunately, FIL_PAGE_TYPE was uninitialized for
- many pages until MySQL/InnoDB 5.1.7. */
- /* ut_ad(fil_page_get_type(page) == FIL_PAGE_TYPE_BLOB); */
+ btr_check_blob_fil_page_type(space_id, page_no, page, TRUE);
+
blob_header = page + offset;
part_len = btr_blob_get_part_len(blob_header);
copy_len = ut_min(part_len, len - copied_len);
diff --git a/btr/btr0pcur.c b/btr/btr0pcur.c
index 7adedf7e035..b14efefe13f 100644
--- a/btr/btr0pcur.c
+++ b/btr/btr0pcur.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
The index tree persistent cursor
-(c) 1996 Innobase Oy
-
Created 2/23/1996 Heikki Tuuri
*******************************************************/
diff --git a/btr/btr0sea.c b/btr/btr0sea.c
index 769448bf349..a60f02cf86c 100644
--- a/btr/btr0sea.c
+++ b/btr/btr0sea.c
@@ -1,8 +1,31 @@
+/*****************************************************************************
+
+Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 2008, Google Inc.
+
+Portions of this file contain modifications contributed and copyrighted by
+Google, Inc. Those modifications are gratefully acknowledged and are described
+briefly in the InnoDB documentation. The contributions by Google are
+incorporated with their permission, and subject to the conditions contained in
+the file COPYING.Google.
+
+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
+
+*****************************************************************************/
+
/************************************************************************
The index tree adaptive search
-(c) 1996 Innobase Oy
-
Created 2/17/1996 Heikki Tuuri
*************************************************************************/
@@ -19,8 +42,11 @@ Created 2/17/1996 Heikki Tuuri
#include "btr0btr.h"
#include "ha0ha.h"
-/* Flag: has the search system been disabled? */
-UNIV_INTERN ibool btr_search_disabled = FALSE;
+/* Flag: has the search system been enabled?
+Protected by btr_search_latch and btr_search_enabled_mutex. */
+UNIV_INTERN char btr_search_enabled = TRUE;
+
+static mutex_t btr_search_enabled_mutex;
/* A dummy variable to fool the compiler */
UNIV_INTERN ulint btr_search_this_is_zero = 0;
@@ -139,11 +165,11 @@ btr_search_sys_create(
btr_search_latch_temp = mem_alloc(sizeof(rw_lock_t));
rw_lock_create(&btr_search_latch, SYNC_SEARCH_SYS);
+ mutex_create(&btr_search_enabled_mutex, SYNC_SEARCH_SYS_CONF);
btr_search_sys = mem_alloc(sizeof(btr_search_sys_t));
btr_search_sys->hash_index = ha_create(hash_size, 0, 0);
-
}
/************************************************************************
@@ -153,12 +179,20 @@ void
btr_search_disable(void)
/*====================*/
{
- btr_search_disabled = TRUE;
+ mutex_enter(&btr_search_enabled_mutex);
rw_lock_x_lock(&btr_search_latch);
- ha_clear(btr_search_sys->hash_index);
+ btr_search_enabled = FALSE;
+
+ /* Clear all block->is_hashed flags and remove all entries
+ from btr_search_sys->hash_index. */
+ buf_pool_drop_hash_index();
+
+ /* btr_search_enabled_mutex should guarantee this. */
+ ut_ad(!btr_search_enabled);
rw_lock_x_unlock(&btr_search_latch);
+ mutex_exit(&btr_search_enabled_mutex);
}
/************************************************************************
@@ -168,7 +202,13 @@ void
btr_search_enable(void)
/*====================*/
{
- btr_search_disabled = FALSE;
+ mutex_enter(&btr_search_enabled_mutex);
+ rw_lock_x_lock(&btr_search_latch);
+
+ btr_search_enabled = TRUE;
+
+ rw_lock_x_unlock(&btr_search_latch);
+ mutex_exit(&btr_search_enabled_mutex);
}
/*********************************************************************
@@ -758,7 +798,6 @@ btr_search_guess_on_hash(
{
buf_block_t* block;
rec_t* rec;
- const page_t* page;
ulint fold;
dulint index_id;
#ifdef notdefined
@@ -798,13 +837,14 @@ btr_search_guess_on_hash(
if (UNIV_LIKELY(!has_search_latch)) {
rw_lock_s_lock(&btr_search_latch);
+
+ if (UNIV_UNLIKELY(!btr_search_enabled)) {
+ goto failure_unlock;
+ }
}
-#ifndef HAVE_GCC_ATOMIC_BUILTINS
- /* It is used as lock word among x_lock */
- ut_ad(btr_search_latch.writer != RW_LOCK_EX);
-#endif
- ut_ad(btr_search_latch.reader_count > 0);
+ ut_ad(rw_lock_get_writer(&btr_search_latch) != RW_LOCK_EX);
+ ut_ad(rw_lock_get_reader_count(&btr_search_latch) > 0);
rec = ha_search_and_get_data(btr_search_sys->hash_index, fold);
@@ -812,31 +852,7 @@ btr_search_guess_on_hash(
goto failure_unlock;
}
- page = page_align(rec);
- {
- ulint page_no = page_get_page_no(page);
- ulint space_id = page_get_space_id(page);
-
- //buf_pool_mutex_enter();
- rw_lock_s_lock(&page_hash_latch);
- block = (buf_block_t*) buf_page_hash_get(space_id, page_no);
- //buf_pool_mutex_exit();
- rw_lock_s_unlock(&page_hash_latch);
- }
-
- if (UNIV_UNLIKELY(!block)
- || UNIV_UNLIKELY(buf_block_get_state(block)
- != BUF_BLOCK_FILE_PAGE)) {
-
- /* The block is most probably being freed.
- The function buf_LRU_search_and_free_block()
- first removes the block from buf_pool->page_hash
- by calling buf_LRU_block_remove_hashed_page().
- After that, it invokes btr_search_drop_page_hash_index().
- Let us pretend that the block was also removed from
- the adaptive hash index. */
- goto failure_unlock;
- }
+ block = buf_block_align(rec);
if (UNIV_LIKELY(!has_search_latch)) {
@@ -853,8 +869,9 @@ btr_search_guess_on_hash(
buf_block_dbg_add_level(block, SYNC_TREE_NODE_FROM_HASH);
}
- if (UNIV_UNLIKELY(buf_block_get_state(block)
- == BUF_BLOCK_REMOVE_HASH)) {
+ if (UNIV_UNLIKELY(buf_block_get_state(block) != BUF_BLOCK_FILE_PAGE)) {
+ ut_ad(buf_block_get_state(block) == BUF_BLOCK_REMOVE_HASH);
+
if (UNIV_LIKELY(!has_search_latch)) {
btr_leaf_page_release(block, latch_mode, mtr);
@@ -863,7 +880,6 @@ btr_search_guess_on_hash(
goto failure;
}
- ut_ad(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
ut_ad(page_rec_is_user_rec(rec));
btr_cur_position(index, rec, block, cursor);
@@ -875,8 +891,8 @@ btr_search_guess_on_hash(
is positioned on. We cannot look at the next of the previous
record to determine if our guess for the cursor position is
right. */
- if (UNIV_EXPECT(
- ut_dulint_cmp(index_id, btr_page_get_index_id(page)), 0)
+ if (UNIV_EXPECT
+ (ut_dulint_cmp(index_id, btr_page_get_index_id(block->frame)), 0)
|| !btr_search_check_guess(cursor,
has_search_latch,
tuple, mode, mtr)) {
@@ -1107,7 +1123,7 @@ next_rec:
block->index = NULL;
cleanup:
-#ifdef UNIV_DEBUG
+#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
if (UNIV_UNLIKELY(block->n_pointers)) {
/* Corruption */
ut_print_timestamp(stderr);
@@ -1123,9 +1139,9 @@ cleanup:
} else {
rw_lock_x_unlock(&btr_search_latch);
}
-#else /* UNIV_DEBUG */
+#else /* UNIV_AHI_DEBUG || UNIV_DEBUG */
rw_lock_x_unlock(&btr_search_latch);
-#endif /* UNIV_DEBUG */
+#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
mem_free(folds);
}
@@ -1160,10 +1176,18 @@ btr_search_drop_page_hash_when_freed(
block = buf_page_get_gen(space, zip_size, page_no, RW_S_LATCH, NULL,
BUF_GET_IF_IN_POOL, __FILE__, __LINE__,
&mtr);
+ /* Because the buffer pool mutex was released by
+ buf_page_peek_if_search_hashed(), it is possible that the
+ block was removed from the buffer pool by another thread
+ before buf_page_get_gen() got a chance to acquire the buffer
+ pool mutex again. Thus, we must check for a NULL return. */
+
+ if (UNIV_LIKELY(block != NULL)) {
- buf_block_dbg_add_level(block, SYNC_TREE_NODE_FROM_HASH);
+ buf_block_dbg_add_level(block, SYNC_TREE_NODE_FROM_HASH);
- btr_search_drop_page_hash_index(block);
+ btr_search_drop_page_hash_index(block);
+ }
mtr_commit(&mtr);
}
@@ -1321,6 +1345,10 @@ btr_search_build_page_hash_index(
rw_lock_x_lock(&btr_search_latch);
+ if (UNIV_UNLIKELY(!btr_search_enabled)) {
+ goto exit_func;
+ }
+
if (block->is_hashed && ((block->curr_n_fields != n_fields)
|| (block->curr_n_bytes != n_bytes)
|| (block->curr_left_side != left_side))) {
@@ -1687,7 +1715,6 @@ btr_search_validate(void)
/*=====================*/
/* out: TRUE if ok */
{
- page_t* page;
ha_node_t* node;
ulint n_page_dumps = 0;
ibool ok = TRUE;
@@ -1725,28 +1752,40 @@ btr_search_validate(void)
node = hash_get_nth_cell(btr_search_sys->hash_index, i)->node;
for (; node != NULL; node = node->next) {
- const buf_block_t* block;
-
- page = page_align(node->data);
- {
- ulint page_no = page_get_page_no(page);
- ulint space_id= page_get_space_id(page);
-
- block = buf_block_hash_get(space_id, page_no);
+ const buf_block_t* block
+ = buf_block_align(node->data);
+ const buf_block_t* hash_block;
+
+ if (UNIV_LIKELY(buf_block_get_state(block)
+ == BUF_BLOCK_FILE_PAGE)) {
+
+ /* The space and offset are only valid
+ for file blocks. It is possible that
+ the block is being freed
+ (BUF_BLOCK_REMOVE_HASH, see the
+ assertion and the comment below) */
+ hash_block = buf_block_hash_get(
+ buf_block_get_space(block),
+ buf_block_get_page_no(block));
+ } else {
+ hash_block = NULL;
}
- if (UNIV_UNLIKELY(!block)) {
-
- /* The block is most probably being freed.
- The function buf_LRU_search_and_free_block()
- first removes the block from
+ if (hash_block) {
+ ut_a(hash_block == block);
+ } else {
+ /* When a block is being freed,
+ buf_LRU_search_and_free_block() first
+ removes the block from
buf_pool->page_hash by calling
buf_LRU_block_remove_hashed_page().
After that, it invokes
- btr_search_drop_page_hash_index().
- Let us pretend that the block was also removed
- from the adaptive hash index. */
- continue;
+ btr_search_drop_page_hash_index() to
+ remove the block from
+ btr_search_sys->hash_index. */
+
+ ut_a(buf_block_get_state(block)
+ == BUF_BLOCK_REMOVE_HASH);
}
ut_a(!dict_index_is_ibuf(block->index));
@@ -1762,7 +1801,9 @@ btr_search_validate(void)
offsets,
block->curr_n_fields,
block->curr_n_bytes,
- btr_page_get_index_id(page))) {
+ btr_page_get_index_id(block->frame))) {
+ const page_t* page = block->frame;
+
ok = FALSE;
ut_print_timestamp(stderr);
diff --git a/buf/buf0buddy.c b/buf/buf0buddy.c
index 767521aaec4..76125609b5e 100644
--- a/buf/buf0buddy.c
+++ b/buf/buf0buddy.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 2006, 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
+
+*****************************************************************************/
+
/******************************************************
Binary buddy allocator for compressed pages
-(c) 2006 Innobase Oy
-
Created December 2006 by Marko Makela
*******************************************************/
@@ -176,6 +192,8 @@ buf_buddy_block_free(
mutex_enter(&zip_hash_mutex);
HASH_SEARCH(hash, buf_pool->zip_hash, fold, buf_page_t*, bpage,
+ ut_ad(buf_page_get_state(bpage) == BUF_BLOCK_MEMORY
+ && bpage->in_zip_hash && !bpage->in_page_hash),
((buf_block_t*) bpage)->frame == buf);
ut_a(bpage);
ut_a(buf_page_get_state(bpage) == BUF_BLOCK_MEMORY);
diff --git a/buf/buf0buf.c b/buf/buf0buf.c
index 140708651a5..4a99ad191d5 100644
--- a/buf/buf0buf.c
+++ b/buf/buf0buf.c
@@ -1,22 +1,31 @@
-/* Innobase relational database engine; Copyright (C) 2001 Innobase Oy
+/*****************************************************************************
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License 2
- as published by the Free Software Foundation in June 1991.
+Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 2008, Google Inc.
- 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.
+Portions of this file contain modifications contributed and copyrighted by
+Google, Inc. Those modifications are gratefully acknowledged and are described
+briefly in the InnoDB documentation. The contributions by Google are
+incorporated with their permission, and subject to the conditions contained in
+the file COPYING.Google.
+
+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
+
+*****************************************************************************/
- You should have received a copy of the GNU General Public License 2
- along with this program (in file COPYING); if not, write to the Free
- Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/******************************************************
The database buffer buf_pool
-(c) 1995 Innobase Oy
-
Created 11/5/1995 Heikki Tuuri
*******************************************************/
@@ -35,7 +44,6 @@ Created 11/5/1995 Heikki Tuuri
#include "ibuf0ibuf.h"
#include "dict0dict.h"
#include "log0recv.h"
-#include "log0log.h"
#include "trx0undo.h"
#include "srv0srv.h"
#include "page0zip.h"
@@ -251,7 +259,7 @@ static ulint buf_dbg_counter = 0; /* This is used to insert validation
operations in excution in the
debug version */
/** Flag to forbid the release of the buffer pool mutex.
-Protected by buf_pool->mutex. */
+Protected by buf_pool_mutex. */
UNIV_INTERN ulint buf_pool_mutex_exit_forbidden = 0;
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
#ifdef UNIV_DEBUG
@@ -662,10 +670,12 @@ buf_block_init(
block->page.in_zip_hash = FALSE;
block->page.in_flush_list = FALSE;
block->page.in_free_list = FALSE;
- block->n_pointers = 0;
#endif /* UNIV_DEBUG */
block->page.in_LRU_list = FALSE;
block->in_unzip_LRU_list = FALSE;
+#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
+ block->n_pointers = 0;
+#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
page_zip_des_init(&block->page.zip);
mutex_create(&block->mutex, SYNC_BUF_BLOCK);
@@ -1020,6 +1030,88 @@ buf_pool_free(void)
buf_pool->n_chunks = 0;
}
+
+/************************************************************************
+Drops the adaptive hash index. To prevent a livelock, this function
+is only to be called while holding btr_search_latch and while
+btr_search_enabled == FALSE. */
+UNIV_INTERN
+void
+buf_pool_drop_hash_index(void)
+/*==========================*/
+{
+ ibool released_search_latch;
+
+#ifdef UNIV_SYNC_DEBUG
+ ut_ad(rw_lock_own(&btr_search_latch, RW_LOCK_EX));
+#endif /* UNIV_SYNC_DEBUG */
+ ut_ad(!btr_search_enabled);
+
+ do {
+ buf_chunk_t* chunks = buf_pool->chunks;
+ buf_chunk_t* chunk = chunks + buf_pool->n_chunks;
+
+ released_search_latch = FALSE;
+
+ while (--chunk >= chunks) {
+ buf_block_t* block = chunk->blocks;
+ ulint i = chunk->size;
+
+ for (; i--; block++) {
+ /* block->is_hashed cannot be modified
+ when we have an x-latch on btr_search_latch;
+ see the comment in buf0buf.h */
+
+ if (!block->is_hashed) {
+ continue;
+ }
+
+ /* To follow the latching order, we
+ have to release btr_search_latch
+ before acquiring block->latch. */
+ rw_lock_x_unlock(&btr_search_latch);
+ /* When we release the search latch,
+ we must rescan all blocks, because
+ some may become hashed again. */
+ released_search_latch = TRUE;
+
+ rw_lock_x_lock(&block->lock);
+
+ /* This should be guaranteed by the
+ callers, which will be holding
+ btr_search_enabled_mutex. */
+ ut_ad(!btr_search_enabled);
+
+ /* Because we did not buffer-fix the
+ block by calling buf_block_get_gen(),
+ it is possible that the block has been
+ allocated for some other use after
+ btr_search_latch was released above.
+ We do not care which file page the
+ block is mapped to. All we want to do
+ is to drop any hash entries referring
+ to the page. */
+
+ /* It is possible that
+ block->page.state != BUF_FILE_PAGE.
+ Even that does not matter, because
+ btr_search_drop_page_hash_index() will
+ check block->is_hashed before doing
+ anything. block->is_hashed can only
+ be set on uncompressed file pages. */
+
+ btr_search_drop_page_hash_index(block);
+
+ rw_lock_x_unlock(&block->lock);
+
+ rw_lock_x_lock(&btr_search_latch);
+
+ ut_ad(!btr_search_enabled);
+ }
+ }
+ } while (released_search_latch);
+}
+
/************************************************************************
Relocate a buffer control block. Relocates the block on the LRU list
and in buf_pool->page_hash. Does not relocate bpage->list.
@@ -1807,6 +1899,93 @@ buf_zip_decompress(
return(FALSE);
}
+/***********************************************************************
+Gets the block to whose frame the pointer is pointing to. */
+UNIV_INTERN
+buf_block_t*
+buf_block_align(
+/*============*/
+ /* out: pointer to block, never NULL */
+ const byte* ptr) /* in: pointer to a frame */
+{
+ buf_chunk_t* chunk;
+ ulint i;
+
+ /* TODO: protect buf_pool->chunks with a mutex (it will
+ currently remain constant after buf_pool_init()) */
+ for (chunk = buf_pool->chunks, i = buf_pool->n_chunks; i--; chunk++) {
+ lint offs = ptr - chunk->blocks->frame;
+
+ if (UNIV_UNLIKELY(offs < 0)) {
+
+ continue;
+ }
+
+ offs >>= UNIV_PAGE_SIZE_SHIFT;
+
+ if (UNIV_LIKELY((ulint) offs < chunk->size)) {
+ buf_block_t* block = &chunk->blocks[offs];
+
+ /* The function buf_chunk_init() invokes
+ buf_block_init() so that block[n].frame ==
+ block->frame + n * UNIV_PAGE_SIZE. Check it. */
+ ut_ad(block->frame == page_align(ptr));
+#ifdef UNIV_DEBUG
+ /* A thread that updates these fields must
+ hold buf_pool_mutex and block->mutex. Acquire
+ only the latter. */
+ mutex_enter(&block->mutex);
+
+ switch (buf_block_get_state(block)) {
+ case BUF_BLOCK_ZIP_FREE:
+ case BUF_BLOCK_ZIP_PAGE:
+ case BUF_BLOCK_ZIP_DIRTY:
+ /* These types should only be used in
+ the compressed buffer pool, whose
+ memory is allocated from
+ buf_pool->chunks, in UNIV_PAGE_SIZE
+ blocks flagged as BUF_BLOCK_MEMORY. */
+ ut_error;
+ break;
+ case BUF_BLOCK_NOT_USED:
+ case BUF_BLOCK_READY_FOR_USE:
+ case BUF_BLOCK_MEMORY:
+ /* Some data structures contain
+ "guess" pointers to file pages. The
+ file pages may have been freed and
+ reused. Do not complain. */
+ break;
+ case BUF_BLOCK_REMOVE_HASH:
+ /* buf_LRU_block_remove_hashed_page()
+ will overwrite the FIL_PAGE_OFFSET and
+ FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID with
+ 0xff and set the state to
+ BUF_BLOCK_REMOVE_HASH. */
+ ut_ad(page_get_space_id(page_align(ptr))
+ == 0xffffffff);
+ ut_ad(page_get_page_no(page_align(ptr))
+ == 0xffffffff);
+ break;
+ case BUF_BLOCK_FILE_PAGE:
+ ut_ad(block->page.space
+ == page_get_space_id(page_align(ptr)));
+ ut_ad(block->page.offset
+ == page_get_page_no(page_align(ptr)));
+ break;
+ }
+
+ mutex_exit(&block->mutex);
+#endif /* UNIV_DEBUG */
+
+ return(block);
+ }
+ }
+
+ /* The block should always be found. */
+ ut_error;
+ return(NULL);
+}
+
/************************************************************************
Find out if a buffer block was created by buf_chunk_init(). */
static
@@ -1856,7 +2035,7 @@ buf_page_get_gen(
ulint rw_latch,/* in: RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH */
buf_block_t* guess, /* in: guessed block or NULL */
ulint mode, /* in: BUF_GET, BUF_GET_IF_IN_POOL,
- BUF_GET_NO_LATCH, BUF_GET_NOWAIT */
+ BUF_GET_NO_LATCH */
const char* file, /* in: file name */
ulint line, /* in: line where called */
mtr_t* mtr) /* in: mini-transaction */
@@ -1873,10 +2052,10 @@ buf_page_get_gen(
|| (rw_latch == RW_NO_LATCH));
ut_ad((mode != BUF_GET_NO_LATCH) || (rw_latch == RW_NO_LATCH));
ut_ad((mode == BUF_GET) || (mode == BUF_GET_IF_IN_POOL)
- || (mode == BUF_GET_NO_LATCH) || (mode == BUF_GET_NOWAIT));
+ || (mode == BUF_GET_NO_LATCH));
ut_ad(zip_size == fil_space_get_zip_size(space));
#ifndef UNIV_LOG_DEBUG
- ut_ad(!ibuf_inside() || ibuf_page(space, zip_size, offset));
+ ut_ad(!ibuf_inside() || ibuf_page(space, zip_size, offset, NULL));
#endif
buf_pool->n_page_gets++;
loop:
@@ -2172,29 +2351,8 @@ wait_until_unfixed:
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
- if (mode == BUF_GET_NOWAIT) {
- ibool success;
-
- if (rw_latch == RW_S_LATCH) {
- success = rw_lock_s_lock_func_nowait(&(block->lock),
- file, line);
- fix_type = MTR_MEMO_PAGE_S_FIX;
- } else {
- ut_ad(rw_latch == RW_X_LATCH);
- success = rw_lock_x_lock_func_nowait(&(block->lock),
- file, line);
- fix_type = MTR_MEMO_PAGE_X_FIX;
- }
-
- if (!success) {
- mutex_enter(&block->mutex);
- buf_block_buf_fix_dec(block);
- mutex_exit(&block->mutex);
-
- return(NULL);
- }
- } else if (rw_latch == RW_NO_LATCH) {
-
+ switch (rw_latch) {
+ case RW_NO_LATCH:
if (must_read) {
/* Let us wait until the read operation
completes */
@@ -2216,15 +2374,20 @@ wait_until_unfixed:
}
fix_type = MTR_MEMO_BUF_FIX;
- } else if (rw_latch == RW_S_LATCH) {
+ break;
+ case RW_S_LATCH:
rw_lock_s_lock_func(&(block->lock), 0, file, line);
fix_type = MTR_MEMO_PAGE_S_FIX;
- } else {
+ break;
+
+ default:
+ ut_ad(rw_latch == RW_X_LATCH);
rw_lock_x_lock_func(&(block->lock), 0, file, line);
fix_type = MTR_MEMO_PAGE_X_FIX;
+ break;
}
mtr_memo_push(mtr, block, fix_type);
@@ -2288,11 +2451,11 @@ buf_page_optimistic_get_func(
ut_ad(!ibuf_inside()
|| ibuf_page(buf_block_get_space(block),
buf_block_get_zip_size(block),
- buf_block_get_page_no(block)));
+ buf_block_get_page_no(block), NULL));
if (rw_latch == RW_S_LATCH) {
- success = rw_lock_s_lock_func_nowait(&(block->lock),
- file, line);
+ success = rw_lock_s_lock_nowait(&(block->lock),
+ file, line);
fix_type = MTR_MEMO_PAGE_S_FIX;
} else {
success = rw_lock_x_lock_func_nowait(&(block->lock),
@@ -2403,8 +2566,8 @@ buf_page_get_known_nowait(
ut_ad(!ibuf_inside() || (mode == BUF_KEEP_OLD));
if (rw_latch == RW_S_LATCH) {
- success = rw_lock_s_lock_func_nowait(&(block->lock),
- file, line);
+ success = rw_lock_s_lock_nowait(&(block->lock),
+ file, line);
fix_type = MTR_MEMO_PAGE_S_FIX;
} else {
success = rw_lock_x_lock_func_nowait(&(block->lock),
@@ -2484,7 +2647,7 @@ buf_page_try_get_func(
mutex_exit(&block->mutex);
fix_type = MTR_MEMO_PAGE_S_FIX;
- success = rw_lock_s_lock_func_nowait(&block->lock, file, line);
+ success = rw_lock_s_lock_nowait(&block->lock, file, line);
if (!success) {
/* Let us try to get an X-latch. If the current thread
@@ -2517,6 +2680,11 @@ buf_page_try_get_func(
buf_pool->n_page_gets++;
+#ifdef UNIV_IBUF_COUNT_DEBUG
+ ut_a(ibuf_count_get(buf_block_get_space(block),
+ buf_block_get_page_no(block)) == 0);
+#endif
+
return(block);
}
@@ -2684,7 +2852,8 @@ buf_page_init_for_read(
mtr_start(&mtr);
- if (!ibuf_page_low(space, zip_size, offset, &mtr)) {
+ if (!recv_no_ibuf_operations
+ && !ibuf_page(space, zip_size, offset, &mtr)) {
mtr_commit(&mtr);
@@ -2720,19 +2889,13 @@ err_exit:
mutex_exit(&block->mutex);
}
else {
-err_exit2:
- //buf_pool_mutex_exit();
- mutex_exit(&LRU_list_mutex);
- mutex_exit(&flush_list_mutex);
- rw_lock_x_unlock(&page_hash_latch);
- }
-
- if (mode == BUF_READ_IBUF_PAGES_ONLY) {
-
- mtr_commit(&mtr);
+ mutex_exit(&LRU_list_mutex);
+ mutex_exit(&flush_list_mutex);
+ rw_lock_x_unlock(&page_hash_latch);
}
- return(NULL);
+ bpage = NULL;
+ goto func_exit;
}
if (fil_tablespace_deleted_or_being_deleted_in_mem(
@@ -2815,7 +2978,13 @@ err_exit2:
/* The block was added by some other thread. */
buf_buddy_free(bpage, sizeof *bpage, TRUE);
buf_buddy_free(data, zip_size, TRUE);
- goto err_exit2;
+
+ mutex_exit(&LRU_list_mutex);
+ mutex_exit(&flush_list_mutex);
+ rw_lock_x_unlock(&page_hash_latch);
+
+ bpage = NULL;
+ goto func_exit;
}
page_zip_des_init(&bpage->zip);
@@ -2859,6 +3028,7 @@ err_exit2:
mutex_enter(&buf_pool_mutex);
buf_pool->n_pend_reads++;
mutex_exit(&buf_pool_mutex);
+func_exit:
//buf_pool_mutex_exit();
if (mode == BUF_READ_IBUF_PAGES_ONLY) {
@@ -2866,7 +3036,7 @@ err_exit2:
mtr_commit(&mtr);
}
- ut_ad(buf_page_in_file(bpage));
+ ut_ad(!bpage || buf_page_in_file(bpage));
return(bpage);
}
diff --git a/buf/buf0flu.c b/buf/buf0flu.c
index 6a5d900615b..8c48b08e0fa 100644
--- a/buf/buf0flu.c
+++ b/buf/buf0flu.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/******************************************************
The database buffer buf_pool flush algorithm
-(c) 1995-2001 Innobase Oy
-
Created 11/11/1995 Heikki Tuuri
*******************************************************/
@@ -43,38 +59,21 @@ UNIV_INTERN
void
buf_flush_insert_into_flush_list(
/*=============================*/
- buf_page_t* bpage) /* in: block which is modified */
+ buf_block_t* block) /* in/out: block which is modified */
{
//ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(&flush_list_mutex));
ut_ad((UT_LIST_GET_FIRST(buf_pool->flush_list) == NULL)
|| (UT_LIST_GET_FIRST(buf_pool->flush_list)->oldest_modification
- <= bpage->oldest_modification));
+ <= block->page.oldest_modification));
- switch (buf_page_get_state(bpage)) {
- case BUF_BLOCK_ZIP_PAGE:
- mutex_enter(&buf_pool_zip_mutex);
- buf_page_set_state(bpage, BUF_BLOCK_ZIP_DIRTY);
- mutex_exit(&buf_pool_zip_mutex);
- UT_LIST_REMOVE(list, buf_pool->zip_clean, bpage);
- /* fall through */
- case BUF_BLOCK_ZIP_DIRTY:
- case BUF_BLOCK_FILE_PAGE:
- ut_ad(bpage->in_LRU_list);
- ut_ad(bpage->in_page_hash);
- ut_ad(!bpage->in_zip_hash);
- ut_ad(!bpage->in_flush_list);
- ut_d(bpage->in_flush_list = TRUE);
- UT_LIST_ADD_FIRST(list, buf_pool->flush_list, bpage);
- break;
- case BUF_BLOCK_ZIP_FREE:
- case BUF_BLOCK_NOT_USED:
- case BUF_BLOCK_READY_FOR_USE:
- case BUF_BLOCK_MEMORY:
- case BUF_BLOCK_REMOVE_HASH:
- ut_error;
- return;
- }
+ ut_ad(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
+ ut_ad(block->page.in_LRU_list);
+ ut_ad(block->page.in_page_hash);
+ ut_ad(!block->page.in_zip_hash);
+ ut_ad(!block->page.in_flush_list);
+ ut_d(block->page.in_flush_list = TRUE);
+ UT_LIST_ADD_FIRST(list, buf_pool->flush_list, &block->page);
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
ut_a(buf_flush_validate_low());
@@ -89,52 +88,35 @@ UNIV_INTERN
void
buf_flush_insert_sorted_into_flush_list(
/*====================================*/
- buf_page_t* bpage) /* in: block which is modified */
+ buf_block_t* block) /* in/out: block which is modified */
{
buf_page_t* prev_b;
buf_page_t* b;
//ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(&flush_list_mutex));
+ ut_ad(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
- switch (buf_page_get_state(bpage)) {
- case BUF_BLOCK_ZIP_PAGE:
- mutex_enter(&buf_pool_zip_mutex);
- buf_page_set_state(bpage, BUF_BLOCK_ZIP_DIRTY);
- mutex_exit(&buf_pool_zip_mutex);
- UT_LIST_REMOVE(list, buf_pool->zip_clean, bpage);
- /* fall through */
- case BUF_BLOCK_ZIP_DIRTY:
- case BUF_BLOCK_FILE_PAGE:
- ut_ad(bpage->in_LRU_list);
- ut_ad(bpage->in_page_hash);
- ut_ad(!bpage->in_zip_hash);
- ut_ad(!bpage->in_flush_list);
- ut_d(bpage->in_flush_list = TRUE);
- break;
- case BUF_BLOCK_ZIP_FREE:
- case BUF_BLOCK_NOT_USED:
- case BUF_BLOCK_READY_FOR_USE:
- case BUF_BLOCK_MEMORY:
- case BUF_BLOCK_REMOVE_HASH:
- ut_error;
- return;
- }
+ ut_ad(block->page.in_LRU_list);
+ ut_ad(block->page.in_page_hash);
+ ut_ad(!block->page.in_zip_hash);
+ ut_ad(!block->page.in_flush_list);
+ ut_d(block->page.in_flush_list = TRUE);
prev_b = NULL;
b = UT_LIST_GET_FIRST(buf_pool->flush_list);
- while (b && b->oldest_modification > bpage->oldest_modification) {
+ while (b && b->oldest_modification > block->page.oldest_modification) {
ut_ad(b->in_flush_list);
prev_b = b;
b = UT_LIST_GET_NEXT(list, b);
}
if (prev_b == NULL) {
- UT_LIST_ADD_FIRST(list, buf_pool->flush_list, bpage);
+ UT_LIST_ADD_FIRST(list, buf_pool->flush_list, &block->page);
} else {
UT_LIST_INSERT_AFTER(list, buf_pool->flush_list,
- prev_b, bpage);
+ prev_b, &block->page);
}
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
@@ -192,6 +174,7 @@ buf_flush_ready_for_flush(
ut_a(buf_page_in_file(bpage));
//ut_ad(buf_pool_mutex_own()); /*optimistic...*/
ut_ad(mutex_own(buf_page_get_mutex(bpage)));
+ ut_ad(flush_type == BUF_FLUSH_LRU || BUF_FLUSH_LIST);
if (bpage->oldest_modification != 0
&& buf_page_get_io_fix(bpage) == BUF_IO_NONE) {
@@ -693,6 +676,16 @@ buf_flush_write_block_low(
ut_ad(buf_page_in_file(bpage));
+ /* We are not holding buf_pool_mutex or block_mutex here.
+ Nevertheless, it is safe to access bpage, because it is
+ io_fixed and oldest_modification != 0. Thus, it cannot be
+ relocated in the buffer pool or removed from flush_list or
+ LRU_list. */
+ ut_ad(!buf_pool_mutex_own());
+ ut_ad(!mutex_own(buf_page_get_mutex(bpage)));
+ ut_ad(buf_page_get_io_fix(bpage) == BUF_IO_WRITE);
+ ut_ad(bpage->oldest_modification != 0);
+
#ifdef UNIV_IBUF_COUNT_DEBUG
ut_a(ibuf_count_get(bpage->space, bpage->offset) == 0);
#endif
@@ -754,73 +747,62 @@ buf_flush_write_block_low(
}
/************************************************************************
-Writes a page asynchronously from the buffer buf_pool to a file, if it can be
-found in the buf_pool and it is in a flushable state. NOTE: in simulated aio
-we must call os_aio_simulated_wake_handler_threads after we have posted a batch
-of writes! */
+Writes a flushable page asynchronously from the buffer pool to a file.
+NOTE: in simulated aio we must call
+os_aio_simulated_wake_handler_threads after we have posted a batch of
+writes! NOTE: buf_pool_mutex and buf_page_get_mutex(bpage) must be
+held upon entering this function, and they will be released by this
+function. */
static
-ulint
-buf_flush_try_page(
-/*===============*/
- /* out: 1 if a page was
- flushed, 0 otherwise */
- ulint space, /* in: space id */
- ulint offset, /* in: page offset */
- enum buf_flush flush_type) /* in: BUF_FLUSH_LRU, BUF_FLUSH_LIST,
- or BUF_FLUSH_SINGLE_PAGE */
+void
+buf_flush_page(
+/*===========*/
+ buf_page_t* bpage, /* in: buffer control block */
+ enum buf_flush flush_type) /* in: BUF_FLUSH_LRU
+ or BUF_FLUSH_LIST */
{
- buf_page_t* bpage;
mutex_t* block_mutex;
- ibool locked;
+ ibool is_uncompressed;
- ut_ad(flush_type == BUF_FLUSH_LRU || flush_type == BUF_FLUSH_LIST
- || flush_type == BUF_FLUSH_SINGLE_PAGE);
-
- //buf_pool_mutex_enter();
- rw_lock_s_lock(&page_hash_latch);
-
- bpage = buf_page_hash_get(space, offset);
-
- if (!bpage) {
- //buf_pool_mutex_exit();
- rw_lock_s_unlock(&page_hash_latch);
- return(0);
- }
+ ut_ad(flush_type == BUF_FLUSH_LRU || flush_type == BUF_FLUSH_LIST);
+ //ut_ad(buf_pool_mutex_own());
+#ifdef UNIV_SYNC_DEBUG
+ ut_ad(rw_lock_own(&page_hash_latch, RW_LOCK_EX)
+ || rw_lock_own(&page_hash_latch, RW_LOCK_SHARED));
+#endif
+ ut_ad(buf_page_in_file(bpage));
- ut_a(buf_page_in_file(bpage));
block_mutex = buf_page_get_mutex(bpage);
+ ut_ad(mutex_own(block_mutex));
- mutex_enter(block_mutex);
mutex_enter(&buf_pool_mutex);
rw_lock_s_unlock(&page_hash_latch);
- if (!buf_flush_ready_for_flush(bpage, flush_type)) {
- mutex_exit(block_mutex);
- //buf_pool_mutex_exit();
- mutex_exit(&buf_pool_mutex);
- return(0);
- }
+ ut_ad(buf_flush_ready_for_flush(bpage, flush_type));
- switch (flush_type) {
- case BUF_FLUSH_LIST:
- buf_page_set_io_fix(bpage, BUF_IO_WRITE);
+ buf_page_set_io_fix(bpage, BUF_IO_WRITE);
- buf_page_set_flush_type(bpage, flush_type);
+ buf_page_set_flush_type(bpage, flush_type);
- if (buf_pool->n_flush[flush_type] == 0) {
+ if (buf_pool->n_flush[flush_type] == 0) {
- os_event_reset(buf_pool->no_flush[flush_type]);
- }
+ os_event_reset(buf_pool->no_flush[flush_type]);
+ }
- buf_pool->n_flush[flush_type]++;
+ buf_pool->n_flush[flush_type]++;
+ is_uncompressed = (buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE);
+ ut_ad(is_uncompressed == (block_mutex != &buf_pool_zip_mutex));
+
+ switch (flush_type) {
+ ibool is_s_latched;
+ case BUF_FLUSH_LIST:
/* If the simulated aio thread is not running, we must
not wait for any latch, as we may end up in a deadlock:
if buf_fix_count == 0, then we know we need not wait */
- locked = bpage->buf_fix_count == 0;
- if (locked
- && buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE) {
+ is_s_latched = (bpage->buf_fix_count == 0);
+ if (is_s_latched && is_uncompressed) {
rw_lock_s_lock_gen(&((buf_block_t*) bpage)->lock,
BUF_IO_WRITE);
}
@@ -829,10 +811,16 @@ buf_flush_try_page(
//buf_pool_mutex_exit();
mutex_exit(&buf_pool_mutex);
- if (!locked) {
+ /* Even though bpage is not protected by any mutex at
+ this point, it is safe to access bpage, because it is
+ io_fixed and oldest_modification != 0. Thus, it
+ cannot be relocated in the buffer pool or removed from
+ flush_list or LRU_list. */
+
+ if (!is_s_latched) {
buf_flush_buffered_writes();
- if (buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE) {
+ if (is_uncompressed) {
rw_lock_s_lock_gen(&((buf_block_t*) bpage)
->lock, BUF_IO_WRITE);
}
@@ -845,22 +833,10 @@ buf_flush_try_page(
Because any thread may call the LRU flush, even when owning
locks on pages, to avoid deadlocks, we must make sure that the
s-lock is acquired on the page without waiting: this is
- accomplished because in the if-condition above we require
- the page not to be bufferfixed (in function
- ..._ready_for_flush). */
-
- buf_page_set_io_fix(bpage, BUF_IO_WRITE);
-
- buf_page_set_flush_type(bpage, flush_type);
-
- if (buf_pool->n_flush[flush_type] == 0) {
+ accomplished because buf_flush_ready_for_flush() must hold,
+ and that requires the page not to be bufferfixed. */
- os_event_reset(buf_pool->no_flush[flush_type]);
- }
-
- buf_pool->n_flush[flush_type]++;
-
- if (buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE) {
+ if (is_uncompressed) {
rw_lock_s_lock_gen(&((buf_block_t*) bpage)->lock,
BUF_IO_WRITE);
}
@@ -874,31 +850,15 @@ buf_flush_try_page(
mutex_exit(&buf_pool_mutex);
break;
- case BUF_FLUSH_SINGLE_PAGE:
- buf_page_set_io_fix(bpage, BUF_IO_WRITE);
-
- buf_page_set_flush_type(bpage, flush_type);
-
- if (buf_pool->n_flush[flush_type] == 0) {
-
- os_event_reset(buf_pool->no_flush[flush_type]);
- }
-
- buf_pool->n_flush[flush_type]++;
-
- mutex_exit(block_mutex);
- //buf_pool_mutex_exit();
- mutex_exit(&buf_pool_mutex);
- if (buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE) {
- rw_lock_s_lock_gen(&((buf_block_t*) bpage)->lock,
- BUF_IO_WRITE);
- }
- break;
-
default:
ut_error;
}
+ /* Even though bpage is not protected by any mutex at this
+ point, it is safe to access bpage, because it is io_fixed and
+ oldest_modification != 0. Thus, it cannot be relocated in the
+ buffer pool or removed from flush_list or LRU_list. */
+
#ifdef UNIV_DEBUG
if (buf_debug_prints) {
fprintf(stderr,
@@ -907,8 +867,6 @@ buf_flush_try_page(
}
#endif /* UNIV_DEBUG */
buf_flush_write_block_low(bpage);
-
- return(1);
}
/***************************************************************
@@ -959,21 +917,20 @@ buf_flush_try_neighbors(
for (i = low; i < high; i++) {
bpage = buf_page_hash_get(space, i);
- ut_a(!bpage || buf_page_in_file(bpage));
if (!bpage) {
continue;
+ }
- } else if (flush_type == BUF_FLUSH_LRU && i != offset
- && !buf_page_is_old(bpage)) {
-
- /* We avoid flushing 'non-old' blocks in an LRU flush,
- because the flushed blocks are soon freed */
+ ut_a(buf_page_in_file(bpage));
- continue;
- } else {
+ /* We avoid flushing 'non-old' blocks in an LRU flush,
+ because the flushed blocks are soon freed */
+ if (flush_type != BUF_FLUSH_LRU
+ || i == offset
+ || buf_page_is_old(bpage)) {
mutex_t* block_mutex = buf_page_get_mutex(bpage);
mutex_enter(block_mutex);
@@ -988,19 +945,9 @@ buf_flush_try_neighbors(
flush the doublewrite buffer before we start
waiting. */
- //buf_pool_mutex_exit();
- rw_lock_s_unlock(&page_hash_latch);
-
- mutex_exit(block_mutex);
-
- /* Note: as we release the buf_pool mutex
- above, in buf_flush_try_page we cannot be sure
- the page is still in a flushable state:
- therefore we check it again inside that
- function. */
-
- count += buf_flush_try_page(space, i,
- flush_type);
+ buf_flush_page(bpage, flush_type);
+ ut_ad(!mutex_own(block_mutex));
+ count++;
//buf_pool_mutex_enter();
rw_lock_s_lock(&page_hash_latch);
@@ -1111,14 +1058,16 @@ flush_next:
function a pointer to a block in the list! */
do {
- mutex_t* block_mutex = buf_page_get_mutex(bpage);
+ mutex_t*block_mutex = buf_page_get_mutex(bpage);
+ ibool ready;
ut_a(buf_page_in_file(bpage));
mutex_enter(block_mutex);
+ ready = buf_flush_ready_for_flush(bpage, flush_type);
+ mutex_exit(block_mutex);
- if (buf_flush_ready_for_flush(bpage, flush_type)) {
-
+ if (ready) {
space = buf_page_get_space(bpage);
offset = buf_page_get_page_no(bpage);
@@ -1127,7 +1076,6 @@ flush_next:
mutex_exit(&LRU_list_mutex);
}
mutex_exit(&flush_list_mutex);
- mutex_exit(block_mutex);
old_page_count = page_count;
@@ -1136,9 +1084,18 @@ flush_next:
page_count += buf_flush_try_neighbors(
space, offset, flush_type);
} else {
- /* Try to flush the page only */
- page_count += buf_flush_try_page(
- space, offset, flush_type);
+ /* Try to flush the page only */
+ //buf_pool_mutex_enter();
+ rw_lock_s_lock(&page_hash_latch);
+
+ mutex_t* block_mutex = buf_page_get_mutex(bpage);
+ mutex_enter(block_mutex);
+
+ buf_page_t* bpage_tmp = buf_page_hash_get(space, offset);
+ if (bpage_tmp) {
+ buf_flush_page(bpage_tmp, flush_type);
+ page_count++;
+ }
}
/* fprintf(stderr,
"Flush type %lu, page no %lu, neighb %lu\n",
@@ -1153,15 +1110,10 @@ flush_next:
goto flush_next;
} else if (flush_type == BUF_FLUSH_LRU) {
-
- mutex_exit(block_mutex);
-
bpage = UT_LIST_GET_PREV(LRU, bpage);
} else {
ut_ad(flush_type == BUF_FLUSH_LIST);
- mutex_exit(block_mutex);
-
bpage = UT_LIST_GET_PREV(list, bpage);
ut_ad(!bpage || bpage->in_flush_list);
}
@@ -1181,8 +1133,7 @@ flush_next:
buf_pool->init_flush[flush_type] = FALSE;
- if ((buf_pool->n_flush[flush_type] == 0)
- && (buf_pool->init_flush[flush_type] == FALSE)) {
+ if (buf_pool->n_flush[flush_type] == 0) {
/* The running flush batch has ended */
diff --git a/buf/buf0lru.c b/buf/buf0lru.c
index 84e2dea3dae..be6acb83d09 100644
--- a/buf/buf0lru.c
+++ b/buf/buf0lru.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/******************************************************
The database buffer replacement algorithm
-(c) 1995 Innobase Oy
-
Created 11/5/1995 Heikki Tuuri
*******************************************************/
@@ -26,6 +42,7 @@ Created 11/5/1995 Heikki Tuuri
#include "buf0flu.h"
#include "buf0rea.h"
#include "btr0sea.h"
+#include "ibuf0ibuf.h"
#include "os0file.h"
#include "page0zip.h"
#include "log0recv.h"
@@ -263,7 +280,7 @@ scan_again:
if (num_entries < BUF_LRU_DROP_SEARCH_HASH_SIZE) {
goto next_page;
}
- /* Array full. We release the buf_pool->mutex to
+ /* Array full. We release the buf_pool_mutex to
obey the latching order. */
//buf_pool_mutex_exit();
mutex_exit(&LRU_list_mutex);
@@ -315,7 +332,6 @@ buf_LRU_invalidate_tablespace(
ulint id) /* in: space id */
{
buf_page_t* bpage;
- ulint page_no;
ibool all_freed;
/* Before we attempt to drop pages one by one we first
@@ -369,21 +385,24 @@ scan_again:
#endif
if (buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE
&& ((buf_block_t*) bpage)->is_hashed) {
- page_no = buf_page_get_page_no(bpage);
+ ulint page_no;
+ ulint zip_size;
//buf_pool_mutex_exit();
mutex_exit(&LRU_list_mutex);
mutex_exit(&flush_list_mutex);
rw_lock_x_unlock(&page_hash_latch);
+
+ zip_size = buf_page_get_zip_size(bpage);
+ page_no = buf_page_get_page_no(bpage);
+
mutex_exit(block_mutex);
/* Note that the following call will acquire
an S-latch on the page */
btr_search_drop_page_hash_when_freed(
- id,
- buf_page_get_zip_size(bpage),
- page_no);
+ id, zip_size, page_no);
goto scan_again;
}
@@ -398,6 +417,12 @@ scan_again:
buf_LRU_block_free_hashed_page((buf_block_t*)
bpage, TRUE);
} else {
+ /* The block_mutex should have been
+ released by buf_LRU_block_remove_hashed_page()
+ when it returns BUF_BLOCK_ZIP_FREE. */
+ ut_ad(block_mutex == &buf_pool_zip_mutex);
+ ut_ad(!mutex_own(block_mutex));
+
/* The compressed block descriptor
(bpage) has been deallocated and
block_mutex released. Also,
@@ -1364,9 +1389,15 @@ buf_LRU_make_block_old(
/**********************************************************************
Try to free a block. If bpage is a descriptor of a compressed-only
-page, the descriptor object will be freed as well. If this function
-returns BUF_LRU_FREED, it will not temporarily release
-buf_pool_mutex. */
+page, the descriptor object will be freed as well.
+
+NOTE: If this function returns BUF_LRU_FREED, it will not temporarily
+release buf_pool_mutex. Furthermore, the page frame will no longer be
+accessible via bpage.
+
+The caller must hold buf_pool_mutex and buf_page_get_mutex(bpage) and
+release these two mutexes after the call. No other
+buf_page_get_mutex() may be held when calling this function. */
UNIV_INTERN
enum buf_lru_free_block_status
buf_LRU_free_block(
@@ -1400,6 +1431,10 @@ buf_LRU_free_block(
return(BUF_LRU_NOT_FREED);
}
+#ifdef UNIV_IBUF_COUNT_DEBUG
+ ut_a(ibuf_count_get(bpage->space, bpage->offset) == 0);
+#endif /* UNIV_IBUF_COUNT_DEBUG */
+
if (zip || !bpage->zip.data) {
/* This would completely free the block. */
/* Do not completely free dirty blocks. */
@@ -1653,6 +1688,10 @@ not_freed:
buf_LRU_block_free_hashed_page((buf_block_t*) bpage, FALSE);
} else {
+ /* The block_mutex should have been released by
+ buf_LRU_block_remove_hashed_page() when it returns
+ BUF_BLOCK_ZIP_FREE. */
+ ut_ad(block_mutex == &buf_pool_zip_mutex);
mutex_enter(block_mutex);
if (!have_LRU_mutex)
@@ -1675,9 +1714,9 @@ buf_LRU_block_free_non_file_page(
{
void* data;
+ ut_ad(block);
//ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(&block->mutex));
- ut_ad(block);
switch (buf_block_get_state(block)) {
case BUF_BLOCK_MEMORY:
@@ -1687,7 +1726,9 @@ buf_LRU_block_free_non_file_page(
ut_error;
}
- ut_ad(block->n_pointers == 0);
+#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
+ ut_a(block->n_pointers == 0);
+#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
ut_ad(!block->page.in_free_list);
ut_ad(!block->page.in_flush_list);
ut_ad(!block->page.in_LRU_list);
@@ -1903,7 +1944,9 @@ buf_LRU_block_remove_hashed_page(
bpage->zip.data = NULL;
mutex_exit(&((buf_block_t*) bpage)->mutex);
+ //buf_pool_mutex_exit_forbid();
buf_buddy_free(data, page_zip_get_size(&bpage->zip), TRUE);
+ //buf_pool_mutex_exit_allow();
mutex_enter(&((buf_block_t*) bpage)->mutex);
page_zip_set_size(&bpage->zip, 0);
}
diff --git a/buf/buf0rea.c b/buf/buf0rea.c
index 632805c43a7..c5a7def8733 100644
--- a/buf/buf0rea.c
+++ b/buf/buf0rea.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/******************************************************
The database buffer read
-(c) 1995 Innobase Oy
-
Created 11/5/1995 Heikki Tuuri
*******************************************************/
diff --git a/compile-innodb b/compile-innodb
index 027ff727af0..82601f03ae9 100755
--- a/compile-innodb
+++ b/compile-innodb
@@ -1,4 +1,19 @@
#! /bin/sh
+#
+# Copyright (c) 2006, 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
+#
path=`dirname $0`
. "$path/SETUP.sh"
diff --git a/compile-innodb-debug b/compile-innodb-debug
index d179c9453ce..efb4abf88d5 100755
--- a/compile-innodb-debug
+++ b/compile-innodb-debug
@@ -1,4 +1,19 @@
#! /bin/sh
+#
+# Copyright (c) 2005, 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
+#
path=`dirname $0`
. "$path/SETUP.sh" $@ --with-debug=full
diff --git a/data/data0data.c b/data/data0data.c
index 212bc8237c0..1cb3803b187 100644
--- a/data/data0data.c
+++ b/data/data0data.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/************************************************************************
SQL data field and tuple
-(c) 1994-1996 Innobase Oy
-
Created 5/30/1994 Heikki Tuuri
*************************************************************************/
@@ -26,8 +42,10 @@ Created 5/30/1994 Heikki Tuuri
for error checking */
UNIV_INTERN byte data_error;
+# ifndef UNIV_DEBUG_VALGRIND
/* this is used to fool the compiler in dtuple_validate */
UNIV_INTERN ulint data_dummy;
+# endif /* !UNIV_DEBUG_VALGRIND */
#endif /* UNIV_DEBUG */
/*************************************************************************
@@ -232,11 +250,9 @@ dtuple_validate(
const dtuple_t* tuple) /* in: tuple */
{
const dfield_t* field;
- const byte* data;
ulint n_fields;
ulint len;
ulint i;
- ulint j;
ut_ad(tuple->magic_n == DATA_TUPLE_MAGIC_N);
@@ -252,8 +268,9 @@ dtuple_validate(
if (!dfield_is_null(field)) {
- data = dfield_get_data(field);
- UNIV_MEM_ASSERT_RW(data, len);
+ const byte* data = dfield_get_data(field);
+#ifndef UNIV_DEBUG_VALGRIND
+ ulint j;
for (j = 0; j < len; j++) {
@@ -262,6 +279,9 @@ dtuple_validate(
code */
data++;
}
+#endif /* !UNIV_DEBUG_VALGRIND */
+
+ UNIV_MEM_ASSERT_RW(data, len);
}
}
@@ -530,9 +550,9 @@ dtuple_print(
dfield_print_raw(f, dtuple_get_nth_field(tuple, i));
putc(';', f);
+ putc('\n', f);
}
- putc('\n', f);
ut_ad(dtuple_validate(tuple));
}
diff --git a/data/data0type.c b/data/data0type.c
index 36a01db8789..5df933ef9fd 100644
--- a/data/data0type.c
+++ b/data/data0type.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Data types
-(c) 1996 Innobase Oy
-
Created 1/16/1996 Heikki Tuuri
*******************************************************/
diff --git a/dict/dict0boot.c b/dict/dict0boot.c
index a1a94c078e6..505ba53ec52 100644
--- a/dict/dict0boot.c
+++ b/dict/dict0boot.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Data dictionary creation and booting
-(c) 1996 Innobase Oy
-
Created 4/18/1996 Heikki Tuuri
*******************************************************/
diff --git a/dict/dict0crea.c b/dict/dict0crea.c
index d4b3b3ae124..b9662c9a44c 100644
--- a/dict/dict0crea.c
+++ b/dict/dict0crea.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Database object creation
-(c) 1996 Innobase Oy
-
Created 1/8/1996 Heikki Tuuri
*******************************************************/
@@ -1079,7 +1095,7 @@ dict_create_index_step(
dulint index_id = node->index->id;
err = dict_index_add_to_cache(node->table, node->index,
- FIL_NULL, trx_is_strict(trx));
+ FIL_NULL, TRUE);
node->index = dict_index_get_if_in_cache_low(index_id);
ut_a(!node->index == (err != DB_SUCCESS));
diff --git a/dict/dict0dict.c b/dict/dict0dict.c
index 0f5eef60059..134be1dadba 100644
--- a/dict/dict0dict.c
+++ b/dict/dict0dict.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/**********************************************************************
Data dictionary system
-(c) 1996 Innobase Oy
-
Created 1/8/1996 Heikki Tuuri
***********************************************************************/
@@ -751,18 +767,34 @@ dict_table_add_to_cache(
{
dict_table_t* table2;
HASH_SEARCH(name_hash, dict_sys->table_hash, fold,
- dict_table_t*, table2,
- (ut_strcmp(table2->name, table->name) == 0));
+ dict_table_t*, table2, ut_ad(table2->cached),
+ ut_strcmp(table2->name, table->name) == 0);
ut_a(table2 == NULL);
+
+#ifdef UNIV_DEBUG
+ /* Look for the same table pointer with a different name */
+ HASH_SEARCH_ALL(name_hash, dict_sys->table_hash,
+ dict_table_t*, table2, ut_ad(table2->cached),
+ table2 == table);
+ ut_ad(table2 == NULL);
+#endif /* UNIV_DEBUG */
}
/* Look for a table with the same id: error if such exists */
{
dict_table_t* table2;
HASH_SEARCH(id_hash, dict_sys->table_id_hash, id_fold,
- dict_table_t*, table2,
- (ut_dulint_cmp(table2->id, table->id) == 0));
+ dict_table_t*, table2, ut_ad(table2->cached),
+ ut_dulint_cmp(table2->id, table->id) == 0);
ut_a(table2 == NULL);
+
+#ifdef UNIV_DEBUG
+ /* Look for the same table pointer with a different id */
+ HASH_SEARCH_ALL(id_hash, dict_sys->table_id_hash,
+ dict_table_t*, table2, ut_ad(table2->cached),
+ table2 == table);
+ ut_ad(table2 == NULL);
+#endif /* UNIV_DEBUG */
}
/* Add table to hash table of tables */
@@ -844,7 +876,7 @@ dict_table_rename_in_cache(
{
dict_table_t* table2;
HASH_SEARCH(name_hash, dict_sys->table_hash, fold,
- dict_table_t*, table2,
+ dict_table_t*, table2, ut_ad(table2->cached),
(ut_strcmp(table2->name, new_name) == 0));
if (UNIV_LIKELY_NULL(table2)) {
ut_print_timestamp(stderr);
diff --git a/dict/dict0load.c b/dict/dict0load.c
index e51b1376be3..44590a261a6 100644
--- a/dict/dict0load.c
+++ b/dict/dict0load.c
@@ -1,9 +1,25 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Loads to the memory cache database object definitions
from dictionary tables
-(c) 1996 Innobase Oy
-
Created 4/24/1996 Heikki Tuuri
*******************************************************/
@@ -949,11 +965,11 @@ err_exit:
of the error condition, since the user may want to dump data from the
clustered index. However we load the foreign key information only if
all indexes were loaded. */
- if (err != DB_SUCCESS && !srv_force_recovery) {
- dict_mem_table_free(table);
- table = NULL;
- } else if (err == DB_SUCCESS) {
+ if (err == DB_SUCCESS) {
err = dict_load_foreigns(table->name, TRUE);
+ } else if (!srv_force_recovery) {
+ dict_table_remove_from_cache(table);
+ table = NULL;
}
# if 0
if (err != DB_SUCCESS && table != NULL) {
diff --git a/dict/dict0mem.c b/dict/dict0mem.c
index 15372d8e261..31c0c23f450 100644
--- a/dict/dict0mem.c
+++ b/dict/dict0mem.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/**********************************************************************
Data dictionary memory object creation
-(c) 1996 Innobase Oy
-
Created 1/8/1996 Heikki Tuuri
***********************************************************************/
@@ -16,8 +32,6 @@ Created 1/8/1996 Heikki Tuuri
#include "data0type.h"
#include "mach0data.h"
#include "dict0dict.h"
-#include "que0que.h"
-#include "pars0pars.h"
#include "lock0lock.h"
#define DICT_HEAP_SIZE 100 /* initial memory heap size when
@@ -84,6 +98,7 @@ dict_mem_table_free(
{
ut_ad(table);
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
+ ut_d(table->cached = FALSE);
mutex_free(&(table->autoinc_mutex));
mem_heap_free(table->heap);
diff --git a/dyn/dyn0dyn.c b/dyn/dyn0dyn.c
index ecb6c27f441..16e82eaed66 100644
--- a/dyn/dyn0dyn.c
+++ b/dyn/dyn0dyn.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
The dynamically allocated array
-(c) 1996 Innobase Oy
-
Created 2/5/1996 Heikki Tuuri
*******************************************************/
diff --git a/eval/eval0eval.c b/eval/eval0eval.c
index 46dd8284c16..a2590c63c38 100644
--- a/eval/eval0eval.c
+++ b/eval/eval0eval.c
@@ -1,9 +1,25 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 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
+
+*****************************************************************************/
+
/******************************************************
SQL evaluator: evaluates simple data structures, like expressions, in
a query graph
-(c) 1997 Innobase Oy
-
Created 12/29/1997 Heikki Tuuri
*******************************************************/
diff --git a/eval/eval0proc.c b/eval/eval0proc.c
index d8b86f689ee..9c7563e8c7d 100644
--- a/eval/eval0proc.c
+++ b/eval/eval0proc.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1998, 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
+
+*****************************************************************************/
+
/******************************************************
Executes SQL stored procedures and their control structures
-(c) 1998 Innobase Oy
-
Created 1/20/1998 Heikki Tuuri
*******************************************************/
diff --git a/fil/fil0fil.c b/fil/fil0fil.c
index ebce7d55ee8..dad045fe067 100644
--- a/fil/fil0fil.c
+++ b/fil/fil0fil.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/******************************************************
The tablespace memory cache
-(c) 1995 Innobase Oy
-
Created 10/25/1995 Heikki Tuuri
*******************************************************/
@@ -18,7 +34,6 @@ Created 10/25/1995 Heikki Tuuri
#include "buf0buf.h"
#include "buf0flu.h"
#include "buf0lru.h"
-#include "log0log.h"
#include "log0recv.h"
#include "fsp0fsp.h"
#include "srv0srv.h"
@@ -191,8 +206,6 @@ struct fil_space_struct {
currently in the list above */
UT_LIST_NODE_T(fil_space_t) space_list;
/* list of all spaces */
- ibuf_data_t* ibuf_data;
- /* insert buffer data */
ulint magic_n;
};
@@ -365,7 +378,9 @@ fil_space_get_by_id(
ut_ad(mutex_own(&fil_system->mutex));
HASH_SEARCH(hash, fil_system->spaces, id,
- fil_space_t*, space, space->id == id);
+ fil_space_t*, space,
+ ut_ad(space->magic_n == FIL_SPACE_MAGIC_N),
+ space->id == id);
return(space);
}
@@ -386,7 +401,9 @@ fil_space_get_by_name(
fold = ut_fold_string(name);
HASH_SEARCH(name_hash, fil_system->name_hash, fold,
- fil_space_t*, space, !strcmp(name, space->name));
+ fil_space_t*, space,
+ ut_ad(space->magic_n == FIL_SPACE_MAGIC_N),
+ !strcmp(name, space->name));
return(space);
}
@@ -475,33 +492,6 @@ fil_space_get_type(
return(space->purpose);
}
-/***********************************************************************
-Returns the ibuf data of a file space. */
-UNIV_INTERN
-ibuf_data_t*
-fil_space_get_ibuf_data(
-/*====================*/
- /* out: ibuf data for this space */
- ulint id) /* in: space id */
-{
- fil_system_t* system = fil_system;
- fil_space_t* space;
-
- ut_ad(system);
-
- ut_a(id == 0);
-
- mutex_enter(&(system->mutex));
-
- space = fil_space_get_by_id(id);
-
- mutex_exit(&(system->mutex));
-
- ut_a(space);
-
- return(space->ibuf_data);
-}
-
/**************************************************************************
Checks if all the file nodes in a space are flushed. The caller must hold
the fil_system mutex. */
@@ -1192,8 +1182,6 @@ try_again:
UT_LIST_INIT(space->chain);
space->magic_n = FIL_SPACE_MAGIC_N;
- space->ibuf_data = NULL;
-
rw_lock_create(&space->latch, SYNC_FSP);
HASH_INSERT(fil_space_t, hash, system->spaces, id, space);
@@ -1681,25 +1669,6 @@ fil_set_max_space_id_if_bigger(
}
/********************************************************************
-Initializes the ibuf data structure for space 0 == the system tablespace.
-This can be called after the file space headers have been created and the
-dictionary system has been initialized. */
-UNIV_INTERN
-void
-fil_ibuf_init_at_db_start(void)
-/*===========================*/
-{
- fil_space_t* space;
-
- space = UT_LIST_GET_FIRST(fil_system->space_list);
-
- ut_a(space);
- ut_a(space->purpose == FIL_TABLESPACE);
-
- space->ibuf_data = ibuf_data_init_for_space(space->id);
-}
-
-/********************************************************************
Writes the flushed lsn and the latest archived log number to the page header
of the first page of a data file of the system tablespace (space 0),
which is uncompressed. */
@@ -1725,6 +1694,8 @@ fil_write_lsn_and_arch_no_to_file(
fil_write(TRUE, 0, 0, sum_of_sizes, 0, UNIV_PAGE_SIZE, buf, NULL);
+ mem_free(buf1);
+
return(DB_SUCCESS);
}
@@ -4313,14 +4284,15 @@ fil_io(
|| !ibuf_bitmap_page(zip_size, block_offset)
|| sync || is_log);
ut_ad(!ibuf_inside() || is_log || (type == OS_FILE_WRITE)
- || ibuf_page(space_id, zip_size, block_offset));
+ || ibuf_page(space_id, zip_size, block_offset, NULL));
#endif
if (sync) {
mode = OS_AIO_SYNC;
} else if (is_log) {
mode = OS_AIO_LOG;
} else if (type == OS_FILE_READ
- && ibuf_page(space_id, zip_size, block_offset)) {
+ && !recv_no_ibuf_operations
+ && ibuf_page(space_id, zip_size, block_offset, NULL)) {
mode = OS_AIO_IBUF;
} else {
mode = OS_AIO_NORMAL;
diff --git a/fsp/fsp0fsp.c b/fsp/fsp0fsp.c
index a2cc4695205..25d260daeea 100644
--- a/fsp/fsp0fsp.c
+++ b/fsp/fsp0fsp.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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 space management
-(c) 1995 Innobase Oy
-
Created 11/29/1995 Heikki Tuuri
***********************************************************************/
@@ -2211,8 +2227,8 @@ fseg_create_general(
/* This thread did not own the latch before this call: free
excess pages from the insert buffer free list */
- if (space == 0) {
- ibuf_free_excess_pages(0);
+ if (space == IBUF_SPACE_ID) {
+ ibuf_free_excess_pages();
}
}
@@ -2788,8 +2804,8 @@ fseg_alloc_free_page_general(
/* This thread did not own the latch before this call: free
excess pages from the insert buffer free list */
- if (space == 0) {
- ibuf_free_excess_pages(0);
+ if (space == IBUF_SPACE_ID) {
+ ibuf_free_excess_pages();
}
}
diff --git a/fut/fut0fut.c b/fut/fut0fut.c
index 7f7a8fa39e7..41ee0cb6715 100644
--- a/fut/fut0fut.c
+++ b/fut/fut0fut.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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-based utilities
-(c) 1995 Innobase Oy
-
Created 12/13/1995 Heikki Tuuri
***********************************************************************/
diff --git a/fut/fut0lst.c b/fut/fut0lst.c
index ed78b71220d..bea27ab70d1 100644
--- a/fut/fut0lst.c
+++ b/fut/fut0lst.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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-based list utilities
-(c) 1995 Innobase Oy
-
Created 11/28/1995 Heikki Tuuri
***********************************************************************/
diff --git a/ha/ha0ha.c b/ha/ha0ha.c
index 78027d9785b..1ecba3df663 100644
--- a/ha/ha0ha.c
+++ b/ha/ha0ha.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/************************************************************************
The hash table with external chains
-(c) 1994-1997 Innobase Oy
-
Created 8/22/1994 Heikki Tuuri
*************************************************************************/
@@ -40,9 +56,9 @@ ha_create_func(
table = hash_create(n);
-#ifdef UNIV_DEBUG
+#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
table->adaptive = TRUE;
-#endif /* UNIV_DEBUG */
+#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
/* Creating MEM_HEAP_BTR_SEARCH type heaps can potentially fail,
but in practise it never should in this case, hence the asserts. */
@@ -111,9 +127,9 @@ ha_insert_for_fold_func(
the same fold value already exists, it is
updated to point to the same data, and no new
node is created! */
-#ifdef UNIV_DEBUG
+#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
buf_block_t* block, /* in: buffer block containing the data */
-#endif /* UNIV_DEBUG */
+#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
void* data) /* in: data, must not be NULL */
{
hash_cell_t* cell;
@@ -122,7 +138,9 @@ ha_insert_for_fold_func(
ulint hash;
ut_ad(table && data);
- ut_ad(block->frame == page_align(data));
+#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
+ ut_a(block->frame == page_align(data));
+#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
ut_ad(!table->mutexes || mutex_own(hash_get_mutex(table, fold)));
hash = hash_calc_hash(fold, table);
@@ -133,7 +151,7 @@ ha_insert_for_fold_func(
while (prev_node != NULL) {
if (prev_node->fold == fold) {
-#ifdef UNIV_DEBUG
+#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
if (table->adaptive) {
buf_block_t* prev_block = prev_node->block;
ut_a(prev_block->frame
@@ -144,7 +162,7 @@ ha_insert_for_fold_func(
}
prev_node->block = block;
-#endif /* UNIV_DEBUG */
+#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
prev_node->data = data;
return(TRUE);
@@ -168,11 +186,11 @@ ha_insert_for_fold_func(
ha_node_set_data(node, block, data);
-#ifdef UNIV_DEBUG
+#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
if (table->adaptive) {
block->n_pointers++;
}
-#endif /* UNIV_DEBUG */
+#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
node->fold = fold;
node->next = NULL;
@@ -205,13 +223,13 @@ ha_delete_hash_node(
hash_table_t* table, /* in: hash table */
ha_node_t* del_node) /* in: node to be deleted */
{
-#ifdef UNIV_DEBUG
+#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
if (table->adaptive) {
ut_a(del_node->block->frame = page_align(del_node->data));
ut_a(del_node->block->n_pointers > 0);
del_node->block->n_pointers--;
}
-#endif /* UNIV_DEBUG */
+#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
HASH_DELETE_AND_COMPACT(ha_node_t, next, table, del_node);
}
@@ -247,20 +265,22 @@ ha_search_and_update_if_found_func(
hash_table_t* table, /* in: hash table */
ulint fold, /* in: folded value of the searched data */
void* data, /* in: pointer to the data */
-#ifdef UNIV_DEBUG
+#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
buf_block_t* new_block,/* in: block containing new_data */
-#endif
+#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
void* new_data)/* in: new pointer to the data */
{
ha_node_t* node;
ut_ad(!table->mutexes || mutex_own(hash_get_mutex(table, fold)));
- ut_ad(new_block->frame == page_align(new_data));
+#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
+ ut_a(new_block->frame == page_align(new_data));
+#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
node = ha_search_with_data(table, fold, data);
if (node) {
-#ifdef UNIV_DEBUG
+#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
if (table->adaptive) {
ut_a(node->block->n_pointers > 0);
node->block->n_pointers--;
@@ -268,7 +288,7 @@ ha_search_and_update_if_found_func(
}
node->block = new_block;
-#endif /* UNIV_DEBUG */
+#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
node->data = new_data;
}
}
diff --git a/ha/ha0storage.c b/ha/ha0storage.c
index ca2e644954c..e7e09591193 100644
--- a/ha/ha0storage.c
+++ b/ha/ha0storage.c
@@ -1,10 +1,26 @@
+/*****************************************************************************
+
+Copyright (c) 2007, 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
+
+*****************************************************************************/
+
/******************************************************
Hash storage.
Provides a data structure that stores chunks of data in
its own storage, avoiding duplicates.
-(c) 2007 Innobase Oy
-
Created September 22, 2007 Vasil Dimov
*******************************************************/
@@ -45,6 +61,7 @@ ha_storage_get(
fold, /* key */
ha_storage_node_t*, /* type of node->next */
node, /* auxiliary variable */
+ , /* assertion */
IS_FOUND); /* search criteria */
if (node == NULL) {
diff --git a/ha/hash0hash.c b/ha/hash0hash.c
index 0587bb37495..9694a288c99 100644
--- a/ha/hash0hash.c
+++ b/ha/hash0hash.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 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
+
+*****************************************************************************/
+
/******************************************************
The simple hash table utility
-(c) 1997 Innobase Oy
-
Created 5/20/1997 Heikki Tuuri
*******************************************************/
@@ -89,9 +105,9 @@ hash_create(
array = ut_malloc(sizeof(hash_cell_t) * prime);
-#ifdef UNIV_DEBUG
+#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
table->adaptive = FALSE;
-#endif /* UNIV_DEBUG */
+#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
table->array = array;
table->n_cells = prime;
table->n_mutexes = 0;
diff --git a/handler/ha_innodb.cc b/handler/ha_innodb.cc
index fadc0ecc314..38a0ef0df05 100644
--- a/handler/ha_innodb.cc
+++ b/handler/ha_innodb.cc
@@ -1,17 +1,27 @@
-/* Copyright (C) 2000-2005 MySQL AB & Innobase Oy
+/*****************************************************************************
+
+Copyright (c) 2000, 2009, MySQL AB & Innobase Oy. All Rights Reserved.
+Copyright (c) 2008, Google Inc.
+
+Portions of this file contain modifications contributed and copyrighted by
+Google, Inc. Those modifications are gratefully acknowledged and are described
+briefly in the InnoDB documentation. The contributions by Google are
+incorporated with their permission, and subject to the conditions contained in
+the file COPYING.Google.
+
+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 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.
- 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
- 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 */
+*****************************************************************************/
/* TODO list for the InnoDB handler in 5.0:
- Remove the flag trx->active_trans and look at trx->conc_state
@@ -26,13 +36,9 @@
#endif
#include <mysql_priv.h>
-#include <mysqld_error.h>
#include <m_ctype.h>
-#include <hash.h>
-#include <myisampack.h>
#include <mysys_err.h>
-#include <my_sys.h>
#include <mysql/plugin.h>
/* Include necessary InnoDB headers */
@@ -65,12 +71,12 @@ extern "C" {
#include "../storage/innobase/include/dict0boot.h"
#include "../storage/innobase/include/ha_prototypes.h"
#include "../storage/innobase/include/ut0mem.h"
+#include "../storage/innobase/include/ibuf0ibuf.h"
}
#include "ha_innodb.h"
#include "i_s.h"
#include "handler0vars.h"
-#include "mysql_addons.h"
#ifndef MYSQL_SERVER
/* This is needed because of Bug #3596. Let us hope that pthread_mutex_t
@@ -147,6 +153,7 @@ static char* innobase_data_home_dir = NULL;
static char* innobase_data_file_path = NULL;
static char* innobase_log_group_home_dir = NULL;
static char* innobase_file_format_name = NULL;
+static char* innobase_change_buffering = NULL;
/* Note: This variable can be set to on/off and any of the supported
file formats in the configuration file, but can only be set to any
@@ -172,7 +179,6 @@ static my_bool innobase_locks_unsafe_for_binlog = FALSE;
static my_bool innobase_rollback_on_timeout = FALSE;
static my_bool innobase_create_status_file = FALSE;
static my_bool innobase_stats_on_metadata = TRUE;
-static my_bool innobase_adaptive_hash_index = TRUE;
static char* internal_innobase_data_file_path = NULL;
@@ -186,14 +192,18 @@ it every INNOBASE_WAKE_INTERVAL'th step. */
#define INNOBASE_WAKE_INTERVAL 32
static ulong innobase_active_counter = 0;
-static HASH innobase_open_tables;
+static hash_table_t* innobase_open_tables;
#ifdef __NETWARE__ /* some special cleanup for NetWare */
bool nw_panic = FALSE;
#endif
-static uchar* innobase_get_key(INNOBASE_SHARE *share, size_t *length,
- my_bool not_used __attribute__((unused)));
+/** Allowed values of innodb_change_buffering */
+static const char* innobase_change_buffering_values[IBUF_USE_COUNT] = {
+ "none", /* IBUF_USE_NONE */
+ "inserts" /* IBUF_USE_INSERT */
+};
+
static INNOBASE_SHARE *get_share(const char *table_name);
static void free_share(INNOBASE_SHARE *share);
static int innobase_close_connection(handlerton *hton, THD* thd);
@@ -464,6 +474,8 @@ static SHOW_VAR innodb_status_variables[]= {
(char*) &export_vars.innodb_dblwr_pages_written, SHOW_LONG},
{"dblwr_writes",
(char*) &export_vars.innodb_dblwr_writes, SHOW_LONG},
+ {"have_atomic_builtins",
+ (char*) &export_vars.innodb_have_atomic_builtins, SHOW_BOOL},
{"log_waits",
(char*) &export_vars.innodb_log_waits, SHOW_LONG},
{"log_write_requests",
@@ -551,7 +563,7 @@ innodb_srv_conc_exit_innodb(
/*========================*/
trx_t* trx) /* in: transaction handle */
{
- if (UNIV_LIKELY(!srv_thread_concurrency)) {
+ if (UNIV_LIKELY(!trx->declared_to_be_inside_innodb)) {
return;
}
@@ -610,15 +622,17 @@ thd_is_select(
}
/**********************************************************************
-Returns true if the thread is executing in innodb_strict_mode. */
+Returns true if the thread supports XA,
+global value of innodb_supports_xa if thd is NULL. */
extern "C" UNIV_INTERN
ibool
-thd_is_strict(
-/*==========*/
- /* out: true if thd is in strict mode */
- void* thd) /* in: thread handle (THD*) */
+thd_supports_xa(
+/*============*/
+ /* out: true if thd has XA support */
+ void* thd) /* in: thread handle (THD*), or NULL to query
+ the global innodb_supports_xa */
{
- return(THDVAR((THD*) thd, strict_mode));
+ return(THDVAR((THD*) thd, support_xa));
}
/**********************************************************************
@@ -1173,6 +1187,12 @@ innobase_next_autoinc(
/* Should never be 0. */
ut_a(increment > 0);
+ /* According to MySQL documentation, if the offset is greater than
+ the increment then the offset is ignored. */
+ if (offset > increment) {
+ offset = 0;
+ }
+
if (max_value <= current) {
next_value = max_value;
} else if (offset <= 1) {
@@ -1219,6 +1239,53 @@ innobase_next_autoinc(
}
/*************************************************************************
+Initializes some fields in an InnoDB transaction object. */
+static
+void
+innobase_trx_init(
+/*==============*/
+ THD* thd, /* in: user thread handle */
+ trx_t* trx) /* in/out: InnoDB transaction handle */
+{
+ DBUG_ENTER("innobase_trx_init");
+ DBUG_ASSERT(EQ_CURRENT_THD(thd));
+ DBUG_ASSERT(thd == trx->mysql_thd);
+
+ trx->check_foreigns = !thd_test_options(
+ thd, OPTION_NO_FOREIGN_KEY_CHECKS);
+
+ trx->check_unique_secondary = !thd_test_options(
+ thd, OPTION_RELAXED_UNIQUE_CHECKS);
+
+ DBUG_VOID_RETURN;
+}
+
+/*************************************************************************
+Allocates an InnoDB transaction for a MySQL handler object. */
+extern "C" UNIV_INTERN
+trx_t*
+innobase_trx_allocate(
+/*==================*/
+ /* out: InnoDB transaction handle */
+ THD* thd) /* in: user thread handle */
+{
+ trx_t* trx;
+
+ DBUG_ENTER("innobase_trx_allocate");
+ DBUG_ASSERT(thd != NULL);
+ DBUG_ASSERT(EQ_CURRENT_THD(thd));
+
+ trx = trx_allocate_for_mysql();
+
+ trx->mysql_thd = thd;
+ trx->mysql_query_str = thd_query(thd);
+
+ innobase_trx_init(thd, trx);
+
+ DBUG_RETURN(trx);
+}
+
+/*************************************************************************
Gets the InnoDB transaction handle for a MySQL handler object, creates
an InnoDB transaction struct if the corresponding MySQL thread struct still
lacks one. */
@@ -1234,34 +1301,13 @@ check_trx_exists(
ut_ad(EQ_CURRENT_THD(thd));
if (trx == NULL) {
- DBUG_ASSERT(thd != NULL);
- trx = trx_allocate_for_mysql();
-
- trx->mysql_thd = thd;
- trx->mysql_query_str = thd_query(thd);
-
- /* Update the info whether we should skip XA steps that eat
- CPU time */
- trx->support_xa = THDVAR(thd, support_xa);
- } else {
- if (trx->magic_n != TRX_MAGIC_N) {
- mem_analyze_corruption(trx);
-
- ut_error;
- }
+ trx = innobase_trx_allocate(thd);
+ } else if (UNIV_UNLIKELY(trx->magic_n != TRX_MAGIC_N)) {
+ mem_analyze_corruption(trx);
+ ut_error;
}
- if (thd_test_options(thd, OPTION_NO_FOREIGN_KEY_CHECKS)) {
- trx->check_foreigns = FALSE;
- } else {
- trx->check_foreigns = TRUE;
- }
-
- if (thd_test_options(thd, OPTION_RELAXED_UNIQUE_CHECKS)) {
- trx->check_unique_secondary = FALSE;
- } else {
- trx->check_unique_secondary = TRUE;
- }
+ innobase_trx_init(thd, trx);
return(trx);
}
@@ -1946,16 +1992,12 @@ innobase_init(
MYF(MY_FAE));
ret = (bool) srv_parse_data_file_paths_and_sizes(
- internal_innobase_data_file_path,
- &srv_data_file_names,
- &srv_data_file_sizes,
- &srv_data_file_is_raw_partition,
- &srv_n_data_files,
- &srv_auto_extend_last_data_file,
- &srv_last_file_size_max);
+ internal_innobase_data_file_path);
if (ret == FALSE) {
sql_print_error(
"InnoDB: syntax error in innodb_data_file_path");
+mem_free_and_error:
+ srv_free_paths_and_sizes();
my_free(internal_innobase_data_file_path,
MYF(MY_ALLOW_ZERO_PTR));
goto error;
@@ -1982,16 +2024,13 @@ innobase_init(
#endif /* UNIG_LOG_ARCHIVE */
ret = (bool)
- srv_parse_log_group_home_dirs(innobase_log_group_home_dir,
- &srv_log_group_home_dirs);
+ srv_parse_log_group_home_dirs(innobase_log_group_home_dir);
if (ret == FALSE || innobase_mirrored_log_groups != 1) {
sql_print_error("syntax error in innodb_log_group_home_dir, or a "
"wrong number of mirrored log groups");
- my_free(internal_innobase_data_file_path,
- MYF(MY_ALLOW_ZERO_PTR));
- goto error;
+ goto mem_free_and_error;
}
/* Validate the file format by animal name */
@@ -2004,9 +2043,7 @@ innobase_init(
sql_print_error("InnoDB: wrong innodb_file_format.");
- my_free(internal_innobase_data_file_path,
- MYF(MY_ALLOW_ZERO_PTR));
- goto error;
+ goto mem_free_and_error;
}
} else {
/* Set it to the default file format id. Though this
@@ -2045,13 +2082,14 @@ innobase_init(
trx_sys_file_format_id_to_name(
DICT_TF_FORMAT_MAX));
- my_free(internal_innobase_data_file_path,
- MYF(MY_ALLOW_ZERO_PTR));
-
- goto error;
+ goto mem_free_and_error;
}
}
+ ut_a((ulint) ibuf_use < UT_ARR_SIZE(innobase_change_buffering_values));
+ innobase_change_buffering = (char*)
+ innobase_change_buffering_values[ibuf_use];
+
/* --------------------------------------------------*/
srv_file_flush_method_str = innobase_unix_file_flush_method;
@@ -2092,8 +2130,6 @@ innobase_init(
srv_max_n_open_files = (ulint) innobase_open_files;
srv_innodb_status = (ibool) innobase_create_status_file;
- btr_search_disabled = (ibool) !innobase_adaptive_hash_index;
-
srv_print_verbose_log = mysqld_embedded ? 0 : 1;
/* Store the default charset-collation number of this MySQL
@@ -2122,13 +2158,10 @@ innobase_init(
err = innobase_start_or_create_for_mysql();
if (err != DB_SUCCESS) {
- my_free(internal_innobase_data_file_path,
- MYF(MY_ALLOW_ZERO_PTR));
- goto error;
+ goto mem_free_and_error;
}
- (void) hash_init(&innobase_open_tables,system_charset_info, 32, 0, 0,
- (hash_get_key) innobase_get_key, 0, 0);
+ innobase_open_tables = hash_create(200);
pthread_mutex_init(&innobase_share_mutex, MY_MUTEX_INIT_FAST);
pthread_mutex_init(&prepare_commit_mutex, MY_MUTEX_INIT_FAST);
pthread_mutex_init(&commit_threads_m, MY_MUTEX_INIT_FAST);
@@ -2172,10 +2205,12 @@ innobase_end(handlerton *hton, ha_panic_function type)
srv_fast_shutdown = (ulint) innobase_fast_shutdown;
innodb_inited = 0;
+ hash_table_free(innobase_open_tables);
+ innobase_open_tables = NULL;
if (innobase_shutdown_for_mysql() != DB_SUCCESS) {
err = 1;
}
- hash_free(&innobase_open_tables);
+ srv_free_paths_and_sizes();
my_free(internal_innobase_data_file_path,
MYF(MY_ALLOW_ZERO_PTR));
pthread_mutex_destroy(&innobase_share_mutex);
@@ -2307,9 +2342,6 @@ innobase_commit(
trx = check_trx_exists(thd);
- /* Update the info whether we should skip XA steps that eat CPU time */
- trx->support_xa = THDVAR(thd, support_xa);
-
/* Since we will reserve the kernel mutex, we have to release
the search system latch first to obey the latching order. */
@@ -2436,9 +2468,6 @@ innobase_rollback(
trx = check_trx_exists(thd);
- /* Update the info whether we should skip XA steps that eat CPU time */
- trx->support_xa = THDVAR(thd, support_xa);
-
/* Release a possible FIFO ticket and search latch. Since we will
reserve the kernel mutex, we have to release the search system latch
first to obey the latching order. */
@@ -3003,6 +3032,8 @@ retry:
prebuilt = row_create_prebuilt(ib_table);
prebuilt->mysql_row_len = table->s->reclength;
+ prebuilt->default_rec = table->s->default_values;
+ ut_ad(prebuilt->default_rec);
/* Looks like MySQL-3.23 sometimes has primary key number != 0 */
@@ -3817,8 +3848,8 @@ build_template(
goto include_field;
}
- if (bitmap_is_set(table->read_set, i) ||
- bitmap_is_set(table->write_set, i)) {
+ if (bitmap_is_set(table->read_set, i) ||
+ bitmap_is_set(table->write_set, i)) {
/* This field is needed in the query */
goto include_field;
@@ -3910,7 +3941,7 @@ skip_field:
}
/************************************************************************
-Get the upper limit of the MySQL integral type. */
+Get the upper limit of the MySQL integral and floating-point type. */
UNIV_INTERN
ulonglong
ha_innobase::innobase_get_int_col_max_value(
@@ -3921,7 +3952,7 @@ ha_innobase::innobase_get_int_col_max_value(
switch(field->key_type()) {
/* TINY */
- case HA_KEYTYPE_BINARY:
+ case HA_KEYTYPE_BINARY:
max_value = 0xFFULL;
break;
case HA_KEYTYPE_INT8:
@@ -3935,7 +3966,7 @@ ha_innobase::innobase_get_int_col_max_value(
max_value = 0x7FFFULL;
break;
/* MEDIUM */
- case HA_KEYTYPE_UINT24:
+ case HA_KEYTYPE_UINT24:
max_value = 0xFFFFFFULL;
break;
case HA_KEYTYPE_INT24:
@@ -3949,12 +3980,20 @@ ha_innobase::innobase_get_int_col_max_value(
max_value = 0x7FFFFFFFULL;
break;
/* BIG */
- case HA_KEYTYPE_ULONGLONG:
+ case HA_KEYTYPE_ULONGLONG:
max_value = 0xFFFFFFFFFFFFFFFFULL;
break;
case HA_KEYTYPE_LONGLONG:
max_value = 0x7FFFFFFFFFFFFFFFULL;
break;
+ case HA_KEYTYPE_FLOAT:
+ /* We use the maximum as per IEEE754-2008 standard, 2^24 */
+ max_value = 0x1000000ULL;
+ break;
+ case HA_KEYTYPE_DOUBLE:
+ /* We use the maximum as per IEEE754-2008 standard, 2^53 */
+ max_value = 0x20000000000000ULL;
+ break;
default:
ut_error;
}
@@ -4082,7 +4121,8 @@ ha_innobase::write_row(
/* out: error code */
uchar* record) /* in: a row in MySQL format */
{
- int error = 0;
+ ulint error = 0;
+ int error_result= 0;
ibool auto_inc_used= FALSE;
ulint sql_command;
trx_t* trx = thd_to_trx(user_thd);
@@ -4192,12 +4232,13 @@ no_commit:
/* We don't want to mask autoinc overflow errors. */
if (prebuilt->autoinc_error != DB_SUCCESS) {
- error = prebuilt->autoinc_error;
+ error = (int) prebuilt->autoinc_error;
goto report_error;
}
/* MySQL errors are passed straight back. */
+ error_result = (int) error;
goto func_exit;
}
@@ -4274,7 +4315,7 @@ no_commit:
will be 0 if get_auto_increment() was not called.*/
if (auto_inc <= col_max_value
- && auto_inc > prebuilt->autoinc_last_value) {
+ && auto_inc >= prebuilt->autoinc_last_value) {
set_max_autoinc:
ut_a(prebuilt->autoinc_increment > 0);
@@ -4290,7 +4331,7 @@ set_max_autoinc:
err = innobase_set_max_autoinc(auto_inc);
if (err != DB_SUCCESS) {
- error = (int) err;
+ error = err;
}
}
break;
@@ -4300,13 +4341,14 @@ set_max_autoinc:
innodb_srv_conc_exit_innodb(prebuilt->trx);
report_error:
- error = convert_error_code_to_mysql(error, prebuilt->table->flags,
- user_thd);
+ error_result = convert_error_code_to_mysql((int) error,
+ prebuilt->table->flags,
+ user_thd);
func_exit:
innobase_active_small();
- DBUG_RETURN(error);
+ DBUG_RETURN(error_result);
}
/**************************************************************************
@@ -4634,7 +4676,8 @@ ha_innobase::unlock_row(void)
switch (prebuilt->row_read_type) {
case ROW_READ_WITH_LOCKS:
if (!srv_locks_unsafe_for_binlog
- || prebuilt->trx->isolation_level == TRX_ISO_READ_COMMITTED) {
+ && prebuilt->trx->isolation_level
+ != TRX_ISO_READ_COMMITTED) {
break;
}
/* fall through */
@@ -5493,9 +5536,19 @@ create_table_def(
charset_no = (ulint)field->charset()->number;
- ut_a(charset_no < 256); /* in data0type.h we assume
- that the number fits in one
- byte */
+ if (UNIV_UNLIKELY(charset_no >= 256)) {
+ /* in data0type.h we assume that the
+ number fits in one byte in prtype */
+ push_warning_printf(
+ (THD*) trx->mysql_thd,
+ MYSQL_ERROR::WARN_LEVEL_ERROR,
+ ER_CANT_CREATE_TABLE,
+ "In InnoDB, charset-collation codes"
+ " must be below 256."
+ " Unsupported code %lu.",
+ (ulong) charset_no);
+ DBUG_RETURN(ER_CANT_CREATE_TABLE);
+ }
}
ut_a(field->type() < 256); /* we assume in dtype_form_prtype()
@@ -5940,18 +5993,7 @@ ha_innobase::create(
trx_search_latch_release_if_reserved(parent_trx);
- trx = trx_allocate_for_mysql();
-
- trx->mysql_thd = thd;
- trx->mysql_query_str = thd_query(thd);
-
- if (thd_test_options(thd, OPTION_NO_FOREIGN_KEY_CHECKS)) {
- trx->check_foreigns = FALSE;
- }
-
- if (thd_test_options(thd, OPTION_RELAXED_UNIQUE_CHECKS)) {
- trx->check_unique_secondary = FALSE;
- }
+ trx = innobase_trx_allocate(thd);
if (lower_case_table_names) {
srv_lower_case_table_names = TRUE;
@@ -5981,40 +6023,21 @@ ha_innobase::create(
if (create_info->key_block_size
|| (create_info->used_fields & HA_CREATE_USED_KEY_BLOCK_SIZE)) {
- switch (create_info->key_block_size) {
- case 1:
- flags = 1 << DICT_TF_ZSSIZE_SHIFT
- | DICT_TF_COMPACT
- | DICT_TF_FORMAT_ZIP
- << DICT_TF_FORMAT_SHIFT;
- break;
- case 2:
- flags = 2 << DICT_TF_ZSSIZE_SHIFT
- | DICT_TF_COMPACT
- | DICT_TF_FORMAT_ZIP
- << DICT_TF_FORMAT_SHIFT;
- break;
- case 4:
- flags = 3 << DICT_TF_ZSSIZE_SHIFT
- | DICT_TF_COMPACT
- | DICT_TF_FORMAT_ZIP
- << DICT_TF_FORMAT_SHIFT;
- break;
- case 8:
- flags = 4 << DICT_TF_ZSSIZE_SHIFT
- | DICT_TF_COMPACT
- | DICT_TF_FORMAT_ZIP
- << DICT_TF_FORMAT_SHIFT;
- break;
- case 16:
- flags = 5 << DICT_TF_ZSSIZE_SHIFT
- | DICT_TF_COMPACT
- | DICT_TF_FORMAT_ZIP
- << DICT_TF_FORMAT_SHIFT;
- break;
-#if DICT_TF_ZSSIZE_MAX != 5
-# error "DICT_TF_ZSSIZE_MAX != 5"
-#endif
+ /* Determine the page_zip.ssize corresponding to the
+ requested page size (key_block_size) in kilobytes. */
+
+ ulint ssize, ksize;
+ ulint key_block_size = create_info->key_block_size;
+
+ for (ssize = ksize = 1; ssize <= DICT_TF_ZSSIZE_MAX;
+ ssize++, ksize <<= 1) {
+ if (key_block_size == ksize) {
+ flags = ssize << DICT_TF_ZSSIZE_SHIFT
+ | DICT_TF_COMPACT
+ | DICT_TF_FORMAT_ZIP
+ << DICT_TF_FORMAT_SHIFT;
+ break;
+ }
}
if (!srv_file_per_table) {
@@ -6066,12 +6089,16 @@ ha_innobase::create(
/* No KEY_BLOCK_SIZE */
if (form->s->row_type == ROW_TYPE_COMPRESSED) {
/* ROW_FORMAT=COMPRESSED without
- KEY_BLOCK_SIZE implies
- KEY_BLOCK_SIZE=8. */
- flags = 4 << DICT_TF_ZSSIZE_SHIFT
+ KEY_BLOCK_SIZE implies half the
+ maximum KEY_BLOCK_SIZE. */
+ flags = (DICT_TF_ZSSIZE_MAX - 1)
+ << DICT_TF_ZSSIZE_SHIFT
| DICT_TF_COMPACT
| DICT_TF_FORMAT_ZIP
- << DICT_TF_FORMAT_SHIFT;
+ << DICT_TF_FORMAT_SHIFT;
+#if DICT_TF_ZSSIZE_MAX < 1
+# error "DICT_TF_ZSSIZE_MAX < 1"
+#endif
}
}
@@ -6372,25 +6399,14 @@ ha_innobase::delete_table(
trx_search_latch_release_if_reserved(parent_trx);
+ trx = innobase_trx_allocate(thd);
+
if (lower_case_table_names) {
srv_lower_case_table_names = TRUE;
} else {
srv_lower_case_table_names = FALSE;
}
- trx = trx_allocate_for_mysql();
-
- trx->mysql_thd = thd;
- trx->mysql_query_str = thd_query(thd);
-
- if (thd_test_options(thd, OPTION_NO_FOREIGN_KEY_CHECKS)) {
- trx->check_foreigns = FALSE;
- }
-
- if (thd_test_options(thd, OPTION_RELAXED_UNIQUE_CHECKS)) {
- trx->check_unique_secondary = FALSE;
- }
-
name_len = strlen(name);
ut_a(name_len < 1000);
@@ -6473,19 +6489,14 @@ innobase_drop_database(
#ifdef __WIN__
innobase_casedn_str(namebuf);
#endif
+#if defined __WIN__ && !defined MYSQL_SERVER
+ /* In the Windows plugin, thd = current_thd is always NULL */
trx = trx_allocate_for_mysql();
- trx->mysql_thd = thd;
- if (thd) {
- trx->mysql_query_str = thd_query(thd);
-
- if (thd_test_options(thd, OPTION_NO_FOREIGN_KEY_CHECKS)) {
- trx->check_foreigns = FALSE;
- }
- } else {
- /* In the Windows plugin, thd = current_thd is always NULL */
- trx->mysql_query_str = NULL;
- }
-
+ trx->mysql_thd = NULL;
+ trx->mysql_query_str = NULL;
+#else
+ trx = innobase_trx_allocate(thd);
+#endif
error = row_drop_database_for_mysql(namebuf, trx);
my_free(namebuf, MYF(0));
@@ -6595,13 +6606,7 @@ ha_innobase::rename_table(
trx_search_latch_release_if_reserved(parent_trx);
- trx = trx_allocate_for_mysql();
- trx->mysql_thd = thd;
- trx->mysql_query_str = thd_query(thd);
-
- if (thd_test_options(thd, OPTION_NO_FOREIGN_KEY_CHECKS)) {
- trx->check_foreigns = FALSE;
- }
+ trx = innobase_trx_allocate(thd);
error = innobase_rename_table(trx, from, to, TRUE);
@@ -6931,11 +6936,13 @@ ha_innobase::info(
n_rows++;
}
- /* Fix bug#29507: TRUNCATE shows too many rows affected.
- Do not show the estimates for TRUNCATE command. */
+ /* Fix bug#40386: Not flushing query cache after truncate.
+ n_rows can not be 0 unless the table is empty, set to 1
+ instead. The original problem of bug#29507 is actually
+ fixed in the server code. */
if (thd_sql_command(user_thd) == SQLCOM_TRUNCATE) {
- n_rows = 0;
+ n_rows = 1;
/* We need to reset the prebuilt value too, otherwise
checks for values greater than the last value written
@@ -7702,12 +7709,12 @@ ha_innobase::external_lock(
READ UNCOMMITTED and READ COMMITTED since the necessary
locks cannot be taken. In this case, we print an
informative error message and return with an error. */
- if (lock_type == F_WRLCK && ib_bin_log_is_engaged(thd))
+ if (lock_type == F_WRLCK)
{
ulong const binlog_format= thd_binlog_format(thd);
ulong const tx_isolation = thd_tx_isolation(ha_thd());
- if (tx_isolation <= ISO_READ_COMMITTED
- && binlog_format == BINLOG_FORMAT_STMT)
+ if (tx_isolation <= ISO_READ_COMMITTED &&
+ binlog_format == BINLOG_FORMAT_STMT)
{
char buf[256];
my_snprintf(buf, sizeof(buf),
@@ -8051,7 +8058,8 @@ innodb_mutex_show_status(
stat_print_fn* stat_print)
{
char buf1[IO_SIZE], buf2[IO_SIZE];
- mutex_t* mutex;
+ mutex_t* mutex;
+ rw_lock_t* lock;
#ifdef UNIV_DEBUG
ulint rw_lock_count= 0;
ulint rw_lock_count_spin_loop= 0;
@@ -8122,6 +8130,29 @@ innodb_mutex_show_status(
mutex_exit(&mutex_list_mutex);
+ mutex_enter(&rw_lock_list_mutex);
+
+ lock = UT_LIST_GET_FIRST(rw_lock_list);
+
+ while (lock != NULL) {
+ if (lock->count_os_wait) {
+ buf1len= my_snprintf(buf1, sizeof(buf1), "%s:%lu",
+ lock->cfile_name, (ulong) lock->cline);
+ buf2len= my_snprintf(buf2, sizeof(buf2),
+ "os_waits=%lu", lock->count_os_wait);
+
+ if (stat_print(thd, innobase_hton_name,
+ hton_name_len, buf1, buf1len,
+ buf2, buf2len)) {
+ mutex_exit(&rw_lock_list_mutex);
+ DBUG_RETURN(1);
+ }
+ }
+ lock = UT_LIST_GET_NEXT(list, lock);
+ }
+
+ mutex_exit(&rw_lock_list_mutex);
+
#ifdef UNIV_DEBUG
buf2len= my_snprintf(buf2, sizeof(buf2),
"count=%lu, spin_waits=%lu, spin_rounds=%lu, "
@@ -8157,44 +8188,38 @@ bool innobase_show_status(handlerton *hton, THD* thd,
}
}
-
/****************************************************************************
Handling the shared INNOBASE_SHARE structure that is needed to provide table
locking.
****************************************************************************/
-static uchar* innobase_get_key(INNOBASE_SHARE* share, size_t *length,
- my_bool not_used __attribute__((unused)))
-{
- *length=share->table_name_length;
-
- return (uchar*) share->table_name;
-}
-
static INNOBASE_SHARE* get_share(const char* table_name)
{
INNOBASE_SHARE *share;
pthread_mutex_lock(&innobase_share_mutex);
- uint length=(uint) strlen(table_name);
- if (!(share=(INNOBASE_SHARE*) hash_search(&innobase_open_tables,
- (uchar*) table_name,
- length))) {
+ ulint fold = ut_fold_string(table_name);
+
+ HASH_SEARCH(table_name_hash, innobase_open_tables, fold,
+ INNOBASE_SHARE*, share,
+ ut_ad(share->use_count > 0),
+ !strcmp(share->table_name, table_name));
+
+ if (!share) {
+
+ uint length = (uint) strlen(table_name);
+
+ /* TODO: invoke HASH_MIGRATE if innobase_open_tables
+ grows too big */
share = (INNOBASE_SHARE *) my_malloc(sizeof(*share)+length+1,
MYF(MY_FAE | MY_ZEROFILL));
- share->table_name_length=length;
- share->table_name=(char*) (share+1);
- strmov(share->table_name,table_name);
-
- if (my_hash_insert(&innobase_open_tables,
- (uchar*) share)) {
- pthread_mutex_unlock(&innobase_share_mutex);
- my_free(share,0);
+ share->table_name = (char*) memcpy(share + 1,
+ table_name, length + 1);
- return(0);
- }
+ HASH_INSERT(INNOBASE_SHARE, table_name_hash,
+ innobase_open_tables, fold, share);
thr_lock_init(&share->lock);
pthread_mutex_init(&share->mutex,MY_MUTEX_INIT_FAST);
@@ -8210,11 +8235,29 @@ static void free_share(INNOBASE_SHARE* share)
{
pthread_mutex_lock(&innobase_share_mutex);
+#ifdef UNIV_DEBUG
+ INNOBASE_SHARE* share2;
+ ulint fold = ut_fold_string(share->table_name);
+
+ HASH_SEARCH(table_name_hash, innobase_open_tables, fold,
+ INNOBASE_SHARE*, share2,
+ ut_ad(share->use_count > 0),
+ !strcmp(share->table_name, share2->table_name));
+
+ ut_a(share2 == share);
+#endif /* UNIV_DEBUG */
+
if (!--share->use_count) {
- hash_delete(&innobase_open_tables, (uchar*) share);
+ ulint fold = ut_fold_string(share->table_name);
+
+ HASH_DELETE(INNOBASE_SHARE, table_name_hash,
+ innobase_open_tables, fold, share);
thr_lock_delete(&share->lock);
pthread_mutex_destroy(&share->mutex);
my_free(share, MYF(0));
+
+ /* TODO: invoke HASH_MIGRATE if innobase_open_tables
+ shrinks too much */
}
pthread_mutex_unlock(&innobase_share_mutex);
@@ -8564,11 +8607,13 @@ ha_innobase::get_auto_increment(
prebuilt->autoinc_last_value = next_value;
- ut_a(prebuilt->autoinc_last_value >= *first_value);
-
- /* Update the table autoinc variable */
- dict_table_autoinc_update_if_greater(
- prebuilt->table, prebuilt->autoinc_last_value);
+ if (prebuilt->autoinc_last_value < *first_value) {
+ *first_value = (~(ulonglong) 0);
+ } else {
+ /* Update the table autoinc variable */
+ dict_table_autoinc_update_if_greater(
+ prebuilt->table, prebuilt->autoinc_last_value);
+ }
} else {
/* This will force write_row() into attempting an update
of the table's AUTOINC counter. */
@@ -8870,7 +8915,10 @@ innobase_xa_prepare(
trx->active_trans = 2;
}
- if (!THDVAR(thd, support_xa)) {
+ /* we use support_xa value as it was seen at transaction start
+ time, not the current session variable value. Any possible changes
+ to the session variable take effect only in the next transaction */
+ if (!trx->support_xa) {
return(0);
}
@@ -9338,6 +9386,94 @@ innodb_file_format_check_update(
}
}
+/********************************************************************
+Update the system variable innodb_adaptive_hash_index using the "saved"
+value. This function is registered as a callback with MySQL. */
+static
+void
+innodb_adaptive_hash_index_update(
+/*==============================*/
+ THD* thd, /* in: thread handle */
+ struct st_mysql_sys_var* var, /* in: pointer to
+ system variable */
+ void* var_ptr, /* out: where the
+ formal string goes */
+ const void* save) /* in: immediate result
+ from check function */
+{
+ if (*(my_bool*) save) {
+ btr_search_enable();
+ } else {
+ btr_search_disable();
+ }
+}
+
+/*****************************************************************
+Check if it is a valid value of innodb_change_buffering. This function is
+registered as a callback with MySQL. */
+static
+int
+innodb_change_buffering_validate(
+/*=============================*/
+ /* out: 0 for valid
+ innodb_change_buffering */
+ THD* thd, /* in: thread handle */
+ struct st_mysql_sys_var* var, /* in: pointer to system
+ variable */
+ void* save, /* out: immediate result
+ for update function */
+ struct st_mysql_value* value) /* in: incoming string */
+{
+ const char* change_buffering_input;
+ char buff[STRING_BUFFER_USUAL_SIZE];
+ int len = sizeof(buff);
+
+ ut_a(save != NULL);
+ ut_a(value != NULL);
+
+ change_buffering_input = value->val_str(value, buff, &len);
+
+ if (change_buffering_input != NULL) {
+ ulint use;
+
+ for (use = 0; use < UT_ARR_SIZE(innobase_change_buffering_values);
+ use++) {
+ if (!innobase_strcasecmp(
+ change_buffering_input,
+ innobase_change_buffering_values[use])) {
+ *(ibuf_use_t*) save = (ibuf_use_t) use;
+ return(0);
+ }
+ }
+ }
+
+ return(1);
+}
+
+/********************************************************************
+Update the system variable innodb_change_buffering using the "saved"
+value. This function is registered as a callback with MySQL. */
+static
+void
+innodb_change_buffering_update(
+/*===========================*/
+ THD* thd, /* in: thread handle */
+ struct st_mysql_sys_var* var, /* in: pointer to
+ system variable */
+ void* var_ptr, /* out: where the
+ formal string goes */
+ const void* save) /* in: immediate result
+ from check function */
+{
+ ut_a(var_ptr != NULL);
+ ut_a(save != NULL);
+ ut_a((*(ibuf_use_t*) save) < IBUF_USE_COUNT);
+
+ ibuf_use = *(const ibuf_use_t*) save;
+
+ *(const char**) var_ptr = innobase_change_buffering_values[ibuf_use];
+}
+
static int show_innodb_vars(THD *thd, SHOW_VAR *var, char *buff)
{
innodb_export_status();
@@ -9479,11 +9615,11 @@ static MYSQL_SYSVAR_ULONGLONG(stats_sample_pages, srv_stats_sample_pages,
"The number of index pages to sample when calculating statistics (default 8)",
NULL, NULL, 8, 1, ~0ULL, 0);
-static MYSQL_SYSVAR_BOOL(adaptive_hash_index, innobase_adaptive_hash_index,
- PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
+static MYSQL_SYSVAR_BOOL(adaptive_hash_index, btr_search_enabled,
+ PLUGIN_VAR_OPCMDARG,
"Enable InnoDB adaptive hash index (enabled by default). "
"Disable with --skip-innodb-adaptive-hash-index.",
- NULL, NULL, TRUE);
+ NULL, innodb_adaptive_hash_index_update, TRUE);
static MYSQL_SYSVAR_ULONG(replication_delay, srv_replication_delay,
PLUGIN_VAR_RQCMDARG,
@@ -9559,7 +9695,7 @@ static MYSQL_SYSVAR_ULONG(sync_spin_loops, srv_n_spin_wait_rounds,
static MYSQL_SYSVAR_ULONG(thread_concurrency, srv_thread_concurrency,
PLUGIN_VAR_RQCMDARG,
"Helps in performance tuning in heavily concurrent environments. Sets the maximum number of threads allowed inside InnoDB. Value 0 will disable the thread throttling.",
- NULL, NULL, 8, 0, 1000, 0);
+ NULL, NULL, 0, 0, 1000, 0);
static MYSQL_SYSVAR_ULONG(thread_sleep_delay, srv_thread_sleep_delay,
PLUGIN_VAR_RQCMDARG,
@@ -9587,6 +9723,18 @@ static MYSQL_SYSVAR_STR(version, innodb_version_str,
PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_READONLY,
"Percona-InnoDB-plugin version", NULL, NULL, INNODB_VERSION_STR);
+static MYSQL_SYSVAR_BOOL(use_sys_malloc, srv_use_sys_malloc,
+ PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
+ "Use OS memory allocator instead of InnoDB's internal memory allocator",
+ NULL, NULL, TRUE);
+
+static MYSQL_SYSVAR_STR(change_buffering, innobase_change_buffering,
+ PLUGIN_VAR_RQCMDARG,
+ "Buffer changes to reduce random access: "
+ "OFF, ON, inserting, deleting, changing, or purging.",
+ innodb_change_buffering_validate,
+ innodb_change_buffering_update, NULL);
+
static MYSQL_SYSVAR_ULONG(io_capacity, srv_io_capacity,
PLUGIN_VAR_RQCMDARG,
"Number of IO operations per second the server can do. Tunes background IO rate.",
@@ -9730,6 +9878,8 @@ static struct st_mysql_sys_var* innobase_system_variables[]= {
MYSQL_SYSVAR(read_io_threads),
MYSQL_SYSVAR(write_io_threads),
MYSQL_SYSVAR(extra_rsegments),
+ MYSQL_SYSVAR(use_sys_malloc),
+ MYSQL_SYSVAR(change_buffering),
NULL
};
diff --git a/handler/ha_innodb.h b/handler/ha_innodb.h
index dbb24e99901..c08dd3ed173 100644
--- a/handler/ha_innodb.h
+++ b/handler/ha_innodb.h
@@ -1,17 +1,20 @@
-/* Copyright (C) 2000-2005 MySQL AB && Innobase Oy
+/*****************************************************************************
- 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.
+Copyright (c) 2000, 2009, MySQL AB & Innobase Oy. All Rights Reserved.
- 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.
+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.
- 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 */
+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
+
+*****************************************************************************/
/*
This file is based on ha_berkeley.h of MySQL distribution
@@ -27,8 +30,9 @@
typedef struct st_innobase_share {
THR_LOCK lock;
pthread_mutex_t mutex;
- char *table_name;
- uint table_name_length,use_count;
+ const char* table_name;
+ uint use_count;
+ void* table_name_hash;
} INNOBASE_SHARE;
@@ -268,3 +272,12 @@ convert_error_code_to_mysql(
int error, /* in: InnoDB error code */
ulint flags, /* in: InnoDB table flags, or 0 */
MYSQL_THD thd); /* in: user thread handle or NULL */
+
+/*************************************************************************
+Allocates an InnoDB transaction for a MySQL handler object. */
+extern "C"
+trx_t*
+innobase_trx_allocate(
+/*==================*/
+ /* out: InnoDB transaction handle */
+ MYSQL_THD thd); /* in: user thread handle */
diff --git a/handler/handler0alter.cc b/handler/handler0alter.cc
index 4ffacb8d5e8..1b5466e66eb 100644
--- a/handler/handler0alter.cc
+++ b/handler/handler0alter.cc
@@ -1,7 +1,23 @@
+/*****************************************************************************
+
+Copyright (c) 2005, 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
+
+*****************************************************************************/
+
/******************************************************
Smart ALTER TABLE
-
-(c) 2005-2008 Innobase Oy
*******************************************************/
#include <mysql_priv.h>
@@ -633,12 +649,9 @@ ha_innobase::add_index(
/* Create a background transaction for the operations on
the data dictionary tables. */
- trx = trx_allocate_for_mysql();
+ trx = innobase_trx_allocate(user_thd);
trx_start_if_not_started(trx);
- trx->mysql_thd = user_thd;
- trx->mysql_query_str = thd_query(user_thd);
-
innodb_table = indexed_table
= dict_table_get(prebuilt->table->name, FALSE);
@@ -1125,12 +1138,9 @@ ha_innobase::final_drop_index(
/* Create a background transaction for the operations on
the data dictionary tables. */
- trx = trx_allocate_for_mysql();
+ trx = innobase_trx_allocate(user_thd);
trx_start_if_not_started(trx);
- trx->mysql_thd = user_thd;
- trx->mysql_query_str = thd_query(user_thd);
-
/* Flag this transaction as a dictionary operation, so that
the data dictionary will be locked in crash recovery. */
trx_set_dict_operation(trx, TRX_DICT_OP_INDEX);
diff --git a/handler/handler0vars.h b/handler/handler0vars.h
index 2e34d6ba85e..ea9f305ce66 100644
--- a/handler/handler0vars.h
+++ b/handler/handler0vars.h
@@ -1,8 +1,25 @@
+/*****************************************************************************
+
+Copyright (c) 2008, 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
+
+*****************************************************************************/
+
/***********************************************************************
This file contains accessor functions for dynamic plugin on Windows.
-
-(c) 2008 Innobase Oy
***********************************************************************/
+
#if defined __WIN__ && defined MYSQL_DYNAMIC_PLUGIN
/***********************************************************************
This is a list of externals that can not be resolved by delay loading.
diff --git a/handler/i_s.cc b/handler/i_s.cc
index dbcb65990d4..d2338e9462a 100644
--- a/handler/i_s.cc
+++ b/handler/i_s.cc
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 2007, 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
+
+*****************************************************************************/
+
/******************************************************
InnoDB INFORMATION SCHEMA tables interface to MySQL.
-(c) 2007 Innobase Oy
-
Created July 18, 2007 Vasil Dimov
*******************************************************/
diff --git a/handler/i_s.h b/handler/i_s.h
index eb116bef849..de0e7610646 100644
--- a/handler/i_s.h
+++ b/handler/i_s.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 2007, 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
+
+*****************************************************************************/
+
/******************************************************
InnoDB INFORMATION SCHEMA tables interface to MySQL.
-(c) 2007 Innobase Oy
-
Created July 18, 2007 Vasil Dimov
*******************************************************/
diff --git a/handler/innodb_patch_info.h b/handler/innodb_patch_info.h
index cac31f8678c..4103744ddc4 100644
--- a/handler/innodb_patch_info.h
+++ b/handler/innodb_patch_info.h
@@ -23,14 +23,14 @@ struct innodb_enhancement {
const char *comment;
const char *link;
}innodb_enhancements[] = {
-{"xtradb_show_enhancements","I_S.XTRADB_ENHANCEMENTS","","http://www.percona.com/docs/wiki/percona-xtradb:xtradb_show_enhancements"},
-{"innodb_show_status","Improvements to SHOW INNODB STATUS","Memory information and lock info fixes","http://www.percona.com/docs/wiki/percona-xtradb:innodb_show_status"},
-{"innodb_io","Improvements to InnoDB IO","","http://www.percona.com/docs/wiki/percona-xtradb:innodb_io"},
-{"innodb_rw_lock","InnoDB RW-lock fixes","Useful for 8+ cores SMP systems","http://www.percona.com/docs/wiki/percona-xtradb:innodb_rw_lock"},
-{"innodb_opt_lru_count","Fix of buffer_pool mutex","Decreases contention on buffer_pool mutex on LRU operations","http://www.percona.com/docs/wiki/percona-xtradb:innodb_opt_lru_count"},
-{"innodb_buffer_pool_pages","Information of buffer pool content","","http://www.percona.com/docs/wiki/percona-xtradb:innodb_buffer_pool_pages"},
-{"innodb_split_buf_pool_mutex","More fix of buffer_pool mutex","Spliting buf_pool_mutex and optimizing based on innodb_opt_lru_count","http://www.percona.com/docs/wiki/percona-xtradb:innodb_split_buf_pool_mutex"},
-{"innodb_expand_undo_slots","expandable maximum number of undo slots","from 1024 (default) to about 4000","http://www.percona.com/docs/wiki/percona-xtradb:innodb_expand_undo_slots"},
-{"innodb_extra_rseg","allow to create extra rollback segments","When create new db, the new parameter allows to create more rollback segments","http://www.percona.com/docs/wiki/percona-xtradb:innodb_extra_rseg"},
+{"xtradb_show_enhancements","I_S.XTRADB_ENHANCEMENTS","","http://www.percona.com/docs/wiki/percona-xtradb"},
+{"innodb_show_status","Improvements to SHOW INNODB STATUS","Memory information and lock info fixes","http://www.percona.com/docs/wiki/percona-xtradb"},
+{"innodb_io","Improvements to InnoDB IO","","http://www.percona.com/docs/wiki/percona-xtradb"},
+{"innodb_rw_lock","InnoDB RW-lock fixes","Useful for 8+ cores SMP systems","http://www.percona.com/docs/wiki/percona-xtradb"},
+{"innodb_opt_lru_count","Fix of buffer_pool mutex","Decreases contention on buffer_pool mutex on LRU operations","http://www.percona.com/docs/wiki/percona-xtradb"},
+{"innodb_buffer_pool_pages","Information of buffer pool content","","http://www.percona.com/docs/wiki/percona-xtradb"},
+{"innodb_split_buf_pool_mutex","More fix of buffer_pool mutex","Spliting buf_pool_mutex and optimizing based on innodb_opt_lru_count","http://www.percona.com/docs/wiki/percona-xtradb"},
+{"innodb_expand_undo_slots","expandable maximum number of undo slots","from 1024 (default) to about 4000","http://www.percona.com/docs/wiki/percona-xtradb"},
+{"innodb_extra_rseg","allow to create extra rollback segments","When create new db, the new parameter allows to create more rollback segments","http://www.percona.com/docs/wiki/percona-xtradb"},
{NULL, NULL, NULL, NULL}
};
diff --git a/handler/mysql_addons.cc b/handler/mysql_addons.cc
index 6dfdf6ced76..a5d9c82c3e3 100644
--- a/handler/mysql_addons.cc
+++ b/handler/mysql_addons.cc
@@ -1,3 +1,21 @@
+/*****************************************************************************
+
+Copyright (c) 2007, 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
+
+*****************************************************************************/
+
/******************************************************
This file contains functions that need to be added to
MySQL code but have not been added yet.
@@ -10,8 +28,6 @@ function in this file.
When MySQL commits the function it can be deleted from
here. In a perfect world this file exists but is empty.
-(c) 2007 Innobase Oy
-
Created November 07, 2007 Vasil Dimov
*******************************************************/
@@ -23,29 +39,3 @@ Created November 07, 2007 Vasil Dimov
#include "mysql_addons.h"
#include "univ.i"
-
-/***********************************************************************
-Retrieve THD::thread_id
-http://bugs.mysql.com/30930 */
-extern "C" UNIV_INTERN
-unsigned long
-ib_thd_get_thread_id(
-/*=================*/
- /* out: THD::thread_id */
- const void* thd) /* in: THD */
-{
- return((unsigned long) ((THD*) thd)->thread_id);
-}
-
-/* http://bugs.mysql.com/40360 */
-/* http://lists.mysql.com/commits/57450 */
-/**
- See if the binary log is engaged for a thread, i.e., open and
- LOG_BIN is set.
-
- @return @c true if the binlog is active, @c false otherwise.
-*/
-my_bool ib_bin_log_is_engaged(const MYSQL_THD thd)
-{
- return mysql_bin_log.is_open() && (thd->options & OPTION_BIN_LOG);
-}
diff --git a/handler/win_delay_loader.cc b/handler/win_delay_loader.cc
index 8b69f4a6e51..1572df42e30 100644
--- a/handler/win_delay_loader.cc
+++ b/handler/win_delay_loader.cc
@@ -1,3 +1,21 @@
+/*****************************************************************************
+
+Copyright (c) 2008, 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
+
+*****************************************************************************/
+
/***********************************************************************
This file contains functions that implement the delay loader on Windows.
@@ -18,8 +36,6 @@ Several acronyms used by Microsoft:
See http://msdn.microsoft.com/en-us/magazine/bb985992.aspx for details of
PE format.
-
-(c) 2008 Innobase Oy
***********************************************************************/
#if defined (__WIN__) && defined (MYSQL_DYNAMIC_PLUGIN)
# define WIN32_LEAN_AND_MEAN
@@ -453,6 +469,7 @@ wdl_get_procaddr_from_map(
map_fold,
map_hash_chain_t*,
hash_chain,
+ ,
(ut_strcmp(hash_chain->symbol, import_proc) == 0));
if (hash_chain == NULL) {
@@ -472,6 +489,7 @@ wdl_get_procaddr_from_map(
map_fold,
map_hash_chain_t*,
hash_chain,
+ ,
(ut_strcmp(hash_chain->symbol, import_proc) == 0));
if (hash_chain == NULL) {
@@ -515,6 +533,7 @@ wdl_get_varaddr_from_map(
map_fold,
map_hash_chain_t*,
hash_chain,
+ ,
(ut_strcmp(hash_chain->symbol, import_variable) == 0));
if (hash_chain == NULL) {
@@ -534,6 +553,7 @@ wdl_get_varaddr_from_map(
map_fold,
map_hash_chain_t*,
hash_chain,
+ ,
(ut_strcmp(hash_chain->symbol, import_variable) == 0));
if (hash_chain == NULL) {
diff --git a/ibuf/ibuf0ibuf.c b/ibuf/ibuf0ibuf.c
index 724aeef37dc..69ddc78427e 100644
--- a/ibuf/ibuf0ibuf.c
+++ b/ibuf/ibuf0ibuf.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 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
+
+*****************************************************************************/
+
/******************************************************
Insert buffer
-(c) 1997 Innobase Oy
-
Created 7/19/1997 Heikki Tuuri
*******************************************************/
@@ -137,17 +153,21 @@ access order rules. */
/* Buffer pool size per the maximum insert buffer size */
#define IBUF_POOL_SIZE_PER_MAX_SIZE 2
-/* The insert buffer control structure */
-UNIV_INTERN ibuf_t* ibuf = NULL;
+/* Table name for the insert buffer. */
+#define IBUF_TABLE_NAME "SYS_IBUF_TABLE"
+
+/** Operations that can currently be buffered. */
+UNIV_INTERN ibuf_use_t ibuf_use = IBUF_USE_INSERT;
-static ulint ibuf_rnd = 986058871;
+/** The insert buffer control structure */
+UNIV_INTERN ibuf_t* ibuf = NULL;
UNIV_INTERN ulint ibuf_flush_count = 0;
#ifdef UNIV_IBUF_COUNT_DEBUG
/* Dimensions for the ibuf_count array */
-#define IBUF_COUNT_N_SPACES 500
-#define IBUF_COUNT_N_PAGES 2000
+#define IBUF_COUNT_N_SPACES 4
+#define IBUF_COUNT_N_PAGES 130000
/* Buffered entry counts for file pages, used in debugging */
static ulint ibuf_counts[IBUF_COUNT_N_SPACES][IBUF_COUNT_N_PAGES];
@@ -230,15 +250,6 @@ because ibuf merge is done to a page when it is read in, and it is
still physically like the index page even if the index would have been
dropped! So, there seems to be no problem. */
-#ifdef UNIV_DEBUG
-/**********************************************************************
-Validates the ibuf data structures when the caller owns ibuf_mutex. */
-static
-ibool
-ibuf_validate_low(void);
-/*===================*/
- /* out: TRUE if ok */
-#endif /* UNIV_DEBUG */
/**********************************************************************
Sets the flag in the current OS thread local storage denoting that it is
inside an insert buffer routine. */
@@ -293,17 +304,14 @@ page_t*
ibuf_header_page_get(
/*=================*/
/* out: insert buffer header page */
- ulint space, /* in: space id */
mtr_t* mtr) /* in: mtr */
{
buf_block_t* block;
- ut_a(space == 0);
-
ut_ad(!ibuf_inside());
- block = buf_page_get(space, 0, FSP_IBUF_HEADER_PAGE_NO,
- RW_X_LATCH, mtr);
+ block = buf_page_get(
+ IBUF_SPACE_ID, 0, FSP_IBUF_HEADER_PAGE_NO, RW_X_LATCH, mtr);
buf_block_dbg_add_level(block, SYNC_IBUF_HEADER);
return(buf_block_get_frame(block));
@@ -316,19 +324,17 @@ page_t*
ibuf_tree_root_get(
/*===============*/
/* out: insert buffer tree root page */
- ibuf_data_t* data, /* in: ibuf data */
- ulint space, /* in: space id */
mtr_t* mtr) /* in: mtr */
{
buf_block_t* block;
- ut_a(space == 0);
ut_ad(ibuf_inside());
- mtr_x_lock(dict_index_get_lock(data->index), mtr);
+ mtr_x_lock(dict_index_get_lock(ibuf->index), mtr);
+
+ block = buf_page_get(
+ IBUF_SPACE_ID, 0, FSP_IBUF_TREE_ROOT_PAGE_NO, RW_X_LATCH, mtr);
- block = buf_page_get(space, 0, FSP_IBUF_TREE_ROOT_PAGE_NO, RW_X_LATCH,
- mtr);
buf_block_dbg_add_level(block, SYNC_TREE_NODE);
return(buf_block_get_frame(block));
@@ -369,118 +375,72 @@ ibuf_count_set(
#endif
/**********************************************************************
-Creates the insert buffer data structure at a database startup and initializes
-the data structures for the insert buffer. */
-UNIV_INTERN
-void
-ibuf_init_at_db_start(void)
-/*=======================*/
-{
- ibuf = mem_alloc(sizeof(ibuf_t));
-
- /* Note that also a pessimistic delete can sometimes make a B-tree
- grow in size, as the references on the upper levels of the tree can
- change */
-
- ibuf->max_size = ut_min( buf_pool_get_curr_size() / UNIV_PAGE_SIZE
- / IBUF_POOL_SIZE_PER_MAX_SIZE, (ulint) srv_ibuf_max_size / UNIV_PAGE_SIZE);
-
- srv_ibuf_max_size = (long long) ibuf->max_size * UNIV_PAGE_SIZE;
-
- UT_LIST_INIT(ibuf->data_list);
-
- ibuf->size = 0;
-
- mutex_create(&ibuf_pessimistic_insert_mutex,
- SYNC_IBUF_PESS_INSERT_MUTEX);
-
- mutex_create(&ibuf_mutex, SYNC_IBUF_MUTEX);
-
- mutex_create(&ibuf_bitmap_mutex, SYNC_IBUF_BITMAP_MUTEX);
-
- fil_ibuf_init_at_db_start();
-}
-
-/**********************************************************************
-Updates the size information in an ibuf data, assuming the segment size has
-not changed. */
+Updates the size information of the ibuf, assuming the segment size has not
+changed. */
static
void
-ibuf_data_sizes_update(
-/*===================*/
- ibuf_data_t* data, /* in: ibuf data struct */
+ibuf_size_update(
+/*=============*/
const page_t* root, /* in: ibuf tree root */
mtr_t* mtr) /* in: mtr */
{
- ulint old_size;
-
ut_ad(mutex_own(&ibuf_mutex));
- old_size = data->size;
-
- data->free_list_len = flst_get_len(root + PAGE_HEADER
+ ibuf->free_list_len = flst_get_len(root + PAGE_HEADER
+ PAGE_BTR_IBUF_FREE_LIST, mtr);
- data->height = 1 + btr_page_get_level(root, mtr);
+ ibuf->height = 1 + btr_page_get_level(root, mtr);
- data->size = data->seg_size - (1 + data->free_list_len);
/* the '1 +' is the ibuf header page */
- ut_ad(data->size < data->seg_size);
+ ibuf->size = ibuf->seg_size - (1 + ibuf->free_list_len);
- if (page_get_n_recs(root) == 0) {
-
- data->empty = TRUE;
- } else {
- data->empty = FALSE;
- }
-
- ut_ad(ibuf->size + data->size >= old_size);
-
- ibuf->size = ibuf->size + data->size - old_size;
-
-#if 0
- fprintf(stderr, "ibuf size %lu, space ibuf size %lu\n",
- ibuf->size, data->size);
-#endif
+ ibuf->empty = page_get_n_recs(root) == 0;
}
/**********************************************************************
-Creates the insert buffer data struct for a single tablespace. Reads the
-root page of the insert buffer tree in the tablespace. This function can
-be called only after the dictionary system has been initialized, as this
-creates also the insert buffer table and index into this tablespace. */
+Creates the insert buffer data structure at a database startup and initializes
+the data structures for the insert buffer. */
UNIV_INTERN
-ibuf_data_t*
-ibuf_data_init_for_space(
-/*=====================*/
- /* out, own: ibuf data struct, linked to the list
- in ibuf control structure */
- ulint space) /* in: space id */
+void
+ibuf_init_at_db_start(void)
+/*=======================*/
{
- ibuf_data_t* data;
page_t* root;
- page_t* header_page;
mtr_t mtr;
- char* buf;
- mem_heap_t* heap;
dict_table_t* table;
+ mem_heap_t* heap;
dict_index_t* index;
ulint n_used;
+ page_t* header_page;
ulint error;
- ut_a(space == 0);
+ ibuf = mem_alloc(sizeof(ibuf_t));
+
+ memset(ibuf, 0, sizeof(*ibuf));
- data = mem_alloc(sizeof(ibuf_data_t));
+ /* Note that also a pessimistic delete can sometimes make a B-tree
+ grow in size, as the references on the upper levels of the tree can
+ change */
- data->space = space;
+ ibuf->max_size = ut_min( buf_pool_get_curr_size() / UNIV_PAGE_SIZE
+ / IBUF_POOL_SIZE_PER_MAX_SIZE, (ulint) srv_ibuf_max_size / UNIV_PAGE_SIZE);
+
+ srv_ibuf_max_size = (long long) ibuf->max_size * UNIV_PAGE_SIZE;
+
+ mutex_create(&ibuf_pessimistic_insert_mutex,
+ SYNC_IBUF_PESS_INSERT_MUTEX);
+
+ mutex_create(&ibuf_mutex, SYNC_IBUF_MUTEX);
+
+ mutex_create(&ibuf_bitmap_mutex, SYNC_IBUF_BITMAP_MUTEX);
mtr_start(&mtr);
mutex_enter(&ibuf_mutex);
- mtr_x_lock(fil_space_get_latch(space, NULL), &mtr);
+ mtr_x_lock(fil_space_get_latch(IBUF_SPACE_ID, NULL), &mtr);
- header_page = ibuf_header_page_get(space, &mtr);
+ header_page = ibuf_header_page_get(&mtr);
fseg_n_reserved_pages(header_page + IBUF_HEADER + IBUF_TREE_SEG_HEADER,
&n_used, &mtr);
@@ -488,32 +448,20 @@ ibuf_data_init_for_space(
ut_ad(n_used >= 2);
- data->seg_size = n_used;
+ ibuf->seg_size = n_used;
{
- buf_block_t* block = buf_page_get(
- space, 0, FSP_IBUF_TREE_ROOT_PAGE_NO,
+ buf_block_t* block;
+
+ block = buf_page_get(
+ IBUF_SPACE_ID, 0, FSP_IBUF_TREE_ROOT_PAGE_NO,
RW_X_LATCH, &mtr);
buf_block_dbg_add_level(block, SYNC_TREE_NODE);
root = buf_block_get_frame(block);
}
- data->size = 0;
- data->n_inserts = 0;
- data->n_merges = 0;
- data->n_merged_recs = 0;
-
- ibuf_data_sizes_update(data, root, &mtr);
- /*
- if (!data->empty) {
- fprintf(stderr,
- "InnoDB: index entries found in the insert buffer\n");
- } else {
- fprintf(stderr,
- "InnoDB: insert buffer empty\n");
- }
- */
+ ibuf_size_update(root, &mtr);
mutex_exit(&ibuf_mutex);
mtr_commit(&mtr);
@@ -521,42 +469,30 @@ ibuf_data_init_for_space(
ibuf_exit();
heap = mem_heap_create(450);
- buf = mem_heap_alloc(heap, 50);
- sprintf(buf, "SYS_IBUF_TABLE_%lu", (ulong) space);
- /* use old-style record format for the insert buffer */
- table = dict_mem_table_create(buf, space, 2, 0);
+ /* Use old-style record format for the insert buffer. */
+ table = dict_mem_table_create(IBUF_TABLE_NAME, IBUF_SPACE_ID, 1, 0);
- dict_mem_table_add_col(table, heap, "PAGE_NO", DATA_BINARY, 0, 0);
- dict_mem_table_add_col(table, heap, "TYPES", DATA_BINARY, 0, 0);
+ dict_mem_table_add_col(table, heap, "DUMMY_COLUMN", DATA_BINARY, 0, 0);
- table->id = ut_dulint_add(DICT_IBUF_ID_MIN, space);
+ table->id = ut_dulint_add(DICT_IBUF_ID_MIN, IBUF_SPACE_ID);
dict_table_add_to_cache(table, heap);
mem_heap_free(heap);
index = dict_mem_index_create(
- buf, "CLUST_IND", space,
- DICT_CLUSTERED | DICT_UNIVERSAL | DICT_IBUF, 2);
+ IBUF_TABLE_NAME, "CLUST_IND",
+ IBUF_SPACE_ID, DICT_CLUSTERED | DICT_UNIVERSAL | DICT_IBUF, 1);
- dict_mem_index_add_field(index, "PAGE_NO", 0);
- dict_mem_index_add_field(index, "TYPES", 0);
+ dict_mem_index_add_field(index, "DUMMY_COLUMN", 0);
- index->id = ut_dulint_add(DICT_IBUF_ID_MIN, space);
+ index->id = ut_dulint_add(DICT_IBUF_ID_MIN, IBUF_SPACE_ID);
error = dict_index_add_to_cache(table, index,
FSP_IBUF_TREE_ROOT_PAGE_NO, FALSE);
ut_a(error == DB_SUCCESS);
- data->index = dict_table_get_first_index(table);
-
- mutex_enter(&ibuf_mutex);
-
- UT_LIST_ADD_LAST(data_list, ibuf->data_list, data);
-
- mutex_exit(&ibuf_mutex);
-
- return(data);
+ ibuf->index = dict_table_get_first_index(table);
}
/*************************************************************************
@@ -1042,12 +978,13 @@ ibuf_fixed_addr_page(
0 for uncompressed pages */
ulint page_no)/* in: page number */
{
- return((space == 0 && page_no == IBUF_TREE_ROOT_PAGE_NO)
+ return((space == IBUF_SPACE_ID && page_no == IBUF_TREE_ROOT_PAGE_NO)
|| ibuf_bitmap_page(zip_size, page_no));
}
/***************************************************************************
-Checks if a page is a level 2 or 3 page in the ibuf hierarchy of pages. */
+Checks if a page is a level 2 or 3 page in the ibuf hierarchy of pages.
+Must not be called when recv_no_ibuf_operations==TRUE. */
UNIV_INTERN
ibool
ibuf_page(
@@ -1055,68 +992,43 @@ ibuf_page(
/* out: TRUE if level 2 or level 3 page */
ulint space, /* in: space id */
ulint zip_size,/* in: compressed page size in bytes, or 0 */
- ulint page_no)/* in: page number */
+ ulint page_no,/* in: page number */
+ mtr_t* mtr) /* in: mtr which will contain an x-latch to the
+ bitmap page if the page is not one of the fixed
+ address ibuf pages, or NULL, in which case a new
+ transaction is created. */
{
- page_t* bitmap_page;
- mtr_t mtr;
ibool ret;
+ mtr_t local_mtr;
+ page_t* bitmap_page;
- if (recv_no_ibuf_operations) {
- /* Recovery is running: no ibuf operations should be
- performed */
-
- return(FALSE);
- }
+ ut_ad(!recv_no_ibuf_operations);
if (ibuf_fixed_addr_page(space, zip_size, page_no)) {
return(TRUE);
- }
-
- if (space != 0) {
- /* Currently we only have an ibuf tree in space 0 */
+ } else if (space != IBUF_SPACE_ID) {
return(FALSE);
}
- ut_ad(fil_space_get_type(space) == FIL_TABLESPACE);
+ ut_ad(fil_space_get_type(IBUF_SPACE_ID) == FIL_TABLESPACE);
- mtr_start(&mtr);
+ if (mtr == NULL) {
+ mtr = &local_mtr;
+ mtr_start(mtr);
+ }
- bitmap_page = ibuf_bitmap_get_map_page(space, page_no, zip_size, &mtr);
+ bitmap_page = ibuf_bitmap_get_map_page(space, page_no, zip_size, mtr);
ret = ibuf_bitmap_page_get_bits(bitmap_page, page_no, zip_size,
- IBUF_BITMAP_IBUF, &mtr);
- mtr_commit(&mtr);
-
- return(ret);
-}
-
-/***************************************************************************
-Checks if a page is a level 2 or 3 page in the ibuf hierarchy of pages. */
-UNIV_INTERN
-ibool
-ibuf_page_low(
-/*==========*/
- /* out: TRUE if level 2 or level 3 page */
- ulint space, /* in: space id */
- ulint zip_size,/* in: compressed page size in bytes, or 0 */
- ulint page_no,/* in: page number */
- mtr_t* mtr) /* in: mtr which will contain an x-latch to the
- bitmap page if the page is not one of the fixed
- address ibuf pages */
-{
- page_t* bitmap_page;
+ IBUF_BITMAP_IBUF, mtr);
- if (ibuf_fixed_addr_page(space, zip_size, page_no)) {
-
- return(TRUE);
+ if (mtr == &local_mtr) {
+ mtr_commit(mtr);
}
- bitmap_page = ibuf_bitmap_get_map_page(space, page_no, zip_size, mtr);
-
- return(ibuf_bitmap_page_get_bits(bitmap_page, page_no, zip_size,
- IBUF_BITMAP_IBUF, mtr));
+ return(ret);
}
/************************************************************************
@@ -1251,6 +1163,59 @@ ibuf_dummy_index_free(
/*************************************************************************
Builds the entry to insert into a non-clustered index when we have the
corresponding record in an ibuf index. */
+UNIV_INLINE
+dtuple_t*
+ibuf_build_entry_pre_4_1_x(
+/*=======================*/
+ /* out, own: entry to insert to
+ a non-clustered index; NOTE that
+ as we copy pointers to fields in
+ ibuf_rec, the caller must hold a
+ latch to the ibuf_rec page as long
+ as the entry is used! */
+ const rec_t* ibuf_rec, /* in: record in an insert buffer */
+ mem_heap_t* heap, /* in: heap where built */
+ dict_index_t** pindex) /* out, own: dummy index that
+ describes the entry */
+{
+ ulint i;
+ ulint len;
+ const byte* types;
+ dtuple_t* tuple;
+ ulint n_fields;
+
+ ut_a(trx_doublewrite_must_reset_space_ids);
+ ut_a(!trx_sys_multiple_tablespace_format);
+
+ n_fields = rec_get_n_fields_old(ibuf_rec) - 2;
+ tuple = dtuple_create(heap, n_fields);
+ types = rec_get_nth_field_old(ibuf_rec, 1, &len);
+
+ ut_a(len == n_fields * DATA_ORDER_NULL_TYPE_BUF_SIZE);
+
+ for (i = 0; i < n_fields; i++) {
+ const byte* data;
+ dfield_t* field;
+
+ field = dtuple_get_nth_field(tuple, i);
+
+ data = rec_get_nth_field_old(ibuf_rec, i + 2, &len);
+
+ dfield_set_data(field, data, len);
+
+ dtype_read_for_order_and_null_size(
+ dfield_get_type(field),
+ types + i * DATA_ORDER_NULL_TYPE_BUF_SIZE);
+ }
+
+ *pindex = ibuf_dummy_index_create(n_fields, FALSE);
+
+ return(tuple);
+}
+
+/*************************************************************************
+Builds the entry to insert into a non-clustered index when we have the
+corresponding record in an ibuf index. */
static
dtuple_t*
ibuf_build_entry_from_ibuf_rec(
@@ -1280,29 +1245,7 @@ ibuf_build_entry_from_ibuf_rec(
if (len > 1) {
/* This a < 4.1.x format record */
- ut_a(trx_doublewrite_must_reset_space_ids);
- ut_a(!trx_sys_multiple_tablespace_format);
-
- n_fields = rec_get_n_fields_old(ibuf_rec) - 2;
- tuple = dtuple_create(heap, n_fields);
- types = rec_get_nth_field_old(ibuf_rec, 1, &len);
-
- ut_a(len == n_fields * DATA_ORDER_NULL_TYPE_BUF_SIZE);
-
- for (i = 0; i < n_fields; i++) {
- field = dtuple_get_nth_field(tuple, i);
-
- data = rec_get_nth_field_old(ibuf_rec, i + 2, &len);
-
- dfield_set_data(field, data, len);
-
- dtype_read_for_order_and_null_size(
- dfield_get_type(field),
- types + i * DATA_ORDER_NULL_TYPE_BUF_SIZE);
- }
-
- *pindex = ibuf_dummy_index_create(n_fields, FALSE);
- return(tuple);
+ return(ibuf_build_entry_pre_4_1_x(ibuf_rec, heap, pindex));
}
/* This a >= 4.1.x format record */
@@ -1352,6 +1295,7 @@ ibuf_build_entry_from_ibuf_rec(
ut_d(dict_table_add_system_columns(index->table, index->table->heap));
*pindex = index;
+
return(tuple);
}
@@ -1682,10 +1626,9 @@ Checks if there are enough pages in the free list of the ibuf tree that we
dare to start a pessimistic insert to the insert buffer. */
UNIV_INLINE
ibool
-ibuf_data_enough_free_for_insert(
-/*=============================*/
+ibuf_data_enough_free_for_insert(void)
+/*==================================*/
/* out: TRUE if enough free pages in list */
- ibuf_data_t* data) /* in: ibuf data for the space */
{
ut_ad(mutex_own(&ibuf_mutex));
@@ -1695,7 +1638,7 @@ ibuf_data_enough_free_for_insert(
inserts buffered for pages that we read to the buffer pool, without
any risk of running out of free space in the insert buffer. */
- return(data->free_list_len >= data->size / 2 + 3 * data->height);
+ return(ibuf->free_list_len >= (ibuf->size / 2) + 3 * ibuf->height);
}
/*************************************************************************
@@ -1703,14 +1646,13 @@ Checks if there are enough pages in the free list of the ibuf tree that we
should remove them and free to the file space management. */
UNIV_INLINE
ibool
-ibuf_data_too_much_free(
-/*====================*/
+ibuf_data_too_much_free(void)
+/*=========================*/
/* out: TRUE if enough free pages in list */
- ibuf_data_t* data) /* in: ibuf data for the space */
{
ut_ad(mutex_own(&ibuf_mutex));
- return(data->free_list_len >= 3 + data->size / 2 + 3 * data->height);
+ return(ibuf->free_list_len >= 3 + (ibuf->size / 2) + 3 * ibuf->height);
}
/*************************************************************************
@@ -1718,12 +1660,10 @@ Allocates a new page from the ibuf file segment and adds it to the free
list. */
static
ulint
-ibuf_add_free_page(
-/*===============*/
+ibuf_add_free_page(void)
+/*====================*/
/* out: DB_SUCCESS, or DB_STRONG_FAIL
if no space left */
- ulint space, /* in: space id */
- ibuf_data_t* ibuf_data) /* in: ibuf data for the space */
{
mtr_t mtr;
page_t* header_page;
@@ -1734,16 +1674,14 @@ ibuf_add_free_page(
page_t* root;
page_t* bitmap_page;
- ut_a(space == 0);
-
mtr_start(&mtr);
/* Acquire the fsp latch before the ibuf header, obeying the latching
order */
- mtr_x_lock(fil_space_get_latch(space, &flags), &mtr);
+ mtr_x_lock(fil_space_get_latch(IBUF_SPACE_ID, &flags), &mtr);
zip_size = dict_table_flags_to_zip_size(flags);
- header_page = ibuf_header_page_get(space, &mtr);
+ header_page = ibuf_header_page_get(&mtr);
/* Allocate a new page: NOTE that if the page has been a part of a
non-clustered index which has subsequently been dropped, then the
@@ -1755,9 +1693,10 @@ ibuf_add_free_page(
of a deadlock. This is the reason why we created a special ibuf
header page apart from the ibuf tree. */
- page_no = fseg_alloc_free_page(header_page + IBUF_HEADER
- + IBUF_TREE_SEG_HEADER, 0, FSP_UP,
- &mtr);
+ page_no = fseg_alloc_free_page(
+ header_page + IBUF_HEADER + IBUF_TREE_SEG_HEADER, 0, FSP_UP,
+ &mtr);
+
if (page_no == FIL_NULL) {
mtr_commit(&mtr);
@@ -1765,10 +1704,14 @@ ibuf_add_free_page(
}
{
- buf_block_t* block = buf_page_get(
- space, 0, page_no, RW_X_LATCH, &mtr);
+ buf_block_t* block;
+
+ block = buf_page_get(
+ IBUF_SPACE_ID, 0, page_no, RW_X_LATCH, &mtr);
+
buf_block_dbg_add_level(block, SYNC_TREE_NODE_NEW);
+
page = buf_block_get_frame(block);
}
@@ -1776,7 +1719,7 @@ ibuf_add_free_page(
mutex_enter(&ibuf_mutex);
- root = ibuf_tree_root_get(ibuf_data, space, &mtr);
+ root = ibuf_tree_root_get(&mtr);
/* Add the page to the free list and update the ibuf size data */
@@ -1786,16 +1729,18 @@ ibuf_add_free_page(
mlog_write_ulint(page + FIL_PAGE_TYPE, FIL_PAGE_IBUF_FREE_LIST,
MLOG_2BYTES, &mtr);
- ibuf_data->seg_size++;
- ibuf_data->free_list_len++;
+ ibuf->seg_size++;
+ ibuf->free_list_len++;
/* Set the bit indicating that this page is now an ibuf tree page
(level 2 page) */
- bitmap_page = ibuf_bitmap_get_map_page(space, page_no, zip_size, &mtr);
+ bitmap_page = ibuf_bitmap_get_map_page(
+ IBUF_SPACE_ID, page_no, zip_size, &mtr);
+
+ ibuf_bitmap_page_set_bits(
+ bitmap_page, page_no, zip_size, IBUF_BITMAP_IBUF, TRUE, &mtr);
- ibuf_bitmap_page_set_bits(bitmap_page, page_no, zip_size,
- IBUF_BITMAP_IBUF, TRUE, &mtr);
mtr_commit(&mtr);
mutex_exit(&ibuf_mutex);
@@ -1809,10 +1754,8 @@ ibuf_add_free_page(
Removes a page from the free list and frees it to the fsp system. */
static
void
-ibuf_remove_free_page(
-/*==================*/
- ulint space, /* in: space id */
- ibuf_data_t* ibuf_data) /* in: ibuf data for the space */
+ibuf_remove_free_page(void)
+/*=======================*/
{
mtr_t mtr;
mtr_t mtr2;
@@ -1824,16 +1767,14 @@ ibuf_remove_free_page(
page_t* root;
page_t* bitmap_page;
- ut_a(space == 0);
-
mtr_start(&mtr);
/* Acquire the fsp latch before the ibuf header, obeying the latching
order */
- mtr_x_lock(fil_space_get_latch(space, &flags), &mtr);
+ mtr_x_lock(fil_space_get_latch(IBUF_SPACE_ID, &flags), &mtr);
zip_size = dict_table_flags_to_zip_size(flags);
- header_page = ibuf_header_page_get(space, &mtr);
+ header_page = ibuf_header_page_get(&mtr);
/* Prevent pessimistic inserts to insert buffer trees for a while */
mutex_enter(&ibuf_pessimistic_insert_mutex);
@@ -1842,7 +1783,7 @@ ibuf_remove_free_page(
mutex_enter(&ibuf_mutex);
- if (!ibuf_data_too_much_free(ibuf_data)) {
+ if (!ibuf_data_too_much_free()) {
mutex_exit(&ibuf_mutex);
@@ -1857,11 +1798,10 @@ ibuf_remove_free_page(
mtr_start(&mtr2);
- root = ibuf_tree_root_get(ibuf_data, space, &mtr2);
+ root = ibuf_tree_root_get(&mtr2);
page_no = flst_get_last(root + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST,
- &mtr2)
- .page;
+ &mtr2).page;
/* NOTE that we must release the latch on the ibuf tree root
because in fseg_free_page we access level 1 pages, and the root
@@ -1879,25 +1819,30 @@ ibuf_remove_free_page(
page from it. */
fseg_free_page(header_page + IBUF_HEADER + IBUF_TREE_SEG_HEADER,
- space, page_no, &mtr);
+ IBUF_SPACE_ID, page_no, &mtr);
+
#ifdef UNIV_DEBUG_FILE_ACCESSES
- buf_page_reset_file_page_was_freed(space, page_no);
+ buf_page_reset_file_page_was_freed(IBUF_SPACE_ID, page_no);
#endif
+
ibuf_enter();
mutex_enter(&ibuf_mutex);
- root = ibuf_tree_root_get(ibuf_data, space, &mtr);
+ root = ibuf_tree_root_get(&mtr);
ut_ad(page_no == flst_get_last(root + PAGE_HEADER
- + PAGE_BTR_IBUF_FREE_LIST, &mtr)
- .page);
+ + PAGE_BTR_IBUF_FREE_LIST, &mtr).page);
{
- buf_block_t* block = buf_page_get(
- space, 0, page_no, RW_X_LATCH, &mtr);
+ buf_block_t* block;
+
+ block = buf_page_get(
+ IBUF_SPACE_ID, 0, page_no, RW_X_LATCH, &mtr);
+
buf_block_dbg_add_level(block, SYNC_TREE_NODE);
+
page = buf_block_get_frame(block);
}
@@ -1906,20 +1851,22 @@ ibuf_remove_free_page(
flst_remove(root + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST,
page + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST_NODE, &mtr);
- ibuf_data->seg_size--;
- ibuf_data->free_list_len--;
+ ibuf->seg_size--;
+ ibuf->free_list_len--;
mutex_exit(&ibuf_pessimistic_insert_mutex);
/* Set the bit indicating that this page is no more an ibuf tree page
(level 2 page) */
- bitmap_page = ibuf_bitmap_get_map_page(space, page_no, zip_size, &mtr);
+ bitmap_page = ibuf_bitmap_get_map_page(
+ IBUF_SPACE_ID, page_no, zip_size, &mtr);
+
+ ibuf_bitmap_page_set_bits(
+ bitmap_page, page_no, zip_size, IBUF_BITMAP_IBUF, FALSE, &mtr);
- ibuf_bitmap_page_set_bits(bitmap_page, page_no, zip_size,
- IBUF_BITMAP_IBUF, FALSE, &mtr);
#ifdef UNIV_DEBUG_FILE_ACCESSES
- buf_page_set_file_page_was_freed(space, page_no);
+ buf_page_set_file_page_was_freed(IBUF_SPACE_ID, page_no);
#endif
mtr_commit(&mtr);
@@ -1934,39 +1881,28 @@ thread calls fsp services to allocate a new file segment, or a new page to a
file segment, and the thread did not own the fsp latch before this call. */
UNIV_INTERN
void
-ibuf_free_excess_pages(
-/*===================*/
- ulint space) /* in: compressed page size in bytes, or 0 */
+ibuf_free_excess_pages(void)
+/*========================*/
{
- ibuf_data_t* ibuf_data;
ulint i;
- if (space != 0) {
- fprintf(stderr,
- "InnoDB: Error: calling ibuf_free_excess_pages"
- " for space %lu\n", (ulong) space);
- return;
- }
-
#ifdef UNIV_SYNC_DEBUG
- ut_ad(rw_lock_own(fil_space_get_latch(space, NULL), RW_LOCK_EX));
+ ut_ad(rw_lock_own(fil_space_get_latch(IBUF_SPACE_ID, NULL),
+ RW_LOCK_EX));
#endif /* UNIV_SYNC_DEBUG */
- ut_ad(rw_lock_get_x_lock_count(fil_space_get_latch(space, NULL)) == 1);
+
+ ut_ad(rw_lock_get_x_lock_count(
+ fil_space_get_latch(IBUF_SPACE_ID, NULL)) == 1);
+
ut_ad(!ibuf_inside());
/* NOTE: We require that the thread did not own the latch before,
because then we know that we can obey the correct latching order
for ibuf latches */
- ibuf_data = fil_space_get_ibuf_data(space);
-
- if (ibuf_data == NULL) {
- /* Not yet initialized */
-
-#if 0 /* defined UNIV_DEBUG */
- fprintf(stderr,
- "Ibuf for space %lu not yet initialized\n", space);
-#endif
+ if (!ibuf) {
+ /* Not yet initialized; not sure if this is possible, but
+ does no harm to check for it. */
return;
}
@@ -1978,7 +1914,7 @@ ibuf_free_excess_pages(
mutex_enter(&ibuf_mutex);
- if (!ibuf_data_too_much_free(ibuf_data)) {
+ if (!ibuf_data_too_much_free()) {
mutex_exit(&ibuf_mutex);
@@ -1987,7 +1923,7 @@ ibuf_free_excess_pages(
mutex_exit(&ibuf_mutex);
- ibuf_remove_free_page(space, ibuf_data);
+ ibuf_remove_free_page();
}
}
@@ -2062,8 +1998,8 @@ ibuf_get_merge_page_nos(
rec_space_id = ibuf_rec_get_space(rec);
if (rec_space_id != first_space_id
- || rec_page_no / IBUF_MERGE_AREA
- != first_page_no / IBUF_MERGE_AREA) {
+ || (rec_page_no / IBUF_MERGE_AREA)
+ != (first_page_no / IBUF_MERGE_AREA)) {
break;
}
@@ -2178,11 +2114,7 @@ ibuf_contract_ext(
issued read with the highest tablespace address
to complete */
{
- ulint rnd_pos;
- ibuf_data_t* data;
btr_pcur_t pcur;
- ulint space;
- ibool all_trees_empty;
ulint page_nos[IBUF_MAX_N_PAGES_MERGED];
ulint space_ids[IBUF_MAX_N_PAGES_MERGED];
ib_int64_t space_versions[IBUF_MAX_N_PAGES_MERGED];
@@ -2191,54 +2123,17 @@ ibuf_contract_ext(
mtr_t mtr;
*n_pages = 0;
-loop:
ut_ad(!ibuf_inside());
mutex_enter(&ibuf_mutex);
- ut_ad(ibuf_validate_low());
-
- /* Choose an ibuf tree at random (though there really is only one tree
- in the current implementation) */
- ibuf_rnd += 865558671;
-
- rnd_pos = ibuf_rnd % ibuf->size;
-
- all_trees_empty = TRUE;
-
- data = UT_LIST_GET_FIRST(ibuf->data_list);
-
- for (;;) {
- if (!data->empty) {
- all_trees_empty = FALSE;
-
- if (rnd_pos < data->size) {
-
- break;
- }
-
- rnd_pos -= data->size;
- }
-
- data = UT_LIST_GET_NEXT(data_list, data);
-
- if (data == NULL) {
- if (all_trees_empty) {
- mutex_exit(&ibuf_mutex);
-
- return(0);
- }
+ if (ibuf->empty) {
+ibuf_is_empty:
+ mutex_exit(&ibuf_mutex);
- data = UT_LIST_GET_FIRST(ibuf->data_list);
- }
+ return(0);
}
- ut_ad(data);
-
- space = data->index->space;
-
- ut_a(space == 0); /* We currently only have an ibuf tree in
- space 0 */
mtr_start(&mtr);
ibuf_enter();
@@ -2246,22 +2141,23 @@ loop:
/* Open a cursor to a randomly chosen leaf of the tree, at a random
position within the leaf */
- btr_pcur_open_at_rnd_pos(data->index, BTR_SEARCH_LEAF, &pcur, &mtr);
-
- if (0 == page_get_n_recs(btr_pcur_get_page(&pcur))) {
+ btr_pcur_open_at_rnd_pos(ibuf->index, BTR_SEARCH_LEAF, &pcur, &mtr);
- /* This tree is empty */
+ if (page_get_n_recs(btr_pcur_get_page(&pcur)) == 0) {
+ /* When the ibuf tree is emptied completely, the last record
+ is removed using an optimistic delete and ibuf_size_update
+ is not called, causing ibuf->empty to remain FALSE. If we do
+ not reset it to TRUE here then database shutdown will hang
+ in the loop in ibuf_contract_for_n_pages. */
- data->empty = TRUE;
+ ibuf->empty = TRUE;
ibuf_exit();
mtr_commit(&mtr);
btr_pcur_close(&pcur);
- mutex_exit(&ibuf_mutex);
-
- goto loop;
+ goto ibuf_is_empty;
}
mutex_exit(&ibuf_mutex);
@@ -2454,12 +2350,17 @@ ibuf_get_volume_buffered(
}
{
- buf_block_t* block = buf_page_get(
- 0, 0, prev_page_no, RW_X_LATCH, mtr);
+ buf_block_t* block;
+
+ block = buf_page_get(
+ IBUF_SPACE_ID, 0, prev_page_no, RW_X_LATCH, mtr);
+
buf_block_dbg_add_level(block, SYNC_TREE_NODE);
+
prev_page = buf_block_get_frame(block);
}
+
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_next(prev_page, mtr)
== page_get_page_no(page));
@@ -2523,15 +2424,19 @@ count_later:
}
{
- buf_block_t* block = buf_page_get(
- 0, 0, next_page_no, RW_X_LATCH, mtr);
+ buf_block_t* block;
+
+ block = buf_page_get(
+ IBUF_SPACE_ID, 0, next_page_no, RW_X_LATCH, mtr);
+
buf_block_dbg_add_level(block, SYNC_TREE_NODE);
+
next_page = buf_block_get_frame(block);
}
+
#ifdef UNIV_BTR_DEBUG
- ut_a(btr_page_get_prev(next_page, mtr)
- == page_get_page_no(page));
+ ut_a(btr_page_get_prev(next_page, mtr) == page_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */
rec = page_get_infimum_rec(next_page);
@@ -2569,22 +2474,18 @@ ibuf_update_max_tablespace_id(void)
const rec_t* rec;
const byte* field;
ulint len;
- ibuf_data_t* ibuf_data;
- dict_index_t* ibuf_index;
btr_pcur_t pcur;
mtr_t mtr;
- ibuf_data = fil_space_get_ibuf_data(0);
-
- ibuf_index = ibuf_data->index;
- ut_a(!dict_table_is_comp(ibuf_index->table));
+ ut_a(!dict_table_is_comp(ibuf->index->table));
ibuf_enter();
mtr_start(&mtr);
- btr_pcur_open_at_index_side(FALSE, ibuf_index, BTR_SEARCH_LEAF,
- &pcur, TRUE, &mtr);
+ btr_pcur_open_at_index_side(
+ FALSE, ibuf->index, BTR_SEARCH_LEAF, &pcur, TRUE, &mtr);
+
btr_pcur_move_to_prev(&pcur, &mtr);
if (btr_pcur_is_before_first_on_page(&pcur)) {
@@ -2637,8 +2538,6 @@ ibuf_insert_low(
rec_t* ins_rec;
ibool old_bit_value;
page_t* bitmap_page;
- ibuf_data_t* ibuf_data;
- dict_index_t* ibuf_index;
page_t* root;
ulint err;
ibool do_merge;
@@ -2658,13 +2557,6 @@ ibuf_insert_low(
do_merge = FALSE;
- /* Currently the insert buffer of space 0 takes care of inserts to all
- tablespaces */
-
- ibuf_data = fil_space_get_ibuf_data(0);
-
- ibuf_index = ibuf_data->index;
-
mutex_enter(&ibuf_mutex);
if (ibuf->size >= ibuf->max_size + IBUF_CONTRACT_DO_NOT_INSERT) {
@@ -2691,7 +2583,7 @@ ibuf_insert_low(
mutex_enter(&ibuf_mutex);
- while (!ibuf_data_enough_free_for_insert(ibuf_data)) {
+ while (!ibuf_data_enough_free_for_insert()) {
mutex_exit(&ibuf_mutex);
@@ -2699,7 +2591,7 @@ ibuf_insert_low(
mutex_exit(&ibuf_pessimistic_insert_mutex);
- err = ibuf_add_free_page(0, ibuf_data);
+ err = ibuf_add_free_page();
if (err == DB_STRONG_FAIL) {
@@ -2730,7 +2622,7 @@ ibuf_insert_low(
mtr_start(&mtr);
- btr_pcur_open(ibuf_index, ibuf_entry, PAGE_CUR_LE, mode, &pcur, &mtr);
+ btr_pcur_open(ibuf->index, ibuf_entry, PAGE_CUR_LE, mode, &pcur, &mtr);
/* Find out the volume of already buffered inserts for the same index
page */
@@ -2779,6 +2671,7 @@ ibuf_insert_low(
old_bit_value = ibuf_bitmap_page_get_bits(
bitmap_page, page_no, zip_size,
IBUF_BITMAP_BUFFERED, &bitmap_mtr);
+
if (!old_bit_value) {
ibuf_bitmap_page_set_bits(bitmap_page, page_no, zip_size,
IBUF_BITMAP_BUFFERED, TRUE,
@@ -2806,7 +2699,7 @@ ibuf_insert_low(
which would cause the x-latching of the root after that to
break the latching order. */
- root = ibuf_tree_root_get(ibuf_data, 0, &mtr);
+ root = ibuf_tree_root_get(&mtr);
err = btr_cur_pessimistic_insert(BTR_NO_LOCKING_FLAG
| BTR_NO_UNDO_LOG_FLAG,
@@ -2819,7 +2712,7 @@ ibuf_insert_low(
thr_get_trx(thr)->id);
}
- ibuf_data_sizes_update(ibuf_data, root, &mtr);
+ ibuf_size_update(root, &mtr);
}
function_exit:
@@ -2835,7 +2728,6 @@ function_exit:
}
#endif
if (mode == BTR_MODIFY_TREE) {
- ut_ad(ibuf_validate_low());
mutex_exit(&ibuf_mutex);
mutex_exit(&ibuf_pessimistic_insert_mutex);
@@ -2850,8 +2742,8 @@ function_exit:
if (err == DB_SUCCESS) {
mutex_enter(&ibuf_mutex);
- ibuf_data->empty = FALSE;
- ibuf_data->n_inserts++;
+ ibuf->empty = FALSE;
+ ibuf->n_inserts++;
mutex_exit(&ibuf_mutex);
@@ -2896,6 +2788,18 @@ ibuf_insert(
ut_a(!dict_index_is_clust(index));
+ switch (UNIV_EXPECT(ibuf_use, IBUF_USE_INSERT)) {
+ case IBUF_USE_NONE:
+ return(FALSE);
+ case IBUF_USE_INSERT:
+ goto do_insert;
+ case IBUF_USE_COUNT:
+ break;
+ }
+
+ ut_error; /* unknown value of ibuf_use */
+
+do_insert:
entry_size = rec_get_converted_size(index, entry, 0);
if (entry_size
@@ -3072,7 +2976,6 @@ ibuf_delete_rec(
mtr_t* mtr) /* in: mtr */
{
ibool success;
- ibuf_data_t* ibuf_data;
page_t* root;
ulint err;
@@ -3104,11 +3007,6 @@ ibuf_delete_rec(
btr_pcur_commit_specify_mtr(pcur, mtr);
- /* Currently the insert buffer of space 0 takes care of inserts to all
- tablespaces */
-
- ibuf_data = fil_space_get_ibuf_data(0);
-
mutex_enter(&ibuf_mutex);
mtr_start(mtr);
@@ -3120,7 +3018,7 @@ ibuf_delete_rec(
/* The tablespace has been dropped. It is possible
that another thread has deleted the insert buffer
entry. Do not complain. */
- goto func_exit;
+ goto commit_and_exit;
}
fprintf(stderr,
@@ -3142,7 +3040,7 @@ ibuf_delete_rec(
btr_pcur_commit_specify_mtr(pcur, mtr);
fputs("InnoDB: Validating insert buffer tree:\n", stderr);
- if (!btr_validate_index(ibuf_data->index, NULL)) {
+ if (!btr_validate_index(ibuf->index, NULL)) {
ut_error;
}
@@ -3152,7 +3050,7 @@ ibuf_delete_rec(
goto func_exit;
}
- root = ibuf_tree_root_get(ibuf_data, 0, mtr);
+ root = ibuf_tree_root_get(mtr);
btr_cur_pessimistic_delete(&err, TRUE, btr_pcur_get_btr_cur(pcur),
RB_NONE, mtr);
@@ -3161,10 +3059,9 @@ ibuf_delete_rec(
#ifdef UNIV_IBUF_COUNT_DEBUG
ibuf_count_set(space, page_no, ibuf_count_get(space, page_no) - 1);
#endif
- ibuf_data_sizes_update(ibuf_data, root, mtr);
-
- ut_ad(ibuf_validate_low());
+ ibuf_size_update(root, mtr);
+commit_and_exit:
btr_pcur_commit_specify_mtr(pcur, mtr);
func_exit:
@@ -3201,11 +3098,7 @@ ibuf_merge_or_delete_for_page(
{
mem_heap_t* heap;
btr_pcur_t pcur;
- dtuple_t* entry;
dtuple_t* search_tuple;
- rec_t* ibuf_rec;
- page_t* bitmap_page;
- ibuf_data_t* ibuf_data;
ulint n_inserts;
#ifdef UNIV_IBUF_DEBUG
ulint volume;
@@ -3219,17 +3112,21 @@ ibuf_merge_or_delete_for_page(
ut_ad(!block || buf_block_get_page_no(block) == page_no);
ut_ad(!block || buf_block_get_zip_size(block) == zip_size);
- if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) {
-
+ if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE
+ || trx_sys_hdr_page(space, page_no)) {
return;
}
- if (trx_sys_hdr_page(space, page_no)) {
- return;
- }
+ /* We cannot refer to zip_size in the following, because
+ zip_size is passed as ULINT_UNDEFINED (it is unknown) when
+ buf_read_ibuf_merge_pages() is merging (discarding) changes
+ for a dropped tablespace. When block != NULL or
+ update_ibuf_bitmap is specified, the zip_size must be known.
+ That is why we will repeat the check below, with zip_size in
+ place of 0. Passing zip_size as 0 assumes that the
+ uncompressed page size always is a power-of-2 multiple of the
+ compressed page size. */
- /* The following assumes that the uncompressed page size
- is a power-of-2 multiple of zip_size. */
if (ibuf_fixed_addr_page(space, 0, page_no)
|| fsp_descr_page(0, page_no)) {
return;
@@ -3257,9 +3154,12 @@ ibuf_merge_or_delete_for_page(
block = NULL;
update_ibuf_bitmap = FALSE;
} else {
+ page_t* bitmap_page;
+
mtr_start(&mtr);
- bitmap_page = ibuf_bitmap_get_map_page(space, page_no,
- zip_size, &mtr);
+
+ bitmap_page = ibuf_bitmap_get_map_page(
+ space, page_no, zip_size, &mtr);
if (!ibuf_bitmap_page_get_bits(bitmap_page, page_no,
zip_size,
@@ -3276,17 +3176,12 @@ ibuf_merge_or_delete_for_page(
}
mtr_commit(&mtr);
}
- } else if (block) {
- if (ibuf_fixed_addr_page(space, zip_size, page_no)
- || fsp_descr_page(zip_size, page_no)) {
- return;
- }
- }
-
- /* Currently the insert buffer of space 0 takes care of inserts to all
- tablespaces */
+ } else if (block
+ && (ibuf_fixed_addr_page(space, zip_size, page_no)
+ || fsp_descr_page(zip_size, page_no))) {
- ibuf_data = fil_space_get_ibuf_data(0);
+ return;
+ }
ibuf_enter();
@@ -3313,6 +3208,8 @@ ibuf_merge_or_delete_for_page(
!= FIL_PAGE_INDEX)
|| UNIV_UNLIKELY(!page_is_leaf(block->frame))) {
+ page_t* bitmap_page;
+
corruption_noticed = TRUE;
ut_print_timestamp(stderr);
@@ -3361,10 +3258,12 @@ loop:
mtr_start(&mtr);
if (block) {
- ibool success = buf_page_get_known_nowait(RW_X_LATCH, block,
- BUF_KEEP_OLD,
- __FILE__, __LINE__,
- &mtr);
+ ibool success;
+
+ success = buf_page_get_known_nowait(
+ RW_X_LATCH, block,
+ BUF_KEEP_OLD, __FILE__, __LINE__, &mtr);
+
ut_a(success);
buf_block_dbg_add_level(block, SYNC_TREE_NODE);
@@ -3372,8 +3271,10 @@ loop:
/* Position pcur in the insert buffer at the first entry for this
index page */
- btr_pcur_open_on_user_rec(ibuf_data->index, search_tuple, PAGE_CUR_GE,
- BTR_MODIFY_LEAF, &pcur, &mtr);
+ btr_pcur_open_on_user_rec(
+ ibuf->index, search_tuple, PAGE_CUR_GE, BTR_MODIFY_LEAF,
+ &pcur, &mtr);
+
if (!btr_pcur_is_on_user_rec(&pcur)) {
ut_ad(btr_pcur_is_after_last_in_tree(&pcur, &mtr));
@@ -3381,37 +3282,43 @@ loop:
}
for (;;) {
+ rec_t* rec;
+
ut_ad(btr_pcur_is_on_user_rec(&pcur));
- ibuf_rec = btr_pcur_get_rec(&pcur);
+ rec = btr_pcur_get_rec(&pcur);
/* Check if the entry is for this index page */
- if (ibuf_rec_get_page_no(ibuf_rec) != page_no
- || ibuf_rec_get_space(ibuf_rec) != space) {
+ if (ibuf_rec_get_page_no(rec) != page_no
+ || ibuf_rec_get_space(rec) != space) {
+
if (block) {
page_header_reset_last_insert(
block->frame, page_zip, &mtr);
}
+
goto reset_bit;
}
if (UNIV_UNLIKELY(corruption_noticed)) {
fputs("InnoDB: Discarding record\n ", stderr);
- rec_print_old(stderr, ibuf_rec);
+ rec_print_old(stderr, rec);
fputs("\nInnoDB: from the insert buffer!\n\n", stderr);
} else if (block) {
/* Now we have at pcur a record which should be
inserted to the index page; NOTE that the call below
- copies pointers to fields in ibuf_rec, and we must
- keep the latch to the ibuf_rec page until the
+ copies pointers to fields in rec, and we must
+ keep the latch to the rec page until the
insertion is finished! */
+ dtuple_t* entry;
+ dulint max_trx_id;
dict_index_t* dummy_index;
- dulint max_trx_id = page_get_max_trx_id(
- page_align(ibuf_rec));
+
+ max_trx_id = page_get_max_trx_id(page_align(rec));
page_update_max_trx_id(block, page_zip, max_trx_id);
entry = ibuf_build_entry_from_ibuf_rec(
- ibuf_rec, heap, &dummy_index);
+ rec, heap, &dummy_index);
#ifdef UNIV_IBUF_DEBUG
volume += rec_get_converted_size(dummy_index, entry, 0)
+ page_dir_calc_reserved_space(1);
@@ -3432,9 +3339,7 @@ loop:
we start from the beginning again */
goto loop;
- }
-
- if (btr_pcur_is_after_last_on_page(&pcur)) {
+ } else if (btr_pcur_is_after_last_on_page(&pcur)) {
mtr_commit(&mtr);
btr_pcur_close(&pcur);
@@ -3450,36 +3355,31 @@ reset_bit:
}
#endif
if (UNIV_LIKELY(update_ibuf_bitmap)) {
- bitmap_page = ibuf_bitmap_get_map_page(space, page_no,
- zip_size, &mtr);
- ibuf_bitmap_page_set_bits(bitmap_page, page_no, zip_size,
- IBUF_BITMAP_BUFFERED, FALSE, &mtr);
+ page_t* bitmap_page;
+
+ bitmap_page = ibuf_bitmap_get_map_page(
+ space, page_no, zip_size, &mtr);
+
+ ibuf_bitmap_page_set_bits(
+ bitmap_page, page_no, zip_size,
+ IBUF_BITMAP_BUFFERED, FALSE, &mtr);
+
if (block) {
ulint old_bits = ibuf_bitmap_page_get_bits(
bitmap_page, page_no, zip_size,
IBUF_BITMAP_FREE, &mtr);
+
ulint new_bits = ibuf_index_page_calc_free(
zip_size, block);
-#if 0 /* defined UNIV_IBUF_DEBUG */
- fprintf(stderr, "Old bits %lu new bits %lu"
- " max size %lu\n",
- old_bits, new_bits,
- page_get_max_insert_size_after_reorganize(
- page, 1));
-#endif
+
if (old_bits != new_bits) {
- ibuf_bitmap_page_set_bits(bitmap_page, page_no,
- zip_size,
- IBUF_BITMAP_FREE,
- new_bits, &mtr);
+ ibuf_bitmap_page_set_bits(
+ bitmap_page, page_no, zip_size,
+ IBUF_BITMAP_FREE, new_bits, &mtr);
}
}
}
-#if 0 /* defined UNIV_IBUF_DEBUG */
- fprintf(stderr,
- "Ibuf merge %lu records volume %lu to page no %lu\n",
- n_inserts, volume, page_no);
-#endif
+
mtr_commit(&mtr);
btr_pcur_close(&pcur);
mem_heap_free(heap);
@@ -3487,8 +3387,8 @@ reset_bit:
/* Protect our statistics keeping from race conditions */
mutex_enter(&ibuf_mutex);
- ibuf_data->n_merges++;
- ibuf_data->n_merged_recs += n_inserts;
+ ibuf->n_merges++;
+ ibuf->n_merged_recs += n_inserts;
mutex_exit(&ibuf_mutex);
@@ -3498,6 +3398,7 @@ reset_bit:
}
ibuf_exit();
+
#ifdef UNIV_IBUF_COUNT_DEBUG
ut_a(ibuf_count_get(space, page_no) == 0);
#endif
@@ -3520,15 +3421,9 @@ ibuf_delete_for_discarded_space(
rec_t* ibuf_rec;
ulint page_no;
ibool closed;
- ibuf_data_t* ibuf_data;
ulint n_inserts;
mtr_t mtr;
- /* Currently the insert buffer of space 0 takes care of inserts to all
- tablespaces */
-
- ibuf_data = fil_space_get_ibuf_data(0);
-
heap = mem_heap_create(512);
/* Use page number 0 to build the search tuple so that we get the
@@ -3544,8 +3439,10 @@ loop:
/* Position pcur in the insert buffer at the first entry for the
space */
- btr_pcur_open_on_user_rec(ibuf_data->index, search_tuple, PAGE_CUR_GE,
- BTR_MODIFY_LEAF, &pcur, &mtr);
+ btr_pcur_open_on_user_rec(
+ ibuf->index, search_tuple, PAGE_CUR_GE, BTR_MODIFY_LEAF,
+ &pcur, &mtr);
+
if (!btr_pcur_is_on_user_rec(&pcur)) {
ut_ad(btr_pcur_is_after_last_in_tree(&pcur, &mtr));
@@ -3596,50 +3493,16 @@ leave_loop:
/* Protect our statistics keeping from race conditions */
mutex_enter(&ibuf_mutex);
- ibuf_data->n_merges++;
- ibuf_data->n_merged_recs += n_inserts;
+ ibuf->n_merges++;
+ ibuf->n_merged_recs += n_inserts;
mutex_exit(&ibuf_mutex);
- /*
- fprintf(stderr,
- "InnoDB: Discarded %lu ibuf entries for space %lu\n",
- (ulong) n_inserts, (ulong) space);
- */
+
ibuf_exit();
mem_heap_free(heap);
}
-#ifdef UNIV_DEBUG
-/**********************************************************************
-Validates the ibuf data structures when the caller owns ibuf_mutex. */
-static
-ibool
-ibuf_validate_low(void)
-/*===================*/
- /* out: TRUE if ok */
-{
- ibuf_data_t* data;
- ulint sum_sizes;
-
- ut_ad(mutex_own(&ibuf_mutex));
-
- sum_sizes = 0;
-
- data = UT_LIST_GET_FIRST(ibuf->data_list);
-
- while (data) {
- sum_sizes += data->size;
-
- data = UT_LIST_GET_NEXT(data_list, data);
- }
-
- ut_a(sum_sizes == ibuf->size);
-
- return(TRUE);
-}
-#endif /* UNIV_DEBUG */
-
/**********************************************************************
Looks if the insert buffer is empty. */
UNIV_INTERN
@@ -3648,7 +3511,6 @@ ibuf_is_empty(void)
/*===============*/
/* out: TRUE if empty */
{
- ibuf_data_t* data;
ibool is_empty;
const page_t* root;
mtr_t mtr;
@@ -3657,17 +3519,15 @@ ibuf_is_empty(void)
mutex_enter(&ibuf_mutex);
- data = UT_LIST_GET_FIRST(ibuf->data_list);
-
mtr_start(&mtr);
- root = ibuf_tree_root_get(data, 0, &mtr);
+ root = ibuf_tree_root_get(&mtr);
if (page_get_n_recs(root) == 0) {
is_empty = TRUE;
- if (data->empty == FALSE) {
+ if (ibuf->empty == FALSE) {
fprintf(stderr,
"InnoDB: Warning: insert buffer tree is empty"
" but the data struct does not\n"
@@ -3676,15 +3536,13 @@ ibuf_is_empty(void)
"InnoDB: run to completion.\n");
}
} else {
- ut_a(data->empty == FALSE);
+ ut_a(ibuf->empty == FALSE);
is_empty = FALSE;
}
mtr_commit(&mtr);
- ut_a(data->space == 0);
-
mutex_exit(&ibuf_mutex);
ibuf_exit();
@@ -3700,39 +3558,36 @@ ibuf_print(
/*=======*/
FILE* file) /* in: file where to print */
{
- ibuf_data_t* data;
#ifdef UNIV_IBUF_COUNT_DEBUG
ulint i;
+ ulint j;
#endif
mutex_enter(&ibuf_mutex);
- data = UT_LIST_GET_FIRST(ibuf->data_list);
-
- while (data) {
- fprintf(file,
- "Ibuf: size %lu, free list len %lu, seg size %lu,\n"
- "%lu inserts, %lu merged recs, %lu merges\n",
- (ulong) data->size,
- (ulong) data->free_list_len,
- (ulong) data->seg_size,
- (ulong) data->n_inserts,
- (ulong) data->n_merged_recs,
- (ulong) data->n_merges);
+ fprintf(file,
+ "Ibuf: size %lu, free list len %lu, seg size %lu,\n"
+ "%lu inserts, %lu merged recs, %lu merges\n",
+ (ulong) ibuf->size,
+ (ulong) ibuf->free_list_len,
+ (ulong) ibuf->seg_size,
+ (ulong) ibuf->n_inserts,
+ (ulong) ibuf->n_merged_recs,
+ (ulong) ibuf->n_merges);
#ifdef UNIV_IBUF_COUNT_DEBUG
- for (i = 0; i < IBUF_COUNT_N_PAGES; i++) {
- if (ibuf_count_get(data->space, i) > 0) {
+ for (i = 0; i < IBUF_COUNT_N_SPACES; i++) {
+ for (j = 0; j < IBUF_COUNT_N_PAGES; j++) {
+ ulint count = ibuf_count_get(i, j);
+ if (count > 0) {
fprintf(stderr,
- "Ibuf count for page %lu is %lu\n",
- (ulong) i,
- (ulong)
- ibuf_count_get(data->space, i));
+ "Ibuf count for space/page %lu/%lu"
+ " is %lu\n",
+ (ulong) i, (ulong) j, (ulong) count);
}
}
-#endif
- data = UT_LIST_GET_NEXT(data_list, data);
}
+#endif /* UNIV_IBUF_COUNT_DEBUG */
mutex_exit(&ibuf_mutex);
}
diff --git a/include/btr0btr.h b/include/btr0btr.h
index 2d80badaf8c..298942bd542 100644
--- a/include/btr0btr.h
+++ b/include/btr0btr.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/******************************************************
The B-tree
-(c) 1994-1996 Innobase Oy
-
Created 6/2/1994 Heikki Tuuri
*******************************************************/
@@ -14,7 +30,6 @@ Created 6/2/1994 Heikki Tuuri
#include "dict0dict.h"
#include "data0data.h"
#include "page0cur.h"
-#include "rem0rec.h"
#include "mtr0mtr.h"
#include "btr0types.h"
diff --git a/include/btr0btr.ic b/include/btr0btr.ic
index 215defbfa3e..a8d934ecc87 100644
--- a/include/btr0btr.ic
+++ b/include/btr0btr.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/******************************************************
The B-tree
-(c) 1994-1996 Innobase Oy
-
Created 6/2/1994 Heikki Tuuri
*******************************************************/
diff --git a/include/btr0cur.h b/include/btr0cur.h
index 890d56f8fb6..c3a478c4bb7 100644
--- a/include/btr0cur.h
+++ b/include/btr0cur.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/******************************************************
The index tree cursor
-(c) 1994-1996 Innobase Oy
-
Created 10/16/1994 Heikki Tuuri
*******************************************************/
@@ -11,7 +27,6 @@ Created 10/16/1994 Heikki Tuuri
#include "univ.i"
#include "dict0dict.h"
-#include "data0data.h"
#include "page0cur.h"
#include "btr0types.h"
#include "que0types.h"
@@ -353,7 +368,10 @@ btr_cur_optimistic_delete(
cursor stays valid: if deletion succeeds,
on function exit it points to the successor
of the deleted record */
- mtr_t* mtr); /* in: mtr */
+ mtr_t* mtr); /* in: mtr; if this function returns
+ TRUE on a leaf page of a secondary
+ index, the mtr must be committed
+ before latching any further pages */
/*****************************************************************
Removes the record on which the tree cursor is positioned. Tries
to compress the page if its fillfactor drops below a threshold
diff --git a/include/btr0cur.ic b/include/btr0cur.ic
index 46ee6d71097..84a3a5cba0b 100644
--- a/include/btr0cur.ic
+++ b/include/btr0cur.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/******************************************************
The index tree cursor
-(c) 1994-1996 Innobase Oy
-
Created 10/16/1994 Heikki Tuuri
*******************************************************/
diff --git a/include/btr0pcur.h b/include/btr0pcur.h
index b38decb6031..1fdd102d32a 100644
--- a/include/btr0pcur.h
+++ b/include/btr0pcur.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
The index tree persistent cursor
-(c) 1996 Innobase Oy
-
Created 2/23/1996 Heikki Tuuri
*******************************************************/
diff --git a/include/btr0pcur.ic b/include/btr0pcur.ic
index b4325249011..bde7413820a 100644
--- a/include/btr0pcur.ic
+++ b/include/btr0pcur.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
The index tree persistent cursor
-(c) 1996 Innobase Oy
-
Created 2/23/1996 Heikki Tuuri
*******************************************************/
diff --git a/include/btr0sea.h b/include/btr0sea.h
index fbb6d764a8f..074e6595258 100644
--- a/include/btr0sea.h
+++ b/include/btr0sea.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/************************************************************************
The index tree adaptive search
-(c) 1996 Innobase Oy
-
Created 2/17/1996 Heikki Tuuri
*************************************************************************/
@@ -165,8 +181,9 @@ btr_search_validate(void);
/*======================*/
/* out: TRUE if ok */
-/* Flag: has the search system been disabled? */
-extern ibool btr_search_disabled;
+/* Flag: has the search system been enabled?
+Protected by btr_search_latch and btr_search_enabled_mutex. */
+extern char btr_search_enabled;
/* The search info struct in an index */
diff --git a/include/btr0sea.ic b/include/btr0sea.ic
index cc25d99fa77..c948d7e92af 100644
--- a/include/btr0sea.ic
+++ b/include/btr0sea.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/************************************************************************
The index tree adaptive search
-(c) 1996 Innobase Oy
-
Created 2/17/1996 Heikki Tuuri
*************************************************************************/
diff --git a/include/btr0types.h b/include/btr0types.h
index 5c1e08be131..074b15fa68d 100644
--- a/include/btr0types.h
+++ b/include/btr0types.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/************************************************************************
The index tree general types
-(c) 1996 Innobase Oy
-
Created 2/17/1996 Heikki Tuuri
*************************************************************************/
diff --git a/include/buf0buddy.h b/include/buf0buddy.h
index 0ab27d3ed67..2afef7913fc 100644
--- a/include/buf0buddy.h
+++ b/include/buf0buddy.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 2006, 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
+
+*****************************************************************************/
+
/******************************************************
Binary buddy allocator for compressed pages
-(c) 2006 Innobase Oy
-
Created December 2006 by Marko Makela
*******************************************************/
diff --git a/include/buf0buddy.ic b/include/buf0buddy.ic
index 88f1a730334..7d46b140449 100644
--- a/include/buf0buddy.ic
+++ b/include/buf0buddy.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 2006, 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
+
+*****************************************************************************/
+
/******************************************************
Binary buddy allocator for compressed pages
-(c) 2006 Innobase Oy
-
Created December 2006 by Marko Makela
*******************************************************/
@@ -61,7 +77,8 @@ buf_buddy_get_slot(
ulint i;
ulint s;
- for (i = 0, s = BUF_BUDDY_LOW; s < size; i++, s <<= 1);
+ for (i = 0, s = BUF_BUDDY_LOW; s < size; i++, s <<= 1) {
+ }
ut_ad(i <= BUF_BUDDY_SIZES);
return(i);
diff --git a/include/buf0buf.h b/include/buf0buf.h
index a6f0bcf0d0a..9f94f72e293 100644
--- a/include/buf0buf.h
+++ b/include/buf0buf.h
@@ -1,22 +1,24 @@
-/* Innobase relational database engine; Copyright (C) 2001 Innobase Oy
+/*****************************************************************************
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License 2
- as published by the Free Software Foundation in June 1991.
+Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
- 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.
+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
+
+*****************************************************************************/
- You should have received a copy of the GNU General Public License 2
- along with this program (in file COPYING); if not, write to the Free
- Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/******************************************************
The database buffer pool high-level routines
-(c) 1995 Innobase Oy
-
Created 11/5/1995 Heikki Tuuri
*******************************************************/
@@ -36,8 +38,6 @@ Created 11/5/1995 Heikki Tuuri
/* Modes for buf_page_get_gen */
#define BUF_GET 10 /* get always */
#define BUF_GET_IF_IN_POOL 11 /* get if in pool */
-#define BUF_GET_NOWAIT 12 /* get if can set the latch without
- waiting */
#define BUF_GET_NO_LATCH 14 /* get and bufferfix, but set no latch;
we have separated this case, because
it is error-prone programming not to
@@ -95,6 +95,15 @@ buf_pool_free(void);
/*===============*/
/************************************************************************
+Drops the adaptive hash index. To prevent a livelock, this function
+is only to be called while holding btr_search_latch and while
+btr_search_enabled == FALSE. */
+UNIV_INTERN
+void
+buf_pool_drop_hash_index(void);
+/*==========================*/
+
+/************************************************************************
Relocate a buffer control block. Relocates the block on the LRU list
and in buf_pool->page_hash. Does not relocate bpage->list.
The caller must take care of relocating bpage->list. */
@@ -172,12 +181,6 @@ with care. */
SP, ZS, OF, RW_NO_LATCH, NULL,\
BUF_GET_NO_LATCH, __FILE__, __LINE__, MTR)
/******************************************************************
-NOTE! The following macros should be used instead of buf_page_get_gen, to
-improve debugging. Only values RW_S_LATCH and RW_X_LATCH are allowed as LA! */
-#define buf_page_get_nowait(SP, ZS, OF, LA, MTR) buf_page_get_gen(\
- SP, ZS, OF, LA, NULL,\
- BUF_GET_NOWAIT, __FILE__, __LINE__, MTR)
-/******************************************************************
NOTE! The following macros should be used instead of
buf_page_optimistic_get_func, to improve debugging. Only values RW_S_LATCH and
RW_X_LATCH are allowed as LA! */
@@ -866,15 +869,15 @@ Gets the compressed page descriptor corresponding to an uncompressed page
if applicable. */
#define buf_block_get_page_zip(block) \
(UNIV_LIKELY_NULL((block)->page.zip.data) ? &(block)->page.zip : NULL)
-#if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG
/***********************************************************************
Gets the block to whose frame the pointer is pointing to. */
-UNIV_INLINE
-const buf_block_t*
+UNIV_INTERN
+buf_block_t*
buf_block_align(
/*============*/
- /* out: pointer to block */
+ /* out: pointer to block, never NULL */
const byte* ptr); /* in: pointer to a frame */
+#if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG
/*************************************************************************
Gets the compressed page descriptor corresponding to an uncompressed page
if applicable. */
@@ -981,8 +984,10 @@ struct buf_page_struct{
since they can be stored in the same machine word. Some of them are
additionally protected by buf_pool_mutex. */
- unsigned space:32; /* tablespace id */
- unsigned offset:32; /* page number */
+ unsigned space:32; /* tablespace id; also protected
+ by buf_pool_mutex. */
+ unsigned offset:32; /* page number; also protected
+ by buf_pool_mutex. */
unsigned state:3; /* state of the control block
(@see enum buf_page_state); also
@@ -1051,7 +1056,8 @@ struct buf_page_struct{
not yet been flushed on disk; zero if
all modifications are on disk */
- /* 3. LRU replacement algorithm fields; protected by buf_pool_mutex */
+ /* 3. LRU replacement algorithm fields; protected by
+ buf_pool_mutex only (not buf_pool_zip_mutex or block->mutex) */
UT_LIST_NODE_T(buf_page_t) LRU;
/* node of the LRU list */
@@ -1162,11 +1168,11 @@ struct buf_block_struct{
An exception to this is when we init or create a page
in the buffer pool in buf0buf.c. */
-#ifdef UNIV_DEBUG
+#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
ulint n_pointers; /* used in debugging: the number of
pointers in the adaptive hash index
pointing to this frame */
-#endif /* UNIV_DEBUG */
+#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
unsigned is_hashed:1; /* TRUE if hash index has already been
built on this page; note that it does
not guarantee that the index is
diff --git a/include/buf0buf.ic b/include/buf0buf.ic
index ee2a199f4d5..c56c0ac62f2 100644
--- a/include/buf0buf.ic
+++ b/include/buf0buf.ic
@@ -1,8 +1,31 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 2008, Google Inc.
+
+Portions of this file contain modifications contributed and copyrighted by
+Google, Inc. Those modifications are gratefully acknowledged and are described
+briefly in the InnoDB documentation. The contributions by Google are
+incorporated with their permission, and subject to the conditions contained in
+the file COPYING.Google.
+
+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
+
+*****************************************************************************/
+
/******************************************************
The database buffer buf_pool
-(c) 1995 Innobase Oy
-
Created 11/5/1995 Heikki Tuuri
*******************************************************/
@@ -20,6 +43,7 @@ buf_page_get_freed_page_clock(
/* out: freed_page_clock */
const buf_page_t* bpage) /* in: block */
{
+ /* This is sometimes read without holding buf_pool_mutex. */
return(bpage->freed_page_clock);
}
@@ -91,6 +115,9 @@ buf_pool_get_oldest_modification(void)
//buf_pool_mutex_exit();
mutex_exit(&flush_list_mutex);
+ /* The returned answer may be out of date: the flush_list can
+ change after the mutex has been released. */
+
return(lsn);
}
@@ -264,6 +291,7 @@ buf_page_get_LRU_position(
const buf_page_t* bpage) /* in: control block */
{
ut_ad(buf_page_in_file(bpage));
+ ut_ad(buf_pool_mutex_own());
return(bpage->LRU_position);
}
@@ -433,6 +461,7 @@ buf_page_is_old(
const buf_page_t* bpage) /* in: control block */
{
ut_ad(buf_page_in_file(bpage));
+ ut_ad(buf_pool_mutex_own());
return(bpage->old);
}
@@ -630,29 +659,6 @@ buf_block_get_zip_size(
}
#if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG
-/***********************************************************************
-Gets the block to whose frame the pointer is pointing to. */
-UNIV_INLINE
-const buf_block_t*
-buf_block_align(
-/*============*/
- /* out: pointer to block */
- const byte* ptr) /* in: pointer to a frame */
-{
- const buf_block_t* block;
- ulint space_id, page_no;
-
- ptr = (const byte*) ut_align_down(ptr, UNIV_PAGE_SIZE);
- page_no = mach_read_from_4(ptr + FIL_PAGE_OFFSET);
- space_id = mach_read_from_4(ptr + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
-
- block = (const buf_block_t*) buf_page_hash_get(space_id, page_no);
- ut_ad(block);
- ut_ad(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
- ut_ad(block->frame == ptr);
- return(block);
-}
-
/*************************************************************************
Gets the compressed page descriptor corresponding to an uncompressed page
if applicable. */
@@ -663,13 +669,7 @@ buf_frame_get_page_zip(
/* out: compressed page descriptor, or NULL */
const byte* ptr) /* in: pointer to the page */
{
- const page_zip_des_t* page_zip;
- //buf_pool_mutex_enter();
- rw_lock_s_lock(&page_hash_latch);
- page_zip = buf_block_get_page_zip(buf_block_align(ptr));
- //buf_pool_mutex_exit();
- rw_lock_s_unlock(&page_hash_latch);
- return(page_zip);
+ return(buf_block_get_page_zip(buf_block_align(ptr)));
}
#endif /* UNIV_DEBUG || UNIV_ZIP_DEBUG */
@@ -815,9 +815,8 @@ buf_page_get_newest_modification(
page frame */
{
ib_uint64_t lsn;
- mutex_t* block_mutex = buf_page_get_mutex(bpage);
+ mutex_t* block_mutex = buf_page_get_mutex(bpage);
- //buf_pool_mutex_enter();
mutex_enter(block_mutex);
if (buf_page_in_file(bpage)) {
@@ -826,7 +825,6 @@ buf_page_get_newest_modification(
lsn = 0;
}
- //buf_pool_mutex_exit();
mutex_exit(block_mutex);
return(lsn);
@@ -884,7 +882,7 @@ buf_block_buf_fix_inc_func(
#ifdef UNIV_SYNC_DEBUG
ibool ret;
- ret = rw_lock_s_lock_func_nowait(&(block->debug_latch), file, line);
+ ret = rw_lock_s_lock_nowait(&(block->debug_latch), file, line);
ut_a(ret);
#endif /* UNIV_SYNC_DEBUG */
ut_ad(mutex_own(&block->mutex));
@@ -938,6 +936,8 @@ buf_page_hash_get(
fold = buf_page_address_fold(space, offset);
HASH_SEARCH(hash, buf_pool->page_hash, fold, buf_page_t*, bpage,
+ ut_ad(bpage->in_page_hash && !bpage->in_zip_hash
+ && buf_page_in_file(bpage)),
bpage->space == space && bpage->offset == offset);
if (bpage) {
ut_a(buf_page_in_file(bpage));
@@ -1064,6 +1064,10 @@ buf_page_release(
#endif
block->page.buf_fix_count--;
+ /* Dirty blocks should be in the flush list. */
+ ut_ad(!block->page.oldest_modification
+ || block->page.in_flush_list);
+
mutex_exit(&block->mutex);
if (rw_latch == RW_S_LATCH) {
diff --git a/include/buf0flu.h b/include/buf0flu.h
index 0ba247a346e..11a37351479 100644
--- a/include/buf0flu.h
+++ b/include/buf0flu.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/******************************************************
The database buffer pool flush algorithm
-(c) 1995 Innobase Oy
-
Created 11/5/1995 Heikki Tuuri
*******************************************************/
@@ -15,13 +31,6 @@ Created 11/5/1995 Heikki Tuuri
#include "mtr0types.h"
/************************************************************************
-Inserts a modified block into the flush list. */
-UNIV_INTERN
-void
-buf_flush_insert_into_flush_list(
-/*=============================*/
- buf_page_t* bpage); /* in: block which is modified */
-/************************************************************************
Remove a block from the flush list of modified blocks. */
UNIV_INTERN
void
diff --git a/include/buf0flu.ic b/include/buf0flu.ic
index fc522ec619d..26fa7c02ef3 100644
--- a/include/buf0flu.ic
+++ b/include/buf0flu.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/******************************************************
The database buffer pool flush algorithm
-(c) 1995 Innobase Oy
-
Created 11/5/1995 Heikki Tuuri
*******************************************************/
@@ -10,6 +26,13 @@ Created 11/5/1995 Heikki Tuuri
#include "mtr0mtr.h"
/************************************************************************
+Inserts a modified block into the flush list. */
+UNIV_INTERN
+void
+buf_flush_insert_into_flush_list(
+/*=============================*/
+ buf_block_t* block); /* in/out: block which is modified */
+/************************************************************************
Inserts a modified block into the flush list in the right sorted position.
This function is used by recovery, because there the modifications do not
necessarily come in the order of lsn's. */
@@ -17,7 +40,7 @@ UNIV_INTERN
void
buf_flush_insert_sorted_into_flush_list(
/*====================================*/
- buf_page_t* bpage); /* in: block which is modified */
+ buf_block_t* block); /* in/out: block which is modified */
/************************************************************************
This function should be called at a mini-transaction commit, if a page was
@@ -50,7 +73,7 @@ buf_flush_note_modification(
block->page.oldest_modification = mtr->start_lsn;
ut_ad(block->page.oldest_modification != 0);
- buf_flush_insert_into_flush_list(&block->page);
+ buf_flush_insert_into_flush_list(block);
} else {
ut_ad(block->page.oldest_modification <= mtr->start_lsn);
}
@@ -90,7 +113,7 @@ buf_flush_recv_note_modification(
ut_ad(block->page.oldest_modification != 0);
- buf_flush_insert_sorted_into_flush_list(&block->page);
+ buf_flush_insert_sorted_into_flush_list(block);
} else {
ut_ad(block->page.oldest_modification <= start_lsn);
}
diff --git a/include/buf0lru.h b/include/buf0lru.h
index c73033fe5e4..3fd534a215d 100644
--- a/include/buf0lru.h
+++ b/include/buf0lru.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/******************************************************
The database buffer pool LRU replacement algorithm
-(c) 1995 Innobase Oy
-
Created 11/5/1995 Heikki Tuuri
*******************************************************/
@@ -87,9 +103,15 @@ buf_LRU_insert_zip_clean(
/**********************************************************************
Try to free a block. If bpage is a descriptor of a compressed-only
-page, the descriptor object will be freed as well. If this function
-returns BUF_LRU_FREED, it will not temporarily release
-buf_pool_mutex. */
+page, the descriptor object will be freed as well.
+
+NOTE: If this function returns BUF_LRU_FREED, it will not temporarily
+release buf_pool_mutex. Furthermore, the page frame will no longer be
+accessible via bpage.
+
+The caller must hold buf_pool_mutex and buf_page_get_mutex(bpage) and
+release these two mutexes after the call. No other
+buf_page_get_mutex() may be held when calling this function. */
UNIV_INTERN
enum buf_lru_free_block_status
buf_LRU_free_block(
diff --git a/include/buf0lru.ic b/include/buf0lru.ic
index 7b8ee457b0b..f4c40e0b606 100644
--- a/include/buf0lru.ic
+++ b/include/buf0lru.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/******************************************************
The database buffer replacement algorithm
-(c) 1995 Innobase Oy
-
Created 11/5/1995 Heikki Tuuri
*******************************************************/
diff --git a/include/buf0rea.h b/include/buf0rea.h
index 1a0e178fc24..6d138a3a02b 100644
--- a/include/buf0rea.h
+++ b/include/buf0rea.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/******************************************************
The database buffer read
-(c) 1995 Innobase Oy
-
Created 11/5/1995 Heikki Tuuri
*******************************************************/
diff --git a/include/buf0types.h b/include/buf0types.h
index b1daccb3212..f2721da85f9 100644
--- a/include/buf0types.h
+++ b/include/buf0types.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/******************************************************
The database buffer pool global types for the directory
-(c) 1995 Innobase Oy
-
Created 11/17/1995 Heikki Tuuri
*******************************************************/
diff --git a/include/data0data.h b/include/data0data.h
index 123f249bebd..1190a7ae45a 100644
--- a/include/data0data.h
+++ b/include/data0data.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/************************************************************************
SQL data field and tuple
-(c) 1994-1996 Innobase Oy
-
Created 5/30/1994 Heikki Tuuri
*************************************************************************/
diff --git a/include/data0data.ic b/include/data0data.ic
index cadac8ac901..f11dbd9fce6 100644
--- a/include/data0data.ic
+++ b/include/data0data.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/************************************************************************
SQL data field and tuple
-(c) 1994-1996 Innobase Oy
-
Created 5/30/1994 Heikki Tuuri
*************************************************************************/
diff --git a/include/data0type.h b/include/data0type.h
index 230ebc93cc8..1f10878984b 100644
--- a/include/data0type.h
+++ b/include/data0type.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Data types
-(c) 1996 Innobase Oy
-
Created 1/16/1996 Heikki Tuuri
*******************************************************/
diff --git a/include/data0type.ic b/include/data0type.ic
index 965b1c39373..d4c1080bebe 100644
--- a/include/data0type.ic
+++ b/include/data0type.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Data types
-(c) 1996 Innobase Oy
-
Created 1/16/1996 Heikki Tuuri
*******************************************************/
diff --git a/include/data0types.h b/include/data0types.h
index ab314f8f471..9e536478d68 100644
--- a/include/data0types.h
+++ b/include/data0types.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 2000, 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
+
+*****************************************************************************/
+
/************************************************************************
Some type definitions
-(c) 1994-2000 Innobase Oy
-
Created 9/21/2000 Heikki Tuuri
*************************************************************************/
diff --git a/include/db0err.h b/include/db0err.h
index e899c075164..d6d2a9785a5 100644
--- a/include/db0err.h
+++ b/include/db0err.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Global error codes for the database
-(c) 1996 Innobase Oy
-
Created 5/24/1996 Heikki Tuuri
*******************************************************/
diff --git a/include/dict0boot.h b/include/dict0boot.h
index d9260c8f353..e1556bdb16e 100644
--- a/include/dict0boot.h
+++ b/include/dict0boot.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Data dictionary creation and booting
-(c) 1996 Innobase Oy
-
Created 4/18/1996 Heikki Tuuri
*******************************************************/
diff --git a/include/dict0boot.ic b/include/dict0boot.ic
index 36955e3619c..9b45f9e84be 100644
--- a/include/dict0boot.ic
+++ b/include/dict0boot.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Data dictionary creation and booting
-(c) 1996 Innobase Oy
-
Created 4/18/1996 Heikki Tuuri
*******************************************************/
diff --git a/include/dict0crea.h b/include/dict0crea.h
index 5c00e9df680..9ac3e408f1f 100644
--- a/include/dict0crea.h
+++ b/include/dict0crea.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Database object creation
-(c) 1996 Innobase Oy
-
Created 1/8/1996 Heikki Tuuri
*******************************************************/
diff --git a/include/dict0crea.ic b/include/dict0crea.ic
index b4da2d7e03f..b05385fa121 100644
--- a/include/dict0crea.ic
+++ b/include/dict0crea.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Database object creation
-(c) 1996 Innobase Oy
-
Created 1/8/1996 Heikki Tuuri
*******************************************************/
diff --git a/include/dict0dict.h b/include/dict0dict.h
index bb9f257583c..82a139a7ff9 100644
--- a/include/dict0dict.h
+++ b/include/dict0dict.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Data dictionary system
-(c) 1996 Innobase Oy
-
Created 1/8/1996 Heikki Tuuri
*******************************************************/
@@ -18,7 +34,6 @@ Created 1/8/1996 Heikki Tuuri
#include "sync0rw.h"
#include "mem0mem.h"
#include "rem0types.h"
-#include "btr0types.h"
#include "ut0mem.h"
#include "ut0lst.h"
#include "hash0hash.h"
@@ -995,14 +1010,6 @@ dict_index_set_page(
dict_index_t* index, /* in/out: index */
ulint page); /* in: page number */
/*************************************************************************
-Gets the type of the index tree. */
-UNIV_INLINE
-ulint
-dict_index_get_type(
-/*================*/
- /* out: type */
- const dict_index_t* index); /* in: index */
-/*************************************************************************
Gets the read-write lock of the index tree. */
UNIV_INLINE
rw_lock_t*
diff --git a/include/dict0dict.ic b/include/dict0dict.ic
index e94a96da872..628d207b329 100644
--- a/include/dict0dict.ic
+++ b/include/dict0dict.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/**********************************************************************
Data dictionary system
-(c) 1996 Innobase Oy
-
Created 1/8/1996 Heikki Tuuri
***********************************************************************/
@@ -658,21 +674,6 @@ dict_index_set_page(
}
/*************************************************************************
-Gets the type of the index tree. */
-UNIV_INLINE
-ulint
-dict_index_get_type(
-/*================*/
- /* out: type */
- const dict_index_t* index) /* in: index */
-{
- ut_ad(index);
- ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
-
- return(index->type);
-}
-
-/*************************************************************************
Gets the read-write lock of the index tree. */
UNIV_INLINE
rw_lock_t*
@@ -720,7 +721,8 @@ dict_table_check_if_in_cache_low(
table_fold = ut_fold_string(table_name);
HASH_SEARCH(name_hash, dict_sys->table_hash, table_fold,
- dict_table_t*, table, !strcmp(table->name, table_name));
+ dict_table_t*, table, ut_ad(table->cached),
+ !strcmp(table->name, table_name));
return(table);
}
@@ -745,6 +747,8 @@ dict_table_get_low(
table = dict_load_table(table_name);
}
+ ut_ad(!table || table->cached);
+
return(table);
}
@@ -766,11 +770,14 @@ dict_table_get_on_id_low(
fold = ut_fold_dulint(table_id);
HASH_SEARCH(id_hash, dict_sys->table_id_hash, fold,
- dict_table_t*, table, !ut_dulint_cmp(table->id, table_id));
+ dict_table_t*, table, ut_ad(table->cached),
+ !ut_dulint_cmp(table->id, table_id));
if (table == NULL) {
table = dict_load_table_on_id(table_id);
}
+ ut_ad(!table || table->cached);
+
/* TODO: should get the type information from MySQL */
return(table);
diff --git a/include/dict0load.h b/include/dict0load.h
index 0132e805dde..759cbcdb14a 100644
--- a/include/dict0load.h
+++ b/include/dict0load.h
@@ -1,9 +1,25 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Loads to the memory cache database object definitions
from dictionary tables
-(c) 1996 Innobase Oy
-
Created 4/24/1996 Heikki Tuuri
*******************************************************/
diff --git a/include/dict0load.ic b/include/dict0load.ic
index 1a207fbf0fd..72eac2f621a 100644
--- a/include/dict0load.ic
+++ b/include/dict0load.ic
@@ -1,9 +1,25 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Loads to the memory cache database object definitions
from dictionary tables
-(c) 1996 Innobase Oy
-
Created 4/24/1996 Heikki Tuuri
*******************************************************/
diff --git a/include/dict0mem.h b/include/dict0mem.h
index bfa0636aee5..e2b3cfa3679 100644
--- a/include/dict0mem.h
+++ b/include/dict0mem.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Data dictionary memory object creation
-(c) 1996 Innobase Oy
-
Created 1/8/1996 Heikki Tuuri
*******************************************************/
@@ -12,7 +28,6 @@ Created 1/8/1996 Heikki Tuuri
#include "univ.i"
#include "dict0types.h"
#include "data0type.h"
-#include "data0data.h"
#include "mem0mem.h"
#include "rem0types.h"
#include "btr0types.h"
diff --git a/include/dict0mem.ic b/include/dict0mem.ic
index 9bcefc2a51f..6916393a9cd 100644
--- a/include/dict0mem.ic
+++ b/include/dict0mem.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/**********************************************************************
Data dictionary memory object creation
-(c) 1996 Innobase Oy
-
Created 1/8/1996 Heikki Tuuri
***********************************************************************/
diff --git a/include/dict0types.h b/include/dict0types.h
index 5a5cb719d7d..b93e995e01b 100644
--- a/include/dict0types.h
+++ b/include/dict0types.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Data dictionary global types
-(c) 1996 Innobase Oy
-
Created 1/8/1996 Heikki Tuuri
*******************************************************/
diff --git a/include/dyn0dyn.h b/include/dyn0dyn.h
index 7affccbf67e..c06d6b88d2f 100644
--- a/include/dyn0dyn.h
+++ b/include/dyn0dyn.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
The dynamically allocated array
-(c) 1996 Innobase Oy
-
Created 2/5/1996 Heikki Tuuri
*******************************************************/
diff --git a/include/dyn0dyn.ic b/include/dyn0dyn.ic
index a2ce75e4667..1ef8b284a99 100644
--- a/include/dyn0dyn.ic
+++ b/include/dyn0dyn.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
The dynamically allocated array
-(c) 1996 Innobase Oy
-
Created 2/5/1996 Heikki Tuuri
*******************************************************/
diff --git a/include/eval0eval.h b/include/eval0eval.h
index 652eb02e7f1..75cf9b38c3a 100644
--- a/include/eval0eval.h
+++ b/include/eval0eval.h
@@ -1,9 +1,25 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 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
+
+*****************************************************************************/
+
/******************************************************
SQL evaluator: evaluates simple data structures, like expressions, in
a query graph
-(c) 1997 Innobase Oy
-
Created 12/29/1997 Heikki Tuuri
*******************************************************/
diff --git a/include/eval0eval.ic b/include/eval0eval.ic
index d7bd5b1e0e9..a6330ae441f 100644
--- a/include/eval0eval.ic
+++ b/include/eval0eval.ic
@@ -1,9 +1,25 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 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
+
+*****************************************************************************/
+
/******************************************************
SQL evaluator: evaluates simple data structures, like expressions, in
a query graph
-(c) 1997 Innobase Oy
-
Created 12/29/1997 Heikki Tuuri
*******************************************************/
diff --git a/include/eval0proc.h b/include/eval0proc.h
index 3de31b53a58..58937c18124 100644
--- a/include/eval0proc.h
+++ b/include/eval0proc.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1998, 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
+
+*****************************************************************************/
+
/******************************************************
Executes SQL stored procedures and their control structures
-(c) 1998 Innobase Oy
-
Created 1/20/1998 Heikki Tuuri
*******************************************************/
diff --git a/include/eval0proc.ic b/include/eval0proc.ic
index cf738056576..6bd978ad3fc 100644
--- a/include/eval0proc.ic
+++ b/include/eval0proc.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1998, 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
+
+*****************************************************************************/
+
/******************************************************
Executes SQL stored procedures and their control structures
-(c) 1998 Innobase Oy
-
Created 1/20/1998 Heikki Tuuri
*******************************************************/
diff --git a/include/fil0fil.h b/include/fil0fil.h
index 9e217caec80..587e5ee48a8 100644
--- a/include/fil0fil.h
+++ b/include/fil0fil.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/******************************************************
The low-level file system
-(c) 1995 Innobase Oy
-
Created 10/25/1995 Heikki Tuuri
*******************************************************/
@@ -12,7 +28,6 @@ Created 10/25/1995 Heikki Tuuri
#include "univ.i"
#include "sync0rw.h"
#include "dict0types.h"
-#include "ibuf0types.h"
#include "ut0byte.h"
#include "os0file.h"
@@ -158,14 +173,6 @@ fil_space_get_type(
/* out: FIL_TABLESPACE or FIL_LOG */
ulint id); /* in: space id */
/***********************************************************************
-Returns the ibuf data of a file space. */
-UNIV_INTERN
-ibuf_data_t*
-fil_space_get_ibuf_data(
-/*====================*/
- /* out: ibuf data for this space */
- ulint id); /* in: space id */
-/***********************************************************************
Appends a new file to the chain of files of a space. File must be closed. */
UNIV_INTERN
void
@@ -283,14 +290,6 @@ fil_set_max_space_id_if_bigger(
/*===========================*/
ulint max_id);/* in: maximum known id */
/********************************************************************
-Initializes the ibuf data structure for space 0 == the system tablespace.
-This can be called after the file space headers have been created and the
-dictionary system has been initialized. */
-UNIV_INTERN
-void
-fil_ibuf_init_at_db_start(void);
-/*===========================*/
-/********************************************************************
Writes the flushed lsn and the latest archived log number to the page
header of the first page of each data file in the system tablespace. */
UNIV_INTERN
diff --git a/include/fsp0fsp.h b/include/fsp0fsp.h
index ada805b70bf..1f6ae4b614b 100644
--- a/include/fsp0fsp.h
+++ b/include/fsp0fsp.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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 space management
-(c) 1995 Innobase Oy
-
Created 12/18/1995 Heikki Tuuri
*******************************************************/
diff --git a/include/fsp0fsp.ic b/include/fsp0fsp.ic
index 57f32d7d1b9..f0301cc5e18 100644
--- a/include/fsp0fsp.ic
+++ b/include/fsp0fsp.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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 space management
-(c) 1995 Innobase Oy
-
Created 12/18/1995 Heikki Tuuri
*******************************************************/
diff --git a/include/fut0fut.h b/include/fut0fut.h
index 5d5430a5ffe..4de0c97294c 100644
--- a/include/fut0fut.h
+++ b/include/fut0fut.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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-based utilities
-(c) 1995 Innobase Oy
-
Created 12/13/1995 Heikki Tuuri
***********************************************************************/
diff --git a/include/fut0fut.ic b/include/fut0fut.ic
index 4b2451a2e00..f7e820da008 100644
--- a/include/fut0fut.ic
+++ b/include/fut0fut.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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-based utilities
-(c) 1995 Innobase Oy
-
Created 12/13/1995 Heikki Tuuri
***********************************************************************/
diff --git a/include/fut0lst.h b/include/fut0lst.h
index cd7449cebb6..f812874fe00 100644
--- a/include/fut0lst.h
+++ b/include/fut0lst.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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-based list utilities
-(c) 1995 Innobase Oy
-
Created 11/28/1995 Heikki Tuuri
***********************************************************************/
diff --git a/include/fut0lst.ic b/include/fut0lst.ic
index 67081d79373..5899e996059 100644
--- a/include/fut0lst.ic
+++ b/include/fut0lst.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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-based list utilities
-(c) 1995 Innobase Oy
-
Created 11/28/1995 Heikki Tuuri
***********************************************************************/
diff --git a/include/ha0ha.h b/include/ha0ha.h
index 47f593564df..768f3d7aca3 100644
--- a/include/ha0ha.h
+++ b/include/ha0ha.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/******************************************************
The hash table with external chains
-(c) 1994-1997 Innobase Oy
-
Created 8/18/1994 Heikki Tuuri
*******************************************************/
@@ -36,18 +52,18 @@ ha_search_and_update_if_found_func(
hash_table_t* table, /* in: hash table */
ulint fold, /* in: folded value of the searched data */
void* data, /* in: pointer to the data */
-#ifdef UNIV_DEBUG
+#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
buf_block_t* new_block,/* in: block containing new_data */
-#endif
+#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
void* new_data);/* in: new pointer to the data */
-#ifdef UNIV_DEBUG
+#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
# define ha_search_and_update_if_found(table,fold,data,new_block,new_data) \
ha_search_and_update_if_found_func(table,fold,data,new_block,new_data)
-#else
+#else /* UNIV_AHI_DEBUG || UNIV_DEBUG */
# define ha_search_and_update_if_found(table,fold,data,new_block,new_data) \
ha_search_and_update_if_found_func(table,fold,data,new_data)
-#endif
+#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
/*****************************************************************
Creates a hash table with >= n array cells. The actual number of cells is
chosen to be a prime number slightly bigger than n. */
@@ -92,16 +108,16 @@ ha_insert_for_fold_func(
the same fold value already exists, it is
updated to point to the same data, and no new
node is created! */
-#ifdef UNIV_DEBUG
+#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
buf_block_t* block, /* in: buffer block containing the data */
-#endif /* UNIV_DEBUG */
+#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
void* data); /* in: data, must not be NULL */
-#ifdef UNIV_DEBUG
+#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
# define ha_insert_for_fold(t,f,b,d) ha_insert_for_fold_func(t,f,b,d)
-#else
+#else /* UNIV_AHI_DEBUG || UNIV_DEBUG */
# define ha_insert_for_fold(t,f,b,d) ha_insert_for_fold_func(t,f,d)
-#endif
+#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
/*****************************************************************
Deletes an entry from a hash table. */
@@ -158,9 +174,9 @@ ha_print_info(
typedef struct ha_node_struct ha_node_t;
struct ha_node_struct {
ha_node_t* next; /* next chain node or NULL if none */
-#ifdef UNIV_DEBUG
+#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
buf_block_t* block; /* buffer block containing the data, or NULL */
-#endif /* UNIV_DEBUG */
+#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
void* data; /* pointer to the data */
ulint fold; /* fold value for the data */
};
diff --git a/include/ha0ha.ic b/include/ha0ha.ic
index 9f319be9725..35fd802eaef 100644
--- a/include/ha0ha.ic
+++ b/include/ha0ha.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/************************************************************************
The hash table with external chains
-(c) 1994-1997 Innobase Oy
-
Created 8/18/1994 Heikki Tuuri
*************************************************************************/
@@ -37,22 +53,22 @@ void
ha_node_set_data_func(
/*==================*/
ha_node_t* node, /* in: hash chain node */
-#ifdef UNIV_DEBUG
+#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
buf_block_t* block, /* in: buffer block containing the data */
-#endif /* UNIV_DEBUG */
+#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
void* data) /* in: pointer to the data */
{
-#ifdef UNIV_DEBUG
+#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
node->block = block;
-#endif /* UNIV_DEBUG */
+#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
node->data = data;
}
-#ifdef UNIV_DEBUG
+#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
# define ha_node_set_data(n,b,d) ha_node_set_data_func(n,b,d)
-#else /* UNIV_DEBUG */
+#else /* UNIV_AHI_DEBUG || UNIV_DEBUG */
# define ha_node_set_data(n,b,d) ha_node_set_data_func(n,d)
-#endif /* UNIV_DEBUG */
+#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
/**********************************************************************
Gets the next node in a hash chain. */
diff --git a/include/ha0storage.h b/include/ha0storage.h
index 3828181aa34..f5a3938f434 100644
--- a/include/ha0storage.h
+++ b/include/ha0storage.h
@@ -1,10 +1,26 @@
+/*****************************************************************************
+
+Copyright (c) 2007, 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
+
+*****************************************************************************/
+
/******************************************************
Hash storage.
Provides a data structure that stores chunks of data in
its own storage, avoiding duplicates.
-(c) 2007 Innobase Oy
-
Created September 22, 2007 Vasil Dimov
*******************************************************/
diff --git a/include/ha0storage.ic b/include/ha0storage.ic
index 311161b015e..7ab43bc00ba 100644
--- a/include/ha0storage.ic
+++ b/include/ha0storage.ic
@@ -1,10 +1,26 @@
+/*****************************************************************************
+
+Copyright (c) 2007, 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
+
+*****************************************************************************/
+
/******************************************************
Hash storage.
Provides a data structure that stores chunks of data in
its own storage, avoiding duplicates.
-(c) 2007 Innobase Oy
-
Created September 24, 2007 Vasil Dimov
*******************************************************/
diff --git a/include/ha_prototypes.h b/include/ha_prototypes.h
index 0696885720b..116242b32e4 100644
--- a/include/ha_prototypes.h
+++ b/include/ha_prototypes.h
@@ -1,3 +1,21 @@
+/*****************************************************************************
+
+Copyright (c) 2006, 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
+
+*****************************************************************************/
+
#ifndef HA_INNODB_PROTOTYPES_H
#define HA_INNODB_PROTOTYPES_H
@@ -207,13 +225,15 @@ innobase_get_charset(
void* mysql_thd); /* in: MySQL thread handle */
/**********************************************************************
-Returns true if the thread is executing in innodb_strict_mode. */
+Returns true if the thread supports XA,
+global value of innodb_supports_xa if thd is NULL. */
ibool
-thd_is_strict(
-/*==========*/
- /* out: true if thd is in strict mode */
- void* thd); /* in: thread handle (THD*) */
+thd_supports_xa(
+/*============*/
+ /* out: true if thd supports XA */
+ void* thd); /* in: thread handle (THD*), or NULL to query
+ the global innodb_supports_xa */
/**********************************************************************
Returns the lock wait timeout for the current connection. */
diff --git a/include/handler0alter.h b/include/handler0alter.h
index 59063c85f3c..69488b67b2b 100644
--- a/include/handler0alter.h
+++ b/include/handler0alter.h
@@ -1,7 +1,23 @@
+/*****************************************************************************
+
+Copyright (c) 2005, 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
+
+*****************************************************************************/
+
/******************************************************
Smart ALTER TABLE
-
-(c) 2005-2007 Innobase Oy
*******************************************************/
/*****************************************************************
diff --git a/include/hash0hash.h b/include/hash0hash.h
index 662947b2a59..2b3eea62754 100644
--- a/include/hash0hash.h
+++ b/include/hash0hash.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 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
+
+*****************************************************************************/
+
/******************************************************
The simple hash table utility
-(c) 1997 Innobase Oy
-
Created 5/20/1997 Heikki Tuuri
*******************************************************/
@@ -66,12 +82,8 @@ hash_calc_hash(
hash_table_t* table); /* in: hash table */
/************************************************************************
Assert that the mutex for the table in a hash operation is owned. */
-#ifdef UNIV_SYNC_DEBUG
-# define HASH_ASSERT_OWNED(TABLE, FOLD) \
+#define HASH_ASSERT_OWNED(TABLE, FOLD) \
ut_ad(!(TABLE)->mutexes || mutex_own(hash_get_mutex(TABLE, FOLD)));
-#else
-# define HASH_ASSERT_OWNED(TABLE, FOLD)
-#endif
/***********************************************************************
Inserts a struct to a hash table. */
@@ -94,7 +106,7 @@ do {\
\
while (struct3333->NAME != NULL) {\
\
- struct3333 = struct3333->NAME;\
+ struct3333 = (TYPE*) struct3333->NAME;\
}\
\
struct3333->NAME = DATA;\
@@ -125,11 +137,11 @@ do {\
HASH_ASSERT_VALID(DATA->NAME);\
cell3333->node = DATA->NAME;\
} else {\
- struct3333 = cell3333->node;\
+ struct3333 = (TYPE*) cell3333->node;\
\
while (struct3333->NAME != DATA) {\
\
- struct3333 = struct3333->NAME;\
+ struct3333 = (TYPE*) struct3333->NAME;\
ut_a(struct3333);\
}\
\
@@ -151,7 +163,7 @@ Gets the next struct in a hash chain, NULL if none. */
/************************************************************************
Looks for a struct in a hash table. */
-#define HASH_SEARCH(NAME, TABLE, FOLD, TYPE, DATA, TEST)\
+#define HASH_SEARCH(NAME, TABLE, FOLD, TYPE, DATA, ASSERTION, TEST)\
{\
\
HASH_ASSERT_OWNED(TABLE, FOLD)\
@@ -160,6 +172,7 @@ Looks for a struct in a hash table. */
HASH_ASSERT_VALID(DATA);\
\
while ((DATA) != NULL) {\
+ ASSERTION;\
if (TEST) {\
break;\
} else {\
@@ -169,6 +182,32 @@ Looks for a struct in a hash table. */
}\
}
+/************************************************************************
+Looks for an item in all hash buckets. */
+#define HASH_SEARCH_ALL(NAME, TABLE, TYPE, DATA, ASSERTION, TEST) \
+do { \
+ ulint i3333; \
+ \
+ for (i3333 = (TABLE)->n_cells; i3333--; ) { \
+ (DATA) = (TYPE) HASH_GET_FIRST(TABLE, i3333); \
+ \
+ while ((DATA) != NULL) { \
+ HASH_ASSERT_VALID(DATA); \
+ ASSERTION; \
+ \
+ if (TEST) { \
+ break; \
+ } \
+ \
+ (DATA) = (TYPE) HASH_GET_NEXT(NAME, DATA); \
+ } \
+ \
+ if ((DATA) != NULL) { \
+ break; \
+ } \
+ } \
+} while (0)
+
/****************************************************************
Gets the nth cell in a hash table. */
UNIV_INLINE
@@ -363,10 +402,10 @@ struct hash_cell_struct{
/* The hash table structure */
struct hash_table_struct {
-#ifdef UNIV_DEBUG
+#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
ibool adaptive;/* TRUE if this is the hash table of the
adaptive hash index */
-#endif /* UNIV_DEBUG */
+#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
ulint n_cells;/* number of cells in the hash table */
hash_cell_t* array; /* pointer to cell array */
ulint n_mutexes;/* if mutexes != NULL, then the number of
diff --git a/include/hash0hash.ic b/include/hash0hash.ic
index 37eb5ec2813..792fdcbf4f8 100644
--- a/include/hash0hash.ic
+++ b/include/hash0hash.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 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
+
+*****************************************************************************/
+
/******************************************************
The simple hash table utility
-(c) 1997 Innobase Oy
-
Created 5/20/1997 Heikki Tuuri
*******************************************************/
@@ -71,7 +87,8 @@ hash_get_mutex_no(
ulint fold) /* in: fold */
{
ut_ad(ut_is_2pow(table->n_mutexes));
- return(ut_2pow_remainder(fold, table->n_mutexes));
+ return(ut_2pow_remainder(hash_calc_hash(fold, table),
+ table->n_mutexes));
}
/****************************************************************
diff --git a/include/ibuf0ibuf.h b/include/ibuf0ibuf.h
index c96ddd0c2e7..41e2392cc4a 100644
--- a/include/ibuf0ibuf.h
+++ b/include/ibuf0ibuf.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 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
+
+*****************************************************************************/
+
/******************************************************
Insert buffer
-(c) 1997 Innobase Oy
-
Created 7/19/1997 Heikki Tuuri
*******************************************************/
@@ -12,13 +28,26 @@ Created 7/19/1997 Heikki Tuuri
#include "univ.i"
#include "dict0mem.h"
-#include "dict0dict.h"
#include "mtr0mtr.h"
#include "que0types.h"
#include "ibuf0types.h"
#include "fsp0fsp.h"
-extern ibuf_t* ibuf;
+/** Combinations of operations that can be buffered. Because the enum
+values are used for indexing innobase_change_buffering_values[], they
+should start at 0 and there should not be any gaps. */
+typedef enum {
+ IBUF_USE_NONE = 0,
+ IBUF_USE_INSERT, /* insert */
+
+ IBUF_USE_COUNT /* number of entries in ibuf_use_t */
+} ibuf_use_t;
+
+/** Operations that can currently be buffered. */
+extern ibuf_use_t ibuf_use;
+
+/** The insert buffer control structure */
+extern ibuf_t* ibuf;
/* The purpose of the insert buffer is to reduce random disk access.
When we wish to insert a record into a non-unique secondary index and
@@ -41,18 +70,6 @@ separately committed mini-transaction, because in crash recovery, the
free bits could momentarily be set too high. */
/**********************************************************************
-Creates the insert buffer data struct for a single tablespace. Reads the
-root page of the insert buffer tree in the tablespace. This function can
-be called only after the dictionary system has been initialized, as this
-creates also the insert buffer table and index for this tablespace. */
-UNIV_INTERN
-ibuf_data_t*
-ibuf_data_init_for_space(
-/*=====================*/
- /* out, own: ibuf data struct, linked to the list
- in ibuf control structure. */
- ulint space); /* in: space id */
-/**********************************************************************
Creates the insert buffer data structure at a database startup and
initializes the data structures for the insert buffer of each tablespace. */
UNIV_INTERN
@@ -199,7 +216,8 @@ ibuf_bitmap_page(
0 for uncompressed pages */
ulint page_no);/* in: page number */
/***************************************************************************
-Checks if a page is a level 2 or 3 page in the ibuf hierarchy of pages. */
+Checks if a page is a level 2 or 3 page in the ibuf hierarchy of pages.
+Must not be called when recv_no_ibuf_operations==TRUE. */
UNIV_INTERN
ibool
ibuf_page(
@@ -207,29 +225,19 @@ ibuf_page(
/* out: TRUE if level 2 or level 3 page */
ulint space, /* in: space id */
ulint zip_size,/* in: compressed page size in bytes, or 0 */
- ulint page_no);/* in: page number */
-/***************************************************************************
-Checks if a page is a level 2 or 3 page in the ibuf hierarchy of pages. */
-UNIV_INTERN
-ibool
-ibuf_page_low(
-/*==========*/
- /* out: TRUE if level 2 or level 3 page */
- ulint space, /* in: space id */
- ulint zip_size,/* in: compressed page size in bytes, or 0 */
ulint page_no,/* in: page number */
mtr_t* mtr); /* in: mtr which will contain an x-latch to the
bitmap page if the page is not one of the fixed
- address ibuf pages */
+ address ibuf pages, or NULL, in which case a new
+ transaction is created. */
/***************************************************************************
Frees excess pages from the ibuf free list. This function is called when an OS
thread calls fsp services to allocate a new file segment, or a new page to a
file segment, and the thread did not own the fsp latch before this call. */
UNIV_INTERN
void
-ibuf_free_excess_pages(
-/*===================*/
- ulint space); /* in: space id */
+ibuf_free_excess_pages(void);
+/*========================*/
/*************************************************************************
Makes an index insert to the insert buffer, instead of directly to the disk
page, if this is possible. Does not do insert if the index is clustered
@@ -351,6 +359,9 @@ for the file segment from which the pages for the ibuf tree are allocated */
#define IBUF_HEADER PAGE_DATA
#define IBUF_TREE_SEG_HEADER 0 /* fseg header for ibuf tree */
+/* The insert buffer tree itself is always located in space 0. */
+#define IBUF_SPACE_ID 0
+
#ifndef UNIV_NONINL
#include "ibuf0ibuf.ic"
#endif
diff --git a/include/ibuf0ibuf.ic b/include/ibuf0ibuf.ic
index d5842fa5a27..170e5dba473 100644
--- a/include/ibuf0ibuf.ic
+++ b/include/ibuf0ibuf.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 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
+
+*****************************************************************************/
+
/******************************************************
Insert buffer
-(c) 1997 Innobase Oy
-
Created 7/19/1997 Heikki Tuuri
*******************************************************/
@@ -18,36 +34,29 @@ If there is this much of free space, the corresponding bits are set in the
ibuf bitmap. */
#define IBUF_PAGE_SIZE_PER_FREE_SPACE 32
-/* Insert buffer data struct for a single tablespace */
-struct ibuf_data_struct{
- ulint space; /* space id */
- ulint seg_size;/* allocated pages if the file segment
- containing ibuf header and tree */
- ulint size; /* size of the insert buffer tree in pages */
- ibool empty; /* after an insert to the ibuf tree is
- performed, this is set to FALSE, and if a
- contract operation finds the tree empty, this
- is set to TRUE */
- ulint free_list_len;
- /* length of the free list */
- ulint height; /* tree height */
- dict_index_t* index; /* insert buffer index */
- UT_LIST_NODE_T(ibuf_data_t) data_list;
- /* list of ibuf data structs */
- ulint n_inserts;/* number of inserts made to the insert
- buffer */
- ulint n_merges;/* number of pages merged */
- ulint n_merged_recs;/* number of records merged */
-};
+/* Insert buffer struct */
struct ibuf_struct{
ulint size; /* current size of the ibuf index
- trees in pages */
- ulint max_size; /* recommended maximum size in pages
- for the ibuf index tree */
- UT_LIST_BASE_NODE_T(ibuf_data_t) data_list;
- /* list of ibuf data structs for
- each tablespace */
+ tree, in pages */
+ ulint max_size; /* recommended maximum size of the
+ ibuf index tree, in pages */
+ ulint seg_size; /* allocated pages of the file
+ segment containing ibuf header and
+ tree */
+ ibool empty; /* after an insert to the ibuf tree
+ is performed, this is set to FALSE,
+ and if a contract operation finds
+ the tree empty, this is set to
+ TRUE */
+ ulint free_list_len; /* length of the free list */
+ ulint height; /* tree height */
+ dict_index_t* index; /* insert buffer index */
+
+ ulint n_inserts; /* number of inserts made to
+ the insert buffer */
+ ulint n_merges; /* number of pages merged */
+ ulint n_merged_recs; /* number of records merged */
};
/****************************************************************************
@@ -86,12 +95,13 @@ ibuf_should_try(
a secondary index when we
decide */
{
- if (!dict_index_is_clust(index)
+ if (ibuf_use != IBUF_USE_NONE
+ && !dict_index_is_clust(index)
&& (ignore_sec_unique || !dict_index_is_unique(index))) {
ibuf_flush_count++;
- if (ibuf_flush_count % 8 == 0) {
+ if (ibuf_flush_count % 4 == 0) {
buf_LRU_try_free_flushed_blocks();
}
diff --git a/include/ibuf0types.h b/include/ibuf0types.h
index fb202ac44b0..264415196a1 100644
--- a/include/ibuf0types.h
+++ b/include/ibuf0types.h
@@ -1,15 +1,30 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 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
+
+*****************************************************************************/
+
/******************************************************
Insert buffer global types
-(c) 1997 Innobase Oy
-
Created 7/29/1997 Heikki Tuuri
*******************************************************/
#ifndef ibuf0types_h
#define ibuf0types_h
-typedef struct ibuf_data_struct ibuf_data_t;
typedef struct ibuf_struct ibuf_t;
#endif
diff --git a/include/lock0iter.h b/include/lock0iter.h
index e3de9b57a90..3cd47bb95d2 100644
--- a/include/lock0iter.h
+++ b/include/lock0iter.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 2007, 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
+
+*****************************************************************************/
+
/******************************************************
Lock queue iterator type and function prototypes.
-(c) 2007 Innobase Oy
-
Created July 16, 2007 Vasil Dimov
*******************************************************/
diff --git a/include/lock0lock.h b/include/lock0lock.h
index 1c9ee9c5442..2deeb804737 100644
--- a/include/lock0lock.h
+++ b/include/lock0lock.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
The transaction lock system
-(c) 1996 Innobase Oy
-
Created 5/7/1996 Heikki Tuuri
*******************************************************/
diff --git a/include/lock0lock.ic b/include/lock0lock.ic
index bd0bcabad70..f978cc70678 100644
--- a/include/lock0lock.ic
+++ b/include/lock0lock.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
The transaction lock system
-(c) 1996 Innobase Oy
-
Created 5/7/1996 Heikki Tuuri
*******************************************************/
diff --git a/include/lock0priv.h b/include/lock0priv.h
index 809710ced9e..0a0d41e6aaa 100644
--- a/include/lock0priv.h
+++ b/include/lock0priv.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 2007, 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
+
+*****************************************************************************/
+
/******************************************************
Lock module internal structures and methods.
-(c) 2007 Innobase Oy
-
Created July 12, 2007 Vasil Dimov
*******************************************************/
diff --git a/include/lock0priv.ic b/include/lock0priv.ic
index d119d00cde2..ae633a4fc61 100644
--- a/include/lock0priv.ic
+++ b/include/lock0priv.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 2007, 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
+
+*****************************************************************************/
+
/******************************************************
Lock module internal inline methods.
-(c) 2007 Innobase Oy
-
Created July 16, 2007 Vasil Dimov
*******************************************************/
diff --git a/include/lock0types.h b/include/lock0types.h
index 2c27c476269..52631b56532 100644
--- a/include/lock0types.h
+++ b/include/lock0types.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
The transaction lock system global types
-(c) 1996 Innobase Oy
-
Created 5/7/1996 Heikki Tuuri
*******************************************************/
diff --git a/include/log0log.h b/include/log0log.h
index a25efdd2a37..51b57ae929c 100644
--- a/include/log0log.h
+++ b/include/log0log.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/******************************************************
Database log
-(c) 1995 Innobase Oy
-
Created 12/9/1995 Heikki Tuuri
*******************************************************/
@@ -255,6 +271,7 @@ UNIV_INTERN
void
log_groups_write_checkpoint_info(void);
/*==================================*/
+#ifdef UNIV_HOTBACKUP
/**********************************************************
Writes info to a buffer of a log group when log files are created in
backup restoration. */
@@ -267,6 +284,7 @@ log_reset_first_header_and_checkpoint(
ib_uint64_t start); /* in: lsn of the start of the first log file;
we pretend that there is a checkpoint at
start + LOG_BLOCK_HDR_SIZE */
+#endif /* UNIV_HOTBACKUP */
/************************************************************************
Starts an archiving operation. */
UNIV_INTERN
@@ -514,7 +532,9 @@ extern log_t* log_sys;
/* Values used as flags */
#define LOG_FLUSH 7652559
#define LOG_CHECKPOINT 78656949
-#define LOG_ARCHIVE 11122331
+#ifdef UNIV_LOG_ARCHIVE
+# define LOG_ARCHIVE 11122331
+#endif /* UNIV_LOG_ARCHIVE */
#define LOG_RECOVER 98887331
/* The counting of lsn's starts from this value: this must be non-zero */
diff --git a/include/log0log.ic b/include/log0log.ic
index e2eecf3fb77..85eebda4942 100644
--- a/include/log0log.ic
+++ b/include/log0log.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/******************************************************
Database log
-(c) 1995 Innobase Oy
-
Created 12/9/1995 Heikki Tuuri
*******************************************************/
diff --git a/include/log0recv.h b/include/log0recv.h
index 9695211ab20..e3fe9ed330a 100644
--- a/include/log0recv.h
+++ b/include/log0recv.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 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
+
+*****************************************************************************/
+
/******************************************************
Recovery
-(c) 1997 Innobase Oy
-
Created 9/20/1997 Heikki Tuuri
*******************************************************/
@@ -17,7 +33,6 @@ Created 9/20/1997 Heikki Tuuri
#ifdef UNIV_HOTBACKUP
extern ibool recv_replay_file_ops;
-#endif /* UNIV_HOTBACKUP */
/***********************************************************************
Reads the checkpoint info needed in hot backup. */
@@ -55,6 +70,7 @@ recv_scan_log_seg_for_backup(
ulint* n_bytes_scanned);/* out: how much we were able to
scan, smaller than buf_len if log
data ended here */
+#endif /* UNIV_HOTBACKUP */
/***********************************************************************
Returns TRUE if recovery is currently running. */
UNIV_INLINE
@@ -91,16 +107,25 @@ recv_recovery_from_checkpoint_finish should be called later to complete
the recovery and free the resources used in it. */
UNIV_INTERN
ulint
-recv_recovery_from_checkpoint_start(
-/*================================*/
+recv_recovery_from_checkpoint_start_func(
+/*=====================================*/
/* out: error code or DB_SUCCESS */
+#ifdef UNIV_LOG_ARCHIVE
ulint type, /* in: LOG_CHECKPOINT or LOG_ARCHIVE */
ib_uint64_t limit_lsn, /* in: recover up to this lsn
if possible */
+#endif /* UNIV_LOG_ARCHIVE */
ib_uint64_t min_flushed_lsn,/* in: min flushed lsn from
data files */
ib_uint64_t max_flushed_lsn);/* in: max flushed lsn from
data files */
+#ifdef UNIV_LOG_ARCHIVE
+# define recv_recovery_from_checkpoint_start(type,lim,min,max) \
+ recv_recovery_from_checkpoint_start_func(type,lim,min,max)
+#else /* UNIV_LOG_ARCHIVE */
+# define recv_recovery_from_checkpoint_start(type,lim,min,max) \
+ recv_recovery_from_checkpoint_start_func(min,max)
+#endif /* UNIV_LOG_ARCHIVE */
/************************************************************
Completes recovery from a checkpoint. */
UNIV_INTERN
@@ -321,9 +346,11 @@ struct recv_sys_struct{
scan find a corrupt log block, or a corrupt
log record, or there is a log parsing
buffer overflow */
+#ifdef UNIV_LOG_ARCHIVE
log_group_t* archive_group;
/* in archive recovery: the log group whose
archive is read */
+#endif /* !UNIV_LOG_ARCHIVE */
mem_heap_t* heap; /* memory heap of log records and file
addresses*/
hash_table_t* addr_hash;/* hash table of file addresses of pages */
diff --git a/include/log0recv.ic b/include/log0recv.ic
index 50ce8a87006..e114bede38f 100644
--- a/include/log0recv.ic
+++ b/include/log0recv.ic
@@ -1,15 +1,28 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 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
+
+*****************************************************************************/
+
/******************************************************
Recovery
-(c) 1997 Innobase Oy
-
Created 9/20/1997 Heikki Tuuri
*******************************************************/
-#include "sync0sync.h"
-#include "mem0mem.h"
-#include "log0log.h"
-#include "os0file.h"
+#include "univ.i"
extern ibool recv_recovery_from_backup_on;
diff --git a/include/mach0data.h b/include/mach0data.h
index 0fd005dbb96..78b48af0836 100644
--- a/include/mach0data.h
+++ b/include/mach0data.h
@@ -1,9 +1,25 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/**********************************************************************
Utilities for converting data from the database file
to the machine format.
-(c) 1995 Innobase Oy
-
Created 11/28/1995 Heikki Tuuri
***********************************************************************/
diff --git a/include/mach0data.ic b/include/mach0data.ic
index def5918218e..5dda9aece2f 100644
--- a/include/mach0data.ic
+++ b/include/mach0data.ic
@@ -1,9 +1,25 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/**********************************************************************
Utilities for converting data from the database file
to the machine format.
-(c) 1995 Innobase Oy
-
Created 11/28/1995 Heikki Tuuri
***********************************************************************/
diff --git a/include/mem0dbg.h b/include/mem0dbg.h
index 5ae2091dd69..0568a595d06 100644
--- a/include/mem0dbg.h
+++ b/include/mem0dbg.h
@@ -1,9 +1,25 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/******************************************************
The memory management: the debug code. This is not a compilation module,
but is included in mem0mem.* !
-(c) 1994, 1995 Innobase Oy
-
Created 6/9/1994 Heikki Tuuri
*******************************************************/
diff --git a/include/mem0dbg.ic b/include/mem0dbg.ic
index a5f2e2c3e12..bf695fee785 100644
--- a/include/mem0dbg.ic
+++ b/include/mem0dbg.ic
@@ -1,9 +1,25 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/************************************************************************
The memory management: the debug code. This is not an independent
compilation module but is included in mem0mem.*.
-(c) 1994, 1995 Innobase Oy
-
Created 6/8/1994 Heikki Tuuri
*************************************************************************/
diff --git a/include/mem0mem.h b/include/mem0mem.h
index 8993373c519..c20e7815001 100644
--- a/include/mem0mem.h
+++ b/include/mem0mem.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/******************************************************
The memory management
-(c) 1994, 1995 Innobase Oy
-
Created 6/9/1994 Heikki Tuuri
*******************************************************/
diff --git a/include/mem0mem.ic b/include/mem0mem.ic
index db067d6734c..04b4234904a 100644
--- a/include/mem0mem.ic
+++ b/include/mem0mem.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/************************************************************************
The memory management
-(c) 1994, 1995 Innobase Oy
-
Created 6/8/1994 Heikki Tuuri
*************************************************************************/
diff --git a/include/mem0pool.h b/include/mem0pool.h
index 55840042591..7e51b07bfe0 100644
--- a/include/mem0pool.h
+++ b/include/mem0pool.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/******************************************************
The lowest-level memory management
-(c) 1994, 1995 Innobase Oy
-
Created 6/9/1994 Heikki Tuuri
*******************************************************/
diff --git a/include/mem0pool.ic b/include/mem0pool.ic
index 4e8c08733ed..4cc65e754ce 100644
--- a/include/mem0pool.ic
+++ b/include/mem0pool.ic
@@ -1,7 +1,23 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/************************************************************************
The lowest-level memory management
-(c) 1994, 1995 Innobase Oy
-
Created 6/8/1994 Heikki Tuuri
*************************************************************************/
diff --git a/include/mtr0log.h b/include/mtr0log.h
index 5acb82619ce..44374cdf1a4 100644
--- a/include/mtr0log.h
+++ b/include/mtr0log.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/******************************************************
Mini-transaction logging routines
-(c) 1995 Innobase Oy
-
Created 12/7/1995 Heikki Tuuri
*******************************************************/
diff --git a/include/mtr0log.ic b/include/mtr0log.ic
index 3209792b2cc..5f05befb9cc 100644
--- a/include/mtr0log.ic
+++ b/include/mtr0log.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/******************************************************
Mini-transaction logging routines
-(c) 1995 Innobase Oy
-
Created 12/7/1995 Heikki Tuuri
*******************************************************/
@@ -191,12 +207,8 @@ mlog_write_initial_log_record_fast(
#endif
#ifdef UNIV_DEBUG
- //buf_pool_mutex_enter();
- rw_lock_s_lock(&page_hash_latch);
/* We now assume that all x-latched pages have been modified! */
block = (buf_block_t*) buf_block_align(ptr);
- //buf_pool_mutex_exit();
- rw_lock_s_unlock(&page_hash_latch);
if (!mtr_memo_contains(mtr, block, MTR_MEMO_MODIFY)) {
diff --git a/include/mtr0mtr.h b/include/mtr0mtr.h
index 645d56c55c5..a29f6c73141 100644
--- a/include/mtr0mtr.h
+++ b/include/mtr0mtr.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/******************************************************
Mini-transaction buffer
-(c) 1995 Innobase Oy
-
Created 11/26/1995 Heikki Tuuri
*******************************************************/
@@ -344,10 +360,14 @@ struct mtr_struct{
this mtr */
ib_uint64_t end_lsn;/* end lsn of the possible log entry for
this mtr */
+#ifdef UNIV_DEBUG
ulint magic_n;
+#endif /* UNIV_DEBUG */
};
-#define MTR_MAGIC_N 54551
+#ifdef UNIV_DEBUG
+# define MTR_MAGIC_N 54551
+#endif /* UNIV_DEBUG */
#define MTR_ACTIVE 12231
#define MTR_COMMITTING 56456
diff --git a/include/mtr0mtr.ic b/include/mtr0mtr.ic
index 7bccf65537f..7d6d99917b7 100644
--- a/include/mtr0mtr.ic
+++ b/include/mtr0mtr.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/******************************************************
Mini-transaction buffer
-(c) 1995 Innobase Oy
-
Created 11/26/1995 Heikki Tuuri
*******************************************************/
@@ -28,10 +44,9 @@ mtr_start(
mtr->modifications = FALSE;
mtr->n_log_recs = 0;
-#ifdef UNIV_DEBUG
- mtr->state = MTR_ACTIVE;
- mtr->magic_n = MTR_MAGIC_N;
-#endif
+ ut_d(mtr->state = MTR_ACTIVE);
+ ut_d(mtr->magic_n = MTR_MAGIC_N);
+
return(mtr);
}
diff --git a/include/mtr0types.h b/include/mtr0types.h
index e3b6ec9a84f..23634c98827 100644
--- a/include/mtr0types.h
+++ b/include/mtr0types.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/******************************************************
Mini-transaction buffer global types
-(c) 1995 Innobase Oy
-
Created 11/26/1995 Heikki Tuuri
*******************************************************/
diff --git a/include/mysql_addons.h b/include/mysql_addons.h
index 3c2933742c8..2e8c87f5962 100644
--- a/include/mysql_addons.h
+++ b/include/mysql_addons.h
@@ -1,3 +1,21 @@
+/*****************************************************************************
+
+Copyright (c) 2007, 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
+
+*****************************************************************************/
+
/******************************************************
This file contains functions that need to be added to
MySQL code but have not been added yet.
@@ -10,38 +28,5 @@ function in this file.
When MySQL commits the function it can be deleted from
here. In a perfect world this file exists but is empty.
-(c) 2007 Innobase Oy
-
Created November 07, 2007 Vasil Dimov
*******************************************************/
-
-#include <my_global.h> /* for my_bool */
-#include <mysql/plugin.h> /* for MYSQL_THD */
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/***********************************************************************
-Retrieve THD::thread_id
-http://bugs.mysql.com/30930 */
-
-unsigned long
-ib_thd_get_thread_id(
-/*=================*/
- /* out: THD::thread_id */
- const void* thd); /* in: THD */
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-/* http://bugs.mysql.com/40360 */
-/* http://lists.mysql.com/commits/57450 */
-/**
- See if the binary log is engaged for a thread, i.e., open and
- LOG_BIN is set.
-
- @return @c true if the binlog is active, @c false otherwise.
-*/
-my_bool ib_bin_log_is_engaged(const MYSQL_THD thd);
diff --git a/include/os0file.h b/include/os0file.h
index 5de08aa12f4..26897226ff4 100644
--- a/include/os0file.h
+++ b/include/os0file.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/******************************************************
The interface to the operating system file io
-(c) 1995 Innobase Oy
-
Created 10/21/1995 Heikki Tuuri
*******************************************************/
diff --git a/include/os0proc.h b/include/os0proc.h
index e6586801e61..19b0b112638 100644
--- a/include/os0proc.h
+++ b/include/os0proc.h
@@ -1,9 +1,25 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/******************************************************
The interface to the operating system
process control primitives
-(c) 1995 Innobase Oy
-
Created 9/30/1995 Heikki Tuuri
*******************************************************/
@@ -34,14 +50,6 @@ ulint
os_proc_get_number(void);
/*====================*/
/********************************************************************
-Allocates non-cacheable memory. */
-UNIV_INTERN
-void*
-os_mem_alloc_nocache(
-/*=================*/
- /* out: allocated memory */
- ulint n); /* in: number of bytes */
-/********************************************************************
Allocates large pages memory. */
UNIV_INTERN
void*
diff --git a/include/os0proc.ic b/include/os0proc.ic
index 651ba1f17e3..9f1fb01866d 100644
--- a/include/os0proc.ic
+++ b/include/os0proc.ic
@@ -1,9 +1,25 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/******************************************************
The interface to the operating system
process control primitives
-(c) 1995 Innobase Oy
-
Created 9/30/1995 Heikki Tuuri
*******************************************************/
diff --git a/include/os0sync.h b/include/os0sync.h
index ee25b9fbe87..7e058266762 100644
--- a/include/os0sync.h
+++ b/include/os0sync.h
@@ -1,11 +1,35 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 2008, Google Inc.
+
+Portions of this file contain modifications contributed and copyrighted by
+Google, Inc. Those modifications are gratefully acknowledged and are described
+briefly in the InnoDB documentation. The contributions by Google are
+incorporated with their permission, and subject to the conditions contained in
+the file COPYING.Google.
+
+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
+
+*****************************************************************************/
+
/******************************************************
The interface to the operating system
synchronization primitives.
-(c) 1995 Innobase Oy
-
Created 9/6/1995 Heikki Tuuri
*******************************************************/
+
#ifndef os0sync_h
#define os0sync_h
@@ -261,6 +285,23 @@ os_fast_mutex_free(
/*===============*/
os_fast_mutex_t* fast_mutex); /* in: mutex to free */
+#ifdef HAVE_GCC_ATOMIC_BUILTINS
+/**************************************************************
+Atomic compare-and-swap for InnoDB. Currently requires GCC atomic builtins.
+Returns true if swapped, ptr is pointer to target, old_val is value to
+compare to, new_val is the value to swap in. */
+#define os_compare_and_swap(ptr, old_val, new_val) \
+ __sync_bool_compare_and_swap(ptr, old_val, new_val)
+
+/**************************************************************
+Atomic increment for InnoDB. Currently requires GCC atomic builtins.
+Returns the resulting value, ptr is pointer to target, amount is the
+amount of increment. */
+#define os_atomic_increment(ptr, amount) \
+ __sync_add_and_fetch(ptr, amount)
+
+#endif /* HAVE_GCC_ATOMIC_BUILTINS */
+
#ifndef UNIV_NONINL
#include "os0sync.ic"
#endif
diff --git a/include/os0sync.ic b/include/os0sync.ic
index 75dea9369c2..5c03d184c7c 100644
--- a/include/os0sync.ic
+++ b/include/os0sync.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/******************************************************
The interface to the operating system synchronization primitives.
-(c) 1995 Innobase Oy
-
Created 9/6/1995 Heikki Tuuri
*******************************************************/
diff --git a/include/os0thread.h b/include/os0thread.h
index 2ed9fd975d7..863596bfa84 100644
--- a/include/os0thread.h
+++ b/include/os0thread.h
@@ -1,9 +1,25 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/******************************************************
The interface to the operating system
process and thread control primitives
-(c) 1995 Innobase Oy
-
Created 9/8/1995 Heikki Tuuri
*******************************************************/
diff --git a/include/os0thread.ic b/include/os0thread.ic
index a75aa3abb34..a86b203809c 100644
--- a/include/os0thread.ic
+++ b/include/os0thread.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/******************************************************
The interface to the operating system
process and thread control primitives
-(c) 1995 Innobase Oy
-
Created 9/8/1995 Heikki Tuuri
*******************************************************/
diff --git a/include/page0cur.h b/include/page0cur.h
index e9ec55381d8..960ecdddf4e 100644
--- a/include/page0cur.h
+++ b/include/page0cur.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/************************************************************************
The page cursor
-(c) 1994-1996 Innobase Oy
-
Created 10/4/1994 Heikki Tuuri
*************************************************************************/
diff --git a/include/page0cur.ic b/include/page0cur.ic
index 2a8ef824149..9cf10ea5e3f 100644
--- a/include/page0cur.ic
+++ b/include/page0cur.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/************************************************************************
The page cursor
-(c) 1994-1996 Innobase Oy
-
Created 10/4/1994 Heikki Tuuri
*************************************************************************/
diff --git a/include/page0page.h b/include/page0page.h
index dceba8b7714..e3de6901ee1 100644
--- a/include/page0page.h
+++ b/include/page0page.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/******************************************************
Index page routines
-(c) 1994-1996 Innobase Oy
-
Created 2/2/1994 Heikki Tuuri
*******************************************************/
diff --git a/include/page0page.ic b/include/page0page.ic
index fae11b6cda3..df0f6f8b360 100644
--- a/include/page0page.ic
+++ b/include/page0page.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/******************************************************
Index page routines
-(c) 1994-1996 Innobase Oy
-
Created 2/2/1994 Heikki Tuuri
*******************************************************/
diff --git a/include/page0types.h b/include/page0types.h
index e2edbcddef2..06af7a63d58 100644
--- a/include/page0types.h
+++ b/include/page0types.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/******************************************************
Index page routines
-(c) 1994-1996 Innobase Oy
-
Created 2/2/1994 Heikki Tuuri
*******************************************************/
diff --git a/include/page0zip.h b/include/page0zip.h
index 6795dd3e148..0183e013d05 100644
--- a/include/page0zip.h
+++ b/include/page0zip.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 2005, 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
+
+*****************************************************************************/
+
/******************************************************
Compressed page interface
-(c) 2005 Innobase Oy
-
Created June 2005 by Marko Makela
*******************************************************/
diff --git a/include/page0zip.ic b/include/page0zip.ic
index ece24941f75..3db5f025c31 100644
--- a/include/page0zip.ic
+++ b/include/page0zip.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 2005, 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
+
+*****************************************************************************/
+
/******************************************************
Compressed page interface
-(c) 2005 Innobase Oy
-
Created June 2005 by Marko Makela
*******************************************************/
@@ -128,7 +144,8 @@ page_zip_set_size(
ut_ad(ut_is_2pow(size));
- for (ssize = 1; size > (ulint) (512 << ssize); ssize++);
+ for (ssize = 1; size > (ulint) (512 << ssize); ssize++) {
+ }
page_zip->ssize = ssize;
} else {
diff --git a/include/pars0grm.h b/include/pars0grm.h
index 0062b8314ee..3de233eed3a 100644
--- a/include/pars0grm.h
+++ b/include/pars0grm.h
@@ -1,27 +1,29 @@
-/* A Bison parser, made by GNU Bison 1.875d. */
+/*****************************************************************************
+
+Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software
+Foundation, Inc.
-/* Skeleton parser for Yacc-like parsing with Bison,
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+As a special exception, when this file is copied by Bison into a
+Bison output file, you may use that output file without restriction.
+This special exception was added by the Free Software Foundation
+in version 1.24 of Bison.
- 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; either version 2, or (at your option)
- any later version.
+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.
+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. */
+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
-/* As a special exception, when this file is copied by Bison into a
- Bison output file, you may use that output file without restriction.
- This special exception was added by the Free Software Foundation
- in version 1.24 of Bison. */
+*****************************************************************************/
+
+/* A Bison parser, made by GNU Bison 1.875d. */
/* Tokens. */
#ifndef YYTOKENTYPE
diff --git a/include/pars0opt.h b/include/pars0opt.h
index 1b407812b34..02524e9d893 100644
--- a/include/pars0opt.h
+++ b/include/pars0opt.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 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
+
+*****************************************************************************/
+
/******************************************************
Simple SQL optimizer
-(c) 1997 Innobase Oy
-
Created 12/21/1997 Heikki Tuuri
*******************************************************/
diff --git a/include/pars0opt.ic b/include/pars0opt.ic
index 0bfa8526bee..35653453b30 100644
--- a/include/pars0opt.ic
+++ b/include/pars0opt.ic
@@ -1,7 +1,23 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 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
+
+*****************************************************************************/
+
/******************************************************
Simple SQL optimizer
-(c) 1997 Innobase Oy
-
Created 12/21/1997 Heikki Tuuri
*******************************************************/
diff --git a/include/pars0pars.h b/include/pars0pars.h
index f1847d421d0..e5693ee5575 100644
--- a/include/pars0pars.h
+++ b/include/pars0pars.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
SQL parser
-(c) 1996 Innobase Oy
-
Created 11/19/1996 Heikki Tuuri
*******************************************************/
diff --git a/include/pars0pars.ic b/include/pars0pars.ic
index 155b6659ace..3a55ad86f48 100644
--- a/include/pars0pars.ic
+++ b/include/pars0pars.ic
@@ -1,7 +1,23 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
SQL parser
-(c) 1996 Innobase Oy
-
Created 11/19/1996 Heikki Tuuri
*******************************************************/
diff --git a/include/pars0sym.h b/include/pars0sym.h
index 5078db20eca..69227a2917e 100644
--- a/include/pars0sym.h
+++ b/include/pars0sym.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 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
+
+*****************************************************************************/
+
/******************************************************
SQL parser symbol table
-(c) 1997 Innobase Oy
-
Created 12/15/1997 Heikki Tuuri
*******************************************************/
diff --git a/include/pars0sym.ic b/include/pars0sym.ic
index 9508d423769..235d6819ae9 100644
--- a/include/pars0sym.ic
+++ b/include/pars0sym.ic
@@ -1,7 +1,23 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 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
+
+*****************************************************************************/
+
/******************************************************
SQL parser symbol table
-(c) 1997 Innobase Oy
-
Created 12/15/1997 Heikki Tuuri
*******************************************************/
diff --git a/include/pars0types.h b/include/pars0types.h
index bf7df89a883..e0902d0611a 100644
--- a/include/pars0types.h
+++ b/include/pars0types.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1998, 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
+
+*****************************************************************************/
+
/******************************************************
SQL parser global types
-(c) 1997 Innobase Oy
-
Created 1/11/1998 Heikki Tuuri
*******************************************************/
diff --git a/include/que0que.h b/include/que0que.h
index c2fc2477864..a534cb7e464 100644
--- a/include/que0que.h
+++ b/include/que0que.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Query graph
-(c) 1996 Innobase Oy
-
Created 5/27/1996 Heikki Tuuri
*******************************************************/
diff --git a/include/que0que.ic b/include/que0que.ic
index c588cc92d19..e9a6b00b9ab 100644
--- a/include/que0que.ic
+++ b/include/que0que.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Query graph
-(c) 1996 Innobase Oy
-
Created 5/27/1996 Heikki Tuuri
*******************************************************/
diff --git a/include/que0types.h b/include/que0types.h
index 30e3f0a172b..1d3217fb491 100644
--- a/include/que0types.h
+++ b/include/que0types.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Query graph global types
-(c) 1996 Innobase Oy
-
Created 5/27/1996 Heikki Tuuri
*******************************************************/
diff --git a/include/read0read.h b/include/read0read.h
index ef4216b1db1..7ea8bdaf8dd 100644
--- a/include/read0read.h
+++ b/include/read0read.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 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
+
+*****************************************************************************/
+
/******************************************************
Cursor read
-(c) 1997 Innobase Oy
-
Created 2/16/1997 Heikki Tuuri
*******************************************************/
diff --git a/include/read0read.ic b/include/read0read.ic
index 3aded1ca07c..9fc6af04e88 100644
--- a/include/read0read.ic
+++ b/include/read0read.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 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
+
+*****************************************************************************/
+
/******************************************************
Cursor read
-(c) 1997 Innobase Oy
-
Created 2/16/1997 Heikki Tuuri
*******************************************************/
diff --git a/include/read0types.h b/include/read0types.h
index 7d42728523e..44849cbb498 100644
--- a/include/read0types.h
+++ b/include/read0types.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 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
+
+*****************************************************************************/
+
/******************************************************
Cursor read
-(c) 1997 Innobase Oy
-
Created 2/16/1997 Heikki Tuuri
*******************************************************/
diff --git a/include/rem0cmp.h b/include/rem0cmp.h
index 0423351a22c..f32bae73a13 100644
--- a/include/rem0cmp.h
+++ b/include/rem0cmp.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/***********************************************************************
Comparison services for records
-(c) 1994-2001 Innobase Oy
-
Created 7/1/1994 Heikki Tuuri
************************************************************************/
diff --git a/include/rem0cmp.ic b/include/rem0cmp.ic
index 40cd64d5052..6c58d9e5a25 100644
--- a/include/rem0cmp.ic
+++ b/include/rem0cmp.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/***********************************************************************
Comparison services for records
-(c) 1994-1996 Innobase Oy
-
Created 7/1/1994 Heikki Tuuri
************************************************************************/
diff --git a/include/rem0rec.h b/include/rem0rec.h
index f51967917fc..cb72a5fa25b 100644
--- a/include/rem0rec.h
+++ b/include/rem0rec.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/************************************************************************
Record manager
-(c) 1994-1996 Innobase Oy
-
Created 5/30/1994 Heikki Tuuri
*************************************************************************/
@@ -506,8 +522,9 @@ rec_offs_n_extern(
/***************************************************************
This is used to modify the value of an already existing field in a record.
The previous value must have exactly the same size as the new value. If len
-is UNIV_SQL_NULL then the field is treated as an SQL null for old-style
-records. For new-style records, len must not be UNIV_SQL_NULL. */
+is UNIV_SQL_NULL then the field is treated as an SQL null.
+For records in ROW_FORMAT=COMPACT (new-style records), len must not be
+UNIV_SQL_NULL unless the field already is SQL null. */
UNIV_INLINE
void
rec_set_nth_field(
@@ -516,11 +533,7 @@ rec_set_nth_field(
const ulint* offsets,/* in: array returned by rec_get_offsets() */
ulint n, /* in: index number of the field */
const void* data, /* in: pointer to the data if not SQL null */
- ulint len); /* in: length of the data or UNIV_SQL_NULL.
- If not SQL null, must have the same
- length as the previous value.
- If SQL null, previous value must be
- SQL null. */
+ ulint len); /* in: length of the data or UNIV_SQL_NULL */
/**************************************************************
The following function returns the data size of an old-style physical
record, that is the sum of field lengths. SQL null fields
diff --git a/include/rem0rec.ic b/include/rem0rec.ic
index 79fa8e17f6a..0b2b9f4a685 100644
--- a/include/rem0rec.ic
+++ b/include/rem0rec.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/************************************************************************
Record manager
-(c) 1994-1996 Innobase Oy
-
Created 5/30/1994 Heikki Tuuri
*************************************************************************/
@@ -1326,8 +1342,9 @@ rec_get_nth_field_size(
/***************************************************************
This is used to modify the value of an already existing field in a record.
The previous value must have exactly the same size as the new value. If len
-is UNIV_SQL_NULL then the field is treated as an SQL null for old-style
-records. For new-style records, len must not be UNIV_SQL_NULL. */
+is UNIV_SQL_NULL then the field is treated as an SQL null.
+For records in ROW_FORMAT=COMPACT (new-style records), len must not be
+UNIV_SQL_NULL unless the field already is SQL null. */
UNIV_INLINE
void
rec_set_nth_field(
@@ -1337,11 +1354,7 @@ rec_set_nth_field(
ulint n, /* in: index number of the field */
const void* data, /* in: pointer to the data
if not SQL null */
- ulint len) /* in: length of the data or UNIV_SQL_NULL.
- If not SQL null, must have the same
- length as the previous value.
- If SQL null, previous value must be
- SQL null. */
+ ulint len) /* in: length of the data or UNIV_SQL_NULL */
{
byte* data2;
ulint len2;
@@ -1349,9 +1362,11 @@ rec_set_nth_field(
ut_ad(rec);
ut_ad(rec_offs_validate(rec, NULL, offsets));
- if (len == UNIV_SQL_NULL) {
- ut_ad(!rec_offs_comp(offsets));
- rec_set_nth_field_sql_null(rec, n);
+ if (UNIV_UNLIKELY(len == UNIV_SQL_NULL)) {
+ if (!rec_offs_nth_sql_null(offsets, n)) {
+ ut_a(!rec_offs_comp(offsets));
+ rec_set_nth_field_sql_null(rec, n);
+ }
return;
}
diff --git a/include/rem0types.h b/include/rem0types.h
index df7c3e9bf92..d0b11b92495 100644
--- a/include/rem0types.h
+++ b/include/rem0types.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/************************************************************************
Record manager global types
-(c) 1994-1996 Innobase Oy
-
Created 5/30/1994 Heikki Tuuri
*************************************************************************/
diff --git a/include/row0ext.h b/include/row0ext.h
index ba45c295ef4..08ebafa4d98 100644
--- a/include/row0ext.h
+++ b/include/row0ext.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 2006, 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
+
+*****************************************************************************/
+
/******************************************************
Caching of externally stored column prefixes
-(c) 2006 Innobase Oy
-
Created September 2006 Marko Makela
*******************************************************/
diff --git a/include/row0ext.ic b/include/row0ext.ic
index 7ec2a1cda04..e56fc175764 100644
--- a/include/row0ext.ic
+++ b/include/row0ext.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 2006, 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
+
+*****************************************************************************/
+
/******************************************************
Caching of externally stored column prefixes
-(c) 2006 Innobase Oy
-
Created September 2006 Marko Makela
*******************************************************/
diff --git a/include/row0ins.h b/include/row0ins.h
index 35aa434d47f..6aa83bed0f6 100644
--- a/include/row0ins.h
+++ b/include/row0ins.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Insert into a table
-(c) 1996 Innobase Oy
-
Created 4/20/1996 Heikki Tuuri
*******************************************************/
diff --git a/include/row0ins.ic b/include/row0ins.ic
index 80a232d41ee..b7aeaf97834 100644
--- a/include/row0ins.ic
+++ b/include/row0ins.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Insert into a table
-(c) 1996 Innobase Oy
-
Created 4/20/1996 Heikki Tuuri
*******************************************************/
diff --git a/include/row0merge.h b/include/row0merge.h
index 9784e1b99ac..9975497cbeb 100644
--- a/include/row0merge.h
+++ b/include/row0merge.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 2005, 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
+
+*****************************************************************************/
+
/******************************************************
Index build routines using a merge sort
-(c) 2005 Innobase Oy
-
Created 13/06/2005 Jan Lindstrom
*******************************************************/
diff --git a/include/row0mysql.h b/include/row0mysql.h
index 696adfc8cbf..c1e11124a5d 100644
--- a/include/row0mysql.h
+++ b/include/row0mysql.h
@@ -1,9 +1,25 @@
+/*****************************************************************************
+
+Copyright (c) 2000, 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
+
+*****************************************************************************/
+
/******************************************************
Interface between Innobase row operations and MySQL.
Contains also create table and other data dictionary operations.
-(c) 2000 Innobase Oy
-
Created 9/17/2000 Heikki Tuuri
*******************************************************/
@@ -302,31 +318,39 @@ Locks the data dictionary exclusively for performing a table create or other
data dictionary modification operation. */
UNIV_INTERN
void
-row_mysql_lock_data_dictionary(
-/*===========================*/
- trx_t* trx); /* in: transaction */
+row_mysql_lock_data_dictionary_func(
+/*================================*/
+ trx_t* trx, /* in/out: transaction */
+ const char* file, /* in: file name */
+ ulint line); /* in: line number */
+#define row_mysql_lock_data_dictionary(trx) \
+ row_mysql_lock_data_dictionary_func(trx, __FILE__, __LINE__)
/*************************************************************************
Unlocks the data dictionary exclusive lock. */
UNIV_INTERN
void
row_mysql_unlock_data_dictionary(
/*=============================*/
- trx_t* trx); /* in: transaction */
+ trx_t* trx); /* in/out: transaction */
/*************************************************************************
Locks the data dictionary in shared mode from modifications, for performing
foreign key check, rollback, or other operation invisible to MySQL. */
UNIV_INTERN
void
-row_mysql_freeze_data_dictionary(
-/*=============================*/
- trx_t* trx); /* in: transaction */
+row_mysql_freeze_data_dictionary_func(
+/*==================================*/
+ trx_t* trx, /* in/out: transaction */
+ const char* file, /* in: file name */
+ ulint line); /* in: line number */
+#define row_mysql_freeze_data_dictionary(trx) \
+ row_mysql_freeze_data_dictionary_func(trx, __FILE__, __LINE__)
/*************************************************************************
Unlocks the data dictionary shared lock. */
UNIV_INTERN
void
row_mysql_unfreeze_data_dictionary(
/*===============================*/
- trx_t* trx); /* in: transaction */
+ trx_t* trx); /* in/out: transaction */
#ifndef UNIV_HOTBACKUP
/*************************************************************************
Creates a table for MySQL. If the name of the table ends in
@@ -609,6 +633,8 @@ struct row_prebuilt_struct {
byte* ins_upd_rec_buff;/* buffer for storing data converted
to the Innobase format from the MySQL
format */
+ const byte* default_rec; /* the default values of all columns
+ (a "default row") in MySQL format */
ulint hint_need_to_fetch_extra_cols;
/* normally this is set to 0; if this
is set to ROW_RETRIEVE_PRIMARY_KEY,
diff --git a/include/row0mysql.ic b/include/row0mysql.ic
index aa8a70d8761..5260ae17924 100644
--- a/include/row0mysql.ic
+++ b/include/row0mysql.ic
@@ -1,7 +1,23 @@
+/*****************************************************************************
+
+Copyright (c) 2001, 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
+
+*****************************************************************************/
+
/******************************************************
MySQL interface for Innobase
-(C) 2001 Innobase Oy
-
Created 1/23/2001 Heikki Tuuri
*******************************************************/
diff --git a/include/row0purge.h b/include/row0purge.h
index 0950b7c1174..fbc12f8d389 100644
--- a/include/row0purge.h
+++ b/include/row0purge.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 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
+
+*****************************************************************************/
+
/******************************************************
Purge obsolete records
-(c) 1997 Innobase Oy
-
Created 3/14/1997 Heikki Tuuri
*******************************************************/
diff --git a/include/row0purge.ic b/include/row0purge.ic
index 50aabf0bc1b..5fc665e9d20 100644
--- a/include/row0purge.ic
+++ b/include/row0purge.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 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
+
+*****************************************************************************/
+
/******************************************************
Purge obsolete records
-(c) 1997 Innobase Oy
-
Created 3/14/1997 Heikki Tuuri
*******************************************************/
diff --git a/include/row0row.h b/include/row0row.h
index 47d4637410e..26c4b5e4e71 100644
--- a/include/row0row.h
+++ b/include/row0row.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
General row routines
-(c) 1996 Innobase Oy
-
Created 4/20/1996 Heikki Tuuri
*******************************************************/
diff --git a/include/row0row.ic b/include/row0row.ic
index ff902286ca5..9947dd43257 100644
--- a/include/row0row.ic
+++ b/include/row0row.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
General row routines
-(c) 1996 Innobase Oy
-
Created 4/20/1996 Heikki Tuuri
*******************************************************/
diff --git a/include/row0sel.h b/include/row0sel.h
index a12ca4af5ee..2f8574d0691 100644
--- a/include/row0sel.h
+++ b/include/row0sel.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 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
+
+*****************************************************************************/
+
/******************************************************
Select
-(c) 1997 Innobase Oy
-
Created 12/19/1997 Heikki Tuuri
*******************************************************/
@@ -280,13 +296,6 @@ struct sel_node_struct{
ibool set_x_locks; /* TRUE if the cursor is for update or
delete, which means that a row x-lock
should be placed on the cursor row */
- ibool select_will_do_update;
- /* TRUE if the select is for a searched
- update which can be performed in-place:
- in this case the select will take care
- of the update */
- ulint latch_mode; /* BTR_SEARCH_LEAF, or BTR_MODIFY_LEAF
- if select_will_do_update is TRUE */
ulint row_lock_mode; /* LOCK_X or LOCK_S */
ulint n_tables; /* number of tables */
ulint fetch_table; /* number of the next table to access
diff --git a/include/row0sel.ic b/include/row0sel.ic
index a0a06e2d32b..a21181e3237 100644
--- a/include/row0sel.ic
+++ b/include/row0sel.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 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
+
+*****************************************************************************/
+
/******************************************************
Select
-(c) 1997 Innobase Oy
-
Created 12/19/1997 Heikki Tuuri
*******************************************************/
diff --git a/include/row0types.h b/include/row0types.h
index b06eeed9d39..f0af7c2bf53 100644
--- a/include/row0types.h
+++ b/include/row0types.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Row operation global types
-(c) 1996 Innobase Oy
-
Created 12/27/1996 Heikki Tuuri
*******************************************************/
diff --git a/include/row0uins.h b/include/row0uins.h
index 3d56cb68f37..16bbbbd0d12 100644
--- a/include/row0uins.h
+++ b/include/row0uins.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 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
+
+*****************************************************************************/
+
/******************************************************
Fresh insert undo
-(c) 1996 Innobase Oy
-
Created 2/25/1997 Heikki Tuuri
*******************************************************/
@@ -20,7 +36,9 @@ Created 2/25/1997 Heikki Tuuri
/***************************************************************
Undoes a fresh insert of a row to a table. A fresh insert means that
the same clustered index unique key did not have any record, even delete
-marked, at the time of the insert. */
+marked, at the time of the insert. InnoDB is eager in a rollback:
+if it figures out that an index record will be removed in the purge
+anyway, it will remove it in the rollback. */
UNIV_INTERN
ulint
row_undo_ins(
diff --git a/include/row0uins.ic b/include/row0uins.ic
index 2b3d5a10f95..75bef8431eb 100644
--- a/include/row0uins.ic
+++ b/include/row0uins.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 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
+
+*****************************************************************************/
+
/******************************************************
Fresh insert undo
-(c) 1996 Innobase Oy
-
Created 2/25/1997 Heikki Tuuri
*******************************************************/
diff --git a/include/row0umod.h b/include/row0umod.h
index 8485962e63b..3a4e8c2f9a3 100644
--- a/include/row0umod.h
+++ b/include/row0umod.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 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
+
+*****************************************************************************/
+
/******************************************************
Undo modify of a row
-(c) 1997 Innobase Oy
-
Created 2/27/1997 Heikki Tuuri
*******************************************************/
diff --git a/include/row0umod.ic b/include/row0umod.ic
index fcbf4dbc1f3..7ac7bc2fea7 100644
--- a/include/row0umod.ic
+++ b/include/row0umod.ic
@@ -1,7 +1,23 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 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
+
+*****************************************************************************/
+
/******************************************************
Undo modify of a row
-(c) 1997 Innobase Oy
-
Created 2/27/1997 Heikki Tuuri
*******************************************************/
diff --git a/include/row0undo.h b/include/row0undo.h
index d4c741c882b..a17cfb1babd 100644
--- a/include/row0undo.h
+++ b/include/row0undo.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 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
+
+*****************************************************************************/
+
/******************************************************
Row undo
-(c) 1997 Innobase Oy
-
Created 1/8/1997 Heikki Tuuri
*******************************************************/
diff --git a/include/row0undo.ic b/include/row0undo.ic
index e7f89c7de67..921e3633b10 100644
--- a/include/row0undo.ic
+++ b/include/row0undo.ic
@@ -1,7 +1,23 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 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
+
+*****************************************************************************/
+
/******************************************************
Row undo
-(c) 1997 Innobase Oy
-
Created 1/8/1997 Heikki Tuuri
*******************************************************/
diff --git a/include/row0upd.h b/include/row0upd.h
index 29166a2f466..71aa20d158c 100644
--- a/include/row0upd.h
+++ b/include/row0upd.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Update of a row
-(c) 1996 Innobase Oy
-
Created 12/27/1996 Heikki Tuuri
*******************************************************/
@@ -292,16 +308,6 @@ row_upd_step(
/* out: query thread to run next or NULL */
que_thr_t* thr); /* in: query thread */
/*************************************************************************
-Performs an in-place update for the current clustered index record in
-select. */
-UNIV_INTERN
-void
-row_upd_in_place_in_select(
-/*=======================*/
- sel_node_t* sel_node, /* in: select node */
- que_thr_t* thr, /* in: query thread */
- mtr_t* mtr); /* in: mtr */
-/*************************************************************************
Parses the log data of system field values. */
UNIV_INTERN
byte*
@@ -374,11 +380,6 @@ struct upd_node_struct{
ibool searched_update;
/* TRUE if searched update, FALSE if
positioned */
- ibool select_will_do_update;
- /* TRUE if a searched update where ordering
- fields will not be updated, and the size of
- the fields will not change: in this case the
- select node will take care of the update */
ibool in_mysql_interface;
/* TRUE if the update node was created
for the MySQL interface */
diff --git a/include/row0upd.ic b/include/row0upd.ic
index 82eb5c84ffc..a0c23aa6b07 100644
--- a/include/row0upd.ic
+++ b/include/row0upd.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Update of a row
-(c) 1996 Innobase Oy
-
Created 12/27/1996 Heikki Tuuri
*******************************************************/
@@ -139,11 +155,7 @@ row_upd_rec_sys_fields(
ut_ad(rec_offs_validate(rec, index, offsets));
#ifdef UNIV_SYNC_DEBUG
if (!rw_lock_own(&btr_search_latch, RW_LOCK_EX)) {
- //buf_pool_mutex_enter();
- rw_lock_s_lock(&page_hash_latch);
ut_ad(!buf_block_align(rec)->is_hashed);
- //buf_pool_mutex_exit();
- rw_lock_s_unlock(&page_hash_latch);
}
#endif /* UNIV_SYNC_DEBUG */
diff --git a/include/row0vers.h b/include/row0vers.h
index 9c278b0d99a..0feae77e8b5 100644
--- a/include/row0vers.h
+++ b/include/row0vers.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 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
+
+*****************************************************************************/
+
/******************************************************
Row versions
-(c) 1997 Innobase Oy
-
Created 2/6/1997 Heikki Tuuri
*******************************************************/
diff --git a/include/row0vers.ic b/include/row0vers.ic
index ab1e264635b..aac95ea6593 100644
--- a/include/row0vers.ic
+++ b/include/row0vers.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 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
+
+*****************************************************************************/
+
/******************************************************
Row versions
-(c) 1997 Innobase Oy
-
Created 2/6/1997 Heikki Tuuri
*******************************************************/
diff --git a/include/srv0que.h b/include/srv0que.h
index 86aa48ff1d7..88db1a013f6 100644
--- a/include/srv0que.h
+++ b/include/srv0que.h
@@ -1,12 +1,27 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Server query execution
-(c) 1996 Innobase Oy
-
Created 6/5/1996 Heikki Tuuri
*******************************************************/
-
#ifndef srv0que_h
#define srv0que_h
diff --git a/include/srv0srv.h b/include/srv0srv.h
index 7b1f898f63a..cb78d66da1b 100644
--- a/include/srv0srv.h
+++ b/include/srv0srv.h
@@ -1,12 +1,34 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 2008, Google Inc.
+
+Portions of this file contain modifications contributed and copyrighted by
+Google, Inc. Those modifications are gratefully acknowledged and are described
+briefly in the InnoDB documentation. The contributions by Google are
+incorporated with their permission, and subject to the conditions contained in
+the file COPYING.Google.
+
+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
+
+*****************************************************************************/
+
/******************************************************
The server main program
-(c) 1995 Innobase Oy
-
Created 10/10/1995 Heikki Tuuri
*******************************************************/
-
#ifndef srv0srv_h
#define srv0srv_h
@@ -98,9 +120,10 @@ extern ulint srv_show_verbose_locks;
/* The sort order table of the MySQL latin1_swedish_ci character set
collation */
extern const byte* srv_latin1_ordering;
-extern ulong srv_buf_pool_size; /* requested size in bytes */
-extern ulong srv_buf_pool_old_size; /* previously requested size */
-extern ulong srv_buf_pool_curr_size; /* current size in bytes */
+extern my_bool srv_use_sys_malloc;
+extern ulint srv_buf_pool_size; /* requested size in bytes */
+extern ulint srv_buf_pool_old_size; /* previously requested size */
+extern ulint srv_buf_pool_curr_size; /* current size in bytes */
extern ulint srv_mem_pool_size;
extern ulint srv_lock_table_size;
@@ -546,6 +569,7 @@ struct export_var_struct{
ulint innodb_buffer_pool_read_ahead_rnd;
ulint innodb_dblwr_pages_written;
ulint innodb_dblwr_writes;
+ ibool innodb_have_atomic_builtins;
ulint innodb_log_waits;
ulint innodb_log_write_requests;
ulint innodb_log_writes;
@@ -582,4 +606,3 @@ struct srv_sys_struct{
extern ulint srv_n_threads_active[];
#endif
-
diff --git a/include/srv0srv.ic b/include/srv0srv.ic
index 73e0729660f..93d675f1dca 100644
--- a/include/srv0srv.ic
+++ b/include/srv0srv.ic
@@ -1,7 +1,23 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/******************************************************
Server main program
-(c) 1995 Innobase Oy
-
Created 10/4/1995 Heikki Tuuri
*******************************************************/
diff --git a/include/srv0start.h b/include/srv0start.h
index b3135807635..15fa3b8f95f 100644
--- a/include/srv0start.h
+++ b/include/srv0start.h
@@ -1,12 +1,27 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/******************************************************
Starts the Innobase database server
-(c) 1995-2000 Innobase Oy
-
Created 10/10/1995 Heikki Tuuri
*******************************************************/
-
#ifndef srv0start_h
#define srv0start_h
@@ -27,21 +42,8 @@ UNIV_INTERN
ibool
srv_parse_data_file_paths_and_sizes(
/*================================*/
- /* out: TRUE if ok, FALSE if parsing
- error */
- char* str, /* in: the data file path string */
- char*** data_file_names, /* out, own: array of data file
- names */
- ulint** data_file_sizes, /* out, own: array of data file sizes
- in megabytes */
- ulint** data_file_is_raw_partition,/* out, own: array of flags
- showing which data files are raw
- partitions */
- ulint* n_data_files, /* out: number of data files */
- ibool* is_auto_extending, /* out: TRUE if the last data file is
- auto-extending */
- ulint* max_auto_extend_size); /* out: max auto extend size for the
- last file if specified, 0 if not */
+ /* out: TRUE if ok, FALSE on parse error */
+ char* str); /* in/out: the data file path string */
/*************************************************************************
Reads log group home directories from a character string given in
the .cnf file. */
@@ -49,10 +51,15 @@ UNIV_INTERN
ibool
srv_parse_log_group_home_dirs(
/*==========================*/
- /* out: TRUE if ok, FALSE if parsing
- error */
- char* str, /* in: character string */
- char*** log_group_home_dirs); /* out, own: log group home dirs */
+ /* out: TRUE if ok, FALSE on parse error */
+ char* str); /* in/out: character string */
+/*************************************************************************
+Frees the memory allocated by srv_parse_data_file_paths_and_sizes()
+and srv_parse_log_group_home_dirs(). */
+UNIV_INTERN
+void
+srv_free_paths_and_sizes(void);
+/*==========================*/
/*************************************************************************
Adds a slash or a backslash to the end of a string if it is missing
and the string is not empty. */
@@ -65,8 +72,7 @@ srv_add_path_separator_if_needed(
char* str); /* in: null-terminated character string */
/********************************************************************
Starts Innobase and creates a new database if database files
-are not found and the user wants. Server parameters are
-read from a file of name "srv_init" in the ib_home directory. */
+are not found and the user wants. */
UNIV_INTERN
int
innobase_start_or_create_for_mysql(void);
diff --git a/include/sync0arr.h b/include/sync0arr.h
index 7236a7f514f..cc01c9ac5c8 100644
--- a/include/sync0arr.h
+++ b/include/sync0arr.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/******************************************************
The wait array used in synchronization primitives
-(c) 1995 Innobase Oy
-
Created 9/5/1995 Heikki Tuuri
*******************************************************/
diff --git a/include/sync0arr.ic b/include/sync0arr.ic
index dbe35c033e5..09a562a4723 100644
--- a/include/sync0arr.ic
+++ b/include/sync0arr.ic
@@ -1,10 +1,26 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/******************************************************
The wait array for synchronization primitives
Inline code
-(c) 1995 Innobase Oy
-
Created 9/5/1995 Heikki Tuuri
*******************************************************/
diff --git a/include/sync0rw.h b/include/sync0rw.h
index acaa200fc2b..89c63af42b1 100644
--- a/include/sync0rw.h
+++ b/include/sync0rw.h
@@ -1,8 +1,31 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 2008, Google Inc.
+
+Portions of this file contain modifications contributed and copyrighted by
+Google, Inc. Those modifications are gratefully acknowledged and are described
+briefly in the InnoDB documentation. The contributions by Google are
+incorporated with their permission, and subject to the conditions contained in
+the file COPYING.Google.
+
+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
+
+*****************************************************************************/
+
/******************************************************
The read-write lock (for threads, not for database transactions)
-(c) 1995 Innobase Oy
-
Created 9/11/1995 Heikki Tuuri
*******************************************************/
@@ -24,6 +47,12 @@ smaller than 30 and the order of the numerical values like below! */
#define RW_X_LATCH 2
#define RW_NO_LATCH 3
+/* We decrement lock_word by this amount for each x_lock. It is also the
+start value for the lock_word, meaning that it limits the maximum number
+of concurrent read locks before the rw_lock breaks. The current value of
+0x00100000 allows 1,048,575 concurrent readers and 2047 recursive writers.*/
+#define X_LOCK_DECR 0x00100000
+
typedef struct rw_lock_struct rw_lock_t;
#ifdef UNIV_SYNC_DEBUG
typedef struct rw_lock_debug_struct rw_lock_debug_t;
@@ -47,14 +76,14 @@ extern ibool rw_lock_debug_waiters; /* This is set to TRUE, if
there may be waiters for the event */
#endif /* UNIV_SYNC_DEBUG */
-extern ulint rw_s_system_call_count;
-extern ulint rw_s_spin_wait_count;
-extern ulint rw_s_exit_count;
-extern ulint rw_s_os_wait_count;
-extern ulint rw_x_system_call_count;
-extern ulint rw_x_spin_wait_count;
-extern ulint rw_x_os_wait_count;
-extern ulint rw_x_exit_count;
+extern ib_int64_t rw_s_spin_wait_count;
+extern ib_int64_t rw_s_spin_round_count;
+extern ib_int64_t rw_s_exit_count;
+extern ib_int64_t rw_s_os_wait_count;
+extern ib_int64_t rw_x_spin_wait_count;
+extern ib_int64_t rw_x_spin_round_count;
+extern ib_int64_t rw_x_os_wait_count;
+extern ib_int64_t rw_x_exit_count;
/**********************************************************************
Creates, or rather, initializes an rw-lock object in a specified memory
@@ -127,8 +156,22 @@ corresponding function. */
NOTE! The following macros should be used in rw s-locking, not the
corresponding function. */
-#define rw_lock_s_lock_nowait(M) rw_lock_s_lock_func_nowait(\
- (M), __FILE__, __LINE__)
+#define rw_lock_s_lock_nowait(M, F, L) rw_lock_s_lock_low(\
+ (M), 0, (F), (L))
+/**********************************************************************
+Low-level function which tries to lock an rw-lock in s-mode. Performs no
+spinning. */
+UNIV_INLINE
+ibool
+rw_lock_s_lock_low(
+/*===============*/
+ /* out: TRUE if success */
+ rw_lock_t* lock, /* in: pointer to rw-lock */
+ ulint pass __attribute__((unused)),
+ /* in: pass value; != 0, if the lock will be
+ passed to another thread to unlock */
+ const char* file_name, /* in: file name where lock requested */
+ ulint line); /* in: line where requested */
/**********************************************************************
NOTE! Use the corresponding macro, not directly this function, except if
you supply the file name and line number. Lock an rw-lock in shared mode
@@ -146,18 +189,6 @@ rw_lock_s_lock_func(
const char* file_name,/* in: file name where lock requested */
ulint line); /* in: line where requested */
/**********************************************************************
-NOTE! Use the corresponding macro, not directly this function, except if
-you supply the file name and line number. Lock an rw-lock in shared mode
-for the current thread if the lock can be acquired immediately. */
-UNIV_INLINE
-ibool
-rw_lock_s_lock_func_nowait(
-/*=======================*/
- /* out: TRUE if success */
- rw_lock_t* lock, /* in: pointer to rw-lock */
- const char* file_name,/* in: file name where lock requested */
- ulint line); /* in: line where requested */
-/**********************************************************************
NOTE! Use the corresponding macro, not directly this function! Lock an
rw-lock in exclusive mode for the current thread if the lock can be
obtained immediately. */
@@ -351,6 +382,41 @@ ulint
rw_lock_get_reader_count(
/*=====================*/
rw_lock_t* lock);
+/**********************************************************************
+Decrements lock_word the specified amount if it is greater than 0.
+This is used by both s_lock and x_lock operations. */
+UNIV_INLINE
+ibool
+rw_lock_lock_word_decr(
+/*===================*/
+ /* out: TRUE if decr occurs */
+ rw_lock_t* lock, /* in: rw-lock */
+ ulint amount); /* in: amount to decrement */
+/**********************************************************************
+Increments lock_word the specified amount and returns new value. */
+UNIV_INLINE
+lint
+rw_lock_lock_word_incr(
+/*===================*/
+ /* out: TRUE if decr occurs */
+ rw_lock_t* lock,
+ ulint amount); /* in: rw-lock */
+/**********************************************************************
+This function sets the lock->writer_thread and lock->recursive fields.
+For platforms where we are using atomic builtins instead of lock->mutex
+it sets the lock->writer_thread field using atomics to ensure memory
+ordering. Note that it is assumed that the caller of this function
+effectively owns the lock i.e.: nobody else is allowed to modify
+lock->writer_thread at this point in time.
+The protocol is that lock->writer_thread MUST be updated BEFORE the
+lock->recursive flag is set. */
+UNIV_INLINE
+void
+rw_lock_set_writer_id_and_recursion_flag(
+/*=====================================*/
+ rw_lock_t* lock, /* in/out: lock to work on */
+ ibool recursive); /* in: TRUE if recursion
+ allowed */
#ifdef UNIV_SYNC_DEBUG
/**********************************************************************
Checks if the thread has locked the rw-lock in the specified mode, with
@@ -422,11 +488,8 @@ rw_lock_debug_print(
rw_lock_debug_t* info); /* in: debug struct */
#endif /* UNIV_SYNC_DEBUG */
-#ifdef HAVE_GCC_ATOMIC_BUILTINS
-/* This value means NOT_LOCKED */
-#define RW_LOCK_BIAS 0x00100000
-#else
-#error HAVE_GCC_ATOMIC_BUILTINS is not defined. Do you use enough new GCC or compatibles?
+#ifndef INNODB_RW_LOCKS_USE_ATOMICS
+#error INNODB_RW_LOCKS_USE_ATOMICS is not defined. Do you use enough new GCC or compatibles?
#error Or do you use exact options for CFLAGS?
#error e.g. (for x86_32): "-m32 -march=i586 -mtune=i686"
#error e.g. (for Sparc_64): "-m64 -mcpu=v9"
@@ -438,48 +501,55 @@ Do not use its fields directly! The structure used in the spin lock
implementation of a read-write lock. Several threads may have a shared lock
simultaneously in this lock, but only one writer may have an exclusive lock,
in which case no shared locks are allowed. To prevent starving of a writer
-blocked by readers, a writer may queue for the lock by setting the writer
-field. Then no new readers are allowed in. */
+blocked by readers, a writer may queue for x-lock by decrementing lock_word:
+no new readers will be let in while the thread waits for readers to exit. */
struct rw_lock_struct {
+ volatile lint lock_word;
+ /* Holds the state of the lock. */
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
+ volatile ulint s_waiters; /* 1: there are waiters (s_lock) */
+ volatile ulint x_waiters; /* 1: there are waiters (x_lock) */
+ volatile ulint wait_ex_waiters; /* 1: there are waiters (wait_ex) */
+ volatile ulint reader_count; /* Number of readers who have locked this
+ lock in the shared mode */
+ volatile ulint writer;
+#else
+ volatile ulint waiters;/* 1: there are waiters */
+#endif
+ volatile ibool recursive;/* Default value FALSE which means the lock
+ is non-recursive. The value is typically set
+ to TRUE making normal rw_locks recursive. In
+ case of asynchronous IO, when a non-zero
+ value of 'pass' is passed then we keep the
+ lock non-recursive.
+ This flag also tells us about the state of
+ writer_thread field. If this flag is set
+ then writer_thread MUST contain the thread
+ id of the current x-holder or wait-x thread.
+ This flag must be reset in x_unlock
+ functions before incrementing the lock_word */
+ volatile os_thread_id_t writer_thread;
+ /* Thread id of writer thread. Is only
+ guaranteed to have sane and non-stale
+ value iff recursive flag is set. */
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
+ volatile ulint writer_count; /* Number of times the same thread has
+ recursively locked the lock in the exclusive
+ mode */
/* Used by sync0arr.c for thread queueing */
os_event_t s_event; /* Used for s_lock */
os_event_t x_event; /* Used for x_lock */
- os_event_t wait_ex_event; /* This windows specific event is
- used by the thread which has set the
- lock state to RW_LOCK_WAIT_EX. The
- rw_lock design guarantees that this
- thread will be the next one to proceed
- once the current the event gets
- signalled. See LEMMA 2 in sync0sync.c */
-
-#ifdef HAVE_GCC_ATOMIC_BUILTINS
- volatile lint lock_word; /* Used by using atomic builtin */
+#else
+ os_event_t event; /* Used by sync0arr.c for thread queueing */
#endif
-
- volatile ulint reader_count; /* Number of readers who have locked this
- lock in the shared mode */
- volatile ulint writer; /* This field is set to RW_LOCK_EX if there
- is a writer owning the lock (in exclusive
- mode), RW_LOCK_WAIT_EX if a writer is
- queueing for the lock, and
- RW_LOCK_NOT_LOCKED, otherwise. */
- volatile os_thread_id_t writer_thread;
- /* Thread id of a possible writer thread */
- volatile ulint writer_count; /* Number of times the same thread has
- recursively locked the lock in the exclusive
- mode */
-#ifndef HAVE_GCC_ATOMIC_BUILTINS
+ os_event_t wait_ex_event;
+ /* Event for next-writer to wait on. A thread
+ must decrement lock_word before waiting. */
+#ifndef INNODB_RW_LOCKS_USE_ATOMICS
mutex_t mutex; /* The mutex protecting rw_lock_struct */
-#endif
- ulint pass; /* Default value 0. This is set to some
- value != 0 given by the caller of an x-lock
- operation, if the x-lock is to be passed to
- another thread to unlock (which happens in
- asynchronous i/o). */
- volatile ulint s_waiters; /* 1: there are waiters (s_lock) */
- volatile ulint x_waiters; /* 1: there are waiters (x_lock) */
- volatile ulint wait_ex_waiters; /* 1: there are waiters (wait_ex) */
+#endif /* INNODB_RW_LOCKS_USE_ATOMICS */
+
UT_LIST_NODE_T(rw_lock_t) list;
/* All allocated rw locks are put into a
list */
@@ -489,7 +559,9 @@ struct rw_lock_struct {
info list of the lock */
ulint level; /* Level in the global latching order. */
#endif /* UNIV_SYNC_DEBUG */
+ ulint count_os_wait; /* Count of os_waits. May not be accurate */
const char* cfile_name;/* File name where lock created */
+ /* last s-lock file/line is not guaranteed to be correct */
const char* last_s_file_name;/* File name where last s-locked */
const char* last_x_file_name;/* File name where last x-locked */
volatile ibool writer_is_wait_ex;
diff --git a/include/sync0rw.ic b/include/sync0rw.ic
index 8096933d7d9..b09e0072725 100644
--- a/include/sync0rw.ic
+++ b/include/sync0rw.ic
@@ -1,8 +1,31 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 2008, Google Inc.
+
+Portions of this file contain modifications contributed and copyrighted by
+Google, Inc. Those modifications are gratefully acknowledged and are described
+briefly in the InnoDB documentation. The contributions by Google are
+incorporated with their permission, and subject to the conditions contained in
+the file COPYING.Google.
+
+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
+
+*****************************************************************************/
+
/******************************************************
The read-write lock (for threads)
-(c) 1995 Innobase Oy
-
Created 9/11/1995 Heikki Tuuri
*******************************************************/
@@ -49,7 +72,8 @@ UNIV_INLINE
ulint
rw_lock_get_s_waiters(
/*================*/
- rw_lock_t* lock)
+ /* out: 1 if waiters, 0 otherwise */
+ rw_lock_t* lock) /* in: rw-lock */
{
return(lock->s_waiters);
}
@@ -69,38 +93,105 @@ rw_lock_get_wx_waiters(
{
return(lock->wait_ex_waiters);
}
+
+/************************************************************************
+Sets lock->waiters to 1. It is not an error if lock->waiters is already
+1. On platforms where ATOMIC builtins are used this function enforces a
+memory barrier. */
UNIV_INLINE
void
-rw_lock_set_s_waiters(
- rw_lock_t* lock,
- ulint flag)
+rw_lock_set_s_waiter_flag(
+/*====================*/
+ rw_lock_t* lock) /* in: rw-lock */
{
- lock->s_waiters = flag;
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
+ // os_compare_and_swap(&lock->s_waiters, 0, 1);
+ __sync_lock_test_and_set(&lock->s_waiters, 1);
+#else /* INNODB_RW_LOCKS_USE_ATOMICS */
+ lock->s_waiters = 1;
+#endif /* INNODB_RW_LOCKS_USE_ATOMICS */
}
UNIV_INLINE
void
-rw_lock_set_x_waiters(
- rw_lock_t* lock,
- ulint flag)
+rw_lock_set_x_waiter_flag(
+/*====================*/
+ rw_lock_t* lock) /* in: rw-lock */
{
- lock->x_waiters = flag;
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
+ // os_compare_and_swap(&lock->x_waiters, 0, 1);
+ __sync_lock_test_and_set(&lock->x_waiters, 1);
+#else /* INNODB_RW_LOCKS_USE_ATOMICS */
+ lock->x_waiters = 1;
+#endif /* INNODB_RW_LOCKS_USE_ATOMICS */
}
UNIV_INLINE
void
-rw_lock_set_wx_waiters(
-/*================*/
- rw_lock_t* lock,
- ulint flag)
+rw_lock_set_wx_waiter_flag(
+/*====================*/
+ rw_lock_t* lock) /* in: rw-lock */
+{
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
+ // os_compare_and_swap(&lock->wait_ex_waiters, 0, 1);
+ __sync_lock_test_and_set(&lock->wait_ex_waiters, 1);
+#else /* INNODB_RW_LOCKS_USE_ATOMICS */
+ lock->wait_ex_waiters = 1;
+#endif /* INNODB_RW_LOCKS_USE_ATOMICS */
+}
+
+/************************************************************************
+Resets lock->waiters to 0. It is not an error if lock->waiters is already
+0. On platforms where ATOMIC builtins are used this function enforces a
+memory barrier. */
+UNIV_INLINE
+void
+rw_lock_reset_s_waiter_flag(
+/*======================*/
+ rw_lock_t* lock) /* in: rw-lock */
{
- lock->wait_ex_waiters = flag;
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
+ // os_compare_and_swap(&lock->s_waiters, 1, 0);
+ __sync_lock_test_and_set(&lock->s_waiters, 0);
+#else /* INNODB_RW_LOCKS_USE_ATOMICS */
+ lock->s_waiters = 0;
+#endif /* INNODB_RW_LOCKS_USE_ATOMICS */
}
UNIV_INLINE
+void
+rw_lock_reset_x_waiter_flag(
+/*======================*/
+ rw_lock_t* lock) /* in: rw-lock */
+{
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
+ // os_compare_and_swap(&lock->x_waiters, 1, 0);
+ __sync_lock_test_and_set(&lock->x_waiters, 0);
+#else /* INNODB_RW_LOCKS_USE_ATOMICS */
+ lock->x_waiters = 0;
+#endif /* INNODB_RW_LOCKS_USE_ATOMICS */
+}
+UNIV_INLINE
+void
+rw_lock_reset_wx_waiter_flag(
+/*======================*/
+ rw_lock_t* lock) /* in: rw-lock */
+{
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
+ // os_compare_and_swap(&lock->wait_ex_waiters, 1, 0);
+ __sync_lock_test_and_set(&lock->wait_ex_waiters, 0);
+#else /* INNODB_RW_LOCKS_USE_ATOMICS */
+ lock->wait_ex_waiters = 0;
+#endif /* INNODB_RW_LOCKS_USE_ATOMICS */
+}
+
+/**********************************************************************
+Returns the write-status of the lock - this function made more sense
+with the old rw_lock implementation. */
+UNIV_INLINE
ulint
rw_lock_get_writer(
/*===============*/
rw_lock_t* lock)
{
-#ifdef HAVE_GCC_ATOMIC_BUILTINS
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
if (lock->writer == RW_LOCK_NOT_LOCKED) {
return(RW_LOCK_NOT_LOCKED);
}
@@ -111,36 +202,44 @@ rw_lock_get_writer(
return(RW_LOCK_EX);
}
#else
- return(lock->writer);
+ lint lock_word = lock->lock_word;
+ if(lock_word > 0) {
+ /* return NOT_LOCKED in s-lock state, like the writer
+ member of the old lock implementation. */
+ return(RW_LOCK_NOT_LOCKED);
+ } else if (((-lock_word) % X_LOCK_DECR) == 0) {
+ return(RW_LOCK_EX);
+ } else {
+ ut_ad(lock_word > -X_LOCK_DECR);
+ return(RW_LOCK_WAIT_EX);
+ }
#endif
}
-UNIV_INLINE
-void
-rw_lock_set_writer(
-/*===============*/
- rw_lock_t* lock,
- ulint flag)
-{
- lock->writer = flag;
-}
+
+/**********************************************************************
+Returns number of readers. */
UNIV_INLINE
ulint
rw_lock_get_reader_count(
/*=====================*/
rw_lock_t* lock)
{
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
return(lock->reader_count);
+#else
+ lint lock_word = lock->lock_word;
+ if(lock_word > 0) {
+ /* s-locked, no x-waiters */
+ return(X_LOCK_DECR - lock_word);
+ } else if (lock_word < 0 && lock_word > -X_LOCK_DECR) {
+ /* s-locked, with x-waiters */
+ return((ulint)(-lock_word));
+ }
+ return(0);
+#endif
}
-UNIV_INLINE
-void
-rw_lock_set_reader_count(
-/*=====================*/
- rw_lock_t* lock,
- ulint count)
-{
- lock->reader_count = count;
-}
-#ifndef HAVE_GCC_ATOMIC_BUILTINS
+
+#ifndef INNODB_RW_LOCKS_USE_ATOMICS
UNIV_INLINE
mutex_t*
rw_lock_get_mutex(
@@ -161,7 +260,136 @@ rw_lock_get_x_lock_count(
/* out: value of writer_count */
rw_lock_t* lock) /* in: rw-lock */
{
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
return(lock->writer_count);
+#else
+ lint lock_copy = lock->lock_word;
+ /* If there is a reader, lock_word is not divisible by X_LOCK_DECR */
+ if(lock_copy > 0 || (-lock_copy) % X_LOCK_DECR != 0) {
+ return(0);
+ }
+ return(((-lock_copy) / X_LOCK_DECR) + 1);
+#endif
+}
+
+/**********************************************************************
+Two different implementations for decrementing the lock_word of a rw_lock:
+one for systems supporting atomic operations, one for others. This does
+does not support recusive x-locks: they should be handled by the caller and
+need not be atomic since they are performed by the current lock holder.
+Returns true if the decrement was made, false if not. */
+UNIV_INLINE
+ibool
+rw_lock_lock_word_decr(
+/*===================*/
+ /* out: TRUE if decr occurs */
+ rw_lock_t* lock, /* in: rw-lock */
+ ulint amount) /* in: amount of decrement */
+{
+
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
+
+ lint local_lock_word = lock->lock_word;
+ while (local_lock_word > 0) {
+ if(os_compare_and_swap(&(lock->lock_word),
+ local_lock_word,
+ local_lock_word - amount)) {
+ return(TRUE);
+ }
+ local_lock_word = lock->lock_word;
+ }
+ return(FALSE);
+
+#else /* INNODB_RW_LOCKS_USE_ATOMICS */
+
+ ibool success = FALSE;
+ mutex_enter(&(lock->mutex));
+ if(lock->lock_word > 0) {
+ lock->lock_word -= amount;
+ success = TRUE;
+ }
+ mutex_exit(&(lock->mutex));
+ return(success);
+
+#endif /* INNODB_RW_LOCKS_USE_ATOMICS */
+}
+
+/**********************************************************************
+Two different implementations for incrementing the lock_word of a rw_lock:
+one for systems supporting atomic operations, one for others.
+Returns the value of lock_word after increment. */
+UNIV_INLINE
+lint
+rw_lock_lock_word_incr(
+/*===================*/
+ /* out: lock->lock_word after increment */
+ rw_lock_t* lock, /* in: rw-lock */
+ ulint amount) /* in: amount of increment */
+{
+
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
+
+ return(os_atomic_increment(&(lock->lock_word), amount));
+
+#else /* INNODB_RW_LOCKS_USE_ATOMICS */
+
+ lint local_lock_word;
+
+ mutex_enter(&(lock->mutex));
+
+ lock->lock_word += amount;
+ local_lock_word = lock->lock_word;
+
+ mutex_exit(&(lock->mutex));
+
+ return(local_lock_word);
+
+#endif /* INNODB_RW_LOCKS_USE_ATOMICS */
+}
+
+/**********************************************************************
+This function sets the lock->writer_thread and lock->recursive fields.
+For platforms where we are using atomic builtins instead of lock->mutex
+it sets the lock->writer_thread field using atomics to ensure memory
+ordering. Note that it is assumed that the caller of this function
+effectively owns the lock i.e.: nobody else is allowed to modify
+lock->writer_thread at this point in time.
+The protocol is that lock->writer_thread MUST be updated BEFORE the
+lock->recursive flag is set. */
+UNIV_INLINE
+void
+rw_lock_set_writer_id_and_recursion_flag(
+/*=====================================*/
+ rw_lock_t* lock, /* in/out: lock to work on */
+ ibool recursive) /* in: TRUE if recursion
+ allowed */
+{
+ os_thread_id_t curr_thread = os_thread_get_curr_id();
+
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
+ os_thread_id_t local_thread;
+ ibool success;
+
+ /* Prevent Valgrind warnings about writer_thread being
+ uninitialized. It does not matter if writer_thread is
+ uninitialized, because we are comparing writer_thread against
+ itself, and the operation should always succeed. */
+ UNIV_MEM_VALID(&lock->writer_thread, sizeof lock->writer_thread);
+
+ local_thread = lock->writer_thread;
+ success = os_compare_and_swap(&lock->writer_thread,
+ local_thread, curr_thread);
+ ut_a(success);
+ lock->recursive = recursive;
+
+#else /* INNODB_RW_LOCKS_USE_ATOMICS */
+
+ mutex_enter(&lock->mutex);
+ lock->writer_thread = curr_thread;
+ lock->recursive = recursive;
+ mutex_exit(&lock->mutex);
+
+#endif /* INNODB_RW_LOCKS_USE_ATOMICS */
}
/**********************************************************************
@@ -179,13 +407,7 @@ rw_lock_s_lock_low(
const char* file_name, /* in: file name where lock requested */
ulint line) /* in: line where requested */
{
-#ifndef HAVE_GCC_ATOMIC_BUILTINS
- ut_ad(mutex_own(rw_lock_get_mutex(lock)));
-#endif
-
- /* Check if the writer field is free */
-
-#ifdef HAVE_GCC_ATOMIC_BUILTINS
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
if (UNIV_LIKELY(rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED)) {
/* try s-lock */
if(__sync_sub_and_fetch(&(lock->lock_word),1) <= 0) {
@@ -195,23 +417,26 @@ rw_lock_s_lock_low(
}
/* success */
__sync_fetch_and_add(&(lock->reader_count),1);
+ } else {
+ return(FALSE); /* locking did not succeed */
+ }
#else
- if (UNIV_LIKELY(lock->writer == RW_LOCK_NOT_LOCKED)) {
- /* Set the shared lock by incrementing the reader count */
- lock->reader_count++;
+ /* TODO: study performance of UNIV_LIKELY branch prediction hints. */
+ if (!rw_lock_lock_word_decr(lock, 1)) {
+ /* Locking did not succeed */
+ return(FALSE);
+ }
#endif
#ifdef UNIV_SYNC_DEBUG
- rw_lock_add_debug_info(lock, pass, RW_LOCK_SHARED, file_name,
- line);
+ rw_lock_add_debug_info(lock, pass, RW_LOCK_SHARED, file_name, line);
#endif
- lock->last_s_file_name = file_name;
- lock->last_s_line = line;
-
- return(TRUE); /* locking succeeded */
- }
+ /* These debugging values are not set safely: they may be incorrect
+ or even refer to a line that is invalid for the file name. */
+ lock->last_s_file_name = file_name;
+ lock->last_s_line = line;
- return(FALSE); /* locking did not succeed */
+ return(TRUE); /* locking succeeded */
}
/**********************************************************************
@@ -226,14 +451,16 @@ rw_lock_s_lock_direct(
const char* file_name, /* in: file name where requested */
ulint line) /* in: line where lock requested */
{
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
ut_ad(rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED);
ut_ad(rw_lock_get_reader_count(lock) == 0);
- /* Set the shared lock by incrementing the reader count */
-#ifdef HAVE_GCC_ATOMIC_BUILTINS
__sync_fetch_and_add(&(lock->reader_count),1);
#else
- lock->reader_count++;
+ ut_ad(lock->lock_word == X_LOCK_DECR);
+
+ /* Indicate there is a new reader by decrementing lock_word */
+ lock->lock_word--;
#endif
lock->last_s_file_name = file_name;
@@ -257,17 +484,19 @@ rw_lock_x_lock_direct(
ulint line) /* in: line where lock requested */
{
ut_ad(rw_lock_validate(lock));
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
ut_ad(rw_lock_get_reader_count(lock) == 0);
ut_ad(rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED);
- rw_lock_set_writer(lock, RW_LOCK_EX);
- lock->writer_thread = os_thread_get_curr_id();
-#ifdef HAVE_GCC_ATOMIC_BUILTINS
+ lock->writer = RW_LOCK_EX;
__sync_fetch_and_add(&(lock->writer_count),1);
#else
- lock->writer_count++;
+ ut_ad(lock->lock_word == X_LOCK_DECR);
+
+ lock->lock_word -= X_LOCK_DECR;
#endif
- lock->pass = 0;
+ lock->writer_thread = os_thread_get_curr_id();
+ lock->recursive = TRUE;
lock->last_x_file_name = file_name;
lock->last_x_line = line;
@@ -308,21 +537,12 @@ rw_lock_s_lock_func(
ut_ad(!rw_lock_own(lock, RW_LOCK_SHARED)); /* see NOTE above */
#endif /* UNIV_SYNC_DEBUG */
-#ifndef HAVE_GCC_ATOMIC_BUILTINS
- mutex_enter(rw_lock_get_mutex(lock));
-#endif
-
- if (UNIV_LIKELY(rw_lock_s_lock_low(lock, pass, file_name, line))) {
-#ifndef HAVE_GCC_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-#endif
+ /* TODO: study performance of UNIV_LIKELY branch prediction hints. */
+ if (rw_lock_s_lock_low(lock, pass, file_name, line)) {
return; /* Success */
} else {
/* Did not succeed, try spin wait */
-#ifndef HAVE_GCC_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-#endif
rw_lock_s_lock_spin(lock, pass, file_name, line);
@@ -332,57 +552,6 @@ rw_lock_s_lock_func(
/**********************************************************************
NOTE! Use the corresponding macro, not directly this function! Lock an
-rw-lock in shared mode for the current thread if the lock can be acquired
-immediately. */
-UNIV_INLINE
-ibool
-rw_lock_s_lock_func_nowait(
-/*=======================*/
- /* out: TRUE if success */
- rw_lock_t* lock, /* in: pointer to rw-lock */
- const char* file_name,/* in: file name where lock requested */
- ulint line) /* in: line where requested */
-{
- ibool success = FALSE;
-
-#ifdef HAVE_GCC_ATOMIC_BUILTINS
- if (rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED) {
- /* try s-lock */
- if(__sync_sub_and_fetch(&(lock->lock_word),1) <= 0) {
- /* fail */
- __sync_fetch_and_add(&(lock->lock_word),1);
- return(FALSE); /* locking did not succeed */
- }
- /* success */
- __sync_fetch_and_add(&(lock->reader_count),1);
-#else
- mutex_enter(rw_lock_get_mutex(lock));
-
- if (lock->writer == RW_LOCK_NOT_LOCKED) {
- /* Set the shared lock by incrementing the reader count */
- lock->reader_count++;
-#endif
-
-#ifdef UNIV_SYNC_DEBUG
- rw_lock_add_debug_info(lock, 0, RW_LOCK_SHARED, file_name,
- line);
-#endif
-
- lock->last_s_file_name = file_name;
- lock->last_s_line = line;
-
- success = TRUE;
- }
-
-#ifndef HAVE_GCC_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-#endif
-
- return(success);
-}
-
-/**********************************************************************
-NOTE! Use the corresponding macro, not directly this function! Lock an
rw-lock in exclusive mode for the current thread if the lock can be
obtained immediately. */
UNIV_INLINE
@@ -394,21 +563,25 @@ rw_lock_x_lock_func_nowait(
const char* file_name,/* in: file name where lock requested */
ulint line) /* in: line where requested */
{
- ibool success = FALSE;
os_thread_id_t curr_thread = os_thread_get_curr_id();
-#ifdef HAVE_GCC_ATOMIC_BUILTINS
- if ((lock->lock_word == RW_LOCK_BIAS)
+
+ ibool success;
+
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
+ success = FALSE;
+ if ((lock->reader_count == 0)
&& rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED) {
+retry_x_lock:
/* try x-lock */
if(__sync_sub_and_fetch(&(lock->lock_word),
- RW_LOCK_BIAS) == 0) {
+ X_LOCK_DECR) == 0) {
/* success */
/* try to lock writer */
if(__sync_lock_test_and_set(&(lock->writer),RW_LOCK_EX)
== RW_LOCK_NOT_LOCKED) {
/* success */
lock->writer_thread = curr_thread;
- lock->pass = 0;
+ lock->recursive = TRUE;
lock->writer_is_wait_ex = FALSE;
/* next function may work as memory barrier */
relock:
@@ -427,54 +600,60 @@ rw_lock_x_lock_func_nowait(
} else {
/* x-unlock */
__sync_fetch_and_add(&(lock->lock_word),
- RW_LOCK_BIAS);
+ X_LOCK_DECR);
}
} else {
/* fail (x-lock) */
- __sync_fetch_and_add(&(lock->lock_word),RW_LOCK_BIAS);
+ if (__sync_fetch_and_add(&(lock->lock_word),X_LOCK_DECR)
+ == 0)
+ goto retry_x_lock;
}
}
- if (lock->pass == 0
- && os_thread_eq(lock->writer_thread, curr_thread)
- && rw_lock_get_writer(lock) == RW_LOCK_EX) {
+ if (lock->recursive
+ && os_thread_eq(lock->writer_thread, curr_thread)) {
goto relock;
}
- ut_ad(rw_lock_validate(lock));
+ //ut_ad(rw_lock_validate(lock));
return(FALSE);
#else
- mutex_enter(rw_lock_get_mutex(lock));
- if (UNIV_UNLIKELY(rw_lock_get_reader_count(lock) != 0)) {
- } else if (UNIV_LIKELY(rw_lock_get_writer(lock)
- == RW_LOCK_NOT_LOCKED)) {
- rw_lock_set_writer(lock, RW_LOCK_EX);
- lock->writer_thread = curr_thread;
- lock->pass = 0;
-relock:
- lock->writer_count++;
-
-#ifdef UNIV_SYNC_DEBUG
- rw_lock_add_debug_info(lock, 0, RW_LOCK_EX, file_name, line);
-#endif
+ success = FALSE;
+ mutex_enter(&(lock->mutex));
+ if (lock->lock_word == X_LOCK_DECR) {
+ lock->lock_word = 0;
+ success = TRUE;
+ }
+ mutex_exit(&(lock->mutex));
- lock->last_x_file_name = file_name;
- lock->last_x_line = line;
+ if (success) {
+ rw_lock_set_writer_id_and_recursion_flag(lock, TRUE);
- success = TRUE;
- } else if (rw_lock_get_writer(lock) == RW_LOCK_EX
- && lock->pass == 0
+ } else if (lock->recursive
&& os_thread_eq(lock->writer_thread, curr_thread)) {
- goto relock;
+ /* Relock: this lock_word modification is safe since no other
+ threads can modify (lock, unlock, or reserve) lock_word while
+ there is an exclusive writer and this is the writer thread. */
+ lock->lock_word -= X_LOCK_DECR;
+
+ ut_ad(((-lock->lock_word) % X_LOCK_DECR) == 0);
+
+ } else {
+ /* Failure */
+ return(FALSE);
}
+#ifdef UNIV_SYNC_DEBUG
+ rw_lock_add_debug_info(lock, 0, RW_LOCK_EX, file_name, line);
+#endif
- mutex_exit(rw_lock_get_mutex(lock));
+ lock->last_x_file_name = file_name;
+ lock->last_x_line = line;
ut_ad(rw_lock_validate(lock));
- return(success);
+ return(TRUE);
#endif
}
@@ -491,73 +670,48 @@ rw_lock_s_unlock_func(
#endif
)
{
-#ifndef HAVE_GCC_ATOMIC_BUILTINS
- mutex_t* mutex = &(lock->mutex);
-#endif
- ibool x_sg = FALSE;
- ibool wx_sg = FALSE;
-#ifdef HAVE_GCC_ATOMIC_BUILTINS
- ibool last = FALSE;
-#endif
-
-#ifndef HAVE_GCC_ATOMIC_BUILTINS
- /* Acquire the mutex protecting the rw-lock fields */
- mutex_enter(mutex);
-#endif
-
- /* Reset the shared lock by decrementing the reader count */
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
+ ibool last = FALSE;
ut_a(lock->reader_count > 0);
-#ifdef HAVE_GCC_ATOMIC_BUILTINS
+
/* unlock lock_word */
__sync_fetch_and_add(&(lock->lock_word),1);
if(__sync_sub_and_fetch(&(lock->reader_count),1) == 0) {
last = TRUE;
}
-#else
- lock->reader_count--;
-#endif
#ifdef UNIV_SYNC_DEBUG
rw_lock_remove_debug_info(lock, pass, RW_LOCK_SHARED);
#endif
- /* If there may be waiters and this was the last s-lock,
- signal the object */
-
-#ifdef HAVE_GCC_ATOMIC_BUILTINS
- if (UNIV_UNLIKELY(last && lock->wait_ex_waiters)) {
-#else
- if (UNIV_UNLIKELY(lock->wait_ex_waiters)
- && lock->reader_count == 0) {
-#endif
- wx_sg = TRUE;
-
- rw_lock_set_wx_waiters(lock, 0);
+ if (UNIV_UNLIKELY(last && __sync_lock_test_and_set(&lock->wait_ex_waiters, 0))) {
+ os_event_set(lock->wait_ex_event);
+ sync_array_object_signalled(sync_primary_wait_array);
}
-#ifdef HAVE_GCC_ATOMIC_BUILTINS
- else if (UNIV_UNLIKELY(last && lock->x_waiters)) {
-#else
- else if (UNIV_UNLIKELY(lock->x_waiters)
- && lock->reader_count == 0) {
-#endif
- x_sg = TRUE;
-
- rw_lock_set_x_waiters(lock, 0);
+ else if (UNIV_UNLIKELY(last && __sync_lock_test_and_set(&lock->x_waiters, 0))) {
+ os_event_set(lock->x_event);
+ sync_array_object_signalled(sync_primary_wait_array);
}
+#else
+ ut_ad((lock->lock_word % X_LOCK_DECR) != 0);
-#ifndef HAVE_GCC_ATOMIC_BUILTINS
- mutex_exit(mutex);
+#ifdef UNIV_SYNC_DEBUG
+ rw_lock_remove_debug_info(lock, pass, RW_LOCK_SHARED);
#endif
- if (UNIV_UNLIKELY(wx_sg)) {
+ /* Increment lock_word to indicate 1 less reader */
+ if (rw_lock_lock_word_incr(lock, 1) == 0) {
+
+ /* wait_ex waiter exists. It may not be asleep, but we signal
+ anyway. We do not wake other waiters, because they can't
+ exist without wait_ex waiter and wait_ex waiter goes first.*/
os_event_set(lock->wait_ex_event);
sync_array_object_signalled(sync_primary_wait_array);
- } else if (UNIV_UNLIKELY(x_sg)) {
- os_event_set(lock->x_event);
- sync_array_object_signalled(sync_primary_wait_array);
+
}
+#endif
ut_ad(rw_lock_validate(lock));
@@ -575,15 +729,10 @@ rw_lock_s_unlock_direct(
/*====================*/
rw_lock_t* lock) /* in: rw-lock */
{
- /* Reset the shared lock by decrementing the reader count */
-
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
ut_ad(lock->reader_count > 0);
-#ifdef HAVE_GCC_ATOMIC_BUILTINS
__sync_sub_and_fetch(&(lock->reader_count),1);
-#else
- lock->reader_count--;
-#endif
#ifdef UNIV_SYNC_DEBUG
rw_lock_remove_debug_info(lock, 0, RW_LOCK_SHARED);
@@ -592,6 +741,18 @@ rw_lock_s_unlock_direct(
ut_ad(!lock->s_waiters);
ut_ad(!lock->x_waiters);
ut_ad(!lock->wait_ex_waiters);
+#else
+ ut_ad(lock->lock_word < X_LOCK_DECR);
+
+#ifdef UNIV_SYNC_DEBUG
+ rw_lock_remove_debug_info(lock, 0, RW_LOCK_SHARED);
+#endif
+
+ /* Decrease reader count by incrementing lock_word */
+ lock->lock_word++;
+
+ ut_ad(!lock->waiters);
+#endif
ut_ad(rw_lock_validate(lock));
#ifdef UNIV_SYNC_PERF_STAT
rw_s_exit_count++;
@@ -611,82 +772,80 @@ rw_lock_x_unlock_func(
#endif
)
{
-#ifdef HAVE_GCC_ATOMIC_BUILTINS
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
ibool last = FALSE;
-#endif
ibool s_sg = FALSE;
ibool x_sg = FALSE;
-#ifndef HAVE_GCC_ATOMIC_BUILTINS
- /* Acquire the mutex protecting the rw-lock fields */
- mutex_enter(&(lock->mutex));
-#endif
-
- /* Reset the exclusive lock if this thread no longer has an x-mode
- lock */
-
ut_ad(lock->writer_count > 0);
-#ifdef HAVE_GCC_ATOMIC_BUILTINS
if(__sync_sub_and_fetch(&(lock->writer_count),1) == 0) {
last = TRUE;
}
if (last) {
/* unlock lock_word */
- __sync_fetch_and_add(&(lock->lock_word),RW_LOCK_BIAS);
+ __sync_fetch_and_add(&(lock->lock_word),X_LOCK_DECR);
+ lock->recursive = FALSE;
/* FIXME: It is a value of bad manners for pthread.
- But we shouldn't keep an ID of not-owner. */
+ But we shouldn't keep an ID of not-owner. */
lock->writer_thread = -1;
-
__sync_lock_test_and_set(&(lock->writer),RW_LOCK_NOT_LOCKED);
}
-#else
- lock->writer_count--;
-
- if (lock->writer_count == 0) {
- rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED);
- }
-#endif
#ifdef UNIV_SYNC_DEBUG
rw_lock_remove_debug_info(lock, pass, RW_LOCK_EX);
#endif
-
- /* If there may be waiters, signal the lock */
-#ifdef HAVE_GCC_ATOMIC_BUILTINS
if (last) {
-#else
- if (lock->writer_count == 0) {
-#endif
- if(lock->s_waiters){
+ if(__sync_lock_test_and_set(&lock->s_waiters, 0)){
s_sg = TRUE;
- rw_lock_set_s_waiters(lock, 0);
}
- if(lock->x_waiters){
+ if(__sync_lock_test_and_set(&lock->x_waiters, 0)){
x_sg = TRUE;
- rw_lock_set_x_waiters(lock, 0);
}
}
-#ifndef HAVE_GCC_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-#endif
-
if (UNIV_UNLIKELY(s_sg)) {
os_event_set(lock->s_event);
sync_array_object_signalled(sync_primary_wait_array);
}
if (UNIV_UNLIKELY(x_sg)) {
-#ifdef __WIN__
- /* I doubt the necessity of it. */
- os_event_set(lock->wait_ex_event);
-#endif
os_event_set(lock->x_event);
sync_array_object_signalled(sync_primary_wait_array);
}
+#else
+ ut_ad((lock->lock_word % X_LOCK_DECR) == 0);
+
+ /* lock->recursive flag also indicates if lock->writer_thread is
+ valid or stale. If we are the last of the recursive callers
+ then we must unset lock->recursive flag to indicate that the
+ lock->writer_thread is now stale.
+ Note that since we still hold the x-lock we can safely read the
+ lock_word. */
+ if (lock->lock_word == 0) {
+ /* Last caller in a possible recursive chain. */
+ lock->recursive = FALSE;
+ UNIV_MEM_INVALID(&lock->writer_thread,
+ sizeof lock->writer_thread);
+ }
+
+#ifdef UNIV_SYNC_DEBUG
+ rw_lock_remove_debug_info(lock, pass, RW_LOCK_EX);
+#endif
+
+ if (rw_lock_lock_word_incr(lock, X_LOCK_DECR) == X_LOCK_DECR) {
+ /* Lock is now free. May have to signal read/write waiters.
+ We do not need to signal wait_ex waiters, since they cannot
+ exist when there is a writer. */
+ if (lock->waiters) {
+ rw_lock_reset_waiter_flag(lock);
+ os_event_set(lock->event);
+ sync_array_object_signalled(sync_primary_wait_array);
+ }
+ }
+#endif
ut_ad(rw_lock_validate(lock));
#ifdef UNIV_SYNC_PERF_STAT
@@ -696,7 +855,7 @@ rw_lock_x_unlock_func(
/**********************************************************************
Releases an exclusive mode lock when we know there are no waiters, and
-none else will access the lock durint the time this function is executed. */
+none else will access the lock during the time this function is executed. */
UNIV_INLINE
void
rw_lock_x_unlock_direct(
@@ -706,16 +865,9 @@ rw_lock_x_unlock_direct(
/* Reset the exclusive lock if this thread no longer has an x-mode
lock */
- ut_ad(lock->writer_count > 0);
-
-#ifdef HAVE_GCC_ATOMIC_BUILTINS
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
if(__sync_sub_and_fetch(&(lock->writer_count),1) == 0) {
-#else
- lock->writer_count--;
-
- if (lock->writer_count == 0) {
-#endif
- rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED);
+ lock->writer = RW_LOCK_NOT_LOCKED;
}
#ifdef UNIV_SYNC_DEBUG
@@ -725,6 +877,23 @@ rw_lock_x_unlock_direct(
ut_ad(!lock->s_waiters);
ut_ad(!lock->x_waiters);
ut_ad(!lock->wait_ex_waiters);
+#else
+ ut_ad((lock->lock_word % X_LOCK_DECR) == 0);
+
+#ifdef UNIV_SYNC_DEBUG
+ rw_lock_remove_debug_info(lock, 0, RW_LOCK_EX);
+#endif
+
+ if (lock->lock_word == 0) {
+ lock->recursive = FALSE;
+ UNIV_MEM_INVALID(&lock->writer_thread,
+ sizeof lock->writer_thread);
+ }
+
+ lock->lock_word += X_LOCK_DECR;
+
+ ut_ad(!lock->waiters);
+#endif
ut_ad(rw_lock_validate(lock));
#ifdef UNIV_SYNC_PERF_STAT
diff --git a/include/sync0sync.h b/include/sync0sync.h
index 1af16fd6289..ea4abddbbf4 100644
--- a/include/sync0sync.h
+++ b/include/sync0sync.h
@@ -1,8 +1,31 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 2008, Google Inc.
+
+Portions of this file contain modifications contributed and copyrighted by
+Google, Inc. Those modifications are gratefully acknowledged and are described
+briefly in the InnoDB documentation. The contributions by Google are
+incorporated with their permission, and subject to the conditions contained in
+the file COPYING.Google.
+
+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
+
+*****************************************************************************/
+
/******************************************************
Mutex, the basic synchronization primitive
-(c) 1995 Innobase Oy
-
Created 9/5/1995 Heikki Tuuri
*******************************************************/
@@ -237,7 +260,7 @@ mutex_n_reserved(void);
NOT to be used outside this module except in debugging! Gets the value
of the lock word. */
UNIV_INLINE
-ulint
+byte
mutex_get_lock_word(
/*================*/
const mutex_t* mutex); /* in: mutex */
@@ -433,7 +456,8 @@ or row lock! */
#define SYNC_TRX_SYS_HEADER 290
#define SYNC_LOG 170
#define SYNC_RECV 168
-#define SYNC_WORK_QUEUE 161
+#define SYNC_WORK_QUEUE 162
+#define SYNC_SEARCH_SYS_CONF 161 /* for assigning btr_search_enabled */
#define SYNC_SEARCH_SYS 160 /* NOTE that if we have a memory
heap that can be extended to the
buffer pool, its logical level is
@@ -462,9 +486,11 @@ implementation of a mutual exclusion semaphore. */
struct mutex_struct {
os_event_t event; /* Used by sync0arr.c for the wait queue */
- ulint lock_word; /* This ulint is the target of the atomic
- test-and-set instruction in Win32 */
-#if defined WIN32 && defined UNIV_CAN_USE_X86_ASSEMBLER
+ byte lock_word; /* This byte is the target of the atomic
+ test-and-set instruction in Win32 and
+ x86 32/64 with GCC 4.1.0 or later version */
+#if defined(_WIN32) && defined(UNIV_CAN_USE_X86_ASSEMBLER)
+#elif defined(HAVE_GCC_ATOMIC_BUILTINS)
#else
os_fast_mutex_t
os_fast_mutex; /* In other systems we use this OS mutex
@@ -518,8 +544,7 @@ to 20 microseconds. */
/* The number of system calls made in this module. Intended for performance
monitoring. */
-extern ulint mutex_system_call_count;
-extern ulint mutex_exit_count;
+extern ib_int64_t mutex_exit_count;
#ifdef UNIV_SYNC_DEBUG
/* Latching order checks start when this is set TRUE */
diff --git a/include/sync0sync.ic b/include/sync0sync.ic
index 5c08ed3e175..c43121ebd0b 100644
--- a/include/sync0sync.ic
+++ b/include/sync0sync.ic
@@ -1,21 +1,34 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 2008, Google Inc.
+
+Portions of this file contain modifications contributed and copyrighted by
+Google, Inc. Those modifications are gratefully acknowledged and are described
+briefly in the InnoDB documentation. The contributions by Google are
+incorporated with their permission, and subject to the conditions contained in
+the file COPYING.Google.
+
+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
+
+*****************************************************************************/
+
/******************************************************
Mutex, the basic synchronization primitive
-(c) 1995 Innobase Oy
-
Created 9/5/1995 Heikki Tuuri
*******************************************************/
-#if defined(not_defined) && defined(__GNUC__) && defined(UNIV_INTEL_X86)
-/* %z0: Use the size of operand %0 which in our case is *m to determine
-instruction size, it should end up as xchgl. "1" in the input constraint,
-says that "in" has to go in the same place as "out".*/
-#define TAS(m, in, out) \
- asm volatile ("xchg%z0 %2, %0" \
- : "=g" (*(m)), "=r" (out) \
- : "1" (in)) /* Note: "1" here refers to "=r" (out) */
-#endif
-
/**********************************************************************
Sets the waiters field in a mutex. */
UNIV_INTERN
@@ -59,7 +72,7 @@ mutex_signal_object(
Performs an atomic test-and-set instruction to the lock_word field of a
mutex. */
UNIV_INLINE
-ulint
+byte
mutex_test_and_set(
/*===============*/
/* out: the previous value of lock_word: 0 or
@@ -67,18 +80,18 @@ mutex_test_and_set(
mutex_t* mutex) /* in: mutex */
{
#if defined(_WIN32) && defined(UNIV_CAN_USE_X86_ASSEMBLER)
- ulint res;
- ulint* lw; /* assembler code is used to ensure that
+ byte res;
+ byte* lw; /* assembler code is used to ensure that
lock_word is loaded from memory */
ut_ad(mutex);
- ut_ad(sizeof(ulint) == 4);
+ ut_ad(sizeof(byte) == 1);
lw = &(mutex->lock_word);
__asm MOV ECX, lw
__asm MOV EDX, 1
- __asm XCHG EDX, DWORD PTR [ECX]
- __asm MOV res, EDX
+ __asm XCHG DL, BYTE PTR [ECX]
+ __asm MOV res, DL
/* The fence below would prevent this thread from
reading the data structure protected by the mutex
@@ -98,12 +111,8 @@ mutex_test_and_set(
/* mutex_fence(); */
return(res);
-#elif defined(not_defined) && defined(__GNUC__) && defined(UNIV_INTEL_X86)
- ulint res;
-
- TAS(&mutex->lock_word, 1, res);
-
- return(res);
+#elif defined(HAVE_GCC_ATOMIC_BUILTINS)
+ return __sync_lock_test_and_set(&(mutex->lock_word), 1);
#else
ibool ret;
@@ -117,7 +126,7 @@ mutex_test_and_set(
mutex->lock_word = 1;
}
- return(ret);
+ return((byte)ret);
#endif
}
@@ -131,7 +140,7 @@ mutex_reset_lock_word(
mutex_t* mutex) /* in: mutex */
{
#if defined(_WIN32) && defined(UNIV_CAN_USE_X86_ASSEMBLER)
- ulint* lw; /* assembler code is used to ensure that
+ byte* lw; /* assembler code is used to ensure that
lock_word is loaded from memory */
ut_ad(mutex);
@@ -139,11 +148,12 @@ mutex_reset_lock_word(
__asm MOV EDX, 0
__asm MOV ECX, lw
- __asm XCHG EDX, DWORD PTR [ECX]
-#elif defined(not_defined) && defined(__GNUC__) && defined(UNIV_INTEL_X86)
- ulint res;
-
- TAS(&mutex->lock_word, 0, res);
+ __asm XCHG DL, BYTE PTR [ECX]
+#elif defined(HAVE_GCC_ATOMIC_BUILTINS)
+ /* In theory __sync_lock_release should be used to release the lock.
+ Unfortunately, it does not work properly alone. The workaround is
+ that more conservative __sync_lock_test_and_set is used instead. */
+ __sync_lock_test_and_set(&(mutex->lock_word), 0);
#else
mutex->lock_word = 0;
@@ -154,12 +164,12 @@ mutex_reset_lock_word(
/**********************************************************************
Gets the value of the lock word. */
UNIV_INLINE
-ulint
+byte
mutex_get_lock_word(
/*================*/
const mutex_t* mutex) /* in: mutex */
{
- const volatile ulint* ptr; /* declared volatile to ensure that
+ const volatile byte* ptr; /* declared volatile to ensure that
lock_word is loaded from memory */
ut_ad(mutex);
diff --git a/include/sync0types.h b/include/sync0types.h
index 57478426f25..3c1021b1a30 100644
--- a/include/sync0types.h
+++ b/include/sync0types.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/******************************************************
Global types for sync
-(c) 1995 Innobase Oy
-
Created 9/5/1995 Heikki Tuuri
*******************************************************/
@@ -12,5 +28,4 @@ Created 9/5/1995 Heikki Tuuri
#define mutex_t ib_mutex_t
typedef struct mutex_struct mutex_t;
-
#endif
diff --git a/include/thr0loc.h b/include/thr0loc.h
index 9928c6b8993..96ec13cc8e4 100644
--- a/include/thr0loc.h
+++ b/include/thr0loc.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/******************************************************
The thread local storage
-(c) 1995 Innobase Oy
-
Created 10/5/1995 Heikki Tuuri
*******************************************************/
diff --git a/include/thr0loc.ic b/include/thr0loc.ic
index b8b8136180c..6de183fd857 100644
--- a/include/thr0loc.ic
+++ b/include/thr0loc.ic
@@ -1,7 +1,23 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/******************************************************
Thread local storage
-(c) 1995 Innobase Oy
-
Created 10/4/1995 Heikki Tuuri
*******************************************************/
diff --git a/include/trx0i_s.h b/include/trx0i_s.h
index 43c4b8bb436..cf2865af127 100644
--- a/include/trx0i_s.h
+++ b/include/trx0i_s.h
@@ -1,10 +1,26 @@
+/*****************************************************************************
+
+Copyright (c) 2007, 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
+
+*****************************************************************************/
+
/******************************************************
INFORMATION SCHEMA innodb_trx, innodb_locks and
innodb_lock_waits tables cache structures and public
functions.
-(c) 2007 Innobase Oy
-
Created July 17, 2007 Vasil Dimov
*******************************************************/
diff --git a/include/trx0purge.h b/include/trx0purge.h
index 8449d92b56b..4921b860485 100644
--- a/include/trx0purge.h
+++ b/include/trx0purge.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Purge old versions
-(c) 1996 Innobase Oy
-
Created 3/26/1996 Heikki Tuuri
*******************************************************/
diff --git a/include/trx0purge.ic b/include/trx0purge.ic
index 9f1c0ed96f8..2c1d2ac75af 100644
--- a/include/trx0purge.ic
+++ b/include/trx0purge.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Purge old versions
-(c) 1996 Innobase Oy
-
Created 3/26/1996 Heikki Tuuri
*******************************************************/
diff --git a/include/trx0rec.h b/include/trx0rec.h
index 2ba90b3410b..444d39e39db 100644
--- a/include/trx0rec.h
+++ b/include/trx0rec.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Transaction undo log record
-(c) 1996 Innobase Oy
-
Created 3/26/1996 Heikki Tuuri
*******************************************************/
@@ -13,7 +29,6 @@ Created 3/26/1996 Heikki Tuuri
#include "trx0types.h"
#include "row0types.h"
#include "mtr0mtr.h"
-#include "trx0sys.h"
#include "dict0types.h"
#include "que0types.h"
#include "data0data.h"
diff --git a/include/trx0rec.ic b/include/trx0rec.ic
index 8ad0b514ebf..bfd74eb9dfb 100644
--- a/include/trx0rec.ic
+++ b/include/trx0rec.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Transaction undo log record
-(c) 1996 Innobase Oy
-
Created 3/26/1996 Heikki Tuuri
*******************************************************/
diff --git a/include/trx0roll.h b/include/trx0roll.h
index f86b600cce8..3318a5985d7 100644
--- a/include/trx0roll.h
+++ b/include/trx0roll.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Transaction rollback
-(c) 1996 Innobase Oy
-
Created 3/26/1996 Heikki Tuuri
*******************************************************/
@@ -15,6 +31,8 @@ Created 3/26/1996 Heikki Tuuri
#include "mtr0mtr.h"
#include "trx0sys.h"
+#define trx_roll_free_all_savepoints(s) trx_roll_savepoints_free((s), NULL)
+
/***********************************************************************
Determines if this transaction is rolling back an incomplete transaction
in crash recovery. */
@@ -249,9 +267,19 @@ trx_release_savepoint_for_mysql(
const char* savepoint_name); /* in: savepoint name */
/***********************************************************************
-Frees savepoint structs. */
+Frees a single savepoint struct. */
UNIV_INTERN
void
+trx_roll_savepoint_free(
+/*=====================*/
+ trx_t* trx, /* in: transaction handle */
+ trx_named_savept_t* savep); /* in: savepoint to free */
+
+/***********************************************************************
+Frees savepoint structs starting from savep, if savep == NULL then
+free all savepoints. */
+
+void
trx_roll_savepoints_free(
/*=====================*/
trx_t* trx, /* in: transaction handle */
diff --git a/include/trx0roll.ic b/include/trx0roll.ic
index dfde83ac478..513b8b44847 100644
--- a/include/trx0roll.ic
+++ b/include/trx0roll.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Transaction rollback
-(c) 1996 Innobase Oy
-
Created 3/26/1996 Heikki Tuuri
*******************************************************/
diff --git a/include/trx0rseg.h b/include/trx0rseg.h
index 35ddf037b27..f3aa736f788 100644
--- a/include/trx0rseg.h
+++ b/include/trx0rseg.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Rollback segment
-(c) 1996 Innobase Oy
-
Created 3/26/1996 Heikki Tuuri
*******************************************************/
diff --git a/include/trx0rseg.ic b/include/trx0rseg.ic
index 38ac2028fa9..e665a40fa8b 100644
--- a/include/trx0rseg.ic
+++ b/include/trx0rseg.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Rollback segment
-(c) 1996 Innobase Oy
-
Created 3/26/1996 Heikki Tuuri
*******************************************************/
diff --git a/include/trx0sys.h b/include/trx0sys.h
index 30f9cf4c2a5..012b34564bc 100644
--- a/include/trx0sys.h
+++ b/include/trx0sys.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Transaction system
-(c) 1996 Innobase Oy
-
Created 3/26/1996 Heikki Tuuri
*******************************************************/
diff --git a/include/trx0sys.ic b/include/trx0sys.ic
index 8e255763b1d..4437133188f 100644
--- a/include/trx0sys.ic
+++ b/include/trx0sys.ic
@@ -1,14 +1,29 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Transaction system
-(c) 1996 Innobase Oy
-
Created 3/26/1996 Heikki Tuuri
*******************************************************/
#include "srv0srv.h"
#include "trx0trx.h"
-#include "data0type.h"
/* The typedef for rseg slot in the file copy */
typedef byte trx_sysf_rseg_t;
diff --git a/include/trx0trx.h b/include/trx0trx.h
index f1bdd9cc979..8d5803ab353 100644
--- a/include/trx0trx.h
+++ b/include/trx0trx.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
The transaction
-(c) 1996 Innobase Oy
-
Created 3/26/1996 Heikki Tuuri
*******************************************************/
@@ -407,15 +423,6 @@ trx_is_interrupted(
#define trx_is_interrupted(trx) FALSE
#endif /* !UNIV_HOTBACKUP */
-/**************************************************************************
-Determines if the currently running transaction is in innodb_strict_mode. */
-UNIV_INTERN
-ibool
-trx_is_strict(
-/*==========*/
- /* out: TRUE if strict */
- trx_t* trx); /* in: transaction */
-
/***********************************************************************
Calculates the "weight" of a transaction. The weight of one transaction
is estimated as the number of altered rows + the number of locked rows.
diff --git a/include/trx0trx.ic b/include/trx0trx.ic
index 6b01a8cc0d4..6da89f002fe 100644
--- a/include/trx0trx.ic
+++ b/include/trx0trx.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
The transaction
-(c) 1996 Innobase Oy
-
Created 3/26/1996 Heikki Tuuri
*******************************************************/
diff --git a/include/trx0types.h b/include/trx0types.h
index e8c41623555..896f4e8c0a2 100644
--- a/include/trx0types.h
+++ b/include/trx0types.h
@@ -1,15 +1,30 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Transaction system global type definitions
-(c) 1996 Innobase Oy
-
Created 3/26/1996 Heikki Tuuri
*******************************************************/
#ifndef trx0types_h
#define trx0types_h
-#include "lock0types.h"
#include "ut0byte.h"
/* prepare trx_t::id for being printed via printf(3) */
diff --git a/include/trx0undo.h b/include/trx0undo.h
index 378c46b1297..7f7408931da 100644
--- a/include/trx0undo.h
+++ b/include/trx0undo.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Transaction undo log
-(c) 1996 Innobase Oy
-
Created 3/26/1996 Heikki Tuuri
*******************************************************/
diff --git a/include/trx0undo.ic b/include/trx0undo.ic
index ea8fbc3907f..0bd8b79414b 100644
--- a/include/trx0undo.ic
+++ b/include/trx0undo.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Transaction undo log
-(c) 1996 Innobase Oy
-
Created 3/26/1996 Heikki Tuuri
*******************************************************/
diff --git a/include/trx0xa.h b/include/trx0xa.h
index 1127d0c9a60..0e040b8d8e5 100644
--- a/include/trx0xa.h
+++ b/include/trx0xa.h
@@ -1,3 +1,21 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/*
* Start of xa.h header
*
diff --git a/include/univ.i b/include/univ.i
index 08db6883bba..122d53c0055 100644
--- a/include/univ.i
+++ b/include/univ.i
@@ -1,8 +1,31 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 2008, Google Inc.
+
+Portions of this file contain modifications contributed and copyrighted by
+Google, Inc. Those modifications are gratefully acknowledged and are described
+briefly in the InnoDB documentation. The contributions by Google are
+incorporated with their permission, and subject to the conditions contained in
+the file COPYING.Google.
+
+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
+
+*****************************************************************************/
+
/***************************************************************************
Version control for database, common definitions, and include files
-(c) 1994 - 2000 Innobase Oy
-
Created 1/20/1994 Heikki Tuuri
****************************************************************************/
@@ -11,7 +34,7 @@ Created 1/20/1994 Heikki Tuuri
#define INNODB_VERSION_MAJOR 1
#define INNODB_VERSION_MINOR 0
-#define INNODB_VERSION_BUGFIX 2
+#define INNODB_VERSION_BUGFIX 3
#define PERCONA_INNODB_VERSION 3
/* The following is the InnoDB version as shown in
@@ -92,6 +115,24 @@ of the 32-bit x86 assembler in mutex operations. */
# define UNIV_CAN_USE_X86_ASSEMBLER
# endif
+/* For InnoDB rw_locks to work with atomics we need the thread_id
+to be no more than machine word wide. The following enables using
+atomics for InnoDB rw_locks where these conditions are met. */
+#ifdef HAVE_GCC_ATOMIC_BUILTINS
+/* if HAVE_ATOMIC_PTHREAD_T is defined at this point that means that
+the code from plug.in has defined it and we do not need to include
+ut0auxconf.h which would either define HAVE_ATOMIC_PTHREAD_T or will
+be empty */
+# ifndef HAVE_ATOMIC_PTHREAD_T
+# include "ut0auxconf.h"
+# endif /* HAVE_ATOMIC_PTHREAD_T */
+/* now HAVE_ATOMIC_PTHREAD_T is eventually defined either by plug.in or
+from Makefile.in->ut0auxconf.h */
+# ifdef HAVE_ATOMIC_PTHREAD_T
+# define INNODB_RW_LOCKS_USE_ATOMICS
+# endif /* HAVE_ATOMIC_PTHREAD_T */
+#endif /* HAVE_GCC_ATOMIC_BUILTINS */
+
/* We only try to do explicit inlining of functions with gcc and
Microsoft Visual C++ */
@@ -132,6 +173,8 @@ command. Not tested on Windows. */
Valgrind instrumentation */
#define UNIV_DEBUG_PRINT /* Enable the compilation of
some debug print functions */
+#define UNIV_AHI_DEBUG /* Enable adaptive hash index
+ debugging without UNIV_DEBUG */
#define UNIV_BUF_DEBUG /* Enable buffer pool
debugging without UNIV_DEBUG */
#define UNIV_DEBUG /* Enable ut_ad() assertions
diff --git a/include/usr0sess.h b/include/usr0sess.h
index fba9ed17642..08c6c70066f 100644
--- a/include/usr0sess.h
+++ b/include/usr0sess.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Sessions
-(c) 1996 Innobase Oy
-
Created 6/25/1996 Heikki Tuuri
*******************************************************/
diff --git a/include/usr0sess.ic b/include/usr0sess.ic
index c851d5745b9..5eefed382da 100644
--- a/include/usr0sess.ic
+++ b/include/usr0sess.ic
@@ -1,7 +1,23 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Sessions
-(c) 1996 Innobase Oy
-
Created 6/25/1996 Heikki Tuuri
*******************************************************/
diff --git a/include/usr0types.h b/include/usr0types.h
index 311471c1a0e..7f7d12f7bf5 100644
--- a/include/usr0types.h
+++ b/include/usr0types.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Users and sessions global types
-(c) 1996 Innobase Oy
-
Created 6/25/1996 Heikki Tuuri
*******************************************************/
diff --git a/include/ut0auxconf.h b/include/ut0auxconf.h
new file mode 100644
index 00000000000..fb5fae9b399
--- /dev/null
+++ b/include/ut0auxconf.h
@@ -0,0 +1,19 @@
+/* Do not remove this file even though it is empty.
+This file is included in univ.i and will cause compilation failure
+if not present.
+A custom check has been added in the generated
+storage/innobase/Makefile.in that is shipped with with the InnoDB Plugin
+source archive. This check tries to compile a test program and if
+successful then adds "#define HAVE_ATOMIC_PTHREAD_T" to this file.
+This is a hack that has been developed in order to check for pthread_t
+atomicity without the need to regenerate the ./configure script that is
+distributed in the MySQL 5.1 official source archives.
+If by any chance Makefile.in and ./configure are regenerated and thus
+the hack from Makefile.in wiped away then the "real" check from plug.in
+will take over.
+*/
+/* This is temprary fix for http://bugs.mysql.com/43740 */
+/* force to enable */
+#ifdef HAVE_GCC_ATOMIC_BUILTINS
+#define HAVE_ATOMIC_PTHREAD_T
+#endif
diff --git a/include/ut0byte.h b/include/ut0byte.h
index 85d4dad1685..24aac1678b3 100644
--- a/include/ut0byte.h
+++ b/include/ut0byte.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/**********************************************************************
Utilities for byte operations
-(c) 1994, 1995 Innobase Oy
-
Created 1/20/1994 Heikki Tuuri
***********************************************************************/
diff --git a/include/ut0byte.ic b/include/ut0byte.ic
index 80a3dfa2e86..021a3a15009 100644
--- a/include/ut0byte.ic
+++ b/include/ut0byte.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/******************************************************************
Utilities for byte operations
-(c) 1994, 1995 Innobase Oy
-
Created 5/30/1994 Heikki Tuuri
*******************************************************************/
diff --git a/include/ut0dbg.h b/include/ut0dbg.h
index e143ac89b69..a206789fd4c 100644
--- a/include/ut0dbg.h
+++ b/include/ut0dbg.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/*********************************************************************
Debug utilities for Innobase
-(c) 1994, 1995 Innobase Oy
-
Created 1/30/1994 Heikki Tuuri
**********************************************************************/
@@ -39,7 +55,7 @@ extern ibool panic_shutdown;
void ut_dbg_panic(void);
# define UT_DBG_PANIC ut_dbg_panic()
/* Stop threads in ut_a(). */
-# define UT_DBG_STOP while (0) /* We do not do this on NetWare */
+# define UT_DBG_STOP do {} while (0) /* We do not do this on NetWare */
#else /* __NETWARE__ */
# if defined(__WIN__) || defined(__INTEL_COMPILER)
# undef UT_DBG_USE_ABORT
@@ -71,7 +87,7 @@ ut_dbg_stop_thread(
/* Abort the execution. */
# define UT_DBG_PANIC abort()
/* Stop threads (null operation) */
-# define UT_DBG_STOP while (0)
+# define UT_DBG_STOP do {} while (0)
# else /* UT_DBG_USE_ABORT */
/* Abort the execution. */
# define UT_DBG_PANIC \
diff --git a/include/ut0list.h b/include/ut0list.h
index c676a22fa39..034aa400af9 100644
--- a/include/ut0list.h
+++ b/include/ut0list.h
@@ -1,3 +1,21 @@
+/*****************************************************************************
+
+Copyright (c) 2006, 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
+
+*****************************************************************************/
+
/***********************************************************************
A double-linked list. This differs from the one in ut0lst.h in that in this
one, each list node contains a pointer to the data, whereas the one in
@@ -18,7 +36,6 @@ automatically freeing the list node when the item's heap is freed.
************************************************************************/
-
#ifndef IB_LIST_H
#define IB_LIST_H
diff --git a/include/ut0list.ic b/include/ut0list.ic
index c2d3e4557f0..c79a0cf18dc 100644
--- a/include/ut0list.ic
+++ b/include/ut0list.ic
@@ -1,3 +1,21 @@
+/*****************************************************************************
+
+Copyright (c) 2006, 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
+
+*****************************************************************************/
+
/********************************************************************
Get the first node in the list. */
UNIV_INLINE
diff --git a/include/ut0lst.h b/include/ut0lst.h
index 72ee85a79f0..46ee23a2538 100644
--- a/include/ut0lst.h
+++ b/include/ut0lst.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/**********************************************************************
List utilities
-(c) 1995 Innobase Oy
-
Created 9/10/1995 Heikki Tuuri
***********************************************************************/
diff --git a/include/ut0mem.h b/include/ut0mem.h
index 1e4b3dd232b..f8dec99ed4a 100644
--- a/include/ut0mem.h
+++ b/include/ut0mem.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/***********************************************************************
Memory primitives
-(c) 1994, 1995 Innobase Oy
-
Created 5/30/1994 Heikki Tuuri
************************************************************************/
@@ -10,11 +26,16 @@ Created 5/30/1994 Heikki Tuuri
#define ut0mem_h
#include "univ.i"
+#include "os0sync.h"
#include <string.h>
-#include <stdlib.h>
-/* The total amount of memory currently allocated from the OS with malloc */
-extern ulint ut_total_allocated_memory;
+/* The total amount of memory currently allocated from the operating
+system with os_mem_alloc_large() or malloc(). Does not count malloc()
+if srv_use_sys_malloc is set. Protected by ut_list_mutex. */
+extern ulint ut_total_allocated_memory;
+
+/* Mutex protecting ut_total_allocated_memory and ut_mem_block_list */
+extern os_fast_mutex_t ut_list_mutex;
UNIV_INLINE
void*
@@ -28,6 +49,12 @@ UNIV_INLINE
int
ut_memcmp(const void* str1, const void* str2, ulint n);
+/**************************************************************************
+Initializes the mem block list at database startup. */
+UNIV_INTERN
+void
+ut_mem_init(void);
+/*=============*/
/**************************************************************************
Allocates memory. Sets it also to zero if UNIV_SET_MEM_TO_ZERO is
diff --git a/include/ut0mem.ic b/include/ut0mem.ic
index 03399497860..5078c721706 100644
--- a/include/ut0mem.ic
+++ b/include/ut0mem.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/***********************************************************************
Memory primitives
-(c) 1994, 1995 Innobase Oy
-
Created 5/30/1994 Heikki Tuuri
************************************************************************/
diff --git a/include/ut0rnd.h b/include/ut0rnd.h
index 9939126db93..b9e23d7cd14 100644
--- a/include/ut0rnd.h
+++ b/include/ut0rnd.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/**********************************************************************
Random numbers and hashing
-(c) 1994, 1995 Innobase Oy
-
Created 1/20/1994 Heikki Tuuri
***********************************************************************/
diff --git a/include/ut0rnd.ic b/include/ut0rnd.ic
index 1f82989d64e..d72100d16a1 100644
--- a/include/ut0rnd.ic
+++ b/include/ut0rnd.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/******************************************************************
Random numbers and hashing
-(c) 1994, 1995 Innobase Oy
-
Created 5/30/1994 Heikki Tuuri
*******************************************************************/
diff --git a/include/ut0sort.h b/include/ut0sort.h
index e047927f026..5fd5db54832 100644
--- a/include/ut0sort.h
+++ b/include/ut0sort.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/**********************************************************************
Sort utility
-(c) 1995 Innobase Oy
-
Created 11/9/1995 Heikki Tuuri
***********************************************************************/
diff --git a/include/ut0ut.h b/include/ut0ut.h
index 9a545859c00..3ca14acd2ef 100644
--- a/include/ut0ut.h
+++ b/include/ut0ut.h
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/**********************************************************************
Various utilities
-(c) 1994, 1995 Innobase Oy
-
Created 1/20/1994 Heikki Tuuri
***********************************************************************/
@@ -196,6 +212,7 @@ void
ut_sprintf_timestamp(
/*=================*/
char* buf); /* in: buffer where to sprintf */
+#ifdef UNIV_HOTBACKUP
/**************************************************************
Sprintfs a timestamp to a buffer with no spaces and with ':' characters
replaced by '_'. */
@@ -213,6 +230,7 @@ ut_get_year_month_day(
ulint* year, /* out: current year */
ulint* month, /* out: month */
ulint* day); /* out: day */
+#endif /* UNIV_HOTBACKUP */
/*****************************************************************
Runs an idle loop on CPU. The argument gives the desired delay
in microseconds on 100 MHz Pentium + Visual C++. */
diff --git a/include/ut0ut.ic b/include/ut0ut.ic
index 12cd48bb7eb..e4e0a2acce6 100644
--- a/include/ut0ut.ic
+++ b/include/ut0ut.ic
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/******************************************************************
Various utilities
-(c) 1994, 1995 Innobase Oy
-
Created 5/30/1994 Heikki Tuuri
*******************************************************************/
diff --git a/include/ut0vec.h b/include/ut0vec.h
index 60b2b3bbc0e..aeb7e168dc6 100644
--- a/include/ut0vec.h
+++ b/include/ut0vec.h
@@ -1,3 +1,21 @@
+/*****************************************************************************
+
+Copyright (c) 2006, 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
+
+*****************************************************************************/
+
#ifndef IB_VECTOR_H
#define IB_VECTOR_H
diff --git a/include/ut0vec.ic b/include/ut0vec.ic
index f89b7826776..b0e853717e3 100644
--- a/include/ut0vec.ic
+++ b/include/ut0vec.ic
@@ -1,3 +1,21 @@
+/*****************************************************************************
+
+Copyright (c) 2006, 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
+
+*****************************************************************************/
+
/********************************************************************
Get number of elements in vector. */
UNIV_INLINE
diff --git a/include/ut0wqueue.h b/include/ut0wqueue.h
index 49747111119..6bb80dad532 100644
--- a/include/ut0wqueue.h
+++ b/include/ut0wqueue.h
@@ -1,8 +1,25 @@
+/*****************************************************************************
+
+Copyright (c) 2006, 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
+
+*****************************************************************************/
+
/***********************************************************************
A Work queue. Threads can add work items to the queue and other threads can
wait for work items to be available and take them off the queue for
processing.
-
************************************************************************/
#ifndef IB_WORK_QUEUE_H
diff --git a/lock/lock0iter.c b/lock/lock0iter.c
index 923010822da..e7a128d0db3 100644
--- a/lock/lock0iter.c
+++ b/lock/lock0iter.c
@@ -1,9 +1,25 @@
+/*****************************************************************************
+
+Copyright (c) 2007, 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
+
+*****************************************************************************/
+
/******************************************************
Lock queue iterator. Can iterate over table and record
lock queues.
-(c) 2007 Innobase Oy
-
Created July 16, 2007 Vasil Dimov
*******************************************************/
@@ -15,6 +31,9 @@ Created July 16, 2007 Vasil Dimov
#include "lock0priv.h"
#include "ut0dbg.h"
#include "ut0lst.h"
+#ifdef UNIV_DEBUG
+# include "srv0srv.h" /* kernel_mutex */
+#endif /* UNIV_DEBUG */
/***********************************************************************
Initialize lock queue iterator so that it starts to iterate from
@@ -34,6 +53,8 @@ lock_queue_iterator_reset(
ulint bit_no) /* in: record number in the
heap */
{
+ ut_ad(mutex_own(&kernel_mutex));
+
iter->current_lock = lock;
if (bit_no != ULINT_UNDEFINED) {
@@ -68,6 +89,8 @@ lock_queue_iterator_get_prev(
{
const lock_t* prev_lock;
+ ut_ad(mutex_own(&kernel_mutex));
+
switch (lock_get_type_low(iter->current_lock)) {
case LOCK_REC:
prev_lock = lock_rec_get_prev(
diff --git a/lock/lock0lock.c b/lock/lock0lock.c
index 9f352a674d2..3730c66313d 100644
--- a/lock/lock0lock.c
+++ b/lock/lock0lock.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
The transaction lock system
-(c) 1996 Innobase Oy
-
Created 5/7/1996 Heikki Tuuri
*******************************************************/
@@ -699,7 +715,10 @@ lock_is_table_exclusive(
const lock_t* lock;
ibool ok = FALSE;
- ut_ad(table && trx);
+ ut_ad(table);
+ ut_ad(trx);
+
+ lock_mutex_enter_kernel();
for (lock = UT_LIST_GET_FIRST(table->locks);
lock;
@@ -707,7 +726,7 @@ lock_is_table_exclusive(
if (lock->trx != trx) {
/* A lock on the table is held
by some other transaction. */
- return(FALSE);
+ goto not_ok;
}
if (!(lock_get_type_low(lock) & LOCK_TABLE)) {
@@ -724,11 +743,16 @@ lock_is_table_exclusive(
auto_increment lock. */
break;
default:
+not_ok:
/* Other table locks than LOCK_IX are not allowed. */
- return(FALSE);
+ ok = FALSE;
+ goto func_exit;
}
}
+func_exit:
+ lock_mutex_exit_kernel();
+
return(ok);
}
@@ -3834,6 +3858,7 @@ lock_table_has_to_wait_in_queue(
dict_table_t* table;
lock_t* lock;
+ ut_ad(mutex_own(&kernel_mutex));
ut_ad(lock_get_wait(wait_lock));
table = wait_lock->un_member.tab_lock.table;
diff --git a/log/log0log.c b/log/log0log.c
index fb737188039..d2ea0507705 100644
--- a/log/log0log.c
+++ b/log/log0log.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/******************************************************
Database log
-(c) 1995-1997 Innobase Oy
-
Created 12/9/1995 Heikki Tuuri
*******************************************************/
@@ -739,7 +755,7 @@ log_init(void)
ut_a(LOG_BUFFER_SIZE >= 16 * OS_FILE_LOG_BLOCK_SIZE);
ut_a(LOG_BUFFER_SIZE >= 4 * UNIV_PAGE_SIZE);
- buf = ut_malloc(LOG_BUFFER_SIZE + OS_FILE_LOG_BLOCK_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_size = LOG_BUFFER_SIZE;
@@ -1782,6 +1798,7 @@ log_group_checkpoint(
}
}
+#ifdef UNIV_HOTBACKUP
/**********************************************************
Writes info to a buffer of a log group when log files are created in
backup restoration. */
@@ -1833,6 +1850,7 @@ log_reset_first_header_and_checkpoint(
allocated size in the tablespace, but unfortunately we do not
know it here */
}
+#endif /* UNIV_HOTBACKUP */
/**********************************************************
Reads a checkpoint info from a log group header to log_sys->checkpoint_buf. */
diff --git a/log/log0recv.c b/log/log0recv.c
index a36eabce9a4..b72dde4efcf 100644
--- a/log/log0recv.c
+++ b/log/log0recv.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 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
+
+*****************************************************************************/
+
/******************************************************
Recovery
-(c) 1997 Innobase Oy
-
Created 9/20/1997 Heikki Tuuri
*******************************************************/
@@ -18,23 +34,14 @@ Created 9/20/1997 Heikki Tuuri
#include "buf0rea.h"
#include "srv0srv.h"
#include "srv0start.h"
-#include "mtr0mtr.h"
#include "mtr0log.h"
-#include "page0page.h"
#include "page0cur.h"
#include "page0zip.h"
-#include "btr0btr.h"
#include "btr0cur.h"
#include "ibuf0ibuf.h"
#include "trx0undo.h"
#include "trx0rec.h"
#include "trx0roll.h"
-#include "btr0cur.h"
-#include "btr0cur.h"
-#include "btr0cur.h"
-#include "dict0boot.h"
-#include "fil0fil.h"
-#include "sync0sync.h"
#include "row0merge.h"
#ifdef UNIV_HOTBACKUP
@@ -583,6 +590,7 @@ not_consistent:
return(DB_SUCCESS);
}
+#ifdef UNIV_HOTBACKUP
/***********************************************************************
Reads the checkpoint info needed in hot backup. */
UNIV_INTERN
@@ -653,6 +661,7 @@ recv_read_cp_info_for_backup(
return(TRUE);
}
+#endif /* UNIV_HOTBACKUP */
/**********************************************************
Checks the 4-byte checksum to the trailer checksum field of a log block.
@@ -690,6 +699,7 @@ log_block_checksum_is_ok_or_old_format(
return(FALSE);
}
+#ifdef UNIV_HOTBACKUP
/***********************************************************************
Scans the log segment and n_bytes_scanned is set to the length of valid
log scanned. */
@@ -779,6 +789,7 @@ recv_scan_log_seg_for_backup(
}
}
}
+#endif /* UNIV_HOTBACKUP */
/***********************************************************************
Tries to parse a single log record body and also applies it to a page if
@@ -2551,12 +2562,14 @@ recv_recovery_from_checkpoint_finish should be called later to complete
the recovery and free the resources used in it. */
UNIV_INTERN
ulint
-recv_recovery_from_checkpoint_start(
-/*================================*/
+recv_recovery_from_checkpoint_start_func(
+/*=====================================*/
/* out: error code or DB_SUCCESS */
+#ifdef UNIV_LOG_ARCHIVE
ulint type, /* in: LOG_CHECKPOINT or LOG_ARCHIVE */
ib_uint64_t limit_lsn, /* in: recover up to this lsn
if possible */
+#endif /* UNIV_LOG_ARCHIVE */
ib_uint64_t min_flushed_lsn,/* in: min flushed lsn from
data files */
ib_uint64_t max_flushed_lsn)/* in: max flushed lsn from
@@ -2572,14 +2585,20 @@ recv_recovery_from_checkpoint_start(
ib_uint64_t group_scanned_lsn;
ib_uint64_t contiguous_lsn;
ib_uint64_t archived_lsn;
- ulint capacity;
byte* buf;
byte log_hdr_buf[LOG_FILE_HDR_SIZE];
ulint err;
+#ifdef UNIV_LOG_ARCHIVE
ut_ad(type != LOG_CHECKPOINT || limit_lsn == IB_ULONGLONG_MAX);
+# define TYPE_CHECKPOINT (type == LOG_CHECKPOINT)
+# define LIMIT_LSN limit_lsn
+#else /* UNIV_LOG_ARCHIVE */
+# define TYPE_CHECKPOINT 1
+# define LIMIT_LSN IB_ULONGLONG_MAX
+#endif /* UNIV_LOG_ARCHIVE */
- if (type == LOG_CHECKPOINT) {
+ if (TYPE_CHECKPOINT) {
recv_sys_create();
recv_sys_init(FALSE, buf_pool_get_curr_size());
}
@@ -2595,7 +2614,7 @@ recv_recovery_from_checkpoint_start(
recv_recovery_on = TRUE;
- recv_sys->limit_lsn = limit_lsn;
+ recv_sys->limit_lsn = LIMIT_LSN;
mutex_enter(&(log_sys->mutex));
@@ -2662,7 +2681,7 @@ recv_recovery_from_checkpoint_start(
}
#endif /* UNIV_LOG_ARCHIVE */
- if (type == LOG_CHECKPOINT) {
+ if (TYPE_CHECKPOINT) {
/* Start reading the log groups from the checkpoint lsn up. The
variable contiguous_lsn contains an lsn up to which the log is
known to be contiguously written to all log groups. */
@@ -2677,7 +2696,12 @@ recv_recovery_from_checkpoint_start(
contiguous_lsn = ut_uint64_align_down(recv_sys->scanned_lsn,
OS_FILE_LOG_BLOCK_SIZE);
- if (type == LOG_ARCHIVE) {
+ if (TYPE_CHECKPOINT) {
+ up_to_date_group = max_cp_group;
+#ifdef UNIV_LOG_ARCHIVE
+ } else {
+ ulint capacity;
+
/* Try to recover the remaining part from logs: first from
the logs of the archived group */
@@ -2710,20 +2734,21 @@ recv_recovery_from_checkpoint_start(
group->scanned_lsn = group_scanned_lsn;
up_to_date_group = group;
- } else {
- up_to_date_group = max_cp_group;
+#endif /* UNIV_LOG_ARCHIVE */
}
ut_ad(RECV_SCAN_SIZE <= log_sys->buf_size);
group = UT_LIST_GET_FIRST(log_sys->log_groups);
+#ifdef UNIV_LOG_ARCHIVE
if ((type == LOG_ARCHIVE) && (group == recv_sys->archive_group)) {
group = UT_LIST_GET_NEXT(log_groups, group);
}
+#endif /* UNIV_LOG_ARCHIVE */
/* Set the flag to publish that we are doing startup scan. */
- recv_log_scan_is_startup_type = (type == LOG_CHECKPOINT);
+ recv_log_scan_is_startup_type = TYPE_CHECKPOINT;
while (group) {
old_scanned_lsn = recv_sys->scanned_lsn;
@@ -2737,17 +2762,19 @@ recv_recovery_from_checkpoint_start(
up_to_date_group = group;
}
+#ifdef UNIV_LOG_ARCHIVE
if ((type == LOG_ARCHIVE)
&& (group == recv_sys->archive_group)) {
group = UT_LIST_GET_NEXT(log_groups, group);
}
+#endif /* UNIV_LOG_ARCHIVE */
group = UT_LIST_GET_NEXT(log_groups, group);
}
/* Done with startup scan. Clear the flag. */
recv_log_scan_is_startup_type = FALSE;
- if (type == LOG_CHECKPOINT) {
+ if (TYPE_CHECKPOINT) {
/* NOTE: we always do a 'recovery' at startup, but only if
there is something wrong we will print a message to the
user about recovery: */
@@ -2825,7 +2852,7 @@ recv_recovery_from_checkpoint_start(
mutex_exit(&(log_sys->mutex));
- if (recv_sys->recovered_lsn >= limit_lsn) {
+ if (recv_sys->recovered_lsn >= LIMIT_LSN) {
return(DB_SUCCESS);
}
@@ -2888,6 +2915,9 @@ recv_recovery_from_checkpoint_start(
records in the hash table can be run in background. */
return(DB_SUCCESS);
+
+#undef TYPE_CHECKPOINT
+#undef LIMIT_LSN
}
/************************************************************
diff --git a/mach/mach0data.c b/mach/mach0data.c
index 928c433ec29..5deb475318d 100644
--- a/mach/mach0data.c
+++ b/mach/mach0data.c
@@ -1,9 +1,25 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/**********************************************************************
Utilities for converting data from the database file
to the machine format.
-(c) 1995 Innobase Oy
-
Created 11/28/1995 Heikki Tuuri
***********************************************************************/
diff --git a/mem/mem0dbg.c b/mem/mem0dbg.c
index 079355ac49b..a1647462922 100644
--- a/mem/mem0dbg.c
+++ b/mem/mem0dbg.c
@@ -1,9 +1,25 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/************************************************************************
The memory management: the debug code. This is not a compilation module,
but is included in mem0mem.* !
-(c) 1994, 1995 Innobase Oy
-
Created 6/9/1994 Heikki Tuuri
*************************************************************************/
@@ -138,6 +154,14 @@ mem_init(
mem_hash_initialized = TRUE;
#endif
+ if (UNIV_LIKELY(srv_use_sys_malloc)) {
+ /* When innodb_use_sys_malloc is set, the
+ mem_comm_pool won't be used for any allocations. We
+ create a dummy mem_comm_pool, because some statistics
+ and debugging code relies on it being initialized. */
+ size = 1;
+ }
+
mem_comm_pool = mem_pool_create(size);
}
diff --git a/mem/mem0mem.c b/mem/mem0mem.c
index 36e53930f42..b7345f5846b 100644
--- a/mem/mem0mem.c
+++ b/mem/mem0mem.c
@@ -1,20 +1,33 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/************************************************************************
The memory management
-(c) 1994, 1995 Innobase Oy
-
Created 6/9/1994 Heikki Tuuri
*************************************************************************/
-
#include "mem0mem.h"
#ifdef UNIV_NONINL
#include "mem0mem.ic"
#endif
-#include "mach0data.h"
#include "buf0buf.h"
-#include "btr0sea.h"
#include "srv0srv.h"
#include "mem0dbg.c"
#include <stdarg.h>
diff --git a/mem/mem0pool.c b/mem/mem0pool.c
index d3bf4d04853..34de6b2a706 100644
--- a/mem/mem0pool.c
+++ b/mem/mem0pool.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 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
+
+*****************************************************************************/
+
/************************************************************************
The lowest-level memory management
-(c) 1997 Innobase Oy
-
Created 5/12/1997 Heikki Tuuri
*************************************************************************/
@@ -11,6 +27,7 @@ Created 5/12/1997 Heikki Tuuri
#include "mem0pool.ic"
#endif
+#include "srv0srv.h"
#include "sync0sync.h"
#include "ut0mem.h"
#include "ut0lst.h"
@@ -192,8 +209,6 @@ mem_pool_create(
ulint i;
ulint used;
- ut_a(size > 10000);
-
pool = ut_malloc(sizeof(mem_pool_t));
/* We do not set the memory to zero (FALSE) in the pool,
@@ -336,6 +351,12 @@ mem_area_alloc(
ulint n;
ibool ret;
+ /* If we are using os allocator just make a simple call
+ to malloc */
+ if (UNIV_LIKELY(srv_use_sys_malloc)) {
+ return(malloc(*psize));
+ }
+
size = *psize;
n = ut_2_log(ut_max(size + MEM_AREA_EXTRA_SIZE, MEM_AREA_MIN_SIZE));
@@ -470,6 +491,12 @@ mem_area_free(
ulint size;
ulint n;
+ if (UNIV_LIKELY(srv_use_sys_malloc)) {
+ free(ptr);
+
+ return;
+ }
+
/* It may be that the area was really allocated from the OS with
regular malloc: check if ptr points within our memory pool */
diff --git a/mtr/mtr0log.c b/mtr/mtr0log.c
index 4ddae293a68..0fe66d08c05 100644
--- a/mtr/mtr0log.c
+++ b/mtr/mtr0log.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/******************************************************
Mini-transaction log routines
-(c) 1995 Innobase Oy
-
Created 12/7/1995 Heikki Tuuri
*******************************************************/
diff --git a/mtr/mtr0mtr.c b/mtr/mtr0mtr.c
index 6ab1247aba7..881751b560e 100644
--- a/mtr/mtr0mtr.c
+++ b/mtr/mtr0mtr.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/******************************************************
Mini-transaction buffer
-(c) 1995 Innobase Oy
-
Created 11/26/1995 Heikki Tuuri
*******************************************************/
@@ -158,9 +174,8 @@ mtr_commit(
ut_ad(mtr);
ut_ad(mtr->magic_n == MTR_MAGIC_N);
ut_ad(mtr->state == MTR_ACTIVE);
-#ifdef UNIV_DEBUG
- mtr->state = MTR_COMMITTING;
-#endif
+ ut_d(mtr->state = MTR_COMMITTING);
+
write_log = mtr->modifications && mtr->n_log_recs;
if (write_log) {
@@ -181,9 +196,7 @@ mtr_commit(
log_release();
}
-#ifdef UNIV_DEBUG
- mtr->state = MTR_COMMITTED;
-#endif
+ ut_d(mtr->state = MTR_COMMITTED);
dyn_array_free(&(mtr->memo));
dyn_array_free(&(mtr->log));
}
@@ -312,14 +325,7 @@ mtr_memo_contains_page(
const byte* ptr, /* in: pointer to buffer frame */
ulint type) /* in: type of object */
{
- ibool ret;
-
- //buf_pool_mutex_enter();
- rw_lock_s_lock(&page_hash_latch);
- ret = mtr_memo_contains(mtr, buf_block_align(ptr), type);
- //buf_pool_mutex_exit();
- rw_lock_s_unlock(&page_hash_latch);
- return(ret);
+ return(mtr_memo_contains(mtr, buf_block_align(ptr), type));
}
/*************************************************************
diff --git a/mysql-test/innodb-autoinc.result b/mysql-test/innodb-autoinc.result
index 589bf2f30b0..ade4db35ce6 100644
--- a/mysql-test/innodb-autoinc.result
+++ b/mysql-test/innodb-autoinc.result
@@ -471,10 +471,9 @@ SHOW VARIABLES LIKE "%auto_inc%";
Variable_name Value
auto_increment_increment 2
auto_increment_offset 10
-INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
+INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
SELECT * FROM t1;
c1
-0
1
18446744073709551603
18446744073709551604
@@ -505,12 +504,13 @@ SHOW VARIABLES LIKE "%auto_inc%";
Variable_name Value
auto_increment_increment 5
auto_increment_offset 7
-INSERT INTO t1 VALUES (NULL),(NULL), (NULL);
-Got one of the listed errors
+INSERT INTO t1 VALUES (NULL),(NULL);
SELECT * FROM t1;
c1
1
18446744073709551603
+18446744073709551607
+18446744073709551612
DROP TABLE t1;
SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
SET @@INSERT_ID=1;
@@ -572,12 +572,298 @@ SHOW VARIABLES LIKE "%auto_inc%";
Variable_name Value
auto_increment_increment 65535
auto_increment_offset 65535
-INSERT INTO t1 VALUES (NULL),(NULL), (NULL);
+INSERT INTO t1 VALUES (NULL);
SELECT * FROM t1;
c1
1
-65534
-65535
18446744073709551610
18446744073709551615
DROP TABLE t1;
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
+SET @@INSERT_ID=1;
+SHOW VARIABLES LIKE "%auto_inc%";
+Variable_name Value
+auto_increment_increment 1
+auto_increment_offset 1
+CREATE TABLE t1 (c1 DOUBLE NOT NULL AUTO_INCREMENT, c2 INT, PRIMARY KEY (c1)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES(NULL, 1);
+INSERT INTO t1 VALUES(NULL, 2);
+SELECT * FROM t1;
+c1 c2
+1 1
+2 2
+ALTER TABLE t1 CHANGE c1 c1 SERIAL;
+SELECT * FROM t1;
+c1 c2
+1 1
+2 2
+INSERT INTO t1 VALUES(NULL, 3);
+INSERT INTO t1 VALUES(NULL, 4);
+SELECT * FROM t1;
+c1 c2
+1 1
+2 2
+3 3
+4 4
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c1 FLOAT NOT NULL AUTO_INCREMENT, c2 INT, PRIMARY KEY (c1)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES(NULL, 1);
+INSERT INTO t1 VALUES(NULL, 2);
+SELECT * FROM t1;
+c1 c2
+1 1
+2 2
+ALTER TABLE t1 CHANGE c1 c1 SERIAL;
+SELECT * FROM t1;
+c1 c2
+1 1
+2 2
+INSERT INTO t1 VALUES(NULL, 3);
+INSERT INTO t1 VALUES(NULL, 4);
+SELECT * FROM t1;
+c1 c2
+1 1
+2 2
+3 3
+4 4
+DROP TABLE t1;
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=5;
+DROP TABLE IF EXISTS t1;
+Warnings:
+Note 1051 Unknown table 't1'
+DROP TABLE IF EXISTS t2;
+Warnings:
+Note 1051 Unknown table 't2'
+CREATE TABLE t1 (
+a INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
+b INT(10) UNSIGNED NOT NULL,
+c ENUM('FALSE','TRUE') DEFAULT NULL,
+PRIMARY KEY (a)) ENGINE = InnoDB;
+CREATE TABLE t2 (
+m INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
+n INT(10) UNSIGNED NOT NULL,
+o enum('FALSE','TRUE') DEFAULT NULL,
+PRIMARY KEY (m)) ENGINE = InnoDB;
+INSERT INTO t2 (n,o) VALUES
+(1 , 'true'), (1 , 'false'), (2 , 'true'), (2 , 'false'), (3 , 'true'),
+(3 , 'false'), (4 , 'true'), (4 , 'false'), (5 , 'true'), (5 , 'false');
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `m` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `n` int(10) unsigned NOT NULL,
+ `o` enum('FALSE','TRUE') DEFAULT NULL,
+ PRIMARY KEY (`m`)
+) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=latin1
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 ;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `b` int(10) unsigned NOT NULL,
+ `c` enum('FALSE','TRUE') DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=latin1
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 ;
+SELECT * FROM t1;
+a b c
+1 1 TRUE
+2 1 FALSE
+3 2 TRUE
+4 2 FALSE
+5 3 TRUE
+6 3 FALSE
+7 4 TRUE
+8 4 FALSE
+9 5 TRUE
+10 5 FALSE
+13 1 TRUE
+14 1 FALSE
+15 2 TRUE
+16 2 FALSE
+17 3 TRUE
+18 3 FALSE
+19 4 TRUE
+20 4 FALSE
+21 5 TRUE
+22 5 FALSE
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `b` int(10) unsigned NOT NULL,
+ `c` enum('FALSE','TRUE') DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=latin1
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
+SELECT * FROM t1;
+a b c
+1 1 TRUE
+2 1 FALSE
+3 2 TRUE
+4 2 FALSE
+5 3 TRUE
+6 3 FALSE
+7 4 TRUE
+8 4 FALSE
+9 5 TRUE
+10 5 FALSE
+13 1 TRUE
+14 1 FALSE
+15 2 TRUE
+16 2 FALSE
+17 3 TRUE
+18 3 FALSE
+19 4 TRUE
+20 4 FALSE
+21 5 TRUE
+22 5 FALSE
+23 1 FALSE
+24 2 FALSE
+25 3 FALSE
+26 4 FALSE
+27 5 FALSE
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `b` int(10) unsigned NOT NULL,
+ `c` enum('FALSE','TRUE') DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=latin1
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
+SELECT * FROM t1;
+a b c
+1 1 TRUE
+2 1 FALSE
+3 2 TRUE
+4 2 FALSE
+5 3 TRUE
+6 3 FALSE
+7 4 TRUE
+8 4 FALSE
+9 5 TRUE
+10 5 FALSE
+13 1 TRUE
+14 1 FALSE
+15 2 TRUE
+16 2 FALSE
+17 3 TRUE
+18 3 FALSE
+19 4 TRUE
+20 4 FALSE
+21 5 TRUE
+22 5 FALSE
+23 1 FALSE
+24 2 FALSE
+25 3 FALSE
+26 4 FALSE
+27 5 FALSE
+30 1 FALSE
+31 2 FALSE
+32 3 FALSE
+33 4 FALSE
+34 5 FALSE
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `b` int(10) unsigned NOT NULL,
+ `c` enum('FALSE','TRUE') DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=latin1
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `b` int(10) unsigned NOT NULL,
+ `c` enum('FALSE','TRUE') DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB AUTO_INCREMENT=44 DEFAULT CHARSET=latin1
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `b` int(10) unsigned NOT NULL,
+ `c` enum('FALSE','TRUE') DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB AUTO_INCREMENT=51 DEFAULT CHARSET=latin1
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
+SELECT * FROM t1;
+a b c
+1 1 TRUE
+2 1 FALSE
+3 2 TRUE
+4 2 FALSE
+5 3 TRUE
+6 3 FALSE
+7 4 TRUE
+8 4 FALSE
+9 5 TRUE
+10 5 FALSE
+13 1 TRUE
+14 1 FALSE
+15 2 TRUE
+16 2 FALSE
+17 3 TRUE
+18 3 FALSE
+19 4 TRUE
+20 4 FALSE
+21 5 TRUE
+22 5 FALSE
+23 1 FALSE
+24 2 FALSE
+25 3 FALSE
+26 4 FALSE
+27 5 FALSE
+30 1 FALSE
+31 2 FALSE
+32 3 FALSE
+33 4 FALSE
+34 5 FALSE
+37 1 FALSE
+38 2 FALSE
+39 3 FALSE
+40 4 FALSE
+41 5 FALSE
+44 1 FALSE
+45 2 FALSE
+46 3 FALSE
+47 4 FALSE
+48 5 FALSE
+51 1 FALSE
+52 2 FALSE
+53 3 FALSE
+54 4 FALSE
+55 5 FALSE
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `b` int(10) unsigned NOT NULL,
+ `c` enum('FALSE','TRUE') DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB AUTO_INCREMENT=58 DEFAULT CHARSET=latin1
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE IF EXISTS t1;
+Warnings:
+Note 1051 Unknown table 't1'
+DROP TABLE IF EXISTS t2;
+Warnings:
+Note 1051 Unknown table 't2'
+CREATE TABLE t1(
+c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT
+PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
+CREATE TABLE t2(
+c1 TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT
+PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t2 SELECT c1 FROM t1;
+Got one of the listed errors
+INSERT INTO t2 SELECT NULL FROM t1;
+Got one of the listed errors
+DROP TABLE t1;
+DROP TABLE t2;
diff --git a/mysql-test/innodb-autoinc.test b/mysql-test/innodb-autoinc.test
index 172913349db..d76b29a7dc8 100644
--- a/mysql-test/innodb-autoinc.test
+++ b/mysql-test/innodb-autoinc.test
@@ -23,7 +23,6 @@ DROP TABLE t1;
CREATE TABLE t1 (c1 TINYINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (127, null);
-- error ER_DUP_ENTRY,1062
--- warning ER_WARN_DATA_OUT_OF_RANGE,1264
INSERT INTO t1 (c2) VALUES ('innodb');
SELECT * FROM t1;
DROP TABLE t1;
@@ -31,7 +30,6 @@ DROP TABLE t1;
CREATE TABLE t1 (c1 TINYINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (255, null);
-- error ER_DUP_ENTRY,1062
--- warning ER_WARN_DATA_OUT_OF_RANGE,1264
INSERT INTO t1 (c2) VALUES ('innodb');
SELECT * FROM t1;
DROP TABLE t1;
@@ -41,7 +39,6 @@ DROP TABLE t1;
CREATE TABLE t1 (c1 SMALLINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (32767, null);
-- error ER_DUP_ENTRY,1062
--- warning ER_WARN_DATA_OUT_OF_RANGE,1264
INSERT INTO t1 (c2) VALUES ('innodb');
SELECT * FROM t1;
DROP TABLE t1;
@@ -49,7 +46,6 @@ DROP TABLE t1;
CREATE TABLE t1 (c1 SMALLINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (65535, null);
-- error ER_DUP_ENTRY,1062
--- warning ER_WARN_DATA_OUT_OF_RANGE,1264
INSERT INTO t1 (c2) VALUES ('innodb');
SELECT * FROM t1;
DROP TABLE t1;
@@ -59,7 +55,6 @@ DROP TABLE t1;
CREATE TABLE t1 (c1 MEDIUMINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (8388607, null);
-- error ER_DUP_ENTRY,1062
--- warning ER_WARN_DATA_OUT_OF_RANGE,1264
INSERT INTO t1 (c2) VALUES ('innodb');
SELECT * FROM t1;
DROP TABLE t1;
@@ -67,7 +62,6 @@ DROP TABLE t1;
CREATE TABLE t1 (c1 MEDIUMINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (16777215, null);
-- error ER_DUP_ENTRY,1062
--- warning ER_WARN_DATA_OUT_OF_RANGE,1264
INSERT INTO t1 (c2) VALUES ('innodb');
SELECT * FROM t1;
DROP TABLE t1;
@@ -77,7 +71,6 @@ DROP TABLE t1;
CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (2147483647, null);
-- error ER_DUP_ENTRY,1062
--- warning ER_WARN_DATA_OUT_OF_RANGE,1264
INSERT INTO t1 (c2) VALUES ('innodb');
SELECT * FROM t1;
DROP TABLE t1;
@@ -94,7 +87,6 @@ DROP TABLE t1;
CREATE TABLE t1 (c1 BIGINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (9223372036854775807, null);
-- error ER_DUP_ENTRY,1062
--- warning ER_WARN_DATA_OUT_OF_RANGE,1264
INSERT INTO t1 (c2) VALUES ('innodb');
SELECT * FROM t1;
DROP TABLE t1;
@@ -276,7 +268,7 @@ CREATE TABLE t1 (c1 BIGINT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
# TODO: Fix the autoinc init code
# We have to do this because of a bug in the AUTOINC init code.
INSERT INTO t1 VALUES(NULL);
-INSERT INTO t1 VALUES (9223372036854775794); -- 2^63 - 14
+INSERT INTO t1 VALUES (9223372036854775794); #-- 2^63 - 14
SELECT * FROM t1;
SET @@SESSION.AUTO_INCREMENT_INCREMENT=2, @@SESSION.AUTO_INCREMENT_OFFSET=10;
SHOW VARIABLES LIKE "%auto_inc%";
@@ -295,14 +287,25 @@ CREATE TABLE t1 (c1 BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=Inno
# TODO: Fix the autoinc init code
# We have to do this because of a bug in the AUTOINC init code.
INSERT INTO t1 VALUES(NULL);
-INSERT INTO t1 VALUES (18446744073709551603); -- 2^64 - 13
+INSERT INTO t1 VALUES (18446744073709551603); #-- 2^64 - 13
SELECT * FROM t1;
SET @@SESSION.AUTO_INCREMENT_INCREMENT=2, @@SESSION.AUTO_INCREMENT_OFFSET=10;
SHOW VARIABLES LIKE "%auto_inc%";
# This should fail because of overflow but it doesn't, it seems to be
# a MySQL server bug. It wraps around to 0 for the last value.
# See MySQL Bug# 39828
-INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
+#
+# Instead of wrapping around, it asserts when MySQL is compiled --with-debug
+# (see sql/handler.cc:handler::update_auto_increment()). Don't test for
+# overflow until Bug #39828 is fixed.
+#
+# Since this asserts when compiled --with-debug, we can't properly test this
+# until Bug #39828 is fixed. For now, this test is meaningless.
+#if Bug #39828 is fixed
+#INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
+#else
+INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
+#endif
SELECT * FROM t1;
DROP TABLE t1;
@@ -316,7 +319,7 @@ CREATE TABLE t1 (c1 BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=Inno
# TODO: Fix the autoinc init code
# We have to do this because of a bug in the AUTOINC init code.
INSERT INTO t1 VALUES(NULL);
-INSERT INTO t1 VALUES (18446744073709551603); -- 2^64 - 13
+INSERT INTO t1 VALUES (18446744073709551603); #-- 2^64 - 13
SELECT * FROM t1;
SET @@SESSION.AUTO_INCREMENT_INCREMENT=5, @@SESSION.AUTO_INCREMENT_OFFSET=7;
SHOW VARIABLES LIKE "%auto_inc%";
@@ -324,8 +327,16 @@ SHOW VARIABLES LIKE "%auto_inc%";
# a duplicate entry message because of a MySQL server bug, it wraps
# around. See MySQL Bug# 39828, once MySQL fix the bug we can replace
# the ER_DUP_ENTRY, 1062 below with the appropriate error message
--- error ER_DUP_ENTRY,1062
-INSERT INTO t1 VALUES (NULL),(NULL), (NULL);
+#
+# Since this asserts when compiled --with-debug, we can't properly test this
+# until Bug #39828 is fixed. For now, this test is meaningless.
+#if Bug #39828 is fixed
+# Still need to fix this error code, error should mention overflow
+#-- error ER_DUP_ENTRY,1062
+#INSERT INTO t1 VALUES (NULL),(NULL), (NULL);
+#else
+INSERT INTO t1 VALUES (NULL),(NULL);
+#endif
SELECT * FROM t1;
DROP TABLE t1;
@@ -339,9 +350,9 @@ CREATE TABLE t1 (c1 BIGINT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
# TODO: Fix the autoinc init code
# We have to do this because of a bug in the AUTOINC init code.
INSERT INTO t1 VALUES(NULL);
-INSERT INTO t1 VALUES(-9223372036854775806); -- -2^63 + 2
-INSERT INTO t1 VALUES(-9223372036854775807); -- -2^63 + 1
-INSERT INTO t1 VALUES(-9223372036854775808); -- -2^63
+INSERT INTO t1 VALUES(-9223372036854775806); #-- -2^63 + 2
+INSERT INTO t1 VALUES(-9223372036854775807); #-- -2^63 + 1
+INSERT INTO t1 VALUES(-9223372036854775808); #-- -2^63
SELECT * FROM t1;
SET @@SESSION.AUTO_INCREMENT_INCREMENT=3, @@SESSION.AUTO_INCREMENT_OFFSET=3;
SHOW VARIABLES LIKE "%auto_inc%";
@@ -359,7 +370,7 @@ CREATE TABLE t1 (c1 BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=Inno
# TODO: Fix the autoinc init code
# We have to do this because of a bug in the AUTOINC init code.
INSERT INTO t1 VALUES(NULL);
-INSERT INTO t1 VALUES (18446744073709551610); -- 2^64 - 2
+INSERT INTO t1 VALUES (18446744073709551610); #-- 2^64 - 2
SELECT * FROM t1;
SET @@SESSION.AUTO_INCREMENT_INCREMENT=1152921504606846976, @@SESSION.AUTO_INCREMENT_OFFSET=1152921504606846976;
SHOW VARIABLES LIKE "%auto_inc%";
@@ -368,6 +379,102 @@ SHOW VARIABLES LIKE "%auto_inc%";
# See MySQL Bug# 39828, once MySQL fix the bug we can enable the error
# code expected test.
# -- error ER_AUTOINC_READ_FAILED,1467
-INSERT INTO t1 VALUES (NULL),(NULL), (NULL);
+#
+# Since this asserts when compiled --with-debug, we can't properly test this
+# until Bug #39828 is fixed. For now, this test is meaningless.
+#if Bug #39828 is fixed
+#-- error ER_AUTOINC_READ_FAILED,1467
+#INSERT INTO t1 VALUES (NULL),(NULL);
+#else
+INSERT INTO t1 VALUES (NULL);
+#endif
+SELECT * FROM t1;
+DROP TABLE t1;
+
+#
+# Check for floating point autoinc column handling
+#
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
+SET @@INSERT_ID=1;
+SHOW VARIABLES LIKE "%auto_inc%";
+CREATE TABLE t1 (c1 DOUBLE NOT NULL AUTO_INCREMENT, c2 INT, PRIMARY KEY (c1)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES(NULL, 1);
+INSERT INTO t1 VALUES(NULL, 2);
+SELECT * FROM t1;
+ALTER TABLE t1 CHANGE c1 c1 SERIAL;
+SELECT * FROM t1;
+INSERT INTO t1 VALUES(NULL, 3);
+INSERT INTO t1 VALUES(NULL, 4);
+SELECT * FROM t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c1 FLOAT NOT NULL AUTO_INCREMENT, c2 INT, PRIMARY KEY (c1)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES(NULL, 1);
+INSERT INTO t1 VALUES(NULL, 2);
+SELECT * FROM t1;
+ALTER TABLE t1 CHANGE c1 c1 SERIAL;
+SELECT * FROM t1;
+INSERT INTO t1 VALUES(NULL, 3);
+INSERT INTO t1 VALUES(NULL, 4);
SELECT * FROM t1;
DROP TABLE t1;
+
+#
+# Bug# 42714: AUTOINC column calculated next value not greater than highest
+# value stored in table.
+#
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=5;
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+CREATE TABLE t1 (
+ a INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
+ b INT(10) UNSIGNED NOT NULL,
+ c ENUM('FALSE','TRUE') DEFAULT NULL,
+ PRIMARY KEY (a)) ENGINE = InnoDB;
+CREATE TABLE t2 (
+ m INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
+ n INT(10) UNSIGNED NOT NULL,
+ o enum('FALSE','TRUE') DEFAULT NULL,
+ PRIMARY KEY (m)) ENGINE = InnoDB;
+INSERT INTO t2 (n,o) VALUES
+ (1 , 'true'), (1 , 'false'), (2 , 'true'), (2 , 'false'), (3 , 'true'),
+ (3 , 'false'), (4 , 'true'), (4 , 'false'), (5 , 'true'), (5 , 'false');
+SHOW CREATE TABLE t2;
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 ;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 ;
+SELECT * FROM t1;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
+SELECT * FROM t1;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
+SELECT * FROM t1;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
+SHOW CREATE TABLE t1;
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
+SHOW CREATE TABLE t1;
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
+SELECT * FROM t1;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+DROP TABLE t2;
+#
+# 43203: Overflow from auto incrementing causes server segv
+#
+
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+CREATE TABLE t1(
+ c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT
+ PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
+CREATE TABLE t2(
+ c1 TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT
+ PRIMARY KEY) ENGINE=InnoDB;
+-- error ER_DUP_ENTRY,1062
+INSERT INTO t2 SELECT c1 FROM t1;
+-- error ER_DUP_ENTRY,1467
+INSERT INTO t2 SELECT NULL FROM t1;
+DROP TABLE t1;
+DROP TABLE t2;
diff --git a/mysql-test/innodb-semi-consistent-master.opt b/mysql-test/innodb-semi-consistent-master.opt
index 2746e4e184e..e76299453d3 100644
--- a/mysql-test/innodb-semi-consistent-master.opt
+++ b/mysql-test/innodb-semi-consistent-master.opt
@@ -1 +1 @@
---innodb_locks_unsafe_for_binlog=true --innodb_lock_wait_timeout=2
+--innodb_lock_wait_timeout=2
diff --git a/mysql-test/innodb-semi-consistent.result b/mysql-test/innodb-semi-consistent.result
index 6173048c320..55e3cb5c7b4 100644
--- a/mysql-test/innodb-semi-consistent.result
+++ b/mysql-test/innodb-semi-consistent.result
@@ -1,6 +1,6 @@
drop table if exists t1;
set binlog_format=mixed;
-set session transaction isolation level read committed;
+set session transaction isolation level repeatable read;
create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
insert into t1 values (1),(2),(3),(4),(5),(6),(7);
set autocommit=0;
@@ -8,11 +8,12 @@ select * from t1 where a=3 lock in share mode;
a
3
set binlog_format=mixed;
-set session transaction isolation level read committed;
+set session transaction isolation level repeatable read;
set autocommit=0;
update t1 set a=10 where a=5;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
commit;
+set session transaction isolation level read committed;
update t1 set a=10 where a=5;
select * from t1 where a=2 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
diff --git a/mysql-test/innodb-semi-consistent.test b/mysql-test/innodb-semi-consistent.test
index a3496625e95..6d3020bb560 100644
--- a/mysql-test/innodb-semi-consistent.test
+++ b/mysql-test/innodb-semi-consistent.test
@@ -11,7 +11,7 @@ connect (a,localhost,root,,);
connect (b,localhost,root,,);
connection a;
set binlog_format=mixed;
-set session transaction isolation level read committed;
+set session transaction isolation level repeatable read;
create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
insert into t1 values (1),(2),(3),(4),(5),(6),(7);
set autocommit=0;
@@ -19,13 +19,15 @@ set autocommit=0;
select * from t1 where a=3 lock in share mode;
connection b;
set binlog_format=mixed;
-set session transaction isolation level read committed;
+set session transaction isolation level repeatable read;
set autocommit=0;
-- error ER_LOCK_WAIT_TIMEOUT
update t1 set a=10 where a=5;
connection a;
commit;
connection b;
+# perform a semi-consisent read (and unlock non-matching rows)
+set session transaction isolation level read committed;
update t1 set a=10 where a=5;
connection a;
-- error ER_LOCK_WAIT_TIMEOUT
@@ -33,6 +35,7 @@ select * from t1 where a=2 for update;
# this should lock the records (1),(2)
select * from t1 where a=2 limit 1 for update;
connection b;
+# semi-consistent read will skip non-matching locked rows a=1, a=2
update t1 set a=11 where a=6;
-- error ER_LOCK_WAIT_TIMEOUT
update t1 set a=12 where a=2;
diff --git a/mysql-test/innodb-use-sys-malloc-master.opt b/mysql-test/innodb-use-sys-malloc-master.opt
new file mode 100644
index 00000000000..889834add01
--- /dev/null
+++ b/mysql-test/innodb-use-sys-malloc-master.opt
@@ -0,0 +1,2 @@
+--innodb-use-sys-malloc=true
+--innodb-use-sys-malloc=true
diff --git a/mysql-test/innodb-use-sys-malloc.result b/mysql-test/innodb-use-sys-malloc.result
new file mode 100644
index 00000000000..2ec4c7c8130
--- /dev/null
+++ b/mysql-test/innodb-use-sys-malloc.result
@@ -0,0 +1,48 @@
+SELECT @@GLOBAL.innodb_use_sys_malloc;
+@@GLOBAL.innodb_use_sys_malloc
+1
+1 Expected
+SET @@GLOBAL.innodb_use_sys_malloc=0;
+ERROR HY000: Variable 'innodb_use_sys_malloc' is a read only variable
+Expected error 'Read only variable'
+SELECT @@GLOBAL.innodb_use_sys_malloc;
+@@GLOBAL.innodb_use_sys_malloc
+1
+1 Expected
+drop table if exists t1;
+create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
+insert into t1 values (1),(2),(3),(4),(5),(6),(7);
+select * from t1;
+a
+1
+2
+3
+4
+5
+6
+7
+drop table t1;
+SELECT @@GLOBAL.innodb_use_sys_malloc;
+@@GLOBAL.innodb_use_sys_malloc
+1
+1 Expected
+SET @@GLOBAL.innodb_use_sys_malloc=0;
+ERROR HY000: Variable 'innodb_use_sys_malloc' is a read only variable
+Expected error 'Read only variable'
+SELECT @@GLOBAL.innodb_use_sys_malloc;
+@@GLOBAL.innodb_use_sys_malloc
+1
+1 Expected
+drop table if exists t1;
+create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
+insert into t1 values (1),(2),(3),(4),(5),(6),(7);
+select * from t1;
+a
+1
+2
+3
+4
+5
+6
+7
+drop table t1;
diff --git a/mysql-test/innodb-use-sys-malloc.test b/mysql-test/innodb-use-sys-malloc.test
new file mode 100644
index 00000000000..325dd19d086
--- /dev/null
+++ b/mysql-test/innodb-use-sys-malloc.test
@@ -0,0 +1,48 @@
+--source include/have_innodb.inc
+
+#display current value of innodb_use_sys_malloc
+SELECT @@GLOBAL.innodb_use_sys_malloc;
+--echo 1 Expected
+
+#try changing it. Should fail.
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+SET @@GLOBAL.innodb_use_sys_malloc=0;
+--echo Expected error 'Read only variable'
+
+SELECT @@GLOBAL.innodb_use_sys_malloc;
+--echo 1 Expected
+
+
+#do some stuff to see if it works.
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
+insert into t1 values (1),(2),(3),(4),(5),(6),(7);
+select * from t1;
+drop table t1;
+--source include/have_innodb.inc
+
+#display current value of innodb_use_sys_malloc
+SELECT @@GLOBAL.innodb_use_sys_malloc;
+--echo 1 Expected
+
+#try changing it. Should fail.
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+SET @@GLOBAL.innodb_use_sys_malloc=0;
+--echo Expected error 'Read only variable'
+
+SELECT @@GLOBAL.innodb_use_sys_malloc;
+--echo 1 Expected
+
+
+#do some stuff to see if it works.
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
+insert into t1 values (1),(2),(3),(4),(5),(6),(7);
+select * from t1;
+drop table t1;
diff --git a/mysql-test/innodb-zip.result b/mysql-test/innodb-zip.result
index ccbfb2b7c37..c81401743a5 100644
--- a/mysql-test/innodb-zip.result
+++ b/mysql-test/innodb-zip.result
@@ -122,7 +122,7 @@ table_schema table_name row_format
test t1 Compressed
test t2 Compact
drop table t1,t2;
-SET SESSION innodb_strict_mode = on;
+SET SESSION innodb_strict_mode = off;
CREATE TABLE t1(
c TEXT NOT NULL, d TEXT NOT NULL,
PRIMARY KEY (c(767),d(767)))
diff --git a/mysql-test/innodb-zip.test b/mysql-test/innodb-zip.test
index faa21b6e7b1..ddc39d44487 100644
--- a/mysql-test/innodb-zip.test
+++ b/mysql-test/innodb-zip.test
@@ -2,6 +2,7 @@
let $per_table=`select @@innodb_file_per_table`;
let $format=`select @@innodb_file_format`;
+let $innodb_file_format_check_orig=`select @@innodb_file_format_check`;
set global innodb_file_per_table=off;
set global innodb_file_format=`0`;
@@ -84,7 +85,8 @@ SELECT table_schema, table_name, row_format
FROM information_schema.tables WHERE engine='innodb';
drop table t1,t2;
-SET SESSION innodb_strict_mode = on;
+# The following should fail even in non-strict mode.
+SET SESSION innodb_strict_mode = off;
--error ER_TOO_BIG_ROWSIZE
CREATE TABLE t1(
c TEXT NOT NULL, d TEXT NOT NULL,
@@ -156,7 +158,8 @@ set global innodb_file_format=`1a`;
set global innodb_file_format=``;
#test strict mode.
---enable_errors
+# this does not work anymore, has been removed from mysqltest
+# -- enable_errors
set global innodb_file_per_table = on;
set global innodb_file_format = `1`;
@@ -329,3 +332,12 @@ show table status;
select @@innodb_file_format_check;
drop table normal_table, zip_table;
-- disable_result_log
+
+#
+# restore environment to the state it was before this test execution
+#
+
+-- disable_query_log
+eval set global innodb_file_format=$format;
+eval set global innodb_file_per_table=$per_table;
+eval set global innodb_file_format_check=$innodb_file_format_check_orig;
diff --git a/mysql-test/innodb.result b/mysql-test/innodb.result
index d84878cac21..385084fb457 100644
--- a/mysql-test/innodb.result
+++ b/mysql-test/innodb.result
@@ -1783,7 +1783,7 @@ Variable_name Value
innodb_sync_spin_loops 20
show variables like "innodb_thread_concurrency";
Variable_name Value
-innodb_thread_concurrency 8
+innodb_thread_concurrency 0
set global innodb_thread_concurrency=1001;
Warnings:
Warning 1292 Truncated incorrect thread_concurrency value: '1001'
diff --git a/mysql-test/innodb_bug34300.test b/mysql-test/innodb_bug34300.test
index 4b4a3fdc8a3..114bcf98c25 100644
--- a/mysql-test/innodb_bug34300.test
+++ b/mysql-test/innodb_bug34300.test
@@ -8,7 +8,9 @@
-- disable_query_log
-- disable_result_log
-SET @@max_allowed_packet=16777216;
+# set packet size and reconnect
+SET @@global.max_allowed_packet=16777216;
+--connect (newconn, localhost, root,,)
DROP TABLE IF EXISTS bug34300;
CREATE TABLE bug34300 (
diff --git a/mysql-test/innodb_bug36169.test b/mysql-test/innodb_bug36169.test
index e7375900675..d3566d3eb39 100644
--- a/mysql-test/innodb_bug36169.test
+++ b/mysql-test/innodb_bug36169.test
@@ -22,6 +22,7 @@ SET GLOBAL innodb_file_per_table=ON;
# Generating 10 tables
# Creating a table with 94 columns and 24 indexes
DROP TABLE IF EXISTS `table0`;
+--error ER_TOO_BIG_ROWSIZE
CREATE TABLE IF NOT EXISTS `table0`
(`col0` BOOL,
`col1` BOOL,
@@ -145,6 +146,7 @@ KEY `idx23` (`col7`(163),`col31`,`col71`,`col14`)
# Creating a table with 10 columns and 32 indexes
DROP TABLE IF EXISTS `table1`;
+--error ER_TOO_BIG_ROWSIZE
CREATE TABLE IF NOT EXISTS `table1`
(`col0` CHAR (113),
`col1` FLOAT,
@@ -192,6 +194,7 @@ KEY `idx31` (`col4`(1),`col0`)
# Creating a table with 141 columns and 18 indexes
DROP TABLE IF EXISTS `table2`;
+--error ER_TOO_BIG_ROWSIZE
CREATE TABLE IF NOT EXISTS `table2`
(`col0` BOOL,
`col1` MEDIUMINT,
@@ -356,6 +359,7 @@ KEY `idx17` (`col24`(250),`col7`,`col92`,`col45`)
# Creating a table with 199 columns and 1 indexes
DROP TABLE IF EXISTS `table3`;
+--error ER_TOO_BIG_ROWSIZE
CREATE TABLE IF NOT EXISTS `table3`
(`col0` SMALLINT,
`col1` SET ('test1','test2','test3'),
@@ -561,6 +565,7 @@ KEY `idx0` (`col39`,`col23`)
# Creating a table with 133 columns and 16 indexes
DROP TABLE IF EXISTS `table4`;
+--error ER_TOO_BIG_ROWSIZE
CREATE TABLE IF NOT EXISTS `table4`
(`col0` VARCHAR (60),
`col1` NUMERIC,
@@ -715,6 +720,7 @@ KEY `idx15` (`col4`(246),`col130`,`col115`,`col3`(141))
# Creating a table with 176 columns and 13 indexes
DROP TABLE IF EXISTS `table5`;
+--error ER_TOO_BIG_ROWSIZE
CREATE TABLE IF NOT EXISTS `table5`
(`col0` MEDIUMTEXT,
`col1` VARCHAR (90),
@@ -910,6 +916,7 @@ KEY `idx12` (`col24`)
# Creating a table with 179 columns and 46 indexes
DROP TABLE IF EXISTS `table6`;
-- error ER_TOO_BIG_ROWSIZE
+--error ER_TOO_BIG_ROWSIZE
CREATE TABLE IF NOT EXISTS `table6`
(`col0` ENUM ('test1','test2','test3'),
`col1` MEDIUMBLOB,
diff --git a/mysql-test/innodb_bug41904.result b/mysql-test/innodb_bug41904.result
new file mode 100644
index 00000000000..6070d32d181
--- /dev/null
+++ b/mysql-test/innodb_bug41904.result
@@ -0,0 +1,4 @@
+CREATE TABLE bug41904 (id INT PRIMARY KEY, uniquecol CHAR(15)) ENGINE=InnoDB;
+INSERT INTO bug41904 VALUES (1,NULL), (2,NULL);
+CREATE UNIQUE INDEX ui ON bug41904 (uniquecol);
+DROP TABLE bug41904;
diff --git a/mysql-test/innodb_bug41904.test b/mysql-test/innodb_bug41904.test
new file mode 100644
index 00000000000..365c5229adc
--- /dev/null
+++ b/mysql-test/innodb_bug41904.test
@@ -0,0 +1,14 @@
+#
+# Make sure http://bugs.mysql.com/41904 remains fixed.
+#
+
+-- source include/not_embedded.inc
+-- source include/have_innodb.inc
+
+CREATE TABLE bug41904 (id INT PRIMARY KEY, uniquecol CHAR(15)) ENGINE=InnoDB;
+
+INSERT INTO bug41904 VALUES (1,NULL), (2,NULL);
+
+CREATE UNIQUE INDEX ui ON bug41904 (uniquecol);
+
+DROP TABLE bug41904;
diff --git a/mysql-test/innodb_xtradb_bug317074.result b/mysql-test/innodb_xtradb_bug317074.result
new file mode 100644
index 00000000000..aa80e4d7aa4
--- /dev/null
+++ b/mysql-test/innodb_xtradb_bug317074.result
@@ -0,0 +1,2 @@
+SET GLOBAL innodb_file_format='Barracuda';
+SET GLOBAL innodb_file_per_table=ON;
diff --git a/mysql-test/innodb_xtradb_bug317074.test b/mysql-test/innodb_xtradb_bug317074.test
new file mode 100644
index 00000000000..d5abb7a1670
--- /dev/null
+++ b/mysql-test/innodb_xtradb_bug317074.test
@@ -0,0 +1,38 @@
+-- source include/have_innodb.inc
+
+SET GLOBAL innodb_file_format='Barracuda';
+SET GLOBAL innodb_file_per_table=ON;
+
+-- disable_query_log
+-- disable_result_log
+
+DROP TABLE IF EXISTS `test1`;
+CREATE TABLE IF NOT EXISTS `test1` (
+ `a` int primary key auto_increment,
+ `b` int default 0,
+ `c` char(100) default 'testtest'
+) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
+
+delimiter |;
+CREATE PROCEDURE insert_many(p1 int)
+BEGIN
+SET @x = 0;
+SET @y = 0;
+REPEAT
+ insert into test1 set b=1;
+ SET @x = @x + 1;
+ SET @y = @y + 1;
+ IF @y >= 100 THEN
+ commit;
+ SET @y = 0;
+ END IF;
+UNTIL @x >= p1 END REPEAT;
+END|
+delimiter ;|
+call insert_many(100000);
+DROP PROCEDURE insert_many;
+
+# The bug is hangup at the following statement
+ALTER TABLE test1 ENGINE=MyISAM;
+
+DROP TABLE test1;
diff --git a/mysql-test/patches/bug35261.diff b/mysql-test/patches/bug35261.diff
deleted file mode 100644
index 4b849776e8d..00000000000
--- a/mysql-test/patches/bug35261.diff
+++ /dev/null
@@ -1,85 +0,0 @@
---- mysql-test/t/date_formats.test.orig 2007-06-15 02:53:07.000000000 +0300
-+++ mysql-test/t/date_formats.test 2008-03-19 17:25:10.000000000 +0200
-@@ -7,9 +7,15 @@
- --enable_warnings
-
- --replace_result ROW <format> STATEMENT <format> MIXED <format>
--SHOW GLOBAL VARIABLES LIKE "%e_format";
-+SELECT variable_name, variable_value
-+FROM information_schema.global_variables
-+WHERE variable_name IN ('date_format', 'datetime_format', 'time_format')
-+ORDER BY variable_name;
- --replace_result ROW <format> STATEMENT <format> MIXED <format>
--SHOW SESSION VARIABLES LIKE "%e_format";
-+SELECT variable_name, variable_value
-+FROM information_schema.session_variables
-+WHERE variable_name IN ('date_format', 'datetime_format', 'time_format')
-+ORDER BY variable_name;
-
- #
- # Test setting a lot of different formats to see which formats are accepted and
-@@ -37,7 +43,10 @@
- set datetime_format= '%h:%i:%s.%f %p %Y-%m-%d';
-
- --replace_result ROW <format> STATEMENT <format> MIXED <format>
--SHOW SESSION VARIABLES LIKE "%e_format";
-+SELECT variable_name, variable_value
-+FROM information_schema.session_variables
-+WHERE variable_name IN ('date_format', 'datetime_format', 'time_format')
-+ORDER BY variable_name;
-
- --error 1231
- SET time_format='%h:%i:%s';
---- mysql-test/r/date_formats.result.orig 2008-02-12 21:09:14.000000000 +0200
-+++ mysql-test/r/date_formats.result 2008-03-19 17:26:33.000000000 +0200
-@@ -1,14 +1,20 @@
- drop table if exists t1;
--SHOW GLOBAL VARIABLES LIKE "%e_format";
--Variable_name Value
--date_format %d.%m.%Y
--datetime_format %Y-%m-%d %H:%i:%s
--time_format %H.%i.%s
--SHOW SESSION VARIABLES LIKE "%e_format";
--Variable_name Value
--date_format %d.%m.%Y
--datetime_format %Y-%m-%d %H:%i:%s
--time_format %H.%i.%s
-+SELECT variable_name, variable_value
-+FROM information_schema.global_variables
-+WHERE variable_name IN ('date_format', 'datetime_format', 'time_format')
-+ORDER BY variable_name;
-+variable_name variable_value
-+DATETIME_FORMAT %Y-%m-%d %H:%i:%s
-+DATE_FORMAT %d.%m.%Y
-+TIME_FORMAT %H.%i.%s
-+SELECT variable_name, variable_value
-+FROM information_schema.session_variables
-+WHERE variable_name IN ('date_format', 'datetime_format', 'time_format')
-+ORDER BY variable_name;
-+variable_name variable_value
-+DATETIME_FORMAT %Y-%m-%d %H:%i:%s
-+DATE_FORMAT %d.%m.%Y
-+TIME_FORMAT %H.%i.%s
- SET time_format='%H%i%s';
- SET time_format='%H:%i:%s.%f';
- SET time_format='%h-%i-%s.%f%p';
-@@ -26,11 +32,14 @@
- set datetime_format= '%H:%i:%s.%f %m-%d-%Y';
- set datetime_format= '%h:%i:%s %p %Y-%m-%d';
- set datetime_format= '%h:%i:%s.%f %p %Y-%m-%d';
--SHOW SESSION VARIABLES LIKE "%e_format";
--Variable_name Value
--date_format %m-%d-%Y
--datetime_format %h:%i:%s.%f %p %Y-%m-%d
--time_format %h:%i:%s%p
-+SELECT variable_name, variable_value
-+FROM information_schema.session_variables
-+WHERE variable_name IN ('date_format', 'datetime_format', 'time_format')
-+ORDER BY variable_name;
-+variable_name variable_value
-+DATETIME_FORMAT %h:%i:%s.%f %p %Y-%m-%d
-+DATE_FORMAT %m-%d-%Y
-+TIME_FORMAT %h:%i:%s%p
- SET time_format='%h:%i:%s';
- ERROR 42000: Variable 'time_format' can't be set to the value of '%h:%i:%s'
- SET time_format='%H %i:%s';
diff --git a/mysql-test/patches/bug41893.diff b/mysql-test/patches/bug41893.diff
new file mode 100644
index 00000000000..f42f4ae71cb
--- /dev/null
+++ b/mysql-test/patches/bug41893.diff
@@ -0,0 +1,87 @@
+=== modified file 'mysql-test/r/variables.result'
+--- mysql-test/r/variables.result 2008-11-27 10:50:28 +0000
++++ mysql-test/r/variables.result 2009-01-06 07:33:27 +0000
+@@ -297,14 +297,14 @@
+ select ROUND(RAND(),5);
+ ROUND(RAND(),5)
+ 0.02887
+-show variables like '%alloc%';
++show variables where variable_name in ('query_alloc_block_size', 'query_prealloc_size', 'range_alloc_block_size', 'transaction_alloc_block_size', 'transaction_prealloc_size');
+ Variable_name Value
+ query_alloc_block_size 8192
+ query_prealloc_size 8192
+ range_alloc_block_size 4096
+ transaction_alloc_block_size 8192
+ transaction_prealloc_size 4096
+-select * from information_schema.session_variables where variable_name like '%alloc%' order by 1;
++select * from information_schema.session_variables where variable_name in ('query_alloc_block_size', 'query_prealloc_size', 'range_alloc_block_size', 'transaction_alloc_block_size', 'transaction_prealloc_size') order by 1;
+ VARIABLE_NAME VARIABLE_VALUE
+ QUERY_ALLOC_BLOCK_SIZE 8192
+ QUERY_PREALLOC_SIZE 8192
+@@ -319,14 +319,14 @@
+ select @@query_alloc_block_size;
+ @@query_alloc_block_size
+ 17408
+-show variables like '%alloc%';
++show variables where variable_name in ('query_alloc_block_size', 'query_prealloc_size', 'range_alloc_block_size', 'transaction_alloc_block_size', 'transaction_prealloc_size');
+ Variable_name Value
+ query_alloc_block_size 17408
+ query_prealloc_size 18432
+ range_alloc_block_size 16384
+ transaction_alloc_block_size 19456
+ transaction_prealloc_size 20480
+-select * from information_schema.session_variables where variable_name like '%alloc%' order by 1;
++select * from information_schema.session_variables where variable_name in ('query_alloc_block_size', 'query_prealloc_size', 'range_alloc_block_size', 'transaction_alloc_block_size', 'transaction_prealloc_size') order by 1;
+ VARIABLE_NAME VARIABLE_VALUE
+ QUERY_ALLOC_BLOCK_SIZE 17408
+ QUERY_PREALLOC_SIZE 18432
+@@ -336,14 +336,14 @@
+ set @@range_alloc_block_size=default;
+ set @@query_alloc_block_size=default, @@query_prealloc_size=default;
+ set transaction_alloc_block_size=default, @@transaction_prealloc_size=default;
+-show variables like '%alloc%';
++show variables where variable_name in ('query_alloc_block_size', 'query_prealloc_size', 'range_alloc_block_size', 'transaction_alloc_block_size', 'transaction_prealloc_size');
+ Variable_name Value
+ query_alloc_block_size 8192
+ query_prealloc_size 8192
+ range_alloc_block_size 4096
+ transaction_alloc_block_size 8192
+ transaction_prealloc_size 4096
+-select * from information_schema.session_variables where variable_name like '%alloc%' order by 1;
++select * from information_schema.session_variables where variable_name in ('query_alloc_block_size', 'query_prealloc_size', 'range_alloc_block_size', 'transaction_alloc_block_size', 'transaction_prealloc_size') order by 1;
+ VARIABLE_NAME VARIABLE_VALUE
+ QUERY_ALLOC_BLOCK_SIZE 8192
+ QUERY_PREALLOC_SIZE 8192
+
+=== modified file 'mysql-test/t/variables.test'
+--- mysql-test/t/variables.test 2008-11-27 10:50:28 +0000
++++ mysql-test/t/variables.test 2009-01-06 07:28:12 +0000
+@@ -172,21 +172,21 @@
+ set @@rand_seed1=10000000,@@rand_seed2=1000000;
+ select ROUND(RAND(),5);
+
+-show variables like '%alloc%';
+-select * from information_schema.session_variables where variable_name like '%alloc%' order by 1;
++show variables where variable_name in ('query_alloc_block_size', 'query_prealloc_size', 'range_alloc_block_size', 'transaction_alloc_block_size', 'transaction_prealloc_size');
++select * from information_schema.session_variables where variable_name in ('query_alloc_block_size', 'query_prealloc_size', 'range_alloc_block_size', 'transaction_alloc_block_size', 'transaction_prealloc_size') order by 1;
+ set @@range_alloc_block_size=1024*16;
+ set @@query_alloc_block_size=1024*17+2;
+ set @@query_prealloc_size=1024*18;
+ set @@transaction_alloc_block_size=1024*20-1;
+ set @@transaction_prealloc_size=1024*21-1;
+ select @@query_alloc_block_size;
+-show variables like '%alloc%';
+-select * from information_schema.session_variables where variable_name like '%alloc%' order by 1;
++show variables where variable_name in ('query_alloc_block_size', 'query_prealloc_size', 'range_alloc_block_size', 'transaction_alloc_block_size', 'transaction_prealloc_size');
++select * from information_schema.session_variables where variable_name in ('query_alloc_block_size', 'query_prealloc_size', 'range_alloc_block_size', 'transaction_alloc_block_size', 'transaction_prealloc_size') order by 1;
+ set @@range_alloc_block_size=default;
+ set @@query_alloc_block_size=default, @@query_prealloc_size=default;
+ set transaction_alloc_block_size=default, @@transaction_prealloc_size=default;
+-show variables like '%alloc%';
+-select * from information_schema.session_variables where variable_name like '%alloc%' order by 1;
++show variables where variable_name in ('query_alloc_block_size', 'query_prealloc_size', 'range_alloc_block_size', 'transaction_alloc_block_size', 'transaction_prealloc_size');
++select * from information_schema.session_variables where variable_name in ('query_alloc_block_size', 'query_prealloc_size', 'range_alloc_block_size', 'transaction_alloc_block_size', 'transaction_prealloc_size') order by 1;
+
+ #
+ # Bug #10904 Illegal mix of collations between
+
diff --git a/mysql-test/patches/information_schema.diff b/mysql-test/patches/information_schema.diff
index 002b7d91bd0..a3a21f7a08d 100644
--- a/mysql-test/patches/information_schema.diff
+++ b/mysql-test/patches/information_schema.diff
@@ -1,26 +1,20 @@
-diff mysql-test/r/information_schema.result.orig mysql-test/r/information_schema.result
---- mysql-test/r/information_schema.result.orig 2008-08-04 09:27:49.000000000 +0300
-+++ mysql-test/r/information_schema.result 2008-10-07 11:21:51.000000000 +0300
-@@ -64,6 +64,18 @@
+--- mysql-test/r/information_schema.result.orig 2009-01-31 03:38:50.000000000 +0200
++++ mysql-test/r/information_schema.result 2009-01-31 07:51:58.000000000 +0200
+@@ -71,6 +71,13 @@
TRIGGERS
USER_PRIVILEGES
VIEWS
-+INNODB_BUFFER_POOL_PAGES_INDEX
-+INNODB_RSEG
-+INNODB_LOCKS
-+INNODB_BUFFER_POOL_PAGES
-+XTRADB_ENHANCEMENTS
-+INNODB_TRX
-+INNODB_BUFFER_POOL_PAGES_BLOB
-+INNODB_LOCK_WAITS
+INNODB_CMP_RESET
-+INNODB_CMP
++INNODB_TRX
+INNODB_CMPMEM_RESET
++INNODB_LOCK_WAITS
+INNODB_CMPMEM
++INNODB_CMP
++INNODB_LOCKS
columns_priv
db
event
-@@ -795,6 +807,8 @@
+@@ -799,6 +806,8 @@
TABLES UPDATE_TIME datetime
TABLES CHECK_TIME datetime
TRIGGERS CREATED datetime
@@ -29,155 +23,102 @@ diff mysql-test/r/information_schema.result.orig mysql-test/r/information_schema
event execute_at datetime
event last_executed datetime
event starts datetime
-@@ -843,12 +857,13 @@
- TABLE_CONSTRAINTS TABLE_NAME select
- TABLE_PRIVILEGES TABLE_NAME select
- VIEWS TABLE_NAME select
-+INNODB_BUFFER_POOL_PAGES_INDEX table_name select
- delete from mysql.user where user='mysqltest_4';
- delete from mysql.db where user='mysqltest_4';
+@@ -852,7 +861,7 @@
flush privileges;
- SELECT table_schema, count(*) FROM information_schema.TABLES where table_name<>'ndb_binlog_index' AND table_name<>'ndb_apply_status' GROUP BY TABLE_SCHEMA;
+ SELECT table_schema, count(*) FROM information_schema.TABLES WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test', 'mysqltest') AND table_name<>'ndb_binlog_index' AND table_name<>'ndb_apply_status' GROUP BY TABLE_SCHEMA;
table_schema count(*)
-information_schema 28
-+information_schema 40
++information_schema 35
mysql 22
create table t1 (i int, j int);
create trigger trg1 before insert on t1 for each row
-@@ -1263,6 +1278,18 @@
+@@ -1267,6 +1276,13 @@
TRIGGERS TRIGGER_SCHEMA
USER_PRIVILEGES GRANTEE
VIEWS TABLE_SCHEMA
-+INNODB_BUFFER_POOL_PAGES_INDEX schema_name
-+INNODB_RSEG rseg_id
-+INNODB_LOCKS lock_id
-+INNODB_BUFFER_POOL_PAGES page_type
-+XTRADB_ENHANCEMENTS name
-+INNODB_TRX trx_id
-+INNODB_BUFFER_POOL_PAGES_BLOB space_id
-+INNODB_LOCK_WAITS requesting_trx_id
+INNODB_CMP_RESET page_size
-+INNODB_CMP page_size
++INNODB_TRX trx_id
+INNODB_CMPMEM_RESET page_size
++INNODB_LOCK_WAITS requesting_trx_id
+INNODB_CMPMEM page_size
++INNODB_CMP page_size
++INNODB_LOCKS lock_id
SELECT t.table_name, c1.column_name
FROM information_schema.tables t
INNER JOIN
-@@ -1306,14 +1333,26 @@
+@@ -1310,6 +1326,13 @@
TRIGGERS TRIGGER_SCHEMA
USER_PRIVILEGES GRANTEE
VIEWS TABLE_SCHEMA
-+INNODB_BUFFER_POOL_PAGES_INDEX schema_name
-+INNODB_RSEG rseg_id
-+INNODB_LOCKS lock_id
-+INNODB_BUFFER_POOL_PAGES page_type
-+XTRADB_ENHANCEMENTS name
-+INNODB_TRX trx_id
-+INNODB_BUFFER_POOL_PAGES_BLOB space_id
-+INNODB_LOCK_WAITS requesting_trx_id
+INNODB_CMP_RESET page_size
-+INNODB_CMP page_size
++INNODB_TRX trx_id
+INNODB_CMPMEM_RESET page_size
++INNODB_LOCK_WAITS requesting_trx_id
+INNODB_CMPMEM page_size
- SELECT MAX(table_name) FROM information_schema.tables;
++INNODB_CMP page_size
++INNODB_LOCKS lock_id
+ SELECT MAX(table_name) FROM information_schema.tables WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test');
MAX(table_name)
--VIEWS
-+XTRADB_ENHANCEMENTS
- SELECT table_name from information_schema.tables
- WHERE table_name=(SELECT MAX(table_name)
- FROM information_schema.tables);
- table_name
--VIEWS
-+XTRADB_ENHANCEMENTS
- DROP TABLE IF EXISTS bug23037;
- DROP FUNCTION IF EXISTS get_value;
- SELECT COLUMN_NAME, MD5(COLUMN_DEFAULT), LENGTH(COLUMN_DEFAULT) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='bug23037';
-@@ -1382,6 +1421,17 @@
+ VIEWS
+@@ -1386,6 +1409,13 @@
FILES information_schema.FILES 1
GLOBAL_STATUS information_schema.GLOBAL_STATUS 1
GLOBAL_VARIABLES information_schema.GLOBAL_VARIABLES 1
-+INNODB_BUFFER_POOL_PAGES information_schema.INNODB_BUFFER_POOL_PAGES 1
-+INNODB_BUFFER_POOL_PAGES_BLOB information_schema.INNODB_BUFFER_POOL_PAGES_BLOB 1
-+INNODB_BUFFER_POOL_PAGES_INDEX information_schema.INNODB_BUFFER_POOL_PAGES_INDEX 1
+INNODB_CMP information_schema.INNODB_CMP 1
+INNODB_CMPMEM information_schema.INNODB_CMPMEM 1
+INNODB_CMPMEM_RESET information_schema.INNODB_CMPMEM_RESET 1
+INNODB_CMP_RESET information_schema.INNODB_CMP_RESET 1
+INNODB_LOCKS information_schema.INNODB_LOCKS 1
+INNODB_LOCK_WAITS information_schema.INNODB_LOCK_WAITS 1
-+INNODB_RSEG information_schema.INNODB_RSEG 1
+INNODB_TRX information_schema.INNODB_TRX 1
KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
PARTITIONS information_schema.PARTITIONS 1
PLUGINS information_schema.PLUGINS 1
-@@ -1400,6 +1450,7 @@
- TRIGGERS information_schema.TRIGGERS 1
- USER_PRIVILEGES information_schema.USER_PRIVILEGES 1
- VIEWS information_schema.VIEWS 1
-+XTRADB_ENHANCEMENTS information_schema.XTRADB_ENHANCEMENTS 1
- create table t1(f1 int);
- create view v1 as select f1+1 as a from t1;
- create table t2 (f1 int, f2 int);
diff mysql-test/r/information_schema_db.result.orig mysql-test/r/information_schema_db.result
--- mysql-test/r/information_schema_db.result.orig 2008-08-04 09:27:49.000000000 +0300
+++ mysql-test/r/information_schema_db.result 2008-10-07 12:26:31.000000000 +0300
-@@ -33,6 +33,18 @@
+@@ -33,6 +33,13 @@
TRIGGERS
USER_PRIVILEGES
VIEWS
-+INNODB_BUFFER_POOL_PAGES_INDEX
-+INNODB_RSEG
-+INNODB_LOCKS
-+INNODB_BUFFER_POOL_PAGES
-+XTRADB_ENHANCEMENTS
-+INNODB_TRX
-+INNODB_BUFFER_POOL_PAGES_BLOB
-+INNODB_LOCK_WAITS
+INNODB_CMP_RESET
-+INNODB_CMP
++INNODB_TRX
+INNODB_CMPMEM_RESET
++INNODB_LOCK_WAITS
+INNODB_CMPMEM
++INNODB_CMP
++INNODB_LOCKS
show tables from INFORMATION_SCHEMA like 'T%';
Tables_in_information_schema (T%)
TABLES
diff mysql-test/r/mysqlshow.result.orig mysql-test/r/mysqlshow.result
--- mysql-test/r/mysqlshow.result.orig 2008-08-04 09:27:51.000000000 +0300
+++ mysql-test/r/mysqlshow.result 2008-10-07 12:35:39.000000000 +0300
-@@ -107,6 +107,18 @@
+@@ -107,6 +107,13 @@
| TRIGGERS |
| USER_PRIVILEGES |
| VIEWS |
-+| INNODB_BUFFER_POOL_PAGES_INDEX |
-+| INNODB_RSEG |
-+| INNODB_LOCKS |
-+| INNODB_BUFFER_POOL_PAGES |
-+| XTRADB_ENHANCEMENTS |
-+| INNODB_TRX |
-+| INNODB_BUFFER_POOL_PAGES_BLOB |
-+| INNODB_LOCK_WAITS |
+| INNODB_CMP_RESET |
-+| INNODB_CMP |
++| INNODB_TRX |
+| INNODB_CMPMEM_RESET |
++| INNODB_LOCK_WAITS |
+| INNODB_CMPMEM |
++| INNODB_CMP |
++| INNODB_LOCKS |
+---------------------------------------+
Database: INFORMATION_SCHEMA
+---------------------------------------+
-@@ -140,6 +152,18 @@
+@@ -140,6 +147,13 @@
| TRIGGERS |
| USER_PRIVILEGES |
| VIEWS |
-+| INNODB_BUFFER_POOL_PAGES_INDEX |
-+| INNODB_RSEG |
-+| INNODB_LOCKS |
-+| INNODB_BUFFER_POOL_PAGES |
-+| XTRADB_ENHANCEMENTS |
-+| INNODB_TRX |
-+| INNODB_BUFFER_POOL_PAGES_BLOB |
-+| INNODB_LOCK_WAITS |
+| INNODB_CMP_RESET |
-+| INNODB_CMP |
++| INNODB_TRX |
+| INNODB_CMPMEM_RESET |
++| INNODB_LOCK_WAITS |
+| INNODB_CMPMEM |
++| INNODB_CMP |
++| INNODB_LOCKS |
+---------------------------------------+
Wildcard: inf_rmation_schema
+--------------------+
diff --git a/mysql-test/patches/innodb_file_per_table.diff b/mysql-test/patches/innodb_file_per_table.diff
deleted file mode 100644
index 73dd7d223e4..00000000000
--- a/mysql-test/patches/innodb_file_per_table.diff
+++ /dev/null
@@ -1,47 +0,0 @@
-diff mysql-test/t/innodb_file_per_table_basic.test.orig mysql-test/t/innodb_file_per_table_basic.test
---- mysql-test/t/innodb_file_per_table_basic.test.orig 2008-10-07 11:32:30.000000000 +0300
-+++ mysql-test/t/innodb_file_per_table_basic.test 2008-10-07 11:52:14.000000000 +0300
-@@ -37,10 +37,6 @@
- # Check if Value can set #
- ####################################################################
-
----error ER_INCORRECT_GLOBAL_LOCAL_VAR
--SET @@GLOBAL.innodb_file_per_table=1;
----echo Expected error 'Read only variable'
--
- SELECT COUNT(@@GLOBAL.innodb_file_per_table);
- --echo 1 Expected
-
-@@ -52,7 +48,7 @@
- # Check if the value in GLOBAL Table matches value in variable #
- #################################################################
-
--SELECT @@GLOBAL.innodb_file_per_table = VARIABLE_VALUE
-+SELECT IF(@@GLOBAL.innodb_file_per_table,'ON','OFF') = VARIABLE_VALUE
- FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
- WHERE VARIABLE_NAME='innodb_file_per_table';
- --echo 1 Expected
-diff mysql-test/t/innodb_file_per_table_basic.result.orig mysql-test/t/innodb_file_per_table_basic.result
---- mysql-test/r/innodb_file_per_table_basic.result.orig 2008-10-07 11:32:02.000000000 +0300
-+++ mysql-test/r/innodb_file_per_table_basic.result 2008-10-07 11:52:47.000000000 +0300
-@@ -4,18 +4,15 @@
- 1
- 1 Expected
- '#---------------------BS_STVARS_028_02----------------------#'
--SET @@GLOBAL.innodb_file_per_table=1;
--ERROR HY000: Variable 'innodb_file_per_table' is a read only variable
--Expected error 'Read only variable'
- SELECT COUNT(@@GLOBAL.innodb_file_per_table);
- COUNT(@@GLOBAL.innodb_file_per_table)
- 1
- 1 Expected
- '#---------------------BS_STVARS_028_03----------------------#'
--SELECT @@GLOBAL.innodb_file_per_table = VARIABLE_VALUE
-+SELECT IF(@@GLOBAL.innodb_file_per_table,'ON','OFF') = VARIABLE_VALUE
- FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
- WHERE VARIABLE_NAME='innodb_file_per_table';
--@@GLOBAL.innodb_file_per_table = VARIABLE_VALUE
-+IF(@@GLOBAL.innodb_file_per_table,'ON','OFF') = VARIABLE_VALUE
- 1
- 1 Expected
- SELECT COUNT(@@GLOBAL.innodb_file_per_table);
diff --git a/mysql-test/patches/innodb_lock_wait_timeout.diff b/mysql-test/patches/innodb_lock_wait_timeout.diff
deleted file mode 100644
index 81fe87f7c0d..00000000000
--- a/mysql-test/patches/innodb_lock_wait_timeout.diff
+++ /dev/null
@@ -1,55 +0,0 @@
---- mysql-test/t/innodb_lock_wait_timeout_basic.test.orig 2008-08-04 09:28:16.000000000 +0300
-+++ mysql-test/t/innodb_lock_wait_timeout_basic.test 2008-10-07 11:14:15.000000000 +0300
-@@ -37,10 +37,6 @@
- # Check if Value can set #
- ####################################################################
-
----error ER_INCORRECT_GLOBAL_LOCAL_VAR
--SET @@GLOBAL.innodb_lock_wait_timeout=1;
----echo Expected error 'Read only variable'
--
- SELECT COUNT(@@GLOBAL.innodb_lock_wait_timeout);
- --echo 1 Expected
-
-@@ -84,13 +80,9 @@
- SELECT COUNT(@@innodb_lock_wait_timeout);
- --echo 1 Expected
-
----Error ER_INCORRECT_GLOBAL_LOCAL_VAR
- SELECT COUNT(@@local.innodb_lock_wait_timeout);
----echo Expected error 'Variable is a GLOBAL variable'
-
----Error ER_INCORRECT_GLOBAL_LOCAL_VAR
- SELECT COUNT(@@SESSION.innodb_lock_wait_timeout);
----echo Expected error 'Variable is a GLOBAL variable'
-
- SELECT COUNT(@@GLOBAL.innodb_lock_wait_timeout);
- --echo 1 Expected
---- mysql-test/r/innodb_lock_wait_timeout_basic.result.orig 2008-08-04 09:27:50.000000000 +0300
-+++ mysql-test/r/innodb_lock_wait_timeout_basic.result 2008-10-07 11:15:14.000000000 +0300
-@@ -4,9 +4,6 @@
- 1
- 1 Expected
- '#---------------------BS_STVARS_032_02----------------------#'
--SET @@GLOBAL.innodb_lock_wait_timeout=1;
--ERROR HY000: Variable 'innodb_lock_wait_timeout' is a read only variable
--Expected error 'Read only variable'
- SELECT COUNT(@@GLOBAL.innodb_lock_wait_timeout);
- COUNT(@@GLOBAL.innodb_lock_wait_timeout)
- 1
-@@ -39,11 +36,11 @@
- 1
- 1 Expected
- SELECT COUNT(@@local.innodb_lock_wait_timeout);
--ERROR HY000: Variable 'innodb_lock_wait_timeout' is a GLOBAL variable
--Expected error 'Variable is a GLOBAL variable'
-+COUNT(@@local.innodb_lock_wait_timeout)
-+1
- SELECT COUNT(@@SESSION.innodb_lock_wait_timeout);
--ERROR HY000: Variable 'innodb_lock_wait_timeout' is a GLOBAL variable
--Expected error 'Variable is a GLOBAL variable'
-+COUNT(@@SESSION.innodb_lock_wait_timeout)
-+1
- SELECT COUNT(@@GLOBAL.innodb_lock_wait_timeout);
- COUNT(@@GLOBAL.innodb_lock_wait_timeout)
- 1
diff --git a/mysql-test/patches/partition_innodb.diff b/mysql-test/patches/partition_innodb.diff
new file mode 100644
index 00000000000..01bc073008e
--- /dev/null
+++ b/mysql-test/patches/partition_innodb.diff
@@ -0,0 +1,59 @@
+The partition_innodb test only fails if run immediately after innodb_trx_weight.
+The reason for this failure is that innodb_trx_weight creates deadlocks and
+leaves something like this in the SHOW ENGINE INNODB STATUS output:
+
+ ------------------------
+ LATEST DETECTED DEADLOCK
+ ------------------------
+ 090213 10:26:25
+ *** (1) TRANSACTION:
+ TRANSACTION 313, ACTIVE 0 sec, OS thread id 13644672 inserting
+ mysql tables in use 1, locked 1
+ LOCK WAIT 4 lock struct(s), heap size 488, 3 row lock(s)
+ MySQL thread id 3, query id 36 localhost root update
+
+The regular expressions that partition_innodb is using are intended to extract
+the lock structs and row locks numbers from another part of the output:
+
+ ------------
+ TRANSACTIONS
+ ------------
+ Trx id counter 31D
+ Purge done for trx's n:o < 0 undo n:o < 0
+ History list length 4
+ LIST OF TRANSACTIONS FOR EACH SESSION:
+ ---TRANSACTION 0, not started, OS thread id 13645056
+ 0 lock struct(s), heap size 488, 0 row lock(s)
+ MySQL thread id 8, query id 81 localhost root
+
+In the InnoDB Plugin a transaction id is not printed as 2 consecutive
+decimal integers (as it is in InnoDB 5.1) but rather as a single
+hexadecimal integer. Thus the regular expressions somehow pick the wrong
+part of the SHOW ENGINE INNODB STATUS output.
+
+So after the regular expressions are adjusted to the InnoDB Plugin's variant
+of trx_id prinout, then they pick the expected part of the output.
+
+This patch cannot be proposed to MySQL because the failures occur only
+in this tree and do not occur in the standard InnoDB 5.1.
+
+--- mysql-test/t/partition_innodb.test 2008-11-14 22:51:17 +0000
++++ mysql-test/t/partition_innodb.test 2009-02-13 07:36:07 +0000
+@@ -27,14 +27,14 @@
+
+ # grouping/referencing in replace_regex is very slow on long strings,
+ # removing all before/after the interesting row before grouping/referencing
+---replace_regex /.*---TRANSACTION [0-9]+ [0-9]+, .*, OS thread id [0-9]+// /MySQL thread id [0-9]+, query id [0-9]+ .*// /.*([0-9]+ lock struct\(s\)), heap size [0-9]+, ([0-9]+ row lock\(s\)).*/\1 \2/
++--replace_regex /.*---TRANSACTION [0-9A-F]+, .*, OS thread id [0-9]+// /MySQL thread id [0-9]+, query id [0-9]+ .*// /.*([0-9]+ lock struct\(s\)), heap size [0-9]+, ([0-9]+ row lock\(s\)).*/\1 \2/
+ SHOW ENGINE InnoDB STATUS;
+
+ UPDATE t1 SET data = data*2 WHERE data = 2;
+
+ # grouping/referencing in replace_regex is very slow on long strings,
+ # removing all before/after the interesting row before grouping/referencing
+---replace_regex /.*---TRANSACTION [0-9]+ [0-9]+, .*, OS thread id [0-9]+// /MySQL thread id [0-9]+, query id [0-9]+ .*// /.*([0-9]+ lock struct\(s\)), heap size [0-9]+, ([0-9]+ row lock\(s\)).*/\1 \2/
++--replace_regex /.*---TRANSACTION [0-9A-F]+, .*, OS thread id [0-9]+// /MySQL thread id [0-9]+, query id [0-9]+ .*// /.*([0-9]+ lock struct\(s\)), heap size [0-9]+, ([0-9]+ row lock\(s\)).*/\1 \2/
+ SHOW ENGINE InnoDB STATUS;
+
+ SET @@session.tx_isolation = @old_tx_isolation;
+
diff --git a/os/os0file.c b/os/os0file.c
index f297443355b..2d130899622 100644
--- a/os/os0file.c
+++ b/os/os0file.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/******************************************************
The interface to the operating system file i/o primitives
-(c) 1995 Innobase Oy
-
Created 10/21/1995 Heikki Tuuri
*******************************************************/
diff --git a/os/os0proc.c b/os/os0proc.c
index d8eb004da11..8d4a71f8c4e 100644
--- a/os/os0proc.c
+++ b/os/os0proc.c
@@ -1,9 +1,25 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/******************************************************
The interface to the operating system
process control primitives
-(c) 1995 Innobase Oy
-
Created 9/30/1995 Heikki Tuuri
*******************************************************/
@@ -45,28 +61,6 @@ os_proc_get_number(void)
}
/********************************************************************
-Allocates non-cacheable memory. */
-UNIV_INTERN
-void*
-os_mem_alloc_nocache(
-/*=================*/
- /* out: allocated memory */
- ulint n) /* in: number of bytes */
-{
-#ifdef __WIN__
- void* ptr;
-
- ptr = VirtualAlloc(NULL, n, MEM_COMMIT,
- PAGE_READWRITE | PAGE_NOCACHE);
- ut_a(ptr);
-
- return(ptr);
-#else
- return(ut_malloc(n));
-#endif
-}
-
-/********************************************************************
Allocates large pages memory. */
UNIV_INTERN
void*
@@ -111,10 +105,13 @@ os_mem_alloc_large(
if (ptr) {
*n = size;
+ os_fast_mutex_lock(&ut_list_mutex);
ut_total_allocated_memory += size;
+ os_fast_mutex_unlock(&ut_list_mutex);
# ifdef UNIV_SET_MEM_TO_ZERO
memset(ptr, '\0', size);
# endif
+ UNIV_MEM_ALLOC(ptr, size);
return(ptr);
}
@@ -129,8 +126,10 @@ skip:
/* Align block size to system page size */
ut_ad(ut_is_2pow(system_info.dwPageSize));
+ /* system_info.dwPageSize is only 32-bit. Casting to ulint is required
+ on 64-bit Windows. */
size = *n = ut_2pow_round(*n + (system_info.dwPageSize - 1),
- system_info.dwPageSize);
+ (ulint) system_info.dwPageSize);
ptr = VirtualAlloc(NULL, size, MEM_COMMIT | MEM_RESERVE,
PAGE_READWRITE);
if (!ptr) {
@@ -138,7 +137,10 @@ skip:
" Windows error %lu\n",
(ulong) size, (ulong) GetLastError());
} else {
+ os_fast_mutex_lock(&ut_list_mutex);
ut_total_allocated_memory += size;
+ os_fast_mutex_unlock(&ut_list_mutex);
+ UNIV_MEM_ALLOC(ptr, size);
}
#elif defined __NETWARE__ || !defined OS_MAP_ANON
size = *n;
@@ -160,7 +162,10 @@ skip:
(ulong) size, (ulong) errno);
ptr = NULL;
} else {
+ os_fast_mutex_lock(&ut_list_mutex);
ut_total_allocated_memory += size;
+ os_fast_mutex_unlock(&ut_list_mutex);
+ UNIV_MEM_ALLOC(ptr, size);
}
#endif
return(ptr);
@@ -177,11 +182,17 @@ os_mem_free_large(
ulint size) /* in: size returned by
os_mem_alloc_large() */
{
+ os_fast_mutex_lock(&ut_list_mutex);
ut_a(ut_total_allocated_memory >= size);
+ os_fast_mutex_unlock(&ut_list_mutex);
#if defined HAVE_LARGE_PAGES && defined UNIV_LINUX
if (os_use_large_pages && os_large_page_size && !shmdt(ptr)) {
+ os_fast_mutex_lock(&ut_list_mutex);
+ ut_a(ut_total_allocated_memory >= size);
ut_total_allocated_memory -= size;
+ os_fast_mutex_unlock(&ut_list_mutex);
+ UNIV_MEM_FREE(ptr, size);
return;
}
#endif /* HAVE_LARGE_PAGES && UNIV_LINUX */
@@ -193,7 +204,11 @@ os_mem_free_large(
" Windows error %lu\n",
ptr, (ulong) size, (ulong) GetLastError());
} else {
+ os_fast_mutex_lock(&ut_list_mutex);
+ ut_a(ut_total_allocated_memory >= size);
ut_total_allocated_memory -= size;
+ os_fast_mutex_unlock(&ut_list_mutex);
+ UNIV_MEM_FREE(ptr, size);
}
#elif defined __NETWARE__ || !defined OS_MAP_ANON
ut_free(ptr);
@@ -203,7 +218,11 @@ os_mem_free_large(
" errno %lu\n",
ptr, (ulong) size, (ulong) errno);
} else {
+ os_fast_mutex_lock(&ut_list_mutex);
+ ut_a(ut_total_allocated_memory >= size);
ut_total_allocated_memory -= size;
+ os_fast_mutex_unlock(&ut_list_mutex);
+ UNIV_MEM_FREE(ptr, size);
}
#endif
}
diff --git a/os/os0sync.c b/os/os0sync.c
index bd3d5cbdc58..78ff74059f8 100644
--- a/os/os0sync.c
+++ b/os/os0sync.c
@@ -1,9 +1,25 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/******************************************************
The interface to the operating system
synchronization primitives.
-(c) 1995 Innobase Oy
-
Created 9/6/1995 Heikki Tuuri
*******************************************************/
diff --git a/os/os0thread.c b/os/os0thread.c
index 6f7cfd725e6..7d0a57ae17c 100644
--- a/os/os0thread.c
+++ b/os/os0thread.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/******************************************************
The interface to the operating system thread control primitives
-(c) 1995 Innobase Oy
-
Created 9/8/1995 Heikki Tuuri
*******************************************************/
diff --git a/page/page0cur.c b/page/page0cur.c
index 66e02b1529e..e810756c1e4 100644
--- a/page/page0cur.c
+++ b/page/page0cur.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/************************************************************************
The page cursor
-(c) 1994-1996 Innobase Oy
-
Created 10/4/1994 Heikki Tuuri
*************************************************************************/
@@ -12,7 +28,6 @@ Created 10/4/1994 Heikki Tuuri
#endif
#include "page0zip.h"
-#include "rem0cmp.h"
#include "mtr0log.h"
#include "log0recv.h"
#include "rem0cmp.h"
@@ -907,7 +922,7 @@ page_cur_insert_rec_low(
ulint* offsets,/* in/out: rec_get_offsets(rec, index) */
mtr_t* mtr) /* in: mini-transaction handle, or NULL */
{
- byte* insert_buf = NULL;
+ byte* insert_buf;
ulint rec_size;
page_t* page; /* the relevant page */
rec_t* last_insert; /* cursor position at previous
@@ -1172,7 +1187,7 @@ page_cur_insert_rec_zip(
ulint* offsets,/* in/out: rec_get_offsets(rec, index) */
mtr_t* mtr) /* in: mini-transaction handle, or NULL */
{
- byte* insert_buf = NULL;
+ byte* insert_buf;
ulint rec_size;
page_t* page; /* the relevant page */
rec_t* last_insert; /* cursor position at previous
@@ -1285,6 +1300,55 @@ too_small:
rec_get_next_ptr(free_rec, TRUE),
rec_size);
+ if (!page_is_leaf(page)) {
+ /* Zero out the node pointer of free_rec,
+ in case it will not be overwritten by
+ insert_rec. */
+
+ ut_ad(rec_size > REC_NODE_PTR_SIZE);
+
+ if (rec_offs_extra_size(foffsets)
+ + rec_offs_data_size(foffsets) > rec_size) {
+
+ memset(rec_get_end(free_rec, foffsets)
+ - REC_NODE_PTR_SIZE, 0,
+ REC_NODE_PTR_SIZE);
+ }
+ } else if (dict_index_is_clust(index)) {
+ /* Zero out the DB_TRX_ID and DB_ROLL_PTR
+ columns of free_rec, in case it will not be
+ overwritten by insert_rec. */
+
+ ulint trx_id_col;
+ ulint trx_id_offs;
+ ulint len;
+
+ trx_id_col = dict_index_get_sys_col_pos(index,
+ DATA_TRX_ID);
+ ut_ad(trx_id_col > 0);
+ ut_ad(trx_id_col != ULINT_UNDEFINED);
+
+ trx_id_offs = rec_get_nth_field_offs(foffsets,
+ trx_id_col, &len);
+ ut_ad(len == DATA_TRX_ID_LEN);
+
+ if (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN + trx_id_offs
+ + rec_offs_extra_size(foffsets) > rec_size) {
+ /* We will have to zero out the
+ DB_TRX_ID and DB_ROLL_PTR, because
+ they will not be fully overwritten by
+ insert_rec. */
+
+ memset(free_rec + trx_id_offs, 0,
+ DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN);
+ }
+
+ ut_ad(free_rec + trx_id_offs + DATA_TRX_ID_LEN
+ == rec_get_nth_field(free_rec, foffsets,
+ trx_id_col + 1, &len));
+ ut_ad(len == DATA_ROLL_PTR_LEN);
+ }
+
if (UNIV_LIKELY_NULL(heap)) {
mem_heap_free(heap);
}
diff --git a/page/page0page.c b/page/page0page.c
index 8f5a0776ba6..0ce532068ce 100644
--- a/page/page0page.c
+++ b/page/page0page.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/******************************************************
Index page routines
-(c) 1994-1996 Innobase Oy
-
Created 2/2/1994 Heikki Tuuri
*******************************************************/
diff --git a/page/page0zip.c b/page/page0zip.c
index 7cd2da171f0..56189ce3bad 100644
--- a/page/page0zip.c
+++ b/page/page0zip.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 2005, 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
+
+*****************************************************************************/
+
/******************************************************
Compressed page interface
-(c) 2005 Innobase Oy
-
Created June 2005 by Marko Makela
*******************************************************/
diff --git a/pars/lexyy.c b/pars/lexyy.c
index b7bacde768a..489752a1900 100644
--- a/pars/lexyy.c
+++ b/pars/lexyy.c
@@ -1,3 +1,21 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
#include "univ.i"
#line 2 "lexyy.c"
diff --git a/pars/make_bison.sh b/pars/make_bison.sh
index 8e993f59de6..09bb86e3106 100755
--- a/pars/make_bison.sh
+++ b/pars/make_bison.sh
@@ -1,5 +1,19 @@
#!/bin/bash
#
+# Copyright (c) 2006, 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
+#
# generate parser files from bison input files.
set -eu
diff --git a/pars/make_flex.sh b/pars/make_flex.sh
index b83e063fef0..89308a6636f 100755
--- a/pars/make_flex.sh
+++ b/pars/make_flex.sh
@@ -1,5 +1,19 @@
#!/bin/bash
#
+# Copyright (c) 2006, 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
+#
# generate lexer files from flex input files.
set -eu
diff --git a/pars/pars0grm.c b/pars/pars0grm.c
index 3d2dcbeee08..d667970735e 100644
--- a/pars/pars0grm.c
+++ b/pars/pars0grm.c
@@ -1,27 +1,29 @@
-/* A Bison parser, made by GNU Bison 2.0. */
+/*****************************************************************************
+
+Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software
+Foundation, Inc.
-/* Skeleton parser for Yacc-like parsing with Bison,
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+As a special exception, when this file is copied by Bison into a
+Bison output file, you may use that output file without restriction.
+This special exception was added by the Free Software Foundation
+in version 1.24 of Bison.
- 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; either version 2, or (at your option)
- any later version.
+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.
+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. */
+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
-/* As a special exception, when this file is copied by Bison into a
- Bison output file, you may use that output file without restriction.
- This special exception was added by the Free Software Foundation
- in version 1.24 of Bison. */
+*****************************************************************************/
+
+/* A Bison parser, made by GNU Bison 2.0. */
/* Written by Richard Stallman by simplifying the original so called
``semantic'' parser. */
diff --git a/pars/pars0grm.y b/pars/pars0grm.y
index a07be9975a1..14d64f1826f 100644
--- a/pars/pars0grm.y
+++ b/pars/pars0grm.y
@@ -1,13 +1,28 @@
-/******************************************************
-SQL parser: input file for the GNU Bison parser generator
+/*****************************************************************************
-(c) 1997 Innobase Oy
+Copyright (c) 1997, 2009, Innobase Oy. All Rights Reserved.
-Created 12/14/1997 Heikki Tuuri
-Published under the GPL version 2
+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
+
+*****************************************************************************/
+
+/******************************************************
+SQL parser: input file for the GNU Bison parser generator
Look from pars0lex.l for instructions how to generate the C files for
the InnoDB parser.
+
+Created 12/14/1997 Heikki Tuuri
*******************************************************/
%{
diff --git a/pars/pars0lex.l b/pars/pars0lex.l
index ad65034fab0..38cb744bd44 100644
--- a/pars/pars0lex.l
+++ b/pars/pars0lex.l
@@ -1,10 +1,23 @@
-/******************************************************
-SQL parser lexical analyzer: input file for the GNU Flex lexer generator
+/*****************************************************************************
-(c) 1997 Innobase Oy
+Copyright (c) 1997, 2009, Innobase Oy. All Rights Reserved.
-Created 12/14/1997 Heikki Tuuri
-Published under the GPL version 2
+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
+
+*****************************************************************************/
+
+/******************************************************
+SQL parser lexical analyzer: input file for the GNU Flex lexer generator
The InnoDB parser is frozen because MySQL takes care of SQL parsing.
Therefore we normally keep the InnoDB parser C files as they are, and do
@@ -18,6 +31,8 @@ How to make the InnoDB parser and lexer C files:
These instructions seem to work at least with bison-1.875d and flex-2.5.31 on
Linux.
+
+Created 12/14/1997 Heikki Tuuri
*******************************************************/
%option nostdinit
diff --git a/pars/pars0opt.c b/pars/pars0opt.c
index f8cf9942545..34246929c53 100644
--- a/pars/pars0opt.c
+++ b/pars/pars0opt.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 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
+
+*****************************************************************************/
+
/******************************************************
Simple SQL optimizer
-(c) 1997 Innobase Oy
-
Created 12/21/1997 Heikki Tuuri
*******************************************************/
diff --git a/pars/pars0pars.c b/pars/pars0pars.c
index 8cd8a531829..62ae3b3d09b 100644
--- a/pars/pars0pars.c
+++ b/pars/pars0pars.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
SQL parser
-(c) 1996 Innobase Oy
-
Created 11/19/1996 Heikki Tuuri
*******************************************************/
@@ -1032,19 +1048,6 @@ pars_update_statement(
node->pcur = &(plan->pcur);
}
- if (!node->is_delete && node->searched_update
- && (node->cmpl_info & UPD_NODE_NO_SIZE_CHANGE)
- && (node->cmpl_info & UPD_NODE_NO_ORD_CHANGE)) {
-
- /* The select node can perform the update in-place */
-
- ut_a(plan->asc);
-
- node->select_will_do_update = TRUE;
- sel_node->select_will_do_update = TRUE;
- sel_node->latch_mode = BTR_MODIFY_LEAF;
- }
-
return(node);
}
diff --git a/pars/pars0sym.c b/pars/pars0sym.c
index d8c49d3db14..fb23547e767 100644
--- a/pars/pars0sym.c
+++ b/pars/pars0sym.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 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
+
+*****************************************************************************/
+
/******************************************************
SQL parser symbol table
-(c) 1997 Innobase Oy
-
Created 12/15/1997 Heikki Tuuri
*******************************************************/
diff --git a/plug.in b/plug.in
index b252d471fba..71da3f48474 100644
--- a/plug.in
+++ b/plug.in
@@ -1,39 +1,80 @@
+#
+# Copyright (c) 2006, 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
+#
+
MYSQL_STORAGE_ENGINE(innobase, innodb, [InnoDB Storage Engine],
[Transactional Tables using InnoDB], [max,max-no-ndb])
MYSQL_PLUGIN_DIRECTORY(innobase, [storage/innobase])
MYSQL_PLUGIN_STATIC(innobase, [libinnobase.a])
MYSQL_PLUGIN_DYNAMIC(innobase, [ha_innodb.la])
MYSQL_PLUGIN_ACTIONS(innobase, [
- AC_CHECK_LIB(rt, aio_read, [innodb_system_libs="-lrt"])
- AC_SUBST(innodb_system_libs)
- AC_CHECK_HEADERS(aio.h sched.h)
+ AC_CHECK_HEADERS(sched.h)
AC_CHECK_SIZEOF(int, 4)
AC_CHECK_SIZEOF(long, 4)
AC_CHECK_SIZEOF(void*, 4)
- AC_CHECK_FUNCS(sched_yield)
- AC_CHECK_FUNCS(fdatasync)
- AC_CHECK_FUNCS(localtime_r)
+ AC_CHECK_FUNCS(sched_yield fdatasync localtime_r)
AC_C_BIGENDIAN
case "$target_os" in
- lin*)
- CFLAGS="$CFLAGS -DUNIV_LINUX";;
- hpux10*)
- CFLAGS="$CFLAGS -DUNIV_MUST_NOT_INLINE -DUNIV_HPUX -DUNIV_HPUX10";;
- hp*)
- CFLAGS="$CFLAGS -DUNIV_MUST_NOT_INLINE -DUNIV_HPUX";;
- aix*)
- CFLAGS="$CFLAGS -DUNIV_AIX";;
- irix*)
- CFLAGS="$CFLAGS -DUNIV_MUST_NOT_INLINE";;
- osf*)
- CFLAGS="$CFLAGS -DUNIV_MUST_NOT_INLINE";;
- *solaris*|*SunOS*)
- CFLAGS="$CFLAGS -DUNIV_SOLARIS";;
- sysv5uw7*)
- # Problem when linking on SCO
- CFLAGS="$CFLAGS -DUNIV_MUST_NOT_INLINE";;
- openbsd*)
- CFLAGS="$CFLAGS -DUNIV_MUST_NOT_INLINE";;
+ lin*)
+ CFLAGS="$CFLAGS -DUNIV_LINUX";;
+ hpux10*)
+ CFLAGS="$CFLAGS -DUNIV_MUST_NOT_INLINE -DUNIV_HPUX -DUNIV_HPUX10";;
+ hp*)
+ CFLAGS="$CFLAGS -DUNIV_MUST_NOT_INLINE -DUNIV_HPUX";;
+ aix*)
+ CFLAGS="$CFLAGS -DUNIV_AIX";;
+ irix*|osf*|sysv5uw7*|openbsd*)
+ CFLAGS="$CFLAGS -DUNIV_MUST_NOT_INLINE";;
+ *solaris*|*SunOS*)
+ CFLAGS="$CFLAGS -DUNIV_SOLARIS";;
+ esac
+ INNODB_DYNAMIC_CFLAGS="-DMYSQL_DYNAMIC_PLUGIN"
+ case "$target_cpu" in
+ x86_64)
+ # The AMD64 ABI forbids absolute addresses in shared libraries
+ ;;
+ *86)
+ # Use absolute addresses on IA-32
+ INNODB_DYNAMIC_CFLAGS="$INNODB_DYNAMIC_CFLAGS -prefer-non-pic"
+ ;;
esac
+ AC_SUBST(INNODB_DYNAMIC_CFLAGS)
+ AC_MSG_CHECKING(whether pthread_t can be used by GCC atomic builtins)
+ AC_TRY_RUN(
+ [
+ #include <pthread.h>
+
+ int main(int argc, char** argv) {
+ pthread_t x1;
+ pthread_t x2;
+ pthread_t x3;
+
+ __sync_bool_compare_and_swap(&x1, x2, x3);
+
+ return(0);
+ }
+ ],
+ [
+ AC_DEFINE([HAVE_ATOMIC_PTHREAD_T], [1],
+ [pthread_t can be used by GCC atomic builtins])
+ AC_MSG_RESULT(yes)
+ ],
+ [
+ AC_MSG_RESULT(no)
+ ]
+ )
])
+# vim: set ft=config:
diff --git a/que/que0que.c b/que/que0que.c
index be49b31d0b9..91a9d30ec4c 100644
--- a/que/que0que.c
+++ b/que/que0que.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Query graph
-(c) 1996 Innobase Oy
-
Created 5/27/1996 Heikki Tuuri
*******************************************************/
diff --git a/read/read0read.c b/read/read0read.c
index cdac50c52ec..e3e5ee5d623 100644
--- a/read/read0read.c
+++ b/read/read0read.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 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
+
+*****************************************************************************/
+
/******************************************************
Cursor read
-(c) 1997 Innobase Oy
-
Created 2/16/1997 Heikki Tuuri
*******************************************************/
diff --git a/rem/rem0cmp.c b/rem/rem0cmp.c
index 597e88c3a4c..39fcb6f19dd 100644
--- a/rem/rem0cmp.c
+++ b/rem/rem0cmp.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/***********************************************************************
Comparison services for records
-(c) 1994-1996 Innobase Oy
-
Created 7/1/1994 Heikki Tuuri
************************************************************************/
diff --git a/rem/rem0rec.c b/rem/rem0rec.c
index e712bc03a38..d6899c810e3 100644
--- a/rem/rem0rec.c
+++ b/rem/rem0rec.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/************************************************************************
Record manager
-(c) 1994-2001 Innobase Oy
-
Created 5/30/1994 Heikki Tuuri
*************************************************************************/
@@ -681,13 +697,13 @@ rec_get_nth_field_offs_old(
ut_ad(rec && len);
ut_ad(n < rec_get_n_fields_old(rec));
- if (n > REC_MAX_N_FIELDS) {
+ if (UNIV_UNLIKELY(n > REC_MAX_N_FIELDS)) {
fprintf(stderr, "Error: trying to access field %lu in rec\n",
(ulong) n);
ut_error;
}
- if (rec == NULL) {
+ if (UNIV_UNLIKELY(rec == NULL)) {
fputs("Error: rec is NULL pointer\n", stderr);
ut_error;
}
@@ -1599,11 +1615,11 @@ rec_print_old(
fprintf(file, " SQL NULL, size %lu ",
rec_get_nth_field_size(rec, i));
}
+
putc(';', file);
+ putc('\n', file);
}
- putc('\n', file);
-
rec_validate_old(rec);
}
@@ -1642,9 +1658,8 @@ rec_print_comp(
fputs(" SQL NULL", file);
}
putc(';', file);
+ putc('\n', file);
}
-
- putc('\n', file);
}
/*******************************************************************
diff --git a/row/row0ext.c b/row/row0ext.c
index 7cba6cc81ac..83dfa024ffc 100644
--- a/row/row0ext.c
+++ b/row/row0ext.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 2006, 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
+
+*****************************************************************************/
+
/******************************************************
Caching of externally stored column prefixes
-(c) 2006 Innobase Oy
-
Created September 2006 Marko Makela
*******************************************************/
diff --git a/row/row0ins.c b/row/row0ins.c
index 5d9cd877ca3..ddb1bb3556c 100644
--- a/row/row0ins.c
+++ b/row/row0ins.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Insert into a table
-(c) 1996 Innobase Oy
-
Created 4/20/1996 Heikki Tuuri
*******************************************************/
diff --git a/row/row0merge.c b/row/row0merge.c
index a44e5c32d84..efed3d26e5b 100644
--- a/row/row0merge.c
+++ b/row/row0merge.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 2005, 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
+
+*****************************************************************************/
+
/******************************************************
New index creation routines using a merge sort
-(c) 2005,2007 Innobase Oy
-
Created 12/4/2005 Jan Lindstrom
Completed by Sunny Bains and Marko Makela
*******************************************************/
@@ -442,14 +458,29 @@ row_merge_tuple_cmp(
int cmp;
const dfield_t* field = a;
+ /* Compare the fields of the tuples until a difference is
+ found or we run out of fields to compare. If !cmp at the
+ end, the tuples are equal. */
do {
cmp = cmp_dfield_dfield(a++, b++);
} while (!cmp && --n_field);
if (UNIV_UNLIKELY(!cmp) && UNIV_LIKELY_NULL(dup)) {
+ /* Report a duplicate value error if the tuples are
+ logically equal. NULL columns are logically inequal,
+ although they are equal in the sorting order. Find
+ out if any of the fields are NULL. */
+ for (b = field; b != a; b++) {
+ if (dfield_is_null(b)) {
+
+ goto func_exit;
+ }
+ }
+
row_merge_dup_report(dup, field);
}
+func_exit:
return(cmp);
}
@@ -1818,16 +1849,16 @@ row_merge_drop_temp_indexes(void)
"PROCEDURE DROP_TEMP_INDEXES_PROC () IS\n"
"indexid CHAR;\n"
"DECLARE CURSOR c IS SELECT ID FROM SYS_INDEXES\n"
- "WHERE SUBSTR(NAME,0,1)='\377' FOR UPDATE;\n"
+ "WHERE SUBSTR(NAME,0,1)='\377';\n"
"BEGIN\n"
"\tOPEN c;\n"
- "\tWHILE 1 LOOP\n"
+ "\tWHILE 1=1 LOOP\n"
"\t\tFETCH c INTO indexid;\n"
"\t\tIF (SQL % NOTFOUND) THEN\n"
"\t\t\tEXIT;\n"
"\t\tEND IF;\n"
"\t\tDELETE FROM SYS_FIELDS WHERE INDEX_ID = indexid;\n"
- "\t\tDELETE FROM SYS_INDEXES WHERE CURRENT OF c;\n"
+ "\t\tDELETE FROM SYS_INDEXES WHERE ID = indexid;\n"
"\tEND LOOP;\n"
"\tCLOSE c;\n"
"\tCOMMIT WORK;\n"
@@ -1837,6 +1868,15 @@ row_merge_drop_temp_indexes(void)
trx->op_info = "dropping partially created indexes";
row_mysql_lock_data_dictionary(trx);
+ /* Incomplete transactions may be holding some locks on the
+ data dictionary tables. However, they should never have been
+ able to lock the records corresponding to the partially
+ created indexes that we are attempting to delete, because the
+ table was locked when the indexes were being created. We will
+ drop the partially created indexes before the rollback of
+ incomplete transactions is initiated. Thus, this should not
+ interfere with the incomplete transactions. */
+ trx->isolation_level = TRX_ISO_READ_UNCOMMITTED;
err = que_eval_sql(NULL, drop_temp_indexes, FALSE, trx);
ut_a(err == DB_SUCCESS);
@@ -1953,7 +1993,6 @@ row_merge_create_temporary_table(
if (error != DB_SUCCESS) {
trx->error_state = error;
- dict_mem_table_free(new_table);
new_table = NULL;
}
diff --git a/row/row0mysql.c b/row/row0mysql.c
index 7db55634cfb..8204285cc38 100644
--- a/row/row0mysql.c
+++ b/row/row0mysql.c
@@ -1,9 +1,25 @@
+/*****************************************************************************
+
+Copyright (c) 2000, 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
+
+*****************************************************************************/
+
/******************************************************
Interface between Innobase row operations and MySQL.
Contains also create table and other data dictionary operations.
-(c) 2000 Innobase Oy
-
Created 9/17/2000 Heikki Tuuri
*******************************************************/
@@ -361,7 +377,7 @@ row_mysql_store_col_in_innobase_format(
/* In some cases we strip trailing spaces from UTF-8 and other
multibyte charsets, from FIXED-length CHAR columns, to save
space. UTF-8 would otherwise normally use 3 * the string length
- bytes to store a latin1 string! */
+ bytes to store an ASCII string! */
/* We assume that this CHAR field is encoded in a
variable-length character set where spaces have
@@ -1200,7 +1216,6 @@ row_create_update_node_for_mysql(
node->in_mysql_interface = TRUE;
node->is_delete = FALSE;
node->searched_update = FALSE;
- node->select_will_do_update = FALSE;
node->select = NULL;
node->pcur = btr_pcur_create_for_mysql();
node->table = table;
@@ -1444,12 +1459,13 @@ row_unlock_for_mysql(
ut_ad(prebuilt && trx);
ut_ad(trx->mysql_thread_id == os_thread_get_curr_id());
- if (!(srv_locks_unsafe_for_binlog
- || trx->isolation_level == TRX_ISO_READ_COMMITTED)) {
+ if (UNIV_UNLIKELY
+ (!srv_locks_unsafe_for_binlog
+ && trx->isolation_level != TRX_ISO_READ_COMMITTED)) {
fprintf(stderr,
"InnoDB: Error: calling row_unlock_for_mysql though\n"
- "InnoDB: srv_locks_unsafe_for_binlog is FALSE and\n"
+ "InnoDB: innodb_locks_unsafe_for_binlog is FALSE and\n"
"InnoDB: this session is not using"
" READ COMMITTED isolation level.\n");
@@ -1635,13 +1651,15 @@ Locks the data dictionary in shared mode from modifications, for performing
foreign key check, rollback, or other operation invisible to MySQL. */
UNIV_INTERN
void
-row_mysql_freeze_data_dictionary(
-/*=============================*/
- trx_t* trx) /* in: transaction */
+row_mysql_freeze_data_dictionary_func(
+/*==================================*/
+ trx_t* trx, /* in/out: transaction */
+ const char* file, /* in: file name */
+ ulint line) /* in: line number */
{
ut_a(trx->dict_operation_lock_mode == 0);
- rw_lock_s_lock(&dict_operation_lock);
+ rw_lock_s_lock_func(&dict_operation_lock, 0, file, line);
trx->dict_operation_lock_mode = RW_S_LATCH;
}
@@ -1652,7 +1670,7 @@ UNIV_INTERN
void
row_mysql_unfreeze_data_dictionary(
/*===============================*/
- trx_t* trx) /* in: transaction */
+ trx_t* trx) /* in/out: transaction */
{
ut_a(trx->dict_operation_lock_mode == RW_S_LATCH);
@@ -1666,9 +1684,11 @@ Locks the data dictionary exclusively for performing a table create or other
data dictionary modification operation. */
UNIV_INTERN
void
-row_mysql_lock_data_dictionary(
-/*===========================*/
- trx_t* trx) /* in: transaction */
+row_mysql_lock_data_dictionary_func(
+/*================================*/
+ trx_t* trx, /* in/out: transaction */
+ const char* file, /* in: file name */
+ ulint line) /* in: line number */
{
ut_a(trx->dict_operation_lock_mode == 0
|| trx->dict_operation_lock_mode == RW_X_LATCH);
@@ -1676,7 +1696,7 @@ row_mysql_lock_data_dictionary(
/* Serialize data dictionary operations with dictionary mutex:
no deadlocks or lock waits can occur then in these operations */
- rw_lock_x_lock(&dict_operation_lock);
+ rw_lock_x_lock_func(&dict_operation_lock, 0, file, line);
trx->dict_operation_lock_mode = RW_X_LATCH;
mutex_enter(&(dict_sys->mutex));
@@ -1688,7 +1708,7 @@ UNIV_INTERN
void
row_mysql_unlock_data_dictionary(
/*=============================*/
- trx_t* trx) /* in: transaction */
+ trx_t* trx) /* in/out: transaction */
{
ut_a(trx->dict_operation_lock_mode == RW_X_LATCH);
diff --git a/row/row0purge.c b/row/row0purge.c
index 0957895cf44..8c3f9b993ba 100644
--- a/row/row0purge.c
+++ b/row/row0purge.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 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
+
+*****************************************************************************/
+
/******************************************************
Purge obsolete records
-(c) 1997 Innobase Oy
-
Created 3/14/1997 Heikki Tuuri
*******************************************************/
@@ -217,7 +233,7 @@ row_purge_remove_sec_if_poss_low(
ibool found;
ulint err;
mtr_t mtr;
- mtr_t* mtr_vers;
+ mtr_t mtr_vers;
log_free_check();
mtr_start(&mtr);
@@ -225,7 +241,15 @@ row_purge_remove_sec_if_poss_low(
found = row_search_index_entry(index, entry, mode, &pcur, &mtr);
if (!found) {
- /* Not found */
+ /* Not found. This is a legitimate condition. In a
+ rollback, InnoDB will remove secondary recs that would
+ be purged anyway. Then the actual purge will not find
+ the secondary index record. Also, the purge itself is
+ eager: if it comes to consider a secondary index
+ record, and notices it does not need to exist in the
+ index, it will remove it. Then if/when the purge
+ comes to consider the secondary index record a second
+ time, it will not exist any more in the index. */
/* fputs("PURGE:........sec entry not found\n", stderr); */
/* dtuple_print(stderr, entry); */
@@ -242,21 +266,17 @@ row_purge_remove_sec_if_poss_low(
which cannot be purged yet, requires its existence. If some requires,
we should do nothing. */
- mtr_vers = mem_alloc(sizeof(mtr_t));
+ mtr_start(&mtr_vers);
- mtr_start(mtr_vers);
-
- success = row_purge_reposition_pcur(BTR_SEARCH_LEAF, node, mtr_vers);
+ success = row_purge_reposition_pcur(BTR_SEARCH_LEAF, node, &mtr_vers);
if (success) {
old_has = row_vers_old_has_index_entry(
TRUE, btr_pcur_get_rec(&(node->pcur)),
- mtr_vers, index, entry);
+ &mtr_vers, index, entry);
}
- btr_pcur_commit_specify_mtr(&(node->pcur), mtr_vers);
-
- mem_free(mtr_vers);
+ btr_pcur_commit_specify_mtr(&(node->pcur), &mtr_vers);
if (!success || !old_has) {
/* Remove the index record */
diff --git a/row/row0row.c b/row/row0row.c
index 7953b4b41c2..4343ee2b009 100644
--- a/row/row0row.c
+++ b/row/row0row.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
General row routines
-(c) 1996 Innobase Oy
-
Created 4/20/1996 Heikki Tuuri
*******************************************************/
diff --git a/row/row0sel.c b/row/row0sel.c
index 620fec64b34..ebd7bf4a2ce 100644
--- a/row/row0sel.c
+++ b/row/row0sel.c
@@ -1,8 +1,31 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 2008, Google Inc.
+
+Portions of this file contain modifications contributed and copyrighted by
+Google, Inc. Those modifications are gratefully acknowledged and are described
+briefly in the InnoDB documentation. The contributions by Google are
+incorporated with their permission, and subject to the conditions contained in
+the file COPYING.Google.
+
+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
+
+*****************************************************************************/
+
/*******************************************************
Select
-(c) 1997 Innobase Oy
-
Created 12/19/1997 Heikki Tuuri
*******************************************************/
@@ -230,9 +253,6 @@ sel_node_create(
node->common.type = QUE_NODE_SELECT;
node->state = SEL_NODE_OPEN;
- node->select_will_do_update = FALSE;
- node->latch_mode = BTR_SEARCH_LEAF;
-
node->plans = NULL;
return(node);
@@ -793,7 +813,7 @@ row_sel_get_clust_rec(
index = dict_table_get_first_index(plan->table);
btr_pcur_open_with_no_init(index, plan->clust_ref, PAGE_CUR_LE,
- node->latch_mode, &(plan->clust_pcur),
+ BTR_SEARCH_LEAF, &plan->clust_pcur,
0, mtr);
clust_rec = btr_pcur_get_rec(&(plan->clust_pcur));
@@ -962,7 +982,6 @@ static
void
row_sel_open_pcur(
/*==============*/
- sel_node_t* node, /* in: select node */
plan_t* plan, /* in: table plan */
ibool search_latch_locked,
/* in: TRUE if the thread currently
@@ -1015,13 +1034,13 @@ row_sel_open_pcur(
/* Open pcur to the index */
btr_pcur_open_with_no_init(index, plan->tuple, plan->mode,
- node->latch_mode, &(plan->pcur),
+ BTR_SEARCH_LEAF, &plan->pcur,
has_search_latch, mtr);
} else {
/* Open the cursor to the start or the end of the index
(FALSE: no init) */
- btr_pcur_open_at_index_side(plan->asc, index, node->latch_mode,
+ btr_pcur_open_at_index_side(plan->asc, index, BTR_SEARCH_LEAF,
&(plan->pcur), FALSE, mtr);
}
@@ -1043,7 +1062,6 @@ row_sel_restore_pcur_pos(
function (moved to the previous, in the case
of a descending cursor) without processing
again the current cursor record */
- sel_node_t* node, /* in: select node */
plan_t* plan, /* in: table plan */
mtr_t* mtr) /* in: mtr */
{
@@ -1054,7 +1072,7 @@ row_sel_restore_pcur_pos(
relative_position = btr_pcur_get_rel_pos(&(plan->pcur));
- equal_position = btr_pcur_restore_position(node->latch_mode,
+ equal_position = btr_pcur_restore_position(BTR_SEARCH_LEAF,
&(plan->pcur), mtr);
/* If the cursor is traveling upwards, and relative_position is
@@ -1173,7 +1191,7 @@ row_sel_try_search_shortcut(
ut_ad(rw_lock_own(&btr_search_latch, RW_LOCK_SHARED));
#endif /* UNIV_SYNC_DEBUG */
- row_sel_open_pcur(node, plan, TRUE, mtr);
+ row_sel_open_pcur(plan, TRUE, mtr);
rec = btr_pcur_get_rec(&(plan->pcur));
@@ -1234,7 +1252,7 @@ row_sel_try_search_shortcut(
goto func_exit;
}
- ut_ad(plan->pcur.latch_mode == node->latch_mode);
+ ut_ad(plan->pcur.latch_mode == BTR_SEARCH_LEAF);
plan->n_rows_fetched++;
ret = SEL_FOUND;
@@ -1274,13 +1292,6 @@ row_sel(
ulint cost_counter = 0;
ibool cursor_just_opened;
ibool must_go_to_next;
- ibool leaf_contains_updates = FALSE;
- /* TRUE if select_will_do_update is
- TRUE and the current clustered index
- leaf page has been updated during
- the current mtr: mtr must be committed
- at the same time as the leaf x-latch
- is released */
ibool mtr_has_extra_clust_latch = FALSE;
/* TRUE if the search was made using
a non-clustered index, and we had to
@@ -1319,7 +1330,6 @@ table_loop:
node->fetch_table changes, and after adding a row to aggregate totals
and, of course, when this function is called. */
- ut_ad(leaf_contains_updates == FALSE);
ut_ad(mtr_has_extra_clust_latch == FALSE);
plan = sel_node_get_nth_plan(node, node->fetch_table);
@@ -1352,7 +1362,7 @@ table_loop:
rw_lock_s_lock(&btr_search_latch);
search_latch_locked = TRUE;
- } else if (btr_search_latch.writer_is_wait_ex) {
+ } else if (rw_lock_get_writer(&btr_search_latch) == RW_LOCK_WAIT_EX) {
/* There is an x-latch request waiting: release the
s-latch for a moment; as an s-latch here is often
@@ -1394,7 +1404,7 @@ table_loop:
/* Evaluate the expressions to build the search tuple and
open the cursor */
- row_sel_open_pcur(node, plan, search_latch_locked, &mtr);
+ row_sel_open_pcur(plan, search_latch_locked, &mtr);
cursor_just_opened = TRUE;
@@ -1403,7 +1413,7 @@ table_loop:
} else {
/* Restore pcur position to the index */
- must_go_to_next = row_sel_restore_pcur_pos(node, plan, &mtr);
+ must_go_to_next = row_sel_restore_pcur_pos(plan, &mtr);
cursor_just_opened = FALSE;
@@ -1742,29 +1752,7 @@ skip_lock:
plan->n_rows_fetched++;
- ut_ad(plan->pcur.latch_mode == node->latch_mode);
-
- if (node->select_will_do_update) {
- /* This is a searched update and we can do the update in-place,
- saving CPU time */
-
- row_upd_in_place_in_select(node, thr, &mtr);
-
- leaf_contains_updates = TRUE;
-
- /* When the database is in the online backup mode, the number
- of log records for a single mtr should be small: increment the
- cost counter to ensure it */
-
- cost_counter += 1 + (SEL_COST_LIMIT / 8);
-
- if (plan->unique_search) {
-
- goto table_exhausted;
- }
-
- goto next_rec;
- }
+ ut_ad(plan->pcur.latch_mode == BTR_SEARCH_LEAF);
if ((plan->n_rows_fetched <= SEL_PREFETCH_LIMIT)
|| plan->unique_search || plan->no_prefetch
@@ -1799,19 +1787,6 @@ next_rec:
goto commit_mtr_for_a_while;
}
- if (leaf_contains_updates
- && btr_pcur_is_after_last_on_page(&plan->pcur)) {
-
- /* We must commit &mtr if we are moving to a different page,
- because we have done updates to the x-latched leaf page, and
- the latch would be released in btr_pcur_move_to_next, without
- &mtr getting committed there */
-
- ut_ad(node->asc);
-
- goto commit_mtr_for_a_while;
- }
-
if (node->asc) {
moved = btr_pcur_move_to_next(&(plan->pcur), &mtr);
} else {
@@ -1848,7 +1823,6 @@ next_table:
mtr_commit(&mtr);
- leaf_contains_updates = FALSE;
mtr_has_extra_clust_latch = FALSE;
next_table_no_mtr:
@@ -1889,7 +1863,6 @@ table_exhausted:
mtr_commit(&mtr);
- leaf_contains_updates = FALSE;
mtr_has_extra_clust_latch = FALSE;
if (plan->n_rows_prefetched > 0) {
@@ -1958,7 +1931,6 @@ commit_mtr_for_a_while:
mtr_commit(&mtr);
- leaf_contains_updates = FALSE;
mtr_has_extra_clust_latch = FALSE;
#ifdef UNIV_SYNC_DEBUG
@@ -2721,6 +2693,7 @@ row_sel_store_mysql_rec(
ulint i;
ut_ad(prebuilt->mysql_template);
+ ut_ad(prebuilt->default_rec);
ut_ad(rec_offs_validate(rec, NULL, offsets));
if (UNIV_LIKELY_NULL(prebuilt->blob_heap)) {
@@ -2808,58 +2781,14 @@ row_sel_store_mysql_rec(
&= ~(byte) templ->mysql_null_bit_mask;
}
} else {
- /* MySQL seems to assume the field for an SQL NULL
- value is set to zero or space. Not taking this into
- account caused seg faults with NULL BLOB fields, and
- bug number 154 in the MySQL bug database: GROUP BY
- and DISTINCT could treat NULL values inequal. */
- int pad_char;
+ /* MySQL assumes that the field for an SQL
+ NULL value is set to the default value. */
mysql_rec[templ->mysql_null_byte_offset]
|= (byte) templ->mysql_null_bit_mask;
- switch (templ->type) {
- case DATA_VARCHAR:
- case DATA_BINARY:
- case DATA_VARMYSQL:
- if (templ->mysql_type
- == DATA_MYSQL_TRUE_VARCHAR) {
- /* This is a >= 5.0.3 type
- true VARCHAR. Zero the field. */
- pad_char = 0x00;
- break;
- }
- /* Fall through */
- case DATA_CHAR:
- case DATA_FIXBINARY:
- case DATA_MYSQL:
- /* MySQL pads all string types (except
- BLOB, TEXT and true VARCHAR) with space. */
- if (UNIV_UNLIKELY(templ->mbminlen == 2)) {
- /* Treat UCS2 as a special case. */
- byte* d = mysql_rec
- + templ->mysql_col_offset;
- len = templ->mysql_col_len;
- /* There are two UCS2 bytes per char,
- so the length has to be even. */
- ut_a(!(len & 1));
- /* Pad with 0x0020. */
- while (len) {
- *d++ = 0x00;
- *d++ = 0x20;
- len -= 2;
- }
- continue;
- }
- pad_char = 0x20;
- break;
- default:
- pad_char = 0x00;
- break;
- }
-
- ut_ad(!pad_char || templ->mbminlen == 1);
- memset(mysql_rec + templ->mysql_col_offset,
- pad_char, templ->mysql_col_len);
+ memcpy(mysql_rec + templ->mysql_col_offset,
+ prebuilt->default_rec + templ->mysql_col_offset,
+ templ->mysql_col_len);
}
}
@@ -3458,7 +3387,7 @@ row_search_for_mysql(
/* PHASE 0: Release a possible s-latch we are holding on the
adaptive hash index latch if there is someone waiting behind */
- if (UNIV_UNLIKELY(btr_search_latch.writer != RW_LOCK_NOT_LOCKED)
+ if (UNIV_UNLIKELY(rw_lock_get_writer(&btr_search_latch) != RW_LOCK_NOT_LOCKED)
&& trx->has_search_latch) {
/* There is an x-latch request on the adaptive hash index:
diff --git a/row/row0uins.c b/row/row0uins.c
index ee33472d748..69d6b2e6c2a 100644
--- a/row/row0uins.c
+++ b/row/row0uins.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 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
+
+*****************************************************************************/
+
/******************************************************
Fresh insert undo
-(c) 1996 Innobase Oy
-
Created 2/25/1997 Heikki Tuuri
*******************************************************/
@@ -274,7 +290,9 @@ row_undo_ins_parse_undo_rec(
/***************************************************************
Undoes a fresh insert of a row to a table. A fresh insert means that
the same clustered index unique key did not have any record, even delete
-marked, at the time of the insert. */
+marked, at the time of the insert. InnoDB is eager in a rollback:
+if it figures out that an index record will be removed in the purge
+anyway, it will remove it in the rollback. */
UNIV_INTERN
ulint
row_undo_ins(
diff --git a/row/row0umod.c b/row/row0umod.c
index 0296566c7d3..835f357fc8d 100644
--- a/row/row0umod.c
+++ b/row/row0umod.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 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
+
+*****************************************************************************/
+
/******************************************************
Undo modify of a row
-(c) 1997 Innobase Oy
-
Created 2/27/1997 Heikki Tuuri
*******************************************************/
@@ -312,7 +328,15 @@ row_undo_mod_del_mark_or_remove_sec_low(
btr_cur = btr_pcur_get_btr_cur(&pcur);
if (!found) {
- /* Not found */
+ /* In crash recovery, the secondary index record may
+ be missing if the UPDATE did not have time to insert
+ the secondary index records before the crash. When we
+ are undoing that UPDATE in crash recovery, the record
+ may be missing.
+
+ In normal processing, if an update ends in a deadlock
+ before it has inserted all updated secondary index
+ records, then the undo will not find those records. */
btr_pcur_close(&pcur);
mtr_commit(&mtr);
diff --git a/row/row0undo.c b/row/row0undo.c
index b955c6d1b44..d372f88e207 100644
--- a/row/row0undo.c
+++ b/row/row0undo.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 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
+
+*****************************************************************************/
+
/******************************************************
Row undo
-(c) 1997 Innobase Oy
-
Created 1/8/1997 Heikki Tuuri
*******************************************************/
diff --git a/row/row0upd.c b/row/row0upd.c
index dae5b90aa8a..740f1ee593d 100644
--- a/row/row0upd.c
+++ b/row/row0upd.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Update of a row
-(c) 1996 Innobase Oy
-
Created 12/27/1996 Heikki Tuuri
*******************************************************/
@@ -275,7 +291,6 @@ upd_node_create(
node->common.type = QUE_NODE_UPDATE;
node->state = UPD_NODE_UPDATE_CLUSTERED;
- node->select_will_do_update = FALSE;
node->in_mysql_interface = FALSE;
node->row = NULL;
@@ -2151,66 +2166,3 @@ error_handling:
return(thr);
}
-
-/*************************************************************************
-Performs an in-place update for the current clustered index record in
-select. */
-UNIV_INTERN
-void
-row_upd_in_place_in_select(
-/*=======================*/
- sel_node_t* sel_node, /* in: select node */
- que_thr_t* thr, /* in: query thread */
- mtr_t* mtr) /* in: mtr */
-{
- upd_node_t* node;
- btr_pcur_t* pcur;
- btr_cur_t* btr_cur;
- ulint err;
- mem_heap_t* heap = NULL;
- ulint offsets_[REC_OFFS_NORMAL_SIZE];
- rec_offs_init(offsets_);
-
- ut_ad(sel_node->select_will_do_update);
- ut_ad(sel_node->latch_mode == BTR_MODIFY_LEAF);
- ut_ad(sel_node->asc);
-
- node = que_node_get_parent(sel_node);
-
- ut_ad(que_node_get_type(node) == QUE_NODE_UPDATE);
-
- pcur = node->pcur;
- btr_cur = btr_pcur_get_btr_cur(pcur);
-
- /* Copy the necessary columns from clust_rec and calculate the new
- values to set */
-
- row_upd_copy_columns(btr_pcur_get_rec(pcur),
- rec_get_offsets(btr_pcur_get_rec(pcur),
- btr_cur->index, offsets_,
- ULINT_UNDEFINED, &heap),
- UT_LIST_GET_FIRST(node->columns));
- if (UNIV_LIKELY_NULL(heap)) {
- mem_heap_free(heap);
- }
- row_upd_eval_new_vals(node->update);
-
- ut_ad(!rec_get_deleted_flag(
- btr_pcur_get_rec(pcur),
- dict_table_is_comp(btr_cur->index->table)));
-
- ut_ad(node->cmpl_info & UPD_NODE_NO_SIZE_CHANGE);
- ut_ad(node->cmpl_info & UPD_NODE_NO_ORD_CHANGE);
- ut_ad(node->select_will_do_update);
-
- err = btr_cur_update_in_place(BTR_NO_LOCKING_FLAG, btr_cur,
- node->update, node->cmpl_info,
- thr, mtr);
- /* TODO: the above can fail with DB_ZIP_OVERFLOW if page_zip != NULL.
- However, this function row_upd_in_place_in_select() is only invoked
- when executing UPDATE statements of the built-in InnoDB SQL parser.
- The built-in SQL is only used for InnoDB system tables, which
- always are in the old, uncompressed format (ROW_FORMAT=REDUNDANT,
- comp == FALSE, page_zip == NULL). */
- ut_ad(err == DB_SUCCESS);
-}
diff --git a/row/row0vers.c b/row/row0vers.c
index 2ed71457dbb..3abba6d6fb8 100644
--- a/row/row0vers.c
+++ b/row/row0vers.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1997, 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
+
+*****************************************************************************/
+
/******************************************************
Row versions
-(c) 1997 Innobase Oy
-
Created 2/6/1997 Heikki Tuuri
*******************************************************/
@@ -48,16 +64,13 @@ row_vers_impl_x_locked_off_kernel(
rec_t* clust_rec;
ulint* clust_offsets;
rec_t* version;
- rec_t* prev_version;
dulint trx_id;
- dulint prev_trx_id;
mem_heap_t* heap;
mem_heap_t* heap2;
dtuple_t* row;
dtuple_t* entry = NULL; /* assignment to eliminate compiler
warning */
trx_t* trx;
- ulint vers_del;
ulint rec_del;
ulint err;
mtr_t mtr;
@@ -141,6 +154,11 @@ row_vers_impl_x_locked_off_kernel(
version = clust_rec;
for (;;) {
+ rec_t* prev_version;
+ ulint vers_del;
+ row_ext_t* ext;
+ dulint prev_trx_id;
+
mutex_exit(&kernel_mutex);
/* While we retrieve an earlier version of clust_rec, we
@@ -157,66 +175,63 @@ row_vers_impl_x_locked_off_kernel(
heap, &prev_version);
mem_heap_free(heap2); /* free version and clust_offsets */
- if (prev_version) {
- row_ext_t* ext;
+ if (prev_version == NULL) {
+ mutex_enter(&kernel_mutex);
+
+ if (!trx_is_active(trx_id)) {
+ /* Transaction no longer active: no
+ implicit x-lock */
- clust_offsets = rec_get_offsets(
- prev_version, clust_index, NULL,
- ULINT_UNDEFINED, &heap);
-
- vers_del = rec_get_deleted_flag(prev_version,
- comp);
- prev_trx_id = row_get_rec_trx_id(prev_version,
- clust_index,
- clust_offsets);
-
- /* If the trx_id and prev_trx_id are
- different and if the prev_version is marked
- deleted then the prev_trx_id must have
- already committed for the trx_id to be able to
- modify the row. Therefore, prev_trx_id cannot
- hold any implicit lock. */
- if (0 != ut_dulint_cmp(trx_id, prev_trx_id)
- && vers_del) {
-
- mutex_enter(&kernel_mutex);
break;
}
- /* The stack of versions is locked by mtr.
- Thus, it is safe to fetch the prefixes for
- externally stored columns. */
- row = row_build(ROW_COPY_POINTERS, clust_index,
- prev_version, clust_offsets,
- NULL, &ext, heap);
- entry = row_build_index_entry(row, ext, index, heap);
- /* entry may be NULL if a record was inserted
- in place of a deleted record, and the BLOB
- pointers of the new record were not
- initialized yet. But in that case,
- prev_version should be NULL. */
- ut_a(entry);
- }
+ /* If the transaction is still active,
+ clust_rec must be a fresh insert, because no
+ previous version was found. */
+ ut_ad(err == DB_SUCCESS);
- mutex_enter(&kernel_mutex);
+ /* It was a freshly inserted version: there is an
+ implicit x-lock on rec */
- if (!trx_is_active(trx_id)) {
- /* Transaction no longer active: no implicit x-lock */
+ trx = trx_get_on_id(trx_id);
break;
}
- /* If the transaction is still active, the previous version
- of clust_rec must be accessible if not a fresh insert; we
- may assert the following: */
+ clust_offsets = rec_get_offsets(prev_version, clust_index,
+ NULL, ULINT_UNDEFINED, &heap);
- ut_ad(err == DB_SUCCESS);
+ vers_del = rec_get_deleted_flag(prev_version, comp);
+ prev_trx_id = row_get_rec_trx_id(prev_version, clust_index,
+ clust_offsets);
- if (prev_version == NULL) {
- /* It was a freshly inserted version: there is an
- implicit x-lock on rec */
+ /* If the trx_id and prev_trx_id are different and if
+ the prev_version is marked deleted then the
+ prev_trx_id must have already committed for the trx_id
+ to be able to modify the row. Therefore, prev_trx_id
+ cannot hold any implicit lock. */
+ if (vers_del && 0 != ut_dulint_cmp(trx_id, prev_trx_id)) {
- trx = trx_get_on_id(trx_id);
+ mutex_enter(&kernel_mutex);
+ break;
+ }
+
+ /* The stack of versions is locked by mtr. Thus, it
+ is safe to fetch the prefixes for externally stored
+ columns. */
+ row = row_build(ROW_COPY_POINTERS, clust_index, prev_version,
+ clust_offsets, NULL, &ext, heap);
+ entry = row_build_index_entry(row, ext, index, heap);
+ /* entry may be NULL if a record was inserted in place
+ of a deleted record, and the BLOB pointers of the new
+ record were not initialized yet. But in that case,
+ prev_version should be NULL. */
+ ut_a(entry);
+
+ mutex_enter(&kernel_mutex);
+
+ if (!trx_is_active(trx_id)) {
+ /* Transaction no longer active: no implicit x-lock */
break;
}
@@ -226,6 +241,11 @@ row_vers_impl_x_locked_off_kernel(
if prev_version would require rec to be in a different
state. */
+ /* The previous version of clust_rec must be
+ accessible, because the transaction is still active
+ and clust_rec was not a fresh insert. */
+ ut_ad(err == DB_SUCCESS);
+
/* We check if entry and rec are identified in the alphabetical
ordering */
if (0 == cmp_dtuple_rec(entry, rec, offsets)) {
diff --git a/setup.sh b/setup.sh
index 8c6b7052a94..23fe729a406 100755
--- a/setup.sh
+++ b/setup.sh
@@ -1,5 +1,19 @@
#!/bin/sh
#
+# Copyright (c) 1995, 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
+#
# Prepare the MySQL source code tree for building
# with checked-out InnoDB Subversion directory.
@@ -21,3 +35,13 @@ cd ../r
ln -sf ../$TARGETDIR/mysql-test/*.result .
cd ../include
ln -sf ../$TARGETDIR/mysql-test/*.inc .
+
+# Apply any patches that are needed to make the mysql-test suite successful.
+# These patches are usually needed because of deviations of behavior between
+# the stock InnoDB and the InnoDB Plugin.
+cd ../..
+for patch in storage/innobase/mysql-test/patches/*.diff ; do
+ if [ "${patch}" != "storage/innobase/mysql-test/patches/*.diff" ] ; then
+ patch -p0 < ${patch}
+ fi
+done
diff --git a/srv/srv0que.c b/srv/srv0que.c
index 5f7ee7ed6fe..344aaed8775 100644
--- a/srv/srv0que.c
+++ b/srv/srv0que.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Server query execution
-(c) 1996 Innobase Oy
-
Created 6/5/1996 Heikki Tuuri
*******************************************************/
diff --git a/srv/srv0srv.c b/srv/srv0srv.c
index c26a397b0c8..f448afb0dad 100644
--- a/srv/srv0srv.c
+++ b/srv/srv0srv.c
@@ -1,3 +1,28 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 2008, Google Inc.
+
+Portions of this file contain modifications contributed and copyrighted by
+Google, Inc. Those modifications are gratefully acknowledged and are described
+briefly in the InnoDB documentation. The contributions by Google are
+incorporated with their permission, and subject to the conditions contained in
+the file COPYING.Google.
+
+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
+
+*****************************************************************************/
+
/******************************************************
The database server main program
@@ -20,10 +45,9 @@ Windows 2000 will have something called thread pooling
Another possibility could be to use some very fast user space
thread library. This might confuse NT though.
-(c) 1995 Innobase Oy
-
Created 10/8/1995 Heikki Tuuri
*******************************************************/
+
/* Dummy comment */
#include "srv0srv.h"
@@ -142,12 +166,14 @@ UNIV_INTERN ulint srv_show_verbose_locks = 0;
collation */
UNIV_INTERN const byte* srv_latin1_ordering;
+/* use os/external memory allocator */
+UNIV_INTERN my_bool srv_use_sys_malloc = TRUE;
/* requested size in kilobytes */
-UNIV_INTERN ulong srv_buf_pool_size = ULINT_MAX;
+UNIV_INTERN ulint srv_buf_pool_size = ULINT_MAX;
/* previously requested size */
-UNIV_INTERN ulong srv_buf_pool_old_size;
+UNIV_INTERN ulint srv_buf_pool_old_size;
/* current size in kilobytes */
-UNIV_INTERN ulong srv_buf_pool_curr_size = 0;
+UNIV_INTERN ulint srv_buf_pool_curr_size = 0;
/* size in bytes */
UNIV_INTERN ulint srv_mem_pool_size = ULINT_MAX;
UNIV_INTERN ulint srv_lock_table_size = ULINT_MAX;
@@ -264,10 +290,10 @@ UNIV_INTERN ulong srv_commit_concurrency = 0;
/* this mutex protects srv_conc data structures */
UNIV_INTERN os_fast_mutex_t srv_conc_mutex;
-/* number of OS threads currently inside InnoDB; it is not an error if
-this drops temporarily below zero because we do not demand that every
-thread increments this, but a thread waiting for a lock decrements
-this temporarily */
+/* number of transactions that have declared_to_be_inside_innodb set.
+It used to be a non-error for this value to drop below zero temporarily.
+This is no longer true. We'll, however, keep the lint datatype to add
+assertions to catch any corner cases that we may have missed. */
UNIV_INTERN lint srv_conc_n_threads = 0;
/* number of OS threads waiting in the FIFO for a permission to enter
InnoDB */
@@ -968,6 +994,7 @@ void
srv_general_init(void)
/*==================*/
{
+ ut_mem_init();
os_sync_init();
sync_init();
mem_init(srv_mem_pool_size);
@@ -1026,6 +1053,8 @@ retry:
return;
}
+ ut_ad(srv_conc_n_threads >= 0);
+
if (srv_conc_n_threads < (lint)srv_thread_concurrency) {
srv_conc_n_threads++;
@@ -1152,6 +1181,8 @@ srv_conc_force_enter_innodb(
return;
}
+ ut_ad(srv_conc_n_threads >= 0);
+
os_fast_mutex_lock(&srv_conc_mutex);
srv_conc_n_threads++;
@@ -1173,11 +1204,6 @@ srv_conc_force_exit_innodb(
{
srv_conc_slot_t* slot = NULL;
- if (UNIV_LIKELY(!srv_thread_concurrency)) {
-
- return;
- }
-
if (trx->mysql_thd != NULL
&& thd_is_replication_slave_thread(trx->mysql_thd)) {
@@ -1191,6 +1217,7 @@ srv_conc_force_exit_innodb(
os_fast_mutex_lock(&srv_conc_mutex);
+ ut_ad(srv_conc_n_threads > 0);
srv_conc_n_threads--;
trx->declared_to_be_inside_innodb = FALSE;
trx->n_tickets_to_enter_innodb = 0;
@@ -1484,10 +1511,13 @@ srv_suspend_mysql_thread(
ut_a(trx->dict_operation_lock_mode == 0);
- /* Wait for the release */
+ /* Suspend this thread and wait for the event. */
os_event_wait(event);
+ /* After resuming, reacquire the data dictionary latch if
+ necessary. */
+
switch (had_dict_lock) {
case RW_S_LATCH:
row_mysql_freeze_data_dictionary(trx);
@@ -1927,6 +1957,11 @@ srv_export_innodb_status(void)
export_vars.innodb_buffer_pool_pages_misc = buf_pool->curr_size
- UT_LIST_GET_LEN(buf_pool->LRU)
- UT_LIST_GET_LEN(buf_pool->free);
+#ifdef HAVE_GCC_ATOMIC_BUILTINS
+ export_vars.innodb_have_atomic_builtins = 1;
+#else
+ export_vars.innodb_have_atomic_builtins = 0;
+#endif
export_vars.innodb_page_size = UNIV_PAGE_SIZE;
export_vars.innodb_log_waits = srv_log_waits;
export_vars.innodb_os_log_written = srv_os_log_written;
diff --git a/srv/srv0start.c b/srv/srv0start.c
index fcf8e0ce0ca..7e000c02550 100644
--- a/srv/srv0start.c
+++ b/srv/srv0start.c
@@ -1,8 +1,31 @@
+/*****************************************************************************
+
+Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 2008, Google Inc.
+
+Portions of this file contain modifications contributed and copyrighted by
+Google, Inc. Those modifications are gratefully acknowledged and are described
+briefly in the InnoDB documentation. The contributions by Google are
+incorporated with their permission, and subject to the conditions contained in
+the file COPYING.Google.
+
+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
+
+*****************************************************************************/
+
/************************************************************************
Starts the InnoDB database server
-(c) 1996-2000 Innobase Oy
-
Created 2/16/1996 Heikki Tuuri
*************************************************************************/
@@ -10,7 +33,6 @@ Created 2/16/1996 Heikki Tuuri
#include "sync0sync.h"
#include "ut0mem.h"
#include "mem0mem.h"
-#include "mem0pool.h"
#include "data0data.h"
#include "data0type.h"
#include "dict0dict.h"
@@ -152,29 +174,19 @@ UNIV_INTERN
ibool
srv_parse_data_file_paths_and_sizes(
/*================================*/
- /* out: TRUE if ok, FALSE if parsing
- error */
- char* str, /* in: the data file path string */
- char*** data_file_names, /* out, own: array of data file
- names */
- ulint** data_file_sizes, /* out, own: array of data file sizes
- in megabytes */
- ulint** data_file_is_raw_partition,/* out, own: array of flags
- showing which data files are raw
- partitions */
- ulint* n_data_files, /* out: number of data files */
- ibool* is_auto_extending, /* out: TRUE if the last data file is
- auto-extending */
- ulint* max_auto_extend_size) /* out: max auto extend size for the
- last file if specified, 0 if not */
+ /* out: TRUE if ok, FALSE on parse error */
+ char* str) /* in/out: the data file path string */
{
char* input_str;
char* path;
ulint size;
ulint i = 0;
- *is_auto_extending = FALSE;
- *max_auto_extend_size = 0;
+ srv_auto_extend_last_data_file = FALSE;
+ srv_last_file_size_max = 0;
+ srv_data_file_names = NULL;
+ srv_data_file_sizes = NULL;
+ srv_data_file_is_raw_partition = NULL;
input_str = str;
@@ -251,11 +263,12 @@ srv_parse_data_file_paths_and_sizes(
return(FALSE);
}
- *data_file_names = (char**)ut_malloc(i * sizeof(void*));
- *data_file_sizes = (ulint*)ut_malloc(i * sizeof(ulint));
- *data_file_is_raw_partition = (ulint*)ut_malloc(i * sizeof(ulint));
+ srv_data_file_names = malloc(i * sizeof *srv_data_file_names);
+ srv_data_file_sizes = malloc(i * sizeof *srv_data_file_sizes);
+ srv_data_file_is_raw_partition = malloc(
+ i * sizeof *srv_data_file_is_raw_partition);
- *n_data_files = i;
+ srv_n_data_files = i;
/* Then store the actual values to our arrays */
@@ -285,13 +298,13 @@ srv_parse_data_file_paths_and_sizes(
str = srv_parse_megabytes(str, &size);
- (*data_file_names)[i] = path;
- (*data_file_sizes)[i] = size;
+ srv_data_file_names[i] = path;
+ srv_data_file_sizes[i] = size;
if (0 == strncmp(str, ":autoextend",
(sizeof ":autoextend") - 1)) {
- *is_auto_extending = TRUE;
+ srv_auto_extend_last_data_file = TRUE;
str += (sizeof ":autoextend") - 1;
@@ -301,7 +314,7 @@ srv_parse_data_file_paths_and_sizes(
str += (sizeof ":max:") - 1;
str = srv_parse_megabytes(
- str, max_auto_extend_size);
+ str, &srv_last_file_size_max);
}
if (*str != '\0') {
@@ -310,21 +323,21 @@ srv_parse_data_file_paths_and_sizes(
}
}
- (*data_file_is_raw_partition)[i] = 0;
+ (srv_data_file_is_raw_partition)[i] = 0;
if (strlen(str) >= 6
&& *str == 'n'
&& *(str + 1) == 'e'
&& *(str + 2) == 'w') {
str += 3;
- (*data_file_is_raw_partition)[i] = SRV_NEW_RAW;
+ (srv_data_file_is_raw_partition)[i] = SRV_NEW_RAW;
}
if (*str == 'r' && *(str + 1) == 'a' && *(str + 2) == 'w') {
str += 3;
- if ((*data_file_is_raw_partition)[i] == 0) {
- (*data_file_is_raw_partition)[i] = SRV_OLD_RAW;
+ if ((srv_data_file_is_raw_partition)[i] == 0) {
+ (srv_data_file_is_raw_partition)[i] = SRV_OLD_RAW;
}
}
@@ -345,15 +358,15 @@ UNIV_INTERN
ibool
srv_parse_log_group_home_dirs(
/*==========================*/
- /* out: TRUE if ok, FALSE if parsing
- error */
- char* str, /* in: character string */
- char*** log_group_home_dirs) /* out, own: log group home dirs */
+ /* out: TRUE if ok, FALSE on parse error */
+ char* str) /* in/out: character string */
{
char* input_str;
char* path;
ulint i = 0;
+ srv_log_group_home_dirs = NULL;
+
input_str = str;
/* First calculate the number of directories and check syntax:
@@ -383,7 +396,7 @@ srv_parse_log_group_home_dirs(
return(FALSE);
}
- *log_group_home_dirs = (char**) ut_malloc(i * sizeof(void*));
+ srv_log_group_home_dirs = malloc(i * sizeof *srv_log_group_home_dirs);
/* Then store the actual values to our array */
@@ -402,7 +415,7 @@ srv_parse_log_group_home_dirs(
str++;
}
- (*log_group_home_dirs)[i] = path;
+ srv_log_group_home_dirs[i] = path;
i++;
}
@@ -410,6 +423,24 @@ srv_parse_log_group_home_dirs(
return(TRUE);
}
+/*************************************************************************
+Frees the memory allocated by srv_parse_data_file_paths_and_sizes()
+and srv_parse_log_group_home_dirs(). */
+UNIV_INTERN
+void
+srv_free_paths_and_sizes(void)
+/*==========================*/
+{
+ free(srv_data_file_names);
+ srv_data_file_names = NULL;
+ free(srv_data_file_sizes);
+ srv_data_file_sizes = NULL;
+ free(srv_data_file_is_raw_partition);
+ srv_data_file_is_raw_partition = NULL;
+ free(srv_log_group_home_dirs);
+ srv_log_group_home_dirs = NULL;
+}
+
#ifndef UNIV_HOTBACKUP
/************************************************************************
I/o-handler thread function. */
@@ -956,8 +987,7 @@ skip_size_check:
/********************************************************************
Starts InnoDB and creates a new database if database files
-are not found and the user wants. Server parameters are
-read from a file of name "srv_init" in the ib_home directory. */
+are not found and the user wants. */
UNIV_INTERN
int
innobase_start_or_create_for_mysql(void)
@@ -1047,6 +1077,24 @@ innobase_start_or_create_for_mysql(void)
"InnoDB: !!!!!!!! UNIV_MEM_DEBUG switched on !!!!!!!!!\n");
#endif
+ if (UNIV_LIKELY(srv_use_sys_malloc)) {
+ fprintf(stderr,
+ "InnoDB: The InnoDB memory heap is disabled\n");
+ }
+
+#ifdef HAVE_GCC_ATOMIC_BUILTINS
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
+ fprintf(stderr,
+ "InnoDB: Mutexes and rw_locks use GCC atomic builtins.\n");
+#else /* INNODB_RW_LOCKS_USE_ATOMICS */
+ fprintf(stderr,
+ "InnoDB: Mutexes use GCC atomic builtins, rw_locks do not.\n");
+#endif /* INNODB_RW_LOCKS_USE_ATOMICS */
+#else /* HAVE_GCC_ATOMIC_BUILTINS */
+ fprintf(stderr,
+ "InnoDB: Neither mutexes nor rw_locks use GCC atomic builtins.\n");
+#endif /* HAVE_GCC_ATOMIC_BUILTINS */
+
/* Since InnoDB does not currently clean up all its internal data
structures in MySQL Embedded Server Library server_end(), we
print an error message if someone tries to start up InnoDB a
diff --git a/sync/sync0arr.c b/sync/sync0arr.c
index ced58708902..7edbbda5b55 100644
--- a/sync/sync0arr.c
+++ b/sync/sync0arr.c
@@ -1,8 +1,31 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 2008, Google Inc.
+
+Portions of this file contain modifications contributed and copyrighted by
+Google, Inc. Those modifications are gratefully acknowledged and are described
+briefly in the InnoDB documentation. The contributions by Google are
+incorporated with their permission, and subject to the conditions contained in
+the file COPYING.Google.
+
+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
+
+*****************************************************************************/
+
/******************************************************
The wait array used in synchronization primitives
-(c) 1995 Innobase Oy
-
Created 9/5/1995 Heikki Tuuri
*******************************************************/
@@ -295,25 +318,28 @@ sync_array_validate(
}
/***********************************************************************
-Puts the cell event in reset state. */
+Returns the event that the thread owning the cell waits for. */
static
-ib_int64_t
-sync_cell_event_reset(
-/*==================*/
- /* out: value of signal_count
- at the time of reset. */
- ulint type, /* in: lock type mutex/rw_lock */
- void* object) /* in: the rw_lock/mutex object */
+os_event_t
+sync_cell_get_event(
+/*================*/
+ sync_cell_t* cell) /* in: non-empty sync array cell */
{
+ ulint type = cell->request_type;
+
if (type == SYNC_MUTEX) {
- return(os_event_reset(((mutex_t *) object)->event));
+ return(((mutex_t *) cell->wait_object)->event);
} else if (type == RW_LOCK_WAIT_EX) {
- return(os_event_reset(
- ((rw_lock_t *) object)->wait_ex_event));
+ return(((rw_lock_t *) cell->wait_object)->wait_ex_event);
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
} else if (type == RW_LOCK_SHARED) {
- return(os_event_reset(((rw_lock_t *) object)->s_event));
+ return(((rw_lock_t *) cell->wait_object)->s_event);
} else { /* RW_LOCK_EX */
- return(os_event_reset(((rw_lock_t *) object)->x_event));
+ return(((rw_lock_t *) cell->wait_object)->x_event);
+#else
+ } else { /* RW_LOCK_SHARED and RW_LOCK_EX wait on the same event */
+ return(((rw_lock_t *) cell->wait_object)->event);
+#endif
}
}
@@ -332,6 +358,7 @@ sync_array_reserve_cell(
ulint* index) /* out: index of the reserved cell */
{
sync_cell_t* cell;
+ os_event_t event;
ulint i;
ut_a(object);
@@ -370,8 +397,8 @@ sync_array_reserve_cell(
/* Make sure the event is reset and also store
the value of signal_count at which the event
was reset. */
- cell->signal_count = sync_cell_event_reset(type,
- object);
+ event = sync_cell_get_event(cell);
+ cell->signal_count = os_event_reset(event);
cell->reservation_time = time(NULL);
@@ -411,16 +438,7 @@ sync_array_wait_event(
ut_a(!cell->waiting);
ut_ad(os_thread_get_curr_id() == cell->thread);
- if (cell->request_type == SYNC_MUTEX) {
- event = ((mutex_t*) cell->wait_object)->event;
- } else if (cell->request_type == RW_LOCK_WAIT_EX) {
- event = ((rw_lock_t*) cell->wait_object)->wait_ex_event;
- } else if (cell->request_type == RW_LOCK_SHARED) {
- event = ((rw_lock_t*) cell->wait_object)->s_event;
- } else {
- event = ((rw_lock_t*) cell->wait_object)->x_event;
- }
-
+ event = sync_cell_get_event(cell);
cell->waiting = TRUE;
#ifdef UNIV_SYNC_DEBUG
@@ -512,12 +530,22 @@ sync_array_cell_print(
}
fprintf(file,
- "number of readers %lu, s_waiters flag %lu, x_waiters flag %lu\n"
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
+ "number of readers %lu, s_waiters flag %lu, x_waiters flag %lu, "
+#else
+ "number of readers %lu, waiters flag %lu, "
+#endif
+ "lock_word: %lx\n"
"Last time read locked in file %s line %lu\n"
"Last time write locked in file %s line %lu\n",
- (ulong) rwlock->reader_count,
+ (ulong) rw_lock_get_reader_count(rwlock),
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
(ulong) rwlock->s_waiters,
(ulong) (rwlock->x_waiters || rwlock->wait_ex_waiters),
+#else
+ (ulong) rwlock->waiters,
+#endif
+ rwlock->lock_word,
rwlock->last_s_file_name,
(ulong) rwlock->last_s_line,
rwlock->last_x_file_name,
@@ -776,28 +804,30 @@ sync_arr_cell_can_wake_up(
return(TRUE);
}
- } else if (cell->request_type == RW_LOCK_EX
- || cell->request_type == RW_LOCK_WAIT_EX) {
+ } else if (cell->request_type == RW_LOCK_EX) {
lock = cell->wait_object;
- if (rw_lock_get_reader_count(lock) == 0
- && rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED) {
+ if (lock->lock_word > 0) {
+ /* Either unlocked or only read locked. */
return(TRUE);
}
- if (rw_lock_get_reader_count(lock) == 0
- && rw_lock_get_writer(lock) == RW_LOCK_WAIT_EX
- && os_thread_eq(lock->writer_thread, cell->thread)) {
+ } else if (cell->request_type == RW_LOCK_WAIT_EX) {
+
+ lock = cell->wait_object;
+
+ /* lock_word == 0 means all readers have left */
+ if (lock->lock_word == 0) {
return(TRUE);
}
-
} else if (cell->request_type == RW_LOCK_SHARED) {
lock = cell->wait_object;
- if (rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED) {
+ /* lock_word > 0 means no writer or reserved writer */
+ if (lock->lock_word > 0) {
return(TRUE);
}
@@ -843,7 +873,7 @@ sync_array_object_signalled(
sync_array_t* arr) /* in: wait array */
{
#ifdef HAVE_GCC_ATOMIC_BUILTINS
- __sync_fetch_and_add(&(arr->sg_count),1);
+ (void) os_atomic_increment(&arr->sg_count, 1);
#else
sync_array_enter(arr);
@@ -870,6 +900,7 @@ sync_arr_wake_threads_if_sema_free(void)
sync_cell_t* cell;
ulint count;
ulint i;
+ os_event_t event;
sync_array_enter(arr);
@@ -879,40 +910,20 @@ sync_arr_wake_threads_if_sema_free(void)
while (count < arr->n_reserved) {
cell = sync_array_get_nth_cell(arr, i);
+ i++;
- if (cell->wait_object != NULL) {
-
+ if (cell->wait_object == NULL) {
+ continue;
+ }
count++;
if (sync_arr_cell_can_wake_up(cell)) {
- if (cell->request_type == SYNC_MUTEX) {
- mutex_t* mutex;
-
- mutex = cell->wait_object;
- os_event_set(mutex->event);
- } else if (cell->request_type
- == RW_LOCK_WAIT_EX) {
- rw_lock_t* lock;
-
- lock = cell->wait_object;
- os_event_set(lock->wait_ex_event);
- } else if (cell->request_type
- == RW_LOCK_SHARED) {
- rw_lock_t* lock;
+ event = sync_cell_get_event(cell);
- lock = cell->wait_object;
- os_event_set(lock->s_event);
- } else {
- rw_lock_t* lock;
-
- lock = cell->wait_object;
- os_event_set(lock->x_event);
- }
- }
+ os_event_set(event);
}
- i++;
}
sync_array_exit(arr);
@@ -1032,4 +1043,3 @@ sync_array_print_info(
sync_array_exit(arr);
}
-
diff --git a/sync/sync0rw.c b/sync/sync0rw.c
index b66ec2389ff..556e46a2ca1 100644
--- a/sync/sync0rw.c
+++ b/sync/sync0rw.c
@@ -1,8 +1,31 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 2008, Google Inc.
+
+Portions of this file contain modifications contributed and copyrighted by
+Google, Inc. Those modifications are gratefully acknowledged and are described
+briefly in the InnoDB documentation. The contributions by Google are
+incorporated with their permission, and subject to the conditions contained in
+the file COPYING.Google.
+
+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
+
+*****************************************************************************/
+
/******************************************************
The read-write lock (for thread synchronization)
-(c) 1995 Innobase Oy
-
Created 9/11/1995 Heikki Tuuri
*******************************************************/
@@ -15,35 +38,125 @@ Created 9/11/1995 Heikki Tuuri
#include "mem0mem.h"
#include "srv0srv.h"
-/* number of system calls made during shared latching */
-UNIV_INTERN ulint rw_s_system_call_count = 0;
+/*
+ IMPLEMENTATION OF THE RW_LOCK
+ =============================
+The status of a rw_lock is held in lock_word. The initial value of lock_word is
+X_LOCK_DECR. lock_word is decremented by 1 for each s-lock and by X_LOCK_DECR
+for each x-lock. This describes the lock state for each value of lock_word:
+
+lock_word == X_LOCK_DECR: Unlocked.
+0 < lock_word < X_LOCK_DECR: Read locked, no waiting writers.
+ (X_LOCK_DECR - lock_word) is the
+ number of readers that hold the lock.
+lock_word == 0: Write locked
+-X_LOCK_DECR < lock_word < 0: Read locked, with a waiting writer.
+ (-lock_word) is the number of readers
+ that hold the lock.
+lock_word <= -X_LOCK_DECR: Recursively write locked. lock_word has been
+ decremented by X_LOCK_DECR once for each lock,
+ so the number of locks is:
+ ((-lock_word) / X_LOCK_DECR) + 1
+When lock_word <= -X_LOCK_DECR, we also know that lock_word % X_LOCK_DECR == 0:
+other values of lock_word are invalid.
+
+The lock_word is always read and updated atomically and consistently, so that
+it always represents the state of the lock, and the state of the lock changes
+with a single atomic operation. This lock_word holds all of the information
+that a thread needs in order to determine if it is eligible to gain the lock
+or if it must spin or sleep. The one exception to this is that writer_thread
+must be verified before recursive write locks: to solve this scenario, we make
+writer_thread readable by all threads, but only writeable by the x-lock holder.
+
+The other members of the lock obey the following rules to remain consistent:
+
+recursive: This and the writer_thread field together control the
+ behaviour of recursive x-locking.
+ lock->recursive must be FALSE in following states:
+ 1) The writer_thread contains garbage i.e.: the
+ lock has just been initialized.
+ 2) The lock is not x-held and there is no
+ x-waiter waiting on WAIT_EX event.
+ 3) The lock is x-held or there is an x-waiter
+ waiting on WAIT_EX event but the 'pass' value
+ is non-zero.
+ lock->recursive is TRUE iff:
+ 1) The lock is x-held or there is an x-waiter
+ waiting on WAIT_EX event and the 'pass' value
+ is zero.
+ This flag must be set after the writer_thread field
+ has been updated with a memory ordering barrier.
+ It is unset before the lock_word has been incremented.
+writer_thread: Is used only in recursive x-locking. Can only be safely
+ read iff lock->recursive flag is TRUE.
+ This field is uninitialized at lock creation time and
+ is updated atomically when x-lock is acquired or when
+ move_ownership is called. A thread is only allowed to
+ set the value of this field to it's thread_id i.e.: a
+ thread cannot set writer_thread to some other thread's
+ id.
+waiters: May be set to 1 anytime, but to avoid unnecessary wake-up
+ signals, it should only be set to 1 when there are threads
+ waiting on event. Must be 1 when a writer starts waiting to
+ ensure the current x-locking thread sends a wake-up signal
+ during unlock. May only be reset to 0 immediately before a
+ a wake-up signal is sent to event. On most platforms, a
+ memory barrier is required after waiters is set, and before
+ verifying lock_word is still held, to ensure some unlocker
+ really does see the flags new value.
+event: Threads wait on event for read or writer lock when another
+ thread has an x-lock or an x-lock reservation (wait_ex). A
+ thread may only wait on event after performing the following
+ actions in order:
+ (1) Record the counter value of event (with os_event_reset).
+ (2) Set waiters to 1.
+ (3) Verify lock_word <= 0.
+ (1) must come before (2) to ensure signal is not missed.
+ (2) must come before (3) to ensure a signal is sent.
+ These restrictions force the above ordering.
+ Immediately before sending the wake-up signal, we should:
+ (1) Verify lock_word == X_LOCK_DECR (unlocked)
+ (2) Reset waiters to 0.
+wait_ex_event: A thread may only wait on the wait_ex_event after it has
+ performed the following actions in order:
+ (1) Decrement lock_word by X_LOCK_DECR.
+ (2) Record counter value of wait_ex_event (os_event_reset,
+ called from sync_array_reserve_cell).
+ (3) Verify that lock_word < 0.
+ (1) must come first to ensures no other threads become reader
+ or next writer, and notifies unlocker that signal must be sent.
+ (2) must come before (3) to ensure the signal is not missed.
+ These restrictions force the above ordering.
+ Immediately before sending the wake-up signal, we should:
+ Verify lock_word == 0 (waiting thread holds x_lock)
+*/
+
/* number of spin waits on rw-latches,
resulted during shared (read) locks */
-UNIV_INTERN ulint rw_s_spin_wait_count = 0;
+UNIV_INTERN ib_int64_t rw_s_spin_wait_count = 0;
+UNIV_INTERN ib_int64_t rw_s_spin_round_count = 0;
/* number of OS waits on rw-latches,
resulted during shared (read) locks */
-UNIV_INTERN ulint rw_s_os_wait_count = 0;
+UNIV_INTERN ib_int64_t rw_s_os_wait_count = 0;
/* number of unlocks (that unlock shared locks),
set only when UNIV_SYNC_PERF_STAT is defined */
-UNIV_INTERN ulint rw_s_exit_count = 0;
-
-/* number of system calls made during exclusive latching */
-UNIV_INTERN ulint rw_x_system_call_count = 0;
+UNIV_INTERN ib_int64_t rw_s_exit_count = 0;
/* number of spin waits on rw-latches,
resulted during exclusive (write) locks */
-UNIV_INTERN ulint rw_x_spin_wait_count = 0;
+UNIV_INTERN ib_int64_t rw_x_spin_wait_count = 0;
+UNIV_INTERN ib_int64_t rw_x_spin_round_count = 0;
/* number of OS waits on rw-latches,
resulted during exclusive (write) locks */
-UNIV_INTERN ulint rw_x_os_wait_count = 0;
+UNIV_INTERN ib_int64_t rw_x_os_wait_count = 0;
/* number of unlocks (that unlock exclusive locks),
set only when UNIV_SYNC_PERF_STAT is defined */
-UNIV_INTERN ulint rw_x_exit_count = 0;
+UNIV_INTERN ib_int64_t rw_x_exit_count = 0;
/* The global list of rw-locks */
UNIV_INTERN rw_lock_list_t rw_lock_list;
@@ -114,34 +227,45 @@ rw_lock_create_func(
const char* cmutex_name, /* in: mutex name */
#endif /* UNIV_DEBUG */
const char* cfile_name, /* in: file name where created */
- ulint cline) /* in: file line where created */
+ ulint cline) /* in: file line where created */
{
/* If this is the very first time a synchronization object is
created, then the following call initializes the sync system. */
-#ifndef HAVE_GCC_ATOMIC_BUILTINS
+#ifndef INNODB_RW_LOCKS_USE_ATOMICS
mutex_create(rw_lock_get_mutex(lock), SYNC_NO_ORDER_CHECK);
lock->mutex.cfile_name = cfile_name;
lock->mutex.cline = cline;
-#if defined UNIV_DEBUG && !defined UNIV_HOTBACKUP
+# if defined UNIV_DEBUG && !defined UNIV_HOTBACKUP
lock->mutex.cmutex_name = cmutex_name;
lock->mutex.mutex_type = 1;
-#endif /* UNIV_DEBUG && !UNIV_HOTBACKUP */
-#endif /* !HAVE_GCC_ATOMIC_BUILTINS */
-
-#ifdef HAVE_GCC_ATOMIC_BUILTINS
- lock->lock_word = RW_LOCK_BIAS;
-#endif
- rw_lock_set_s_waiters(lock, 0);
- rw_lock_set_x_waiters(lock, 0);
- rw_lock_set_wx_waiters(lock, 0);
- rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED);
+# endif /* UNIV_DEBUG && !UNIV_HOTBACKUP */
+
+#else /* INNODB_RW_LOCKS_USE_ATOMICS */
+# ifdef UNIV_DEBUG
+ UT_NOT_USED(cmutex_name);
+# endif
+#endif /* INNODB_RW_LOCKS_USE_ATOMICS */
+
+ lock->lock_word = X_LOCK_DECR;
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
+ lock->s_waiters = 0;
+ lock->x_waiters = 0;
+ lock->wait_ex_waiters = 0;
+ lock->writer = RW_LOCK_NOT_LOCKED;
lock->writer_count = 0;
- rw_lock_set_reader_count(lock, 0);
-
+ lock->reader_count = 0;
lock->writer_is_wait_ex = FALSE;
+#else
+ lock->waiters = 0;
+#endif
+
+ /* We set this value to signify that lock->writer_thread
+ contains garbage at initialization and cannot be used for
+ recursive x-locking. */
+ lock->recursive = FALSE;
#ifdef UNIV_SYNC_DEBUG
UT_LIST_INIT(lock->debug_list);
@@ -154,12 +278,17 @@ rw_lock_create_func(
lock->cfile_name = cfile_name;
lock->cline = (unsigned int) cline;
+ lock->count_os_wait = 0;
lock->last_s_file_name = "not yet reserved";
lock->last_x_file_name = "not yet reserved";
lock->last_s_line = 0;
lock->last_x_line = 0;
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
lock->s_event = os_event_create(NULL);
lock->x_event = os_event_create(NULL);
+#else
+ lock->event = os_event_create(NULL);
+#endif
lock->wait_ex_event = os_event_create(NULL);
mutex_enter(&rw_lock_list_mutex);
@@ -185,21 +314,30 @@ rw_lock_free(
rw_lock_t* lock) /* in: rw-lock */
{
ut_ad(rw_lock_validate(lock));
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
ut_a(rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED);
ut_a(rw_lock_get_s_waiters(lock) == 0);
ut_a(rw_lock_get_x_waiters(lock) == 0);
ut_a(rw_lock_get_wx_waiters(lock) == 0);
ut_a(rw_lock_get_reader_count(lock) == 0);
+#else
+ ut_a(lock->lock_word == X_LOCK_DECR);
+#endif
lock->magic_n = 0;
-#ifndef HAVE_GCC_ATOMIC_BUILTINS
+#ifndef INNODB_RW_LOCKS_USE_ATOMICS
mutex_free(rw_lock_get_mutex(lock));
-#endif
+#endif /* INNODB_RW_LOCKS_USE_ATOMICS */
mutex_enter(&rw_lock_list_mutex);
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
os_event_free(lock->s_event);
os_event_free(lock->x_event);
+#else
+ os_event_free(lock->event);
+#endif
+
os_event_free(lock->wait_ex_event);
if (UT_LIST_GET_PREV(list, lock)) {
@@ -218,44 +356,30 @@ rw_lock_free(
/**********************************************************************
Checks that the rw-lock has been initialized and that there are no
simultaneous shared and exclusive locks. */
-/* MEMO: If HAVE_GCC_ATOMIC_BUILTINS, we should use this function statically. */
-
UNIV_INTERN
ibool
rw_lock_validate(
/*=============*/
rw_lock_t* lock)
{
- ulint tmp;
ut_a(lock);
-#ifndef HAVE_GCC_ATOMIC_BUILTINS
- mutex_enter(rw_lock_get_mutex(lock));
-#endif
-
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
ut_a(lock->magic_n == RW_LOCK_MAGIC_N);
-#ifndef HAVE_GCC_ATOMIC_BUILTINS
- /* It is dynamic combination */
- ut_a((rw_lock_get_reader_count(lock) == 0)
- || (rw_lock_get_writer(lock) != RW_LOCK_EX));
-#endif
- tmp = rw_lock_get_writer(lock);
- ut_a((tmp == RW_LOCK_EX)
- || (tmp == RW_LOCK_WAIT_EX)
- || (tmp == RW_LOCK_NOT_LOCKED));
- tmp = rw_lock_get_s_waiters(lock);
- ut_a((tmp == 0) || (tmp == 1));
- tmp = rw_lock_get_x_waiters(lock);
- ut_a((tmp == 0) || (tmp == 1));
- tmp = rw_lock_get_wx_waiters(lock);
- ut_a((tmp == 0) || (tmp == 1));
-#ifndef HAVE_GCC_ATOMIC_BUILTINS
- /* It is dynamic combination */
- ut_a((lock->writer != RW_LOCK_EX) || (lock->writer_count > 0));
-#endif
-#ifndef HAVE_GCC_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
+ ulint waiters = rw_lock_get_s_waiters(lock);
+ ut_a(waiters == 0 || waiters == 1);
+ waiters = rw_lock_get_x_waiters(lock);
+ ut_a(waiters == 0 || waiters == 1);
+ waiters = rw_lock_get_wx_waiters(lock);
+ ut_a(waiters == 0 || waiters == 1);
+#else
+ ulint waiters = rw_lock_get_waiters(lock);
+ lint lock_word = lock->lock_word;
+
+ ut_a(lock->magic_n == RW_LOCK_MAGIC_N);
+ ut_a(waiters == 0 || waiters == 1);
+ ut_a(lock_word > -X_LOCK_DECR ||(-lock_word) % X_LOCK_DECR == 0);
#endif
return(TRUE);
@@ -278,19 +402,20 @@ rw_lock_s_lock_spin(
ulint line) /* in: line where requested */
{
ulint index; /* index of the reserved wait cell */
- ulint i; /* spin round count */
+ ulint i = 0; /* spin round count */
ut_ad(rw_lock_validate(lock));
+ rw_s_spin_wait_count++; /* Count calls to this function */
lock_loop:
- i = 0;
-spin_loop:
- rw_s_spin_wait_count++;
/* Spin waiting for the writer field to become free */
-
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
while (i < SYNC_SPIN_ROUNDS
&& rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED) {
+#else
+ while (i < SYNC_SPIN_ROUNDS && lock->lock_word <= 0) {
+#endif
if (srv_spin_wait_delay) {
ut_delay(ut_rnd_interval(0, srv_spin_wait_delay));
}
@@ -311,56 +436,48 @@ spin_loop:
lock->cfile_name, (ulong) lock->cline, (ulong) i);
}
-#ifndef HAVE_GCC_ATOMIC_BUILTINS
- mutex_enter(rw_lock_get_mutex(lock));
-#endif
-
/* We try once again to obtain the lock */
-
if (TRUE == rw_lock_s_lock_low(lock, pass, file_name, line)) {
-#ifndef HAVE_GCC_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-#endif
+ rw_s_spin_round_count += i;
return; /* Success */
} else {
-#ifdef HAVE_GCC_ATOMIC_BUILTINS
- /* like sync0sync.c doing */
- i++;
if (i < SYNC_SPIN_ROUNDS) {
- goto spin_loop;
+ goto lock_loop;
}
-#endif
- /* If we get here, locking did not succeed, we may
- suspend the thread to wait in the wait array */
- rw_s_system_call_count++;
+ rw_s_spin_round_count += i;
sync_array_reserve_cell(sync_primary_wait_array,
lock, RW_LOCK_SHARED,
file_name, line,
&index);
- rw_lock_set_s_waiters(lock, 1);
+ /* Set waiters before checking lock_word to ensure wake-up
+ signal is sent. This may lead to some unnecessary signals. */
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
+ rw_lock_set_s_waiter_flag(lock);
+#else
+ rw_lock_set_waiter_flag(lock);
+#endif
-#ifdef HAVE_GCC_ATOMIC_BUILTINS
- /* like sync0sync.c doing */
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
for (i = 0; i < 4; i++) {
- if (TRUE == rw_lock_s_lock_low(lock, pass, file_name, line)) {
- sync_array_free_cell(sync_primary_wait_array, index);
- return; /* Success */
- }
+#endif
+ if (TRUE == rw_lock_s_lock_low(lock, pass, file_name, line)) {
+ sync_array_free_cell(sync_primary_wait_array, index);
+ return; /* Success */
+ }
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
}
/* If wait_ex_waiter stalls, wakes it. */
- if (lock->wait_ex_waiters && lock->lock_word == RW_LOCK_BIAS) {
- rw_lock_set_wx_waiters(lock, 0);
+ if (lock->reader_count == 0
+ && __sync_lock_test_and_set(&lock->wait_ex_waiters, 0)) {
os_event_set(lock->wait_ex_event);
sync_array_object_signalled(sync_primary_wait_array);
}
-#else
- mutex_exit(rw_lock_get_mutex(lock));
#endif
if (srv_print_latch_waits) {
@@ -372,11 +489,13 @@ spin_loop:
(ulong) lock->cline);
}
- rw_s_system_call_count++;
+ /* these stats may not be accurate */
+ lock->count_os_wait++;
rw_s_os_wait_count++;
sync_array_wait_event(sync_primary_wait_array, index);
+ i = 0;
goto lock_loop;
}
}
@@ -398,46 +517,111 @@ rw_lock_x_lock_move_ownership(
{
ut_ad(rw_lock_is_locked(lock, RW_LOCK_EX));
-#ifndef HAVE_GCC_ATOMIC_BUILTINS
- mutex_enter(&(lock->mutex));
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
+ lock->writer_thread = os_thread_get_curr_id();
+ lock->recursive = TRUE;
+#else
+ rw_lock_set_writer_id_and_recursion_flag(lock, TRUE);
#endif
+}
- lock->writer_thread = os_thread_get_curr_id();
+/**********************************************************************
+Function for the next writer to call. Waits for readers to exit.
+The caller must have already decremented lock_word by X_LOCK_DECR.*/
+UNIV_INLINE
+void
+rw_lock_x_lock_wait(
+/*================*/
+ rw_lock_t* lock, /* in: pointer to rw-lock */
+#ifdef UNIV_SYNC_DEBUG
+ ulint pass, /* in: pass value; != 0, if the lock will
+ be passed to another thread to unlock */
+#endif
+ const char* file_name,/* in: file name where lock requested */
+ ulint line) /* in: line where requested */
+{
+ ulint index;
+ ulint i = 0;
- lock->pass = 0;
+ ut_ad(lock->lock_word <= 0);
-#ifndef HAVE_GCC_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-#else
- __sync_synchronize();
+ while (lock->lock_word < 0) {
+ if (srv_spin_wait_delay) {
+ ut_delay(ut_rnd_interval(0, srv_spin_wait_delay));
+ }
+ if(i < SYNC_SPIN_ROUNDS) {
+ i++;
+ continue;
+ }
+
+ /* If there is still a reader, then go to sleep.*/
+ rw_x_spin_round_count += i;
+ i = 0;
+ sync_array_reserve_cell(sync_primary_wait_array,
+ lock,
+ RW_LOCK_WAIT_EX,
+ file_name, line,
+ &index);
+ /* Check lock_word to ensure wake-up isn't missed.*/
+ if(lock->lock_word < 0) {
+
+ /* these stats may not be accurate */
+ lock->count_os_wait++;
+ rw_x_os_wait_count++;
+
+ /* Add debug info as it is needed to detect possible
+ deadlock. We must add info for WAIT_EX thread for
+ deadlock detection to work properly. */
+#ifdef UNIV_SYNC_DEBUG
+ rw_lock_add_debug_info(lock, pass, RW_LOCK_WAIT_EX,
+ file_name, line);
+#endif
+
+ sync_array_wait_event(sync_primary_wait_array,
+ index);
+#ifdef UNIV_SYNC_DEBUG
+ rw_lock_remove_debug_info(lock, pass,
+ RW_LOCK_WAIT_EX);
#endif
+ /* It is possible to wake when lock_word < 0.
+ We must pass the while-loop check to proceed.*/
+ } else {
+ sync_array_free_cell(sync_primary_wait_array,
+ index);
+ }
+ }
+ rw_x_spin_round_count += i;
}
/**********************************************************************
Low-level function for acquiring an exclusive lock. */
UNIV_INLINE
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
ulint
+#else
+ibool
+#endif
rw_lock_x_lock_low(
/*===============*/
/* out: RW_LOCK_NOT_LOCKED if did
- not succeed, RW_LOCK_EX if success,
- RW_LOCK_WAIT_EX, if got wait reservation */
+ not succeed, RW_LOCK_EX if success. */
rw_lock_t* lock, /* in: pointer to rw-lock */
ulint pass, /* in: pass value; != 0, if the lock will
be passed to another thread to unlock */
const char* file_name,/* in: file name where lock requested */
ulint line) /* in: line where requested */
{
-#ifdef HAVE_GCC_ATOMIC_BUILTINS
os_thread_id_t curr_thread = os_thread_get_curr_id();
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
+retry_writer:
/* try to lock writer */
if(__sync_lock_test_and_set(&(lock->writer),RW_LOCK_EX)
== RW_LOCK_NOT_LOCKED) {
/* success */
/* obtain RW_LOCK_WAIT_EX right */
lock->writer_thread = curr_thread;
- lock->pass = pass;
+ lock->recursive = pass ? FALSE : TRUE;
lock->writer_is_wait_ex = TRUE;
/* atomic operation may be safer about memory order. */
__sync_synchronize();
@@ -457,9 +641,9 @@ rw_lock_x_lock_low(
retry_x_lock:
/* try x-lock */
if(__sync_sub_and_fetch(&(lock->lock_word),
- RW_LOCK_BIAS) == 0) {
+ X_LOCK_DECR) == 0) {
/* success */
- lock->pass = pass;
+ lock->recursive = pass ? FALSE : TRUE;
lock->writer_is_wait_ex = FALSE;
__sync_fetch_and_add(&(lock->writer_count),1);
@@ -475,7 +659,7 @@ retry_x_lock:
/* Locking succeeded, we may return */
return(RW_LOCK_EX);
} else if(__sync_fetch_and_add(&(lock->lock_word),
- RW_LOCK_BIAS) == 0) {
+ X_LOCK_DECR) == 0) {
/* retry x-lock */
goto retry_x_lock;
}
@@ -487,7 +671,7 @@ retry_x_lock:
case RW_LOCK_EX:
/* already have x-lock */
- if ((lock->pass == 0)&&(pass == 0)) {
+ if (lock->recursive && (pass == 0)) {
__sync_fetch_and_add(&(lock->writer_count),1);
#ifdef UNIV_SYNC_DEBUG
@@ -506,95 +690,51 @@ retry_x_lock:
break;
- default: /* ??? */
- return(RW_LOCK_NOT_LOCKED);
+ default: /* RW_LOCK_NOT_LOCKED? maybe impossible */
+ goto retry_writer;
}
-#else /* HAVE_GCC_ATOMIC_BUILTINS */
-
- ut_ad(mutex_own(rw_lock_get_mutex(lock)));
- if (rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED) {
+ /* Locking did not succeed */
+ return(RW_LOCK_NOT_LOCKED);
+#else
+ if (rw_lock_lock_word_decr(lock, X_LOCK_DECR)) {
- if (rw_lock_get_reader_count(lock) == 0) {
+ /* lock->recursive also tells us if the writer_thread
+ field is stale or active. As we are going to write
+ our own thread id in that field it must be that the
+ current writer_thread value is not active. */
+ ut_a(!lock->recursive);
- rw_lock_set_writer(lock, RW_LOCK_EX);
- lock->writer_thread = os_thread_get_curr_id();
- lock->writer_count++;
- lock->pass = pass;
+ /* Decrement occurred: we are writer or next-writer. */
+ rw_lock_set_writer_id_and_recursion_flag(lock,
+ pass ? FALSE : TRUE);
+ rw_lock_x_lock_wait(lock,
#ifdef UNIV_SYNC_DEBUG
- rw_lock_add_debug_info(lock, pass, RW_LOCK_EX,
- file_name, line);
+ pass,
#endif
- lock->last_x_file_name = file_name;
- lock->last_x_line = (unsigned int) line;
+ file_name, line);
- /* Locking succeeded, we may return */
- return(RW_LOCK_EX);
+ } else {
+ /* Decrement failed: relock or failed lock */
+ if (!pass && lock->recursive
+ && os_thread_eq(lock->writer_thread, curr_thread)) {
+ /* Relock */
+ lock->lock_word -= X_LOCK_DECR;
} else {
- /* There are readers, we have to wait */
- rw_lock_set_writer(lock, RW_LOCK_WAIT_EX);
- lock->writer_thread = os_thread_get_curr_id();
- lock->pass = pass;
- lock->writer_is_wait_ex = TRUE;
-
-#ifdef UNIV_SYNC_DEBUG
- rw_lock_add_debug_info(lock, pass, RW_LOCK_WAIT_EX,
- file_name, line);
-#endif
-
- return(RW_LOCK_WAIT_EX);
+ /* Another thread locked before us */
+ return(FALSE);
}
-
- } else if ((rw_lock_get_writer(lock) == RW_LOCK_WAIT_EX)
- && os_thread_eq(lock->writer_thread,
- os_thread_get_curr_id())) {
-
- if (rw_lock_get_reader_count(lock) == 0) {
-
- rw_lock_set_writer(lock, RW_LOCK_EX);
- lock->writer_count++;
- lock->pass = pass;
- lock->writer_is_wait_ex = FALSE;
-
+ }
#ifdef UNIV_SYNC_DEBUG
- rw_lock_remove_debug_info(lock, pass, RW_LOCK_WAIT_EX);
- rw_lock_add_debug_info(lock, pass, RW_LOCK_EX,
- file_name, line);
+ rw_lock_add_debug_info(lock, pass, RW_LOCK_EX,
+ file_name, line);
#endif
+ lock->last_x_file_name = file_name;
+ lock->last_x_line = (unsigned int) line;
- lock->last_x_file_name = file_name;
- lock->last_x_line = (unsigned int) line;
-
- /* Locking succeeded, we may return */
- return(RW_LOCK_EX);
- }
-
- return(RW_LOCK_WAIT_EX);
-
- } else if ((rw_lock_get_writer(lock) == RW_LOCK_EX)
- && os_thread_eq(lock->writer_thread,
- os_thread_get_curr_id())
- && (lock->pass == 0)
- && (pass == 0)) {
-
- lock->writer_count++;
-
-#ifdef UNIV_SYNC_DEBUG
- rw_lock_add_debug_info(lock, pass, RW_LOCK_EX, file_name,
- line);
+ return(TRUE);
#endif
-
- lock->last_x_file_name = file_name;
- lock->last_x_line = (unsigned int) line;
-
- /* Locking succeeded, we may return */
- return(RW_LOCK_EX);
- }
-#endif /* HAVE_GCC_ATOMIC_BUILTINS */
-
- /* Locking did not succeed */
- return(RW_LOCK_NOT_LOCKED);
}
/**********************************************************************
@@ -617,43 +757,44 @@ rw_lock_x_lock_func(
ulint line) /* in: line where requested */
{
ulint index; /* index of the reserved wait cell */
+ ulint i; /* spin round count */
+ ibool spinning = FALSE;
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
ulint state = RW_LOCK_NOT_LOCKED; /* lock state acquired */
-#ifdef HAVE_GCC_ATOMIC_BUILTINS
ulint prev_state = RW_LOCK_NOT_LOCKED;
#endif
- ulint i; /* spin round count */
ut_ad(rw_lock_validate(lock));
-lock_loop:
i = 0;
-#ifdef HAVE_GCC_ATOMIC_BUILTINS
+lock_loop:
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
prev_state = state;
-#else
- /* Acquire the mutex protecting the rw-lock fields */
- mutex_enter_fast(&(lock->mutex));
-#endif
-
state = rw_lock_x_lock_low(lock, pass, file_name, line);
-#ifdef HAVE_GCC_ATOMIC_BUILTINS
+lock_loop_2:
if (state != prev_state) i=0; /* if progress, reset counter. */
-#else
- mutex_exit(&(lock->mutex));
-#endif
-spin_loop:
if (state == RW_LOCK_EX) {
+#else
+ if (rw_lock_x_lock_low(lock, pass, file_name, line)) {
+#endif
+ rw_x_spin_round_count += i;
return; /* Locking succeeded */
- } else if (state == RW_LOCK_NOT_LOCKED) {
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
+ } else if (state == RW_LOCK_WAIT_EX) {
- /* Spin waiting for the writer field to become free */
+ if (!spinning) {
+ spinning = TRUE;
+ rw_x_spin_wait_count++;
+ }
+ /* Spin waiting for the reader count field to become zero */
while (i < SYNC_SPIN_ROUNDS
- && rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED) {
+ && lock->lock_word != X_LOCK_DECR) {
if (srv_spin_wait_delay) {
ut_delay(ut_rnd_interval(0,
srv_spin_wait_delay));
@@ -663,17 +804,24 @@ spin_loop:
}
if (i == SYNC_SPIN_ROUNDS) {
os_thread_yield();
+ } else {
+ goto lock_loop;
}
- } else if (state == RW_LOCK_WAIT_EX) {
+#endif
+ } else {
- /* Spin waiting for the reader count field to become zero */
+ if (!spinning) {
+ spinning = TRUE;
+ rw_x_spin_wait_count++;
+ }
-#ifdef HAVE_GCC_ATOMIC_BUILTINS
- while (lock->lock_word != RW_LOCK_BIAS
+ /* Spin waiting for the lock_word to become free */
+ while (i < SYNC_SPIN_ROUNDS
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
+ && rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED) {
#else
- while (rw_lock_get_reader_count(lock) != 0
+ && lock->lock_word <= 0) {
#endif
- && i < SYNC_SPIN_ROUNDS) {
if (srv_spin_wait_delay) {
ut_delay(ut_rnd_interval(0,
srv_spin_wait_delay));
@@ -683,11 +831,13 @@ spin_loop:
}
if (i == SYNC_SPIN_ROUNDS) {
os_thread_yield();
+ } else {
+ goto lock_loop;
}
- } else {
- ut_error;
}
+ rw_x_spin_round_count += i;
+
if (srv_print_latch_waits) {
fprintf(stderr,
"Thread %lu spin wait rw-x-lock at %p"
@@ -696,73 +846,47 @@ spin_loop:
lock->cfile_name, (ulong) lock->cline, (ulong) i);
}
- rw_x_spin_wait_count++;
-
- /* We try once again to obtain the lock. Acquire the mutex protecting
- the rw-lock fields */
-
-#ifdef HAVE_GCC_ATOMIC_BUILTINS
- prev_state = state;
-#else
- mutex_enter(rw_lock_get_mutex(lock));
-#endif
-
- state = rw_lock_x_lock_low(lock, pass, file_name, line);
-
-#ifdef HAVE_GCC_ATOMIC_BUILTINS
- if (state != prev_state) i=0; /* if progress, reset counter. */
-#endif
-
- if (state == RW_LOCK_EX) {
-#ifndef HAVE_GCC_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-#endif
-
- return; /* Locking succeeded */
- }
-
-#ifdef HAVE_GCC_ATOMIC_BUILTINS
- /* like sync0sync.c doing */
- i++;
-
- if (i < SYNC_SPIN_ROUNDS) {
- goto spin_loop;
- }
-#endif
-
- rw_x_system_call_count++;
-
sync_array_reserve_cell(sync_primary_wait_array,
lock,
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
(state == RW_LOCK_WAIT_EX)
- ? RW_LOCK_WAIT_EX :
+ ? RW_LOCK_WAIT_EX : RW_LOCK_EX,
+#else
RW_LOCK_EX,
+#endif
file_name, line,
&index);
+ /* Waiters must be set before checking lock_word, to ensure signal
+ is sent. This could lead to a few unnecessary wake-up signals. */
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
if (state == RW_LOCK_WAIT_EX) {
- rw_lock_set_wx_waiters(lock, 1);
+ rw_lock_set_wx_waiter_flag(lock);
} else {
- rw_lock_set_x_waiters(lock, 1);
+ rw_lock_set_x_waiter_flag(lock);
}
+#else
+ rw_lock_set_waiter_flag(lock);
+#endif
-#ifdef HAVE_GCC_ATOMIC_BUILTINS
- /* like sync0sync.c doing */
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
for (i = 0; i < 4; i++) {
prev_state = state;
state = rw_lock_x_lock_low(lock, pass, file_name, line);
if (state == RW_LOCK_EX) {
sync_array_free_cell(sync_primary_wait_array, index);
return; /* Locking succeeded */
- }
- if (state != prev_state) {
+ } else if (state != prev_state) {
/* retry! */
sync_array_free_cell(sync_primary_wait_array, index);
- goto lock_loop;
+ goto lock_loop_2;
}
}
#else
- mutex_exit(rw_lock_get_mutex(lock));
+ if (rw_lock_x_lock_low(lock, pass, file_name, line)) {
+ sync_array_free_cell(sync_primary_wait_array, index);
+ return; /* Locking succeeded */
+ }
#endif
if (srv_print_latch_waits) {
@@ -773,11 +897,13 @@ spin_loop:
lock->cfile_name, (ulong) lock->cline);
}
- rw_x_system_call_count++;
+ /* these stats may not be accurate */
+ lock->count_os_wait++;
rw_x_os_wait_count++;
sync_array_wait_event(sync_primary_wait_array, index);
+ i = 0;
goto lock_loop;
}
@@ -925,9 +1051,7 @@ rw_lock_own(
ut_ad(lock);
ut_ad(rw_lock_validate(lock));
-#ifndef HAVE_GCC_ATOMIC_BUILTINS
- mutex_enter(&(lock->mutex));
-#endif
+ rw_lock_debug_mutex_enter();
info = UT_LIST_GET_FIRST(lock->debug_list);
@@ -937,9 +1061,7 @@ rw_lock_own(
&& (info->pass == 0)
&& (info->lock_type == lock_type)) {
-#ifndef HAVE_GCC_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-#endif
+ rw_lock_debug_mutex_exit();
/* Found! */
return(TRUE);
@@ -947,9 +1069,7 @@ rw_lock_own(
info = UT_LIST_GET_NEXT(list, info);
}
-#ifndef HAVE_GCC_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-#endif
+ rw_lock_debug_mutex_exit();
return(FALSE);
}
@@ -971,12 +1091,8 @@ rw_lock_is_locked(
ut_ad(lock);
ut_ad(rw_lock_validate(lock));
-#ifndef HAVE_GCC_ATOMIC_BUILTINS
- mutex_enter(&(lock->mutex));
-#endif
-
if (lock_type == RW_LOCK_SHARED) {
- if (lock->reader_count > 0) {
+ if (rw_lock_get_reader_count(lock) > 0) {
ret = TRUE;
}
} else if (lock_type == RW_LOCK_EX) {
@@ -987,10 +1103,6 @@ rw_lock_is_locked(
ut_error;
}
-#ifndef HAVE_GCC_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-#endif
-
return(ret);
}
@@ -1019,29 +1131,31 @@ rw_lock_list_print_info(
count++;
-#ifndef HAVE_GCC_ATOMIC_BUILTINS
+#ifndef INNODB_RW_LOCKS_USE_ATOMICS
mutex_enter(&(lock->mutex));
#endif
-
- if ((rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED)
- || (rw_lock_get_reader_count(lock) != 0)
- || (rw_lock_get_s_waiters(lock) != 0)
- || (rw_lock_get_x_waiters(lock) != 0)
- || (rw_lock_get_wx_waiters(lock) != 0)) {
+ if (lock->lock_word != X_LOCK_DECR) {
fprintf(file, "RW-LOCK: %p ", (void*) lock);
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
if (rw_lock_get_s_waiters(lock)) {
- fputs(" s_waiters for the lock exist,", file);
+ fputs(" s_waiters for the lock exist", file);
}
if (rw_lock_get_x_waiters(lock)) {
- fputs(" x_waiters for the lock exist\n", file);
+ fputs(" x_waiters for the lock exist", file);
}
if (rw_lock_get_wx_waiters(lock)) {
- fputs(" wait_ex_waiters for the lock exist\n", file);
+ fputs(" wait_ex_waiters for the lock exist", file);
+ }
+ putc('\n', file);
+#else
+ if (rw_lock_get_waiters(lock)) {
+ fputs(" Waiters for the lock exist\n", file);
} else {
putc('\n', file);
}
+#endif
info = UT_LIST_GET_FIRST(lock->debug_list);
while (info != NULL) {
@@ -1049,10 +1163,10 @@ rw_lock_list_print_info(
info = UT_LIST_GET_NEXT(list, info);
}
}
-
-#ifndef HAVE_GCC_ATOMIC_BUILTINS
+#ifndef INNODB_RW_LOCKS_USE_ATOMICS
mutex_exit(&(lock->mutex));
#endif
+
lock = UT_LIST_GET_NEXT(list, lock);
}
@@ -1075,23 +1189,29 @@ rw_lock_print(
"RW-LATCH INFO\n"
"RW-LATCH: %p ", (void*) lock);
- if ((rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED)
- || (rw_lock_get_reader_count(lock) != 0)
- || (rw_lock_get_s_waiters(lock) != 0)
- || (rw_lock_get_x_waiters(lock) != 0)
- || (rw_lock_get_wx_waiters(lock) != 0)) {
+#ifndef INNODB_RW_LOCKS_USE_ATOMICS
+ mutex_enter(&(lock->mutex));
+#endif
+ if (lock->lock_word != X_LOCK_DECR) {
+#ifdef INNODB_RW_LOCKS_USE_ATOMICS
if (rw_lock_get_s_waiters(lock)) {
- fputs(" s_waiters for the lock exist,", stderr);
+ fputs(" s_waiters for the lock exist", stderr);
}
if (rw_lock_get_x_waiters(lock)) {
- fputs(" x_waiters for the lock exist\n", stderr);
+ fputs(" x_waiters for the lock exist", stderr);
}
if (rw_lock_get_wx_waiters(lock)) {
- fputs(" wait_ex_waiters for the lock exist\n", stderr);
+ fputs(" wait_ex_waiters for the lock exist", stderr);
+ }
+ putc('\n', stderr);
+#else
+ if (rw_lock_get_waiters(lock)) {
+ fputs(" Waiters for the lock exist\n", stderr);
} else {
putc('\n', stderr);
}
+#endif
info = UT_LIST_GET_FIRST(lock->debug_list);
while (info != NULL) {
@@ -1099,6 +1219,9 @@ rw_lock_print(
info = UT_LIST_GET_NEXT(list, info);
}
}
+#ifndef INNODB_RW_LOCKS_USE_ATOMICS
+ mutex_exit(&(lock->mutex));
+#endif
}
/*************************************************************************
@@ -1147,18 +1270,11 @@ rw_lock_n_locked(void)
lock = UT_LIST_GET_FIRST(rw_lock_list);
while (lock != NULL) {
-#ifndef HAVE_GCC_ATOMIC_BUILTINS
- mutex_enter(rw_lock_get_mutex(lock));
-#endif
- if ((rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED)
- || (rw_lock_get_reader_count(lock) != 0)) {
+ if (lock->lock_word != X_LOCK_DECR) {
count++;
}
-#ifndef HAVE_GCC_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-#endif
lock = UT_LIST_GET_NEXT(list, lock);
}
diff --git a/sync/sync0sync.c b/sync/sync0sync.c
index f8c3cbdf4a8..3b2d033aae5 100644
--- a/sync/sync0sync.c
+++ b/sync/sync0sync.c
@@ -1,8 +1,31 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 2008, Google Inc.
+
+Portions of this file contain modifications contributed and copyrighted by
+Google, Inc. Those modifications are gratefully acknowledged and are described
+briefly in the InnoDB documentation. The contributions by Google are
+incorporated with their permission, and subject to the conditions contained in
+the file COPYING.Google.
+
+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
+
+*****************************************************************************/
+
/******************************************************
Mutex, the basic synchronization primitive
-(c) 1995 Innobase Oy
-
Created 9/5/1995 Heikki Tuuri
*******************************************************/
@@ -138,18 +161,13 @@ Therefore, this thread is guaranteed to catch the os_set_event()
signalled unconditionally at the release of the lock.
Q.E.D. */
-/* The number of system calls made in this module. Intended for performance
-monitoring. */
-
-UNIV_INTERN ulint mutex_system_call_count = 0;
-
/* Number of spin waits on mutexes: for performance monitoring */
/* round=one iteration of a spin loop */
-UNIV_INTERN ulint mutex_spin_round_count = 0;
-UNIV_INTERN ulint mutex_spin_wait_count = 0;
-UNIV_INTERN ulint mutex_os_wait_count = 0;
-UNIV_INTERN ulint mutex_exit_count = 0;
+UNIV_INTERN ib_int64_t mutex_spin_round_count = 0;
+UNIV_INTERN ib_int64_t mutex_spin_wait_count = 0;
+UNIV_INTERN ib_int64_t mutex_os_wait_count = 0;
+UNIV_INTERN ib_int64_t mutex_exit_count = 0;
/* The global array of wait cells for implementation of the database's own
mutexes and read-write locks */
@@ -219,6 +237,8 @@ mutex_create_func(
{
#if defined(_WIN32) && defined(UNIV_CAN_USE_X86_ASSEMBLER)
mutex_reset_lock_word(mutex);
+#elif defined(HAVE_GCC_ATOMIC_BUILTINS)
+ mutex_reset_lock_word(mutex);
#else
os_fast_mutex_init(&(mutex->os_fast_mutex));
mutex->lock_word = 0;
@@ -309,7 +329,9 @@ mutex_free(
os_event_free(mutex->event);
-#if !defined(_WIN32) || !defined(UNIV_CAN_USE_X86_ASSEMBLER)
+#if defined(_WIN32) && defined(UNIV_CAN_USE_X86_ASSEMBLER)
+#elif defined(HAVE_GCC_ATOMIC_BUILTINS)
+#else
os_fast_mutex_free(&(mutex->os_fast_mutex));
#endif
/* If we free the mutex protecting the mutex list (freeing is
@@ -426,6 +448,12 @@ mutex_spin_wait(
#endif /* UNIV_DEBUG && !UNIV_HOTBACKUP */
ut_ad(mutex);
+ /* This update is not thread safe, but we don't mind if the count
+ isn't exact. Moved out of ifdef that follows because we are willing
+ to sacrifice the cost of counting this as the data is valuable.
+ Count the number of calls to mutex_spin_wait. */
+ mutex_spin_wait_count++;
+
mutex_loop:
i = 0;
@@ -438,7 +466,6 @@ mutex_loop:
spin_loop:
#if defined UNIV_DEBUG && !defined UNIV_HOTBACKUP
- mutex_spin_wait_count++;
mutex->count_spin_loop++;
#endif /* UNIV_DEBUG && !UNIV_HOTBACKUP */
@@ -503,8 +530,6 @@ spin_loop:
sync_array_reserve_cell(sync_primary_wait_array, mutex,
SYNC_MUTEX, file_name, line, &index);
- mutex_system_call_count++;
-
/* The memory order of the array reservation and the change in the
waiters field is important: when we suspend a thread, we first
reserve the cell and then set waiters field to 1. When threads are
@@ -551,7 +576,6 @@ spin_loop:
mutex->cfile_name, (ulong) mutex->cline, (ulong) i);
#endif
- mutex_system_call_count++;
mutex_os_wait_count++;
#ifndef UNIV_HOTBACKUP
@@ -1059,6 +1083,7 @@ sync_thread_add_level(
case SYNC_DOUBLEWRITE:
case SYNC_BUF_POOL:
case SYNC_SEARCH_SYS:
+ case SYNC_SEARCH_SYS_CONF:
case SYNC_TRX_LOCK_HEAP:
case SYNC_KERNEL:
case SYNC_IBUF_BITMAP_MUTEX:
@@ -1079,6 +1104,9 @@ sync_thread_add_level(
}
break;
case SYNC_BUF_BLOCK:
+ /* Either the thread must own the buffer pool mutex
+ (buf_pool_mutex), or it is allowed to latch only ONE
+ buffer block (block->mutex or buf_pool_zip_mutex). */
ut_a((sync_thread_levels_contain(array, SYNC_BUF_POOL)
&& sync_thread_levels_g(array, SYNC_BUF_BLOCK - 1))
|| sync_thread_levels_g(array, SYNC_BUF_BLOCK));
@@ -1336,21 +1364,31 @@ sync_print_wait_info(
FILE* file) /* in: file where to print */
{
#ifdef UNIV_SYNC_DEBUG
- fprintf(file, "Mutex exits %lu, rws exits %lu, rwx exits %lu\n",
+ fprintf(file, "Mutex exits %llu, rws exits %llu, rwx exits %llu\n",
mutex_exit_count, rw_s_exit_count, rw_x_exit_count);
#endif
fprintf(file,
- "Mutex spin waits %lu, rounds %lu, OS waits %lu\n"
- "RW-shared spins %lu, OS waits %lu;"
- " RW-excl spins %lu, OS waits %lu\n",
- (ulong) mutex_spin_wait_count,
- (ulong) mutex_spin_round_count,
- (ulong) mutex_os_wait_count,
- (ulong) rw_s_spin_wait_count,
- (ulong) rw_s_os_wait_count,
- (ulong) rw_x_spin_wait_count,
- (ulong) rw_x_os_wait_count);
+ "Mutex spin waits %llu, rounds %llu, OS waits %llu\n"
+ "RW-shared spins %llu, OS waits %llu;"
+ " RW-excl spins %llu, OS waits %llu\n",
+ mutex_spin_wait_count,
+ mutex_spin_round_count,
+ mutex_os_wait_count,
+ rw_s_spin_wait_count,
+ rw_s_os_wait_count,
+ rw_x_spin_wait_count,
+ rw_x_os_wait_count);
+
+ fprintf(file,
+ "Spin rounds per wait: %.2f mutex, %.2f RW-shared, "
+ "%.2f RW-excl\n",
+ (double) mutex_spin_round_count /
+ (mutex_spin_wait_count ? mutex_spin_wait_count : 1),
+ (double) rw_s_spin_round_count /
+ (rw_s_spin_wait_count ? rw_s_spin_wait_count : 1),
+ (double) rw_x_spin_round_count /
+ (rw_x_spin_wait_count ? rw_x_spin_wait_count : 1));
}
/***********************************************************************
diff --git a/thr/thr0loc.c b/thr/thr0loc.c
index e67c0864413..aea1992a921 100644
--- a/thr/thr0loc.c
+++ b/thr/thr0loc.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 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
+
+*****************************************************************************/
+
/******************************************************
The thread local storage
-(c) 1995 Innobase Oy
-
Created 10/5/1995 Heikki Tuuri
*******************************************************/
@@ -72,7 +88,7 @@ try_again:
local = NULL;
HASH_SEARCH(hash, thr_local_hash, os_thread_pf(id),
- thr_local_t*, local, os_thread_eq(local->id, id));
+ thr_local_t*, local,, os_thread_eq(local->id, id));
if (local == NULL) {
mutex_exit(&thr_local_mutex);
@@ -197,7 +213,7 @@ thr_local_free(
/* Look for the local struct in the hash table */
HASH_SEARCH(hash, thr_local_hash, os_thread_pf(id),
- thr_local_t*, local, os_thread_eq(local->id, id));
+ thr_local_t*, local,, os_thread_eq(local->id, id));
if (local == NULL) {
mutex_exit(&thr_local_mutex);
diff --git a/trx/trx0i_s.c b/trx/trx0i_s.c
index 6bb46dd4e58..512e38cc17e 100644
--- a/trx/trx0i_s.c
+++ b/trx/trx0i_s.c
@@ -1,3 +1,21 @@
+/*****************************************************************************
+
+Copyright (c) 2007, 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
+
+*****************************************************************************/
+
/******************************************************
INFORMATION SCHEMA innodb_trx, innodb_locks and
innodb_lock_waits tables fetch code.
@@ -6,8 +24,6 @@ The code below fetches information needed to fill those
3 dynamic tables and uploads it into a "transactions
table cache" for later retrieval.
-(c) 2007 Innobase Oy
-
Created July 17, 2007 Vasil Dimov
*******************************************************/
@@ -393,7 +409,7 @@ fill_trx_row(
if (trx->mysql_thd != NULL) {
row->trx_mysql_thread_id
- = ib_thd_get_thread_id(trx->mysql_thd);
+ = thd_get_thread_id(trx->mysql_thd);
} else {
/* For internal transactions e.g., purge and transactions
being recovered at startup there is no associated MySQL
@@ -821,6 +837,8 @@ search_innodb_locks(
i_s_hash_chain_t*,
/* auxiliary variable */
hash_chain,
+ /* assertion on every traversed item */
+ ,
/* this determines if we have found the lock */
locks_row_eq_lock(hash_chain->value, lock, heap_no));
@@ -952,6 +970,8 @@ add_trx_relevant_locks_to_cache(
requested lock row, or NULL or
undefined */
{
+ ut_ad(mutex_own(&kernel_mutex));
+
/* If transaction is waiting we add the wait lock and all locks
from another transactions that are blocking the wait lock. */
if (trx->que_state == TRX_QUE_LOCK_WAIT) {
@@ -1093,6 +1113,8 @@ fetch_data_into_cache(
i_s_trx_row_t* trx_row;
i_s_locks_row_t* requested_lock_row;
+ ut_ad(mutex_own(&kernel_mutex));
+
trx_i_s_cache_clear(cache);
/* We iterate over the list of all transactions and add each one
diff --git a/trx/trx0purge.c b/trx/trx0purge.c
index 52d3cfc878e..7a2a27a94ff 100644
--- a/trx/trx0purge.c
+++ b/trx/trx0purge.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Purge old versions
-(c) 1996 Innobase Oy
-
Created 3/26/1996 Heikki Tuuri
*******************************************************/
diff --git a/trx/trx0rec.c b/trx/trx0rec.c
index bc7d76c32b5..148f93cdbe7 100644
--- a/trx/trx0rec.c
+++ b/trx/trx0rec.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Transaction undo log record
-(c) 1996 Innobase Oy
-
Created 3/26/1996 Heikki Tuuri
*******************************************************/
diff --git a/trx/trx0roll.c b/trx/trx0roll.c
index b1079eff01d..5f3cb15a254 100644
--- a/trx/trx0roll.c
+++ b/trx/trx0roll.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Transaction rollback
-(c) 1996 Innobase Oy
-
Created 3/26/1996 Heikki Tuuri
*******************************************************/
@@ -171,9 +187,27 @@ trx_rollback_last_sql_stat_for_mysql(
}
/***********************************************************************
-Frees savepoint structs. */
+Frees a single savepoint struct. */
UNIV_INTERN
void
+trx_roll_savepoint_free(
+/*=====================*/
+ trx_t* trx, /* in: transaction handle */
+ trx_named_savept_t* savep) /* in: savepoint to free */
+{
+ ut_a(savep != NULL);
+ ut_a(UT_LIST_GET_LEN(trx->trx_savepoints) > 0);
+
+ UT_LIST_REMOVE(trx_savepoints, trx->trx_savepoints, savep);
+ mem_free(savep->name);
+ mem_free(savep);
+}
+
+/***********************************************************************
+Frees savepoint structs starting from savep, if savep == NULL then
+free all savepoints. */
+
+void
trx_roll_savepoints_free(
/*=====================*/
trx_t* trx, /* in: transaction handle */
@@ -192,9 +226,7 @@ trx_roll_savepoints_free(
while (savep != NULL) {
next_savep = UT_LIST_GET_NEXT(trx_savepoints, savep);
- UT_LIST_REMOVE(trx_savepoints, trx->trx_savepoints, savep);
- mem_free(savep->name);
- mem_free(savep);
+ trx_roll_savepoint_free(trx, savep);
savep = next_savep;
}
@@ -329,8 +361,8 @@ trx_savepoint_for_mysql(
}
/***********************************************************************
-Releases a named savepoint. Savepoints which
-were set after this savepoint are deleted. */
+Releases only the named savepoint. Savepoints which were set after this
+savepoint are left as is. */
UNIV_INTERN
ulint
trx_release_savepoint_for_mysql(
@@ -346,31 +378,16 @@ trx_release_savepoint_for_mysql(
savep = UT_LIST_GET_FIRST(trx->trx_savepoints);
+ /* Search for the savepoint by name and free if found. */
while (savep != NULL) {
if (0 == ut_strcmp(savep->name, savepoint_name)) {
- /* Found */
- break;
+ trx_roll_savepoint_free(trx, savep);
+ return(DB_SUCCESS);
}
savep = UT_LIST_GET_NEXT(trx_savepoints, savep);
}
- if (savep == NULL) {
-
- return(DB_NO_SAVEPOINT);
- }
-
- /* We can now free all savepoints strictly later than this one */
-
- trx_roll_savepoints_free(trx, savep);
-
- /* Now we can free this savepoint too */
-
- UT_LIST_REMOVE(trx_savepoints, trx->trx_savepoints, savep);
-
- mem_free(savep->name);
- mem_free(savep);
-
- return(DB_SUCCESS);
+ return(DB_NO_SAVEPOINT);
}
/***********************************************************************
diff --git a/trx/trx0rseg.c b/trx/trx0rseg.c
index 7f7e3f41f55..db5efd65eb3 100644
--- a/trx/trx0rseg.c
+++ b/trx/trx0rseg.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Rollback segment
-(c) 1996 Innobase Oy
-
Created 3/26/1996 Heikki Tuuri
*******************************************************/
diff --git a/trx/trx0sys.c b/trx/trx0sys.c
index a282cba255f..50fe7003b6e 100644
--- a/trx/trx0sys.c
+++ b/trx/trx0sys.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Transaction system
-(c) 1996 Innobase Oy
-
Created 3/26/1996 Heikki Tuuri
*******************************************************/
diff --git a/trx/trx0trx.c b/trx/trx0trx.c
index 108108d7128..3cf21000f9b 100644
--- a/trx/trx0trx.c
+++ b/trx/trx0trx.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
The transaction
-(c) 1996 Innobase Oy
-
Created 3/26/1996 Heikki Tuuri
*******************************************************/
@@ -34,22 +50,6 @@ UNIV_INTERN sess_t* trx_dummy_sess = NULL;
the kernel mutex */
UNIV_INTERN ulint trx_n_mysql_transactions = 0;
-/**************************************************************************
-Determines if the currently running transaction is in innodb_strict_mode. */
-UNIV_INTERN
-ibool
-trx_is_strict(
-/*==========*/
- /* out: TRUE if strict */
- trx_t* trx) /* in: transaction */
-{
-#ifndef UNIV_HOTBACKUP
- return(trx && trx->mysql_thd && thd_is_strict(trx->mysql_thd));
-#else /* UNIV_HOTBACKUP */
- return(FALSE);
-#endif /* UNIV_HOTBACKUP */
-}
-
/*****************************************************************
Set detailed error message for the transaction. */
UNIV_INTERN
@@ -266,6 +266,10 @@ trx_free(
"InnoDB: inside InnoDB.\n", stderr);
trx_print(stderr, trx, 600);
putc('\n', stderr);
+
+ /* This is an error but not a fatal error. We must keep
+ the counters like srv_conc_n_threads accurate. */
+ srv_conc_force_exit_innodb(trx);
}
if (trx->n_mysql_tables_in_use != 0
@@ -694,6 +698,14 @@ trx_start(
{
ibool ret;
+ /* Update the info whether we should skip XA steps that eat CPU time
+ For the duration of the transaction trx->support_xa is not reread
+ from thd so any changes in the value take effect in the next
+ transaction. This is to avoid a scenario where some undo
+ generated by a transaction, has XA stuff, and other undo,
+ generated by the same transaction, doesn't. */
+ trx->support_xa = thd_supports_xa(trx->mysql_thd);
+
mutex_enter(&kernel_mutex);
ret = trx_start_low(trx, rseg_id);
@@ -921,8 +933,8 @@ trx_commit_off_kernel(
mutex_enter(&kernel_mutex);
}
- /* Free savepoints */
- trx_roll_savepoints_free(trx, NULL);
+ /* Free all savepoints */
+ trx_roll_free_all_savepoints(trx);
trx->conc_state = TRX_NOT_STARTED;
trx->rseg = NULL;
diff --git a/trx/trx0undo.c b/trx/trx0undo.c
index c9021fdb2c9..bb5710aeba9 100644
--- a/trx/trx0undo.c
+++ b/trx/trx0undo.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Transaction undo log
-(c) 1996 Innobase Oy
-
Created 3/26/1996 Heikki Tuuri
*******************************************************/
@@ -427,7 +443,7 @@ trx_undo_seg_create(
if (slot_no == ULINT_UNDEFINED) {
ut_print_timestamp(stderr);
fprintf(stderr,
- "InnoDB: Warning: cannot find a free slot for"
+ " InnoDB: Warning: cannot find a free slot for"
" an undo log. Do you have too\n"
"InnoDB: many active transactions"
" running concurrently?\n");
diff --git a/usr/usr0sess.c b/usr/usr0sess.c
index 8c5780d4c2b..f45c43869ea 100644
--- a/usr/usr0sess.c
+++ b/usr/usr0sess.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+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
+
+*****************************************************************************/
+
/******************************************************
Sessions
-(c) 1996 Innobase Oy
-
Created 6/25/1996 Heikki Tuuri
*******************************************************/
diff --git a/ut/ut0auxconf.c b/ut/ut0auxconf.c
new file mode 100644
index 00000000000..fd9433d16f6
--- /dev/null
+++ b/ut/ut0auxconf.c
@@ -0,0 +1,13 @@
+#include <pthread.h>
+
+int
+main(int argc, char** argv)
+{
+ pthread_t x1;
+ pthread_t x2;
+ pthread_t x3;
+
+ __sync_bool_compare_and_swap(&x1, x2, x3);
+
+ return(0);
+}
diff --git a/ut/ut0byte.c b/ut/ut0byte.c
index a6f5c3601ce..5e11e37d0b6 100644
--- a/ut/ut0byte.c
+++ b/ut/ut0byte.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/*******************************************************************
Byte utilities
-(c) 1994, 1995 Innobase Oy
-
Created 5/11/1994 Heikki Tuuri
********************************************************************/
diff --git a/ut/ut0dbg.c b/ut/ut0dbg.c
index e706ee119c4..55dd457a177 100644
--- a/ut/ut0dbg.c
+++ b/ut/ut0dbg.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/*********************************************************************
Debug utilities for Innobase.
-(c) 1994, 1995 Innobase Oy
-
Created 1/30/1994 Heikki Tuuri
**********************************************************************/
diff --git a/ut/ut0list.c b/ut/ut0list.c
index a48992a9630..c6250edb6cd 100644
--- a/ut/ut0list.c
+++ b/ut/ut0list.c
@@ -1,3 +1,21 @@
+/*****************************************************************************
+
+Copyright (c) 2006, 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
+
+*****************************************************************************/
+
#include "ut0list.h"
#ifdef UNIV_NONINL
#include "ut0list.ic"
diff --git a/ut/ut0mem.c b/ut/ut0mem.c
index c76e8674f3b..c87a6a4b57e 100644
--- a/ut/ut0mem.c
+++ b/ut/ut0mem.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/************************************************************************
Memory primitives
-(c) 1994, 1995 Innobase Oy
-
Created 5/11/1994 Heikki Tuuri
*************************************************************************/
@@ -13,14 +29,21 @@ Created 5/11/1994 Heikki Tuuri
#endif
#include "mem0mem.h"
-#include "os0sync.h"
#include "os0thread.h"
+#include "srv0srv.h"
+
+#include <stdlib.h>
/* This struct is placed first in every allocated memory block */
typedef struct ut_mem_block_struct ut_mem_block_t;
-/* The total amount of memory currently allocated from the OS with malloc */
-UNIV_INTERN ulint ut_total_allocated_memory = 0;
+/* The total amount of memory currently allocated from the operating
+system with os_mem_alloc_large() or malloc(). Does not count malloc()
+if srv_use_sys_malloc is set. Protected by ut_list_mutex. */
+UNIV_INTERN ulint ut_total_allocated_memory = 0;
+
+/* Mutex protecting ut_total_allocated_memory and ut_mem_block_list */
+UNIV_INTERN os_fast_mutex_t ut_list_mutex;
struct ut_mem_block_struct{
UT_LIST_NODE_T(ut_mem_block_t) mem_block_list;
@@ -32,22 +55,21 @@ struct ut_mem_block_struct{
#define UT_MEM_MAGIC_N 1601650166
/* List of all memory blocks allocated from the operating system
-with malloc */
+with malloc. Protected by ut_list_mutex. */
static UT_LIST_BASE_NODE_T(ut_mem_block_t) ut_mem_block_list;
-static os_fast_mutex_t ut_list_mutex; /* this protects the list */
-
static ibool ut_mem_block_list_inited = FALSE;
static ulint* ut_mem_null_ptr = NULL;
/**************************************************************************
Initializes the mem block list at database startup. */
-static
+UNIV_INTERN
void
-ut_mem_block_list_init(void)
-/*========================*/
+ut_mem_init(void)
+/*=============*/
{
+ ut_a(!ut_mem_block_list_inited);
os_fast_mutex_init(&ut_list_mutex);
UT_LIST_INIT(ut_mem_block_list);
ut_mem_block_list_inited = TRUE;
@@ -68,14 +90,26 @@ ut_malloc_low(
ibool assert_on_error)/* in: if TRUE, we crash mysqld if the
memory cannot be allocated */
{
- ulint retry_count = 0;
+ ulint retry_count;
void* ret;
- ut_ad((sizeof(ut_mem_block_t) % 8) == 0); /* check alignment ok */
+ if (UNIV_LIKELY(srv_use_sys_malloc)) {
+ ret = malloc(n);
+ ut_a(ret || !assert_on_error);
- if (!ut_mem_block_list_inited) {
- ut_mem_block_list_init();
+#ifdef UNIV_SET_MEM_TO_ZERO
+ if (set_to_zero) {
+ memset(ret, '\0', n);
+ UNIV_MEM_ALLOC(ret, n);
+ }
+#endif
+ return(ret);
}
+
+ ut_ad((sizeof(ut_mem_block_t) % 8) == 0); /* check alignment ok */
+ ut_a(ut_mem_block_list_inited);
+
+ retry_count = 0;
retry:
os_fast_mutex_lock(&ut_list_mutex);
@@ -239,6 +273,11 @@ ut_free(
{
ut_mem_block_t* block;
+ if (UNIV_LIKELY(srv_use_sys_malloc)) {
+ free(ptr);
+ return;
+ }
+
block = (ut_mem_block_t*)((byte*)ptr - sizeof(ut_mem_block_t));
os_fast_mutex_lock(&ut_list_mutex);
@@ -291,6 +330,10 @@ ut_realloc(
ulint min_size;
void* new_ptr;
+ if (UNIV_LIKELY(srv_use_sys_malloc)) {
+ return(realloc(ptr, size));
+ }
+
if (ptr == NULL) {
return(ut_malloc(size));
@@ -338,6 +381,8 @@ ut_free_all_mem(void)
{
ut_mem_block_t* block;
+ ut_a(ut_mem_block_list_inited);
+ ut_mem_block_list_inited = FALSE;
os_fast_mutex_free(&ut_list_mutex);
while ((block = UT_LIST_GET_FIRST(ut_mem_block_list))) {
diff --git a/ut/ut0rnd.c b/ut/ut0rnd.c
index c7a0ca1ab2a..f5d6cb08b0f 100644
--- a/ut/ut0rnd.c
+++ b/ut/ut0rnd.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/*******************************************************************
Random numbers and hashing
-(c) 1994, 1995 Innobase Oy
-
Created 5/11/1994 Heikki Tuuri
********************************************************************/
diff --git a/ut/ut0ut.c b/ut/ut0ut.c
index 1385e728321..12500988ec6 100644
--- a/ut/ut0ut.c
+++ b/ut/ut0ut.c
@@ -1,8 +1,24 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 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
+
+*****************************************************************************/
+
/*******************************************************************
Various utilities for Innobase.
-(c) 1994, 1995 Innobase Oy
-
Created 5/11/1994 Heikki Tuuri
********************************************************************/
@@ -270,6 +286,7 @@ ut_sprintf_timestamp(
#endif
}
+#ifdef UNIV_HOTBACKUP
/**************************************************************
Sprintfs a timestamp to a buffer with no spaces and with ':' characters
replaced by '_'. */
@@ -350,6 +367,7 @@ ut_get_year_month_day(
*day = (ulint)cal_tm_ptr->tm_mday;
#endif
}
+#endif /* UNIV_HOTBACKUP */
/*****************************************************************
Runs an idle loop on CPU. The argument gives the desired delay
diff --git a/ut/ut0vec.c b/ut/ut0vec.c
index c66eaf2c48b..69b7bec701a 100644
--- a/ut/ut0vec.c
+++ b/ut/ut0vec.c
@@ -1,3 +1,21 @@
+/*****************************************************************************
+
+Copyright (c) 2006, 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
+
+*****************************************************************************/
+
#include "ut0vec.h"
#ifdef UNIV_NONINL
#include "ut0vec.ic"
diff --git a/ut/ut0wqueue.c b/ut/ut0wqueue.c
index b9f287d9e33..a5c14ac8130 100644
--- a/ut/ut0wqueue.c
+++ b/ut/ut0wqueue.c
@@ -1,3 +1,21 @@
+/*****************************************************************************
+
+Copyright (c) 2006, 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
+
+*****************************************************************************/
+
#include "ut0wqueue.h"
/********************************************************************
diff --git a/win-plugin/win-plugin.diff b/win-plugin/win-plugin.diff
index b3e90e2d31c..46d2e5b2d2d 100644
--- a/win-plugin/win-plugin.diff
+++ b/win-plugin/win-plugin.diff
@@ -37,7 +37,7 @@ diff -Nur sql/CMakeLists.txt.orig sql/CMakeLists.txt
diff -Nur sql/mysqld.def.orig sql/mysqld.def
--- sql/mysqld.def.orig 1969-12-31 18:00:00 -06:00
+++ sql/mysqld.def 2008-10-31 02:20:32 -05:00
-@@ -0,0 +1,99 @@
+@@ -0,0 +1,98 @@
+EXPORTS
+ ?use_hidden_primary_key@handler@@UAEXXZ
+ ?get_dynamic_partition_info@handler@@UAEXPAUPARTITION_INFO@@I@Z
@@ -82,11 +82,10 @@ diff -Nur sql/mysqld.def.orig sql/mysqld.def
+ ?THR_THD@@3PAVTHD@@A
+ ?end_of_list@@3Ulist_node@@A
+ ?mysql_tmpdir_list@@3Ust_my_tmpdir@@A
-+ ?mysql_bin_log@@3VMYSQL_BIN_LOG@@A
-+ ?is_open@MYSQL_LOG@@QAE_NXZ
+ mysql_query_cache_invalidate4
+ thd_query
+ thd_sql_command
++ thd_get_thread_id
+ thd_get_xid
+ thd_slave_thread
+ thd_non_transactional_update
@@ -138,10 +137,10 @@ diff -Nur sql/mysqld.def.orig sql/mysqld.def
+ localtime_r
+ my_strdup
-diff -Nur ../old/sql/mysqld_x64.def.orig ./sql/mysqld_x64.def
+diff -Nur sql/mysqld_x64.def.orig sql/mysqld_x64.def
--- sql/mysqld_x64.def.orig 1969-12-31 18:00:00 -06:00
+++ sql/mysqld_x64.def 2008-10-31 02:22:04 -05:00
-@@ -0,0 +1,99 @@
+@@ -0,0 +1,98 @@
+EXPORTS
+ ?use_hidden_primary_key@handler@@UEAAXXZ
+ ?get_dynamic_partition_info@handler@@UEAAXPEAUPARTITION_INFO@@I@Z
@@ -186,11 +185,10 @@ diff -Nur ../old/sql/mysqld_x64.def.orig ./sql/mysqld_x64.def
+ ?THR_THD@@3PEAVTHD@@EA
+ ?end_of_list@@3Ulist_node@@A
+ ?mysql_tmpdir_list@@3Ust_my_tmpdir@@A
-+ ?mysql_bin_log@@3VMYSQL_BIN_LOG@@A
-+ ?is_open@MYSQL_LOG@@QEAA_NXZ
+ mysql_query_cache_invalidate4
+ thd_query
+ thd_sql_command
++ thd_get_thread_id
+ thd_get_xid
+ thd_slave_thread
+ thd_non_transactional_update