Commit 82b81a29 authored by marko's avatar marko

Make InnoDB pluggable. That is, merge the modifications from MySQL WL#2936

and adapt some things.

Note that ha_innodb.cc depends on mysql_tmpfile() being declared in
<mysql/plugin.h>.  Until the function is declared there, you can
uncomment the buggy definition of mysql_tmpfile in ha_innodb.cc.

Remove storage/innobase/*/Makefile.am.  The whole compilation is driven by
storage/innobase/Makefile.am and storage/innobase/plug.in.

plug.in: Declare InnoDB as a dynamic plugin.

ha_innodb.h: Remove the declarations of many global variables.  The variables
are no longer directly referenced outside of storage/innobase.

trx_t: Add the field trx->duplicates.

trx_create(): Initialize the fields trx->active_trans and trx->duplicates.

innobase_query_is_update(): Remove.  Consult trx->duplicates instead.
parent 02507a76
...@@ -25,102 +25,146 @@ INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include \ ...@@ -25,102 +25,146 @@ INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include \
-I$(top_srcdir)/sql \ -I$(top_srcdir)/sql \
-I$(srcdir) -I$(srcdir)
AUTOMAKE_OPTIONS = foreign DEFS = @DEFS@
TAR = gtar
noinst_HEADERS =
SUBDIRS = os ut btr buf data dict dyn eval fil fsp fut \ noinst_HEADERS = include/btr0btr.h include/btr0btr.ic \
ha ibuf lock log mach mem mtr page \ include/btr0cur.h include/btr0cur.ic \
handler \ include/btr0pcur.h include/btr0pcur.ic \
pars que read rem row srv sync thr trx usr include/btr0sea.h include/btr0sea.ic \
include/btr0types.h include/buf0buf.h \
include/buf0buf.ic include/buf0flu.h \
include/buf0flu.ic include/buf0lru.h \
include/buf0lru.ic include/buf0rea.h \
include/buf0types.h include/data0data.h \
include/data0data.ic include/data0type.h \
include/data0type.ic include/data0types.h \
include/db0err.h include/dict0boot.h \
include/dict0boot.ic include/dict0crea.h \
include/dict0crea.ic include/dict0dict.h \
include/dict0dict.ic include/dict0load.h \
include/dict0load.ic include/dict0mem.h \
include/dict0mem.ic include/dict0types.h \
include/dyn0dyn.h include/dyn0dyn.ic \
include/eval0eval.h include/eval0eval.ic \
include/eval0proc.h include/eval0proc.ic \
include/fil0fil.h include/fsp0fsp.h \
include/fsp0fsp.ic include/fut0fut.h \
include/fut0fut.ic include/fut0lst.h \
include/fut0lst.ic include/ha0ha.h \
include/ha0ha.ic include/hash0hash.h \
include/hash0hash.ic include/ibuf0ibuf.h \
include/ibuf0ibuf.ic include/ibuf0types.h \
include/lock0lock.h include/lock0lock.ic \
include/lock0types.h include/log0log.h \
include/log0log.ic include/log0recv.h \
include/log0recv.ic include/mach0data.h \
include/mach0data.ic include/mem0dbg.h \
include/mem0dbg.ic mem/mem0dbg.c \
include/mem0mem.h include/mem0mem.ic \
include/mem0pool.h include/mem0pool.ic \
include/mtr0log.h include/mtr0log.ic \
include/mtr0mtr.h include/mtr0mtr.ic \
include/mtr0types.h include/os0file.h \
include/os0proc.h include/os0proc.ic \
include/os0sync.h include/os0sync.ic \
include/os0thread.h include/os0thread.ic \
include/page0cur.h include/page0cur.ic \
include/page0page.h include/page0page.ic \
include/page0types.h include/pars0grm.h \
include/pars0opt.h include/pars0opt.ic \
include/pars0pars.h include/pars0pars.ic \
include/pars0sym.h include/pars0sym.ic \
include/pars0types.h include/que0que.h \
include/que0que.ic include/que0types.h \
include/read0read.h include/read0read.ic \
include/read0types.h include/rem0cmp.h \
include/rem0cmp.ic include/rem0rec.h \
include/rem0rec.ic include/rem0types.h \
include/row0ins.h include/row0ins.ic \
include/row0mysql.h include/row0mysql.ic \
include/row0purge.h include/row0purge.ic \
include/row0row.h include/row0row.ic \
include/row0sel.h include/row0sel.ic \
include/row0types.h include/row0uins.h \
include/row0uins.ic include/row0umod.h \
include/row0umod.ic include/row0undo.h \
include/row0undo.ic include/row0upd.h \
include/row0upd.ic include/row0vers.h \
include/row0vers.ic include/srv0que.h \
include/srv0srv.h include/srv0srv.ic \
include/srv0start.h include/sync0arr.h \
include/sync0arr.ic include/sync0rw.h \
include/sync0rw.ic include/sync0sync.h \
include/sync0sync.ic include/sync0types.h \
include/thr0loc.h include/thr0loc.ic \
include/trx0purge.h include/trx0purge.ic \
include/trx0rec.h include/trx0rec.ic \
include/trx0roll.h include/trx0roll.ic \
include/trx0rseg.h include/trx0rseg.ic \
include/trx0sys.h include/trx0sys.ic \
include/trx0trx.h include/trx0trx.ic \
include/trx0types.h include/trx0undo.h \
include/trx0undo.ic include/trx0xa.h \
include/univ.i include/usr0sess.h \
include/usr0sess.ic include/usr0types.h \
include/ut0byte.h include/ut0byte.ic \
include/ut0dbg.h include/ut0lst.h \
include/ut0mem.h include/ut0mem.ic \
include/ut0rnd.h include/ut0rnd.ic \
include/ut0sort.h include/ut0ut.h \
include/ut0ut.ic include/ut0vec.h \
include/ut0vec.ic include/ut0list.h \
include/ut0list.ic include/ut0wqueue.h \
include/ha_prototypes.h handler/ha_innodb.h
EXTRA_DIST = include/btr0btr.h include/btr0btr.ic include/btr0cur.h include/btr0cur.ic \ EXTRA_LIBRARIES = libinnobase.a
include/btr0pcur.h include/btr0pcur.ic include/btr0sea.h include/btr0sea.ic \ noinst_LIBRARIES = @plugin_innobase_static_target@
include/btr0types.h \ libinnobase_a_SOURCES = btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c \
include/buf0buf.h include/buf0buf.ic include/buf0flu.h include/buf0flu.ic \ btr/btr0sea.c buf/buf0buf.c buf/buf0flu.c \
include/buf0lru.h include/buf0lru.ic include/buf0rea.h include/buf0types.h \ buf/buf0lru.c buf/buf0rea.c data/data0data.c \
include/data0data.h include/data0data.ic include/data0type.h include/data0type.ic \ data/data0type.c dict/dict0boot.c \
include/data0types.h include/db0err.h \ dict/dict0crea.c dict/dict0dict.c \
include/dict0boot.h include/dict0boot.ic include/dict0crea.h include/dict0crea.ic \ dict/dict0load.c dict/dict0mem.c dyn/dyn0dyn.c \
include/dict0dict.h include/dict0dict.ic include/dict0load.h include/dict0load.ic \ eval/eval0eval.c eval/eval0proc.c \
include/dict0mem.h include/dict0mem.ic include/dict0types.h \ fil/fil0fil.c fsp/fsp0fsp.c fut/fut0fut.c \
include/dyn0dyn.h include/dyn0dyn.ic \ fut/fut0lst.c ha/ha0ha.c ha/hash0hash.c \
include/eval0eval.h include/eval0eval.ic include/eval0proc.h include/eval0proc.ic \ ibuf/ibuf0ibuf.c lock/lock0lock.c \
include/fil0fil.h include/fsp0fsp.h include/fsp0fsp.ic \ log/log0log.c log/log0recv.c mach/mach0data.c \
include/fut0fut.h include/fut0fut.ic include/fut0lst.h include/fut0lst.ic \ mem/mem0mem.c mem/mem0pool.c mtr/mtr0log.c \
include/ha0ha.h include/ha0ha.ic include/hash0hash.h include/hash0hash.ic \ mtr/mtr0mtr.c os/os0file.c os/os0proc.c \
include/ibuf0ibuf.h include/ibuf0ibuf.ic include/ibuf0types.h \ os/os0sync.c os/os0thread.c page/page0cur.c \
include/lock0lock.h include/lock0lock.ic include/lock0types.h \ page/page0page.c pars/lexyy.c pars/pars0grm.c \
include/log0log.h include/log0log.ic include/log0recv.h include/log0recv.ic \ pars/pars0opt.c pars/pars0pars.c \
include/mach0data.h include/mach0data.ic include/mem0dbg.h include/mem0dbg.ic \ pars/pars0sym.c que/que0que.c read/read0read.c \
include/mem0mem.h include/mem0mem.ic include/mem0pool.h include/mem0pool.ic \ rem/rem0cmp.c rem/rem0rec.c row/row0ins.c \
include/mtr0log.h include/mtr0log.ic include/mtr0mtr.h include/mtr0mtr.ic \ row/row0mysql.c row/row0purge.c row/row0row.c \
include/mtr0types.h include/os0file.h \ row/row0sel.c row/row0uins.c row/row0umod.c \
include/os0proc.h include/os0proc.ic include/os0sync.h include/os0sync.ic \ row/row0undo.c row/row0upd.c row/row0vers.c \
include/os0thread.h include/os0thread.ic \ srv/srv0que.c srv/srv0srv.c srv/srv0start.c \
include/page0cur.h include/page0cur.ic include/page0page.h include/page0page.ic \ sync/sync0arr.c sync/sync0rw.c \
include/page0types.h \ sync/sync0sync.c thr/thr0loc.c trx/trx0purge.c \
include/pars0grm.h include/pars0opt.h include/pars0opt.ic \ trx/trx0rec.c trx/trx0roll.c trx/trx0rseg.c \
include/pars0pars.h include/pars0pars.ic include/pars0sym.h include/pars0sym.ic \ trx/trx0sys.c trx/trx0trx.c trx/trx0undo.c \
include/pars0types.h \ usr/usr0sess.c ut/ut0byte.c ut/ut0dbg.c \
include/que0que.h include/que0que.ic include/que0types.h \ ut/ut0list.c ut/ut0mem.c ut/ut0rnd.c \
include/read0read.h include/read0read.ic include/read0types.h \ ut/ut0ut.c ut/ut0vec.c ut/ut0wqueue.c \
include/rem0cmp.h include/rem0cmp.ic include/rem0rec.h include/rem0rec.ic \ handler/ha_innodb.cc
include/rem0types.h \
include/row0ins.h include/row0ins.ic include/row0mysql.h include/row0mysql.ic \
include/row0purge.h include/row0purge.ic include/row0row.h include/row0row.ic \
include/row0sel.h include/row0sel.ic include/row0types.h \
include/row0uins.h include/row0uins.ic include/row0umod.h include/row0umod.ic \
include/row0undo.h include/row0undo.ic include/row0upd.h include/row0upd.ic \
include/row0vers.h include/row0vers.ic \
include/srv0que.h include/srv0srv.h include/srv0srv.ic include/srv0start.h \
include/sync0arr.h include/sync0arr.ic include/sync0rw.h include/sync0rw.ic \
include/sync0sync.h include/sync0sync.ic include/sync0types.h \
include/thr0loc.h include/thr0loc.ic \
include/trx0purge.h include/trx0purge.ic include/trx0rec.h include/trx0rec.ic \
include/trx0roll.h include/trx0roll.ic include/trx0rseg.h include/trx0rseg.ic \
include/trx0sys.h include/trx0sys.ic include/trx0trx.h include/trx0trx.ic \
include/trx0types.h include/trx0undo.h include/trx0undo.ic include/trx0xa.h \
include/univ.i include/usr0sess.h include/usr0sess.ic include/usr0types.h \
include/ut0byte.h include/ut0byte.ic include/ut0dbg.h include/ut0lst.h \
include/ut0mem.h include/ut0mem.ic include/ut0rnd.h include/ut0rnd.ic \
handler/ha_innodb.h \
include/ut0sort.h include/ut0ut.h include/ut0ut.ic include/ut0vec.h include/ut0vec.ic include/ha_prototypes.h \
include/ut0list.h include/ut0list.ic \
include/ut0wqueue.h \
pars/make_bison.sh pars/make_flex.sh \
pars/pars0grm.y pars/pars0lex.l \
CMakeLists.txt plug.in
noinst_LIBRARIES = libinnobase.a libinnobase_a_CXXFLAGS= $(AM_CFLAGS) -DMYSQL_SERVER
libinnobase_a_LIBADD = usr/libusr.a srv/libsrv.a dict/libdict.a \ libinnobase_a_CFLAGS = $(AM_CFLAGS) -DMYSQL_SERVER
que/libque.a srv/libsrv.a ibuf/libibuf.a \
row/librow.a pars/libpars.a btr/libbtr.a \
trx/libtrx.a read/libread.a usr/libusr.a \
buf/libbuf.a ibuf/libibuf.a eval/libeval.a \
log/liblog.a fsp/libfsp.a fut/libfut.a \
fil/libfil.a lock/liblock.a mtr/libmtr.a \
page/libpage.a rem/librem.a thr/libthr.a \
sync/libsync.a data/libdata.a mach/libmach.a \
ha/libha.a dyn/libdyn.a mem/libmem.a \
handler/libhandler.a \
ut/libut.a os/libos.a ut/libut.a
libinnobase_a_SOURCES =
EXTRA_LTLIBRARIES = ha_innodb.la
pkglib_LTLIBRARIES = @plugin_innobase_shared_target@
libinnobase.a: $(libinnobase_a_LIBADD) ha_innodb_la_LDFLAGS = -module -rpath $(MYSQLLIBdir)
-rm -f $@ ha_innodb_la_CXXFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
if test "$(host_os)" = "netware" ; \ ha_innodb_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
then \ ha_innodb_la_SOURCES = $(libinnobase_a_SOURCES)
$(libinnobase_a_AR) $@ $(libinnobase_a_LIBADD) ; \
else \ EXTRA_DIST = CMakeLists.txt plug.in \
for arc in $(libinnobase_a_LIBADD); do \ pars/make_bison.sh pars/make_flex.sh \
arpath=`echo $$arc|sed 's|[^/]*$$||'`; \ pars/pars0grm.y pars/pars0lex.l
$(AR) t $$arc|sed "s|^|$$arpath|"; \
done | sort -u | xargs $(AR) cq $@ ; \
$(RANLIB) $@ ; \
fi
# Don't update the files from bitkeeper # Don't update the files from bitkeeper
%::SCCS/s.% %::SCCS/s.%
# Copyright (C) 2001, 2003 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public 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 ../include/Makefile.i
noinst_LIBRARIES = libbtr.a
libbtr_a_SOURCES = btr0btr.c btr0cur.c btr0pcur.c btr0sea.c
EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2001, 2003 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public 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 ../include/Makefile.i
noinst_LIBRARIES = libbuf.a
libbuf_a_SOURCES = buf0buf.c buf0flu.c buf0lru.c buf0rea.c
EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2001, 2003 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public 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 ../include/Makefile.i
noinst_LIBRARIES = libdata.a
libdata_a_SOURCES = data0data.c data0type.c
EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2001, 2003 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public 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 ../include/Makefile.i
noinst_LIBRARIES = libdict.a
libdict_a_SOURCES = dict0boot.c dict0crea.c dict0dict.c dict0load.c\
dict0mem.c
EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2001, 2003 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public 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 ../include/Makefile.i
noinst_LIBRARIES = libdyn.a
libdyn_a_SOURCES = dyn0dyn.c
EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2001, 2003 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public 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 ../include/Makefile.i
noinst_LIBRARIES = libeval.a
libeval_a_SOURCES = eval0eval.c eval0proc.c
EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2001, 2003 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public 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 ../include/Makefile.i
noinst_LIBRARIES = libfil.a
libfil_a_SOURCES = fil0fil.c
EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2001, 2003 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public 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 ../include/Makefile.i
noinst_LIBRARIES = libfsp.a
libfsp_a_SOURCES = fsp0fsp.c
EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2001, 2003 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public 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 ../include/Makefile.i
noinst_LIBRARIES = libfut.a
libfut_a_SOURCES = fut0fut.c fut0lst.c
EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2001, 2003 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public 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 ../include/Makefile.i
noinst_LIBRARIES = libha.a
libha_a_SOURCES = ha0ha.c hash0hash.c
EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public 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 ../include/Makefile.i
DEFS = -DMYSQL_SERVER @DEFS@
noinst_LIBRARIES = libhandler.a
libhandler_a_SOURCES = ha_innodb.cc
EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
...@@ -18,8 +18,7 @@ NOTE: You can only use noninlined InnoDB functions in this file, because we ...@@ -18,8 +18,7 @@ NOTE: You can only use noninlined InnoDB functions in this file, because we
have disabled the InnoDB inlining in this file. */ have disabled the InnoDB inlining in this file. */
/* TODO list for the InnoDB handler in 5.0: /* TODO list for the InnoDB handler in 5.0:
- Remove the flag trx->active_trans and look at the InnoDB - Remove the flag trx->active_trans and look at trx->conc_state
trx struct state field
- fix savepoint functions to use savepoint storage area - fix savepoint functions to use savepoint storage area
- Find out what kind of problems the OS X case-insensitivity causes to - Find out what kind of problems the OS X case-insensitivity causes to
table and database names; should we 'normalize' the names like we do table and database names; should we 'normalize' the names like we do
...@@ -33,29 +32,61 @@ have disabled the InnoDB inlining in this file. */ ...@@ -33,29 +32,61 @@ have disabled the InnoDB inlining in this file. */
#include <mysql_priv.h> #include <mysql_priv.h>
#include <mysqld_error.h> #include <mysqld_error.h>
#ifdef WITH_INNOBASE_STORAGE_ENGINE
#include <m_ctype.h> #include <m_ctype.h>
#include <hash.h> #include <hash.h>
#include <myisampack.h> #include <myisampack.h>
#include <mysys_err.h> #include <mysys_err.h>
#include <my_sys.h> #include <my_sys.h>
#include "ha_innodb.h" #include "ha_innodb.h"
#include <mysql/plugin.h>
#ifdef MYSQL_SERVER
/* Define some macros until these functions are declared in <mysql/plugin.h>.
Once these functions are defined by MySQL, we may consider
removing -DMYSQL_SERVER from ../Makefile.am as well. */
#define thd_charset(thd) (thd)->charset()
#define thd_get_xid(thd,xid_) ((*xid_) = (thd)->transaction.xid_state.xid)
#define thd_memdup(thd,str,len) (thd)->memdup(str, len)
#define thd_killed(thd) (thd)->killed
#define thd_slave_thread(thd) (thd)->slave_thread
#define thd_query(thd) (&(thd)->query)
#define mysql_bin_log_file_name() mysql_bin_log.get_log_fname()
#define mysql_bin_log_file_pos() mysql_bin_log.get_log_file()->pos_in_file
/*#define mysql_tmpfile() fileno(tmpfile())/* BUGGY: leaks memory, Bug #3998 */
#define mysql_query_cache_invalidate4(a,b,c,d) query_cache.invalidate(a,b,c,d)
#else /* MYSQL_SERVER */
/* This is needed because of Bug #3596. Let us hope that pthread_mutex_t
is defined the same in both builds: the MySQL server and the InnoDB plugin. */
extern pthread_mutex_t LOCK_thread_count;
#endif /* MYSQL_SERVER */
pthread_mutex_t innobase_share_mutex, /* to protect innobase_open_files */ extern "C" {
prepare_commit_mutex; /* to force correct commit order in extern ulong srv_max_buf_pool_modified_pct;
binlog */ extern ulong srv_max_purge_lag;
ulong commit_threads= 0; extern ulong srv_auto_extend_increment;
pthread_mutex_t commit_threads_m; extern ulong srv_n_spin_wait_rounds;
pthread_cond_t commit_cond; extern ulong srv_n_free_tickets_to_enter;
pthread_mutex_t commit_cond_m; extern ulong srv_thread_sleep_delay;
bool innodb_inited= 0; extern ulong srv_thread_concurrency;
extern ulong srv_commit_concurrency;
extern ulong srv_flush_log_at_trx_commit;
}
/** to protect innobase_open_files */
static pthread_mutex_t innobase_share_mutex;
/** to force correct commit order in binlog */
static pthread_mutex_t prepare_commit_mutex;
static ulong commit_threads = 0;
static pthread_mutex_t commit_threads_m;
static pthread_cond_t commit_cond;
static pthread_mutex_t commit_cond_m;
static bool innodb_inited = 0;
/* /*
This needs to exist until the query cache callback is removed This needs to exist until the query cache callback is removed
or learns to pass hton. or learns to pass hton.
*/ */
static handlerton *legacy_innodb_hton; static handlerton *innodb_hton_ptr;
/* Store MySQL definition of 'byte': in Linux it is char while InnoDB /* Store MySQL definition of 'byte': in Linux it is char while InnoDB
uses unsigned char; the header univ.i which we include next defines uses unsigned char; the header univ.i which we include next defines
...@@ -93,46 +124,41 @@ extern "C" { ...@@ -93,46 +124,41 @@ extern "C" {
#include "ha_prototypes.h" #include "ha_prototypes.h"
} }
ulong innobase_large_page_size = 0; static long innobase_mirrored_log_groups, innobase_log_files_in_group,
/* The default values for the following, type long or longlong, start-up
parameters are declared in mysqld.cc: */
long innobase_mirrored_log_groups, innobase_log_files_in_group,
innobase_log_buffer_size, innobase_buffer_pool_awe_mem_mb, innobase_log_buffer_size, innobase_buffer_pool_awe_mem_mb,
innobase_additional_mem_pool_size, innobase_file_io_threads, innobase_additional_mem_pool_size, innobase_file_io_threads,
innobase_lock_wait_timeout, innobase_force_recovery, innobase_lock_wait_timeout, innobase_force_recovery,
innobase_open_files; innobase_open_files;
longlong innobase_buffer_pool_size, innobase_log_file_size; static longlong innobase_buffer_pool_size, innobase_log_file_size;
/* The default values for the following char* start-up parameters /* The default values for the following char* start-up parameters
are determined in innobase_init below: */ are determined in innobase_init below: */
char* innobase_data_home_dir = NULL; static char* innobase_data_home_dir = NULL;
char* innobase_data_file_path = NULL; static char* innobase_data_file_path = NULL;
char* innobase_log_group_home_dir = NULL; static char* innobase_log_group_home_dir = NULL;
char* innobase_log_arch_dir = NULL;/* unused */
/* The following has a misleading name: starting from 4.0.5, this also /* The following has a misleading name: starting from 4.0.5, this also
affects Windows: */ affects Windows: */
char* innobase_unix_file_flush_method = NULL; static char* innobase_unix_file_flush_method = NULL;
/* Below we have boolean-valued start-up parameters, and their default /* Below we have boolean-valued start-up parameters, and their default
values */ values */
ulong innobase_fast_shutdown = 1; static ulong innobase_fast_shutdown = 1;
my_bool innobase_log_archive = FALSE;/* unused */ #ifdef UNIV_LOG_ARCHIVE
my_bool innobase_use_doublewrite = TRUE; static my_bool innobase_log_archive = FALSE;
my_bool innobase_use_checksums = TRUE; static char* innobase_log_arch_dir = NULL;
my_bool innobase_use_large_pages = FALSE; #endif /* UNIV_LOG_ARCHIVE */
my_bool innobase_use_native_aio = FALSE; static my_bool innobase_use_doublewrite = TRUE;
my_bool innobase_file_per_table = FALSE; static my_bool innobase_use_checksums = TRUE;
my_bool innobase_locks_unsafe_for_binlog = FALSE; static my_bool innobase_file_per_table = FALSE;
my_bool innobase_rollback_on_timeout = FALSE; static my_bool innobase_locks_unsafe_for_binlog = FALSE;
my_bool innobase_create_status_file = FALSE; static my_bool innobase_rollback_on_timeout = FALSE;
my_bool innobase_stats_on_metadata = TRUE; static my_bool innobase_create_status_file = FALSE;
static my_bool innobase_stats_on_metadata = TRUE;
static char *internal_innobase_data_file_path = NULL; static char* internal_innobase_data_file_path = NULL;
/* The following counter is used to convey information to InnoDB /* The following counter is used to convey information to InnoDB
about server activity: in selects it is not sensible to call about server activity: in selects it is not sensible to call
...@@ -166,6 +192,17 @@ static handler *innobase_create_handler(handlerton *hton, ...@@ -166,6 +192,17 @@ static handler *innobase_create_handler(handlerton *hton,
static const char innobase_hton_name[]= "InnoDB"; static const char innobase_hton_name[]= "InnoDB";
static MYSQL_THDVAR_BOOL(support_xa, PLUGIN_VAR_OPCMDARG,
"Enable InnoDB support for the XA two-phase commit",
/* check_func */ NULL, /* update_func */ NULL,
/* default */ TRUE);
static MYSQL_THDVAR_BOOL(table_locks, PLUGIN_VAR_OPCMDARG,
"Enable InnoDB locking in LOCK TABLES",
/* check_func */ NULL, /* update_func */ NULL,
/* default */ TRUE);
static handler *innobase_create_handler(handlerton *hton, static handler *innobase_create_handler(handlerton *hton,
TABLE_SHARE *table, TABLE_SHARE *table,
MEM_ROOT *mem_root) MEM_ROOT *mem_root)
...@@ -421,7 +458,7 @@ thd_is_replication_slave_thread( ...@@ -421,7 +458,7 @@ thd_is_replication_slave_thread(
/* out: true if thd is the replication thread */ /* out: true if thd is the replication thread */
void* thd) /* in: thread handle (THD*) */ void* thd) /* in: thread handle (THD*) */
{ {
return((ibool)(((THD*)thd)->slave_thread)); return((ibool) thd_slave_thread((THD*) thd));
} }
/********************************************************************** /**********************************************************************
...@@ -490,6 +527,7 @@ thd_to_trx( ...@@ -490,6 +527,7 @@ thd_to_trx(
THD* thd, /* in: MySQL thread */ THD* thd, /* in: MySQL thread */
handlerton* hton) /* in: InnoDB handlerton */ handlerton* hton) /* in: InnoDB handlerton */
{ {
DBUG_ASSERT(hton == innodb_hton_ptr);
return(*(trx_t**) thd_ha_data(thd, hton)); return(*(trx_t**) thd_ha_data(thd, hton));
} }
...@@ -501,8 +539,9 @@ static ...@@ -501,8 +539,9 @@ static
int int
innobase_release_temporary_latches( innobase_release_temporary_latches(
/*===============================*/ /*===============================*/
handlerton *hton, /* out: 0 */
THD *thd) handlerton* hton, /* in: handlerton */
THD* thd) /* in: MySQL thread */
{ {
trx_t* trx; trx_t* trx;
...@@ -705,78 +744,12 @@ innobase_mysql_print_thd( ...@@ -705,78 +744,12 @@ innobase_mysql_print_thd(
uint max_query_len) /* in: max query length to print, or 0 to uint max_query_len) /* in: max query length to print, or 0 to
use the default max length */ use the default max length */
{ {
const THD* thd; THD* thd;
const Security_context *sctx; char buffer[1024];
const char* s;
thd = (const THD*) input_thd;
/* We probably want to have original user as part of debug output. */
sctx = &thd->main_security_ctx;
fprintf(f, "MySQL thread id %lu, query id %lu",
thd->thread_id, (ulong) thd->query_id);
if (sctx->host) {
putc(' ', f);
fputs(sctx->host, f);
}
if (sctx->ip) {
putc(' ', f);
fputs(sctx->ip, f);
}
if (sctx->user) {
putc(' ', f);
fputs(sctx->user, f);
}
if ((s = thd->proc_info)) {
putc(' ', f);
fputs(s, f);
}
if ((s = thd->query)) {
/* 3100 is chosen because currently 3000 is the maximum
max_query_len we ever give this. */
char buf[3100];
uint len;
/* If buf is too small, we dynamically allocate storage
in this. */
char* dyn_str = NULL;
/* Points to buf or dyn_str. */
char* str = buf;
if (max_query_len == 0) {
/* ADDITIONAL SAFETY: the default is to print at
most 300 chars to reduce the probability of a
seg fault if there is a race in
thd->query_length in MySQL; after May 14, 2004
probably no race any more, but better be
safe */
max_query_len = 300;
}
len = min(thd->query_length, max_query_len);
if (len > (sizeof(buf) - 1)) {
dyn_str = my_malloc(len + 1, MYF(0));
str = dyn_str;
}
/* Use strmake to reduce the timeframe for a race,
compared to fwrite() */
len = (uint) (strmake(str, s, len) - str);
putc('\n', f);
fwrite(str, 1, len, f);
if (dyn_str) {
my_free(dyn_str, MYF(0));
}
}
thd = (THD*) input_thd;
fputs(thd_security_context(thd, buffer, sizeof(buffer),
max_query_len), f);
putc('\n', f); putc('\n', f);
} }
...@@ -823,7 +796,7 @@ innobase_convert_from_table_id( ...@@ -823,7 +796,7 @@ innobase_convert_from_table_id(
{ {
uint errors; uint errors;
strconvert(current_thd->charset(), from, strconvert(thd_charset(current_thd), from,
&my_charset_filename, to, (uint) len, &errors); &my_charset_filename, to, (uint) len, &errors);
} }
...@@ -842,7 +815,7 @@ innobase_convert_from_id( ...@@ -842,7 +815,7 @@ innobase_convert_from_id(
{ {
uint errors; uint errors;
strconvert(current_thd->charset(), from, strconvert(thd_charset(current_thd), from,
system_charset_info, to, (uint) len, &errors); system_charset_info, to, (uint) len, &errors);
} }
...@@ -905,7 +878,7 @@ innobase_get_charset( ...@@ -905,7 +878,7 @@ innobase_get_charset(
/* out: connection character set */ /* out: connection character set */
void* mysql_thd) /* in: MySQL thread handle */ void* mysql_thd) /* in: MySQL thread handle */
{ {
return(((THD*) mysql_thd)->charset()); return(thd_charset((THD*) mysql_thd));
} }
/************************************************************************* /*************************************************************************
...@@ -916,41 +889,7 @@ innobase_mysql_tmpfile(void) ...@@ -916,41 +889,7 @@ innobase_mysql_tmpfile(void)
/*========================*/ /*========================*/
/* out: temporary file descriptor, or < 0 on error */ /* out: temporary file descriptor, or < 0 on error */
{ {
char filename[FN_REFLEN]; return(mysql_tmpfile());
int fd2 = -1;
File fd = create_temp_file(filename, mysql_tmpdir, "ib",
#ifdef __WIN__
O_BINARY | O_TRUNC | O_SEQUENTIAL |
O_TEMPORARY | O_SHORT_LIVED |
#endif /* __WIN__ */
O_CREAT | O_EXCL | O_RDWR,
MYF(MY_WME));
if (fd >= 0) {
#ifndef __WIN__
/* On Windows, open files cannot be removed, but files can be
created with the O_TEMPORARY flag to the same effect
("delete on close"). */
unlink(filename);
#endif /* !__WIN__ */
/* Copy the file descriptor, so that the additional resources
allocated by create_temp_file() can be freed by invoking
my_close().
Because the file descriptor returned by this function
will be passed to fdopen(), it will be closed by invoking
fclose(), which in turn will invoke close() instead of
my_close(). */
fd2 = dup(fd);
if (fd2 < 0) {
DBUG_PRINT("error",("Got error %d on dup",fd2));
my_errno=errno;
my_error(EE_OUT_OF_FILERESOURCES,
MYF(ME_BELL+ME_WAITTANG),
filename, my_errno);
}
my_close(fd, MYF(MY_WME));
}
return(fd2);
} }
/************************************************************************* /*************************************************************************
...@@ -994,12 +933,11 @@ check_trx_exists( ...@@ -994,12 +933,11 @@ check_trx_exists(
trx = trx_allocate_for_mysql(); trx = trx_allocate_for_mysql();
trx->mysql_thd = thd; trx->mysql_thd = thd;
trx->mysql_query_str = &(thd->query); trx->mysql_query_str = thd_query(thd);
trx->active_trans = 0;
/* Update the info whether we should skip XA steps that eat /* Update the info whether we should skip XA steps that eat
CPU time */ CPU time */
trx->support_xa = (ibool)(thd->variables.innodb_support_xa); trx->support_xa = THDVAR(thd, support_xa);
} else { } else {
if (trx->magic_n != TRX_MAGIC_N) { if (trx->magic_n != TRX_MAGIC_N) {
mem_analyze_corruption(trx); mem_analyze_corruption(trx);
...@@ -1008,13 +946,13 @@ check_trx_exists( ...@@ -1008,13 +946,13 @@ check_trx_exists(
} }
} }
if (thd->options & OPTION_NO_FOREIGN_KEY_CHECKS) { if (thd_test_options(thd, OPTION_NO_FOREIGN_KEY_CHECKS)) {
trx->check_foreigns = FALSE; trx->check_foreigns = FALSE;
} else { } else {
trx->check_foreigns = TRUE; trx->check_foreigns = TRUE;
} }
if (thd->options & OPTION_RELAXED_UNIQUE_CHECKS) { if (thd_test_options(thd, OPTION_RELAXED_UNIQUE_CHECKS)) {
trx->check_unique_secondary = FALSE; trx->check_unique_secondary = FALSE;
} else { } else {
trx->check_unique_secondary = TRUE; trx->check_unique_secondary = TRUE;
...@@ -1101,7 +1039,7 @@ innobase_register_trx_and_stmt( ...@@ -1101,7 +1039,7 @@ innobase_register_trx_and_stmt(
innobase_register_stmt(hton, thd); innobase_register_stmt(hton, thd);
if (thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) { if (thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) {
/* No autocommit mode, register for a transaction */ /* No autocommit mode, register for a transaction */
trans_register_ha(thd, TRUE, hton); trans_register_ha(thd, TRUE, hton);
...@@ -1193,14 +1131,15 @@ innobase_query_caching_of_table_permitted( ...@@ -1193,14 +1131,15 @@ innobase_query_caching_of_table_permitted(
ut_a(full_name_len < 999); ut_a(full_name_len < 999);
if (thd->variables.tx_isolation == ISO_SERIALIZABLE) { trx = check_trx_exists(innodb_hton_ptr, thd);
if (trx->isolation_level == TRX_ISO_SERIALIZABLE) {
/* In the SERIALIZABLE mode we add LOCK IN SHARE MODE to every /* In the SERIALIZABLE mode we add LOCK IN SHARE MODE to every
plain SELECT if AUTOCOMMIT is not on. */ plain SELECT if AUTOCOMMIT is not on. */
return((my_bool)FALSE); return((my_bool)FALSE);
} }
trx = check_trx_exists(legacy_innodb_hton, thd);
if (trx->has_search_latch) { if (trx->has_search_latch) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
sql_print_error("The calling thread is holding the adaptive " sql_print_error("The calling thread is holding the adaptive "
...@@ -1214,7 +1153,7 @@ innobase_query_caching_of_table_permitted( ...@@ -1214,7 +1153,7 @@ innobase_query_caching_of_table_permitted(
innobase_release_stat_resources(trx); innobase_release_stat_resources(trx);
if (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) { if (!thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) {
is_autocommit = TRUE; is_autocommit = TRUE;
} else { } else {
...@@ -1259,7 +1198,7 @@ innobase_query_caching_of_table_permitted( ...@@ -1259,7 +1198,7 @@ innobase_query_caching_of_table_permitted(
if (trx->active_trans == 0) { if (trx->active_trans == 0) {
innobase_register_trx_and_stmt(legacy_innodb_hton, thd); innobase_register_trx_and_stmt(innodb_hton_ptr, thd);
trx->active_trans = 1; trx->active_trans = 1;
} }
...@@ -1297,10 +1236,10 @@ innobase_invalidate_query_cache( ...@@ -1297,10 +1236,10 @@ innobase_invalidate_query_cache(
/* Argument TRUE below means we are using transactions */ /* Argument TRUE below means we are using transactions */
#ifdef HAVE_QUERY_CACHE #ifdef HAVE_QUERY_CACHE
query_cache.invalidate((THD*)(trx->mysql_thd), mysql_query_cache_invalidate4((THD*) trx->mysql_thd,
(const char*)full_name, (const char*) full_name,
(uint32)full_name_len, (uint32) full_name_len,
TRUE); TRUE);
#endif #endif
} }
...@@ -1380,7 +1319,7 @@ trx_is_interrupted( ...@@ -1380,7 +1319,7 @@ trx_is_interrupted(
/* out: TRUE if interrupted */ /* out: TRUE if interrupted */
trx_t* trx) /* in: transaction */ trx_t* trx) /* in: transaction */
{ {
return(trx && trx->mysql_thd && ((THD*) trx->mysql_thd)->killed); return(trx && trx->mysql_thd && thd_killed((THD*) trx->mysql_thd));
} }
/********************************************************************* /*********************************************************************
...@@ -1399,7 +1338,7 @@ ha_innobase::init_table_handle_for_HANDLER(void) ...@@ -1399,7 +1338,7 @@ ha_innobase::init_table_handle_for_HANDLER(void)
one. Update the trx pointers in the prebuilt struct. Normally one. Update the trx pointers in the prebuilt struct. Normally
this operation is done in external_lock. */ this operation is done in external_lock. */
update_thd(current_thd); update_thd(ha_thd());
/* Initialize the prebuilt struct much like it would be inited in /* Initialize the prebuilt struct much like it would be inited in
external_lock */ external_lock */
...@@ -1418,7 +1357,7 @@ ha_innobase::init_table_handle_for_HANDLER(void) ...@@ -1418,7 +1357,7 @@ ha_innobase::init_table_handle_for_HANDLER(void)
if (prebuilt->trx->active_trans == 0) { if (prebuilt->trx->active_trans == 0) {
innobase_register_trx_and_stmt(ht, current_thd); innobase_register_trx_and_stmt(ht, user_thd);
prebuilt->trx->active_trans = 1; prebuilt->trx->active_trans = 1;
} }
...@@ -1452,8 +1391,10 @@ ha_innobase::init_table_handle_for_HANDLER(void) ...@@ -1452,8 +1391,10 @@ ha_innobase::init_table_handle_for_HANDLER(void)
Opens an InnoDB database. */ Opens an InnoDB database. */
static static
int int
innobase_init(void *p) innobase_init(
/*===============*/ /*==========*/
/* out: 0 on success, error code on failure */
void *p) /* in: InnoDB handlerton */
{ {
static char current_dir[3]; /* Set if using current lib */ static char current_dir[3]; /* Set if using current lib */
int err; int err;
...@@ -1462,9 +1403,9 @@ innobase_init(void *p) ...@@ -1462,9 +1403,9 @@ innobase_init(void *p)
DBUG_ENTER("innobase_init"); DBUG_ENTER("innobase_init");
handlerton *innobase_hton= (handlerton *)p; handlerton *innobase_hton= (handlerton *)p;
legacy_innodb_hton= innobase_hton; innodb_hton_ptr = innobase_hton;
innobase_hton->state=have_innodb; innobase_hton->state = SHOW_OPTION_YES;
innobase_hton->db_type= DB_TYPE_INNODB; innobase_hton->db_type= DB_TYPE_INNODB;
innobase_hton->savepoint_offset=sizeof(trx_named_savept_t); innobase_hton->savepoint_offset=sizeof(trx_named_savept_t);
innobase_hton->close_connection=innobase_close_connection; innobase_hton->close_connection=innobase_close_connection;
...@@ -1489,9 +1430,6 @@ innobase_init(void *p) ...@@ -1489,9 +1430,6 @@ innobase_init(void *p)
innobase_hton->flags=HTON_NO_FLAGS; innobase_hton->flags=HTON_NO_FLAGS;
innobase_hton->release_temporary_latches=innobase_release_temporary_latches; innobase_hton->release_temporary_latches=innobase_release_temporary_latches;
if (have_innodb != SHOW_OPTION_YES)
DBUG_RETURN(0); // nothing else to do
ut_a(DATA_MYSQL_TRUE_VARCHAR == (ulint)MYSQL_TYPE_VARCHAR); ut_a(DATA_MYSQL_TRUE_VARCHAR == (ulint)MYSQL_TYPE_VARCHAR);
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
...@@ -1673,8 +1611,10 @@ innobase_init(void *p) ...@@ -1673,8 +1611,10 @@ innobase_init(void *p)
srv_use_doublewrite_buf = (ibool) innobase_use_doublewrite; srv_use_doublewrite_buf = (ibool) innobase_use_doublewrite;
srv_use_checksums = (ibool) innobase_use_checksums; srv_use_checksums = (ibool) innobase_use_checksums;
os_use_large_pages = (ibool) innobase_use_large_pages; #ifdef HAVE_LARGE_PAGES
os_large_page_size = (ulint) innobase_large_page_size; if ((os_use_large_pages = (ibool) my_use_large_pages))
os_large_page_size = (ulint) opt_large_page_size;
#endif
row_rollback_on_timeout = (ibool) innobase_rollback_on_timeout; row_rollback_on_timeout = (ibool) innobase_rollback_on_timeout;
...@@ -1733,7 +1673,7 @@ innobase_init(void *p) ...@@ -1733,7 +1673,7 @@ innobase_init(void *p)
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
error: error:
have_innodb= SHOW_OPTION_DISABLED; // If we couldn't use handler innobase_hton->state = SHOW_OPTION_DISABLED;
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
...@@ -1876,7 +1816,7 @@ innobase_commit( ...@@ -1876,7 +1816,7 @@ innobase_commit(
trx = check_trx_exists(hton, thd); trx = check_trx_exists(hton, thd);
/* Update the info whether we should skip XA steps that eat CPU time */ /* Update the info whether we should skip XA steps that eat CPU time */
trx->support_xa = (ibool)(thd->variables.innodb_support_xa); trx->support_xa = THDVAR(thd, support_xa);
/* Since we will reserve the kernel mutex, we have to release /* Since we will reserve the kernel mutex, we have to release
the search system latch first to obey the latching order. */ the search system latch first to obey the latching order. */
...@@ -1907,7 +1847,7 @@ innobase_commit( ...@@ -1907,7 +1847,7 @@ innobase_commit(
" trx->conc_state != TRX_NOT_STARTED"); " trx->conc_state != TRX_NOT_STARTED");
} }
if (all if (all
|| (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))) { || (!thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) {
/* We were instructed to commit the whole transaction, or /* We were instructed to commit the whole transaction, or
this is an SQL statement end and autocommit is on */ this is an SQL statement end and autocommit is on */
...@@ -1932,9 +1872,8 @@ innobase_commit( ...@@ -1932,9 +1872,8 @@ innobase_commit(
} }
} }
trx->mysql_log_file_name = mysql_bin_log.get_log_fname(); trx->mysql_log_file_name = mysql_bin_log_file_name();
trx->mysql_log_offset = trx->mysql_log_offset = (ib_longlong) mysql_bin_log_file_pos();
(ib_longlong)mysql_bin_log.get_log_file()->pos_in_file;
innobase_commit_low(trx); innobase_commit_low(trx);
...@@ -2089,8 +2028,8 @@ innobase_commit_complete( ...@@ -2089,8 +2028,8 @@ innobase_commit_complete(
/********************************************************************* /*********************************************************************
Rolls back a transaction or the latest SQL statement. */ Rolls back a transaction or the latest SQL statement. */
static
static int int
innobase_rollback( innobase_rollback(
/*==============*/ /*==============*/
/* out: 0 or error number */ /* out: 0 or error number */
...@@ -2109,7 +2048,7 @@ innobase_rollback( ...@@ -2109,7 +2048,7 @@ innobase_rollback(
trx = check_trx_exists(hton, thd); trx = check_trx_exists(hton, thd);
/* Update the info whether we should skip XA steps that eat CPU time */ /* Update the info whether we should skip XA steps that eat CPU time */
trx->support_xa = (ibool)(thd->variables.innodb_support_xa); trx->support_xa = THDVAR(thd, support_xa);
/* Release a possible FIFO ticket and search latch. Since we will /* Release a possible FIFO ticket and search latch. Since we will
reserve the kernel mutex, we have to release the search system latch reserve the kernel mutex, we have to release the search system latch
...@@ -2126,7 +2065,7 @@ innobase_rollback( ...@@ -2126,7 +2065,7 @@ innobase_rollback(
} }
if (all if (all
|| (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))) { || !thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) {
error = trx_rollback_for_mysql(trx); error = trx_rollback_for_mysql(trx);
trx->active_trans = 0; trx->active_trans = 0;
...@@ -2258,8 +2197,10 @@ innobase_savepoint( ...@@ -2258,8 +2197,10 @@ innobase_savepoint(
(unless we are in sub-statement), so SQL layer ensures that (unless we are in sub-statement), so SQL layer ensures that
this method is never called in such situation. this method is never called in such situation.
*/ */
DBUG_ASSERT(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN) || #ifdef MYSQL_SERVER /* plugins cannot access thd->in_sub_stmt */
DBUG_ASSERT(thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN) ||
thd->in_sub_stmt); thd->in_sub_stmt);
#endif /* MYSQL_SERVER */
trx = check_trx_exists(hton, thd); trx = check_trx_exists(hton, thd);
...@@ -2429,7 +2370,7 @@ ha_innobase::open( ...@@ -2429,7 +2370,7 @@ ha_innobase::open(
UT_NOT_USED(mode); UT_NOT_USED(mode);
UT_NOT_USED(test_if_locked); UT_NOT_USED(test_if_locked);
thd = current_thd; thd = ha_thd();
normalize_table_name(norm_name, name); normalize_table_name(norm_name, name);
user_thd = NULL; user_thd = NULL;
...@@ -3388,8 +3329,8 @@ ha_innobase::write_row( ...@@ -3388,8 +3329,8 @@ ha_innobase::write_row(
longlong auto_inc; longlong auto_inc;
longlong dummy; longlong dummy;
ibool auto_inc_used= FALSE; ibool auto_inc_used= FALSE;
THD* thd = current_thd; ulint sql_command;
trx_t* trx = thd_to_trx(thd, ht); trx_t* trx = thd_to_trx(user_thd, ht);
DBUG_ENTER("ha_innobase::write_row"); DBUG_ENTER("ha_innobase::write_row");
...@@ -3413,11 +3354,13 @@ ha_innobase::write_row( ...@@ -3413,11 +3354,13 @@ ha_innobase::write_row(
if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT) if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT)
table->timestamp_field->set_time(); table->timestamp_field->set_time();
if ((user_thd->lex->sql_command == SQLCOM_ALTER_TABLE sql_command = thd_sql_command(user_thd);
|| user_thd->lex->sql_command == SQLCOM_OPTIMIZE
|| user_thd->lex->sql_command == SQLCOM_CREATE_INDEX if ((sql_command == SQLCOM_ALTER_TABLE
|| user_thd->lex->sql_command == SQLCOM_DROP_INDEX) || sql_command == SQLCOM_OPTIMIZE
&& num_write_row >= 10000) { || sql_command == SQLCOM_CREATE_INDEX
|| sql_command == SQLCOM_DROP_INDEX)
&& num_write_row >= 10000) {
/* ALTER TABLE is COMMITted at every 10000 copied rows. /* ALTER TABLE is COMMITted at every 10000 copied rows.
The IX table lock for the original table has to be re-issued. The IX table lock for the original table has to be re-issued.
As this method will be called on a temporary table where the As this method will be called on a temporary table where the
...@@ -3568,10 +3511,16 @@ ha_innobase::write_row( ...@@ -3568,10 +3511,16 @@ ha_innobase::write_row(
performing those statements. */ performing those statements. */
if (error == DB_DUPLICATE_KEY && auto_inc_used if (error == DB_DUPLICATE_KEY && auto_inc_used
&& (user_thd->lex->sql_command == SQLCOM_REPLACE && (sql_command == SQLCOM_REPLACE
|| user_thd->lex->sql_command == SQLCOM_REPLACE_SELECT || sql_command == SQLCOM_REPLACE_SELECT
|| (user_thd->lex->sql_command == SQLCOM_LOAD || (sql_command == SQLCOM_INSERT
&& user_thd->lex->duplicates == DUP_REPLACE))) { && ((trx->duplicates
& (TRX_DUP_IGNORE | TRX_DUP_REPLACE))
== TRX_DUP_IGNORE))
|| (sql_command == SQLCOM_LOAD
&& ((trx->duplicates
& (TRX_DUP_IGNORE | TRX_DUP_REPLACE))
== (TRX_DUP_IGNORE | TRX_DUP_REPLACE))))) {
auto_inc = table->next_number_field->val_int(); auto_inc = table->next_number_field->val_int();
...@@ -3759,7 +3708,7 @@ ha_innobase::update_row( ...@@ -3759,7 +3708,7 @@ ha_innobase::update_row(
{ {
upd_t* uvect; upd_t* uvect;
int error = 0; int error = 0;
trx_t* trx = thd_to_trx(current_thd, ht); trx_t* trx = thd_to_trx(user_thd, ht);
DBUG_ENTER("ha_innobase::update_row"); DBUG_ENTER("ha_innobase::update_row");
...@@ -3812,7 +3761,7 @@ ha_innobase::delete_row( ...@@ -3812,7 +3761,7 @@ ha_innobase::delete_row(
const mysql_byte* record) /* in: a row in MySQL format */ const mysql_byte* record) /* in: a row in MySQL format */
{ {
int error = 0; int error = 0;
trx_t* trx = thd_to_trx(current_thd, ht); trx_t* trx = thd_to_trx(user_thd, ht);
DBUG_ENTER("ha_innobase::delete_row"); DBUG_ENTER("ha_innobase::delete_row");
...@@ -3891,14 +3840,15 @@ void ...@@ -3891,14 +3840,15 @@ void
ha_innobase::try_semi_consistent_read(bool yes) ha_innobase::try_semi_consistent_read(bool yes)
/*===========================================*/ /*===========================================*/
{ {
ut_a(prebuilt->trx == thd_to_trx(current_thd, ht)); ut_a(prebuilt->trx == thd_to_trx(ha_thd(), ht));
/* Row read type is set to semi consistent read if this was /* Row read type is set to semi consistent read if this was
requested by the MySQL and either innodb_locks_unsafe_for_binlog requested by the MySQL and either innodb_locks_unsafe_for_binlog
option is used or this session is using READ COMMITTED isolation option is used or this session is using READ COMMITTED isolation
level. */ level. */
if (yes && (srv_locks_unsafe_for_binlog if (yes
&& (srv_locks_unsafe_for_binlog
|| prebuilt->trx->isolation_level == TRX_ISO_READ_COMMITTED)) { || prebuilt->trx->isolation_level == TRX_ISO_READ_COMMITTED)) {
prebuilt->row_read_type = ROW_READ_TRY_SEMI_CONSISTENT; prebuilt->row_read_type = ROW_READ_TRY_SEMI_CONSISTENT;
} else { } else {
...@@ -4056,7 +4006,7 @@ ha_innobase::index_read( ...@@ -4056,7 +4006,7 @@ ha_innobase::index_read(
DBUG_ENTER("index_read"); DBUG_ENTER("index_read");
ut_a(prebuilt->trx == thd_to_trx(current_thd, ht)); ut_a(prebuilt->trx == thd_to_trx(user_thd, ht));
ha_statistic_increment(&SSV::ha_read_key_count); ha_statistic_increment(&SSV::ha_read_key_count);
...@@ -4156,10 +4106,10 @@ ha_innobase::change_active_index( ...@@ -4156,10 +4106,10 @@ ha_innobase::change_active_index(
InnoDB */ InnoDB */
{ {
KEY* key=0; KEY* key=0;
ha_statistic_increment(&SSV::ha_read_key_count);
DBUG_ENTER("change_active_index"); DBUG_ENTER("change_active_index");
ha_statistic_increment(&SSV::ha_read_key_count);
ut_ad(user_thd == current_thd); ut_ad(user_thd == ha_thd());
ut_a(prebuilt->trx == thd_to_trx(user_thd, ht)); ut_a(prebuilt->trx == thd_to_trx(user_thd, ht));
active_index = keynr; active_index = keynr;
...@@ -4248,7 +4198,7 @@ ha_innobase::general_fetch( ...@@ -4248,7 +4198,7 @@ ha_innobase::general_fetch(
DBUG_ENTER("general_fetch"); DBUG_ENTER("general_fetch");
ut_a(prebuilt->trx == thd_to_trx(current_thd, ht)); ut_a(prebuilt->trx == thd_to_trx(user_thd, ht));
innodb_srv_conc_enter_innodb(prebuilt->trx); innodb_srv_conc_enter_innodb(prebuilt->trx);
...@@ -4473,7 +4423,7 @@ ha_innobase::rnd_pos( ...@@ -4473,7 +4423,7 @@ ha_innobase::rnd_pos(
ha_statistic_increment(&SSV::ha_read_rnd_count); ha_statistic_increment(&SSV::ha_read_rnd_count);
ut_a(prebuilt->trx == thd_to_trx(current_thd, ht)); ut_a(prebuilt->trx == thd_to_trx(ha_thd(), ht));
if (prebuilt->clust_index_was_generated) { if (prebuilt->clust_index_was_generated) {
/* No primary key was defined for the table and we /* No primary key was defined for the table and we
...@@ -4521,7 +4471,7 @@ ha_innobase::position( ...@@ -4521,7 +4471,7 @@ ha_innobase::position(
{ {
uint len; uint len;
ut_a(prebuilt->trx == thd_to_trx(current_thd, ht)); ut_a(prebuilt->trx == thd_to_trx(ha_thd(), ht));
if (prebuilt->clust_index_was_generated) { if (prebuilt->clust_index_was_generated) {
/* No primary key was defined for the table and we /* No primary key was defined for the table and we
...@@ -4875,7 +4825,7 @@ ha_innobase::create( ...@@ -4875,7 +4825,7 @@ ha_innobase::create(
uint i; uint i;
char name2[FN_REFLEN]; char name2[FN_REFLEN];
char norm_name[FN_REFLEN]; char norm_name[FN_REFLEN];
THD *thd= current_thd; THD* thd = ha_thd();
ib_longlong auto_inc_value; ib_longlong auto_inc_value;
ulint flags; ulint flags;
...@@ -4903,13 +4853,13 @@ ha_innobase::create( ...@@ -4903,13 +4853,13 @@ ha_innobase::create(
trx = trx_allocate_for_mysql(); trx = trx_allocate_for_mysql();
trx->mysql_thd = thd; trx->mysql_thd = thd;
trx->mysql_query_str = &((*thd).query); trx->mysql_query_str = thd_query(thd);
if (thd->options & OPTION_NO_FOREIGN_KEY_CHECKS) { if (thd_test_options(thd, OPTION_NO_FOREIGN_KEY_CHECKS)) {
trx->check_foreigns = FALSE; trx->check_foreigns = FALSE;
} }
if (thd->options & OPTION_RELAXED_UNIQUE_CHECKS) { if (thd_test_options(thd, OPTION_RELAXED_UNIQUE_CHECKS)) {
trx->check_unique_secondary = FALSE; trx->check_unique_secondary = FALSE;
} }
...@@ -4989,9 +4939,9 @@ ha_innobase::create( ...@@ -4989,9 +4939,9 @@ ha_innobase::create(
} }
} }
if (thd->query != NULL) { if (*trx->mysql_query_str) {
error = row_table_add_foreign_constraints(trx, error = row_table_add_foreign_constraints(trx,
thd->query, norm_name, *trx->mysql_query_str, norm_name,
create_info->options & HA_LEX_CREATE_TMP_TABLE); create_info->options & HA_LEX_CREATE_TMP_TABLE);
error = convert_error_code_to_mysql(error, NULL); error = convert_error_code_to_mysql(error, NULL);
...@@ -5065,7 +5015,7 @@ ha_innobase::discard_or_import_tablespace( ...@@ -5065,7 +5015,7 @@ ha_innobase::discard_or_import_tablespace(
ut_a(prebuilt->trx); ut_a(prebuilt->trx);
ut_a(prebuilt->trx->magic_n == TRX_MAGIC_N); ut_a(prebuilt->trx->magic_n == TRX_MAGIC_N);
ut_a(prebuilt->trx == thd_to_trx(current_thd, ht)); ut_a(prebuilt->trx == thd_to_trx(ha_thd(), ht));
dict_table = prebuilt->table; dict_table = prebuilt->table;
trx = prebuilt->trx; trx = prebuilt->trx;
...@@ -5090,22 +5040,21 @@ ha_innobase::delete_all_rows(void) ...@@ -5090,22 +5040,21 @@ ha_innobase::delete_all_rows(void)
/* out: error number */ /* out: error number */
{ {
int error; int error;
THD* thd = current_thd;
DBUG_ENTER("ha_innobase::delete_all_rows"); DBUG_ENTER("ha_innobase::delete_all_rows");
if (thd->lex->sql_command != SQLCOM_TRUNCATE) { /* Get the transaction associated with the current thd, or create one
if not yet created, and update prebuilt->trx */
update_thd(ha_thd());
if (thd_sql_command(user_thd) != SQLCOM_TRUNCATE) {
fallback: fallback:
/* We only handle TRUNCATE TABLE t as a special case. /* We only handle TRUNCATE TABLE t as a special case.
DELETE FROM t will have to use ha_innobase::delete_row(). */ DELETE FROM t will have to use ha_innobase::delete_row(). */
DBUG_RETURN(my_errno=HA_ERR_WRONG_COMMAND); DBUG_RETURN(my_errno=HA_ERR_WRONG_COMMAND);
} }
/* Get the transaction associated with the current thd, or create one
if not yet created, and update prebuilt->trx */
update_thd(thd);
/* Truncate the table in InnoDB */ /* Truncate the table in InnoDB */
error = row_truncate_table_for_mysql(prebuilt->table, prebuilt->trx); error = row_truncate_table_for_mysql(prebuilt->table, prebuilt->trx);
...@@ -5136,7 +5085,7 @@ ha_innobase::delete_table( ...@@ -5136,7 +5085,7 @@ ha_innobase::delete_table(
int error; int error;
trx_t* parent_trx; trx_t* parent_trx;
trx_t* trx; trx_t* trx;
THD *thd= current_thd; THD *thd = ha_thd();
char norm_name[1000]; char norm_name[1000];
DBUG_ENTER("ha_innobase::delete_table"); DBUG_ENTER("ha_innobase::delete_table");
...@@ -5159,14 +5108,14 @@ ha_innobase::delete_table( ...@@ -5159,14 +5108,14 @@ ha_innobase::delete_table(
trx = trx_allocate_for_mysql(); trx = trx_allocate_for_mysql();
trx->mysql_thd = current_thd; trx->mysql_thd = thd;
trx->mysql_query_str = &((*current_thd).query); trx->mysql_query_str = thd_query(thd);
if (thd->options & OPTION_NO_FOREIGN_KEY_CHECKS) { if (thd_test_options(thd, OPTION_NO_FOREIGN_KEY_CHECKS)) {
trx->check_foreigns = FALSE; trx->check_foreigns = FALSE;
} }
if (thd->options & OPTION_RELAXED_UNIQUE_CHECKS) { if (thd_test_options(thd, OPTION_RELAXED_UNIQUE_CHECKS)) {
trx->check_unique_secondary = FALSE; trx->check_unique_secondary = FALSE;
} }
...@@ -5182,7 +5131,8 @@ ha_innobase::delete_table( ...@@ -5182,7 +5131,8 @@ ha_innobase::delete_table(
/* Drop the table in InnoDB */ /* Drop the table in InnoDB */
error = row_drop_table_for_mysql(norm_name, trx, error = row_drop_table_for_mysql(norm_name, trx,
thd->lex->sql_command == SQLCOM_DROP_DB); thd_sql_command(thd)
== SQLCOM_DROP_DB);
/* Flush the log to reduce probability that the .frm files and /* Flush the log to reduce probability that the .frm files and
the InnoDB data dictionary get out-of-sync if the user runs the InnoDB data dictionary get out-of-sync if the user runs
...@@ -5223,11 +5173,12 @@ innobase_drop_database( ...@@ -5223,11 +5173,12 @@ innobase_drop_database(
char* ptr; char* ptr;
int error; int error;
char* namebuf; char* namebuf;
THD* thd = current_thd;
/* Get the transaction associated with the current thd, or create one /* Get the transaction associated with the current thd, or create one
if not yet created */ if not yet created */
parent_trx = check_trx_exists(hton, current_thd); parent_trx = check_trx_exists(hton, thd);
/* In case MySQL calls this in the middle of a SELECT query, release /* In case MySQL calls this in the middle of a SELECT query, release
possible adaptive hash latch to avoid deadlocks of threads */ possible adaptive hash latch to avoid deadlocks of threads */
...@@ -5251,10 +5202,10 @@ innobase_drop_database( ...@@ -5251,10 +5202,10 @@ innobase_drop_database(
innobase_casedn_str(namebuf); innobase_casedn_str(namebuf);
#endif #endif
trx = trx_allocate_for_mysql(); trx = trx_allocate_for_mysql();
trx->mysql_thd = current_thd; trx->mysql_thd = thd;
trx->mysql_query_str = &((*current_thd).query); trx->mysql_query_str = thd_query(thd);
if (current_thd->options & OPTION_NO_FOREIGN_KEY_CHECKS) { if (thd_test_options(thd, OPTION_NO_FOREIGN_KEY_CHECKS)) {
trx->check_foreigns = FALSE; trx->check_foreigns = FALSE;
} }
...@@ -5300,13 +5251,14 @@ ha_innobase::rename_table( ...@@ -5300,13 +5251,14 @@ ha_innobase::rename_table(
trx_t* trx; trx_t* trx;
char norm_from[1000]; char norm_from[1000];
char norm_to[1000]; char norm_to[1000];
THD* thd = ha_thd();
DBUG_ENTER("ha_innobase::rename_table"); DBUG_ENTER("ha_innobase::rename_table");
/* Get the transaction associated with the current thd, or create one /* Get the transaction associated with the current thd, or create one
if not yet created */ if not yet created */
parent_trx = check_trx_exists(ht, current_thd); parent_trx = check_trx_exists(ht, thd);
/* In case MySQL calls this in the middle of a SELECT query, release /* In case MySQL calls this in the middle of a SELECT query, release
possible adaptive hash latch to avoid deadlocks of threads */ possible adaptive hash latch to avoid deadlocks of threads */
...@@ -5320,10 +5272,10 @@ ha_innobase::rename_table( ...@@ -5320,10 +5272,10 @@ ha_innobase::rename_table(
} }
trx = trx_allocate_for_mysql(); trx = trx_allocate_for_mysql();
trx->mysql_thd = current_thd; trx->mysql_thd = thd;
trx->mysql_query_str = &((*current_thd).query); trx->mysql_query_str = thd_query(thd);
if (current_thd->options & OPTION_NO_FOREIGN_KEY_CHECKS) { if (thd_test_options(thd, OPTION_NO_FOREIGN_KEY_CHECKS)) {
trx->check_foreigns = FALSE; trx->check_foreigns = FALSE;
} }
...@@ -5391,7 +5343,7 @@ ha_innobase::records_in_range( ...@@ -5391,7 +5343,7 @@ ha_innobase::records_in_range(
DBUG_ENTER("records_in_range"); DBUG_ENTER("records_in_range");
ut_a(prebuilt->trx == thd_to_trx(current_thd, ht)); ut_a(prebuilt->trx == thd_to_trx(ha_thd(), ht));
prebuilt->trx->op_info = (char*)"estimating records in index range"; prebuilt->trx->op_info = (char*)"estimating records in index range";
...@@ -5475,7 +5427,7 @@ ha_innobase::estimate_rows_upper_bound(void) ...@@ -5475,7 +5427,7 @@ ha_innobase::estimate_rows_upper_bound(void)
external_lock(). To be safe, update the thd of the current table external_lock(). To be safe, update the thd of the current table
handle. */ handle. */
update_thd(current_thd); update_thd(ha_thd());
prebuilt->trx->op_info = (char*) prebuilt->trx->op_info = (char*)
"calculating upper bound for table rows"; "calculating upper bound for table rows";
...@@ -5592,7 +5544,7 @@ ha_innobase::info( ...@@ -5592,7 +5544,7 @@ ha_innobase::info(
external_lock(). To be safe, update the thd of the current table external_lock(). To be safe, update the thd of the current table
handle. */ handle. */
update_thd(current_thd); update_thd(ha_thd());
/* In case MySQL calls this in the middle of a SELECT query, release /* In case MySQL calls this in the middle of a SELECT query, release
possible adaptive hash latch to avoid deadlocks of threads */ possible adaptive hash latch to avoid deadlocks of threads */
...@@ -5605,15 +5557,14 @@ ha_innobase::info( ...@@ -5605,15 +5557,14 @@ ha_innobase::info(
if (flag & HA_STATUS_TIME) { if (flag & HA_STATUS_TIME) {
if (srv_stats_on_metadata) { if (srv_stats_on_metadata) {
/* In sql_show we call with this flag: update then statistics /* In sql_show we call with this flag: update
so that they are up-to-date */ then statistics so that they are up-to-date */
prebuilt->trx->op_info = (char*)"updating table statistics"; prebuilt->trx->op_info = "updating table statistics";
dict_update_statistics(ib_table); dict_update_statistics(ib_table);
prebuilt->trx->op_info = (char*) prebuilt->trx->op_info = "returning various info to MySQL";
"returning various info to MySQL";
} }
my_snprintf(path, sizeof(path), "%s/%s%s", my_snprintf(path, sizeof(path), "%s/%s%s",
...@@ -5822,8 +5773,9 @@ ha_innobase::check( ...@@ -5822,8 +5773,9 @@ ha_innobase::check(
{ {
ulint ret; ulint ret;
DBUG_ASSERT(thd == ha_thd());
ut_a(prebuilt->trx && prebuilt->trx->magic_n == TRX_MAGIC_N); ut_a(prebuilt->trx && prebuilt->trx->magic_n == TRX_MAGIC_N);
ut_a(prebuilt->trx == thd_to_trx(current_thd, ht)); ut_a(prebuilt->trx == thd_to_trx(thd, ht));
if (prebuilt->mysql_template == NULL) { if (prebuilt->mysql_template == NULL) {
/* Build the template; we will use a dummy template /* Build the template; we will use a dummy template
...@@ -5865,7 +5817,7 @@ ha_innobase::update_table_comment( ...@@ -5865,7 +5817,7 @@ ha_innobase::update_table_comment(
return((char*)comment); /* string too long */ return((char*)comment); /* string too long */
} }
update_thd(current_thd); update_thd(ha_thd());
prebuilt->trx->op_info = (char*)"returning table comment"; prebuilt->trx->op_info = (char*)"returning table comment";
...@@ -5936,7 +5888,7 @@ ha_innobase::get_foreign_key_create_info(void) ...@@ -5936,7 +5888,7 @@ ha_innobase::get_foreign_key_create_info(void)
external_lock(). To be safe, update the thd of the current table external_lock(). To be safe, update the thd of the current table
handle. */ handle. */
update_thd(current_thd); update_thd(ha_thd());
prebuilt->trx->op_info = (char*)"getting info on foreign keys"; prebuilt->trx->op_info = (char*)"getting info on foreign keys";
...@@ -5985,7 +5937,7 @@ ha_innobase::get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list) ...@@ -5985,7 +5937,7 @@ ha_innobase::get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list)
DBUG_ENTER("get_foreign_key_list"); DBUG_ENTER("get_foreign_key_list");
ut_a(prebuilt != NULL); ut_a(prebuilt != NULL);
update_thd(current_thd); update_thd(ha_thd());
prebuilt->trx->op_info = (char*)"getting list of foreign keys"; prebuilt->trx->op_info = (char*)"getting list of foreign keys";
trx_search_latch_release_if_reserved(prebuilt->trx); trx_search_latch_release_if_reserved(prebuilt->trx);
mutex_enter_noninline(&(dict_sys->mutex)); mutex_enter_noninline(&(dict_sys->mutex));
...@@ -6095,9 +6047,8 @@ ha_innobase::get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list) ...@@ -6095,9 +6047,8 @@ ha_innobase::get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list)
strlen(foreign->referenced_index->name), 1); strlen(foreign->referenced_index->name), 1);
} }
FOREIGN_KEY_INFO *pf_key_info= ((FOREIGN_KEY_INFO *) FOREIGN_KEY_INFO *pf_key_info = (FOREIGN_KEY_INFO *)
thd->memdup((gptr) &f_key_info, thd_memdup(thd, (gptr) &f_key_info, sizeof f_key_info);
sizeof(FOREIGN_KEY_INFO)));
f_key_list->push_back(pf_key_info); f_key_list->push_back(pf_key_info);
foreign = UT_LIST_GET_NEXT(foreign_list, foreign); foreign = UT_LIST_GET_NEXT(foreign_list, foreign);
} }
...@@ -6120,7 +6071,7 @@ ha_innobase::can_switch_engines(void) ...@@ -6120,7 +6071,7 @@ ha_innobase::can_switch_engines(void)
DBUG_ENTER("ha_innobase::can_switch_engines"); DBUG_ENTER("ha_innobase::can_switch_engines");
ut_a(prebuilt->trx == thd_to_trx(current_thd, ht)); ut_a(prebuilt->trx == thd_to_trx(ha_thd(), ht));
prebuilt->trx->op_info = prebuilt->trx->op_info =
"determining if there are foreign key constraints"; "determining if there are foreign key constraints";
...@@ -6201,6 +6152,19 @@ ha_innobase::extra( ...@@ -6201,6 +6152,19 @@ ha_innobase::extra(
case HA_EXTRA_KEYREAD_PRESERVE_FIELDS: case HA_EXTRA_KEYREAD_PRESERVE_FIELDS:
prebuilt->keep_other_fields_on_keyread = 1; prebuilt->keep_other_fields_on_keyread = 1;
break; break;
case HA_EXTRA_IGNORE_DUP_KEY:
prebuilt->trx->duplicates |= TRX_DUP_IGNORE;
break;
case HA_EXTRA_WRITE_CAN_REPLACE:
prebuilt->trx->duplicates |= TRX_DUP_REPLACE;
break;
case HA_EXTRA_WRITE_CANNOT_REPLACE:
prebuilt->trx->duplicates &= ~TRX_DUP_REPLACE;
break;
case HA_EXTRA_NO_IGNORE_DUP_KEY:
prebuilt->trx->duplicates &=
~(TRX_DUP_IGNORE | TRX_DUP_REPLACE);
break;
default:/* Do nothing */ default:/* Do nothing */
; ;
} }
...@@ -6267,7 +6231,7 @@ ha_innobase::start_stmt( ...@@ -6267,7 +6231,7 @@ ha_innobase::start_stmt(
prebuilt->select_lock_type = LOCK_X; prebuilt->select_lock_type = LOCK_X;
} else { } else {
if (trx->isolation_level != TRX_ISO_SERIALIZABLE if (trx->isolation_level != TRX_ISO_SERIALIZABLE
&& thd->lex->sql_command == SQLCOM_SELECT && thd_sql_command(thd) == SQLCOM_SELECT
&& lock_type == TL_READ) { && lock_type == TL_READ) {
/* For other than temporary tables, we obtain /* For other than temporary tables, we obtain
...@@ -6379,8 +6343,8 @@ ha_innobase::external_lock( ...@@ -6379,8 +6343,8 @@ ha_innobase::external_lock(
if (trx->isolation_level == TRX_ISO_SERIALIZABLE if (trx->isolation_level == TRX_ISO_SERIALIZABLE
&& prebuilt->select_lock_type == LOCK_NONE && prebuilt->select_lock_type == LOCK_NONE
&& (thd->options && thd_test_options(thd,
& (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) { OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) {
/* To get serializable execution, we let InnoDB /* To get serializable execution, we let InnoDB
conceptually add 'LOCK IN SHARE MODE' to all SELECTs conceptually add 'LOCK IN SHARE MODE' to all SELECTs
...@@ -6407,9 +6371,9 @@ ha_innobase::external_lock( ...@@ -6407,9 +6371,9 @@ ha_innobase::external_lock(
if (prebuilt->select_lock_type != LOCK_NONE) { if (prebuilt->select_lock_type != LOCK_NONE) {
if (thd->lex->sql_command == SQLCOM_LOCK_TABLES if (thd_sql_command(thd) == SQLCOM_LOCK_TABLES
&& thd->variables.innodb_table_locks && THDVAR(thd, table_locks)
&& (thd->options & OPTION_NOT_AUTOCOMMIT) && thd_test_options(thd, OPTION_NOT_AUTOCOMMIT)
&& thd_in_lock_tables(thd)) { && thd_in_lock_tables(thd)) {
ulint error = row_lock_table_for_mysql( ulint error = row_lock_table_for_mysql(
...@@ -6417,7 +6381,7 @@ ha_innobase::external_lock( ...@@ -6417,7 +6381,7 @@ ha_innobase::external_lock(
if (error != DB_SUCCESS) { if (error != DB_SUCCESS) {
error = convert_error_code_to_mysql( error = convert_error_code_to_mysql(
(int) error, user_thd); (int) error, thd);
DBUG_RETURN((int) error); DBUG_RETURN((int) error);
} }
} }
...@@ -6447,7 +6411,7 @@ ha_innobase::external_lock( ...@@ -6447,7 +6411,7 @@ ha_innobase::external_lock(
trx->mysql_n_tables_locked = 0; trx->mysql_n_tables_locked = 0;
prebuilt->used_in_HANDLER = FALSE; prebuilt->used_in_HANDLER = FALSE;
if (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) { if (!thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) {
if (trx->active_trans != 0) { if (trx->active_trans != 0) {
innobase_commit(ht, thd, TRUE); innobase_commit(ht, thd, TRUE);
} }
...@@ -6488,8 +6452,7 @@ ha_innobase::transactional_table_lock( ...@@ -6488,8 +6452,7 @@ ha_innobase::transactional_table_lock(
update_thd(thd); update_thd(thd);
if (prebuilt->table->ibd_file_missing if (prebuilt->table->ibd_file_missing && !thd_tablespace_op(thd)) {
&& !thd_tablespace_op(current_thd)) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, " InnoDB error:\n" fprintf(stderr, " InnoDB error:\n"
"MySQL is trying to use a table handle but the .ibd file for\n" "MySQL is trying to use a table handle but the .ibd file for\n"
...@@ -6534,17 +6497,17 @@ ha_innobase::transactional_table_lock( ...@@ -6534,17 +6497,17 @@ ha_innobase::transactional_table_lock(
trx->active_trans = 1; trx->active_trans = 1;
} }
if (thd->variables.innodb_table_locks && thd_in_lock_tables(thd)) { if (THDVAR(thd, table_locks) && thd_in_lock_tables(thd)) {
ulint error = DB_SUCCESS; ulint error = DB_SUCCESS;
error = row_lock_table_for_mysql(prebuilt, NULL, 0); error = row_lock_table_for_mysql(prebuilt, NULL, 0);
if (error != DB_SUCCESS) { if (error != DB_SUCCESS) {
error = convert_error_code_to_mysql((int) error, user_thd); error = convert_error_code_to_mysql((int) error, thd);
DBUG_RETURN((int) error); DBUG_RETURN((int) error);
} }
if (thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) { if (thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) {
/* Store the current undo_no of the transaction /* Store the current undo_no of the transaction
so that we know where to roll back if we have so that we know where to roll back if we have
...@@ -6590,7 +6553,7 @@ innodb_show_status( ...@@ -6590,7 +6553,7 @@ innodb_show_status(
DBUG_ENTER("innodb_show_status"); DBUG_ENTER("innodb_show_status");
if (have_innodb != SHOW_OPTION_YES) { if (hton->state != SHOW_OPTION_YES) {
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
} }
...@@ -6882,10 +6845,9 @@ ha_innobase::store_lock( ...@@ -6882,10 +6845,9 @@ ha_innobase::store_lock(
of the transaction. */ of the transaction. */
if (lock_type != TL_IGNORE if (lock_type != TL_IGNORE
&& trx->n_mysql_tables_in_use == 0) { && trx->n_mysql_tables_in_use == 0) {
trx->isolation_level = innobase_map_isolation_level( trx->isolation_level = innobase_map_isolation_level(
(enum_tx_isolation) (enum_tx_isolation) thd_tx_isolation(thd));
thd->variables.tx_isolation);
if (trx->isolation_level <= TRX_ISO_READ_COMMITTED if (trx->isolation_level <= TRX_ISO_READ_COMMITTED
&& trx->global_read_view) { && trx->global_read_view) {
...@@ -6895,23 +6857,24 @@ ha_innobase::store_lock( ...@@ -6895,23 +6857,24 @@ ha_innobase::store_lock(
read_view_close_for_mysql(trx); read_view_close_for_mysql(trx);
} }
} }
DBUG_ASSERT(thd == current_thd);
const bool in_lock_tables = thd_in_lock_tables(thd); const bool in_lock_tables = thd_in_lock_tables(thd);
const uint sql_command = thd_sql_command(thd);
if (thd->lex->sql_command == SQLCOM_DROP_TABLE) { if (sql_command == SQLCOM_DROP_TABLE) {
/* MySQL calls this function in DROP TABLE though this table /* MySQL calls this function in DROP TABLE though this table
handle may belong to another thd that is running a query. Let handle may belong to another thd that is running a query. Let
us in that case skip any changes to the prebuilt struct. */ us in that case skip any changes to the prebuilt struct. */
} else if ((lock_type == TL_READ && in_lock_tables) || } else if ((lock_type == TL_READ && in_lock_tables)
(lock_type == TL_READ_HIGH_PRIORITY && in_lock_tables) || || (lock_type == TL_READ_HIGH_PRIORITY && in_lock_tables)
lock_type == TL_READ_WITH_SHARED_LOCKS || || lock_type == TL_READ_WITH_SHARED_LOCKS
lock_type == TL_READ_NO_INSERT || || lock_type == TL_READ_NO_INSERT
(thd->lex->sql_command != SQLCOM_SELECT || (lock_type != TL_IGNORE
&& lock_type != TL_IGNORE)) { && sql_command != SQLCOM_SELECT)) {
/* The OR cases above are in this order: /* The OR cases above are in this order:
1) MySQL is doing LOCK TABLES ... READ LOCAL, or we 1) MySQL is doing LOCK TABLES ... READ LOCAL, or we
...@@ -6936,12 +6899,12 @@ ha_innobase::store_lock( ...@@ -6936,12 +6899,12 @@ ha_innobase::store_lock(
isolation_level = trx->isolation_level; isolation_level = trx->isolation_level;
if ((srv_locks_unsafe_for_binlog if ((srv_locks_unsafe_for_binlog
|| isolation_level == TRX_ISO_READ_COMMITTED) || isolation_level == TRX_ISO_READ_COMMITTED)
&& isolation_level != TRX_ISO_SERIALIZABLE && isolation_level != TRX_ISO_SERIALIZABLE
&& (lock_type == TL_READ || lock_type == TL_READ_NO_INSERT) && (lock_type == TL_READ || lock_type == TL_READ_NO_INSERT)
&& (thd->lex->sql_command == SQLCOM_INSERT_SELECT && (sql_command == SQLCOM_INSERT_SELECT
|| thd->lex->sql_command == SQLCOM_UPDATE || sql_command == SQLCOM_UPDATE
|| thd->lex->sql_command == SQLCOM_CREATE_TABLE)) { || sql_command == SQLCOM_CREATE_TABLE)) {
/* If we either have innobase_locks_unsafe_for_binlog /* If we either have innobase_locks_unsafe_for_binlog
option set or this session is using READ COMMITTED option set or this session is using READ COMMITTED
...@@ -6954,7 +6917,7 @@ ha_innobase::store_lock( ...@@ -6954,7 +6917,7 @@ ha_innobase::store_lock(
prebuilt->select_lock_type = LOCK_NONE; prebuilt->select_lock_type = LOCK_NONE;
prebuilt->stored_select_lock_type = LOCK_NONE; prebuilt->stored_select_lock_type = LOCK_NONE;
} else if (thd->lex->sql_command == SQLCOM_CHECKSUM) { } else if (sql_command == SQLCOM_CHECKSUM) {
/* Use consistent read for checksum table */ /* Use consistent read for checksum table */
prebuilt->select_lock_type = LOCK_NONE; prebuilt->select_lock_type = LOCK_NONE;
...@@ -6984,7 +6947,7 @@ ha_innobase::store_lock( ...@@ -6984,7 +6947,7 @@ ha_innobase::store_lock(
(if it does not use a consistent read). */ (if it does not use a consistent read). */
if (lock_type == TL_READ if (lock_type == TL_READ
&& thd->lex->sql_command == SQLCOM_LOCK_TABLES) { && sql_command == SQLCOM_LOCK_TABLES) {
/* We come here if MySQL is processing LOCK TABLES /* We come here if MySQL is processing LOCK TABLES
... READ LOCAL. MyISAM under that table lock type ... READ LOCAL. MyISAM under that table lock type
reads the table as it was at the time the lock was reads the table as it was at the time the lock was
...@@ -7010,24 +6973,25 @@ ha_innobase::store_lock( ...@@ -7010,24 +6973,25 @@ ha_innobase::store_lock(
TRUE there). */ TRUE there). */
if ((lock_type >= TL_WRITE_CONCURRENT_INSERT if ((lock_type >= TL_WRITE_CONCURRENT_INSERT
&& lock_type <= TL_WRITE) && lock_type <= TL_WRITE)
&& !(in_lock_tables && !(in_lock_tables
&& thd->lex->sql_command == SQLCOM_LOCK_TABLES) && sql_command == SQLCOM_LOCK_TABLES)
&& !thd_tablespace_op(thd) && !thd_tablespace_op(thd)
&& thd->lex->sql_command != SQLCOM_TRUNCATE && sql_command != SQLCOM_TRUNCATE
&& thd->lex->sql_command != SQLCOM_OPTIMIZE && sql_command != SQLCOM_OPTIMIZE
#ifdef __WIN__ #ifdef __WIN__
/* For alter table on win32 for succesful operation /* For alter table on win32 for successful
completion it is used TL_WRITE(=10) lock instead of operation completion it is used TL_WRITE(=10) lock
TL_WRITE_ALLOW_READ(=6), however here in innodb handler instead of TL_WRITE_ALLOW_READ(=6), however here
TL_WRITE is lifted to TL_WRITE_ALLOW_WRITE, which causes in innodb handler TL_WRITE is lifted to
race condition when several clients do alter table TL_WRITE_ALLOW_WRITE, which causes race condition
simultaneously (bug #17264). This fix avoids the problem. */ when several clients do alter table simultaneously
&& thd->lex->sql_command != SQLCOM_ALTER_TABLE (bug #17264). This fix avoids the problem. */
&& sql_command != SQLCOM_ALTER_TABLE
#endif #endif
&& thd->lex->sql_command != SQLCOM_CREATE_TABLE) { && sql_command != SQLCOM_CREATE_TABLE) {
lock_type = TL_WRITE_ALLOW_WRITE; lock_type = TL_WRITE_ALLOW_WRITE;
} }
...@@ -7040,10 +7004,10 @@ ha_innobase::store_lock( ...@@ -7040,10 +7004,10 @@ ha_innobase::store_lock(
We especially allow concurrent inserts if MySQL is at the We especially allow concurrent inserts if MySQL is at the
start of a stored procedure call (SQLCOM_CALL) start of a stored procedure call (SQLCOM_CALL)
(MySQL does have in_lock_tables TRUE there). */ (MySQL does have thd_in_lock_tables() TRUE there). */
if (lock_type == TL_READ_NO_INSERT if (lock_type == TL_READ_NO_INSERT
&& thd->lex->sql_command != SQLCOM_LOCK_TABLES) { && sql_command != SQLCOM_LOCK_TABLES) {
lock_type = TL_READ; lock_type = TL_READ;
} }
...@@ -7078,7 +7042,7 @@ ha_innobase::innobase_read_and_init_auto_inc( ...@@ -7078,7 +7042,7 @@ ha_innobase::innobase_read_and_init_auto_inc(
ut_a(prebuilt->table); ut_a(prebuilt->table);
/* Prepare prebuilt->trx in the table handle */ /* Prepare prebuilt->trx in the table handle */
update_thd(current_thd); update_thd(ha_thd());
if (prebuilt->trx->conc_state == TRX_NOT_STARTED) { if (prebuilt->trx->conc_state == TRX_NOT_STARTED) {
trx_was_not_started = TRUE; trx_was_not_started = TRUE;
...@@ -7221,7 +7185,7 @@ void ha_innobase::get_auto_increment( ...@@ -7221,7 +7185,7 @@ void ha_innobase::get_auto_increment(
int error; int error;
/* Prepare prebuilt->trx in the table handle */ /* Prepare prebuilt->trx in the table handle */
update_thd(current_thd); update_thd(ha_thd());
error = innobase_read_and_init_auto_inc(&nr); error = innobase_read_and_init_auto_inc(&nr);
...@@ -7250,7 +7214,7 @@ ha_innobase::reset_auto_increment(ulonglong value) ...@@ -7250,7 +7214,7 @@ ha_innobase::reset_auto_increment(ulonglong value)
int error; int error;
update_thd(current_thd); update_thd(ha_thd());
error = row_lock_table_autoinc_for_mysql(prebuilt); error = row_lock_table_autoinc_for_mysql(prebuilt);
...@@ -7269,7 +7233,7 @@ ha_innobase::reset_auto_increment(ulonglong value) ...@@ -7269,7 +7233,7 @@ ha_innobase::reset_auto_increment(ulonglong value)
bool bool
ha_innobase::get_error_message(int error, String *buf) ha_innobase::get_error_message(int error, String *buf)
{ {
trx_t* trx = check_trx_exists(ht, current_thd); trx_t* trx = check_trx_exists(ht, ha_thd());
buf->copy(trx->detailed_error, strlen(trx->detailed_error), buf->copy(trx->detailed_error, strlen(trx->detailed_error),
system_charset_info); system_charset_info);
...@@ -7392,7 +7356,6 @@ ha_innobase::get_mysql_bin_log_pos() ...@@ -7392,7 +7356,6 @@ ha_innobase::get_mysql_bin_log_pos()
return(trx_sys_mysql_bin_log_pos); return(trx_sys_mysql_bin_log_pos);
} }
extern "C" {
/********************************************************************** /**********************************************************************
This function is used to find the storage length in bytes of the first n This function is used to find the storage length in bytes of the first n
characters for prefix indexes using a multibyte character set. The function characters for prefix indexes using a multibyte character set. The function
...@@ -7401,7 +7364,7 @@ index field in bytes. ...@@ -7401,7 +7364,7 @@ index field in bytes.
NOTE: the prototype of this function is copied to data0type.c! If you change NOTE: the prototype of this function is copied to data0type.c! If you change
this function, you MUST change also data0type.c! */ this function, you MUST change also data0type.c! */
extern "C"
ulint ulint
innobase_get_at_most_n_mbchars( innobase_get_at_most_n_mbchars(
/*===========================*/ /*===========================*/
...@@ -7466,46 +7429,6 @@ innobase_get_at_most_n_mbchars( ...@@ -7466,46 +7429,6 @@ innobase_get_at_most_n_mbchars(
return(char_length); return(char_length);
} }
}
/**********************************************************************
This function returns true if
1) SQL-query in the current thread
is either REPLACE or LOAD DATA INFILE REPLACE.
2) SQL-query in the current thread
is INSERT ON DUPLICATE KEY UPDATE.
NOTE that storage/innobase/row/row0ins.c must contain the
prototype for this function ! */
extern "C"
ibool
innobase_query_is_update(void)
/*==========================*/
{
THD* thd = current_thd;
if (!thd) {
/* InnoDB's internal threads may run InnoDB stored procedures
that call this function. Then current_thd is not defined
(it is probably NULL). */
return(FALSE);
}
switch (thd->lex->sql_command) {
case SQLCOM_REPLACE:
case SQLCOM_REPLACE_SELECT:
return(TRUE);
case SQLCOM_LOAD:
return(thd->lex->duplicates == DUP_REPLACE);
case SQLCOM_INSERT:
return(thd->lex->duplicates == DUP_UPDATE);
default:
return(FALSE);
}
}
/*********************************************************************** /***********************************************************************
This function is used to prepare X/Open XA distributed transaction */ This function is used to prepare X/Open XA distributed transaction */
...@@ -7523,8 +7446,8 @@ innobase_xa_prepare( ...@@ -7523,8 +7446,8 @@ innobase_xa_prepare(
int error = 0; int error = 0;
trx_t* trx = check_trx_exists(hton, thd); trx_t* trx = check_trx_exists(hton, thd);
if (thd->lex->sql_command != SQLCOM_XA_PREPARE && if (thd_sql_command(thd) != SQLCOM_XA_PREPARE &&
(all || !(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))) (all || !thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))
{ {
/* For ibbackup to work the order of transactions in binlog /* For ibbackup to work the order of transactions in binlog
...@@ -7550,12 +7473,12 @@ innobase_xa_prepare( ...@@ -7550,12 +7473,12 @@ innobase_xa_prepare(
trx->active_trans = 2; trx->active_trans = 2;
} }
if (!thd->variables.innodb_support_xa) { if (!THDVAR(thd, support_xa)) {
return(0); return(0);
} }
trx->xid=thd->transaction.xid_state.xid; thd_get_xid(thd, &trx->xid);
/* Release a possible FIFO ticket and search latch. Since we will /* Release a possible FIFO ticket and search latch. Since we will
reserve the kernel mutex, we have to release the search system latch reserve the kernel mutex, we have to release the search system latch
...@@ -7570,7 +7493,7 @@ innobase_xa_prepare( ...@@ -7570,7 +7493,7 @@ innobase_xa_prepare(
} }
if (all if (all
|| (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))) { || (!thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) {
/* We were instructed to prepare the whole transaction, or /* We were instructed to prepare the whole transaction, or
this is an SQL statement end and autocommit is on */ this is an SQL statement end and autocommit is on */
...@@ -7682,8 +7605,7 @@ innobase_create_cursor_view( ...@@ -7682,8 +7605,7 @@ innobase_create_cursor_view(
handlerton *hton, /* in: innobase hton */ handlerton *hton, /* in: innobase hton */
THD* thd) /* in: user thread handle */ THD* thd) /* in: user thread handle */
{ {
return(read_cursor_view_create_for_mysql( return(read_cursor_view_create_for_mysql(check_trx_exists(hton, thd)));
check_trx_exists(hton, thd)));
} }
/*********************************************************************** /***********************************************************************
...@@ -7698,8 +7620,8 @@ innobase_close_cursor_view( ...@@ -7698,8 +7620,8 @@ innobase_close_cursor_view(
THD* thd, /* in: user thread handle */ THD* thd, /* in: user thread handle */
void* curview)/* in: Consistent read view to be closed */ void* curview)/* in: Consistent read view to be closed */
{ {
read_cursor_view_close_for_mysql(check_trx_exists(hton, current_thd), read_cursor_view_close_for_mysql(check_trx_exists(hton, thd),
(cursor_view_t*) curview); (cursor_view_t*) curview);
} }
/*********************************************************************** /***********************************************************************
...@@ -7715,8 +7637,8 @@ innobase_set_cursor_view( ...@@ -7715,8 +7637,8 @@ innobase_set_cursor_view(
THD* thd, /* in: user thread handle */ THD* thd, /* in: user thread handle */
void* curview)/* in: Consistent cursor view to be set */ void* curview)/* in: Consistent cursor view to be set */
{ {
read_cursor_set_for_mysql(check_trx_exists(hton, current_thd), read_cursor_set_for_mysql(check_trx_exists(hton, thd),
(cursor_view_t*) curview); (cursor_view_t*) curview);
} }
...@@ -7762,6 +7684,222 @@ static SHOW_VAR innodb_status_variables_export[]= { ...@@ -7762,6 +7684,222 @@ static SHOW_VAR innodb_status_variables_export[]= {
static struct st_mysql_storage_engine innobase_storage_engine= static struct st_mysql_storage_engine innobase_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION }; { MYSQL_HANDLERTON_INTERFACE_VERSION };
/* plugin options */
static MYSQL_SYSVAR_BOOL(checksums, innobase_use_checksums,
PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
"Enable InnoDB checksums validation (enabled by default). "
"Disable with --skip-innodb-checksums.",
NULL, NULL, TRUE);
static MYSQL_SYSVAR_STR(data_home_dir, innobase_data_home_dir,
PLUGIN_VAR_READONLY,
"The common part for InnoDB table spaces.",
NULL, NULL, NULL);
static MYSQL_SYSVAR_BOOL(doublewrite, innobase_use_doublewrite,
PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
"Enable InnoDB doublewrite buffer (enabled by default). "
"Disable with --skip-innodb-doublewrite.",
NULL, NULL, TRUE);
static MYSQL_SYSVAR_ULONG(fast_shutdown, innobase_fast_shutdown,
PLUGIN_VAR_OPCMDARG,
"Speeds up the shutdown process of the InnoDB storage engine. Possible "
"values are 0, 1 (faster)"
/*
NetWare can't close unclosed files, can't automatically kill remaining
threads, etc, so on this OS we disable the crash-like InnoDB shutdown.
*/
IF_NETWARE("", " or 2 (fastest - crash-like)")
".",
NULL, NULL, 1, 0, IF_NETWARE(1,2), 0);
static MYSQL_SYSVAR_BOOL(file_per_table, innobase_file_per_table,
PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
"Stores each InnoDB table to an .ibd file in the database dir.",
NULL, NULL, FALSE);
static MYSQL_SYSVAR_ULONG(flush_log_at_trx_commit, srv_flush_log_at_trx_commit,
PLUGIN_VAR_OPCMDARG,
"Set to 0 (write and flush once per second),"
" 1 (write and flush at each commit)"
" or 2 (write at commit, flush once per second).",
NULL, NULL, 1, 0, 2, 0);
static MYSQL_SYSVAR_STR(flush_method, innobase_unix_file_flush_method,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"With which method to flush data.", NULL, NULL, NULL);
static MYSQL_SYSVAR_BOOL(locks_unsafe_for_binlog, innobase_locks_unsafe_for_binlog,
PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
"Force InnoDB to not use next-key locking, to use only row-level locking.",
NULL, NULL, FALSE);
#ifdef UNIV_LOG_ARCHIVE
static MYSQL_SYSVAR_STR(log_arch_dir, innobase_log_arch_dir,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"Where full logs should be archived.", NULL, NULL, NULL);
static MYSQL_SYSVAR_BOOL(log_archive, innobase_log_archive,
PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
"Set to 1 if you want to have logs archived.", NULL, NULL, FALSE);
#endif /* UNIV_LOG_ARCHIVE */
static MYSQL_SYSVAR_STR(log_group_home_dir, innobase_log_group_home_dir,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"Path to InnoDB log files.", NULL, NULL, NULL);
static MYSQL_SYSVAR_ULONG(max_dirty_pages_pct, srv_max_buf_pool_modified_pct,
PLUGIN_VAR_RQCMDARG,
"Percentage of dirty pages allowed in bufferpool.",
NULL, NULL, 90, 0, 100, 0);
static MYSQL_SYSVAR_ULONG(max_purge_lag, srv_max_purge_lag,
PLUGIN_VAR_RQCMDARG,
"Desired maximum length of the purge queue (0 = no limit)",
NULL, NULL, 0, 0, ~0L, 0);
static MYSQL_SYSVAR_BOOL(rollback_on_timeout, innobase_rollback_on_timeout,
PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
"Roll back the complete transaction on lock wait timeout, for 4.x compatibility (disabled by default)",
NULL, NULL, FALSE);
static MYSQL_SYSVAR_BOOL(status_file, innobase_create_status_file,
PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_NOSYSVAR,
"Enable SHOW INNODB STATUS output in the innodb_status.<pid> file",
NULL, NULL, FALSE);
static MYSQL_SYSVAR_BOOL(stats_on_metadata, innobase_stats_on_metadata,
PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_NOSYSVAR,
"Enable statistics gathering for metadata commands such as SHOW TABLE STATUS (on by default)",
NULL, NULL, TRUE);
static MYSQL_SYSVAR_LONG(additional_mem_pool_size, innobase_additional_mem_pool_size,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"Size of a memory pool InnoDB uses to store data dictionary information and other internal data structures.",
NULL, NULL, 1*1024*1024L, 512*1024L, ~0L, 1024);
static MYSQL_SYSVAR_ULONG(autoextend_increment, srv_auto_extend_increment,
PLUGIN_VAR_RQCMDARG,
"Data file autoextend increment in megabytes",
NULL, NULL, 8L, 1L, 1000L, 0);
static MYSQL_SYSVAR_LONGLONG(buffer_pool_size, innobase_buffer_pool_size,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"The size of the memory buffer InnoDB uses to cache data and indexes of its tables.",
NULL, NULL, 8*1024*1024L, 1024*1024L, LONGLONG_MAX, 1024*1024L);
static MYSQL_SYSVAR_ULONG(commit_concurrency, srv_commit_concurrency,
PLUGIN_VAR_RQCMDARG,
"Helps in performance tuning in heavily concurrent environments.",
NULL, NULL, 0, 0, 1000, 0);
static MYSQL_SYSVAR_ULONG(concurrency_tickets, srv_n_free_tickets_to_enter,
PLUGIN_VAR_RQCMDARG,
"Number of times a thread is allowed to enter InnoDB within the same SQL query after it has once got the ticket",
NULL, NULL, 500L, 1L, ~0L, 0);
static MYSQL_SYSVAR_LONG(file_io_threads, innobase_file_io_threads,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"Number of file I/O threads in InnoDB.",
NULL, NULL, 4, 4, 64, 0);
static MYSQL_SYSVAR_LONG(force_recovery, innobase_force_recovery,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"Helps to save your data in case the disk image of the database becomes corrupt.",
NULL, NULL, 0, 0, 6, 0);
static MYSQL_SYSVAR_LONG(lock_wait_timeout, innobase_lock_wait_timeout,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"Timeout in seconds an InnoDB transaction may wait for a lock before being rolled back.",
NULL, NULL, 50, 1, 1024 * 1024 * 1024, 0);
static MYSQL_SYSVAR_LONG(log_buffer_size, innobase_log_buffer_size,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"The size of the buffer which InnoDB uses to write log to the log files on disk.",
NULL, NULL, 1024*1024L, 256*1024L, ~0L, 1024);
static MYSQL_SYSVAR_LONGLONG(log_file_size, innobase_log_file_size,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"Size of each log file in a log group.",
NULL, NULL, 5*1024*1024L, 1*1024*1024L, LONGLONG_MAX, 1024*1024L);
static MYSQL_SYSVAR_LONG(log_files_in_group, innobase_log_files_in_group,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"Number of log files in the log group. InnoDB writes to the files in a circular fashion. Value 3 is recommended here.",
NULL, NULL, 2, 2, 100, 0);
static MYSQL_SYSVAR_LONG(mirrored_log_groups, innobase_mirrored_log_groups,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"Number of identical copies of log groups we keep for the database. Currently this should be set to 1.",
NULL, NULL, 1, 1, 10, 0);
static MYSQL_SYSVAR_LONG(open_files, innobase_open_files,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"How many files at the maximum InnoDB keeps open at the same time.",
NULL, NULL, 300L, 10L, ~0L, 0);
static MYSQL_SYSVAR_ULONG(sync_spin_loops, srv_n_spin_wait_rounds,
PLUGIN_VAR_RQCMDARG,
"Count of spin-loop rounds in InnoDB mutexes",
NULL, NULL, 20L, 0L, ~0L, 0);
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);
static MYSQL_SYSVAR_ULONG(thread_sleep_delay, srv_thread_sleep_delay,
PLUGIN_VAR_RQCMDARG,
"Time of innodb thread sleeping before joining InnoDB queue (usec). Value 0 disable a sleep",
NULL, NULL, 10000L, 0L, ~0L, 0);
static MYSQL_SYSVAR_STR(data_file_path, innobase_data_file_path,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"Path to individual files and their sizes.",
NULL, NULL, NULL);
static struct st_mysql_sys_var* innobase_system_variables[]= {
MYSQL_SYSVAR(additional_mem_pool_size),
MYSQL_SYSVAR(autoextend_increment),
MYSQL_SYSVAR(buffer_pool_size),
MYSQL_SYSVAR(checksums),
MYSQL_SYSVAR(commit_concurrency),
MYSQL_SYSVAR(concurrency_tickets),
MYSQL_SYSVAR(data_file_path),
MYSQL_SYSVAR(data_home_dir),
MYSQL_SYSVAR(doublewrite),
MYSQL_SYSVAR(fast_shutdown),
MYSQL_SYSVAR(file_io_threads),
MYSQL_SYSVAR(file_per_table),
MYSQL_SYSVAR(flush_log_at_trx_commit),
MYSQL_SYSVAR(flush_method),
MYSQL_SYSVAR(force_recovery),
MYSQL_SYSVAR(locks_unsafe_for_binlog),
MYSQL_SYSVAR(lock_wait_timeout),
#ifdef UNIV_LOG_ARCHIVE
MYSQL_SYSVAR(log_arch_dir),
MYSQL_SYSVAR(log_archive),
#endif /* UNIV_LOG_ARCHIVE */
MYSQL_SYSVAR(log_buffer_size),
MYSQL_SYSVAR(log_file_size),
MYSQL_SYSVAR(log_files_in_group),
MYSQL_SYSVAR(log_group_home_dir),
MYSQL_SYSVAR(max_dirty_pages_pct),
MYSQL_SYSVAR(max_purge_lag),
MYSQL_SYSVAR(mirrored_log_groups),
MYSQL_SYSVAR(open_files),
MYSQL_SYSVAR(rollback_on_timeout),
MYSQL_SYSVAR(stats_on_metadata),
MYSQL_SYSVAR(status_file),
MYSQL_SYSVAR(support_xa),
MYSQL_SYSVAR(sync_spin_loops),
MYSQL_SYSVAR(table_locks),
MYSQL_SYSVAR(thread_concurrency),
MYSQL_SYSVAR(thread_sleep_delay),
NULL
};
mysql_declare_plugin(innobase) mysql_declare_plugin(innobase)
{ {
MYSQL_STORAGE_ENGINE_PLUGIN, MYSQL_STORAGE_ENGINE_PLUGIN,
...@@ -7774,9 +7912,7 @@ mysql_declare_plugin(innobase) ...@@ -7774,9 +7912,7 @@ mysql_declare_plugin(innobase)
NULL, /* Plugin Deinit */ NULL, /* Plugin Deinit */
0x0100 /* 1.0 */, 0x0100 /* 1.0 */,
innodb_status_variables_export,/* status variables */ innodb_status_variables_export,/* status variables */
NULL, /* system variables */ innobase_system_variables, /* system variables */
NULL /* config options */ NULL /* reserved */
} }
mysql_declare_plugin_end; mysql_declare_plugin_end;
#endif
...@@ -190,41 +190,6 @@ class ha_innobase: public handler ...@@ -190,41 +190,6 @@ class ha_innobase: public handler
uint table_changes); uint table_changes);
}; };
extern ulong innobase_fast_shutdown;
extern ulong innobase_large_page_size;
extern long innobase_mirrored_log_groups, innobase_log_files_in_group;
extern longlong innobase_buffer_pool_size, innobase_log_file_size;
extern long innobase_log_buffer_size;
extern long innobase_additional_mem_pool_size;
extern long innobase_buffer_pool_awe_mem_mb;
extern long innobase_file_io_threads, innobase_lock_wait_timeout;
extern long innobase_force_recovery;
extern long innobase_open_files;
extern char *innobase_data_home_dir, *innobase_data_file_path;
extern char *innobase_log_group_home_dir, *innobase_log_arch_dir;
extern char *innobase_unix_file_flush_method;
/* The following variables have to be my_bool for SHOW VARIABLES to work */
extern my_bool innobase_log_archive,
innobase_use_doublewrite,
innobase_use_checksums,
innobase_use_large_pages,
innobase_use_native_aio,
innobase_file_per_table, innobase_locks_unsafe_for_binlog,
innobase_rollback_on_timeout,
innobase_create_status_file,
innobase_stats_on_metadata;
extern "C" {
extern ulong srv_max_buf_pool_modified_pct;
extern ulong srv_max_purge_lag;
extern ulong srv_auto_extend_increment;
extern ulong srv_n_spin_wait_rounds;
extern ulong srv_n_free_tickets_to_enter;
extern ulong srv_thread_sleep_delay;
extern ulong srv_thread_concurrency;
extern ulong srv_commit_concurrency;
extern ulong srv_flush_log_at_trx_commit;
}
/* /*
don't delete it - it may be re-enabled later don't delete it - it may be re-enabled later
as an optimization for the most common case InnoDB+binlog as an optimization for the most common case InnoDB+binlog
......
# Copyright (C) 2001, 2003 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public 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 ../include/Makefile.i
noinst_LIBRARIES = libibuf.a
libibuf_a_SOURCES = ibuf0ibuf.c
EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Makefile included in Makefile.am in every subdirectory
INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include \
-I$(top_srcdir)/regex \
-I$(top_srcdir)/storage/innobase/include \
-I$(top_srcdir)/sql \
-I$(srcdir)
# Don't update the files from bitkeeper
%::SCCS/s.%
...@@ -453,7 +453,8 @@ struct trx_struct{ ...@@ -453,7 +453,8 @@ struct trx_struct{
dulint table_id; /* table id if the preceding field is dulint table_id; /* table id if the preceding field is
TRUE */ TRUE */
/*------------------------------*/ /*------------------------------*/
int active_trans; /* 1 - if a transaction in MySQL unsigned duplicates:2; /* TRX_DUP_IGNORE | TRX_DUP_REPLACE */
unsigned active_trans:2; /* 1 - if a transaction in MySQL
is active. 2 - if prepare_commit_mutex is active. 2 - if prepare_commit_mutex
was taken */ was taken */
void* mysql_thd; /* MySQL thread handle corresponding void* mysql_thd; /* MySQL thread handle corresponding
...@@ -678,19 +679,19 @@ struct trx_struct{ ...@@ -678,19 +679,19 @@ struct trx_struct{
single operation of a single operation of a
transaction, e.g., a parallel transaction, e.g., a parallel
query */ query */
/* Transaction concurrency states */ /* Transaction concurrency states (trx->conc_state) */
#define TRX_NOT_STARTED 1 #define TRX_NOT_STARTED 1
#define TRX_ACTIVE 2 #define TRX_ACTIVE 2
#define TRX_COMMITTED_IN_MEMORY 3 #define TRX_COMMITTED_IN_MEMORY 3
#define TRX_PREPARED 4 /* Support for 2PC/XA */ #define TRX_PREPARED 4 /* Support for 2PC/XA */
/* Transaction execution states when trx state is TRX_ACTIVE */ /* Transaction execution states when trx->conc_state == TRX_ACTIVE */
#define TRX_QUE_RUNNING 1 /* transaction is running */ #define TRX_QUE_RUNNING 1 /* transaction is running */
#define TRX_QUE_LOCK_WAIT 2 /* transaction is waiting for a lock */ #define TRX_QUE_LOCK_WAIT 2 /* transaction is waiting for a lock */
#define TRX_QUE_ROLLING_BACK 3 /* transaction is rolling back */ #define TRX_QUE_ROLLING_BACK 3 /* transaction is rolling back */
#define TRX_QUE_COMMITTING 4 /* transaction is committing */ #define TRX_QUE_COMMITTING 4 /* transaction is committing */
/* Transaction isolation levels */ /* Transaction isolation levels (trx->isolation_level) */
#define TRX_ISO_READ_UNCOMMITTED 1 /* dirty read: non-locking #define TRX_ISO_READ_UNCOMMITTED 1 /* dirty read: non-locking
SELECTs are performed so that SELECTs are performed so that
we do not look at a possible we do not look at a possible
...@@ -725,6 +726,12 @@ struct trx_struct{ ...@@ -725,6 +726,12 @@ struct trx_struct{
converted to LOCK IN SHARE converted to LOCK IN SHARE
MODE reads */ MODE reads */
/* Treatment of duplicate values (trx->duplicates; for example, in inserts).
Multiple flags can be combined with bitwise OR. */
#define TRX_DUP_IGNORE 1 /* duplicate rows are to be updated */
#define TRX_DUP_REPLACE 2 /* duplicate rows are to be replaced */
/* Types of a trx signal */ /* Types of a trx signal */
#define TRX_SIG_NO_SIGNAL 100 #define TRX_SIG_NO_SIGNAL 100
#define TRX_SIG_TOTAL_ROLLBACK 1 #define TRX_SIG_TOTAL_ROLLBACK 1
......
# Copyright (C) 2001, 2003 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public 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 ../include/Makefile.i
noinst_LIBRARIES = liblock.a
liblock_a_SOURCES = lock0lock.c
EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2001, 2003 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public 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 ../include/Makefile.i
noinst_LIBRARIES = liblog.a
liblog_a_SOURCES = log0log.c log0recv.c
EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2001, 2003 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public 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 ../include/Makefile.i
noinst_LIBRARIES = libmach.a
libmach_a_SOURCES = mach0data.c
EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2001, 2003 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public 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 ../include/Makefile.i
noinst_LIBRARIES = libmem.a
libmem_a_SOURCES = mem0mem.c mem0pool.c
EXTRA_DIST = mem0dbg.c
EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2001, 2003 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public 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 ../include/Makefile.i
noinst_LIBRARIES = libmtr.a
libmtr_a_SOURCES = mtr0mtr.c mtr0log.c
EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2001, 2003-2004 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public 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 ../include/Makefile.i
noinst_LIBRARIES = libos.a
libos_a_SOURCES = os0proc.c os0sync.c os0thread.c os0file.c
EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2001, 2003 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public 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 ../include/Makefile.i
noinst_LIBRARIES = libpage.a
libpage_a_SOURCES = page0page.c page0cur.c
EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2001, 2003 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public 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 ../include/Makefile.i
noinst_LIBRARIES = libpars.a
noinst_HEADERS = pars0grm.h
libpars_a_SOURCES = pars0grm.c lexyy.c pars0opt.c pars0pars.c pars0sym.c
EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
...@@ -2,6 +2,8 @@ MYSQL_STORAGE_ENGINE(innobase, innodb, [InnoDB Storage Engine], ...@@ -2,6 +2,8 @@ MYSQL_STORAGE_ENGINE(innobase, innodb, [InnoDB Storage Engine],
[Transactional Tables using InnoDB], [max,max-no-ndb]) [Transactional Tables using InnoDB], [max,max-no-ndb])
MYSQL_PLUGIN_DIRECTORY(innobase, [storage/innobase]) MYSQL_PLUGIN_DIRECTORY(innobase, [storage/innobase])
MYSQL_PLUGIN_STATIC(innobase, [libinnobase.a]) MYSQL_PLUGIN_STATIC(innobase, [libinnobase.a])
MYSQL_PLUGIN_DYNAMIC(innobase, [ha_innodb.la])
MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS(innobase, [handler/ha_innodb.cc])
MYSQL_PLUGIN_ACTIONS(innobase, [ MYSQL_PLUGIN_ACTIONS(innobase, [
AC_CHECK_LIB(rt, aio_read, [innodb_system_libs="-lrt"]) AC_CHECK_LIB(rt, aio_read, [innodb_system_libs="-lrt"])
AC_SUBST(innodb_system_libs) AC_SUBST(innodb_system_libs)
...@@ -38,37 +40,6 @@ MYSQL_PLUGIN_ACTIONS(innobase, [ ...@@ -38,37 +40,6 @@ MYSQL_PLUGIN_ACTIONS(innobase, [
openbsd*) openbsd*)
CFLAGS="$CFLAGS -DUNIV_MUST_NOT_INLINE";; CFLAGS="$CFLAGS -DUNIV_MUST_NOT_INLINE";;
esac esac
AC_CONFIG_FILES(
storage/innobase/ut/Makefile
storage/innobase/btr/Makefile
storage/innobase/buf/Makefile
storage/innobase/data/Makefile
storage/innobase/dict/Makefile
storage/innobase/dyn/Makefile
storage/innobase/eval/Makefile
storage/innobase/fil/Makefile
storage/innobase/fsp/Makefile
storage/innobase/fut/Makefile
storage/innobase/ha/Makefile
storage/innobase/ibuf/Makefile
storage/innobase/lock/Makefile
storage/innobase/log/Makefile
storage/innobase/mach/Makefile
storage/innobase/mem/Makefile
storage/innobase/mtr/Makefile
storage/innobase/os/Makefile
storage/innobase/page/Makefile
storage/innobase/pars/Makefile
storage/innobase/que/Makefile
storage/innobase/read/Makefile
storage/innobase/rem/Makefile
storage/innobase/row/Makefile
storage/innobase/srv/Makefile
storage/innobase/sync/Makefile
storage/innobase/thr/Makefile
storage/innobase/trx/Makefile
storage/innobase/handler/Makefile
storage/innobase/usr/Makefile)
]) ])
MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS(innobase, [handler/ha_innodb.cc]) MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS(innobase, [handler/ha_innodb.cc])
# Copyright (C) 2001, 2003 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public 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 ../include/Makefile.i
noinst_LIBRARIES = libque.a
libque_a_SOURCES = que0que.c
EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2001, 2003 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public 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 ../include/Makefile.i
noinst_LIBRARIES = libread.a
libread_a_SOURCES = read0read.c
EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2001, 2003 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public 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 ../include/Makefile.i
noinst_LIBRARIES = librem.a
librem_a_SOURCES = rem0rec.c rem0cmp.c
EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2001, 2003 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public 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 ../include/Makefile.i
noinst_LIBRARIES = librow.a
librow_a_SOURCES = row0ins.c row0mysql.c row0purge.c row0row.c row0sel.c\
row0uins.c row0umod.c row0undo.c row0upd.c row0vers.c
EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
...@@ -51,21 +51,6 @@ innobase_invalidate_query_cache( ...@@ -51,21 +51,6 @@ innobase_invalidate_query_cache(
ulint full_name_len); /* in: full name length where also the null ulint full_name_len); /* in: full name length where also the null
chars count */ chars count */
/**********************************************************************
This function returns true if
1) SQL-query in the current thread
is either REPLACE or LOAD DATA INFILE REPLACE.
2) SQL-query in the current thread
is INSERT ON DUPLICATE KEY UPDATE.
NOTE that /mysql/innobase/row/row0ins.c must contain the
prototype for this function ! */
ibool
innobase_query_is_update(void);
/************************************************************************* /*************************************************************************
Creates an insert node struct. */ Creates an insert node struct. */
...@@ -1652,6 +1637,7 @@ row_ins_scan_sec_index_for_duplicate( ...@@ -1652,6 +1637,7 @@ row_ins_scan_sec_index_for_duplicate(
btr_pcur_t pcur; btr_pcur_t pcur;
ulint err = DB_SUCCESS; ulint err = DB_SUCCESS;
ibool moved; ibool moved;
unsigned allow_duplicates;
mtr_t mtr; mtr_t mtr;
mem_heap_t* heap = NULL; mem_heap_t* heap = NULL;
ulint offsets_[REC_OFFS_NORMAL_SIZE]; ulint offsets_[REC_OFFS_NORMAL_SIZE];
...@@ -1682,6 +1668,8 @@ row_ins_scan_sec_index_for_duplicate( ...@@ -1682,6 +1668,8 @@ row_ins_scan_sec_index_for_duplicate(
btr_pcur_open(index, entry, PAGE_CUR_GE, BTR_SEARCH_LEAF, &pcur, &mtr); btr_pcur_open(index, entry, PAGE_CUR_GE, BTR_SEARCH_LEAF, &pcur, &mtr);
allow_duplicates = thr_get_trx(thr)->duplicates & TRX_DUP_IGNORE;
/* Scan index records and check if there is a duplicate */ /* Scan index records and check if there is a duplicate */
for (;;) { for (;;) {
...@@ -1695,7 +1683,7 @@ row_ins_scan_sec_index_for_duplicate( ...@@ -1695,7 +1683,7 @@ row_ins_scan_sec_index_for_duplicate(
offsets = rec_get_offsets(rec, index, offsets, offsets = rec_get_offsets(rec, index, offsets,
ULINT_UNDEFINED, &heap); ULINT_UNDEFINED, &heap);
if (innobase_query_is_update()) { if (allow_duplicates) {
/* If the SQL-query will update or replace /* If the SQL-query will update or replace
duplicate key we will take X-lock for duplicate key we will take X-lock for
...@@ -1824,7 +1812,7 @@ row_ins_duplicate_error_in_clust( ...@@ -1824,7 +1812,7 @@ row_ins_duplicate_error_in_clust(
sure that in roll-forward we get the same duplicate sure that in roll-forward we get the same duplicate
errors as in original execution */ errors as in original execution */
if (innobase_query_is_update()) { if (trx->duplicates & TRX_DUP_IGNORE) {
/* If the SQL-query will update or replace /* If the SQL-query will update or replace
duplicate key we will take X-lock for duplicate key we will take X-lock for
...@@ -1862,7 +1850,7 @@ row_ins_duplicate_error_in_clust( ...@@ -1862,7 +1850,7 @@ row_ins_duplicate_error_in_clust(
offsets = rec_get_offsets(rec, cursor->index, offsets, offsets = rec_get_offsets(rec, cursor->index, offsets,
ULINT_UNDEFINED, &heap); ULINT_UNDEFINED, &heap);
if (innobase_query_is_update()) { if (trx->duplicates & TRX_DUP_IGNORE) {
/* If the SQL-query will update or replace /* If the SQL-query will update or replace
duplicate key we will take X-lock for duplicate key we will take X-lock for
......
# Copyright (C) 2001, 2003-2004 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public 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 ../include/Makefile.i
noinst_LIBRARIES = libsrv.a
libsrv_a_SOURCES = srv0srv.c srv0que.c srv0start.c
EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2001, 2003-2004 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public 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 ../include/Makefile.i
noinst_LIBRARIES = libsync.a
libsync_a_SOURCES = sync0arr.c sync0rw.c sync0sync.c
EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2001, 2003 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public 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 ../include/Makefile.i
noinst_LIBRARIES = libthr.a
libthr_a_SOURCES = thr0loc.c
EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2001, 2003 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public 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 ../include/Makefile.i
noinst_LIBRARIES = libtrx.a
libtrx_a_SOURCES = trx0purge.c trx0rec.c trx0roll.c trx0rseg.c\
trx0sys.c trx0trx.c trx0undo.c
EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
...@@ -130,6 +130,8 @@ trx_create( ...@@ -130,6 +130,8 @@ trx_create(
trx->mysql_thd = NULL; trx->mysql_thd = NULL;
trx->mysql_query_str = NULL; trx->mysql_query_str = NULL;
trx->active_trans = 0;
trx->duplicates = 0;
trx->n_mysql_tables_in_use = 0; trx->n_mysql_tables_in_use = 0;
trx->mysql_n_tables_locked = 0; trx->mysql_n_tables_locked = 0;
......
# Copyright (C) 2001, 2003 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public 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 ../include/Makefile.i
noinst_LIBRARIES = libusr.a
libusr_a_SOURCES = usr0sess.c
EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
# Copyright (C) 2001, 2003 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public 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 ../include/Makefile.i
noinst_LIBRARIES = libut.a
libut_a_SOURCES = ut0byte.c ut0dbg.c ut0mem.c ut0rnd.c ut0ut.c ut0vec.c ut0list.c ut0wqueue.c
EXTRA_PROGRAMS =
# Don't update the files from bitkeeper
%::SCCS/s.%
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment