diff --git a/libmysqld/Makefile.am b/libmysqld/Makefile.am
index e6d1c1acfcaa0014a00480bb2b7deaaeaf90f7ab..08a8d68b2e5e92c1ff032a37f2317df455ac6b58 100644
--- a/libmysqld/Makefile.am
+++ b/libmysqld/Makefile.am
@@ -44,7 +44,7 @@ libmysqlsources =	errmsg.c get_password.c libmysql.c client.c pack.c \
 noinst_HEADERS =	embedded_priv.h emb_qcache.h
 
 sqlsources = derror.cc field.cc field_conv.cc strfunc.cc filesort.cc \
-	ha_innodb.cc ha_ndbcluster.cc \
+	     ha_ndbcluster.cc \
 	ha_ndbcluster_binlog.cc ha_partition.cc \
 	handler.cc sql_handler.cc \
 	hostname.cc init.cc password.c \
diff --git a/sql/Makefile.am b/sql/Makefile.am
index dfb625d4747e594f91be0fbbe4ee2cc9f8b9cd81..d1ebea45d0ca79e3b1bf361a38e0d2e06b00a07b 100644
--- a/sql/Makefile.am
+++ b/sql/Makefile.am
@@ -50,7 +50,6 @@ noinst_HEADERS =	item.h item_func.h item_sum.h item_cmpfunc.h \
 			sql_map.h sql_string.h unireg.h \
 			sql_error.h field.h handler.h mysqld_suffix.h \
 			ha_partition.h \
-			ha_innodb.h  \
 			ha_ndbcluster.h ha_ndbcluster_binlog.h \
 			ha_ndbcluster_tables.h \
 			opt_range.h protocol.h rpl_tblmap.h \
@@ -87,7 +86,7 @@ mysqld_SOURCES =	sql_lex.cc sql_handler.cc sql_partition.cc \
 			unireg.cc des_key_file.cc \
 			discover.cc time.cc opt_range.cc opt_sum.cc \
 		   	records.cc filesort.cc handler.cc \
-			ha_partition.cc ha_innodb.cc \
+			ha_partition.cc \
                         ha_ndbcluster.cc ha_ndbcluster_binlog.cc \
 			sql_db.cc sql_table.cc sql_rename.cc sql_crypt.cc \
 			sql_load.cc mf_iocache.cc field_conv.cc sql_show.cc \
diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt
index 8b8c3af6582191492be093f09dffc169c4af57f1..8e456993413dfaae07728f2affb0847b78f7a25d 100644
--- a/storage/innobase/CMakeLists.txt
+++ b/storage/innobase/CMakeLists.txt
@@ -2,7 +2,7 @@
 #SET(CMAKE_C_FLAGS_DEBUG "-DSAFEMALLOC -DSAFE_MUTEX")
 ADD_DEFINITIONS(-DMYSQL_SERVER -D_WIN32 -DWIN32 -D_LIB)
 
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include include)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/handler include)
 ADD_LIBRARY(innobase btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c btr/btr0sea.c 
 					 buf/buf0buf.c buf/buf0flu.c buf/buf0lru.c buf/buf0rea.c 
 					 data/data0data.c data/data0type.c 
@@ -23,6 +23,7 @@ ADD_LIBRARY(innobase btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c btr/btr0sea.c
 					 os/os0file.c os/os0proc.c os/os0sync.c os/os0thread.c 
 					 page/page0cur.c page/page0page.c 
 					 que/que0que.c 
+					 handler/ha_innodb.cc
 					 read/read0read.c 
 					 rem/rem0cmp.c rem/rem0rec.c
 					 row/row0ins.c row/row0mysql.c row/row0purge.c row/row0row.c row/row0sel.c row/row0uins.c 
diff --git a/storage/innobase/Makefile.am b/storage/innobase/Makefile.am
index a68dbbcc2e6e8e632f376b6d00f9705aaf18be64..bdab35f1dc0faf50b143314795894e8195c5c23d 100644
--- a/storage/innobase/Makefile.am
+++ b/storage/innobase/Makefile.am
@@ -34,6 +34,7 @@ noinst_HEADERS =
 
 SUBDIRS =		os ut btr buf data dict dyn eval fil fsp fut \
 			ha ibuf lock log mach mem mtr page \
+			handler \
 			pars que read rem row srv sync thr trx usr
 
 EXTRA_DIST = 	include/btr0btr.h include/btr0btr.ic include/btr0cur.h include/btr0cur.ic \
@@ -86,6 +87,7 @@ EXTRA_DIST = 	include/btr0btr.h include/btr0btr.ic include/btr0cur.h include/btr
 		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 \
@@ -102,6 +104,7 @@ libinnobase_a_LIBADD =	usr/libusr.a srv/libsrv.a dict/libdict.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 =	
 
diff --git a/storage/innobase/handler/Makefile.am b/storage/innobase/handler/Makefile.am
new file mode 100644
index 0000000000000000000000000000000000000000..46909c8b7e1527bb242874450a8d680158d5ed61
--- /dev/null
+++ b/storage/innobase/handler/Makefile.am
@@ -0,0 +1,29 @@
+# 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; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public 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.%
diff --git a/sql/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
similarity index 99%
rename from sql/ha_innodb.cc
rename to storage/innobase/handler/ha_innodb.cc
index 1665c7c011afe72024b528c218e0421078ec3553..9bf347a1f298d269af95b2be2ce5762eebf781e8 100644
--- a/sql/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -31,8 +31,7 @@ have disables the InnoDB inlining in this file. */
 #pragma implementation				// gcc: Class implementation
 #endif
 
-#include "mysql_priv.h"
-#include "slave.h"
+#include <mysql_priv.h>
 
 #include <m_ctype.h>
 #include <hash.h>
@@ -1689,7 +1688,7 @@ innobase_commit_low(
 		return;
 	}
 
-#ifdef HAVE_REPLICATION
+#ifdef DISABLED_HAVE_REPLICATION
 	THD *thd=current_thd;
 
 	if (thd && thd->slave_thread) {
diff --git a/sql/ha_innodb.h b/storage/innobase/handler/ha_innodb.h
similarity index 100%
rename from sql/ha_innodb.h
rename to storage/innobase/handler/ha_innodb.h
diff --git a/storage/innobase/plug.in b/storage/innobase/plug.in
index fc1d758fd87edc41008102747603a84f0c41f583..028937882b2410e7adda742f2c1fd0b80ee0cacc 100644
--- a/storage/innobase/plug.in
+++ b/storage/innobase/plug.in
@@ -65,6 +65,7 @@ MYSQL_PLUGIN_ACTIONS(innobase,  [
       storage/innobase/sync/Makefile
       storage/innobase/thr/Makefile
       storage/innobase/trx/Makefile
+      storage/innobase/handler/Makefile
       storage/innobase/usr/Makefile)
   ])