List:Commits« Previous MessageNext Message »
From:kent Date:December 21 2006 11:54pm
Subject:bk commit into 5.1 tree (kent:1.2368)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of kent. When kent does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2006-12-21 23:54:37+01:00, kent@kent-amd64.(none) +85 -0
  Merge mysql.com:/home/kent/bk/mysql-5.0-build
  into  mysql.com:/home/kent/bk/mysql-5.1-build
  MERGE: 1.1810.2359.30

  BitKeeper/deleted/.del-Makefile.am~1f16f5bcb0850b40@stripped, 2006-12-21 22:30:43+01:00,
kent@kent-amd64.(none) +0 -4
    MERGE: 1.3.1.2

  BitKeeper/deleted/.del-Makefile.am~1f16f5bcb0850b40@stripped, 2006-12-21 22:25:50+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: ndb/src/kernel/blocks/qmgr/Makefile.am ->
BitKeeper/deleted/.del-Makefile.am~1f16f5bcb0850b40

  BitKeeper/deleted/.del-Makefile.am~2446a572de707944@stripped, 2006-12-21 22:31:31+01:00,
kent@kent-amd64.(none) +0 -4
    MERGE: 1.3.1.2

  BitKeeper/deleted/.del-Makefile.am~2446a572de707944@stripped, 2006-12-21 22:25:50+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: ndb/src/kernel/blocks/trix/Makefile.am ->
BitKeeper/deleted/.del-Makefile.am~2446a572de707944

  BitKeeper/deleted/.del-Makefile.am~51344ef8d0bbc561@stripped, 2006-12-21 22:31:51+01:00,
kent@kent-amd64.(none) +0 -4
    MERGE: 1.4.1.2

  BitKeeper/deleted/.del-Makefile.am~51344ef8d0bbc561@stripped, 2006-12-21 22:25:50+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: ndb/src/kernel/blocks/suma/Makefile.am ->
BitKeeper/deleted/.del-Makefile.am~51344ef8d0bbc561

  BitKeeper/deleted/.del-Makefile.am~661a7e944c6a2048@stripped, 2006-12-21 22:32:05+01:00,
kent@kent-amd64.(none) +0 -4
    MERGE: 1.5.1.2

  BitKeeper/deleted/.del-Makefile.am~661a7e944c6a2048@stripped, 2006-12-21 22:25:50+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: ndb/src/kernel/blocks/dbacc/Makefile.am ->
BitKeeper/deleted/.del-Makefile.am~661a7e944c6a2048

  BitKeeper/deleted/.del-Makefile.am~7062fe587bbd7db4@stripped, 2006-12-21 22:32:16+01:00,
kent@kent-amd64.(none) +0 -4
    MERGE: 1.3.1.2

  BitKeeper/deleted/.del-Makefile.am~7062fe587bbd7db4@stripped, 2006-12-21 22:25:50+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: ndb/src/kernel/blocks/cmvmi/Makefile.am ->
BitKeeper/deleted/.del-Makefile.am~7062fe587bbd7db4

  BitKeeper/deleted/.del-Makefile.am~b7531a4ddc688658@stripped, 2006-12-21 22:32:23+01:00,
kent@kent-amd64.(none) +0 -4
    MERGE: 1.5.1.2

  BitKeeper/deleted/.del-Makefile.am~b7531a4ddc688658@stripped, 2006-12-21 22:25:50+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: ndb/src/kernel/blocks/dbtux/Makefile.am ->
BitKeeper/deleted/.del-Makefile.am~b7531a4ddc688658

  BitKeeper/deleted/.del-Makefile.am~c65b52fdd2143330@stripped, 2006-12-21 22:32:32+01:00,
kent@kent-amd64.(none) +0 -4
    MERGE: 1.3.1.2

  BitKeeper/deleted/.del-Makefile.am~c65b52fdd2143330@stripped, 2006-12-21 22:25:50+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: ndb/src/kernel/blocks/ndbfs/Makefile.am ->
BitKeeper/deleted/.del-Makefile.am~c65b52fdd2143330

  BitKeeper/deleted/.del-Makefile.am~c9ae371812ceaf68@stripped, 2006-12-21 22:32:39+01:00,
kent@kent-amd64.(none) +0 -4
    MERGE: 1.3.1.2

  BitKeeper/deleted/.del-Makefile.am~c9ae371812ceaf68@stripped, 2006-12-21 22:25:50+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: ndb/src/kernel/blocks/dbutil/Makefile.am ->
BitKeeper/deleted/.del-Makefile.am~c9ae371812ceaf68

  BitKeeper/deleted/.del-Makefile.am~e06c16d4515a6ce6@stripped, 2006-12-21 22:32:49+01:00,
kent@kent-amd64.(none) +0 -4
    MERGE: 1.3.1.2

  BitKeeper/deleted/.del-Makefile.am~e06c16d4515a6ce6@stripped, 2006-12-21 22:25:50+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: ndb/src/kernel/blocks/dbtc/Makefile.am ->
BitKeeper/deleted/.del-Makefile.am~e06c16d4515a6ce6

  BitKeeper/deleted/.del-Makefile.am~e1b9fbc3d07a629d@stripped, 2006-12-21 22:32:56+01:00,
kent@kent-amd64.(none) +0 -4
    MERGE: 1.3.1.2

  BitKeeper/deleted/.del-Makefile.am~e1b9fbc3d07a629d@stripped, 2006-12-21 22:25:50+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: ndb/src/kernel/blocks/ndbcntr/Makefile.am ->
BitKeeper/deleted/.del-Makefile.am~e1b9fbc3d07a629d

  BitKeeper/deleted/.del-ha_innodb.m4~6f141fb5b80c1f39@stripped, 2006-12-21 22:35:20+01:00,
kent@kent-amd64.(none) +2 -2
    MERGE: 1.2.2.2

  BitKeeper/deleted/.del-ha_innodb.m4~6f141fb5b80c1f39@stripped, 2006-12-21 22:25:47+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: config/ac-macros/ha_innodb.m4 ->
BitKeeper/deleted/.del-ha_innodb.m4~6f141fb5b80c1f39

  client/Makefile.am@stripped, 2006-12-21 22:38:25+01:00, kent@kent-amd64.(none) +0 -1
    MERGE: 1.52.1.10

  config/ac-macros/ha_ndbcluster.m4@stripped, 2006-12-21 22:40:33+01:00,
kent@kent-amd64.(none) +1 -2
    MERGE: 1.5.1.4

  configure.in@stripped, 2006-12-21 22:27:09+01:00, kent@kent-amd64.(none) +0 -1
    MERGE: 1.245.1.170

  dbug/Makefile.am@stripped, 2006-12-21 22:25:51+01:00, kent@kent-amd64.(none) +0 -0
    Auto merged
    MERGE: 1.14.1.2

  extra/Makefile.am@stripped, 2006-12-21 22:25:51+01:00, kent@kent-amd64.(none) +0 -0
    Auto merged
    MERGE: 1.30.1.6

  libmysqld/Makefile.am@stripped, 2006-12-21 22:53:46+01:00, kent@kent-amd64.(none) +5 -3
    MERGE: 1.55.1.16

  libmysqld/examples/Makefile.am@stripped, 2006-12-21 22:54:27+01:00, kent@kent-amd64.(none)
+0 -1
    MERGE: 1.31.1.3

  mysys/Makefile.am@stripped, 2006-12-21 22:58:12+01:00, kent@kent-amd64.(none) +2 -4
    MERGE: 1.62.1.11

  netware/Makefile.am@stripped, 2006-12-21 22:25:51+01:00, kent@kent-amd64.(none) +0 -0
    Auto merged
    MERGE: 1.15.1.6

  regex/Makefile.am@stripped, 2006-12-21 22:25:51+01:00, kent@kent-amd64.(none) +0 -0
    Auto merged
    MERGE: 1.14.1.2

  server-tools/instance-manager/Makefile.am@stripped, 2006-12-21 22:25:51+01:00,
kent@kent-amd64.(none) +0 -0
    Auto merged
    MERGE: 1.29.1.5

  sql/Makefile.am@stripped, 2006-12-21 22:59:48+01:00, kent@kent-amd64.(none) +2 -8
    MERGE: 1.103.1.26

  storage/heap/Makefile.am@stripped, 2006-12-21 23:09:43+01:00, kent@kent-amd64.(none) +19 -12
    MERGE: 1.9.3.2

  storage/heap/Makefile.am@stripped, 2006-12-21 22:25:49+01:00, kent@kent-amd64.(none) +0
-0
    Merge rename: heap/Makefile.am -> storage/heap/Makefile.am

  storage/innobase/Makefile.am@stripped, 2006-12-21 23:15:31+01:00, kent@kent-amd64.(none) +36
-65
    MERGE: 1.6.2.2

  storage/innobase/Makefile.am@stripped, 2006-12-21 22:25:49+01:00, kent@kent-amd64.(none)
+0 -0
    Merge rename: innobase/Makefile.am -> storage/innobase/Makefile.am

  storage/innobase/btr/Makefile.am@stripped, 2006-12-21 22:25:51+01:00, kent@kent-amd64.(none)
+0 -0
    Auto merged
    MERGE: 1.3.1.2

  storage/innobase/btr/Makefile.am@stripped, 2006-12-21 22:25:49+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: innobase/btr/Makefile.am -> storage/innobase/btr/Makefile.am

  storage/innobase/buf/Makefile.am@stripped, 2006-12-21 22:25:51+01:00, kent@kent-amd64.(none)
+0 -0
    Auto merged
    MERGE: 1.2.1.2

  storage/innobase/buf/Makefile.am@stripped, 2006-12-21 22:25:50+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: innobase/buf/Makefile.am -> storage/innobase/buf/Makefile.am

  storage/innobase/buf/buf0buf.c@stripped, 2006-12-21 22:25:51+01:00, kent@kent-amd64.(none)
+0 -0
    Auto merged
    MERGE: 1.45.11.2

  storage/innobase/buf/buf0buf.c@stripped, 2006-12-21 22:25:50+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: innobase/buf/buf0buf.c -> storage/innobase/buf/buf0buf.c

  storage/innobase/data/Makefile.am@stripped, 2006-12-21 22:25:51+01:00, kent@kent-amd64.(none)
+0 -0
    Auto merged
    MERGE: 1.3.1.2

  storage/innobase/data/Makefile.am@stripped, 2006-12-21 22:25:50+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: innobase/data/Makefile.am -> storage/innobase/data/Makefile.am

  storage/innobase/dict/Makefile.am@stripped, 2006-12-21 22:25:51+01:00, kent@kent-amd64.(none)
+0 -0
    Auto merged
    MERGE: 1.2.1.2

  storage/innobase/dict/Makefile.am@stripped, 2006-12-21 22:25:50+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: innobase/dict/Makefile.am -> storage/innobase/dict/Makefile.am

  storage/innobase/dict/dict0dict.c@stripped, 2006-12-21 23:16:25+01:00,
kent@kent-amd64.(none) +2 -5
    MERGE: 1.65.17.2

  storage/innobase/dict/dict0dict.c@stripped, 2006-12-21 22:25:50+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: innobase/dict/dict0dict.c -> storage/innobase/dict/dict0dict.c

  storage/innobase/dyn/Makefile.am@stripped, 2006-12-21 22:25:51+01:00, kent@kent-amd64.(none)
+0 -0
    Auto merged
    MERGE: 1.2.1.2

  storage/innobase/dyn/Makefile.am@stripped, 2006-12-21 22:25:47+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: innobase/dyn/Makefile.am -> storage/innobase/dyn/Makefile.am

  storage/innobase/eval/Makefile.am@stripped, 2006-12-21 22:25:51+01:00, kent@kent-amd64.(none)
+0 -0
    Auto merged
    MERGE: 1.3.1.2

  storage/innobase/eval/Makefile.am@stripped, 2006-12-21 22:25:47+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: innobase/eval/Makefile.am -> storage/innobase/eval/Makefile.am

  storage/innobase/fil/Makefile.am@stripped, 2006-12-21 22:25:51+01:00, kent@kent-amd64.(none)
+0 -0
    Auto merged
    MERGE: 1.2.1.2

  storage/innobase/fil/Makefile.am@stripped, 2006-12-21 22:25:48+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: innobase/fil/Makefile.am -> storage/innobase/fil/Makefile.am

  storage/innobase/fil/fil0fil.c@stripped, 2006-12-21 22:25:51+01:00, kent@kent-amd64.(none)
+0 -0
    Auto merged
    MERGE: 1.54.16.2

  storage/innobase/fil/fil0fil.c@stripped, 2006-12-21 22:25:48+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: innobase/fil/fil0fil.c -> storage/innobase/fil/fil0fil.c

  storage/innobase/fsp/Makefile.am@stripped, 2006-12-21 22:25:51+01:00, kent@kent-amd64.(none)
+0 -0
    Auto merged
    MERGE: 1.2.1.2

  storage/innobase/fsp/Makefile.am@stripped, 2006-12-21 22:25:48+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: innobase/fsp/Makefile.am -> storage/innobase/fsp/Makefile.am

  storage/innobase/fut/Makefile.am@stripped, 2006-12-21 22:25:51+01:00, kent@kent-amd64.(none)
+0 -0
    Auto merged
    MERGE: 1.2.1.2

  storage/innobase/fut/Makefile.am@stripped, 2006-12-21 22:25:48+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: innobase/fut/Makefile.am -> storage/innobase/fut/Makefile.am

  storage/innobase/ha/Makefile.am@stripped, 2006-12-21 22:25:51+01:00, kent@kent-amd64.(none)
+0 -0
    Auto merged
    MERGE: 1.2.1.2

  storage/innobase/ha/Makefile.am@stripped, 2006-12-21 22:25:48+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: innobase/ha/Makefile.am -> storage/innobase/ha/Makefile.am

  storage/innobase/ha/ha0ha.c@stripped, 2006-12-21 22:25:51+01:00, kent@kent-amd64.(none) +0
-0
    Auto merged
    MERGE: 1.15.2.2

  storage/innobase/ha/ha0ha.c@stripped, 2006-12-21 22:25:48+01:00, kent@kent-amd64.(none)
+0 -0
    Merge rename: innobase/ha/ha0ha.c -> storage/innobase/ha/ha0ha.c

  storage/innobase/ha/hash0hash.c@stripped, 2006-12-21 22:25:51+01:00, kent@kent-amd64.(none)
+0 -0
    Auto merged
    MERGE: 1.4.1.2

  storage/innobase/ha/hash0hash.c@stripped, 2006-12-21 22:25:48+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: innobase/ha/hash0hash.c -> storage/innobase/ha/hash0hash.c

  storage/innobase/ibuf/Makefile.am@stripped, 2006-12-21 22:25:51+01:00, kent@kent-amd64.(none)
+0 -0
    Auto merged
    MERGE: 1.3.1.2

  storage/innobase/ibuf/Makefile.am@stripped, 2006-12-21 22:25:48+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: innobase/ibuf/Makefile.am -> storage/innobase/ibuf/Makefile.am

  storage/innobase/include/hash0hash.h@stripped, 2006-12-21 22:25:51+01:00,
kent@kent-amd64.(none) +0 -0
    Auto merged
    MERGE: 1.6.1.2

  storage/innobase/include/hash0hash.h@stripped, 2006-12-21 22:25:49+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: innobase/include/hash0hash.h -> storage/innobase/include/hash0hash.h

  storage/innobase/lock/Makefile.am@stripped, 2006-12-21 22:25:51+01:00, kent@kent-amd64.(none)
+0 -0
    Auto merged
    MERGE: 1.2.1.2

  storage/innobase/lock/Makefile.am@stripped, 2006-12-21 22:25:49+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: innobase/lock/Makefile.am -> storage/innobase/lock/Makefile.am

  storage/innobase/lock/lock0lock.c@stripped, 2006-12-21 22:25:51+01:00,
kent@kent-amd64.(none) +0 -0
    Auto merged
    MERGE: 1.55.8.2

  storage/innobase/lock/lock0lock.c@stripped, 2006-12-21 22:25:49+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: innobase/lock/lock0lock.c -> storage/innobase/lock/lock0lock.c

  storage/innobase/log/Makefile.am@stripped, 2006-12-21 22:25:51+01:00, kent@kent-amd64.(none)
+0 -0
    Auto merged
    MERGE: 1.2.1.2

  storage/innobase/log/Makefile.am@stripped, 2006-12-21 22:25:49+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: innobase/log/Makefile.am -> storage/innobase/log/Makefile.am

  storage/innobase/log/log0recv.c@stripped, 2006-12-21 22:25:52+01:00, kent@kent-amd64.(none)
+0 -0
    Auto merged
    MERGE: 1.46.11.2

  storage/innobase/log/log0recv.c@stripped, 2006-12-21 22:25:49+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: innobase/log/log0recv.c -> storage/innobase/log/log0recv.c

  storage/innobase/mach/Makefile.am@stripped, 2006-12-21 22:25:52+01:00, kent@kent-amd64.(none)
+0 -0
    Auto merged
    MERGE: 1.2.1.2

  storage/innobase/mach/Makefile.am@stripped, 2006-12-21 22:25:49+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: innobase/mach/Makefile.am -> storage/innobase/mach/Makefile.am

  storage/innobase/mem/Makefile.am@stripped, 2006-12-21 22:25:52+01:00, kent@kent-amd64.(none)
+0 -0
    Auto merged
    MERGE: 1.4.1.2

  storage/innobase/mem/Makefile.am@stripped, 2006-12-21 22:25:49+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: innobase/mem/Makefile.am -> storage/innobase/mem/Makefile.am

  storage/innobase/mtr/Makefile.am@stripped, 2006-12-21 22:25:52+01:00, kent@kent-amd64.(none)
+0 -0
    Auto merged
    MERGE: 1.2.1.2

  storage/innobase/mtr/Makefile.am@stripped, 2006-12-21 22:25:49+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: innobase/mtr/Makefile.am -> storage/innobase/mtr/Makefile.am

  storage/innobase/os/Makefile.am@stripped, 2006-12-21 22:25:52+01:00, kent@kent-amd64.(none)
+0 -0
    Auto merged
    MERGE: 1.4.1.2

  storage/innobase/os/Makefile.am@stripped, 2006-12-21 22:25:49+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: innobase/os/Makefile.am -> storage/innobase/os/Makefile.am

  storage/innobase/page/Makefile.am@stripped, 2006-12-21 22:25:52+01:00, kent@kent-amd64.(none)
+0 -0
    Auto merged
    MERGE: 1.2.1.2

  storage/innobase/page/Makefile.am@stripped, 2006-12-21 22:25:49+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: innobase/page/Makefile.am -> storage/innobase/page/Makefile.am

  storage/innobase/pars/Makefile.am@stripped, 2006-12-21 22:25:52+01:00, kent@kent-amd64.(none)
+0 -0
    Auto merged
    MERGE: 1.4.1.2

  storage/innobase/pars/Makefile.am@stripped, 2006-12-21 22:25:49+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: innobase/pars/Makefile.am -> storage/innobase/pars/Makefile.am

  storage/innobase/que/Makefile.am@stripped, 2006-12-21 22:25:52+01:00, kent@kent-amd64.(none)
+0 -0
    Auto merged
    MERGE: 1.2.1.2

  storage/innobase/que/Makefile.am@stripped, 2006-12-21 22:25:49+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: innobase/que/Makefile.am -> storage/innobase/que/Makefile.am

  storage/innobase/read/Makefile.am@stripped, 2006-12-21 22:25:52+01:00, kent@kent-amd64.(none)
+0 -0
    Auto merged
    MERGE: 1.2.1.2

  storage/innobase/read/Makefile.am@stripped, 2006-12-21 22:25:49+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: innobase/read/Makefile.am -> storage/innobase/read/Makefile.am

  storage/innobase/rem/Makefile.am@stripped, 2006-12-21 22:25:52+01:00, kent@kent-amd64.(none)
+0 -0
    Auto merged
    MERGE: 1.2.1.2

  storage/innobase/rem/Makefile.am@stripped, 2006-12-21 22:25:49+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: innobase/rem/Makefile.am -> storage/innobase/rem/Makefile.am

  storage/innobase/row/Makefile.am@stripped, 2006-12-21 22:25:52+01:00, kent@kent-amd64.(none)
+0 -0
    Auto merged
    MERGE: 1.2.1.2

  storage/innobase/row/Makefile.am@stripped, 2006-12-21 22:25:49+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: innobase/row/Makefile.am -> storage/innobase/row/Makefile.am

  storage/innobase/srv/Makefile.am@stripped, 2006-12-21 22:25:52+01:00, kent@kent-amd64.(none)
+0 -0
    Auto merged
    MERGE: 1.4.1.2

  storage/innobase/srv/Makefile.am@stripped, 2006-12-21 22:25:49+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: innobase/srv/Makefile.am -> storage/innobase/srv/Makefile.am

  storage/innobase/sync/Makefile.am@stripped, 2006-12-21 22:25:52+01:00, kent@kent-amd64.(none)
+0 -0
    Auto merged
    MERGE: 1.3.1.2

  storage/innobase/sync/Makefile.am@stripped, 2006-12-21 22:25:49+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: innobase/sync/Makefile.am -> storage/innobase/sync/Makefile.am

  storage/innobase/thr/Makefile.am@stripped, 2006-12-21 22:25:52+01:00, kent@kent-amd64.(none)
+0 -0
    Auto merged
    MERGE: 1.2.1.2

  storage/innobase/thr/Makefile.am@stripped, 2006-12-21 22:25:49+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: innobase/thr/Makefile.am -> storage/innobase/thr/Makefile.am

  storage/innobase/thr/thr0loc.c@stripped, 2006-12-21 22:25:52+01:00, kent@kent-amd64.(none)
+0 -0
    Auto merged
    MERGE: 1.7.1.2

  storage/innobase/thr/thr0loc.c@stripped, 2006-12-21 22:25:49+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: innobase/thr/thr0loc.c -> storage/innobase/thr/thr0loc.c

  storage/innobase/trx/Makefile.am@stripped, 2006-12-21 22:25:52+01:00, kent@kent-amd64.(none)
+0 -0
    Auto merged
    MERGE: 1.2.1.2

  storage/innobase/trx/Makefile.am@stripped, 2006-12-21 22:25:49+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: innobase/trx/Makefile.am -> storage/innobase/trx/Makefile.am

  storage/innobase/usr/Makefile.am@stripped, 2006-12-21 22:25:52+01:00, kent@kent-amd64.(none)
+0 -0
    Auto merged
    MERGE: 1.2.1.2

  storage/innobase/usr/Makefile.am@stripped, 2006-12-21 22:25:49+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: innobase/usr/Makefile.am -> storage/innobase/usr/Makefile.am

  storage/innobase/ut/Makefile.am@stripped, 2006-12-21 23:16:59+01:00, kent@kent-amd64.(none)
+1 -2
    MERGE: 1.2.1.2

  storage/innobase/ut/Makefile.am@stripped, 2006-12-21 22:25:49+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: innobase/ut/Makefile.am -> storage/innobase/ut/Makefile.am

  storage/myisam/Makefile.am@stripped, 2006-12-21 23:25:56+01:00, kent@kent-amd64.(none) +5
-10
    MERGE: 1.29.4.2

  storage/myisam/Makefile.am@stripped, 2006-12-21 22:25:49+01:00, kent@kent-amd64.(none)
+0 -0
    Merge rename: myisam/Makefile.am -> storage/myisam/Makefile.am

  storage/myisammrg/Makefile.am@stripped, 2006-12-21 23:26:51+01:00, kent@kent-amd64.(none) +0
-0
    SCCS merged
    MERGE: 1.13.3.2

  storage/myisammrg/Makefile.am@stripped, 2006-12-21 22:25:49+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: myisammrg/Makefile.am -> storage/myisammrg/Makefile.am

  storage/ndb/config/type_ndbapitest.mk.am@stripped, 2006-12-21 23:27:39+01:00,
kent@kent-amd64.(none) +1 -2
    MERGE: 1.10.2.2

  storage/ndb/config/type_ndbapitest.mk.am@stripped, 2006-12-21 22:25:49+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: ndb/config/type_ndbapitest.mk.am ->
storage/ndb/config/type_ndbapitest.mk.am

  storage/ndb/config/type_ndbapitools.mk.am@stripped, 2006-12-21 23:28:02+01:00,
kent@kent-amd64.(none) +1 -2
    MERGE: 1.8.4.2

  storage/ndb/config/type_ndbapitools.mk.am@stripped, 2006-12-21 22:25:49+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: ndb/config/type_ndbapitools.mk.am ->
storage/ndb/config/type_ndbapitools.mk.am

  storage/ndb/src/common/util/Makefile.am@stripped, 2006-12-21 22:25:52+01:00,
kent@kent-amd64.(none) +0 -0
    Auto merged
    MERGE: 1.10.2.2

  storage/ndb/src/common/util/Makefile.am@stripped, 2006-12-21 22:25:50+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: ndb/src/common/util/Makefile.am ->
storage/ndb/src/common/util/Makefile.am

  storage/ndb/src/cw/cpcd/Makefile.am@stripped, 2006-12-21 22:25:52+01:00,
kent@kent-amd64.(none) +0 -0
    Auto merged
    MERGE: 1.12.1.2

  storage/ndb/src/cw/cpcd/Makefile.am@stripped, 2006-12-21 22:25:50+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: ndb/src/cw/cpcd/Makefile.am -> storage/ndb/src/cw/cpcd/Makefile.am

  storage/ndb/src/kernel/Makefile.am@stripped, 2006-12-21 23:29:18+01:00,
kent@kent-amd64.(none) +1 -15
    MERGE: 1.10.6.2

  storage/ndb/src/kernel/Makefile.am@stripped, 2006-12-21 22:25:50+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: ndb/src/kernel/Makefile.am -> storage/ndb/src/kernel/Makefile.am

  storage/ndb/src/kernel/blocks/backup/Makefile.am@stripped, 2006-12-21 23:32:11+01:00,
kent@kent-amd64.(none) +6 -9
    MERGE: 1.4.1.2

  storage/ndb/src/kernel/blocks/backup/Makefile.am@stripped, 2006-12-21 22:25:50+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: ndb/src/kernel/blocks/backup/Makefile.am ->
storage/ndb/src/kernel/blocks/backup/Makefile.am

  storage/ndb/src/kernel/blocks/dbdict/Makefile.am@stripped, 2006-12-21 23:40:22+01:00,
kent@kent-amd64.(none) +8 -15
    MERGE: 1.3.2.2

  storage/ndb/src/kernel/blocks/dbdict/Makefile.am@stripped, 2006-12-21 22:25:50+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: ndb/src/kernel/blocks/dbdict/Makefile.am ->
storage/ndb/src/kernel/blocks/dbdict/Makefile.am

  storage/ndb/src/kernel/blocks/dbdih/Makefile.am@stripped, 2006-12-21 23:41:55+01:00,
kent@kent-amd64.(none) +7 -10
    MERGE: 1.3.2.2

  storage/ndb/src/kernel/blocks/dbdih/Makefile.am@stripped, 2006-12-21 22:25:50+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: ndb/src/kernel/blocks/dbdih/Makefile.am ->
storage/ndb/src/kernel/blocks/dbdih/Makefile.am

  storage/ndb/src/kernel/blocks/dblqh/Makefile.am@stripped, 2006-12-21 23:43:50+01:00,
kent@kent-amd64.(none) +7 -9
    MERGE: 1.3.2.2

  storage/ndb/src/kernel/blocks/dblqh/Makefile.am@stripped, 2006-12-21 22:25:50+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: ndb/src/kernel/blocks/dblqh/Makefile.am ->
storage/ndb/src/kernel/blocks/dblqh/Makefile.am

  storage/ndb/src/kernel/blocks/dbtup/Makefile.am@stripped, 2006-12-21 23:45:33+01:00,
kent@kent-amd64.(none) +9 -12
    MERGE: 1.4.1.2

  storage/ndb/src/kernel/blocks/dbtup/Makefile.am@stripped, 2006-12-21 22:25:50+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: ndb/src/kernel/blocks/dbtup/Makefile.am ->
storage/ndb/src/kernel/blocks/dbtup/Makefile.am

  storage/ndb/src/kernel/error/Makefile.am@stripped, 2006-12-21 23:47:05+01:00,
kent@kent-amd64.(none) +5 -7
    MERGE: 1.4.2.2

  storage/ndb/src/kernel/error/Makefile.am@stripped, 2006-12-21 22:25:50+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: ndb/src/kernel/error/Makefile.am ->
storage/ndb/src/kernel/error/Makefile.am

  storage/ndb/src/kernel/vm/Makefile.am@stripped, 2006-12-21 23:50:58+01:00,
kent@kent-amd64.(none) +15 -24
    MERGE: 1.6.3.2

  storage/ndb/src/kernel/vm/Makefile.am@stripped, 2006-12-21 22:25:50+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: ndb/src/kernel/vm/Makefile.am ->
storage/ndb/src/kernel/vm/Makefile.am

  storage/ndb/src/mgmclient/Makefile.am@stripped, 2006-12-21 22:25:52+01:00,
kent@kent-amd64.(none) +0 -0
    Auto merged
    MERGE: 1.17.1.2

  storage/ndb/src/mgmclient/Makefile.am@stripped, 2006-12-21 22:25:50+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: ndb/src/mgmclient/Makefile.am ->
storage/ndb/src/mgmclient/Makefile.am

  storage/ndb/src/mgmsrv/Makefile.am@stripped, 2006-12-21 22:25:53+01:00,
kent@kent-amd64.(none) +0 -0
    Auto merged
    MERGE: 1.22.2.2

  storage/ndb/src/mgmsrv/Makefile.am@stripped, 2006-12-21 22:25:50+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: ndb/src/mgmsrv/Makefile.am -> storage/ndb/src/mgmsrv/Makefile.am

  storage/ndb/test/ndbapi/Makefile.am@stripped, 2006-12-21 22:25:53+01:00,
kent@kent-amd64.(none) +0 -0
    Auto merged
    MERGE: 1.19.11.2

  storage/ndb/test/ndbapi/Makefile.am@stripped, 2006-12-21 22:25:50+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: ndb/test/ndbapi/Makefile.am -> storage/ndb/test/ndbapi/Makefile.am

  storage/ndb/test/ndbapi/bank/Makefile.am@stripped, 2006-12-21 22:25:53+01:00,
kent@kent-amd64.(none) +0 -0
    Auto merged
    MERGE: 1.5.1.2

  storage/ndb/test/ndbapi/bank/Makefile.am@stripped, 2006-12-21 22:25:50+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: ndb/test/ndbapi/bank/Makefile.am ->
storage/ndb/test/ndbapi/bank/Makefile.am

  storage/ndb/test/run-test/Makefile.am@stripped, 2006-12-21 23:51:42+01:00,
kent@kent-amd64.(none) +1 -2
    MERGE: 1.19.4.2

  storage/ndb/test/run-test/Makefile.am@stripped, 2006-12-21 22:25:50+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: ndb/test/run-test/Makefile.am ->
storage/ndb/test/run-test/Makefile.am

  storage/ndb/test/src/Makefile.am@stripped, 2006-12-21 23:52:13+01:00, kent@kent-amd64.(none)
+2 -4
    MERGE: 1.8.1.2

  storage/ndb/test/src/Makefile.am@stripped, 2006-12-21 22:25:50+01:00,
kent@kent-amd64.(none) +0 -0
    Merge rename: ndb/test/src/Makefile.am -> storage/ndb/test/src/Makefile.am

  strings/Makefile.am@stripped, 2006-12-21 23:54:32+01:00, kent@kent-amd64.(none) +1 -1
    MERGE: 1.49.1.3

  vio/Makefile.am@stripped, 2006-12-21 22:25:53+01:00, kent@kent-amd64.(none) +0 -0
    Auto merged
    MERGE: 1.17.1.4

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	kent
# Host:	kent-amd64.(none)
# Root:	/home/kent/bk/mysql-5.1-build/RESYNC

--- 1.405/configure.in	2006-12-21 23:54:44 +01:00
+++ 1.406/configure.in	2006-12-21 23:54:44 +01:00
@@ -805,7 +805,7 @@
     if test x"$have_libiberty" = xyes -a x"$have_libbfd" = xyes
     then
       pstack_dirs='$(top_srcdir)'/pstack
-      pstack_libs="../pstack/libpstack.a -lbfd -liberty"
+      pstack_libs="../pstack/libpstack.la -lbfd -liberty"
       # We must link staticly when using pstack
       with_mysqld_ldflags="-all-static"
       AC_SUBST([pstack_dirs])
@@ -2352,7 +2352,7 @@
     readline_topdir="cmd-line-utils"
     readline_basedir="libedit"
     readline_dir="$readline_topdir/$readline_basedir"
-    readline_link="\$(top_builddir)/cmd-line-utils/libedit/libedit.a"
+    readline_link="\$(top_builddir)/cmd-line-utils/libedit/libedit.la"
     readline_h_ln_cmd="\$(LN) -s \$(top_srcdir)/cmd-line-utils/libedit/readline readline"
     compile_libedit=yes
     AC_DEFINE_UNQUOTED(HAVE_HIST_ENTRY, 1)
@@ -2362,7 +2362,7 @@
     readline_topdir="cmd-line-utils"
     readline_basedir="readline"
     readline_dir="$readline_topdir/$readline_basedir"
-    readline_link="\$(top_builddir)/cmd-line-utils/readline/libreadline.a"
+    readline_link="\$(top_builddir)/cmd-line-utils/readline/libreadline.la"
     readline_h_ln_cmd="\$(LN) -s \$(top_srcdir)/cmd-line-utils/readline readline"
     compile_readline=yes
     AC_DEFINE_UNQUOTED(USE_NEW_READLINE_INTERFACE, 1)
@@ -2453,14 +2453,13 @@
 then
   AC_DEFINE([THREAD], [1],
             [Define if you want to have threaded code. This may be undef on client code])
-  # Avoid _PROGRAMS names
-  THREAD_LOBJECTS="thr_alarm.o thr_lock.o thr_mutex.o thr_rwlock.o my_pthread.o
my_thr_init.o mf_keycache.o"
-  AC_SUBST(THREAD_LOBJECTS)
   server_scripts="mysqld_safe mysql_install_db"
   sql_server_dirs="strings mysys dbug extra regex"
 
   sql_server="$sql_server vio sql"
 fi
+
+AM_CONDITIONAL(HAVE_THREAD_SAFE_CLIENT, test "$with_server" = "yes" -o
"$THREAD_SAFE_CLIENT" != "no")
 
 # IMPORTANT - do not modify LIBS past this line - this hack is the only way
 # I know to add the static NSS magic if we have static NSS libraries with

--- 1.18/dbug/Makefile.am	2006-12-21 23:54:44 +01:00
+++ 1.19/dbug/Makefile.am	2006-12-21 23:54:44 +01:00
@@ -16,10 +16,11 @@
 # MA 02111-1307, USA
 
 INCLUDES =              -I$(top_builddir)/include -I$(top_srcdir)/include
-LDADD =                 libdbug.a ../mysys/libmysys.a ../strings/libmystrings.a
-pkglib_LIBRARIES =      libdbug.a
+LDADD =                 libdbug.la ../mysys/libmysys.la ../strings/libmystrings.la
+pkglib_LTLIBRARIES =    libdbug.la
 noinst_HEADERS =        dbug_long.h
-libdbug_a_SOURCES =     dbug.c sanity.c
+libdbug_la_SOURCES =    dbug.c sanity.c
+libdbug_la_LDFLAGS =	-static
 EXTRA_DIST =            CMakeLists.txt example1.c example2.c example3.c \
                         user.r monty.doc dbug_add_tags.pl \
                         my_main.c main.c factorial.c dbug_analyze.c \

--- 1.42/extra/Makefile.am	2006-12-21 23:54:44 +01:00
+++ 1.43/extra/Makefile.am	2006-12-21 23:54:44 +01:00
@@ -16,8 +16,8 @@
 
 INCLUDES =		-I$(top_builddir)/include -I$(top_srcdir)/include \
 			-I$(top_srcdir)/sql
-LDADD =			@CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.a \
-			../dbug/libdbug.a ../strings/libmystrings.a
+LDADD =			@CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.la \
+			../dbug/libdbug.la ../strings/libmystrings.la
 BUILT_SOURCES=		$(top_builddir)/include/mysqld_error.h \
                         $(top_builddir)/include/sql_state.h \
                         $(top_builddir)/include/mysqld_ername.h

--- 1.9.3.1/heap/Makefile.am	2006-12-21 23:54:44 +01:00
+++ 1.20/storage/heap/Makefile.am	2006-12-21 23:54:44 +01:00
@@ -14,21 +14,40 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-INCLUDES =		-I$(top_builddir)/include -I$(top_srcdir)/include 
-LDADD =			libheap.la ../mysys/libmysys.la ../dbug/libdbug.la \
-			../strings/libmystrings.la
+MYSQLDATAdir =          $(localstatedir)
+MYSQLSHAREdir =         $(pkgdatadir)
+MYSQLBASEdir=           $(prefix)
+MYSQLLIBdir=            $(pkglibdir)
+INCLUDES =              -I$(top_builddir)/include -I$(top_srcdir)/include \
+			-I$(top_srcdir)/regex \
+			-I$(top_srcdir)/sql \
+                        -I$(srcdir)
+WRAPLIBS=
+
+LDADD =			libheap.la \
+			$(top_builddir)/mysys/libmysys.la \
+			$(top_builddir)/dbug/libdbug.la \
+			$(top_builddir)/strings/libmystrings.la
+
+DEFS =                  @DEFS@
 pkglib_LTLIBRARIES =	libheap.la
 noinst_PROGRAMS	=	hp_test1 hp_test2
+libheap_la_LDFLAGS =	-static
 hp_test1_LDFLAGS = @NOINST_LDFLAGS@
+hp_test1_LDADD =	$(LDADD)
 hp_test2_LDFLAGS = @NOINST_LDFLAGS@
-noinst_HEADERS =	heapdef.h
+hp_test2_LDADD =	$(LDADD)
+noinst_HEADERS =	heapdef.h ha_heap.h
 libheap_la_SOURCES =	hp_open.c hp_extra.c hp_close.c hp_panic.c hp_info.c \
 			hp_rrnd.c hp_scan.c hp_update.c hp_write.c hp_delete.c \
 			hp_rsame.c hp_create.c hp_rename.c hp_rfirst.c \
 			hp_rnext.c hp_rlast.c hp_rprev.c hp_clear.c \
 			hp_rkey.c hp_block.c \
+			ha_heap.cc \
 			hp_hash.c _check.c _rectest.c hp_static.c
-libheap_la_LDFLAGS =	-static
-EXTRA_DIST =	CMakeLists.txt
+
+
+EXTRA_DIST =		CMakeLists.txt plug.in
+
 # Don't update the files from bitkeeper
 %::SCCS/s.%

--- 1.29.4.1/myisam/Makefile.am	2006-12-21 23:54:44 +01:00
+++ 1.39/storage/myisam/Makefile.am	2006-12-21 23:54:44 +01:00
@@ -14,27 +14,41 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-EXTRA_DIST =		mi_test_all.sh mi_test_all.res ft_stem.c CMakeLists.txt
-pkgdata_DATA =		mi_test_all mi_test_all.res
+MYSQLDATAdir =          $(localstatedir)
+MYSQLSHAREdir =         $(pkgdatadir)
+MYSQLBASEdir=           $(prefix)
+MYSQLLIBdir=            $(pkglibdir)
+INCLUDES =              -I$(top_srcdir)/include -I$(top_builddir)/include \
+			-I$(top_srcdir)/regex \
+			-I$(top_srcdir)/sql \
+                        -I$(srcdir)
+WRAPLIBS=
 
-INCLUDES =		-I$(top_builddir)/include -I$(top_srcdir)/include
 LDADD =			@CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
 			$(top_builddir)/mysys/libmysys.la \
 			$(top_builddir)/dbug/libdbug.la \
 			$(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
+
+DEFS =                  @DEFS@
+
+EXTRA_DIST =		mi_test_all.sh mi_test_all.res ft_stem.c CMakeLists.txt plug.in
+pkgdata_DATA =		mi_test_all mi_test_all.res
+
 pkglib_LTLIBRARIES =	libmyisam.la
 bin_PROGRAMS =		myisamchk myisamlog myisampack myisam_ftdump
 myisamchk_DEPENDENCIES=	$(LTLIBRARIES)
 myisamlog_DEPENDENCIES=	$(LTLIBRARIES)
 myisampack_DEPENDENCIES=$(LTLIBRARIES)
 noinst_PROGRAMS =	mi_test1 mi_test2 mi_test3 rt_test sp_test #ft_test1 ft_eval
-noinst_HEADERS =	myisamdef.h rt_index.h rt_key.h rt_mbr.h sp_defs.h fulltext.h ftdefs.h
ft_test1.h ft_eval.h
+noinst_HEADERS =	myisamdef.h rt_index.h rt_key.h rt_mbr.h sp_defs.h \
+			fulltext.h ftdefs.h ft_test1.h ft_eval.h \
+			ha_myisam.h
 mi_test1_DEPENDENCIES=	$(LTLIBRARIES)
 mi_test2_DEPENDENCIES=	$(LTLIBRARIES)
 mi_test3_DEPENDENCIES=	$(LTLIBRARIES)
 #ft_test1_DEPENDENCIES=	$(LTLIBRARIES)
 #ft_eval_DEPENDENCIES=	$(LTLIBRARIES)
-myisam_ftdump_DEPENDENCIES=	$(LTLIBRARIES)
+myisam_ftdump_DEPENDENCIES=$(LTLIBRARIES)
 rt_test_DEPENDENCIES=	$(LTLIBRARIES)
 sp_test_DEPENDENCIES=	$(LTLIBRARIES)
 libmyisam_la_SOURCES =	mi_open.c mi_extra.c mi_info.c mi_rkey.c \
@@ -52,10 +66,10 @@
 			mi_keycache.c mi_preload.c \
 			ft_parser.c ft_stopwords.c ft_static.c \
 			ft_update.c ft_boolean_search.c ft_nlq_search.c sort.c \
+			ha_myisam.cc \
 			rt_index.c rt_key.c rt_mbr.c rt_split.c sp_key.c
 libmyisam_la_LDFLAGS =	-static
 CLEANFILES =		test?.MY? FT?.MY? isam.log mi_test_all rt_test.MY? sp_test.MY?
-DEFS =			-DMAP_TO_USE_RAID
 
 # Move to automake rules ?
 prolint:;	plparse -b -u -hF1 "-width(0,0)" "-format=%f:%l:\s%t:%n\s%m" \

--- 1.13.3.1/myisammrg/Makefile.am	2006-12-21 23:54:44 +01:00
+++ 1.21/storage/myisammrg/Makefile.am	2006-12-21 23:54:44 +01:00
@@ -14,16 +14,33 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-INCLUDES =		-I$(top_builddir)/include -I$(top_srcdir)/include
+MYSQLDATAdir =          $(localstatedir)
+MYSQLSHAREdir =         $(pkgdatadir)
+MYSQLBASEdir=           $(prefix)
+MYSQLLIBdir=            $(pkglibdir)
+INCLUDES =              -I$(top_srcdir)/include -I$(top_builddir)/include \
+			-I$(top_srcdir)/regex \
+			-I$(top_srcdir)/sql \
+                        -I$(srcdir)
+WRAPLIBS=
+
+LDADD =
+
+DEFS =                  @DEFS@
 pkglib_LTLIBRARIES =	libmyisammrg.la
-noinst_HEADERS =	myrg_def.h
+noinst_HEADERS =	myrg_def.h ha_myisammrg.h
+noinst_LIBRARIES =	libmyisammrg.a
 libmyisammrg_la_SOURCES = myrg_open.c myrg_extra.c myrg_info.c myrg_locking.c \
 			myrg_rrnd.c myrg_update.c myrg_delete.c myrg_rsame.c \
 			myrg_panic.c myrg_close.c myrg_create.c myrg_static.c \
 			myrg_rkey.c myrg_rfirst.c myrg_rlast.c myrg_rnext.c \
 			myrg_rprev.c myrg_queue.c myrg_write.c myrg_range.c \
+			ha_myisammrg.cc \
 			myrg_rnext_same.c
 libmyisammrg_la_LDFLAGS = -static
-EXTRA_DIST = 	CMakeLists.txt
+
+
+EXTRA_DIST =		CMakeLists.txt plug.in
+
 # Don't update the files from bitkeeper
 %::SCCS/s.%

--- 1.86/mysys/Makefile.am	2006-12-21 23:54:44 +01:00
+++ 1.87/mysys/Makefile.am	2006-12-21 23:54:44 +01:00
@@ -19,10 +19,10 @@
 MYSQLBASEdir=		$(prefix)
 INCLUDES =		@ZLIB_INCLUDES@ -I$(top_builddir)/include \
 			-I$(top_srcdir)/include -I$(srcdir)
-pkglib_LIBRARIES =	libmysys.a
-LDADD =			libmysys.a $(top_builddir)/strings/libmystrings.a
$(top_builddir)/dbug/libdbug.a
+pkglib_LTLIBRARIES =	libmysys.la
+LDADD =			libmysys.la $(top_builddir)/strings/libmystrings.la
$(top_builddir)/dbug/libdbug.la
 noinst_HEADERS =	mysys_priv.h my_static.h
-libmysys_a_SOURCES =    my_init.c my_getwd.c mf_getdate.c my_mmap.c \
+libmysys_la_SOURCES =	my_init.c my_getwd.c mf_getdate.c my_mmap.c \
 			mf_path.c mf_loadpath.c my_file.c \
 			my_open.c my_create.c my_dup.c my_seek.c my_read.c \
 			my_pread.c my_write.c my_getpagesize.c \
@@ -53,12 +53,20 @@
 			my_gethostbyname.c rijndael.c my_aes.c sha1.c \
 			my_handler.c my_netware.c my_largepage.c \
 			my_memmem.c \
-			my_windac.c my_access.c base64.c my_libwrap.c
+			my_windac.c my_access.c base64.c my_libwrap.c $(THREAD_SRC)
+libmysys_la_LDFLAGS =	-static
+libmysys_la_LIBADD =	$(top_builddir)/strings/libmystrings.la
+if HAVE_THREAD_SAFE_CLIENT
+THREAD_SRC =		thr_alarm.c thr_lock.c thr_mutex.c thr_rwlock.c \
+			my_pthread.c my_thr_init.c
+else
+THREAD_SRC =
+endif
+# Duplicate some in THREAD_SRC, just to ensure always in dist
 EXTRA_DIST =		thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \
 			thr_mutex.c thr_rwlock.c \
 			CMakeLists.txt mf_soundex.c \
 			my_conio.c my_wincond.c my_winsem.c my_winthread.c
-libmysys_a_LIBADD =	@THREAD_LOBJECTS@
 # test_dir_DEPENDENCIES=	$(LIBRARIES)
 # testhash_DEPENDENCIES=	$(LIBRARIES)
 # test_charset_DEPENDENCIES=	$(LIBRARIES)
@@ -71,8 +79,6 @@
 			-DDEFAULT_GROUP_SUFFIX_ENV=MYSQL_GROUP_SUFFIX \
 			-DDEFAULT_SYSCONFDIR="\"$(sysconfdir)\"" \
                         @DEFS@
-
-libmysys_a_DEPENDENCIES= @THREAD_LOBJECTS@
 
 # I hope this always does the right thing. Otherwise this is only test programs
 FLAGS=$(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) @NOINST_LDFLAGS@

--- 1.17/regex/Makefile.am	2006-12-21 23:54:44 +01:00
+++ 1.18/regex/Makefile.am	2006-12-21 23:54:44 +01:00
@@ -16,10 +16,10 @@
 # MA 02111-1307, USA
 
 INCLUDES =		-I$(top_builddir)/include -I$(top_srcdir)/include
-noinst_LIBRARIES =	libregex.a
-LDADD=			libregex.a $(top_builddir)/strings/libmystrings.a
+noinst_LTLIBRARIES =	libregex.la
+LDADD=			libregex.la $(top_builddir)/strings/libmystrings.la
 noinst_HEADERS =	cclass.h cname.h regex2.h utils.h engine.c my_regex.h
-libregex_a_SOURCES =	regerror.c regcomp.c regexec.c regfree.c reginit.c
+libregex_la_SOURCES =	regerror.c regcomp.c regexec.c regfree.c reginit.c
 noinst_PROGRAMS =	re
 re_SOURCES =		split.c debug.c main.c
 re_LDFLAGS= @NOINST_LDFLAGS@

--- 1.167/sql/Makefile.am	2006-12-21 23:54:44 +01:00
+++ 1.168/sql/Makefile.am	2006-12-21 23:54:44 +01:00
@@ -30,18 +30,18 @@
 noinst_PROGRAMS =	gen_lex_hash
 bin_PROGRAMS =		mysql_tzinfo_to_sql
 gen_lex_hash_LDFLAGS =  @NOINST_LDFLAGS@
-SUPPORTING_LIBS =			$(top_builddir)/vio/libvio.a \
-			$(top_builddir)/mysys/libmysys.a \
-			$(top_builddir)/dbug/libdbug.a \
-			$(top_builddir)/regex/libregex.a \
-			$(top_builddir)/strings/libmystrings.a
+SUPPORTING_LIBS =	$(top_builddir)/vio/libvio.la \
+			$(top_builddir)/mysys/libmysys.la \
+			$(top_builddir)/dbug/libdbug.la \
+			$(top_builddir)/regex/libregex.la \
+			$(top_builddir)/strings/libmystrings.la
 mysqld_DEPENDENCIES=	@mysql_plugin_libs@ $(SUPPORTING_LIBS)
 LDADD = $(SUPPORTING_LIBS) @ZLIB_LIBS@
 mysqld_LDADD =		@MYSQLD_EXTRA_LDFLAGS@ \
 			@pstack_libs@ \
 			@mysql_plugin_libs@ \
 			$(LDADD)  $(CXXLDFLAGS) $(WRAPLIBS) @LIBDL@ \
-                        @yassl_libs@ @openssl_libs@
+			@yassl_libs@ @openssl_libs@
 noinst_HEADERS =	item.h item_func.h item_sum.h item_cmpfunc.h \
 			item_strfunc.h item_timefunc.h item_uniq.h \
 			item_xmlfunc.h \

--- 1.55/strings/Makefile.am	2006-12-21 23:54:44 +01:00
+++ 1.56/strings/Makefile.am	2006-12-21 23:54:44 +01:00
@@ -17,7 +17,7 @@
 # This file is public domain and comes with NO WARRANTY of any kind
 
 INCLUDES =		-I$(top_builddir)/include -I$(top_srcdir)/include
-pkglib_LIBRARIES =	libmystrings.a
+pkglib_LTLIBRARIES =	libmystrings.la
 
 # Exact one of ASSEMBLER_X
 if ASSEMBLER_x86
@@ -38,7 +38,7 @@
 endif
 endif
 
-libmystrings_a_SOURCES = $(ASRCS) $(CSRCS)
+libmystrings_la_SOURCES = $(ASRCS) $(CSRCS)
 noinst_PROGRAMS = conf_to_src
 CLEANFILES = str_test uctypedump test_decimal
 # Default charset definitions
@@ -55,10 +55,11 @@
 			strinstr-sparc.s strmake-sparc.s strmov-sparc.s \
 			strnmov-sparc.s strstr-sparc.s strxmov-sparc.s \
 			t_ctype.h my_strchr.c CMakeLists.txt
+libmystrings_la_LDFLAGS = -static
+libmystrings_la_LIBADD=
 
-libmystrings_a_LIBADD=
-conf_to_src_SOURCES = conf_to_src.c xml.c ctype.c bcmp.c
-conf_to_src_LDADD=
+conf_to_src_SOURCES = conf_to_src.c
+conf_to_src_LDADD= libmystrings.la
 #force static linking of conf_to_src - essential when linking against
 #custom installation of libc
 conf_to_src_LDFLAGS= @NOINST_LDFLAGS@
@@ -69,15 +70,15 @@
 
 FLAGS=$(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) @NOINST_LDFLAGS@
 
-str_test: str_test.c $(pkglib_LIBRARIES)
-	$(LINK) $(FLAGS) -DMAIN $(INCLUDES) $(srcdir)/str_test.c $(LDADD) $(pkglib_LIBRARIES)
+str_test: str_test.c $(pkglib_LTLIBRARIES)
+	$(LINK) $(FLAGS) -DMAIN $(INCLUDES) $(srcdir)/str_test.c $(LDADD) $(pkglib_LTLIBRARIES)
 
 uctypedump: uctypedump.c
 	$(LINK) $(INCLUDES) $(srcdir)/uctypedump.c
 
-test_decimal$(EXEEXT): decimal.c $(pkglib_LIBRARIES)
+test_decimal$(EXEEXT): decimal.c $(pkglib_LTLIBRARIES)
 	$(CP) $(srcdir)/decimal.c ./test_decimal.c
-	$(LINK) $(FLAGS) -DMAIN  ./test_decimal.c $(LDADD) $(pkglib_LIBRARIES)
+	$(LINK) $(FLAGS) -DMAIN  ./test_decimal.c $(LDADD) $(pkglib_LTLIBRARIES)
 	$(RM) -f ./test_decimal.c
 
 # Don't update the files from bitkeeper

--- 1.23/vio/Makefile.am	2006-12-21 23:54:44 +01:00
+++ 1.24/vio/Makefile.am	2006-12-21 23:54:44 +01:00
@@ -17,11 +17,12 @@
 INCLUDES =		-I$(top_builddir)/include -I$(top_srcdir)/include \
 			$(openssl_includes)
 LDADD =			@CLIENT_EXTRA_LDFLAGS@ $(openssl_libs) $(yassl_libs)
-pkglib_LIBRARIES =	libvio.a
+pkglib_LTLIBRARIES =	libvio.la
 
 noinst_HEADERS =	vio_priv.h
 
-libvio_a_SOURCES =	vio.c viosocket.c viossl.c viosslfactories.c
+libvio_la_SOURCES =	vio.c viosocket.c viossl.c viosslfactories.c
+libvio_la_LDFLAGS =	-static
 
 EXTRA_DIST=		CMakeLists.txt
 

--- 1.2.2.1/config/ac-macros/ha_innodb.m4	2006-12-21 23:54:44 +01:00
+++ 1.6/BitKeeper/deleted/.del-ha_innodb.m4~6f141fb5b80c1f39	2006-12-21 23:54:44 +01:00
@@ -21,8 +21,8 @@
       AC_MSG_RESULT([Using Innodb])
       AC_DEFINE([HAVE_INNOBASE_DB], [1], [Using Innobase DB])
       have_innodb="yes"
-      innodb_includes="-I\$(top_builddir)/innobase/include
-I\$(top_srcdir)/innobase/include"
-      innodb_libs="\$(top_builddir)/innobase/libinnodb.la"
+      innodb_includes="-I\$(top_builddir)/storage/innobase/include
-I\$(top_srcdir)/storage/innobase/include"
+      innodb_libs="\$(top_builddir)/storage/innobase/libinnodb.la"
       AC_CHECK_LIB(rt, aio_read, [innodb_system_libs="-lrt"])
       ;;
     * )

--- 1.21/config/ac-macros/ha_ndbcluster.m4	2006-12-21 23:54:44 +01:00
+++ 1.22/config/ac-macros/ha_ndbcluster.m4	2006-12-21 23:54:44 +01:00
@@ -188,7 +188,7 @@
   TEST_NDBCLUSTER="--ndbcluster"
 
   ndbcluster_includes="-I\$(top_builddir)/storage/ndb/include
-I\$(top_srcdir)/storage/ndb/include -I\$(top_srcdir)/storage/ndb/include/ndbapi
-I\$(top_srcdir)/storage/ndb/include/mgmapi"
-  ndbcluster_libs="\$(top_builddir)/storage/ndb/src/.libs/libndbclient.a"
+  ndbcluster_libs="\$(top_builddir)/storage/ndb/src/libndbclient.la"
   ndbcluster_system_libs=""
   ndb_mgmclient_libs="\$(top_builddir)/storage/ndb/src/mgmclient/libndbmgmclient.la"
 

--- 1.43/server-tools/instance-manager/Makefile.am	2006-12-21 23:54:44 +01:00
+++ 1.44/server-tools/instance-manager/Makefile.am	2006-12-21 23:54:44 +01:00
@@ -24,8 +24,7 @@
 # default_options.h, generated from default_options.h.in)
 # See automake/autoconf docs for details
 
-noinst_LTLIBRARIES= liboptions.la
-noinst_LIBRARIES=   libnet.a
+noinst_LTLIBRARIES= liboptions.la libnet.la
 
 liboptions_la_CXXFLAGS= $(CXXFLAGS) \
 	-DDEFAULT_PID_FILE_NAME="$(localstatedir)/mysqlmanager.pid" \
@@ -42,12 +41,12 @@
 # MySQL sometimes uses symlinks to reuse code 
 # All symlinked files are grouped in libnet.a
 
-nodist_libnet_a_SOURCES= net_serv.cc client_settings.h
-libnet_a_LIBADD= $(top_builddir)/sql/password.$(OBJEXT) \
-	$(top_builddir)/sql/pack.$(OBJEXT) \
-	$(top_builddir)/sql/sql_state.$(OBJEXT) \
-	$(top_builddir)/sql/mini_client_errors.$(OBJEXT)\
-	$(top_builddir)/sql/client.$(OBJEXT)
+nodist_libnet_la_SOURCES= net_serv.cc client_settings.h \
+	$(top_builddir)/sql/password.c \
+	$(top_builddir)/sql/pack.c \
+	$(top_builddir)/sql/sql_state.c \
+	$(top_builddir)/sql/mini_client_errors.c \
+	$(top_builddir)/sql/client.c
 
 CLEANFILES= net_serv.cc client_settings.h
 
@@ -85,11 +84,11 @@
 
 mysqlmanager_LDADD=	@CLIENT_EXTRA_LDFLAGS@ \
 			liboptions.la \
-			libnet.a \
-			$(top_builddir)/vio/libvio.a \
-			$(top_builddir)/mysys/libmysys.a \
-			$(top_builddir)/strings/libmystrings.a \
-			$(top_builddir)/dbug/libdbug.a \
+			libnet.la \
+			$(top_builddir)/vio/libvio.la \
+			$(top_builddir)/mysys/libmysys.la \
+			$(top_builddir)/strings/libmystrings.la \
+			$(top_builddir)/dbug/libdbug.la \
 			@openssl_libs@ @yassl_libs@ @ZLIB_LIBS@
 
 EXTRA_DIST =		WindowsService.cpp WindowsService.h IMService.cpp \

--- 1.6.2.1/innobase/Makefile.am	2006-12-21 23:54:44 +01:00
+++ 1.24/storage/innobase/Makefile.am	2006-12-21 23:54:44 +01:00
@@ -17,21 +17,86 @@
 
 # Process this file with automake to create Makefile.in
 
+MYSQLDATAdir =          $(localstatedir)
+MYSQLSHAREdir =         $(pkgdatadir)
+MYSQLBASEdir=           $(prefix)
+MYSQLLIBdir=            $(pkglibdir)
+INCLUDES =              -I$(top_builddir)/include -I$(top_srcdir)/include \
+			-I$(top_srcdir)/regex \
+			-I$(top_srcdir)/storage/innobase/include \
+			-I$(top_srcdir)/sql \
+                        -I$(srcdir)
+
 AUTOMAKE_OPTIONS =	foreign
 
-noinst_HEADERS = ib_config.h
+noinst_HEADERS = 
 
 SUBDIRS =		os ut btr buf data dict dyn eval fil fsp fut \
-			ha ibuf include lock log mach mem mtr page \
+			ha ibuf lock log mach mem mtr page \
+			handler \
 			pars que read rem row srv sync thr trx usr
 
-EXTRA_DIST = CMakeLists.txt
+EXTRA_DIST = 	include/btr0btr.h include/btr0btr.ic include/btr0cur.h include/btr0cur.ic \
+		include/btr0pcur.h include/btr0pcur.ic 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 \
+		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 \
+		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 \
+		CMakeLists.txt plug.in
 
 # Work around the circular dependency problem in innodb libs,
 # we create one lib from all the other libs
-noinst_LTLIBRARIES = 	libinnodb.la
-libinnodb_la_SOURCES =	
-libinnodb_la_LIBADD = \
+noinst_LTLIBRARIES =	libinnobase.la
+libinnobase_la_SOURCES =
+libinnobase_la_LIBADD =	\
 			btr/libbtr.la \
 			buf/libbuf.la \
 			data/libdata.la \
@@ -42,6 +107,7 @@
 			fsp/libfsp.la \
 			fut/libfut.la \
 			ha/libha.la \
+			handler/libhandler.la \
 			ibuf/libibuf.la \
 			lock/liblock.la \
 			log/liblog.la \

--- 1.45.11.1/innobase/buf/buf0buf.c	2006-12-21 23:54:44 +01:00
+++ 1.63/storage/innobase/buf/buf0buf.c	2006-12-21 23:54:44 +01:00
@@ -1,14 +1,14 @@
 /*   Innobase relational database engine; Copyright (C) 2001 Innobase Oy
-     
+
      This program is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License 2
      as published by the Free Software Foundation in June 1991.
-     
+
      This program is distributed in the hope that it will be useful,
      but WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      GNU General Public License for more details.
-     
+
      You should have received a copy of the GNU General Public License 2
      along with this program (in file COPYING); if not, write to the Free
      Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
@@ -42,7 +42,7 @@
 		IMPLEMENTATION OF THE BUFFER POOL
 		=================================
 
-Performance improvement: 
+Performance improvement:
 ------------------------
 Thread scheduling in NT may be so slow that the OS wait mechanism should
 not be used even in waiting for disk reads to complete.
@@ -160,8 +160,8 @@
 releases the X-lock on the frame and resets the io_fix field
 when the io operation completes.
 
-A thread may request the above operation using the buf_page_get-
-function. It may then continue to request a lock on the frame.
+A thread may request the above operation using the function
+buf_page_get(). It may then continue to request a lock on the frame.
 The lock is granted when the io-handler releases the x-lock.
 
 		Read-ahead
@@ -242,33 +242,33 @@
 ulint
 buf_calc_page_new_checksum(
 /*=======================*/
-		       /* out: checksum */
-	byte*    page) /* in: buffer page */
+			/* out: checksum */
+	byte*	 page)	/* in: buffer page */
 {
-  	ulint checksum;
+	ulint checksum;
 
-        /* Since the field FIL_PAGE_FILE_FLUSH_LSN, and in versions <= 4.1.x
-        ..._ARCH_LOG_NO, are written outside the buffer pool to the first
-        pages of data files, we have to skip them in the page checksum
-        calculation.
+	/* Since the field FIL_PAGE_FILE_FLUSH_LSN, and in versions <= 4.1.x
+	..._ARCH_LOG_NO, are written outside the buffer pool to the first
+	pages of data files, we have to skip them in the page checksum
+	calculation.
 	We must also skip the field FIL_PAGE_SPACE_OR_CHKSUM where the
 	checksum is stored, and also the last 8 bytes of page because
 	there we store the old formula checksum. */
-  	
-  	checksum = ut_fold_binary(page + FIL_PAGE_OFFSET,
-				 FIL_PAGE_FILE_FLUSH_LSN - FIL_PAGE_OFFSET)
-  		   + ut_fold_binary(page + FIL_PAGE_DATA, 
-				           UNIV_PAGE_SIZE - FIL_PAGE_DATA
-				           - FIL_PAGE_END_LSN_OLD_CHKSUM);
-  	checksum = checksum & 0xFFFFFFFFUL;
 
-  	return(checksum);
+	checksum = ut_fold_binary(page + FIL_PAGE_OFFSET,
+				  FIL_PAGE_FILE_FLUSH_LSN - FIL_PAGE_OFFSET)
+		+ ut_fold_binary(page + FIL_PAGE_DATA,
+				 UNIV_PAGE_SIZE - FIL_PAGE_DATA
+				 - FIL_PAGE_END_LSN_OLD_CHKSUM);
+	checksum = checksum & 0xFFFFFFFFUL;
+
+	return(checksum);
 }
 
 /************************************************************************
 In versions < 4.0.14 and < 4.1.1 there was a bug that the checksum only
 looked at the first few bytes of the page. This calculates that old
-checksum. 
+checksum.
 NOTE: we must first store the new formula checksum to
 FIL_PAGE_SPACE_OR_CHKSUM before calculating and storing this old checksum
 because this takes that field as an input! */
@@ -276,16 +276,16 @@
 ulint
 buf_calc_page_old_checksum(
 /*=======================*/
-		       /* out: checksum */
-	byte*    page) /* in: buffer page */
+			/* out: checksum */
+	byte*	 page)	/* in: buffer page */
 {
-  	ulint checksum;
-  	
-  	checksum = ut_fold_binary(page, FIL_PAGE_FILE_FLUSH_LSN);
+	ulint checksum;
+
+	checksum = ut_fold_binary(page, FIL_PAGE_FILE_FLUSH_LSN);
 
-  	checksum = checksum & 0xFFFFFFFFUL;
+	checksum = checksum & 0xFFFFFFFFUL;
 
-  	return(checksum);
+	return(checksum);
 }
 
 /************************************************************************
@@ -305,7 +305,7 @@
 	dulint	current_lsn;
 #endif
 	if (mach_read_from_4(read_buf + FIL_PAGE_LSN + 4)
-	     != mach_read_from_4(read_buf + UNIV_PAGE_SIZE
+	    != mach_read_from_4(read_buf + UNIV_PAGE_SIZE
 				- FIL_PAGE_END_LSN_OLD_CHKSUM + 4)) {
 
 		/* Stored log sequence numbers at the start and the end
@@ -318,63 +318,75 @@
 	if (recv_lsn_checks_on && log_peek_lsn(&current_lsn)) {
 		if (ut_dulint_cmp(current_lsn,
 				  mach_read_from_8(read_buf + FIL_PAGE_LSN))
-				 < 0) {
+		    < 0) {
 			ut_print_timestamp(stderr);
 
 			fprintf(stderr,
-"  InnoDB: Error: page %lu log sequence number %lu %lu\n"
-"InnoDB: is in the future! Current system log sequence number %lu %lu.\n"
-"InnoDB: Your database may be corrupt or you may have copied the InnoDB\n"
-"InnoDB: tablespace but not the InnoDB log files. See\n"
-"InnoDB: http://dev.mysql.com/doc/refman/5.0/en/forcing-recovery.html\n"
-"InnoDB: for more information.\n",
-		        (ulong) mach_read_from_4(read_buf + FIL_PAGE_OFFSET),
-			(ulong) ut_dulint_get_high(
-				mach_read_from_8(read_buf + FIL_PAGE_LSN)),
-			(ulong) ut_dulint_get_low(
-				mach_read_from_8(read_buf + FIL_PAGE_LSN)),
-			(ulong) ut_dulint_get_high(current_lsn),
-			(ulong) ut_dulint_get_low(current_lsn));
+				"  InnoDB: Error: page %lu log sequence number"
+				" %lu %lu\n"
+				"InnoDB: is in the future! Current system "
+				"log sequence number %lu %lu.\n"
+				"InnoDB: Your database may be corrupt or "
+				"you may have copied the InnoDB\n"
+				"InnoDB: tablespace but not the InnoDB "
+				"log files. See\n"
+				"InnoDB: http://dev.mysql.com/doc/refman/"
+				"5.1/en/forcing-recovery.html\n"
+				"InnoDB: for more information.\n",
+				(ulong) mach_read_from_4(read_buf
+							 + FIL_PAGE_OFFSET),
+				(ulong) ut_dulint_get_high
+				(mach_read_from_8(read_buf + FIL_PAGE_LSN)),
+				(ulong) ut_dulint_get_low
+				(mach_read_from_8(read_buf + FIL_PAGE_LSN)),
+				(ulong) ut_dulint_get_high(current_lsn),
+				(ulong) ut_dulint_get_low(current_lsn));
 		}
 	}
 #endif
-  
-  /* If we use checksums validation, make additional check before returning
-  TRUE to ensure that the checksum is not equal to BUF_NO_CHECKSUM_MAGIC which
-  might be stored by InnoDB with checksums disabled.
-     Otherwise, skip checksum calculation and return FALSE */
-  
-  if (srv_use_checksums) {
-    old_checksum = buf_calc_page_old_checksum(read_buf); 
-
-    old_checksum_field = mach_read_from_4(read_buf + UNIV_PAGE_SIZE
-					- FIL_PAGE_END_LSN_OLD_CHKSUM);
-
-    /* There are 2 valid formulas for old_checksum_field:
-	  1. Very old versions of InnoDB only stored 8 byte lsn to the start
-	  and the end of the page.
-	  2. Newer InnoDB versions store the old formula checksum there. */
-	
-    if (old_checksum_field != mach_read_from_4(read_buf + FIL_PAGE_LSN)
-        && old_checksum_field != old_checksum
-        && old_checksum_field != BUF_NO_CHECKSUM_MAGIC) {
-
-      return(TRUE);
-    }
-
-    checksum = buf_calc_page_new_checksum(read_buf);
-    checksum_field = mach_read_from_4(read_buf + FIL_PAGE_SPACE_OR_CHKSUM);
-
-    /* InnoDB versions < 4.0.14 and < 4.1.1 stored the space id
-	  (always equal to 0), to FIL_PAGE_SPACE_SPACE_OR_CHKSUM */
-
-    if (checksum_field != 0 && checksum_field != checksum
-        && checksum_field != BUF_NO_CHECKSUM_MAGIC) {
-
-      return(TRUE);
-    }
-  }
-  
+
+	/* If we use checksums validation, make additional check before
+	returning TRUE to ensure that the checksum is not equal to
+	BUF_NO_CHECKSUM_MAGIC which might be stored by InnoDB with checksums
+	disabled. Otherwise, skip checksum calculation and return FALSE */
+
+	if (srv_use_checksums) {
+		old_checksum = buf_calc_page_old_checksum(read_buf);
+
+		old_checksum_field = mach_read_from_4(
+			read_buf + UNIV_PAGE_SIZE
+			- FIL_PAGE_END_LSN_OLD_CHKSUM);
+
+		/* There are 2 valid formulas for old_checksum_field:
+
+		1. Very old versions of InnoDB only stored 8 byte lsn to the
+		start and the end of the page.
+
+		2. Newer InnoDB versions store the old formula checksum
+		there. */
+
+		if (old_checksum_field != mach_read_from_4(read_buf
+							   + FIL_PAGE_LSN)
+		    && old_checksum_field != old_checksum
+		    && old_checksum_field != BUF_NO_CHECKSUM_MAGIC) {
+
+			return(TRUE);
+		}
+
+		checksum = buf_calc_page_new_checksum(read_buf);
+		checksum_field = mach_read_from_4(read_buf
+						  + FIL_PAGE_SPACE_OR_CHKSUM);
+
+		/* InnoDB versions < 4.0.14 and < 4.1.1 stored the space id
+		(always equal to 0), to FIL_PAGE_SPACE_SPACE_OR_CHKSUM */
+
+		if (checksum_field != 0 && checksum_field != checksum
+		    && checksum_field != BUF_NO_CHECKSUM_MAGIC) {
+
+			return(TRUE);
+		}
+	}
+
 	return(FALSE);
 }
 
@@ -396,65 +408,104 @@
 	ut_print_buf(stderr, read_buf, UNIV_PAGE_SIZE);
 	fputs("InnoDB: End of page dump\n", stderr);
 
-	checksum = srv_use_checksums ?
-    buf_calc_page_new_checksum(read_buf) : BUF_NO_CHECKSUM_MAGIC;
-	old_checksum = srv_use_checksums ?
-    buf_calc_page_old_checksum(read_buf) : BUF_NO_CHECKSUM_MAGIC;
+	checksum = srv_use_checksums
+		? buf_calc_page_new_checksum(read_buf) : BUF_NO_CHECKSUM_MAGIC;
+	old_checksum = srv_use_checksums
+		? buf_calc_page_old_checksum(read_buf) : BUF_NO_CHECKSUM_MAGIC;
 
 	ut_print_timestamp(stderr);
-	fprintf(stderr, 
-"  InnoDB: Page checksum %lu, prior-to-4.0.14-form checksum %lu\n"
-"InnoDB: stored checksum %lu, prior-to-4.0.14-form stored checksum %lu\n",
-			(ulong) checksum, (ulong) old_checksum,
-			(ulong) mach_read_from_4(read_buf + FIL_PAGE_SPACE_OR_CHKSUM),
-			(ulong) mach_read_from_4(read_buf + UNIV_PAGE_SIZE
-					- FIL_PAGE_END_LSN_OLD_CHKSUM));
 	fprintf(stderr,
-"InnoDB: Page lsn %lu %lu, low 4 bytes of lsn at page end %lu\n"
-"InnoDB: Page number (if stored to page already) %lu,\n"
-"InnoDB: space id (if created with >= MySQL-4.1.1 and stored already) %lu\n",
+		"  InnoDB: Page checksum %lu, prior-to-4.0.14-form"
+		" checksum %lu\n"
+		"InnoDB: stored checksum %lu, prior-to-4.0.14-form"
+		" stored checksum %lu\n"
+		"InnoDB: Page lsn %lu %lu, low 4 bytes of lsn"
+		" at page end %lu\n"
+		"InnoDB: Page number (if stored to page already) %lu,\n"
+		"InnoDB: space id (if created with >= MySQL-4.1.1"
+		" and stored already) %lu\n",
+		(ulong) checksum, (ulong) old_checksum,
+		(ulong) mach_read_from_4(read_buf + FIL_PAGE_SPACE_OR_CHKSUM),
+		(ulong) mach_read_from_4(read_buf + UNIV_PAGE_SIZE
+					 - FIL_PAGE_END_LSN_OLD_CHKSUM),
 		(ulong) mach_read_from_4(read_buf + FIL_PAGE_LSN),
 		(ulong) mach_read_from_4(read_buf + FIL_PAGE_LSN + 4),
 		(ulong) mach_read_from_4(read_buf + UNIV_PAGE_SIZE
-					- FIL_PAGE_END_LSN_OLD_CHKSUM + 4),
+					 - FIL_PAGE_END_LSN_OLD_CHKSUM + 4),
 		(ulong) mach_read_from_4(read_buf + FIL_PAGE_OFFSET),
-		(ulong) mach_read_from_4(read_buf + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID));
+		(ulong) mach_read_from_4(read_buf
+					 + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID));
 
 	if (mach_read_from_2(read_buf + TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_TYPE)
 	    == TRX_UNDO_INSERT) {
-	    	fprintf(stderr,
+		fprintf(stderr,
 			"InnoDB: Page may be an insert undo log page\n");
 	} else if (mach_read_from_2(read_buf + TRX_UNDO_PAGE_HDR
-						+ TRX_UNDO_PAGE_TYPE)
-	    	== TRX_UNDO_UPDATE) {
-	    	fprintf(stderr,
+				    + TRX_UNDO_PAGE_TYPE)
+		   == TRX_UNDO_UPDATE) {
+		fprintf(stderr,
 			"InnoDB: Page may be an update undo log page\n");
 	}
 
-	if (fil_page_get_type(read_buf) == FIL_PAGE_INDEX) {
-	    	fprintf(stderr,
-"InnoDB: Page may be an index page where index id is %lu %lu\n",
-			(ulong) ut_dulint_get_high(btr_page_get_index_id(read_buf)),
-			(ulong) ut_dulint_get_low(btr_page_get_index_id(read_buf)));
+	switch (fil_page_get_type(read_buf)) {
+	case FIL_PAGE_INDEX:
+		fprintf(stderr,
+			"InnoDB: Page may be an index page where"
+			" index id is %lu %lu\n",
+			(ulong) ut_dulint_get_high
+			(btr_page_get_index_id(read_buf)),
+			(ulong) ut_dulint_get_low
+			(btr_page_get_index_id(read_buf)));
 
 		/* If the code is in ibbackup, dict_sys may be uninitialized,
 		i.e., NULL */
 
 		if (dict_sys != NULL) {
 
-		        index = dict_index_find_on_id_low(
-					btr_page_get_index_id(read_buf));
-		        if (index) {
+			index = dict_index_find_on_id_low(
+				btr_page_get_index_id(read_buf));
+			if (index) {
 				fputs("InnoDB: (", stderr);
 				dict_index_name_print(stderr, NULL, index);
 				fputs(")\n", stderr);
 			}
 		}
-	} else if (fil_page_get_type(read_buf) == FIL_PAGE_INODE) {
+		break;
+	case FIL_PAGE_INODE:
 		fputs("InnoDB: Page may be an 'inode' page\n", stderr);
-	} else if (fil_page_get_type(read_buf) == FIL_PAGE_IBUF_FREE_LIST) {
+		break;
+	case FIL_PAGE_IBUF_FREE_LIST:
 		fputs("InnoDB: Page may be an insert buffer free list page\n",
-			stderr);
+		      stderr);
+		break;
+	case FIL_PAGE_TYPE_ALLOCATED:
+		fputs("InnoDB: Page may be a freshly allocated page\n",
+		      stderr);
+		break;
+	case FIL_PAGE_IBUF_BITMAP:
+		fputs("InnoDB: Page may be an insert buffer bitmap page\n",
+		      stderr);
+		break;
+	case FIL_PAGE_TYPE_SYS:
+		fputs("InnoDB: Page may be a system page\n",
+		      stderr);
+		break;
+	case FIL_PAGE_TYPE_TRX_SYS:
+		fputs("InnoDB: Page may be a transaction system page\n",
+		      stderr);
+		break;
+	case FIL_PAGE_TYPE_FSP_HDR:
+		fputs("InnoDB: Page may be a file space header page\n",
+		      stderr);
+		break;
+	case FIL_PAGE_TYPE_XDES:
+		fputs("InnoDB: Page may be an extent descriptor page\n",
+		      stderr);
+		break;
+	case FIL_PAGE_TYPE_BLOB:
+		fputs("InnoDB: Page may be a BLOB page\n",
+		      stderr);
+		break;
 	}
 }
 
@@ -471,7 +522,7 @@
 	block->magic_n = 0;
 
 	block->state = BUF_BLOCK_NOT_USED;
-	
+
 	block->frame = frame;
 
 	block->awe_info = NULL;
@@ -480,7 +531,7 @@
 	block->io_fix = 0;
 
 	block->modify_clock = ut_dulint_zero;
-	
+
 	block->file_page_was_freed = FALSE;
 
 	block->check_index_page_at_flush = FALSE;
@@ -491,15 +542,13 @@
 
 	block->n_pointers = 0;
 
-	mutex_create(&block->mutex);
-	mutex_set_level(&block->mutex, SYNC_BUF_BLOCK);
+	mutex_create(&block->mutex, SYNC_BUF_BLOCK);
 
-	rw_lock_create(&(block->lock));
+	rw_lock_create(&block->lock, SYNC_LEVEL_VARYING);
 	ut_ad(rw_lock_validate(&(block->lock)));
 
 #ifdef UNIV_SYNC_DEBUG
-	rw_lock_create(&(block->debug_latch));
-	rw_lock_set_level(&(block->debug_latch), SYNC_NO_ORDER_CHECK);
+	rw_lock_create(&block->debug_latch, SYNC_NO_ORDER_CHECK);
 #endif /* UNIV_SYNC_DEBUG */
 }
 
@@ -525,15 +574,18 @@
 	byte*		frame;
 	ulint		i;
 	buf_block_t*	block;
-	
+
 	ut_a(max_size == curr_size);
 	ut_a(srv_use_awe || n_frames == max_size);
-	
+
 	if (n_frames > curr_size) {
-	        fprintf(stderr,
-"InnoDB: AWE: Error: you must specify in my.cnf .._awe_mem_mb larger\n"
-"InnoDB: than .._buffer_pool_size. Now the former is %lu pages,\n"
-"InnoDB: the latter %lu pages.\n", (ulong) curr_size, (ulong) n_frames);
+		fprintf(stderr,
+			"InnoDB: AWE: Error: you must specify in my.cnf"
+			" .._awe_mem_mb larger\n"
+			"InnoDB: than .._buffer_pool_size. Now the former"
+			" is %lu pages,\n"
+			"InnoDB: the latter %lu pages.\n",
+			(ulong) curr_size, (ulong) n_frames);
 
 		return(NULL);
 	}
@@ -541,9 +593,8 @@
 	buf_pool = mem_alloc(sizeof(buf_pool_t));
 
 	/* 1. Initialize general fields
-	   ---------------------------- */
-	mutex_create(&(buf_pool->mutex));
-	mutex_set_level(&(buf_pool->mutex), SYNC_BUF_POOL);
+	---------------------------- */
+	mutex_create(&buf_pool->mutex, SYNC_BUF_POOL);
 
 	mutex_enter(&(buf_pool->mutex));
 
@@ -553,31 +604,34 @@
 		buffer pool frames */
 
 		buf_pool->frame_mem = os_awe_allocate_virtual_mem_window(
-					UNIV_PAGE_SIZE * (n_frames + 1));
-					
+			UNIV_PAGE_SIZE * (n_frames + 1));
+
 		/* Allocate the physical memory for AWE and the AWE info array
 		for buf_pool */
 
 		if ((curr_size % ((1024 * 1024) / UNIV_PAGE_SIZE)) != 0) {
 
-		        fprintf(stderr,
-"InnoDB: AWE: Error: physical memory must be allocated in full megabytes.\n"
-"InnoDB: Trying to allocate %lu database pages.\n", 
-			  (ulong) curr_size);
+			fprintf(stderr,
+				"InnoDB: AWE: Error: physical memory must be"
+				" allocated in full megabytes.\n"
+				"InnoDB: Trying to allocate %lu"
+				" database pages.\n",
+				(ulong) curr_size);
 
-		        return(NULL);
+			return(NULL);
 		}
 
 		if (!os_awe_allocate_physical_mem(&(buf_pool->awe_info),
-			curr_size / ((1024 * 1024) / UNIV_PAGE_SIZE))) {
+						  curr_size
+						  / ((1024 * 1024)
+						     / UNIV_PAGE_SIZE))) {
 
 			return(NULL);
 		}
 		/*----------------------------------------*/
 	} else {
 		buf_pool->frame_mem = os_mem_alloc_large(
-					UNIV_PAGE_SIZE * (n_frames + 1),
-					TRUE, FALSE);
+			UNIV_PAGE_SIZE * (n_frames + 1), TRUE, FALSE);
 	}
 
 	if (buf_pool->frame_mem == NULL) {
@@ -610,14 +664,15 @@
 		the window */
 
 		os_awe_map_physical_mem_to_window(buf_pool->frame_zero,
-				n_frames *
-				(UNIV_PAGE_SIZE / OS_AWE_X86_PAGE_SIZE),
-					buf_pool->awe_info);
+						  n_frames
+						  * (UNIV_PAGE_SIZE
+						     / OS_AWE_X86_PAGE_SIZE),
+						  buf_pool->awe_info);
 		/*----------------------------------------*/
 	}
 
 	buf_pool->blocks_of_frames = ut_malloc(sizeof(void*) * n_frames);
-	
+
 	if (buf_pool->blocks_of_frames == NULL) {
 
 		return(NULL);
@@ -638,7 +693,7 @@
 		} else {
 			frame = NULL;
 		}
-		
+
 		buf_block_init(block, frame);
 
 		if (srv_use_awe) {
@@ -659,16 +714,16 @@
 	buf_pool->n_pages_written = 0;
 	buf_pool->n_pages_created = 0;
 	buf_pool->n_pages_awe_remapped = 0;
-	
+
 	buf_pool->n_page_gets = 0;
 	buf_pool->n_page_gets_old = 0;
 	buf_pool->n_pages_read_old = 0;
 	buf_pool->n_pages_written_old = 0;
 	buf_pool->n_pages_created_old = 0;
 	buf_pool->n_pages_awe_remapped_old = 0;
-	
+
 	/* 2. Initialize flushing fields
-	   ---------------------------- */
+	---------------------------- */
 	UT_LIST_INIT(buf_pool->flush_list);
 
 	for (i = BUF_FLUSH_LRU; i <= BUF_FLUSH_LIST; i++) {
@@ -681,9 +736,9 @@
 
 	buf_pool->ulint_clock = 1;
 	buf_pool->freed_page_clock = 0;
-	
+
 	/* 3. Initialize LRU fields
-	   ---------------------------- */
+	---------------------------- */
 	UT_LIST_INIT(buf_pool->LRU);
 
 	buf_pool->LRU_old = NULL;
@@ -707,9 +762,10 @@
 			if (srv_use_awe) {
 				/* Add to the list of blocks mapped to
 				frames */
-				
+
 				UT_LIST_ADD_LAST(awe_LRU_free_mapped,
-					buf_pool->awe_LRU_free_mapped, block);
+						 buf_pool->awe_LRU_free_mapped,
+						 block);
 			}
 		}
 
@@ -720,15 +776,15 @@
 	mutex_exit(&(buf_pool->mutex));
 
 	if (srv_use_adaptive_hash_indexes) {
-	  	btr_search_sys_create(
-			  curr_size * UNIV_PAGE_SIZE / sizeof(void*) / 64);
+		btr_search_sys_create(curr_size * UNIV_PAGE_SIZE
+				      / sizeof(void*) / 64);
 	} else {
-	        /* Create only a small dummy system */
-	        btr_search_sys_create(1000);
+		/* Create only a small dummy system */
+		btr_search_sys_create(1000);
 	}
 
 	return(buf_pool);
-}	
+}
 
 /************************************************************************
 Maps the page of block to a frame, if not mapped yet. Unmaps some page
@@ -761,7 +817,7 @@
 
 	bck = UT_LIST_GET_LAST(buf_pool->awe_LRU_free_mapped);
 
-	while (bck) {	
+	while (bck) {
 		ibool skip;
 
 		mutex_enter(&bck->mutex);
@@ -785,24 +841,25 @@
 			block->frame = bck->frame;
 
 			*(buf_pool->blocks_of_frames
-				+ (((ulint)(block->frame
-						- buf_pool->frame_zero))
-						>> UNIV_PAGE_SIZE_SHIFT))
+			  + (((ulint)(block->frame
+				      - buf_pool->frame_zero))
+			     >> UNIV_PAGE_SIZE_SHIFT))
 				= block;
-			
+
 			bck->frame = NULL;
 			UT_LIST_REMOVE(awe_LRU_free_mapped,
-					buf_pool->awe_LRU_free_mapped,
-					bck);
+				       buf_pool->awe_LRU_free_mapped,
+				       bck);
 
 			if (add_to_mapped_list) {
-				UT_LIST_ADD_FIRST(awe_LRU_free_mapped,
+				UT_LIST_ADD_FIRST(
+					awe_LRU_free_mapped,
 					buf_pool->awe_LRU_free_mapped,
 					block);
 			}
 
 			buf_pool->n_pages_awe_remapped++;
-			
+
 			mutex_exit(&bck->mutex);
 
 			return;
@@ -810,8 +867,8 @@
 	}
 
 	fprintf(stderr,
-"InnoDB: AWE: Fatal error: cannot find a page to unmap\n"
-"InnoDB: awe_LRU_free_mapped list length %lu\n",
+		"InnoDB: AWE: Fatal error: cannot find a page to unmap\n"
+		"InnoDB: awe_LRU_free_mapped list length %lu\n",
 		(ulong) UT_LIST_GET_LEN(buf_pool->awe_LRU_free_mapped));
 
 	ut_a(0);
@@ -850,7 +907,7 @@
 	/* Note that we read freed_page_clock's without holding any mutex:
 	this is allowed since the result is used only in heuristics */
 
-	if (buf_pool->freed_page_clock >= block->freed_page_clock 
+	if (buf_pool->freed_page_clock >= block->freed_page_clock
 				+ 1 + (buf_pool->curr_size / 4)) {
 
 		mutex_enter(&buf_pool->mutex);
@@ -869,11 +926,11 @@
 
 void
 buf_page_make_young(
-/*=================*/
+/*================*/
 	buf_frame_t*	frame)	/* in: buffer frame of a file page */
 {
 	buf_block_t*	block;
-	
+
 	mutex_enter(&(buf_pool->mutex));
 
 	block = buf_block_align(frame);
@@ -927,7 +984,7 @@
 {
 	buf_block_free(buf_block_align(frame));
 }
-	
+
 /************************************************************************
 Returns the buffer control block if the page can be found in the buffer
 pool. NOTE that it is possible that the page is not yet read
@@ -972,7 +1029,7 @@
 	if (block) {
 		block->check_index_page_at_flush = FALSE;
 	}
-	
+
 	mutex_exit(&(buf_pool->mutex));
 }
 
@@ -1108,7 +1165,7 @@
 	ulint		fix_type;
 	ibool		success;
 	ibool		must_read;
-	
+
 	ut_ad(mtr);
 	ut_ad((rw_latch == RW_S_LATCH)
 	      || (rw_latch == RW_X_LATCH)
@@ -1123,12 +1180,12 @@
 loop:
 	block = NULL;
 	mutex_enter_fast(&(buf_pool->mutex));
-	
+
 	if (guess) {
 		block = buf_block_align(guess);
 
 		if ((offset != block->offset) || (space != block->space)
-				|| (block->state != BUF_BLOCK_FILE_PAGE)) {
+		    || (block->state != BUF_BLOCK_FILE_PAGE)) {
 
 			block = NULL;
 		}
@@ -1165,7 +1222,7 @@
 	ut_a(block->state == BUF_BLOCK_FILE_PAGE);
 
 	must_read = FALSE;
-	
+
 	if (block->io_fix == BUF_IO_READ) {
 
 		must_read = TRUE;
@@ -1177,7 +1234,7 @@
 
 			return(NULL);
 		}
-	}		
+	}
 
 	/* If AWE is enabled and the page is not mapped to a frame, then
 	map it */
@@ -1188,10 +1245,10 @@
 		/* We set second parameter TRUE because the block is in the
 		LRU list and we must put it to awe_LRU_free_mapped list once
 		mapped to a frame */
-		
+
 		buf_awe_map_page_to_frame(block, TRUE);
 	}
-	
+
 #ifdef UNIV_SYNC_DEBUG
 	buf_block_buf_fix_inc_debug(block, file, line);
 #else
@@ -1211,7 +1268,7 @@
 
 #ifdef UNIV_DEBUG_FILE_ACCESSES
 	ut_a(block->file_page_was_freed == FALSE);
-#endif	
+#endif
 
 #ifdef UNIV_DEBUG
 	buf_dbg_counter++;
@@ -1226,12 +1283,12 @@
 	if (mode == BUF_GET_NOWAIT) {
 		if (rw_latch == RW_S_LATCH) {
 			success = rw_lock_s_lock_func_nowait(&(block->lock),
-								file, line);
+							     file, line);
 			fix_type = MTR_MEMO_PAGE_S_FIX;
 		} else {
 			ut_ad(rw_latch == RW_X_LATCH);
 			success = rw_lock_x_lock_func_nowait(&(block->lock),
-					file, line);
+							     file, line);
 			fix_type = MTR_MEMO_PAGE_X_FIX;
 		}
 
@@ -1243,29 +1300,29 @@
 			mutex_exit(&block->mutex);
 #ifdef UNIV_SYNC_DEBUG
 			rw_lock_s_unlock(&(block->debug_latch));
-#endif			
+#endif
 
 			return(NULL);
 		}
 	} else if (rw_latch == RW_NO_LATCH) {
 
 		if (must_read) {
-		        /* Let us wait until the read operation
+			/* Let us wait until the read operation
 			completes */
 
-		        for (;;) {
+			for (;;) {
 				mutex_enter(&block->mutex);
 
-		                if (block->io_fix == BUF_IO_READ) {
+				if (block->io_fix == BUF_IO_READ) {
 
 					mutex_exit(&block->mutex);
-				  
+
 					os_thread_sleep(WAIT_FOR_READ);
 				} else {
-				  
+
 					mutex_exit(&block->mutex);
 
-				       break;
+					break;
 				}
 			}
 		}
@@ -1294,7 +1351,7 @@
 #ifdef UNIV_IBUF_DEBUG
 	ut_a(ibuf_count_get(block->space, block->offset) == 0);
 #endif
-	return(block->frame);		
+	return(block->frame);
 }
 
 /************************************************************************
@@ -1352,17 +1409,17 @@
 
 	if (rw_latch == RW_S_LATCH) {
 		success = rw_lock_s_lock_func_nowait(&(block->lock),
-								file, line);
+						     file, line);
 		fix_type = MTR_MEMO_PAGE_S_FIX;
 	} else {
 		success = rw_lock_x_lock_func_nowait(&(block->lock),
-								file, line);
+						     file, line);
 		fix_type = MTR_MEMO_PAGE_X_FIX;
 	}
 
 	if (UNIV_UNLIKELY(!success)) {
 		mutex_enter(&block->mutex);
-		
+
 		block->buf_fix_count--;
 
 		mutex_exit(&block->mutex);
@@ -1384,7 +1441,7 @@
 		}
 
 		mutex_enter(&block->mutex);
-		
+
 		block->buf_fix_count--;
 
 		mutex_exit(&block->mutex);
@@ -1415,7 +1472,7 @@
 		read-ahead */
 
 		buf_read_ahead_linear(buf_frame_get_space_id(guess),
-					buf_frame_get_page_no(guess));
+				      buf_frame_get_page_no(guess));
 	}
 
 #ifdef UNIV_IBUF_DEBUG
@@ -1448,14 +1505,14 @@
 
 	ut_ad(mtr);
 	ut_ad((rw_latch == RW_S_LATCH) || (rw_latch == RW_X_LATCH));
-	
+
 	block = buf_block_align(guess);
 
 	mutex_enter(&block->mutex);
 
 	if (block->state == BUF_BLOCK_REMOVE_HASH) {
-	        /* Another thread is just freeing the block from the LRU list
-	        of the buffer pool: do not try to access this page; this
+		/* Another thread is just freeing the block from the LRU list
+		of the buffer pool: do not try to access this page; this
 		attempt to access the page can only come through the hash
 		index because when the buffer block state is ..._REMOVE_HASH,
 		we have already removed it from the page address hash table
@@ -1483,24 +1540,24 @@
 
 	if (rw_latch == RW_S_LATCH) {
 		success = rw_lock_s_lock_func_nowait(&(block->lock),
-								file, line);
+						     file, line);
 		fix_type = MTR_MEMO_PAGE_S_FIX;
 	} else {
 		success = rw_lock_x_lock_func_nowait(&(block->lock),
-								file, line);
+						     file, line);
 		fix_type = MTR_MEMO_PAGE_X_FIX;
 	}
-	
+
 	if (!success) {
 		mutex_enter(&block->mutex);
-		
+
 		block->buf_fix_count--;
 
 		mutex_exit(&block->mutex);
 
 #ifdef UNIV_SYNC_DEBUG
 		rw_lock_s_unlock(&(block->debug_latch));
-#endif		
+#endif
 
 		return(FALSE);
 	}
@@ -1522,7 +1579,7 @@
 
 #ifdef UNIV_IBUF_DEBUG
 	ut_a((mode == BUF_KEEP_OLD)
-		|| (ibuf_count_get(block->space, block->offset) == 0));
+	     || (ibuf_count_get(block->space, block->offset) == 0));
 #endif
 	buf_pool->n_page_gets++;
 
@@ -1543,9 +1600,9 @@
 	/* Set the state of the block */
 	block->magic_n		= BUF_BLOCK_MAGIC_N;
 
-	block->state 		= BUF_BLOCK_FILE_PAGE;
-	block->space 		= space;
-	block->offset 		= offset;
+	block->state		= BUF_BLOCK_FILE_PAGE;
+	block->space		= space;
+	block->offset		= offset;
 
 	block->lock_hash_val	= 0;
 
@@ -1553,16 +1610,16 @@
 
 	block->newest_modification = ut_dulint_zero;
 	block->oldest_modification = ut_dulint_zero;
-	
+
 	block->accessed		= FALSE;
-	block->buf_fix_count 	= 0;
+	block->buf_fix_count	= 0;
 	block->io_fix		= 0;
 
 	block->n_hash_helps	= 0;
 	block->is_hashed	= FALSE;
-	block->n_fields         = 1;
-	block->n_bytes          = 0;
-	block->side             = BTR_SEARCH_LEFT_SIDE;
+	block->n_fields		= 1;
+	block->n_bytes		= 0;
+	block->left_side	= TRUE;
 
 	block->file_page_was_freed = FALSE;
 }
@@ -1587,48 +1644,49 @@
 	/* Set the state of the block */
 	block->magic_n		= BUF_BLOCK_MAGIC_N;
 
-	block->state 		= BUF_BLOCK_FILE_PAGE;
-	block->space 		= space;
-	block->offset 		= offset;
+	block->state		= BUF_BLOCK_FILE_PAGE;
+	block->space		= space;
+	block->offset		= offset;
 
 	block->check_index_page_at_flush = FALSE;
 	block->index		= NULL;
-	
+
 	block->lock_hash_val	= lock_rec_hash(space, offset);
 
 	/* Insert into the hash table of file pages */
 
-        if (buf_page_hash_get(space, offset)) {
-                fprintf(stderr,
-"InnoDB: Error: page %lu %lu already found from the hash table\n",
+	if (buf_page_hash_get(space, offset)) {
+		fprintf(stderr,
+			"InnoDB: Error: page %lu %lu already found"
+			" in the hash table\n",
 			(ulong) space,
 			(ulong) offset);
 #ifdef UNIV_DEBUG
-                buf_print();
-                buf_LRU_print();
-                buf_validate();
-                buf_LRU_validate();
+		buf_print();
+		buf_LRU_print();
+		buf_validate();
+		buf_LRU_validate();
 #endif /* UNIV_DEBUG */
-                ut_a(0);
-        }
+		ut_a(0);
+	}
 
 	HASH_INSERT(buf_block_t, hash, buf_pool->page_hash,
-				buf_page_address_fold(space, offset), block);
+		    buf_page_address_fold(space, offset), block);
 
 	block->freed_page_clock = 0;
 
 	block->newest_modification = ut_dulint_zero;
 	block->oldest_modification = ut_dulint_zero;
-	
+
 	block->accessed		= FALSE;
-	block->buf_fix_count 	= 0;
+	block->buf_fix_count	= 0;
 	block->io_fix		= 0;
 
 	block->n_hash_helps	= 0;
 	block->is_hashed	= FALSE;
-	block->n_fields         = 1;
-	block->n_bytes          = 0;
-	block->side             = BTR_SEARCH_LEFT_SIDE;
+	block->n_fields		= 1;
+	block->n_bytes		= 0;
+	block->left_side	= TRUE;
 
 	block->file_page_was_freed = FALSE;
 }
@@ -1643,7 +1701,7 @@
 on the buffer frame. The io-handler must take care that the flag is cleared
 and the lock released later. This is one of the functions which perform the
 state transition NOT_USED => FILE_PAGE to a block (the other is
-buf_page_create). */ 
+buf_page_create). */
 
 buf_block_t*
 buf_page_init_for_read(
@@ -1669,9 +1727,9 @@
 
 		ut_ad(!ibuf_bitmap_page(offset));
 		ut_ad(ibuf_inside());
-	
+
 		mtr_start(&mtr);
-	
+
 		if (!ibuf_page_low(space, offset, &mtr)) {
 
 			mtr_commit(&mtr);
@@ -1681,7 +1739,7 @@
 	} else {
 		ut_ad(mode == BUF_READ_ANY_PAGE);
 	}
-	
+
 	block = buf_block_alloc();
 
 	ut_a(block);
@@ -1689,53 +1747,54 @@
 	mutex_enter(&(buf_pool->mutex));
 	mutex_enter(&block->mutex);
 
-	if (fil_tablespace_deleted_or_being_deleted_in_mem(space,
-							tablespace_version)) {
+	if (fil_tablespace_deleted_or_being_deleted_in_mem(
+		    space, tablespace_version)) {
 		*err = DB_TABLESPACE_DELETED;
 	}
 
 	if (*err == DB_TABLESPACE_DELETED
 	    || NULL != buf_page_hash_get(space, offset)) {
 
-		/* The page belongs to a space which has been deleted or is
-		being deleted, or the page is already in buf_pool, return */
+		    /* The page belongs to a space which has been
+		    deleted or is being deleted, or the page is
+		    already in buf_pool, return */
 
 		mutex_exit(&block->mutex);
-		mutex_exit(&(buf_pool->mutex));
+		    mutex_exit(&(buf_pool->mutex));
 
-		buf_block_free(block);
+		    buf_block_free(block);
 
-		if (mode == BUF_READ_IBUF_PAGES_ONLY) {
+		    if (mode == BUF_READ_IBUF_PAGES_ONLY) {
 
-			mtr_commit(&mtr);
-		}
+			    mtr_commit(&mtr);
+		    }
 
-		return(NULL);
-	}
+		    return(NULL);
+	    }
 
 	ut_ad(block);
-	
+
 	buf_page_init(space, offset, block);
 
 	/* The block must be put to the LRU list, to the old blocks */
 
-	buf_LRU_add_block(block, TRUE); 	/* TRUE == to old blocks */
-	
+	buf_LRU_add_block(block, TRUE);		/* TRUE == to old blocks */
+
 	block->io_fix = BUF_IO_READ;
 
 	buf_pool->n_pend_reads++;
-	
+
 	/* We set a pass-type x-lock on the frame because then the same
 	thread which called for the read operation (and is running now at
 	this point of code) can wait for the read to complete by waiting
 	for the x-lock on the frame; if the x-lock were recursive, the
 	same thread would illegally get the x-lock before the page read
 	is completed. The x-lock is cleared by the io-handler thread. */
-	
+
 	rw_lock_x_lock_gen(&(block->lock), BUF_IO_READ);
-	
+
 	mutex_exit(&block->mutex);
- 	mutex_exit(&(buf_pool->mutex));
+	mutex_exit(&(buf_pool->mutex));
 
 	if (mode == BUF_READ_IBUF_PAGES_ONLY) {
 
@@ -1743,7 +1802,7 @@
 	}
 
 	return(block);
-}	
+}
 
 /************************************************************************
 Initializes a page to the buffer buf_pool. The page is usually not read
@@ -1763,11 +1822,11 @@
 	buf_frame_t*	frame;
 	buf_block_t*	block;
 	buf_block_t*	free_block	= NULL;
-	
+
 	ut_ad(mtr);
 
 	free_block = buf_LRU_get_free_block();
-	
+
 	mutex_enter(&(buf_pool->mutex));
 
 	block = buf_page_hash_get(space, offset);
@@ -1798,14 +1857,14 @@
 #endif /* UNIV_DEBUG */
 
 	block = free_block;
-	
+
 	mutex_enter(&block->mutex);
 
 	buf_page_init(space, offset, block);
 
 	/* The block must be put to the LRU list */
 	buf_LRU_add_block(block, FALSE);
-		
+
 #ifdef UNIV_SYNC_DEBUG
 	buf_block_buf_fix_inc_debug(block, __FILE__, __LINE__);
 #else
@@ -1818,7 +1877,7 @@
 	mtr_memo_push(mtr, block, MTR_MEMO_BUF_FIX);
 
 	block->accessed = TRUE;
-	
+
 	mutex_exit(&block->mutex);
 
 	/* Delete possible entries for the page from the insert buffer:
@@ -1831,6 +1890,10 @@
 
 	frame = block->frame;
 
+	memset(frame + FIL_PAGE_PREV, 0xff, 4);
+	memset(frame + FIL_PAGE_NEXT, 0xff, 4);
+	mach_write_to_2(frame + FIL_PAGE_TYPE, FIL_PAGE_TYPE_ALLOCATED);
+
 	/* Reset to zero the file flush lsn field in the page; if the first
 	page of an ibdata file is 'created' in this function into the buffer
 	pool then we lose the original contents of the file flush lsn stamp.
@@ -1862,8 +1925,7 @@
 	buf_block_t*	block)	/* in: pointer to the block in question */
 {
 	ulint		io_type;
-	ulint		read_page_no;
-	
+
 	ut_ad(block);
 
 	ut_a(block->state == BUF_BLOCK_FILE_PAGE);
@@ -1878,70 +1940,103 @@
 
 	if (io_type == BUF_IO_READ) {
 		/* If this page is not uninitialized and not in the
-		doublewrite buffer, then the page number should be the
-		same as in block */
+		doublewrite buffer, then the page number and space id
+		should be the same as in block. */
+		ulint	read_page_no = mach_read_from_4(
+			block->frame + FIL_PAGE_OFFSET);
+		ulint	read_space_id = mach_read_from_4(
+			block->frame + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
 
-		read_page_no = mach_read_from_4((block->frame)
-						+ FIL_PAGE_OFFSET);
-		if (read_page_no != 0
-			&& !trx_doublewrite_page_inside(read_page_no)
-	    		&& read_page_no != block->offset) {
+		if (!block->space
+		    && trx_doublewrite_page_inside(block->offset)) {
 
+			ut_print_timestamp(stderr);
 			fprintf(stderr,
-"InnoDB: Error: page n:o stored in the page read in is %lu, should be %lu!\n",
-				(ulong) read_page_no, (ulong) block->offset);
+				"  InnoDB: Error: reading page %lu\n"
+				"InnoDB: which is in the"
+				" doublewrite buffer!\n",
+				(ulong) block->offset);
+		} else if (!read_space_id && !read_page_no) {
+			/* This is likely an uninitialized page. */
+		} else if ((block->space && block->space != read_space_id)
+			   || block->offset != read_page_no) {
+			/* We did not compare space_id to read_space_id
+			if block->space == 0, because the field on the
+			page may contain garbage in MySQL < 4.1.1,
+			which only supported block->space == 0. */
+
+			ut_print_timestamp(stderr);
+			fprintf(stderr,
+				"  InnoDB: Error: space id and page n:o"
+				" stored in the page\n"
+				"InnoDB: read in are %lu:%lu,"
+				" should be %lu:%lu!\n",
+				(ulong) read_space_id, (ulong) read_page_no,
+				(ulong) block->space, (ulong) block->offset);
 		}
 		/* From version 3.23.38 up we store the page checksum
-		   to the 4 first bytes of the page end lsn field */
+		to the 4 first bytes of the page end lsn field */
 
 		if (buf_page_is_corrupted(block->frame)) {
-		  	fprintf(stderr,
-		"InnoDB: Database page corruption on disk or a failed\n"
-		"InnoDB: file read of page %lu.\n", (ulong) block->offset);
-			  
-			fputs(
-		"InnoDB: You may have to recover from a backup.\n", stderr);
+			fprintf(stderr,
+				"InnoDB: Database page corruption on disk"
+				" or a failed\n"
+				"InnoDB: file read of page %lu.\n",
+				(ulong) block->offset);
+
+			fputs("InnoDB: You may have to recover"
+			      " from a backup.\n", stderr);
 
 			buf_page_print(block->frame);
 
-		  	fprintf(stderr,
-		"InnoDB: Database page corruption on disk or a failed\n"
-		"InnoDB: file read of page %lu.\n", (ulong) block->offset);
-			fputs(
-		"InnoDB: You may have to recover from a backup.\n", stderr);
-			fputs(
-		"InnoDB: It is also possible that your operating\n"
-		"InnoDB: system has corrupted its own file cache\n"
-		"InnoDB: and rebooting your computer removes the\n"
-		"InnoDB: error.\n"
-		"InnoDB: If the corrupt page is an index page\n"
-		"InnoDB: you can also try to fix the corruption\n"
-		"InnoDB: by dumping, dropping, and reimporting\n"
-		"InnoDB: the corrupt table. You can use CHECK\n"
-		"InnoDB: TABLE to scan your table for corruption.\n"
-		"InnoDB: See also "
-"InnoDB: http://dev.mysql.com/doc/refman/5.0/en/forcing-recovery.html\n"
-		"InnoDB: about forcing recovery.\n", stderr);
-			  
+			fprintf(stderr,
+				"InnoDB: Database page corruption on disk"
+				" or a failed\n"
+				"InnoDB: file read of page %lu.\n",
+				(ulong) block->offset);
+			fputs("InnoDB: You may have to recover"
+			      " from a backup.\n", stderr);
+			fputs("InnoDB: It is also possible that"
+			      " your operating\n"
+			      "InnoDB: system has corrupted its"
+			      " own file cache\n"
+			      "InnoDB: and rebooting your computer"
+			      " removes the\n"
+			      "InnoDB: error.\n"
+			      "InnoDB: If the corrupt page is an index page\n"
+			      "InnoDB: you can also try to"
+			      " fix the corruption\n"
+			      "InnoDB: by dumping, dropping,"
+			      " and reimporting\n"
+			      "InnoDB: the corrupt table."
+			      " You can use CHECK\n"
+			      "InnoDB: TABLE to scan your"
+			      " table for corruption.\n"
+			      "InnoDB: See also"
+			      " http://dev.mysql.com/doc/refman/5.1/en/"
+			      "forcing-recovery.html\n"
+			      "InnoDB: about forcing recovery.\n", stderr);
+
 			if (srv_force_recovery < SRV_FORCE_IGNORE_CORRUPT) {
-				fputs(
-	"InnoDB: Ending processing because of a corrupt database page.\n",
-					stderr);
-		  		exit(1);
-		  	}
+				fputs("InnoDB: Ending processing because of"
+				      " a corrupt database page.\n",
+				      stderr);
+				exit(1);
+			}
 		}
 
 		if (recv_recovery_is_on()) {
 			recv_recover_page(FALSE, TRUE, block->frame,
-						block->space, block->offset);
+					  block->space, block->offset);
 		}
 
 		if (!recv_no_ibuf_operations) {
-			ibuf_merge_or_delete_for_page(block->frame,
-					block->space, block->offset, TRUE);
+			ibuf_merge_or_delete_for_page(
+				block->frame, block->space, block->offset,
+				TRUE);
 		}
 	}
-	
+
 	mutex_enter(&(buf_pool->mutex));
 	mutex_enter(&block->mutex);
 
@@ -1954,12 +2049,12 @@
 	id. */
 
 	block->io_fix = 0;
-	
+
 	if (io_type == BUF_IO_READ) {
 		/* NOTE that the call to ibuf may have moved the ownership of
 		the x-latch to this OS thread: do not let this confuse you in
-		debugging! */		
-	
+		debugging! */
+
 		ut_ad(buf_pool->n_pend_reads > 0);
 		buf_pool->n_pend_reads--;
 		buf_pool->n_pages_read++;
@@ -1989,7 +2084,7 @@
 		}
 #endif /* UNIV_DEBUG */
 	}
-	
+
 	mutex_exit(&block->mutex);
 	mutex_exit(&(buf_pool->mutex));
 
@@ -2013,13 +2108,13 @@
 	ibool	freed;
 
 	ut_ad(buf_all_freed());
-	
+
 	freed = TRUE;
 
 	while (freed) {
 		freed = buf_LRU_search_and_free_block(100);
 	}
-	
+
 	mutex_enter(&(buf_pool->mutex));
 
 	ut_ad(UT_LIST_GET_LEN(buf_pool->LRU) == 0);
@@ -2044,7 +2139,7 @@
 	ulint		n_flush		= 0;
 	ulint		n_free		= 0;
 	ulint		n_page		= 0;
-	
+
 	ut_ad(buf_pool);
 
 	mutex_enter(&(buf_pool->mutex));
@@ -2058,25 +2153,26 @@
 		if (block->state == BUF_BLOCK_FILE_PAGE) {
 
 			ut_a(buf_page_hash_get(block->space,
-						block->offset) == block);
+					       block->offset) == block);
 			n_page++;
 
 #ifdef UNIV_IBUF_DEBUG
 			ut_a((block->io_fix == BUF_IO_READ)
 			     || ibuf_count_get(block->space, block->offset)
-								== 0);
+			     == 0);
 #endif
 			if (block->io_fix == BUF_IO_WRITE) {
 
 				if (block->flush_type == BUF_FLUSH_LRU) {
 					n_lru_flush++;
-					ut_a(rw_lock_is_locked(&(block->lock),
-							RW_LOCK_SHARED));
-				} else if (block->flush_type ==
-						BUF_FLUSH_LIST) {
+					ut_a(rw_lock_is_locked(
+						     &block->lock,
+						     RW_LOCK_SHARED));
+				} else if (block->flush_type
+					   == BUF_FLUSH_LIST) {
 					n_list_flush++;
-				} else if (block->flush_type ==
-						BUF_FLUSH_SINGLE_PAGE) {
+				} else if (block->flush_type
+					   == BUF_FLUSH_SINGLE_PAGE) {
 					n_single_flush++;
 				} else {
 					ut_error;
@@ -2085,32 +2181,34 @@
 			} else if (block->io_fix == BUF_IO_READ) {
 
 				ut_a(rw_lock_is_locked(&(block->lock),
-							RW_LOCK_EX));
+						       RW_LOCK_EX));
 			}
-			
+
 			n_lru++;
 
 			if (ut_dulint_cmp(block->oldest_modification,
-						ut_dulint_zero) > 0) {
-					n_flush++;
-			}	
-		
+					  ut_dulint_zero) > 0) {
+				n_flush++;
+			}
+
 		} else if (block->state == BUF_BLOCK_NOT_USED) {
 			n_free++;
 		}
 
 		mutex_exit(&block->mutex);
- 	}
+	}
 
 	if (n_lru + n_free > buf_pool->curr_size) {
-		fprintf(stderr, "n LRU %lu, n free %lu\n", (ulong) n_lru, (ulong) n_free);
+		fprintf(stderr, "n LRU %lu, n free %lu\n",
+			(ulong) n_lru, (ulong) n_free);
 		ut_error;
 	}
 
 	ut_a(UT_LIST_GET_LEN(buf_pool->LRU) == n_lru);
 	if (UT_LIST_GET_LEN(buf_pool->free) != n_free) {
 		fprintf(stderr, "Free list len %lu, free blocks %lu\n",
-			(ulong) UT_LIST_GET_LEN(buf_pool->free), (ulong) n_free);
+			(ulong) UT_LIST_GET_LEN(buf_pool->free),
+			(ulong) n_free);
 		ut_error;
 	}
 	ut_a(UT_LIST_GET_LEN(buf_pool->flush_list) == n_flush);
@@ -2118,14 +2216,14 @@
 	ut_a(buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE] == n_single_flush);
 	ut_a(buf_pool->n_flush[BUF_FLUSH_LIST] == n_list_flush);
 	ut_a(buf_pool->n_flush[BUF_FLUSH_LRU] == n_lru_flush);
-	
+
 	mutex_exit(&(buf_pool->mutex));
 
 	ut_a(buf_LRU_validate());
 	ut_a(buf_flush_validate());
 
 	return(TRUE);
-}	
+}
 
 /*************************************************************************
 Prints info of the buffer buf_pool data structure. */
@@ -2141,9 +2239,9 @@
 	ulint		j;
 	dulint		id;
 	ulint		n_found;
-	buf_frame_t* 	frame;
+	buf_frame_t*	frame;
 	dict_index_t*	index;
-	
+
 	ut_ad(buf_pool);
 
 	size = buf_pool->curr_size;
@@ -2152,7 +2250,7 @@
 	counts = mem_alloc(sizeof(ulint) * size);
 
 	mutex_enter(&(buf_pool->mutex));
-	
+
 	fprintf(stderr,
 		"buf_pool size %lu\n"
 		"database pages %lu\n"
@@ -2173,7 +2271,7 @@
 		(ulong) buf_pool->n_pages_written);
 
 	/* Count the number of blocks belonging to each index in the buffer */
-	
+
 	n_found = 0;
 
 	for (i = 0; i < size; i++) {
@@ -2211,8 +2309,8 @@
 
 		fprintf(stderr,
 			"Block count for index %lu in buffer is about %lu",
-		       (ulong) ut_dulint_get_low(index_ids[i]),
-		       (ulong) counts[i]);
+			(ulong) ut_dulint_get_low(index_ids[i]),
+			(ulong) counts[i]);
 
 		if (index) {
 			putc(' ', stderr);
@@ -2221,12 +2319,12 @@
 
 		putc('\n', stderr);
 	}
-	
+
 	mem_free(index_ids);
 	mem_free(counts);
 
 	ut_a(buf_validate());
-}	
+}
 #endif /* UNIV_DEBUG */
 
 /*************************************************************************
@@ -2235,13 +2333,13 @@
 ulint
 buf_get_latched_pages_number(void)
 {
-        buf_block_t* block;
-        ulint i;
-        ulint fixed_pages_number = 0;
+	buf_block_t*	block;
+	ulint		i;
+	ulint		fixed_pages_number = 0;
 
-        mutex_enter(&(buf_pool->mutex));
+	mutex_enter(&(buf_pool->mutex));
 
-        for (i = 0; i < buf_pool->curr_size; i++) {
+	for (i = 0; i < buf_pool->curr_size; i++) {
 
 		block = buf_pool_get_nth_block(buf_pool, i);
 
@@ -2254,10 +2352,11 @@
 
 			mutex_exit(&block->mutex);
 		}
-        }
+	}
+
+	mutex_exit(&(buf_pool->mutex));
 
-        mutex_exit(&(buf_pool->mutex));
-        return fixed_pages_number;
+	return(fixed_pages_number);
 }
 
 /*************************************************************************
@@ -2268,9 +2367,9 @@
 /*=======================*/
 {
 	return(buf_pool->n_pend_reads
-		+ buf_pool->n_flush[BUF_FLUSH_LRU]
-		+ buf_pool->n_flush[BUF_FLUSH_LIST]
-		+ buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE]);
+	       + buf_pool->n_flush[BUF_FLUSH_LRU]
+	       + buf_pool->n_flush[BUF_FLUSH_LIST]
+	       + buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE]);
 }
 
 /*************************************************************************
@@ -2286,10 +2385,10 @@
 	mutex_enter(&(buf_pool->mutex));
 
 	ratio = (100 * UT_LIST_GET_LEN(buf_pool->flush_list))
-		     / (1 + UT_LIST_GET_LEN(buf_pool->LRU)
-		        + UT_LIST_GET_LEN(buf_pool->free));
+		/ (1 + UT_LIST_GET_LEN(buf_pool->LRU)
+		   + UT_LIST_GET_LEN(buf_pool->free));
 
-		       /* 1 + is there to avoid division by zero */   
+	/* 1 + is there to avoid division by zero */
 
 	mutex_exit(&(buf_pool->mutex));
 
@@ -2307,20 +2406,22 @@
 	time_t	current_time;
 	double	time_elapsed;
 	ulint	size;
-	
+
 	ut_ad(buf_pool);
 	size = buf_pool->curr_size;
 
 	mutex_enter(&(buf_pool->mutex));
-	
+
 	if (srv_use_awe) {
 		fprintf(stderr,
-		"AWE: Buffer pool memory frames                        %lu\n",
-				(ulong) buf_pool->n_frames);
-		
+			"AWE: Buffer pool memory frames %lu\n",
+			(ulong) buf_pool->n_frames);
+
 		fprintf(stderr,
-		"AWE: Database pages and free buffers mapped in frames %lu\n",
-				(ulong) UT_LIST_GET_LEN(buf_pool->awe_LRU_free_mapped));
+			"AWE: Database pages and free buffers"
+			" mapped in frames %lu\n",
+			(ulong)
+			UT_LIST_GET_LEN(buf_pool->awe_LRU_free_mapped));
 	}
 	fprintf(file,
 		"Buffer pool size   %lu\n"
@@ -2335,14 +2436,14 @@
 		(ulong) UT_LIST_GET_LEN(buf_pool->flush_list),
 		(ulong) buf_pool->n_pend_reads,
 		(ulong) buf_pool->n_flush[BUF_FLUSH_LRU]
-			+ buf_pool->init_flush[BUF_FLUSH_LRU],
+		+ buf_pool->init_flush[BUF_FLUSH_LRU],
 		(ulong) buf_pool->n_flush[BUF_FLUSH_LIST]
-			+ buf_pool->init_flush[BUF_FLUSH_LIST],
+		+ buf_pool->init_flush[BUF_FLUSH_LIST],
 		(ulong) buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE]);
 
 	current_time = time(NULL);
 	time_elapsed = 0.001 + difftime(current_time,
-						buf_pool->last_printout_time);
+					buf_pool->last_printout_time);
 	buf_pool->last_printout_time = current_time;
 
 	fprintf(file,
@@ -2360,20 +2461,21 @@
 
 	if (srv_use_awe) {
 		fprintf(file, "AWE: %.2f page remaps/s\n",
-		(buf_pool->n_pages_awe_remapped
-				- buf_pool->n_pages_awe_remapped_old)
+			(buf_pool->n_pages_awe_remapped
+			 - buf_pool->n_pages_awe_remapped_old)
 			/ time_elapsed);
 	}
-		
+
 	if (buf_pool->n_page_gets > buf_pool->n_page_gets_old) {
 		fprintf(file, "Buffer pool hit rate %lu / 1000\n",
-       (ulong) (1000
-		- ((1000 *
-		    (buf_pool->n_pages_read - buf_pool->n_pages_read_old))
-		/ (buf_pool->n_page_gets - buf_pool->n_page_gets_old))));
+			(ulong)
+			(1000 - ((1000 * (buf_pool->n_pages_read
+					  - buf_pool->n_pages_read_old))
+				 / (buf_pool->n_page_gets
+				    - buf_pool->n_page_gets_old))));
 	} else {
 		fputs("No buffer pool page gets since the last printout\n",
-			file);
+		      file);
 	}
 
 	buf_pool->n_page_gets_old = buf_pool->n_page_gets;
@@ -2392,12 +2494,12 @@
 buf_refresh_io_stats(void)
 /*======================*/
 {
-        buf_pool->last_printout_time = time(NULL);
+	buf_pool->last_printout_time = time(NULL);
 	buf_pool->n_page_gets_old = buf_pool->n_page_gets;
 	buf_pool->n_pages_read_old = buf_pool->n_pages_read;
 	buf_pool->n_pages_created_old = buf_pool->n_pages_created;
 	buf_pool->n_pages_written_old = buf_pool->n_pages_written;
-	buf_pool->n_pages_awe_remapped_old = buf_pool->n_pages_awe_remapped; 
+	buf_pool->n_pages_awe_remapped_old = buf_pool->n_pages_awe_remapped;
 }
 
 /*************************************************************************
@@ -2409,7 +2511,7 @@
 {
 	buf_block_t*	block;
 	ulint		i;
-	
+
 	ut_ad(buf_pool);
 
 	mutex_enter(&(buf_pool->mutex));
@@ -2428,17 +2530,17 @@
 					"Page %lu %lu still fixed or dirty\n",
 					(ulong) block->space,
 					(ulong) block->offset);
-			    	ut_error;
+				ut_error;
 			}
 		}
 
 		mutex_exit(&block->mutex);
- 	}
+	}
 
 	mutex_exit(&(buf_pool->mutex));
 
 	return(TRUE);
-}	
+}
 
 /*************************************************************************
 Checks that there currently are no pending i/o-operations for the buffer
@@ -2454,8 +2556,8 @@
 	mutex_enter(&(buf_pool->mutex));
 
 	if (buf_pool->n_pend_reads + buf_pool->n_flush[BUF_FLUSH_LRU]
-				+ buf_pool->n_flush[BUF_FLUSH_LIST]
-				+ buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE]) {
+	    + buf_pool->n_flush[BUF_FLUSH_LIST]
+	    + buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE]) {
 		ret = FALSE;
 	} else {
 		ret = TRUE;

--- 1.65.17.1/innobase/dict/dict0dict.c	2006-12-21 23:54:44 +01:00
+++ 1.95/storage/innobase/dict/dict0dict.c	2006-12-21 23:54:44 +01:00
@@ -26,9 +26,9 @@
 #include "pars0sym.h"
 #include "que0que.h"
 #include "rem0cmp.h"
-
-/* Implement isspace() in a locale-independent way. (Bug #24299) */
-#define ib_isspace(c) strchr(" \v\f\t\r\n", c)
+#ifndef UNIV_HOTBACKUP
+# include "m_ctype.h" /* my_isspace() */
+#endif /* !UNIV_HOTBACKUP */
 
 dict_sys_t*	dict_sys	= NULL;	/* the dictionary system */
 
@@ -48,8 +48,6 @@
 					creating a table or index object */
 #define DICT_POOL_PER_TABLE_HASH 512	/* buffer pool max size per table
 					hash table fixed size in bytes */
-#define DICT_POOL_PER_COL_HASH	128	/* buffer pool max size per column
-					hash table fixed size in bytes */
 #define DICT_POOL_PER_VARYING	4	/* buffer pool max size per data
 					dictionary varying size in bytes */
 
@@ -58,6 +56,42 @@
 
 #ifndef UNIV_HOTBACKUP
 /**********************************************************************
+Converts an identifier to a table name.
+
+NOTE: the prototype of this function is copied from ha_innodb.cc! If you change
+this function, you MUST change also the prototype here! */
+extern
+void
+innobase_convert_from_table_id(
+/*===========================*/
+	char*		to,	/* out: converted identifier */
+	const char*	from,	/* in: identifier to convert */
+	ulint		len);	/* in: length of 'to', in bytes;
+				should be at least 5 * strlen(to) + 1 */
+/**********************************************************************
+Converts an identifier to UTF-8.
+
+NOTE: the prototype of this function is copied from ha_innodb.cc! If you change
+this function, you MUST change also the prototype here! */
+extern
+void
+innobase_convert_from_id(
+/*=====================*/
+	char*		to,	/* out: converted identifier */
+	const char*	from,	/* in: identifier to convert */
+	ulint		len);	/* in: length of 'to', in bytes;
+				should be at least 3 * strlen(to) + 1 */
+/**********************************************************************
+Removes the filename encoding of a table or database name.
+
+NOTE: the prototype of this function is copied from ha_innodb.cc! If you change
+this function, you MUST change also the prototype here! */
+extern
+void
+innobase_convert_from_filename(
+/*===========================*/
+	char*		s);	/* in: identifier; out: decoded identifier */
+/**********************************************************************
 Compares NUL-terminated UTF-8 strings case insensitively.
 
 NOTE: the prototype of this function is copied from ha_innodb.cc! If you change
@@ -80,34 +114,19 @@
 innobase_casedn_str(
 /*================*/
 	char*	a);	/* in/out: string to put in lower case */
-#endif /* !UNIV_HOTBACKUP */
 
 /**************************************************************************
-Adds a column to the data dictionary hash table. */
-static
-void
-dict_col_add_to_cache(
-/*==================*/
-	dict_table_t*	table,	/* in: table */
-	dict_col_t*	col);	/* in: column */
-/**************************************************************************
-Repositions a column in the data dictionary hash table when the table name
-changes. */
-static
-void
-dict_col_reposition_in_cache(
-/*=========================*/
-	dict_table_t*	table,		/* in: table */
-	dict_col_t*	col,		/* in: column */
-	const char*	new_name);	/* in: new table name */
-/**************************************************************************
-Removes a column from the data dictionary hash table. */
-static
-void
-dict_col_remove_from_cache(
-/*=======================*/
-	dict_table_t*	table,	/* in: table */
-	dict_col_t*	col);	/* in: column */
+Determines the connection character set.
+
+NOTE: the prototype of this function is copied from ha_innodb.cc! If you change
+this function, you MUST change also the prototype here! */
+struct charset_info_st*
+innobase_get_charset(
+/*=================*/
+				/* out: connection character set */
+	void*	mysql_thd);	/* in: MySQL thread handle */
+#endif /* !UNIV_HOTBACKUP */
+
 /**************************************************************************
 Removes an index from the dictionary cache. */
 static
@@ -124,18 +143,18 @@
 /*============*/
 	dict_index_t*	index1,	/* in: index to copy to */
 	dict_index_t*	index2,	/* in: index to copy from */
+	dict_table_t*	table,	/* in: table */
 	ulint		start,	/* in: first position to copy */
 	ulint		end);	/* in: last position to copy */
 /***********************************************************************
-Tries to find column names for the index in the column hash table and
-sets the col field of the index. */
+Tries to find column names for the index and sets the col field of the
+index. */
 static
-ibool
+void
 dict_index_find_cols(
 /*=================*/
-				/* out: TRUE if success */
 	dict_table_t*	table,	/* in: table */
-	dict_index_t*	index);	/* in: index */	
+	dict_index_t*	index);	/* in: index */
 /***********************************************************************
 Builds the internal dictionary cache representation for a clustered
 index, containing also system fields not defined by the user. */
@@ -147,7 +166,7 @@
 				of the clustered index */
 	dict_table_t*	table,	/* in: table */
 	dict_index_t*	index);	/* in: user representation of a clustered
-				index */	
+				index */
 /***********************************************************************
 Builds the internal dictionary cache representation for a non-clustered
 index, containing also system fields not defined by the user. */
@@ -159,7 +178,7 @@
 				of the non-clustered index */
 	dict_table_t*	table,	/* in: table */
 	dict_index_t*	index);	/* in: user representation of a non-clustered
-				index */	
+				index */
 /**************************************************************************
 Removes a foreign constraint struct from the dictionary cache. */
 static
@@ -173,7 +192,8 @@
 void
 dict_col_print_low(
 /*===============*/
-	dict_col_t*	col);	/* in: column */
+	const dict_table_t*	table,	/* in: table */
+	const dict_col_t*	col);	/* in: column */
 /**************************************************************************
 Prints an index data. */
 static
@@ -199,9 +219,10 @@
 /* Stream for storing detailed information about the latest foreign key
 and unique key errors */
 FILE*	dict_foreign_err_file		= NULL;
-mutex_t	dict_foreign_err_mutex; 	/* mutex protecting the foreign
+mutex_t	dict_foreign_err_mutex;		/* mutex protecting the foreign
 					and unique error buffers */
-	
+
+#ifndef UNIV_HOTBACKUP
 /**********************************************************************
 Makes all characters in a NUL-terminated UTF-8 string lower case. */
 
@@ -212,6 +233,7 @@
 {
 	innobase_casedn_str(a);
 }
+#endif /* !UNIV_HOTBACKUP */
 
 /************************************************************************
 Checks if the database name in two table names is the same. */
@@ -236,7 +258,7 @@
 
 /************************************************************************
 Return the end of table name where we have removed dbname and '/'. */
-static
+
 const char*
 dict_remove_db_name(
 /*================*/
@@ -244,11 +266,10 @@
 	const char*	name)	/* in: table name in the form
 				dbname '/' tablename */
 {
-	const char*	s;
-	s = strchr(name, '/');
+	const char*	s = strchr(name, '/');
 	ut_a(s);
-	if (s) s++;
-	return(s);
+
+	return(s + 1);
 }
 
 /************************************************************************
@@ -266,7 +287,7 @@
 	ut_a(s);
 	return(s - name);
 }
-	
+
 /************************************************************************
 Reserves the dictionary system mutex for MySQL. */
 
@@ -276,7 +297,7 @@
 {
 	mutex_enter(&(dict_sys->mutex));
 }
-	
+
 /************************************************************************
 Releases the dictionary system mutex for MySQL. */
 
@@ -286,7 +307,7 @@
 {
 	mutex_exit(&(dict_sys->mutex));
 }
-	
+
 /************************************************************************
 Decrements the count of open MySQL handles to a table. */
 
@@ -300,19 +321,31 @@
 	ut_a(table->n_mysql_handles_opened > 0);
 
 	table->n_mysql_handles_opened--;
-	
+
 	mutex_exit(&(dict_sys->mutex));
 }
 
+/*************************************************************************
+Gets the column data type. */
+
+void
+dict_col_copy_type_noninline(
+/*=========================*/
+	const dict_col_t*	col,	/* in: column */
+	dtype_t*		type)	/* out: data type */
+{
+	dict_col_copy_type(col, type);
+}
+
 /************************************************************************
 Gets the nth column of a table. */
 
-dict_col_t*
+const dict_col_t*
 dict_table_get_nth_col_noninline(
 /*=============================*/
-				/* out: pointer to column object */
-	dict_table_t*	table,	/* in: table */
-	ulint		pos)	/* in: position of column */
+					/* out: pointer to column object */
+	const dict_table_t*	table,	/* in: table */
+	ulint			pos)	/* in: position of column */
 {
 	return(dict_table_get_nth_col(table, pos));
 }
@@ -353,7 +386,36 @@
 {
 	return(dict_table_get_index(table, name));
 }
-	
+
+/**************************************************************************
+Returns a column's name. */
+
+const char*
+dict_table_get_col_name(
+/*====================*/
+					/* out: column name. NOTE: not
+					guaranteed to stay valid if table is
+					modified in any way (columns added,
+					etc.). */
+	const dict_table_t*	table,	/* in: table */
+	ulint			col_nr)	/* in: column number */
+{
+	ulint		i;
+	const char*	s;
+
+	ut_ad(table);
+	ut_ad(col_nr < table->n_def);
+	ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
+
+	s = table->col_names;
+
+	for (i = 0; i < col_nr; i++) {
+		s += strlen(s) + 1;
+	}
+
+	return(s);
+}
+
 /************************************************************************
 Initializes the autoinc counter. It is not an error to initialize an already
 initialized counter. */
@@ -393,7 +455,7 @@
 		value = table->autoinc;
 		table->autoinc = table->autoinc + 1;
 	}
-	
+
 	mutex_exit(&(table->autoinc_mutex));
 
 	return(value);
@@ -410,7 +472,7 @@
 	mutex_enter(&(table->autoinc_mutex));
 
 	table->autoinc = table->autoinc - 1;
-	
+
 	mutex_exit(&(table->autoinc_mutex));
 }
 
@@ -434,7 +496,7 @@
 	} else {
 		value = table->autoinc;
 	}
-	
+
 	mutex_exit(&(table->autoinc_mutex));
 
 	return(value);
@@ -479,7 +541,7 @@
 		if (value >= table->autoinc) {
 			table->autoinc = value + 1;
 		}
-	}	
+	}
 
 	mutex_exit(&(table->autoinc_mutex));
 }
@@ -496,11 +558,11 @@
 	dict_index_t*	index,	/* in: index */
 	ulint		n)	/* in: column number */
 {
-	dict_field_t*	field;
-	dict_col_t*	col;
-	ulint		pos;
-	ulint		n_fields;
-	
+	const dict_field_t*	field;
+	const dict_col_t*	col;
+	ulint			pos;
+	ulint			n_fields;
+
 	ut_ad(index);
 	ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
 
@@ -508,11 +570,11 @@
 
 	if (index->type & DICT_CLUSTERED) {
 
-		return(col->clust_pos);
+		return(dict_col_get_clust_pos(col, index));
 	}
 
 	n_fields = dict_index_get_n_fields(index);
-	
+
 	for (pos = 0; pos < n_fields; pos++) {
 		field = dict_index_get_nth_field(index, pos);
 
@@ -536,11 +598,11 @@
 	dict_index_t*	index,	/* in: index */
 	ulint		n)	/* in: column number */
 {
-	dict_field_t*	field;
-	dict_col_t*	col;
-	ulint		pos;
-	ulint		n_fields;
-	
+	const dict_field_t*	field;
+	const dict_col_t*	col;
+	ulint			pos;
+	ulint			n_fields;
+
 	ut_ad(index);
 	ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
 
@@ -552,7 +614,7 @@
 	col = dict_table_get_nth_col(index->table, n);
 
 	n_fields = dict_index_get_n_fields(index);
-	
+
 	for (pos = 0; pos < n_fields; pos++) {
 		field = dict_index_get_nth_field(index, pos);
 
@@ -585,14 +647,14 @@
 	dict_field_t*	field2;
 	ulint		n_fields;
 	ulint		pos;
-	
+
 	ut_ad(index);
 	ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
 
 	field2 = dict_index_get_nth_field(index2, n);
 
 	n_fields = dict_index_get_n_fields(index);
-	
+
 	for (pos = 0; pos < n_fields; pos++) {
 		field = dict_index_get_nth_field(index, pos);
 
@@ -609,7 +671,7 @@
 }
 
 /**************************************************************************
-Returns a table object, based on table id, and memoryfixes it. */
+Returns a table object based on table id. */
 
 dict_table_t*
 dict_table_get_on_id(
@@ -619,9 +681,9 @@
 	trx_t*	trx)		/* in: transaction handle */
 {
 	dict_table_t*	table;
-	
+
 	if (ut_dulint_cmp(table_id, DICT_FIELDS_ID) <= 0
-	   || trx->dict_operation_lock_mode == RW_X_LATCH) {
+	    || trx->dict_operation_lock_mode == RW_X_LATCH) {
 		/* It is a system table which will always exist in the table
 		cache: we avoid acquiring the dictionary mutex, because
 		if we are doing a rollback to handle an error in TABLE
@@ -631,13 +693,13 @@
 		ut_ad(mutex_own(&(dict_sys->mutex)));
 #endif /* UNIV_SYNC_DEBUG */
 
-		return(dict_table_get_on_id_low(table_id, trx));
+		return(dict_table_get_on_id_low(table_id));
 	}
 
 	mutex_enter(&(dict_sys->mutex));
 
-	table = dict_table_get_on_id_low(table_id, trx);
-	
+	table = dict_table_get_on_id_low(table_id);
+
 	mutex_exit(&(dict_sys->mutex));
 
 	return(table);
@@ -655,7 +717,20 @@
 	ulint		n)	/* in: column number */
 {
 	return(dict_index_get_nth_col_pos(dict_table_get_first_index(table),
-								n));
+					  n));
+}
+
+/************************************************************************
+Check whether the table uses the compact page format. */
+
+ibool
+dict_table_is_comp_noninline(
+/*=========================*/
+					/* out: TRUE if table uses the
+					compact page format */
+	const dict_table_t*	table)	/* in: table */
+{
+	return(dict_table_is_comp(table));
 }
 
 /************************************************************************
@@ -670,12 +745,12 @@
 	dict_table_t*	table,	/* in: table */
 	ulint		n)	/* in: column number */
 {
-	dict_index_t*	index;
-	dict_field_t*	field;
-	dict_col_t*	col;
-	ulint		pos;
-	ulint		n_fields;
-	
+	dict_index_t*		index;
+	const dict_field_t*	field;
+	const dict_col_t*	col;
+	ulint			pos;
+	ulint			n_fields;
+
 	ut_ad(table);
 
 	col = dict_table_get_nth_col(table, n);
@@ -683,7 +758,7 @@
 	index = dict_table_get_first_index(table);
 
 	n_fields = dict_index_get_n_unique(index);
-	
+
 	for (pos = 0; pos < n_fields; pos++) {
 		field = dict_index_get_nth_field(index, pos);
 
@@ -705,60 +780,52 @@
 {
 	dict_sys = mem_alloc(sizeof(dict_sys_t));
 
-	mutex_create(&(dict_sys->mutex));
-	mutex_set_level(&(dict_sys->mutex), SYNC_DICT);
+	mutex_create(&dict_sys->mutex, SYNC_DICT);
 
-	dict_sys->table_hash = hash0_create(buf_pool_get_max_size() /
-					(DICT_POOL_PER_TABLE_HASH *
-					UNIV_WORD_SIZE));
-	dict_sys->table_id_hash = hash0_create(buf_pool_get_max_size() /
-					(DICT_POOL_PER_TABLE_HASH *
-					UNIV_WORD_SIZE));
-	dict_sys->col_hash = hash0_create(buf_pool_get_max_size() /
-					(DICT_POOL_PER_COL_HASH *
-					UNIV_WORD_SIZE));
+	dict_sys->table_hash = hash0_create(buf_pool_get_max_size()
+					   / (DICT_POOL_PER_TABLE_HASH
+					      * UNIV_WORD_SIZE));
+	dict_sys->table_id_hash = hash0_create(buf_pool_get_max_size()
+					      / (DICT_POOL_PER_TABLE_HASH
+						 * UNIV_WORD_SIZE));
 	dict_sys->size = 0;
 
 	UT_LIST_INIT(dict_sys->table_LRU);
 
-	rw_lock_create(&dict_operation_lock);
-	rw_lock_set_level(&dict_operation_lock, SYNC_DICT_OPERATION);
+	rw_lock_create(&dict_operation_lock, SYNC_DICT_OPERATION);
 
 	dict_foreign_err_file = os_file_create_tmpfile();
 	ut_a(dict_foreign_err_file);
-	mutex_create(&dict_foreign_err_mutex);
-	mutex_set_level(&dict_foreign_err_mutex, SYNC_ANY_LATCH);
+
+	mutex_create(&dict_foreign_err_mutex, SYNC_ANY_LATCH);
 }
 
 /**************************************************************************
-Returns a table object and memoryfixes it. NOTE! This is a high-level
-function to be used mainly from outside the 'dict' directory. Inside this
-directory dict_table_get_low is usually the appropriate function. */
+Returns a table object. NOTE! This is a high-level function to be used
+mainly from outside the 'dict' directory. Inside this directory
+dict_table_get_low is usually the appropriate function. */
 
 dict_table_t*
 dict_table_get(
 /*===========*/
 					/* out: table, NULL if
 					does not exist */
-	const char*	table_name,	/* in: table name */
-	trx_t*		trx)		/* in: transaction handle or NULL */
+	const char*	table_name)	/* in: table name */
 {
 	dict_table_t*	table;
 
-	UT_NOT_USED(trx);
-
 	mutex_enter(&(dict_sys->mutex));
-	
+
 	table = dict_table_get_low(table_name);
 
 	mutex_exit(&(dict_sys->mutex));
 
 	if (table != NULL) {
-	        if (!table->stat_initialized) {
+		if (!table->stat_initialized) {
 			dict_update_statistics(table);
 		}
 	}
-	
+
 	return(table);
 }
 
@@ -770,30 +837,27 @@
 /*======================================*/
 					/* out: table, NULL if
 					does not exist */
-	const char*	table_name,	/* in: table name */
-	trx_t*		trx)		/* in: transaction handle or NULL */
+	const char*	table_name)	/* in: table name */
 {
 	dict_table_t*	table;
 
-	UT_NOT_USED(trx);
-
 	mutex_enter(&(dict_sys->mutex));
-	
+
 	table = dict_table_get_low(table_name);
 
 	if (table != NULL) {
 
-	        table->n_mysql_handles_opened++;
+		table->n_mysql_handles_opened++;
 	}
 
 	mutex_exit(&(dict_sys->mutex));
 
 	if (table != NULL) {
-	        if (!table->stat_initialized && !table->ibd_file_missing) {
+		if (!table->stat_initialized && !table->ibd_file_missing) {
 			dict_update_statistics(table);
 		}
 	}
-	
+
 	return(table);
 }
 
@@ -808,7 +872,8 @@
 	ulint	fold;
 	ulint	id_fold;
 	ulint	i;
-	
+	ulint	row_len;
+
 	ut_ad(table);
 #ifdef UNIV_SYNC_DEBUG
 	ut_ad(mutex_own(&(dict_sys->mutex)));
@@ -816,12 +881,12 @@
 	ut_ad(table->n_def == table->n_cols - DATA_N_SYS_COLS);
 	ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
 	ut_ad(table->cached == FALSE);
-	
+
 	fold = ut_fold_string(table->name);
 	id_fold = ut_fold_dulint(table->id);
-	
+
 	table->cached = TRUE;
-	
+
 	/* NOTE: the system columns MUST be added in the following order
 	(so that they can be indexed by the numerical value of DATA_ROW_ID,
 	etc.) and as the last columns of the table memory object.
@@ -829,37 +894,56 @@
 	system columns. */
 
 	dict_mem_table_add_col(table, "DB_ROW_ID", DATA_SYS,
-			DATA_ROW_ID | DATA_NOT_NULL, DATA_ROW_ID_LEN, 0);
+			       DATA_ROW_ID | DATA_NOT_NULL,
+			       DATA_ROW_ID_LEN);
 #if DATA_ROW_ID != 0
 #error "DATA_ROW_ID != 0"
 #endif
 	dict_mem_table_add_col(table, "DB_TRX_ID", DATA_SYS,
-			DATA_TRX_ID | DATA_NOT_NULL, DATA_TRX_ID_LEN, 0);
+			       DATA_TRX_ID | DATA_NOT_NULL,
+			       DATA_TRX_ID_LEN);
 #if DATA_TRX_ID != 1
 #error "DATA_TRX_ID != 1"
 #endif
 	dict_mem_table_add_col(table, "DB_ROLL_PTR", DATA_SYS,
-			DATA_ROLL_PTR | DATA_NOT_NULL, DATA_ROLL_PTR_LEN, 0);
+			       DATA_ROLL_PTR | DATA_NOT_NULL,
+			       DATA_ROLL_PTR_LEN);
 #if DATA_ROLL_PTR != 2
 #error "DATA_ROLL_PTR != 2"
 #endif
-	dict_mem_table_add_col(table, "DB_MIX_ID", DATA_SYS,
-			DATA_MIX_ID | DATA_NOT_NULL, DATA_MIX_ID_LEN, 0);
-#if DATA_MIX_ID != 3
-#error "DATA_MIX_ID != 3"
-#endif
 
 	/* This check reminds that if a new system column is added to
-	the program, it should be dealt with here */ 
-#if DATA_N_SYS_COLS != 4
-#error "DATA_N_SYS_COLS != 4"
+	the program, it should be dealt with here */
+#if DATA_N_SYS_COLS != 3
+#error "DATA_N_SYS_COLS != 3"
 #endif
 
+	/* The lower limit for what we consider a "big" row */
+#define BIG_ROW_SIZE 1024
+
+	row_len = 0;
+	for (i = 0; i < table->n_def; i++) {
+		ulint	col_len = dict_col_get_max_size(
+			dict_table_get_nth_col(table, i));
+
+		row_len += col_len;
+
+		/* If we have a single unbounded field, or several gigantic
+		fields, mark the maximum row size as BIG_ROW_SIZE. */
+		if (row_len >= BIG_ROW_SIZE || col_len >= BIG_ROW_SIZE) {
+			row_len = BIG_ROW_SIZE;
+
+			break;
+		}
+	}
+
+	table->big_rows = row_len >= BIG_ROW_SIZE;
+
 	/* Look for a table with the same name: error if such exists */
 	{
 		dict_table_t*	table2;
 		HASH_SEARCH(name_hash, dict_sys->table_hash, fold, table2,
-				(ut_strcmp(table2->name, table->name) == 0));
+			    (ut_strcmp(table2->name, table->name) == 0));
 		ut_a(table2 == NULL);
 	}
 
@@ -867,36 +951,21 @@
 	{
 		dict_table_t*	table2;
 		HASH_SEARCH(id_hash, dict_sys->table_id_hash, id_fold, table2,
-				(ut_dulint_cmp(table2->id, table->id) == 0));
+			    (ut_dulint_cmp(table2->id, table->id) == 0));
 		ut_a(table2 == NULL);
 	}
 
-	if (table->type == DICT_TABLE_CLUSTER_MEMBER) {
-
-		table->mix_id_len = mach_dulint_get_compressed_size(
-								table->mix_id);
-		mach_dulint_write_compressed(table->mix_id_buf, table->mix_id);
-	}
-
-	/* Add the columns to the column hash table */
-	for (i = 0; i < table->n_cols; i++) {
-		dict_col_add_to_cache(table, dict_table_get_nth_col(table, i));
-	}
-
 	/* Add table to hash table of tables */
 	HASH_INSERT(dict_table_t, name_hash, dict_sys->table_hash, fold,
-								   table);
+		    table);
 
 	/* Add table to hash table of tables based on table id */
 	HASH_INSERT(dict_table_t, id_hash, dict_sys->table_id_hash, id_fold,
-								   table);
+		    table);
 	/* Add table to LRU list of tables */
 	UT_LIST_ADD_FIRST(table_LRU, dict_sys->table_LRU, table);
 
-	/* If the dictionary cache grows too big, trim the table LRU list */
-
 	dict_sys->size += mem_heap_get_size(table->heap);
-	/* dict_table_LRU_trim(); */
 }
 
 /**************************************************************************
@@ -912,14 +981,14 @@
 {
 	dict_table_t*	table;
 	dict_index_t*	index;
-	
+
 	table = UT_LIST_GET_FIRST(dict_sys->table_LRU);
 
 	while (table) {
 		index = dict_table_get_first_index(table);
 
 		while (index) {
-			if (0 == ut_dulint_cmp(id, index->tree->id)) {
+			if (0 == ut_dulint_cmp(id, index->id)) {
 				/* Found */
 
 				return(index);
@@ -953,26 +1022,26 @@
 	ulint		old_size;
 	char*		old_name;
 	ibool		success;
-	ulint		i;
-	
+
 	ut_ad(table);
 #ifdef UNIV_SYNC_DEBUG
 	ut_ad(mutex_own(&(dict_sys->mutex)));
 #endif /* UNIV_SYNC_DEBUG */
 
 	old_size = mem_heap_get_size(table->heap);
-	
+
 	fold = ut_fold_string(new_name);
-	
+
 	/* Look for a table with the same name: error if such exists */
 	{
 		dict_table_t*	table2;
 		HASH_SEARCH(name_hash, dict_sys->table_hash, fold, table2,
-				(ut_strcmp(table2->name, new_name) == 0));
+			    (ut_strcmp(table2->name, new_name) == 0));
 		if (table2) {
 			fprintf(stderr,
-"InnoDB: Error: dictionary cache already contains a table of name %s\n",
-	 							     new_name);
+				"InnoDB: Error: dictionary cache"
+				" already contains a table of name %s\n",
+				new_name);
 			return(FALSE);
 		}
 	}
@@ -983,12 +1052,14 @@
 	if (table->space != 0) {
 		if (table->dir_path_of_temp_table != NULL) {
 			fprintf(stderr,
-"InnoDB: Error: trying to rename a table %s (%s) created with CREATE\n"
-"InnoDB: TEMPORARY TABLE\n", table->name, table->dir_path_of_temp_table);
+				"InnoDB: Error: trying to rename a table"
+				" %s (%s) created with CREATE\n"
+				"InnoDB: TEMPORARY TABLE\n",
+				table->name, table->dir_path_of_temp_table);
 			success = FALSE;
 		} else {
-			success = fil_rename_tablespace(table->name,
-						table->space, new_name);
+			success = fil_rename_tablespace(
+				table->name, table->space, new_name);
 		}
 
 		if (!success) {
@@ -997,23 +1068,15 @@
 		}
 	}
 
-	/* Reposition the columns in the column hash table; they are hashed
-	according to the pair (table name, column name) */
-
-	for (i = 0; i < table->n_cols; i++) {
-		dict_col_reposition_in_cache(table,
-				dict_table_get_nth_col(table, i), new_name);
-	}
-
 	/* Remove table from the hash tables of tables */
 	HASH_DELETE(dict_table_t, name_hash, dict_sys->table_hash,
-					ut_fold_string(table->name), table);
+		    ut_fold_string(table->name), table);
 	old_name = mem_heap_strdup(table->heap, table->name);
 	table->name = mem_heap_strdup(table->heap, new_name);
 
 	/* Add table to hash table of tables */
 	HASH_INSERT(dict_table_t, name_hash, dict_sys->table_hash, fold,
-								   table);
+		    table);
 	dict_sys->size += (mem_heap_get_size(table->heap) - old_size);
 
 	/* Update the table_name field in indexes */
@@ -1021,7 +1084,7 @@
 
 	while (index != NULL) {
 		index->table_name = table->name;
-		
+
 		index = dict_table_get_next_index(index);
 	}
 
@@ -1033,7 +1096,7 @@
 		constraints from the dictionary cache here. The foreign key
 		constraints will be inherited to the new table from the
 		system tables through a call of dict_load_foreigns. */
-	
+
 		/* Remove the foreign constraints from the cache */
 		foreign = UT_LIST_GET_LAST(table->foreign_list);
 
@@ -1049,14 +1112,14 @@
 		while (foreign != NULL) {
 			foreign->referenced_table = NULL;
 			foreign->referenced_index = NULL;
-		
+
 			foreign = UT_LIST_GET_NEXT(referenced_list, foreign);
 		}
 
 		/* Make the list of referencing constraints empty */
 
 		UT_LIST_INIT(table->referenced_list);
-		
+
 		return(TRUE);
 	}
 
@@ -1067,14 +1130,14 @@
 	foreign = UT_LIST_GET_FIRST(table->foreign_list);
 
 	while (foreign != NULL) {
-		if (ut_strlen(foreign->foreign_table_name) <
-						ut_strlen(table->name)) {
+		if (ut_strlen(foreign->foreign_table_name)
+		    < ut_strlen(table->name)) {
 			/* Allocate a longer name buffer;
 			TODO: store buf len to save memory */
 
-			foreign->foreign_table_name = mem_heap_alloc(
-					foreign->heap,
-					ut_strlen(table->name) + 1);
+			foreign->foreign_table_name
+				= mem_heap_alloc(foreign->heap,
+						 ut_strlen(table->name) + 1);
 		}
 
 		strcpy(foreign->foreign_table_name, table->name);
@@ -1088,47 +1151,46 @@
 			old_id = mem_strdup(foreign->id);
 
 			if (ut_strlen(foreign->id) > ut_strlen(old_name)
-						+ ((sizeof dict_ibfk) - 1)
-			    && 0 == ut_memcmp(foreign->id, old_name,
-						ut_strlen(old_name))
-			    && 0 == ut_memcmp(
-					foreign->id + ut_strlen(old_name),
-					dict_ibfk, (sizeof dict_ibfk) - 1)) {
+			    + ((sizeof dict_ibfk) - 1)
+			    && !memcmp(foreign->id, old_name,
+				       ut_strlen(old_name))
+			    && !memcmp(foreign->id + ut_strlen(old_name),
+				       dict_ibfk, (sizeof dict_ibfk) - 1)) {
 
 				/* This is a generated >= 4.0.18 format id */
 
-				if (ut_strlen(table->name) > ut_strlen(old_name)) {
+				if (strlen(table->name) > strlen(old_name)) {
 					foreign->id = mem_heap_alloc(
-					     foreign->heap,
-						ut_strlen(table->name)
-						+ ut_strlen(old_id) + 1);
+						foreign->heap,
+						strlen(table->name)
+						+ strlen(old_id) + 1);
 				}
-				
+
 				/* Replace the prefix 'databasename/tablename'
 				with the new names */
 				strcpy(foreign->id, table->name);
 				strcat(foreign->id,
-						old_id + ut_strlen(old_name));
+				       old_id + ut_strlen(old_name));
 			} else {
 				/* This is a >= 4.0.18 format id where the user
 				gave the id name */
 				db_len = dict_get_db_name_len(table->name) + 1;
 
 				if (dict_get_db_name_len(table->name)
-			    	    > dict_get_db_name_len(foreign->id)) {
+				    > dict_get_db_name_len(foreign->id)) {
 
 					foreign->id = mem_heap_alloc(
-					     foreign->heap,
-				 	     db_len + ut_strlen(old_id) + 1);
+						foreign->heap,
+						db_len + strlen(old_id) + 1);
 				}
 
 				/* Replace the database prefix in id with the
 				one from table->name */
-			
+
 				ut_memcpy(foreign->id, table->name, db_len);
 
 				strcpy(foreign->id + db_len,
-						dict_remove_db_name(old_id));
+				       dict_remove_db_name(old_id));
 			}
 
 			mem_free(old_id);
@@ -1140,14 +1202,13 @@
 	foreign = UT_LIST_GET_FIRST(table->referenced_list);
 
 	while (foreign != NULL) {
-		if (ut_strlen(foreign->referenced_table_name) <
-						ut_strlen(table->name)) {
+		if (ut_strlen(foreign->referenced_table_name)
+		    < ut_strlen(table->name)) {
 			/* Allocate a longer name buffer;
 			TODO: store buf len to save memory */
 
 			foreign->referenced_table_name = mem_heap_alloc(
-					foreign->heap,
-					ut_strlen(table->name) + 1);
+				foreign->heap, strlen(table->name) + 1);
 		}
 
 		strcpy(foreign->referenced_table_name, table->name);
@@ -1177,12 +1238,12 @@
 	/* Remove the table from the hash table of id's */
 
 	HASH_DELETE(dict_table_t, id_hash, dict_sys->table_id_hash,
-					ut_fold_dulint(table->id), table);
+		    ut_fold_dulint(table->id), table);
 	table->id = new_id;
 
 	/* Add the table back to the hash table */
 	HASH_INSERT(dict_table_t, id_hash, dict_sys->table_id_hash,
-					ut_fold_dulint(table->id), table);
+		    ut_fold_dulint(table->id), table);
 }
 
 /**************************************************************************
@@ -1196,8 +1257,7 @@
 	dict_foreign_t*	foreign;
 	dict_index_t*	index;
 	ulint		size;
-	ulint		i;
-	
+
 	ut_ad(table);
 #ifdef UNIV_SYNC_DEBUG
 	ut_ad(mutex_own(&(dict_sys->mutex)));
@@ -1225,7 +1285,7 @@
 	while (foreign != NULL) {
 		foreign->referenced_table = NULL;
 		foreign->referenced_index = NULL;
-		
+
 		foreign = UT_LIST_GET_NEXT(referenced_list, foreign);
 	}
 
@@ -1237,17 +1297,11 @@
 		index = UT_LIST_GET_LAST(table->indexes);
 	}
 
-	/* Remove the columns of the table from the cache */
-	for (i = 0; i < table->n_cols; i++) {
-		dict_col_remove_from_cache(table,
-					   dict_table_get_nth_col(table, i));
-	}
-
 	/* Remove table from the hash tables of tables */
 	HASH_DELETE(dict_table_t, name_hash, dict_sys->table_hash,
-					ut_fold_string(table->name), table);
+		    ut_fold_string(table->name), table);
 	HASH_DELETE(dict_table_t, id_hash, dict_sys->table_id_hash,
-					ut_fold_dulint(table->id), table);
+		    ut_fold_dulint(table->id), table);
 
 	/* Remove table from LRU list of tables */
 	UT_LIST_REMOVE(table_LRU, dict_sys->table_LRU, table);
@@ -1261,122 +1315,16 @@
 	dict_mem_table_free(table);
 }
 
-/**************************************************************************
-Frees tables from the end of table_LRU if the dictionary cache occupies
-too much space. Currently not used! */
-
-void
-dict_table_LRU_trim(void)
-/*=====================*/
-{
-	dict_table_t*	table;
-	dict_table_t*	prev_table;
-
-	ut_error;
-
-#ifdef UNIV_SYNC_DEBUG
-	ut_ad(mutex_own(&(dict_sys->mutex)));
-#endif /* UNIV_SYNC_DEBUG */
-
-	table = UT_LIST_GET_LAST(dict_sys->table_LRU);
-
-	while (table && (dict_sys->size >
-			 buf_pool_get_max_size() / DICT_POOL_PER_VARYING)) {
-
-		prev_table = UT_LIST_GET_PREV(table_LRU, table);
-
-		if (table->mem_fix == 0) {
-			dict_table_remove_from_cache(table);
-		}
-
-		table = prev_table;
-	}
-}
-
-/**************************************************************************
-Adds a column to the data dictionary hash table. */
-static
-void
-dict_col_add_to_cache(
-/*==================*/
-	dict_table_t*	table,	/* in: table */
-	dict_col_t*	col)	/* in: column */
-{
-	ulint	fold;
-
-	ut_ad(table && col);
-#ifdef UNIV_SYNC_DEBUG
-	ut_ad(mutex_own(&(dict_sys->mutex)));
-#endif /* UNIV_SYNC_DEBUG */
-	ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
-	
-	fold = ut_fold_ulint_pair(ut_fold_string(table->name),
-				  ut_fold_string(col->name));
-
-	/* Look for a column with same table name and column name: error */
-	{
-		dict_col_t*	col2;
-		HASH_SEARCH(hash, dict_sys->col_hash, fold, col2,
-			(ut_strcmp(col->name, col2->name) == 0)
-			&& (ut_strcmp((col2->table)->name, table->name)
-							== 0));  
-		ut_a(col2 == NULL);
-	}
-
-	HASH_INSERT(dict_col_t, hash, dict_sys->col_hash, fold, col);
-}
-
-/**************************************************************************
-Removes a column from the data dictionary hash table. */
-static
-void
-dict_col_remove_from_cache(
-/*=======================*/
-	dict_table_t*	table,	/* in: table */
-	dict_col_t*	col)	/* in: column */
-{
-	ulint		fold;
-
-	ut_ad(table && col);
-#ifdef UNIV_SYNC_DEBUG
-	ut_ad(mutex_own(&(dict_sys->mutex)));
-#endif /* UNIV_SYNC_DEBUG */
-	ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
-	
-	fold = ut_fold_ulint_pair(ut_fold_string(table->name),
-				  ut_fold_string(col->name));
-
-	HASH_DELETE(dict_col_t, hash, dict_sys->col_hash, fold, col);
-}
+/*************************************************************************
+Gets the column position in the clustered index. */
 
-/**************************************************************************
-Repositions a column in the data dictionary hash table when the table name
-changes. */
-static
-void
-dict_col_reposition_in_cache(
-/*=========================*/
-	dict_table_t*	table,		/* in: table */
-	dict_col_t*	col,		/* in: column */
-	const char*	new_name)	/* in: new table name */
+ulint
+dict_col_get_clust_pos_noninline(
+/*=============================*/
+	const dict_col_t*	col,		/* in: table column */
+	const dict_index_t*	clust_index)	/* in: clustered index */
 {
-	ulint		fold;
-
-	ut_ad(table && col);
-#ifdef UNIV_SYNC_DEBUG
-	ut_ad(mutex_own(&(dict_sys->mutex)));
-#endif /* UNIV_SYNC_DEBUG */
-	ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
-	
-	fold = ut_fold_ulint_pair(ut_fold_string(table->name),
-				  ut_fold_string(col->name));
-
-	HASH_DELETE(dict_col_t, hash, dict_sys->col_hash, fold, col);
-
-	fold = ut_fold_ulint_pair(ut_fold_string(new_name),
-				  ut_fold_string(col->name));
-				  
-	HASH_INSERT(dict_col_t, hash, dict_sys->col_hash, fold, col);
+	return(dict_col_get_clust_pos(col, clust_index));
 }
 
 /********************************************************************
@@ -1391,12 +1339,12 @@
 {
 	/* This check reminds that if a new system column is added to
 	the program, it should be dealt with here. */
-#if DATA_N_SYS_COLS != 4
-#error "DATA_N_SYS_COLS != 4"
+#if DATA_N_SYS_COLS != 3
+#error "DATA_N_SYS_COLS != 3"
 #endif
 
 	static const char*	reserved_names[] = {
-		"DB_ROW_ID", "DB_TRX_ID", "DB_ROLL_PTR", "DB_MIX_ID"
+		"DB_ROW_ID", "DB_TRX_ID", "DB_ROLL_PTR"
 	};
 
 	ulint			i;
@@ -1414,32 +1362,28 @@
 /**************************************************************************
 Adds an index to the dictionary cache. */
 
-ibool
+void
 dict_index_add_to_cache(
 /*====================*/
-				/* out: TRUE if success */
 	dict_table_t*	table,	/* in: table on which the index is */
 	dict_index_t*	index,	/* in, own: index; NOTE! The index memory
 				object is freed in this function! */
 	ulint		page_no)/* in: root page number of the index */
 {
 	dict_index_t*	new_index;
-	dict_tree_t*	tree;
-	dict_table_t*	cluster;
-	dict_field_t*	field;
 	ulint		n_ord;
-	ibool		success;
 	ulint		i;
-	
+
 	ut_ad(index);
 #ifdef UNIV_SYNC_DEBUG
 	ut_ad(mutex_own(&(dict_sys->mutex)));
 #endif /* UNIV_SYNC_DEBUG */
 	ut_ad(index->n_def == index->n_fields);
 	ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
-	
+
 	ut_ad(mem_heap_validate(index->heap));
 
+#ifdef UNIV_DEBUG
 	{
 		dict_index_t*	index2;
 		index2 = UT_LIST_GET_FIRST(table->indexes);
@@ -1449,19 +1393,14 @@
 
 			index2 = UT_LIST_GET_NEXT(indexes, index2);
 		}
-
-		ut_a(UT_LIST_GET_LEN(table->indexes) == 0
-	      			|| (index->type & DICT_CLUSTERED) == 0);
 	}
+#endif /* UNIV_DEBUG */
 
-	success = dict_index_find_cols(table, index);
+	ut_a(!(index->type & DICT_CLUSTERED)
+	     || UT_LIST_GET_LEN(table->indexes) == 0);
 
-	if (!success) {
-		dict_mem_index_free(index);
+	dict_index_find_cols(table, index);
 
-		return(FALSE);
-	}
-	
 	/* Build the cache internal representation of the index,
 	containing also the added system fields */
 
@@ -1472,15 +1411,15 @@
 	}
 
 	new_index->search_info = btr_search_info_create(new_index->heap);
-	
+
 	/* Set the n_fields value in new_index to the actual defined
 	number of fields in the cache internal representation */
 
 	new_index->n_fields = new_index->n_def;
-	
+
 	/* Add the new index as the last index for the table */
 
-	UT_LIST_ADD_LAST(indexes, table->indexes, new_index);	
+	UT_LIST_ADD_LAST(indexes, table->indexes, new_index);
 	new_index->table = table;
 	new_index->table_name = table->name;
 
@@ -1494,33 +1433,18 @@
 
 	for (i = 0; i < n_ord; i++) {
 
-		field = dict_index_get_nth_field(new_index, i);
-
-		dict_field_get_col(field)->ord_part++;
+		dict_index_get_nth_field(new_index, i)->col->ord_part = 1;
 	}
 
-	if (table->type == DICT_TABLE_CLUSTER_MEMBER) {
-		/* The index tree is found from the cluster object */
-	    
-		cluster = dict_table_get_low(table->cluster_name);
-
-		tree = dict_index_get_tree(
-					UT_LIST_GET_FIRST(cluster->indexes));
-		new_index->tree = tree;
-	} else {
-		/* Create an index tree memory object for the index */
-		tree = dict_tree_create(new_index, page_no);
-		ut_ad(tree);
-
-		new_index->tree = tree;
-	}
+	new_index->page = page_no;
+	rw_lock_create(&new_index->lock, SYNC_INDEX_TREE);
 
 	if (!UNIV_UNLIKELY(new_index->type & DICT_UNIVERSAL)) {
 
-		new_index->stat_n_diff_key_vals =
-			mem_heap_alloc(new_index->heap,
-				(1 + dict_index_get_n_unique(new_index))
-				* sizeof(ib_longlong));
+		new_index->stat_n_diff_key_vals = mem_heap_alloc(
+			new_index->heap,
+			(1 + dict_index_get_n_unique(new_index))
+			* sizeof(ib_longlong));
 		/* Give some sensible values to stat_n_... in case we do
 		not calculate statistics quickly enough */
 
@@ -1529,18 +1453,10 @@
 			new_index->stat_n_diff_key_vals[i] = 100;
 		}
 	}
-	
-	/* Add the index to the list of indexes stored in the tree */
-	UT_LIST_ADD_LAST(tree_indexes, tree->tree_indexes, new_index); 
-	
-	/* If the dictionary cache grows too big, trim the table LRU list */
 
 	dict_sys->size += mem_heap_get_size(new_index->heap);
-	/* dict_table_LRU_trim(); */
 
 	dict_mem_index_free(index);
-
-	return(TRUE);
 }
 
 /**************************************************************************
@@ -1552,9 +1468,7 @@
 	dict_table_t*	table,	/* in: table */
 	dict_index_t*	index)	/* in, own: index */
 {
-	dict_field_t*	field;
 	ulint		size;
-	ulint		i;
 
 	ut_ad(table && index);
 	ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
@@ -1563,17 +1477,7 @@
 	ut_ad(mutex_own(&(dict_sys->mutex)));
 #endif /* UNIV_SYNC_DEBUG */
 
-	ut_ad(UT_LIST_GET_LEN((index->tree)->tree_indexes) == 1);
-	dict_tree_free(index->tree);
-
-	/* Decrement the ord_part counts in columns which are ordering */
-	for (i = 0; i < dict_index_get_n_unique(index); i++) {
-
-		field = dict_index_get_nth_field(index, i);
-
-		ut_ad(dict_field_get_col(field)->ord_part > 0);
-		(dict_field_get_col(field)->ord_part)--;
-	}
+	rw_lock_free(&index->lock);
 
 	/* Remove the index from the list of indexes of the table */
 	UT_LIST_REMOVE(indexes, table->indexes, index);
@@ -1588,21 +1492,17 @@
 }
 
 /***********************************************************************
-Tries to find column names for the index in the column hash table and
-sets the col field of the index. */
+Tries to find column names for the index and sets the col field of the
+index. */
 static
-ibool
+void
 dict_index_find_cols(
 /*=================*/
-				/* out: TRUE if success */
 	dict_table_t*	table,	/* in: table */
-	dict_index_t*	index)	/* in: index */	
+	dict_index_t*	index)	/* in: index */
 {
-	dict_col_t*	col;
-	dict_field_t*	field;
-	ulint		fold;
 	ulint		i;
-	
+
 	ut_ad(table && index);
 	ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
 #ifdef UNIV_SYNC_DEBUG
@@ -1610,26 +1510,27 @@
 #endif /* UNIV_SYNC_DEBUG */
 
 	for (i = 0; i < index->n_fields; i++) {
-		field = dict_index_get_nth_field(index, i);
+		ulint		j;
+		dict_field_t*	field = dict_index_get_nth_field(index, i);
 
-		fold = ut_fold_ulint_pair(ut_fold_string(table->name),
-				  	       ut_fold_string(field->name));
-			
-		HASH_SEARCH(hash, dict_sys->col_hash, fold, col,
-				(ut_strcmp(col->name, field->name) == 0)
-				&& (ut_strcmp((col->table)->name, table->name)
-								== 0));  
-		if (col == NULL) {
+		for (j = 0; j < table->n_cols; j++) {
+			if (!strcmp(dict_table_get_col_name(table, j),
+				    field->name)) {
+				field->col = (dict_col_t*)
+					dict_table_get_nth_col(table, j);
 
- 			return(FALSE);
-		} else {
-			field->col = col;
+				goto found;
+			}
 		}
-	}
 
-	return(TRUE);
+		/* It is an error not to find a matching column. */
+		ut_error;
+
+	found:
+		;
+	}
 }
-	
+
 /***********************************************************************
 Adds a column to index. */
 
@@ -1637,18 +1538,21 @@
 dict_index_add_col(
 /*===============*/
 	dict_index_t*	index,		/* in: index */
+	dict_table_t*	table,		/* in: table */
 	dict_col_t*	col,		/* in: column */
-	ulint		order,		/* in: order criterion */
 	ulint		prefix_len)	/* in: column prefix length */
 {
 	dict_field_t*	field;
+	const char*	col_name;
+
+	col_name = dict_table_get_col_name(table, dict_col_get_no(col));
 
-	dict_mem_index_add_field(index, col->name, order, prefix_len);
+	dict_mem_index_add_field(index, col_name, prefix_len);
 
 	field = dict_index_get_nth_field(index, index->n_def - 1);
 
 	field->col = col;
-	field->fixed_len = dtype_get_fixed_size(&col->type);
+	field->fixed_len = dict_col_get_fixed_size(col);
 
 	if (prefix_len && field->fixed_len > prefix_len) {
 		field->fixed_len = prefix_len;
@@ -1662,20 +1566,9 @@
 		field->fixed_len = 0;
 	}
 
-	if (!(dtype_get_prtype(&col->type) & DATA_NOT_NULL)) {
+	if (!(col->prtype & DATA_NOT_NULL)) {
 		index->n_nullable++;
 	}
-
-	if (index->n_def > 1) {
-		const dict_field_t*	field2 =
-			dict_index_get_nth_field(index, index->n_def - 2);
-		field->fixed_offs = (!field2->fixed_len ||
-					field2->fixed_offs == ULINT_UNDEFINED)
-				? ULINT_UNDEFINED
-				: field2->fixed_len + field2->fixed_offs;
-	} else {
-		field->fixed_offs = 0;
-	}
 }
 
 /***********************************************************************
@@ -1686,19 +1579,20 @@
 /*============*/
 	dict_index_t*	index1,	/* in: index to copy to */
 	dict_index_t*	index2,	/* in: index to copy from */
+	dict_table_t*	table,	/* in: table */
 	ulint		start,	/* in: first position to copy */
 	ulint		end)	/* in: last position to copy */
 {
 	dict_field_t*	field;
 	ulint		i;
-	
+
 	/* Copy fields contained in index2 */
 
 	for (i = start; i < end; i++) {
 
 		field = dict_index_get_nth_field(index2, i);
-		dict_index_add_col(index1, field->col, field->order,
-						      field->prefix_len);
+		dict_index_add_col(index1, table, field->col,
+				   field->prefix_len);
 	}
 }
 
@@ -1712,8 +1606,6 @@
 	dict_index_t*	index,		/* in: index */
 	ulint		n_fields)	/* in: number of field types to copy */
 {
-	dtype_t*	dfield_type;
-	dtype_t*	type;
 	ulint		i;
 
 	if (UNIV_UNLIKELY(index->type & DICT_UNIVERSAL)) {
@@ -1723,10 +1615,15 @@
 	}
 
 	for (i = 0; i < n_fields; i++) {
+		dict_field_t*	ifield;
+		dtype_t*	dfield_type;
+
+		ifield = dict_index_get_nth_field(index, i);
 		dfield_type = dfield_get_type(dtuple_get_nth_field(tuple, i));
-		type = dict_col_get_type(dict_field_get_col(
-				dict_index_get_nth_field(index, i)));
-		*dfield_type = *type;
+		dict_col_copy_type(dict_field_get_col(ifield), dfield_type);
+		if (UNIV_UNLIKELY(ifield->prefix_len)) {
+			dfield_type->len = ifield->prefix_len;
+		}
 	}
 }
 
@@ -1740,17 +1637,13 @@
 	dict_table_t*	table)	/* in: index */
 {
 	dtype_t*	dfield_type;
-	dtype_t*	type;
 	ulint		i;
 
-	ut_ad(!(table->type & DICT_UNIVERSAL));
-
 	for (i = 0; i < dtuple_get_n_fields(tuple); i++) {
 
 		dfield_type = dfield_get_type(dtuple_get_nth_field(tuple, i));
-		type = dict_col_get_type(dict_table_get_nth_col(table, i));
-
-		*dfield_type = *type;
+		dict_col_copy_type(dict_table_get_nth_col(table, i),
+				   dfield_type);
 	}
 }
 
@@ -1765,14 +1658,14 @@
 				of the clustered index */
 	dict_table_t*	table,	/* in: table */
 	dict_index_t*	index)	/* in: user representation of a clustered
-				index */	
+				index */
 {
 	dict_index_t*	new_index;
 	dict_field_t*	field;
-	dict_col_t*	col;
 	ulint		fixed_size;
 	ulint		trx_id_pos;
 	ulint		i;
+	ibool*		indexed;
 
 	ut_ad(table && index);
 	ut_ad(index->type & DICT_CLUSTERED);
@@ -1783,40 +1676,25 @@
 
 	/* Create a new index object with certainly enough fields */
 	new_index = dict_mem_index_create(table->name,
-				     index->name,
-				     table->space,
-				     index->type,
-				     index->n_fields + table->n_cols);
+					  index->name, table->space,
+					  index->type,
+					  index->n_fields + table->n_cols);
 
 	/* Copy other relevant data from the old index struct to the new
 	struct: it inherits the values */
 
 	new_index->n_user_defined_cols = index->n_fields;
-	
+
 	new_index->id = index->id;
 
-	if (table->type != DICT_TABLE_ORDINARY) {
-		/* The index is mixed: copy common key prefix fields */
-		
-		dict_index_copy(new_index, index, 0, table->mix_len);
-
-		/* Add the mix id column */
-		dict_index_add_col(new_index,
-			  dict_table_get_sys_col(table, DATA_MIX_ID), 0, 0);
-
-		/* Copy the rest of fields */
-		dict_index_copy(new_index, index, table->mix_len,
-							index->n_fields);
-	} else {
-		/* Copy the fields of index */
-		dict_index_copy(new_index, index, 0, index->n_fields);
-	}
+	/* Copy the fields of index */
+	dict_index_copy(new_index, index, table, 0, index->n_fields);
 
 	if (UNIV_UNLIKELY(index->type & DICT_UNIVERSAL)) {
 		/* No fixed number of fields determines an entry uniquely */
 
-		new_index->n_uniq = ULINT_MAX;
-		
+		new_index->n_uniq = REC_MAX_N_FIELDS;
+
 	} else if (index->type & DICT_UNIQUE) {
 		/* Only the fields defined so far are needed to identify
 		the index entry uniquely */
@@ -1834,26 +1712,37 @@
 
 		trx_id_pos = new_index->n_def;
 
-		ut_ad(DATA_ROW_ID == 0);
-		ut_ad(DATA_TRX_ID == 1);
-		ut_ad(DATA_ROLL_PTR == 2);
+#if DATA_ROW_ID != 0
+# error "DATA_ROW_ID != 0"
+#endif
+#if DATA_TRX_ID != 1
+# error "DATA_TRX_ID != 1"
+#endif
+#if DATA_ROLL_PTR != 2
+# error "DATA_ROLL_PTR != 2"
+#endif
 
 		if (!(index->type & DICT_UNIQUE)) {
-			dict_index_add_col(new_index,
-			   dict_table_get_sys_col(table, DATA_ROW_ID), 0, 0);
+			dict_index_add_col(new_index, table, (dict_col_t*)
+					   dict_table_get_sys_col(
+						   table, DATA_ROW_ID),
+					   0);
 			trx_id_pos++;
 		}
 
-		dict_index_add_col(new_index,
-			   dict_table_get_sys_col(table, DATA_TRX_ID), 0, 0);
-	
-		dict_index_add_col(new_index,
-			   dict_table_get_sys_col(table, DATA_ROLL_PTR), 0, 0);
+		dict_index_add_col(new_index, table, (dict_col_t*)
+				   dict_table_get_sys_col(table, DATA_TRX_ID),
+				   0);
+
+		dict_index_add_col(new_index, table, (dict_col_t*)
+				   dict_table_get_sys_col(table,
+							  DATA_ROLL_PTR),
+				   0);
 
 		for (i = 0; i < trx_id_pos; i++) {
 
-			fixed_size = dtype_get_fixed_size(
-				dict_index_get_nth_type(new_index, i));
+			fixed_size = dict_col_get_fixed_size(
+				dict_index_get_nth_col(new_index, i));
 
 			if (fixed_size == 0) {
 				new_index->trx_id_offset = 0;
@@ -1873,12 +1762,9 @@
 
 	}
 
-	/* Set auxiliary variables in table columns as undefined */
-	for (i = 0; i < table->n_cols; i++) {
-
-		col = dict_table_get_nth_col(table, i);
-		col->aux = ULINT_UNDEFINED;
-	}
+	/* Remember the table columns already contained in new_index */
+	indexed = mem_alloc(table->n_cols * sizeof *indexed);
+	memset(indexed, 0, table->n_cols * sizeof *indexed);
 
 	/* Mark with 0 the table columns already contained in new_index */
 	for (i = 0; i < new_index->n_def; i++) {
@@ -1890,41 +1776,32 @@
 
 		if (field->prefix_len == 0) {
 
-		        field->col->aux = 0;
+			indexed[field->col->ind] = TRUE;
 		}
 	}
-	
+
 	/* Add to new_index non-system columns of table not yet included
 	there */
-	for (i = 0; i < table->n_cols - DATA_N_SYS_COLS; i++) {
+	for (i = 0; i + DATA_N_SYS_COLS < (ulint) table->n_cols; i++) {
 
-		col = dict_table_get_nth_col(table, i);
-		ut_ad(col->type.mtype != DATA_SYS);
+		dict_col_t*	col = (dict_col_t*)
+			dict_table_get_nth_col(table, i);
+		ut_ad(col->mtype != DATA_SYS);
 
-		if (col->aux == ULINT_UNDEFINED) {
-			dict_index_add_col(new_index, col, 0, 0);
+		if (!indexed[col->ind]) {
+			dict_index_add_col(new_index, table, col, 0);
 		}
 	}
 
-	ut_ad((index->type & DICT_IBUF)
-				|| (UT_LIST_GET_LEN(table->indexes) == 0));
-
-	/* Store to the column structs the position of the table columns
-	in the clustered index */
-
-	for (i = 0; i < new_index->n_def; i++) {
-		field = dict_index_get_nth_field(new_index, i);
+	mem_free(indexed);
 
-		if (field->prefix_len == 0) {
+	ut_ad((index->type & DICT_IBUF)
+	      || (UT_LIST_GET_LEN(table->indexes) == 0));
 
-		        field->col->clust_pos = i;
-		}
-	}
-	
 	new_index->cached = TRUE;
 
 	return(new_index);
-}	
+}
 
 /***********************************************************************
 Builds the internal dictionary cache representation for a non-clustered
@@ -1937,12 +1814,13 @@
 				of the non-clustered index */
 	dict_table_t*	table,	/* in: table */
 	dict_index_t*	index)	/* in: user representation of a non-clustered
-				index */	
+				index */
 {
 	dict_field_t*	field;
 	dict_index_t*	new_index;
 	dict_index_t*	clust_index;
 	ulint		i;
+	ibool*		indexed;
 
 	ut_ad(table && index);
 	ut_ad(0 == (index->type & DICT_CLUSTERED));
@@ -1953,36 +1831,29 @@
 
 	/* The clustered index should be the first in the list of indexes */
 	clust_index = UT_LIST_GET_FIRST(table->indexes);
-	
+
 	ut_ad(clust_index);
 	ut_ad(clust_index->type & DICT_CLUSTERED);
 	ut_ad(!(clust_index->type & DICT_UNIVERSAL));
 
 	/* Create a new index */
-	new_index = dict_mem_index_create(table->name,
-				     index->name,
-				     index->space,
-				     index->type,
-				     index->n_fields
-				     + 1 + clust_index->n_uniq);
+	new_index = dict_mem_index_create(
+		table->name, index->name, index->space, index->type,
+		index->n_fields + 1 + clust_index->n_uniq);
 
 	/* Copy other relevant data from the old index
 	struct to the new struct: it inherits the values */
 
 	new_index->n_user_defined_cols = index->n_fields;
-	
+
 	new_index->id = index->id;
 
 	/* Copy fields from index to new_index */
-	dict_index_copy(new_index, index, 0, index->n_fields);
-
-	/* Set the auxiliary variables in the clust_index unique columns
-	as undefined */
-	for (i = 0; i < clust_index->n_uniq; i++) {
+	dict_index_copy(new_index, index, table, 0, index->n_fields);
 
-		field = dict_index_get_nth_field(clust_index, i);
-		field->col->aux = ULINT_UNDEFINED;
-	}
+	/* Remember the table columns already contained in new_index */
+	indexed = mem_alloc(table->n_cols * sizeof *indexed);
+	memset(indexed, 0, table->n_cols * sizeof *indexed);
 
 	/* Mark with 0 table columns already contained in new_index */
 	for (i = 0; i < new_index->n_def; i++) {
@@ -1994,7 +1865,7 @@
 
 		if (field->prefix_len == 0) {
 
-		        field->col->aux = 0;
+			indexed[field->col->ind] = TRUE;
 		}
 	}
 
@@ -2005,12 +1876,14 @@
 
 		field = dict_index_get_nth_field(clust_index, i);
 
-		if (field->col->aux == ULINT_UNDEFINED) {
-			dict_index_add_col(new_index, field->col, 0,
-						      field->prefix_len);
+		if (!indexed[field->col->ind]) {
+			dict_index_add_col(new_index, table, field->col,
+					   field->prefix_len);
 		}
 	}
 
+	mem_free(indexed);
+
 	if ((index->type) & DICT_UNIQUE) {
 		new_index->n_uniq = index->n_fields;
 	} else {
@@ -2025,7 +1898,7 @@
 	new_index->cached = TRUE;
 
 	return(new_index);
-}	
+}
 
 /*====================== FOREIGN KEY PROCESSING ========================*/
 
@@ -2040,7 +1913,7 @@
 	dict_table_t*	table)	/* in: InnoDB table */
 {
 	if (UT_LIST_GET_LEN(table->referenced_list) > 0) {
-		
+
 		return(TRUE);
 	}
 
@@ -2070,15 +1943,17 @@
 	ut_ad(mutex_own(&(dict_sys->mutex)));
 #endif /* UNIV_SYNC_DEBUG */
 	ut_a(foreign);
-	
+
 	if (foreign->referenced_table) {
 		UT_LIST_REMOVE(referenced_list,
-			foreign->referenced_table->referenced_list, foreign);
+			       foreign->referenced_table->referenced_list,
+			       foreign);
 	}
 
 	if (foreign->foreign_table) {
 		UT_LIST_REMOVE(foreign_list,
-			foreign->foreign_table->foreign_list, foreign);
+			       foreign->foreign_table->foreign_list,
+			       foreign);
 	}
 
 	dict_foreign_free(foreign);
@@ -2111,7 +1986,7 @@
 
 		foreign = UT_LIST_GET_NEXT(foreign_list, foreign);
 	}
-	
+
 	foreign = UT_LIST_GET_FIRST(table->referenced_list);
 
 	while (foreign) {
@@ -2124,8 +1999,9 @@
 	}
 
 	return(NULL);
-}	
+}
 
+#ifndef UNIV_HOTBACKUP
 /*************************************************************************
 Tries to find an index whose first fields are the columns in the array,
 in the same order. */
@@ -2139,43 +2015,46 @@
 	ulint		n_cols,	/* in: number of columns */
 	dict_index_t*	types_idx, /* in: NULL or an index to whose types the
 				   column types must match */
-	ibool		check_charsets)	/* in: whether to check charsets.
-					only has an effect if types_idx !=
-					NULL. */
+	ibool		check_charsets)
+				/* in: whether to check charsets.
+				only has an effect if types_idx != NULL */
 {
-#ifndef UNIV_HOTBACKUP
 	dict_index_t*	index;
+	dict_field_t*	field;
 	const char*	col_name;
 	ulint		i;
-	
+
 	index = dict_table_get_first_index(table);
 
 	while (index != NULL) {
 		if (dict_index_get_n_fields(index) >= n_cols) {
 
 			for (i = 0; i < n_cols; i++) {
-				col_name = dict_index_get_nth_field(index, i)
-							->col->name;
-				if (dict_index_get_nth_field(index, i)
-						->prefix_len != 0) {
+				field = dict_index_get_nth_field(index, i);
+
+				col_name = dict_table_get_col_name(
+					table, dict_col_get_no(field->col));
+
+				if (field->prefix_len != 0) {
 					/* We do not accept column prefix
 					indexes here */
-					
+
 					break;
 				}
 
 				if (0 != innobase_strcasecmp(columns[i],
-								col_name)) {
-				  	break;
+							     col_name)) {
+					break;
 				}
 
-				if (types_idx && !cmp_types_are_equal(
-				     dict_index_get_nth_type(index, i),
-				     dict_index_get_nth_type(types_idx, i),
-				     check_charsets)) {
+				if (types_idx && !cmp_cols_are_equal(
+					    dict_index_get_nth_col(index, i),
+					    dict_index_get_nth_col(types_idx,
+								   i),
+					    check_charsets)) {
 
-				  	break;
-				}		
+					break;
+				}
 			}
 
 			if (i == n_cols) {
@@ -2189,12 +2068,6 @@
 	}
 
 	return(NULL);
-#else /* UNIV_HOTBACKUP */
-	/* This function depends on MySQL code that is not included in
-	InnoDB Hot Backup builds.  Besides, this function should never
-	be called in InnoDB Hot Backup. */
-	ut_error;
-#endif /* UNIV_HOTBACKUP */
 }
 
 /**************************************************************************
@@ -2230,11 +2103,12 @@
 	putc('\n', file);
 	if (fk->foreign_index) {
 		fputs("The index in the foreign key in table is ", file);
-		ut_print_name(file, NULL, fk->foreign_index->name);
+		ut_print_name(file, NULL, FALSE, fk->foreign_index->name);
 		fputs("\n"
-"See http://dev.mysql.com/doc/refman/5.0/en/innodb-foreign-key-constraints.html\n"
-"for correct foreign key definition.\n",
-		file);
+		      "See http://dev.mysql.com/doc/refman/5.1/en/"
+		      "innodb-foreign-key-constraints.html\n"
+		      "for correct foreign key definition.\n",
+		      file);
 	}
 	mutex_exit(&dict_foreign_err_mutex);
 }
@@ -2258,17 +2132,17 @@
 	dict_foreign_t*	for_in_cache		= NULL;
 	dict_index_t*	index;
 	ibool		added_to_referenced_list= FALSE;
-	FILE*		ef 			= dict_foreign_err_file;
+	FILE*		ef			= dict_foreign_err_file;
 
 #ifdef UNIV_SYNC_DEBUG
 	ut_ad(mutex_own(&(dict_sys->mutex)));
 #endif /* UNIV_SYNC_DEBUG */
 
 	for_table = dict_table_check_if_in_cache_low(
-					foreign->foreign_table_name);
-	
+		foreign->foreign_table_name);
+
 	ref_table = dict_table_check_if_in_cache_low(
-					foreign->referenced_table_name);
+		foreign->referenced_table_name);
 	ut_a(for_table || ref_table);
 
 	if (for_table) {
@@ -2287,62 +2161,73 @@
 	}
 
 	if (for_in_cache->referenced_table == NULL && ref_table) {
-		index = dict_foreign_find_index(ref_table,
+		index = dict_foreign_find_index(
+			ref_table,
 			(const char**) for_in_cache->referenced_col_names,
-			for_in_cache->n_fields,
-			for_in_cache->foreign_index, check_charsets);
+			for_in_cache->n_fields, for_in_cache->foreign_index,
+			check_charsets);
 
 		if (index == NULL) {
-			dict_foreign_error_report(ef, for_in_cache,
-"there is no index in referenced table which would contain\n"
-"the columns as the first columns, or the data types in the\n"
-"referenced table do not match to the ones in table.");
+			dict_foreign_error_report(
+				ef, for_in_cache,
+				"there is no index in referenced table"
+				" which would contain\n"
+				"the columns as the first columns,"
+				" or the data types in the\n"
+				"referenced table do not match"
+				" the ones in table.");
 
 			if (for_in_cache == foreign) {
 				mem_heap_free(foreign->heap);
 			}
 
-		    	return(DB_CANNOT_ADD_CONSTRAINT);
+			return(DB_CANNOT_ADD_CONSTRAINT);
 		}
 
 		for_in_cache->referenced_table = ref_table;
 		for_in_cache->referenced_index = index;
 		UT_LIST_ADD_LAST(referenced_list,
-					ref_table->referenced_list,
-					for_in_cache);
+				 ref_table->referenced_list,
+				 for_in_cache);
 		added_to_referenced_list = TRUE;
 	}
 
 	if (for_in_cache->foreign_table == NULL && for_table) {
-		index = dict_foreign_find_index(for_table,
+		index = dict_foreign_find_index(
+			for_table,
 			(const char**) for_in_cache->foreign_col_names,
 			for_in_cache->n_fields,
 			for_in_cache->referenced_index, check_charsets);
 
 		if (index == NULL) {
-			dict_foreign_error_report(ef, for_in_cache,
-"there is no index in the table which would contain\n"
-"the columns as the first columns, or the data types in the\n"
-"table do not match to the ones in the referenced table.");
+			dict_foreign_error_report(
+				ef, for_in_cache,
+				"there is no index in the table"
+				" which would contain\n"
+				"the columns as the first columns,"
+				" or the data types in the\n"
+				"table do not match"
+				" the ones in the referenced table.");
 
 			if (for_in_cache == foreign) {
 				if (added_to_referenced_list) {
-					UT_LIST_REMOVE(referenced_list,
+					UT_LIST_REMOVE(
+						referenced_list,
 						ref_table->referenced_list,
 						for_in_cache);
 				}
-			
+
 				mem_heap_free(foreign->heap);
 			}
 
-		    	return(DB_CANNOT_ADD_CONSTRAINT);
+			return(DB_CANNOT_ADD_CONSTRAINT);
 		}
 
 		for_in_cache->foreign_table = for_table;
 		for_in_cache->foreign_index = index;
 		UT_LIST_ADD_LAST(foreign_list,
-					for_table->foreign_list,
-					for_in_cache);
+				 for_table->foreign_list,
+				 for_in_cache);
 	}
 
 	return(DB_SUCCESS);
@@ -2377,13 +2262,13 @@
 			ulint	i;
 			for (i = 0; string[i]; i++) {
 				if (toupper((int)(unsigned char)(ptr[i]))
-						!= toupper((int)(unsigned char)
-						(string[i]))) {
+				    != toupper((int)(unsigned char)
+					       (string[i]))) {
 					goto nomatch;
 				}
 			}
 			break;
-		nomatch:
+nomatch:
 			;
 		}
 	}
@@ -2393,12 +2278,13 @@
 
 /*************************************************************************
 Accepts a specified string. Comparisons are case-insensitive. */
-
+static
 const char*
 dict_accept(
 /*========*/
 				/* out: if string was accepted, the pointer
 				is moved after that, else ptr is returned */
+	struct charset_info_st*	cs,/* in: the character set of ptr */
 	const char*	ptr,	/* in: scan from this */
 	const char*	string,	/* in: accept only this string as the next
 				non-whitespace string */
@@ -2408,15 +2294,15 @@
 	const char*	old_ptr2;
 
 	*success = FALSE;
-	
-	while (ib_isspace(*ptr)) {
+
+	while (my_isspace(cs, *ptr)) {
 		ptr++;
 	}
 
 	old_ptr2 = ptr;
-	
+
 	ptr = dict_scan_to(ptr, string);
-	
+
 	if (*ptr == '\0' || old_ptr2 != ptr) {
 		return(old_ptr);
 	}
@@ -2434,12 +2320,15 @@
 dict_scan_id(
 /*=========*/
 				/* out: scanned to */
+	struct charset_info_st*	cs,/* in: the character set of ptr */
 	const char*	ptr,	/* in: scanned to */
 	mem_heap_t*	heap,	/* in: heap where to allocate the id
 				(NULL=id will not be allocated, but it
 				will point to string near ptr) */
 	const char**	id,	/* out,own: the id; NULL if no id was
 				scannable */
+	ibool		table_id,/* in: TRUE=convert the allocated id
+				as a table name; FALSE=convert to UTF-8 */
 	ibool		accept_also_dot)
 				/* in: TRUE if also a dot can appear in a
 				non-quoted id; in a quoted id it can appear
@@ -2448,13 +2337,12 @@
 	char		quote	= '\0';
 	ulint		len	= 0;
 	const char*	s;
-	char*		d;
-	ulint		id_len;
-	byte*		b;
+	char*		str;
+	char*		dst;
 
 	*id = NULL;
 
-	while (ib_isspace(*ptr)) {
+	while (my_isspace(cs, *ptr)) {
 		ptr++;
 	}
 
@@ -2485,7 +2373,7 @@
 			len++;
 		}
 	} else {
-		while (!ib_isspace(*ptr) && *ptr != '(' && *ptr != ')'
+		while (!my_isspace(cs, *ptr) && *ptr != '(' && *ptr != ')'
 		       && (accept_also_dot || *ptr != '.')
 		       && *ptr != ',' && *ptr != '\0') {
 
@@ -2495,43 +2383,50 @@
 		len = ptr - s;
 	}
 
-	if (quote && heap) {
-		*id = d = mem_heap_alloc(heap, len + 1);
+	if (UNIV_UNLIKELY(!heap)) {
+		/* no heap given: id will point to source string */
+		*id = s;
+		return(ptr);
+	}
+
+	if (quote) {
+		char*	d;
+		str = d = mem_heap_alloc(heap, len + 1);
 		while (len--) {
 			if ((*d++ = *s++) == quote) {
 				s++;
 			}
 		}
 		*d++ = 0;
-		ut_a(*s == quote);
-		ut_a(s + 1 == ptr);
-	} else if (heap) {
-		*id = mem_heap_strdupl(heap, s, len);
+		len = d - str;
+		ut_ad(*s == quote);
+		ut_ad(s + 1 == ptr);
 	} else {
-		/* no heap given: id will point to source string */
-		*id = s;
+		str = mem_heap_strdupl(heap, s, len);
 	}
 
-	if (heap && !quote) {
-		/* EMS MySQL Manager sometimes adds characters 0xA0 (in
-		latin1, a 'non-breakable space') to the end of a table name.
-		After the UTF-8 conversion in ha_innodb.cc, bytes 0xC2
-		and 0xA0 are at the end of the string, and ib_isspace()
-		does not work for multi-byte UTF-8 characters.
-
-		In MySQL 5.1 we lex the string using thd->charset_info, and
-		my_isspace(). This workaround is not needed there. */
-
-		b = (byte*)(*id);
-		id_len = strlen((char*) b);
-		
-		if (id_len >= 3 && b[id_len - 1] == 0xA0
-			       && b[id_len - 2] == 0xC2) {
-
-			/* Strip the 2 last bytes */
+	if (!table_id) {
+convert_id:
+		/* Convert the identifier from connection character set
+		to UTF-8. */
+		len = 3 * len + 1;
+		*id = dst = mem_heap_alloc(heap, len);
+
+		innobase_convert_from_id(dst, str, len);
+	} else if (!strncmp(str, srv_mysql50_table_name_prefix,
+			    sizeof srv_mysql50_table_name_prefix)) {
+		/* This is a pre-5.1 table name
+		containing chars other than [A-Za-z0-9].
+		Discard the prefix and use raw UTF-8 encoding. */
+		str += sizeof srv_mysql50_table_name_prefix;
+		len -= sizeof srv_mysql50_table_name_prefix;
+		goto convert_id;
+	} else {
+		/* Encode using filename-safe characters. */
+		len = 5 * len + 1;
+		*id = dst = mem_heap_alloc(heap, len);
 
-			b[id_len - 2] = '\0';
-		}
+		innobase_convert_from_table_id(dst, str, len);
 	}
 
 	return(ptr);
@@ -2543,22 +2438,21 @@
 const char*
 dict_scan_col(
 /*==========*/
-				/* out: scanned to */
-	const char*	ptr,	/* in: scanned to */
-	ibool*		success,/* out: TRUE if success */
-	dict_table_t*	table,	/* in: table in which the column is */
-	dict_col_t**	column,	/* out: pointer to column if success */
-	mem_heap_t*	heap,	/* in: heap where to allocate the name */
-	const char**	name)	/* out,own: the column name; NULL if no name
-				was scannable */
+					/* out: scanned to */
+	struct charset_info_st*	cs,	/* in: the character set of ptr */
+	const char*		ptr,	/* in: scanned to */
+	ibool*			success,/* out: TRUE if success */
+	dict_table_t*		table,	/* in: table in which the column is */
+	const dict_col_t**	column,	/* out: pointer to column if success */
+	mem_heap_t*		heap,	/* in: heap where to allocate */
+	const char**		name)	/* out,own: the column name;
+					NULL if no name was scannable */
 {
-#ifndef UNIV_HOTBACKUP
-	dict_col_t*	col;
 	ulint		i;
 
 	*success = FALSE;
 
-	ptr = dict_scan_id(ptr, heap, name, TRUE);
+	ptr = dict_scan_id(cs, ptr, heap, name, FALSE, TRUE);
 
 	if (*name == NULL) {
 
@@ -2569,29 +2463,24 @@
 		*success = TRUE;
 		*column = NULL;
 	} else {
-	    	for (i = 0; i < dict_table_get_n_cols(table); i++) {
+		for (i = 0; i < dict_table_get_n_cols(table); i++) {
 
-			col = dict_table_get_nth_col(table, i);
+			const char*	col_name = dict_table_get_col_name(
+				table, i);
 
-			if (0 == innobase_strcasecmp(col->name, *name)) {
-		    		/* Found */
+			if (0 == innobase_strcasecmp(col_name, *name)) {
+				/* Found */
 
-		    		*success = TRUE;
-		    		*column = col;
-		    		strcpy((char*) *name, col->name);
+				*success = TRUE;
+				*column = dict_table_get_nth_col(table, i);
+				strcpy((char*) *name, col_name);
 
-		    		break;
+				break;
 			}
 		}
 	}
-	
+
 	return(ptr);
-#else /* UNIV_HOTBACKUP */
-	/* This function depends on MySQL code that is not included in
-	InnoDB Hot Backup builds.  Besides, this function should never
-	be called in InnoDB Hot Backup. */
-	ut_error;
-#endif /* UNIV_HOTBACKUP */
 }
 
 /*************************************************************************
@@ -2601,6 +2490,7 @@
 dict_scan_table_name(
 /*=================*/
 				/* out: scanned to */
+	struct charset_info_st*	cs,/* in: the character set of ptr */
 	const char*	ptr,	/* in: scanned to */
 	dict_table_t**	table,	/* out: table object or NULL */
 	const char*	name,	/* in: foreign key table name */
@@ -2609,7 +2499,6 @@
 	const char**	ref_name)/* out,own: the table name;
 				NULL if no name was scannable */
 {
-#ifndef UNIV_HOTBACKUP
 	const char*	database_name	= NULL;
 	ulint		database_name_len = 0;
 	const char*	table_name	= NULL;
@@ -2619,11 +2508,11 @@
 
 	*success = FALSE;
 	*table = NULL;
-	
-	ptr = dict_scan_id(ptr, heap, &scan_name, FALSE);	
+
+	ptr = dict_scan_id(cs, ptr, heap, &scan_name, TRUE, FALSE);
 
 	if (scan_name == NULL) {
-		
+
 		return(ptr);	/* Syntax error */
 	}
 
@@ -2635,7 +2524,7 @@
 		database_name = scan_name;
 		database_name_len = strlen(database_name);
 
-		ptr = dict_scan_id(ptr, heap, &table_name, FALSE);
+		ptr = dict_scan_id(cs, ptr, heap, &table_name, TRUE, FALSE);
 
 		if (table_name == NULL) {
 
@@ -2646,9 +2535,9 @@
 		earlier, we must allow the dot separator between the database
 		name and the table name also to appear within a quoted
 		identifier! InnoDB used to print a constraint as:
-			... REFERENCES `databasename.tablename` ...
+		... REFERENCES `databasename.tablename` ...
 		starting from 4.0.18 it is
-			... REFERENCES `databasename`.`tablename` ... */
+		... REFERENCES `databasename`.`tablename` ... */
 		const char* s;
 
 		for (s = scan_name; *s; s++) {
@@ -2691,12 +2580,6 @@
 	*table = dict_table_get_low(ref);
 
 	return(ptr);
-#else /* UNIV_HOTBACKUP */
-	/* This function depends on MySQL code that is not included in
-	InnoDB Hot Backup builds.  Besides, this function should never
-	be called in InnoDB Hot Backup. */
-	ut_error;
-#endif /* UNIV_HOTBACKUP */
 }
 
 /*************************************************************************
@@ -2706,20 +2589,21 @@
 dict_skip_word(
 /*===========*/
 				/* out: scanned to */
+	struct charset_info_st*	cs,/* in: the character set of ptr */
 	const char*	ptr,	/* in: scanned to */
 	ibool*		success)/* out: TRUE if success, FALSE if just spaces
 				left in string or a syntax error */
 {
 	const char*	start;
-	
+
 	*success = FALSE;
 
-	ptr = dict_scan_id(ptr, NULL, &start, TRUE);
+	ptr = dict_scan_id(cs, ptr, NULL, &start, FALSE, TRUE);
 
 	if (start) {
 		*success = TRUE;
 	}
-	
+
 	return(ptr);
 }
 
@@ -2741,8 +2625,8 @@
 	char*		str;
 	const char*	sptr;
 	char*		ptr;
- 	/* unclosed quote character (0 if none) */
- 	char		quote	= 0;
+	/* unclosed quote character (0 if none) */
+	char		quote	= 0;
 
 	str = mem_alloc(strlen(sql_string) + 1);
 
@@ -2770,8 +2654,8 @@
 			/* Starting quote: remember the quote character. */
 			quote = *sptr;
 		} else if (*sptr == '#'
-                           || (sptr[0] == '-' && sptr[1] == '-' &&
-                               sptr[2] == ' ')) {
+			   || (sptr[0] == '-' && sptr[1] == '-'
+			       && sptr[2] == ' ')) {
 			for (;;) {
 				/* In Unix a newline is 0x0A while in Windows
 				it is 0x0D followed by 0x0A */
@@ -2789,7 +2673,7 @@
 			for (;;) {
 				if (*sptr == '*' && *(sptr + 1) == '/') {
 
-				     	sptr += 2;
+					sptr += 2;
 
 					goto scan_more;
 				}
@@ -2837,12 +2721,13 @@
 		if (ut_strlen(foreign->id) > ((sizeof dict_ibfk) - 1) + len
 		    && 0 == ut_memcmp(foreign->id, table->name, len)
 		    && 0 == ut_memcmp(foreign->id + len,
-				dict_ibfk, (sizeof dict_ibfk) - 1)
+				      dict_ibfk, (sizeof dict_ibfk) - 1)
 		    && foreign->id[len + ((sizeof dict_ibfk) - 1)] != '0') {
 			/* It is of the >= 4.0.18 format */
 
-			id = strtoul(foreign->id + len + ((sizeof dict_ibfk) - 1),
-					&endp, 10);
+			id = strtoul(foreign->id + len
+				     + ((sizeof dict_ibfk) - 1),
+				     &endp, 10);
 			if (*endp == '\0') {
 				ut_a(id != biggest_id);
 
@@ -2892,6 +2777,7 @@
 				/* out: error code or DB_SUCCESS */
 	trx_t*		trx,	/* in: transaction */
 	mem_heap_t*	heap,	/* in: memory heap */
+	struct charset_info_st*	cs,/* in: the character set of sql_string */
 	const char*	sql_string,
 				/* in: CREATE TABLE or ALTER TABLE statement
 				where foreign keys are declared like:
@@ -2912,7 +2798,7 @@
 	ulint		highest_id_so_far	= 0;
 	dict_index_t*	index;
 	dict_foreign_t*	foreign;
- 	const char*	ptr			= sql_string;
+	const char*	ptr			= sql_string;
 	const char*	start_of_latest_foreign	= sql_string;
 	FILE*		ef			= dict_foreign_err_file;
 	const char*	constraint_name;
@@ -2925,10 +2811,10 @@
 	ibool		is_on_delete;
 	ulint		n_on_deletes;
 	ulint		n_on_updates;
-	dict_col_t*	columns[500];
+	const dict_col_t*columns[500];
 	const char*	column_names[500];
 	const char*	referenced_table_name;
-	
+
 #ifdef UNIV_SYNC_DEBUG
 	ut_ad(mutex_own(&(dict_sys->mutex)));
 #endif /* UNIV_SYNC_DEBUG */
@@ -2939,8 +2825,9 @@
 		mutex_enter(&dict_foreign_err_mutex);
 		dict_foreign_error_report_low(ef, name);
 		fprintf(ef,
-"Cannot find the table in the internal data dictionary of InnoDB.\n"
-"Create table statement:\n%s\n", sql_string);
+			"Cannot find the table in the internal"
+			" data dictionary of InnoDB.\n"
+			"Create table statement:\n%s\n", sql_string);
 		mutex_exit(&dict_foreign_err_mutex);
 
 		return(DB_ERROR);
@@ -2949,14 +2836,14 @@
 	/* First check if we are actually doing an ALTER TABLE, and in that
 	case look for the table being altered */
 
-	ptr = dict_accept(ptr, "ALTER", &success);
+	ptr = dict_accept(cs, ptr, "ALTER", &success);
 
 	if (!success) {
 
 		goto loop;
 	}
 
-	ptr = dict_accept(ptr, "TABLE", &success);
+	ptr = dict_accept(cs, ptr, "TABLE", &success);
 
 	if (!success) {
 
@@ -2965,11 +2852,13 @@
 
 	/* We are doing an ALTER TABLE: scan the table name we are altering */
 
-	ptr = dict_scan_table_name(ptr, &table_to_alter, name,
-				&success, heap, &referenced_table_name);
+	ptr = dict_scan_table_name(cs, ptr, &table_to_alter, name,
+				   &success, heap, &referenced_table_name);
 	if (!success) {
 		fprintf(stderr,
-"InnoDB: Error: could not find the table being ALTERED in:\n%s\n", sql_string);
+			"InnoDB: Error: could not find"
+			" the table being ALTERED in:\n%s\n",
+			sql_string);
 
 		return(DB_ERROR);
 	}
@@ -2987,7 +2876,7 @@
 		highest_id_so_far = 0;
 	} else {
 		highest_id_so_far = dict_table_get_highest_foreign_id(
-							table_to_alter);
+			table_to_alter);
 	}
 
 	/* Scan for foreign key declarations in a loop */
@@ -3005,21 +2894,22 @@
 		of the constraint to system tables. */
 		ptr = ptr1;
 
-		ptr = dict_accept(ptr, "CONSTRAINT", &success);
+		ptr = dict_accept(cs, ptr, "CONSTRAINT", &success);
 
 		ut_a(success);
 
-		if (!ib_isspace(*ptr) && *ptr != '"' && *ptr != '`') {
-	        	goto loop;
+		if (!my_isspace(cs, *ptr) && *ptr != '"' && *ptr != '`') {
+			goto loop;
 		}
 
-		while (ib_isspace(*ptr)) {
+		while (my_isspace(cs, *ptr)) {
 			ptr++;
 		}
 
 		/* read constraint name unless got "CONSTRAINT FOREIGN" */
 		if (ptr != ptr2) {
-			ptr = dict_scan_id(ptr, heap, &constraint_name, FALSE);
+			ptr = dict_scan_id(cs, ptr, heap,
+					   &constraint_name, FALSE, FALSE);
 		}
 	} else {
 		ptr = ptr2;
@@ -3027,65 +2917,65 @@
 
 	if (*ptr == '\0') {
 		/* The proper way to reject foreign keys for temporary
-		   tables would be to split the lexing and syntactical
-		   analysis of foreign key clauses from the actual adding
-		   of them, so that ha_innodb.cc could first parse the SQL
-		   command, determine if there are any foreign keys, and
-		   if so, immediately reject the command if the table is a
-		   temporary one. For now, this kludge will work. */
-		if (reject_fks && (UT_LIST_GET_LEN(table->foreign_list) > 0))
-		{
-			return DB_CANNOT_ADD_CONSTRAINT;
+		tables would be to split the lexing and syntactical
+		analysis of foreign key clauses from the actual adding
+		of them, so that ha_innodb.cc could first parse the SQL
+		command, determine if there are any foreign keys, and
+		if so, immediately reject the command if the table is a
+		temporary one. For now, this kludge will work. */
+		if (reject_fks && (UT_LIST_GET_LEN(table->foreign_list) > 0)) {
+
+			return(DB_CANNOT_ADD_CONSTRAINT);
 		}
-		
+
 		/**********************************************************/
 		/* The following call adds the foreign key constraints
 		to the data dictionary system tables on disk */
-		
+
 		error = dict_create_add_foreigns_to_dictionary(
-						highest_id_so_far, table, trx);
+			highest_id_so_far, table, trx);
 		return(error);
 	}
 
 	start_of_latest_foreign = ptr;
 
-	ptr = dict_accept(ptr, "FOREIGN", &success);		
-	
+	ptr = dict_accept(cs, ptr, "FOREIGN", &success);
+
 	if (!success) {
 		goto loop;
 	}
 
-	if (!ib_isspace(*ptr)) {
-	        goto loop;
+	if (!my_isspace(cs, *ptr)) {
+		goto loop;
 	}
 
-	ptr = dict_accept(ptr, "KEY", &success);
+	ptr = dict_accept(cs, ptr, "KEY", &success);
 
 	if (!success) {
 		goto loop;
 	}
 
-	ptr = dict_accept(ptr, "(", &success);
+	ptr = dict_accept(cs, ptr, "(", &success);
 
 	if (!success) {
 		/* MySQL allows also an index id before the '('; we
 		skip it */
-		ptr = dict_skip_word(ptr, &success);
+		ptr = dict_skip_word(cs, ptr, &success);
 
 		if (!success) {
-			dict_foreign_report_syntax_err(name,
-					start_of_latest_foreign, ptr);
+			dict_foreign_report_syntax_err(
+				name, start_of_latest_foreign, ptr);
 
 			return(DB_CANNOT_ADD_CONSTRAINT);
 		}
 
-		ptr = dict_accept(ptr, "(", &success);
+		ptr = dict_accept(cs, ptr, "(", &success);
 
 		if (!success) {
 			/* We do not flag a syntax error here because in an
 			ALTER TABLE we may also have DROP FOREIGN KEY abc */
 
-		        goto loop;
+			goto loop;
 		}
 	}
 
@@ -3094,31 +2984,31 @@
 	/* Scan the columns in the first list */
 col_loop1:
 	ut_a(i < (sizeof column_names) / sizeof *column_names);
-	ptr = dict_scan_col(ptr, &success, table, columns + i,
-				heap, column_names + i);
+	ptr = dict_scan_col(cs, ptr, &success, table, columns + i,
+			    heap, column_names + i);
 	if (!success) {
 		mutex_enter(&dict_foreign_err_mutex);
 		dict_foreign_error_report_low(ef, name);
 		fprintf(ef, "%s:\nCannot resolve column name close to:\n%s\n",
-					start_of_latest_foreign, ptr);
+			start_of_latest_foreign, ptr);
 		mutex_exit(&dict_foreign_err_mutex);
 
 		return(DB_CANNOT_ADD_CONSTRAINT);
 	}
 
 	i++;
-	
-	ptr = dict_accept(ptr, ",", &success);
+
+	ptr = dict_accept(cs, ptr, ",", &success);
 
 	if (success) {
 		goto col_loop1;
 	}
-	
-	ptr = dict_accept(ptr, ")", &success);
+
+	ptr = dict_accept(cs, ptr, ")", &success);
 
 	if (!success) {
-		dict_foreign_report_syntax_err(name, start_of_latest_foreign,
-									ptr);
+		dict_foreign_report_syntax_err(
+			name, start_of_latest_foreign, ptr);
 		return(DB_CANNOT_ADD_CONSTRAINT);
 	}
 
@@ -3131,21 +3021,22 @@
 		mutex_enter(&dict_foreign_err_mutex);
 		dict_foreign_error_report_low(ef, name);
 		fputs("There is no index in table ", ef);
-		ut_print_name(ef, NULL, name);
+		ut_print_name(ef, NULL, TRUE, name);
 		fprintf(ef, " where the columns appear\n"
-"as the first columns. Constraint:\n%s\n"
-"See http://dev.mysql.com/doc/refman/5.0/en/innodb-foreign-key-constraints.html\n"
-"for correct foreign key definition.\n",
+			"as the first columns. Constraint:\n%s\n"
+			"See http://dev.mysql.com/doc/refman/5.1/en/"
+			"innodb-foreign-key-constraints.html\n"
+			"for correct foreign key definition.\n",
 			start_of_latest_foreign);
 		mutex_exit(&dict_foreign_err_mutex);
 
 		return(DB_CANNOT_ADD_CONSTRAINT);
 	}
-	ptr = dict_accept(ptr, "REFERENCES", &success);
+	ptr = dict_accept(cs, ptr, "REFERENCES", &success);
 
-	if (!success || !ib_isspace(*ptr)) {
-		dict_foreign_report_syntax_err(name, start_of_latest_foreign,
-									ptr);
+	if (!success || !my_isspace(cs, *ptr)) {
+		dict_foreign_report_syntax_err(
+			name, start_of_latest_foreign, ptr);
 		return(DB_CANNOT_ADD_CONSTRAINT);
 	}
 
@@ -3154,7 +3045,7 @@
 	foreign = dict_mem_foreign_create();
 
 	if (constraint_name) {
-		ulint	db_len;	
+		ulint	db_len;
 
 		/* Catenate 'databasename/' to the constraint name specified
 		by the user: we conceive the constraint as belonging to the
@@ -3163,8 +3054,8 @@
 
 		db_len = dict_get_db_name_len(table->name);
 
-		foreign->id = mem_heap_alloc(foreign->heap,
-				db_len + strlen(constraint_name) + 2);
+		foreign->id = mem_heap_alloc(
+			foreign->heap, db_len + strlen(constraint_name) + 2);
 
 		ut_memcpy(foreign->id, table->name, db_len);
 		foreign->id[db_len] = '/';
@@ -3173,18 +3064,20 @@
 
 	foreign->foreign_table = table;
 	foreign->foreign_table_name = mem_heap_strdup(foreign->heap,
-							table->name);
+						      table->name);
 	foreign->foreign_index = index;
 	foreign->n_fields = i;
 	foreign->foreign_col_names = mem_heap_alloc(foreign->heap,
-							i * sizeof(void*));
+						    i * sizeof(void*));
 	for (i = 0; i < foreign->n_fields; i++) {
-		foreign->foreign_col_names[i] =
-			mem_heap_strdup(foreign->heap, columns[i]->name);
+		foreign->foreign_col_names[i] = mem_heap_strdup(
+			foreign->heap,
+			dict_table_get_col_name(table,
+						dict_col_get_no(columns[i])));
 	}
-	
-	ptr = dict_scan_table_name(ptr, &referenced_table, name,
-				&success, heap, &referenced_table_name);
+
+	ptr = dict_scan_table_name(cs, ptr, &referenced_table, name,
+				   &success, heap, &referenced_table_name);
 
 	/* Note that referenced_table can be NULL if the user has suppressed
 	checking of foreign key constraints! */
@@ -3201,13 +3094,13 @@
 
 		return(DB_CANNOT_ADD_CONSTRAINT);
 	}
-	
-	ptr = dict_accept(ptr, "(", &success);
+
+	ptr = dict_accept(cs, ptr, "(", &success);
 
 	if (!success) {
 		dict_foreign_free(foreign);
 		dict_foreign_report_syntax_err(name, start_of_latest_foreign,
-									ptr);
+					       ptr);
 		return(DB_CANNOT_ADD_CONSTRAINT);
 	}
 
@@ -3215,10 +3108,10 @@
 	i = 0;
 
 col_loop2:
-	ptr = dict_scan_col(ptr, &success, referenced_table, columns + i,
-				heap, column_names + i);
+	ptr = dict_scan_col(cs, ptr, &success, referenced_table, columns + i,
+			    heap, column_names + i);
 	i++;
-	
+
 	if (!success) {
 		dict_foreign_free(foreign);
 
@@ -3232,45 +3125,45 @@
 		return(DB_CANNOT_ADD_CONSTRAINT);
 	}
 
-	ptr = dict_accept(ptr, ",", &success);
+	ptr = dict_accept(cs, ptr, ",", &success);
 
 	if (success) {
 		goto col_loop2;
 	}
-	
-	ptr = dict_accept(ptr, ")", &success);
+
+	ptr = dict_accept(cs, ptr, ")", &success);
 
 	if (!success || foreign->n_fields != i) {
 		dict_foreign_free(foreign);
-		
+
 		dict_foreign_report_syntax_err(name, start_of_latest_foreign,
-									ptr);
+					       ptr);
 		return(DB_CANNOT_ADD_CONSTRAINT);
 	}
 
 	n_on_deletes = 0;
 	n_on_updates = 0;
-	
+
 scan_on_conditions:
 	/* Loop here as long as we can find ON ... conditions */
 
-	ptr = dict_accept(ptr, "ON", &success);
+	ptr = dict_accept(cs, ptr, "ON", &success);
 
 	if (!success) {
 
 		goto try_find_index;
 	}
 
-	ptr = dict_accept(ptr, "DELETE", &success);
+	ptr = dict_accept(cs, ptr, "DELETE", &success);
 
 	if (!success) {
-		ptr = dict_accept(ptr, "UPDATE", &success);
+		ptr = dict_accept(cs, ptr, "UPDATE", &success);
 
 		if (!success) {
 			dict_foreign_free(foreign);
-		
-			dict_foreign_report_syntax_err(name,
-						start_of_latest_foreign, ptr);
+
+			dict_foreign_report_syntax_err(
+				name, start_of_latest_foreign, ptr);
 			return(DB_CANNOT_ADD_CONSTRAINT);
 		}
 
@@ -3281,13 +3174,13 @@
 		n_on_deletes++;
 	}
 
-	ptr = dict_accept(ptr, "RESTRICT", &success);
+	ptr = dict_accept(cs, ptr, "RESTRICT", &success);
 
 	if (success) {
 		goto scan_on_conditions;
 	}
 
-	ptr = dict_accept(ptr, "CASCADE", &success);
+	ptr = dict_accept(cs, ptr, "CASCADE", &success);
 
 	if (success) {
 		if (is_on_delete) {
@@ -3299,16 +3192,16 @@
 		goto scan_on_conditions;
 	}
 
-	ptr = dict_accept(ptr, "NO", &success);
+	ptr = dict_accept(cs, ptr, "NO", &success);
 
 	if (success) {
-		ptr = dict_accept(ptr, "ACTION", &success);
+		ptr = dict_accept(cs, ptr, "ACTION", &success);
 
 		if (!success) {
 			dict_foreign_free(foreign);
-			dict_foreign_report_syntax_err(name,
-					start_of_latest_foreign, ptr);
-		
+			dict_foreign_report_syntax_err(
+				name, start_of_latest_foreign, ptr);
+
 			return(DB_CANNOT_ADD_CONSTRAINT);
 		}
 
@@ -3321,28 +3214,27 @@
 		goto scan_on_conditions;
 	}
 
-	ptr = dict_accept(ptr, "SET", &success);
+	ptr = dict_accept(cs, ptr, "SET", &success);
 
 	if (!success) {
 		dict_foreign_free(foreign);
 		dict_foreign_report_syntax_err(name, start_of_latest_foreign,
-									ptr);
+					       ptr);
 		return(DB_CANNOT_ADD_CONSTRAINT);
 	}
 
-	ptr = dict_accept(ptr, "NULL", &success);
+	ptr = dict_accept(cs, ptr, "NULL", &success);
 
 	if (!success) {
 		dict_foreign_free(foreign);
 		dict_foreign_report_syntax_err(name, start_of_latest_foreign,
-									ptr);
+					       ptr);
 		return(DB_CANNOT_ADD_CONSTRAINT);
 	}
 
 	for (j = 0; j < foreign->n_fields; j++) {
-		if ((dict_index_get_nth_type(
-				foreign->foreign_index, j)->prtype)
-				& DATA_NOT_NULL) {
+		if ((dict_index_get_nth_col(foreign->foreign_index, j)->prtype)
+		    & DATA_NOT_NULL) {
 
 			/* It is not sensible to define SET NULL
 			if the column is not allowed to be NULL! */
@@ -3352,8 +3244,10 @@
 			mutex_enter(&dict_foreign_err_mutex);
 			dict_foreign_error_report_low(ef, name);
 			fprintf(ef, "%s:\n"
-		"You have defined a SET NULL condition though some of the\n"
-		"columns are defined as NOT NULL.\n", start_of_latest_foreign);
+				"You have defined a SET NULL condition"
+				" though some of the\n"
+				"columns are defined as NOT NULL.\n",
+				start_of_latest_foreign);
 			mutex_exit(&dict_foreign_err_mutex);
 
 			return(DB_CANNOT_ADD_CONSTRAINT);
@@ -3365,19 +3259,20 @@
 	} else {
 		foreign->type |= DICT_FOREIGN_ON_UPDATE_SET_NULL;
 	}
-	
+
 	goto scan_on_conditions;
 
 try_find_index:
 	if (n_on_deletes > 1 || n_on_updates > 1) {
 		/* It is an error to define more than 1 action */
-		
+
 		dict_foreign_free(foreign);
 
 		mutex_enter(&dict_foreign_err_mutex);
 		dict_foreign_error_report_low(ef, name);
 		fprintf(ef, "%s:\n"
-"You have twice an ON DELETE clause or twice an ON UPDATE clause.\n",
+			"You have twice an ON DELETE clause"
+			" or twice an ON UPDATE clause.\n",
 			start_of_latest_foreign);
 		mutex_exit(&dict_foreign_err_mutex);
 
@@ -3390,20 +3285,28 @@
 
 	if (referenced_table) {
 		index = dict_foreign_find_index(referenced_table,
-			column_names, i, foreign->foreign_index, TRUE);
+						column_names, i,
+						foreign->foreign_index, TRUE);
 		if (!index) {
 			dict_foreign_free(foreign);
 			mutex_enter(&dict_foreign_err_mutex);
 			dict_foreign_error_report_low(ef, name);
 			fprintf(ef, "%s:\n"
-"Cannot find an index in the referenced table where the\n"
-"referenced columns appear as the first columns, or column types\n"
-"in the table and the referenced table do not match for constraint.\n"
-"Note that the internal storage type of ENUM and SET changed in\n"
-"tables created with >= InnoDB-4.1.12, and such columns in old tables\n"
-"cannot be referenced by such columns in new tables.\n"
-"See http://dev.mysql.com/doc/refman/5.0/en/innodb-foreign-key-constraints.html\n"
-"for correct foreign key definition.\n",
+				"Cannot find an index in the"
+				" referenced table where the\n"
+				"referenced columns appear as the"
+				" first columns, or column types\n"
+				"in the table and the referenced table"
+				" do not match for constraint.\n"
+				"Note that the internal storage type of"
+				" ENUM and SET changed in\n"
+				"tables created with >= InnoDB-4.1.12,"
+				" and such columns in old tables\n"
+				"cannot be referenced by such columns"
+				" in new tables.\n"
+				"See http://dev.mysql.com/doc/refman/5.1/en/"
+				"innodb-foreign-key-constraints.html\n"
+				"for correct foreign key definition.\n",
 				start_of_latest_foreign);
 			mutex_exit(&dict_foreign_err_mutex);
 
@@ -3417,29 +3320,48 @@
 	foreign->referenced_index = index;
 	foreign->referenced_table = referenced_table;
 
-	foreign->referenced_table_name = mem_heap_strdup(foreign->heap,
-						referenced_table_name);
-					
+	foreign->referenced_table_name
+		= mem_heap_strdup(foreign->heap, referenced_table_name);
+
 	foreign->referenced_col_names = mem_heap_alloc(foreign->heap,
-							i * sizeof(void*));
+						       i * sizeof(void*));
 	for (i = 0; i < foreign->n_fields; i++) {
 		foreign->referenced_col_names[i]
 			= mem_heap_strdup(foreign->heap, column_names[i]);
 	}
 
 	/* We found an ok constraint definition: add to the lists */
-	
+
 	UT_LIST_ADD_LAST(foreign_list, table->foreign_list, foreign);
 
 	if (referenced_table) {
 		UT_LIST_ADD_LAST(referenced_list,
-					referenced_table->referenced_list,
-								foreign);
+				 referenced_table->referenced_list,
+				 foreign);
 	}
 
 	goto loop;
 }
 
+/**************************************************************************
+Determines whether a string starts with the specified keyword. */
+
+ibool
+dict_str_starts_with_keyword(
+/*=========================*/
+					/* out: TRUE if str starts
+					with keyword */
+	void*		mysql_thd,	/* in: MySQL thread handle */
+	const char*	str,		/* in: string to scan for keyword */
+	const char*	keyword)	/* in: keyword to look for */
+{
+	struct charset_info_st*	cs	= innobase_get_charset(mysql_thd);
+	ibool			success;
+
+	dict_accept(cs, str, keyword, &success);
+	return(success);
+}
+
 /*************************************************************************
 Scans a table create SQL string and adds to the data dictionary the foreign
 key constraints declared in the string. This function should be called after
@@ -3467,20 +3389,23 @@
 					code DB_CANNOT_ADD_CONSTRAINT if
 					any foreign keys are found. */
 {
-	char*		str;
-	ulint		err;
-	mem_heap_t*	heap;
+	char*			str;
+	ulint			err;
+	mem_heap_t*		heap;
+
+	ut_a(trx && trx->mysql_thd);
 
 	str = dict_strip_comments(sql_string);
 	heap = mem_heap_create(10000);
 
-	err = dict_create_foreign_constraints_low(trx, heap, str, name,
+	err = dict_create_foreign_constraints_low(
+		trx, heap, innobase_get_charset(trx->mysql_thd), str, name,
 		reject_fks);
 
 	mem_heap_free(heap);
 	mem_free(str);
 
-	return(err);	
+	return(err);
 }
 
 /**************************************************************************
@@ -3502,13 +3427,18 @@
 	const char***	constraints_to_drop)	/* out: id's of the
 						constraints to drop */
 {
-	dict_foreign_t*	foreign;
-	ibool		success;
-	char*		str;
-	const char*	ptr;
-	const char*	id;
-	FILE*		ef	= dict_foreign_err_file;
-	
+	dict_foreign_t*		foreign;
+	ibool			success;
+	char*			str;
+	const char*		ptr;
+	const char*		id;
+	FILE*			ef	= dict_foreign_err_file;
+	struct charset_info_st*	cs;
+
+	ut_a(trx && trx->mysql_thd);
+
+	cs = innobase_get_charset(trx->mysql_thd);
+
 	*n = 0;
 
 	*constraints_to_drop = mem_heap_alloc(heap, 1000 * sizeof(char*));
@@ -3524,32 +3454,32 @@
 
 	if (*ptr == '\0') {
 		mem_free(str);
-		
+
 		return(DB_SUCCESS);
 	}
 
-	ptr = dict_accept(ptr, "DROP", &success);
+	ptr = dict_accept(cs, ptr, "DROP", &success);
 
-	if (!ib_isspace(*ptr)) {
+	if (!my_isspace(cs, *ptr)) {
 
-	        goto loop;
+		goto loop;
 	}
 
-	ptr = dict_accept(ptr, "FOREIGN", &success);
-	
+	ptr = dict_accept(cs, ptr, "FOREIGN", &success);
+
 	if (!success) {
 
-	        goto loop;
+		goto loop;
 	}
 
-	ptr = dict_accept(ptr, "KEY", &success);
+	ptr = dict_accept(cs, ptr, "KEY", &success);
 
 	if (!success) {
 
 		goto syntax_error;
 	}
 
-	ptr = dict_scan_id(ptr, heap, &id, TRUE);
+	ptr = dict_scan_id(cs, ptr, heap, &id, FALSE, TRUE);
 
 	if (id == NULL) {
 
@@ -3559,7 +3489,7 @@
 	ut_a(*n < 1000);
 	(*constraints_to_drop)[*n] = id;
 	(*n)++;
-	
+
 	/* Look for the given constraint id */
 
 	foreign = UT_LIST_GET_FIRST(table->foreign_list);
@@ -3568,11 +3498,11 @@
 		if (0 == strcmp(foreign->id, id)
 		    || (strchr(foreign->id, '/')
 			&& 0 == strcmp(id,
-					dict_remove_db_name(foreign->id)))) {
+				       dict_remove_db_name(foreign->id)))) {
 			/* Found */
 			break;
 		}
-		
+
 		foreign = UT_LIST_GET_NEXT(foreign_list, foreign);
 	}
 
@@ -3580,14 +3510,14 @@
 		mutex_enter(&dict_foreign_err_mutex);
 		rewind(ef);
 		ut_print_timestamp(ef);
-		fputs(
-	" Error in dropping of a foreign key constraint of table ", ef);
-		ut_print_name(ef, NULL, table->name);
+		fputs(" Error in dropping of a foreign key constraint"
+		      " of table ", ef);
+		ut_print_name(ef, NULL, TRUE, table->name);
 		fputs(",\n"
-			"in SQL command\n", ef);
+		      "in SQL command\n", ef);
 		fputs(str, ef);
 		fputs("\nCannot find a constraint with the given id ", ef);
-		ut_print_name(ef, NULL, id);
+		ut_print_name(ef, NULL, FALSE, id);
 		fputs(".\n", ef);
 		mutex_exit(&dict_foreign_err_mutex);
 
@@ -3596,15 +3526,15 @@
 		return(DB_CANNOT_DROP_CONSTRAINT);
 	}
 
-	goto loop;	
+	goto loop;
 
 syntax_error:
 	mutex_enter(&dict_foreign_err_mutex);
 	rewind(ef);
 	ut_print_timestamp(ef);
-	fputs(
-	" Syntax error in dropping of a foreign key constraint of table ", ef);
-	ut_print_name(ef, NULL, table->name);
+	fputs(" Syntax error in dropping of a"
+	      " foreign key constraint of table ", ef);
+	ut_print_name(ef, NULL, TRUE, table->name);
 	fprintf(ef, ",\n"
 		"close to:\n%s\n in SQL command\n%s\n", ptr, str);
 	mutex_exit(&dict_foreign_err_mutex);
@@ -3613,9 +3543,11 @@
 
 	return(DB_CANNOT_DROP_CONSTRAINT);
 }
+#endif /* UNIV_HOTBACKUP */
 
 /*==================== END OF FOREIGN KEY PROCESSING ====================*/
 
+#ifdef UNIV_DEBUG
 /**************************************************************************
 Returns an index object if it is found in the dictionary cache. */
 
@@ -3625,7 +3557,6 @@
 				/* out: index, NULL if not found */
 	dulint	index_id)	/* in: index id */
 {
-	dict_table_t*	table;
 	dict_index_t*	index;
 
 	if (dict_sys == NULL) {
@@ -3633,273 +3564,69 @@
 	}
 
 	mutex_enter(&(dict_sys->mutex));
-	
-	table = UT_LIST_GET_FIRST(dict_sys->table_LRU);
-
-	while (table) {
-		index = UT_LIST_GET_FIRST(table->indexes);
-
-		while (index) {
-			if (0 == ut_dulint_cmp(index->id, index_id)) {
-
-				goto found;
-			}
-
-			index = UT_LIST_GET_NEXT(indexes, index);
-		}
 
-		table = UT_LIST_GET_NEXT(table_LRU, table);
-	}
+	index = dict_index_find_on_id_low(index_id);
 
-	index = NULL;
-found:
 	mutex_exit(&(dict_sys->mutex));
 
 	return(index);
 }
+#endif /* UNIV_DEBUG */
 
-/**************************************************************************
-Creates an index tree struct. */
-
-dict_tree_t*
-dict_tree_create(
-/*=============*/
-				/* out, own: created tree */
-	dict_index_t*	index,	/* in: the index for which to create: in the
-				case of a mixed tree, this should be the
-				index of the cluster object */
-	ulint		page_no)/* in: root page number of the index */
-{
-	dict_tree_t*	tree;
-
-	tree = mem_alloc(sizeof(dict_tree_t));
-
-	/* Inherit info from the index */
-
-	tree->type = index->type;
-	tree->space = index->space;
-	tree->page = page_no;
-
-	tree->id = index->id;
-	
-	UT_LIST_INIT(tree->tree_indexes);
-
-	tree->magic_n = DICT_TREE_MAGIC_N;
-
-	rw_lock_create(&(tree->lock));
-
-	rw_lock_set_level(&(tree->lock), SYNC_INDEX_TREE);
-
-	return(tree);
-}
-
-/**************************************************************************
-Frees an index tree struct. */
-
-void
-dict_tree_free(
-/*===========*/
-	dict_tree_t*	tree)	/* in, own: index tree */
-{
-	ut_a(tree);
-	ut_ad(tree->magic_n == DICT_TREE_MAGIC_N);
-
-	rw_lock_free(&(tree->lock));
-	mem_free(tree);
-}
-
-/**************************************************************************
-In an index tree, finds the index corresponding to a record in the tree. */
-UNIV_INLINE
-dict_index_t*
-dict_tree_find_index_low(
-/*=====================*/
-				/* out: index */
-	dict_tree_t*	tree,	/* in: index tree */
-	rec_t*		rec)	/* in: record for which to find correct
-				index */
-{
-	dict_index_t*	index;
-	dict_table_t*	table;
-	dulint		mix_id;
-	ulint		len;
-	
-	index = UT_LIST_GET_FIRST(tree->tree_indexes);
-	ut_ad(index);
-	table = index->table;
-	
-	if ((index->type & DICT_CLUSTERED)
-			&& UNIV_UNLIKELY(table->type != DICT_TABLE_ORDINARY)) {
-
-		/* Get the mix id of the record */
-		ut_a(!table->comp);
-
-		mix_id = mach_dulint_read_compressed(
-			rec_get_nth_field_old(rec, table->mix_len, &len));
-
-		while (ut_dulint_cmp(table->mix_id, mix_id) != 0) {
-
-			index = UT_LIST_GET_NEXT(tree_indexes, index);
-			table = index->table;
-			ut_ad(index);
-		}
-	}
-
-	return(index);
-}
-
-/**************************************************************************
-In an index tree, finds the index corresponding to a record in the tree. */
-
-dict_index_t*
-dict_tree_find_index(
-/*=================*/
-				/* out: index */
-	dict_tree_t*	tree,	/* in: index tree */
-	rec_t*		rec)	/* in: record for which to find correct
-				index */
-{
-	dict_index_t*	index;
-	
-	index = dict_tree_find_index_low(tree, rec);
-	
-	return(index);
-}
-
-/**************************************************************************
-In an index tree, finds the index corresponding to a dtuple which is used
-in a search to a tree. */
-
-dict_index_t*
-dict_tree_find_index_for_tuple(
-/*===========================*/
-				/* out: index; NULL if the tuple does not
-				contain the mix id field in a mixed tree */
-	dict_tree_t*	tree,	/* in: index tree */
-	dtuple_t*	tuple)	/* in: tuple for which to find index */
-{
-	dict_index_t*	index;
-	dict_table_t*	table;
-	dulint		mix_id;
-
-	ut_ad(dtuple_check_typed(tuple));
-	
-	if (UT_LIST_GET_LEN(tree->tree_indexes) == 1) {
-
-		return(UT_LIST_GET_FIRST(tree->tree_indexes));
-	}
-
-	index = UT_LIST_GET_FIRST(tree->tree_indexes);
-	ut_ad(index);
-	table = index->table;
-
-	if (dtuple_get_n_fields(tuple) <= table->mix_len) {
-
-		return(NULL);
-	}
-
-	/* Get the mix id of the record */
-
-	mix_id = mach_dulint_read_compressed(
-			dfield_get_data(
-				dtuple_get_nth_field(tuple, table->mix_len)));
-
-	while (ut_dulint_cmp(table->mix_id, mix_id) != 0) {
-
-		index = UT_LIST_GET_NEXT(tree_indexes, index);
-		table = index->table;
-		ut_ad(index);
-	}
-
-	return(index);
-}
-
-/***********************************************************************
-Checks if a table which is a mixed cluster member owns a record. */
-
-ibool
-dict_is_mixed_table_rec(
-/*====================*/
-				/* out: TRUE if the record belongs to this
-				table */
-	dict_table_t*	table,	/* in: table in a mixed cluster */
-	rec_t*		rec)	/* in: user record in the clustered index */
-{
-	byte*	mix_id_field;
-	ulint	len;
-
-	ut_ad(!table->comp);
-
-	mix_id_field = rec_get_nth_field_old(rec,
-					table->mix_len, &len);
-
-	return(len == table->mix_id_len
-		&& !ut_memcmp(table->mix_id_buf, mix_id_field, len));
-}
-
+#ifdef UNIV_DEBUG
 /**************************************************************************
 Checks that a tuple has n_fields_cmp value in a sensible range, so that
 no comparison can occur with the page number field in a node pointer. */
 
 ibool
-dict_tree_check_search_tuple(
-/*=========================*/
+dict_index_check_search_tuple(
+/*==========================*/
 				/* out: TRUE if ok */
-	dict_tree_t*	tree,	/* in: index tree */
+	dict_index_t*	index,	/* in: index tree */
 	dtuple_t*	tuple)	/* in: tuple used in a search */
 {
-	dict_index_t*	index;
-
-	index = dict_tree_find_index_for_tuple(tree, tuple);
-
-	if (index == NULL) {
-
-		return(TRUE);
-	}
-
+	ut_a(index);
 	ut_a(dtuple_get_n_fields_cmp(tuple)
-				<= dict_index_get_n_unique_in_tree(index));
+	     <= dict_index_get_n_unique_in_tree(index));
 	return(TRUE);
 }
+#endif /* UNIV_DEBUG */
 
 /**************************************************************************
 Builds a node pointer out of a physical record and a page number. */
 
 dtuple_t*
-dict_tree_build_node_ptr(
-/*=====================*/
+dict_index_build_node_ptr(
+/*======================*/
 				/* out, own: node pointer */
-	dict_tree_t*	tree,	/* in: index tree */
+	dict_index_t*	index,	/* in: index tree */
 	rec_t*		rec,	/* in: record for which to build node
 				pointer */
 	ulint		page_no,/* in: page number to put in node pointer */
 	mem_heap_t*	heap,	/* in: memory heap where pointer created */
-	ulint           level)  /* in: level of rec in tree: 0 means leaf
+	ulint		level)	/* in: level of rec in tree: 0 means leaf
 				level */
 {
 	dtuple_t*	tuple;
-	dict_index_t*	ind;
 	dfield_t*	field;
 	byte*		buf;
 	ulint		n_unique;
 
-	ind = dict_tree_find_index_low(tree, rec);
-	
-	if (UNIV_UNLIKELY(tree->type & DICT_UNIVERSAL)) {
+	if (UNIV_UNLIKELY(index->type & DICT_UNIVERSAL)) {
 		/* In a universal index tree, we take the whole record as
-		the node pointer if the reord is on the leaf level,
+		the node pointer if the record is on the leaf level,
 		on non-leaf levels we remove the last field, which
 		contains the page number of the child page */
 
-		ut_a(!ind->table->comp);
+		ut_a(!dict_table_is_comp(index->table));
 		n_unique = rec_get_n_fields_old(rec);
 
 		if (level > 0) {
-		        ut_a(n_unique > 1);
-		        n_unique--;
+			ut_a(n_unique > 1);
+			n_unique--;
 		}
-	} else {	
-		n_unique = dict_index_get_n_unique_in_tree(ind);
+	} else {
+		n_unique = dict_index_get_n_unique_in_tree(index);
 	}
 
 	tuple = dtuple_create(heap, n_unique + 1);
@@ -3909,52 +3636,50 @@
 	levels in the tree there may be identical node pointers with a
 	different page number; therefore, we set the n_fields_cmp to one
 	less: */
-	
+
 	dtuple_set_n_fields_cmp(tuple, n_unique);
 
-	dict_index_copy_types(tuple, ind, n_unique);
-	
+	dict_index_copy_types(tuple, index, n_unique);
+
 	buf = mem_heap_alloc(heap, 4);
 
 	mach_write_to_4(buf, page_no);
-	
+
 	field = dtuple_get_nth_field(tuple, n_unique);
 	dfield_set_data(field, buf, 4);
 
-	dtype_set(dfield_get_type(field), DATA_SYS_CHILD, DATA_NOT_NULL, 4, 0);
+	dtype_set(dfield_get_type(field), DATA_SYS_CHILD, DATA_NOT_NULL, 4);
 
-	rec_copy_prefix_to_dtuple(tuple, rec, ind, n_unique, heap);
-	dtuple_set_info_bits(tuple, dtuple_get_info_bits(tuple) |
-					REC_STATUS_NODE_PTR);
+	rec_copy_prefix_to_dtuple(tuple, rec, index, n_unique, heap);
+	dtuple_set_info_bits(tuple, dtuple_get_info_bits(tuple)
+			     | REC_STATUS_NODE_PTR);
 
 	ut_ad(dtuple_check_typed(tuple));
 
 	return(tuple);
-}	
-	
+}
+
 /**************************************************************************
 Copies an initial segment of a physical record, long enough to specify an
 index entry uniquely. */
 
 rec_t*
-dict_tree_copy_rec_order_prefix(
-/*============================*/
+dict_index_copy_rec_order_prefix(
+/*=============================*/
 				/* out: pointer to the prefix record */
-	dict_tree_t*	tree,	/* in: index tree */
+	dict_index_t*	index,	/* in: index tree */
 	rec_t*		rec,	/* in: record for which to copy prefix */
 	ulint*		n_fields,/* out: number of fields copied */
 	byte**		buf,	/* in/out: memory buffer for the copied prefix,
 				or NULL */
 	ulint*		buf_size)/* in/out: buffer size */
 {
-	dict_index_t*	index;
 	ulint		n;
 
 	UNIV_PREFETCH_R(rec);
-	index = dict_tree_find_index_low(tree, rec);
 
-	if (UNIV_UNLIKELY(tree->type & DICT_UNIVERSAL)) {
-		ut_a(!index->table->comp);
+	if (UNIV_UNLIKELY(index->type & DICT_UNIVERSAL)) {
+		ut_a(!dict_table_is_comp(index->table));
 		n = rec_get_n_fields_old(rec);
 	} else {
 		n = dict_index_get_n_unique_in_tree(index);
@@ -3968,32 +3693,30 @@
 Builds a typed data tuple out of a physical record. */
 
 dtuple_t*
-dict_tree_build_data_tuple(
-/*=======================*/
+dict_index_build_data_tuple(
+/*========================*/
 				/* out, own: data tuple */
-	dict_tree_t*	tree,	/* in: index tree */
+	dict_index_t*	index,	/* in: index tree */
 	rec_t*		rec,	/* in: record for which to build data tuple */
 	ulint		n_fields,/* in: number of data fields */
 	mem_heap_t*	heap)	/* in: memory heap where tuple created */
 {
 	dtuple_t*	tuple;
-	dict_index_t*	ind;
 
-	ind = dict_tree_find_index_low(tree, rec);
+	ut_ad(dict_table_is_comp(index->table)
+	      || n_fields <= rec_get_n_fields_old(rec));
 
-	ut_ad(ind->table->comp || n_fields <= rec_get_n_fields_old(rec));
-	
-	tuple = dtuple_create(heap, n_fields); 
+	tuple = dtuple_create(heap, n_fields);
 
-	dict_index_copy_types(tuple, ind, n_fields);
+	dict_index_copy_types(tuple, index, n_fields);
 
-	rec_copy_prefix_to_dtuple(tuple, rec, ind, n_fields, heap);
+	rec_copy_prefix_to_dtuple(tuple, rec, index, n_fields, heap);
 
 	ut_ad(dtuple_check_typed(tuple));
 
 	return(tuple);
-}	
-	
+}
+
 /*************************************************************************
 Calculates the minimum record length in an index. */
 
@@ -4005,19 +3728,21 @@
 	ulint	sum	= 0;
 	ulint	i;
 
-	if (UNIV_LIKELY(index->table->comp)) {
+	if (dict_table_is_comp(index->table)) {
 		ulint nullable = 0;
 		sum = REC_N_NEW_EXTRA_BYTES;
 		for (i = 0; i < dict_index_get_n_fields(index); i++) {
-			dtype_t*t = dict_index_get_nth_type(index, i);
-			ulint	size = dtype_get_fixed_size(t);
+			const dict_col_t*	col
+				= dict_index_get_nth_col(index, i);
+			ulint	size = dict_col_get_fixed_size(col);
 			sum += size;
 			if (!size) {
-				size = dtype_get_len(t);
+				size = col->len;
 				sum += size < 128 ? 1 : 2;
 			}
-			if (!(dtype_get_prtype(t) & DATA_NOT_NULL))
+			if (!(col->prtype & DATA_NOT_NULL)) {
 				nullable++;
+			}
 		}
 
 		/* round the NULL flags up to full bytes */
@@ -4027,7 +3752,8 @@
 	}
 
 	for (i = 0; i < dict_index_get_n_fields(index); i++) {
-		sum += dtype_get_fixed_size(dict_index_get_nth_type(index, i));
+		sum += dict_col_get_fixed_size(
+			dict_index_get_nth_col(index, i));
 	}
 
 	if (sum > 127) {
@@ -4050,8 +3776,8 @@
 /*=======================*/
 	dict_table_t*	table,		/* in: table */
 	ibool		has_dict_mutex __attribute__((unused)))
-                                        /* in: TRUE if the caller has the
-					dictionary mutex */	
+					/* in: TRUE if the caller has the
+					dictionary mutex */
 {
 	dict_index_t*	index;
 	ulint		size;
@@ -4061,8 +3787,10 @@
 		ut_print_timestamp(stderr);
 		fprintf(stderr,
 			"  InnoDB: cannot calculate statistics for table %s\n"
-"InnoDB: because the .ibd file is missing.  For help, please refer to\n"
-"InnoDB: http://dev.mysql.com/doc/refman/5.0/en/innodb-troubleshooting.html\n",
+			"InnoDB: because the .ibd file is missing.  For help,"
+			" please refer to\n"
+			"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/"
+			"innodb-troubleshooting.html\n",
 			table->name);
 
 		return;
@@ -4079,11 +3807,11 @@
 	/* Find out the sizes of the indexes and how many different values
 	for the key they approximately have */
 
-	index = dict_table_get_first_index(table);	
+	index = dict_table_get_first_index(table);
 
 	if (index == NULL) {
 		/* Table definition is corrupt */
-	
+
 		return;
 	}
 
@@ -4102,7 +3830,7 @@
 		}
 
 		index->stat_n_leaf_pages = size;
-		
+
 		btr_estimate_number_of_different_key_vals(index);
 
 		index = dict_table_get_next_index(index);
@@ -4111,16 +3839,16 @@
 	index = dict_table_get_first_index(table);
 
 	table->stat_n_rows = index->stat_n_diff_key_vals[
-					dict_index_get_n_unique(index)];
+		dict_index_get_n_unique(index)];
 
 	table->stat_clustered_index_size = index->stat_index_size;
 
 	table->stat_sum_of_other_index_sizes = sum_of_index_sizes
-						- index->stat_index_size;
+		- index->stat_index_size;
 
 	table->stat_initialized = TRUE;
 
-        table->stat_modified_counter = 0;
+	table->stat_modified_counter = 0;
 }
 
 /*************************************************************************
@@ -4136,6 +3864,18 @@
 }
 
 /**************************************************************************
+A noninlined version of dict_table_get_low. */
+
+dict_table_t*
+dict_table_get_low_noninlined(
+/*==========================*/
+					/* out: table, NULL if not found */
+	const char*	table_name)	/* in: table name */
+{
+	return(dict_table_get_low(table_name));
+}
+
+/**************************************************************************
 Prints info of a foreign key constraint. */
 static
 void
@@ -4159,7 +3899,7 @@
 	fprintf(stderr, " )\n"
 		"             REFERENCES %s (",
 		foreign->referenced_table_name);
-	
+
 	for (i = 0; i < foreign->n_fields; i++) {
 		fprintf(stderr, " %s", foreign->referenced_col_names[i]);
 	}
@@ -4195,7 +3935,7 @@
 	table = dict_table_get_low(name);
 
 	ut_a(table);
-	
+
 	dict_table_print_low(table);
 	mutex_exit(&(dict_sys->mutex));
 }
@@ -4217,20 +3957,21 @@
 #endif /* UNIV_SYNC_DEBUG */
 
 	dict_update_statistics_low(table, TRUE);
-	
+
 	fprintf(stderr,
-"--------------------------------------\n"
-"TABLE: name %s, id %lu %lu, columns %lu, indexes %lu, appr.rows %lu\n"
-"  COLUMNS: ",
-			table->name,
-			(ulong) ut_dulint_get_high(table->id),
-			(ulong) ut_dulint_get_low(table->id),
-			(ulong) table->n_cols,
-		        (ulong) UT_LIST_GET_LEN(table->indexes),
-			(ulong) table->stat_n_rows);
+		"--------------------------------------\n"
+		"TABLE: name %s, id %lu %lu, columns %lu, indexes %lu,"
+		" appr.rows %lu\n"
+		"  COLUMNS: ",
+		table->name,
+		(ulong) ut_dulint_get_high(table->id),
+		(ulong) ut_dulint_get_low(table->id),
+		(ulong) table->n_cols,
+		(ulong) UT_LIST_GET_LEN(table->indexes),
+		(ulong) table->stat_n_rows);
 
-	for (i = 0; i < table->n_cols - 1; i++) {
-		dict_col_print_low(dict_table_get_nth_col(table, i));
+	for (i = 0; i + 1 < (ulint) table->n_cols; i++) {
+		dict_col_print_low(table, dict_table_get_nth_col(table, i));
 		fputs("; ", stderr);
 	}
 
@@ -4264,18 +4005,20 @@
 void
 dict_col_print_low(
 /*===============*/
-	dict_col_t*	col)	/* in: column */
+	const dict_table_t*	table,	/* in: table */
+	const dict_col_t*	col)	/* in: column */
 {
-	dtype_t*	type;
+	dtype_t	type;
 
 #ifdef UNIV_SYNC_DEBUG
 	ut_ad(mutex_own(&(dict_sys->mutex)));
 #endif /* UNIV_SYNC_DEBUG */
 
-	type = dict_col_get_type(col);
-	fprintf(stderr, "%s: ", col->name);
+	dict_col_copy_type(col, &type);
+	fprintf(stderr, "%s: ", dict_table_get_col_name(table,
+							dict_col_get_no(col)));
 
-	dtype_print(type);
+	dtype_print(&type);
 }
 
 /**************************************************************************
@@ -4286,7 +4029,6 @@
 /*=================*/
 	dict_index_t*	index)	/* in: index */
 {
-	dict_tree_t*	tree;
 	ib_longlong	n_vals;
 	ulint		i;
 
@@ -4294,30 +4036,31 @@
 	ut_ad(mutex_own(&(dict_sys->mutex)));
 #endif /* UNIV_SYNC_DEBUG */
 
-	tree = index->tree;
-
 	if (index->n_user_defined_cols > 0) {
 		n_vals = index->stat_n_diff_key_vals[
-					index->n_user_defined_cols];
+			index->n_user_defined_cols];
 	} else {
 		n_vals = index->stat_n_diff_key_vals[1];
 	}
 
 	fprintf(stderr,
-		"  INDEX: name %s, id %lu %lu, fields %lu/%lu, type %lu\n"
+		"  INDEX: name %s, id %lu %lu, fields %lu/%lu,"
+		" uniq %lu, type %lu\n"
 		"   root page %lu, appr.key vals %lu,"
 		" leaf pages %lu, size pages %lu\n"
 		"   FIELDS: ",
 		index->name,
-		(ulong) ut_dulint_get_high(tree->id),
-		(ulong) ut_dulint_get_low(tree->id),
+		(ulong) ut_dulint_get_high(index->id),
+		(ulong) ut_dulint_get_low(index->id),
 		(ulong) index->n_user_defined_cols,
-		(ulong) index->n_fields, (ulong) index->type,
-		(ulong) tree->page,
+		(ulong) index->n_fields,
+		(ulong) index->n_uniq,
+		(ulong) index->type,
+		(ulong) index->page,
 		(ulong) n_vals,
 		(ulong) index->stat_n_leaf_pages,
 		(ulong) index->stat_index_size);
-			
+
 	for (i = 0; i < index->n_fields; i++) {
 		dict_field_print_low(dict_index_get_nth_field(index, i));
 	}
@@ -4325,9 +4068,9 @@
 	putc('\n', stderr);
 
 #ifdef UNIV_BTR_PRINT
-	btr_print_size(tree);
+	btr_print_size(index);
 
-	btr_print_tree(tree, 7);
+	btr_print_index(index, 7);
 #endif /* UNIV_BTR_PRINT */
 }
 
@@ -4363,33 +4106,33 @@
 {
 	const char*	stripped_id;
 	ulint	i;
-	
+
 	if (strchr(foreign->id, '/')) {
 		/* Strip the preceding database name from the constraint id */
 		stripped_id = foreign->id + 1
-				+ dict_get_db_name_len(foreign->id);
+			+ dict_get_db_name_len(foreign->id);
 	} else {
 		stripped_id = foreign->id;
 	}
 
 	putc(',', file);
-	
+
 	if (add_newline) {
 		/* SHOW CREATE TABLE wants constraints each printed nicely
 		on its own line, while error messages want no newlines
 		inserted. */
 		fputs("\n ", file);
 	}
-	
+
 	fputs(" CONSTRAINT ", file);
-	ut_print_name(file, trx, stripped_id);
+	ut_print_name(file, trx, FALSE, stripped_id);
 	fputs(" FOREIGN KEY (", file);
 
 	for (i = 0;;) {
-		ut_print_name(file, trx, foreign->foreign_col_names[i]);
+		ut_print_name(file, trx, FALSE, foreign->foreign_col_names[i]);
 		if (++i < foreign->n_fields) {
 			fputs(", ", file);
-	        } else {
+		} else {
 			break;
 		}
 	}
@@ -4397,29 +4140,22 @@
 	fputs(") REFERENCES ", file);
 
 	if (dict_tables_have_same_db(foreign->foreign_table_name,
-					foreign->referenced_table_name)) {
+				     foreign->referenced_table_name)) {
 		/* Do not print the database name of the referenced table */
-		ut_print_name(file, trx, dict_remove_db_name(
-					foreign->referenced_table_name));
+		ut_print_name(file, trx, TRUE,
+			      dict_remove_db_name(
+				      foreign->referenced_table_name));
 	} else {
-		/* Look for the '/' in the table name */
-
-		i = 0;
-		while (foreign->referenced_table_name[i] != '/') {
-			i++;
-		}
-
-		ut_print_namel(file, trx, foreign->referenced_table_name, i);
-		putc('.', file);
-		ut_print_name(file, trx,
-				foreign->referenced_table_name + i + 1);
+		ut_print_name(file, trx, TRUE,
+			      foreign->referenced_table_name);
 	}
 
 	putc(' ', file);
 	putc('(', file);
 
 	for (i = 0;;) {
-		ut_print_name(file, trx, foreign->referenced_col_names[i]);
+		ut_print_name(file, trx, FALSE,
+			      foreign->referenced_col_names[i]);
 		if (++i < foreign->n_fields) {
 			fputs(", ", file);
 		} else {
@@ -4432,7 +4168,7 @@
 	if (foreign->type & DICT_FOREIGN_ON_DELETE_CASCADE) {
 		fputs(" ON DELETE CASCADE", file);
 	}
-	
+
 	if (foreign->type & DICT_FOREIGN_ON_DELETE_SET_NULL) {
 		fputs(" ON DELETE SET NULL", file);
 	}
@@ -4444,7 +4180,7 @@
 	if (foreign->type & DICT_FOREIGN_ON_UPDATE_CASCADE) {
 		fputs(" ON UPDATE CASCADE", file);
 	}
-	
+
 	if (foreign->type & DICT_FOREIGN_ON_UPDATE_SET_NULL) {
 		fputs(" ON UPDATE SET NULL", file);
 	}
@@ -4483,7 +4219,7 @@
 	while (foreign != NULL) {
 		if (create_table_format) {
 			dict_print_info_on_foreign_key_in_create_format(
-						file, trx, foreign, TRUE);
+				file, trx, foreign, TRUE);
 		} else {
 			ulint	i;
 			fputs("; (", file);
@@ -4493,20 +4229,21 @@
 					putc(' ', file);
 				}
 
-				ut_print_name(file, trx,
-					foreign->foreign_col_names[i]);
+				ut_print_name(file, trx, FALSE,
+					      foreign->foreign_col_names[i]);
 			}
 
 			fputs(") REFER ", file);
-			ut_print_name(file, trx,
-					foreign->referenced_table_name);
+			ut_print_name(file, trx, TRUE,
+				      foreign->referenced_table_name);
 			putc('(', file);
 
 			for (i = 0; i < foreign->n_fields; i++) {
 				if (i) {
 					putc(' ', file);
 				}
-				ut_print_name(file, trx,
+				ut_print_name(
+					file, trx, FALSE,
 					foreign->referenced_col_names[i]);
 			}
 
@@ -4515,7 +4252,7 @@
 			if (foreign->type == DICT_FOREIGN_ON_DELETE_CASCADE) {
 				fputs(" ON DELETE CASCADE", file);
 			}
-	
+
 			if (foreign->type == DICT_FOREIGN_ON_DELETE_SET_NULL) {
 				fputs(" ON DELETE SET NULL", file);
 			}
@@ -4527,7 +4264,7 @@
 			if (foreign->type & DICT_FOREIGN_ON_UPDATE_CASCADE) {
 				fputs(" ON UPDATE CASCADE", file);
 			}
-	
+
 			if (foreign->type & DICT_FOREIGN_ON_UPDATE_SET_NULL) {
 				fputs(" ON UPDATE SET NULL", file);
 			}
@@ -4553,7 +4290,7 @@
 	const dict_index_t*	index)	/* in: index to print */
 {
 	fputs("index ", file);
-	ut_print_name(file, trx, index->name);
+	ut_print_name(file, trx, FALSE, index->name);
 	fputs(" of table ", file);
-	ut_print_name(file, trx, index->table_name);
+	ut_print_name(file, trx, TRUE, index->table_name);
 }

--- 1.54.16.1/innobase/fil/fil0fil.c	2006-12-21 23:54:44 +01:00
+++ 1.75/storage/innobase/fil/fil0fil.c	2006-12-21 23:54:44 +01:00
@@ -27,7 +27,7 @@
 #include "mtr0log.h"
 #include "dict0dict.h"
 
-	 
+
 /*
 		IMPLEMENTATION OF THE TABLESPACE MEMORY CACHE
 		=============================================
@@ -69,7 +69,7 @@
 certainly prevents the OS from fragmenting disk space, but it is not clear
 if it really adds speed. We measured on the Pentium 100 MHz + NT + NTFS file
 system + EIDE Conner disk only a negligible difference in speed when reading
-from a file, versus reading from a raw disk. 
+from a file, versus reading from a raw disk.
 
 To have fast access to a tablespace or a log file, we put the data structures
 to a hash table. Each tablespace and log file is given an unique 32-bit
@@ -90,7 +90,7 @@
 const char*	fil_path_to_mysql_datadir	= ".";
 
 /* The number of fsyncs done to the log */
-ulint	fil_n_log_flushes                       = 0;
+ulint	fil_n_log_flushes			= 0;
 
 ulint	fil_n_pending_log_flushes		= 0;
 ulint	fil_n_pending_tablespace_flushes	= 0;
@@ -117,7 +117,7 @@
 	ulint		n_pending_flushes;
 				/* count of pending flushes on this file;
 				closing of the file is not allowed if
-				this is > 0 */	
+				this is > 0 */
 	ib_longlong	modification_counter;/* when we write to the file we
 				increment this by one */
 	ib_longlong	flush_counter;/* up to what modification_counter value
@@ -165,7 +165,7 @@
 	ulint		size;	/* space size in pages; 0 if a single-table
 				tablespace whose size we do not know yet;
 				last incomplete megabytes in data files may be
-				ignored if space == 0 */ 
+				ignored if space == 0 */
 	ulint		n_reserved_extents;
 				/* number of reserved free extents for
 				ongoing operations like B-tree page split */
@@ -177,7 +177,7 @@
 				may need to access the ibuf bitmap page in the
 				tablespade: dropping of the tablespace is
 				forbidden if this is > 0 */
-	hash_node_t	hash; 	/* hash chain node */
+	hash_node_t	hash;	/* hash chain node */
 	hash_node_t	name_hash;/* hash chain the name_hash table */
 	rw_lock_t	latch;	/* latch protecting the file space storage
 				allocation */
@@ -464,14 +464,14 @@
 
 	node->modification_counter = 0;
 	node->flush_counter = 0;
-	
+
 	HASH_SEARCH(hash, system->spaces, id, space, space->id == id);
 
 	if (!space) {
 		ut_print_timestamp(stderr);
 		fprintf(stderr,
-"  InnoDB: Error: Could not find tablespace %lu for\n"
-"InnoDB: file ", (ulong) id);
+			"  InnoDB: Error: Could not find tablespace %lu for\n"
+			"InnoDB: file ", (ulong) id);
 		ut_print_filename(stderr, name);
 		fputs(" in the tablespace memory cache.\n", stderr);
 		mem_free(node->name);
@@ -488,7 +488,7 @@
 	node->space = space;
 
 	UT_LIST_ADD_LAST(chain, space->chain, node);
-				
+
 	mutex_exit(&(system->mutex));
 }
 
@@ -507,10 +507,12 @@
 	ulint		size_low;
 	ulint		size_high;
 	ibool		ret;
+	ibool		success;
+#ifndef UNIV_HOTBACKUP
 	byte*		buf2;
 	byte*		page;
-	ibool		success;
 	ulint		space_id;
+#endif /* !UNIV_HOTBACKUP */
 
 #ifdef UNIV_SYNC_DEBUG
 	ut_ad(mutex_own(&(system->mutex)));
@@ -528,8 +530,7 @@
 		async I/O! */
 
 		node->handle = os_file_create_simple_no_error_handling(
-						node->name, OS_FILE_OPEN,
-						OS_FILE_READ_ONLY, &success);
+			node->name, OS_FILE_OPEN, OS_FILE_READ_ONLY, &success);
 		if (!success) {
 			/* The following call prints an error message */
 			os_file_get_last_error(TRUE);
@@ -537,30 +538,36 @@
 			ut_print_timestamp(stderr);
 
 			fprintf(stderr,
-"  InnoDB: Fatal error: cannot open %s\n."
-"InnoDB: Have you deleted .ibd files under a running mysqld server?\n",
+				"  InnoDB: Fatal error: cannot open %s\n."
+				"InnoDB: Have you deleted .ibd files"
+				" under a running mysqld server?\n",
 				node->name);
 			ut_a(0);
 		}
 
-		ut_a(space->purpose != FIL_LOG);
-		ut_a(space->id != 0);
-
 		os_file_get_size(node->handle, &size_low, &size_high);
 
 		size_bytes = (((ib_longlong)size_high) << 32)
-				     		+ (ib_longlong)size_low;
+			+ (ib_longlong)size_low;
 #ifdef UNIV_HOTBACKUP
 		node->size = (ulint) (size_bytes / UNIV_PAGE_SIZE);
 
 #else
+		ut_a(space->purpose != FIL_LOG);
+		ut_a(space->id != 0);
+
 		if (size_bytes < FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE) {
-	        	fprintf(stderr,
-"InnoDB: Error: the size of single-table tablespace file %s\n"
-"InnoDB: is only %lu %lu, should be at least %lu!\n", node->name,
-			(ulong) size_high,
-			(ulong) size_low, (ulong) (4 * UNIV_PAGE_SIZE));
-			
+			fprintf(stderr,
+				"InnoDB: Error: the size of single-table"
+				" tablespace file %s\n"
+				"InnoDB: is only %lu %lu,"
+				" should be at least %lu!\n",
+				node->name,
+				(ulong) size_high,
+				(ulong) size_low,
+				(ulong) (FIL_IBD_FILE_INITIAL_SIZE
+					 * UNIV_PAGE_SIZE));
+
 			ut_a(0);
 		}
 
@@ -572,35 +579,38 @@
 		page = ut_align(buf2, UNIV_PAGE_SIZE);
 
 		success = os_file_read(node->handle, page, 0, 0,
-							UNIV_PAGE_SIZE);
+				       UNIV_PAGE_SIZE);
 		space_id = fsp_header_get_space_id(page);
 
 		ut_free(buf2);
-		
+
 		/* Close the file now that we have read the space id from it */
 
 		os_file_close(node->handle);
 
 		if (space_id == ULINT_UNDEFINED || space_id == 0) {
-	        	fprintf(stderr,
-"InnoDB: Error: tablespace id %lu in file %s is not sensible\n",
-			(ulong) space_id,
-			node->name);
-			
-			ut_a(0);			
+			fprintf(stderr,
+				"InnoDB: Error: tablespace id %lu"
+				" in file %s is not sensible\n",
+				(ulong) space_id, node->name);
+
+			ut_a(0);
 		}
 
 		if (space_id != space->id) {
-	        	fprintf(stderr,
-"InnoDB: Error: tablespace id is %lu in the data dictionary\n"
-"InnoDB: but in file %s it is %lu!\n", space->id, node->name, space_id);
+			fprintf(stderr,
+				"InnoDB: Error: tablespace id is %lu"
+				" in the data dictionary\n"
+				"InnoDB: but in file %s it is %lu!\n",
+				space->id, node->name, space_id);
 
 			ut_a(0);
 		}
 
 		if (size_bytes >= FSP_EXTENT_SIZE * UNIV_PAGE_SIZE) {
-			node->size = (ulint) ((size_bytes / (1024 * 1024))
-					   * ((1024 * 1024) / UNIV_PAGE_SIZE));
+			node->size = (ulint)
+				((size_bytes / (1024 * 1024))
+				 * ((1024 * 1024) / UNIV_PAGE_SIZE));
 		} else {
 			node->size = (ulint) (size_bytes / UNIV_PAGE_SIZE);
 		}
@@ -614,20 +624,20 @@
 	unbuffered async I/O mode, though global variables may make
 	os_file_create() to fall back to the normal file I/O mode. */
 
-	if (space->purpose == FIL_LOG) {	
+	if (space->purpose == FIL_LOG) {
 		node->handle = os_file_create(node->name, OS_FILE_OPEN,
-					OS_FILE_AIO, OS_LOG_FILE, &ret);
+					      OS_FILE_AIO, OS_LOG_FILE, &ret);
 	} else if (node->is_raw_disk) {
 		node->handle = os_file_create(node->name,
-				        OS_FILE_OPEN_RAW,
-					OS_FILE_AIO, OS_DATA_FILE, &ret);
+					      OS_FILE_OPEN_RAW,
+					      OS_FILE_AIO, OS_DATA_FILE, &ret);
 	} else {
 		node->handle = os_file_create(node->name, OS_FILE_OPEN,
-					OS_FILE_AIO, OS_DATA_FILE, &ret);
+					      OS_FILE_AIO, OS_DATA_FILE, &ret);
 	}
-		
+
 	ut_a(ret);
-		
+
 	node->open = TRUE;
 
 	system->n_open++;
@@ -683,7 +693,7 @@
 fil_try_to_close_file_in_LRU(
 /*=========================*/
 				/* out: TRUE if success, FALSE if should retry
-				later; since i/o's generally complete in < 
+				later; since i/o's generally complete in <
 				100 ms, and as InnoDB writes at most 128 pages
 				from the buffer pool in a batch, and then
 				immediately flushes the files, there is a good
@@ -702,7 +712,8 @@
 
 	if (print_info) {
 		fprintf(stderr,
-"InnoDB: fil_sys open file LRU len %lu\n", (ulong) UT_LIST_GET_LEN(system->LRU));
+			"InnoDB: fil_sys open file LRU len %lu\n",
+			(ulong) UT_LIST_GET_LEN(system->LRU));
 	}
 
 	while (node != NULL) {
@@ -710,15 +721,15 @@
 		    && node->n_pending_flushes == 0) {
 
 			fil_node_close_file(node, system);
-			
+
 			return(TRUE);
 		}
-		
+
 		if (print_info && node->n_pending_flushes > 0) {
 			fputs("InnoDB: cannot close file ", stderr);
 			ut_print_filename(stderr, node->name);
 			fprintf(stderr, ", because n_pending_flushes %lu\n",
-				       (ulong) node->n_pending_flushes);
+				(ulong) node->n_pending_flushes);
 		}
 
 		if (print_info
@@ -776,7 +787,7 @@
 	}
 
 	HASH_SEARCH(hash, system->spaces, space_id, space,
-							space->id == space_id);
+		    space->id == space_id);
 	if (space != NULL && space->stop_ios) {
 		/* We are going to do a rename file and want to stop new i/o's
 		for a while */
@@ -829,10 +840,13 @@
 	if (count >= 2) {
 		ut_print_timestamp(stderr);
 		fprintf(stderr,
-"  InnoDB: Warning: too many (%lu) files stay open while the maximum\n"
-"InnoDB: allowed value would be %lu.\n"
-"InnoDB: You may need to raise the value of innodb_max_files_open in\n"
-"InnoDB: my.cnf.\n", (ulong) system->n_open, (ulong) system->max_n_open);
+			"  InnoDB: Warning: too many (%lu) files stay open"
+			" while the maximum\n"
+			"InnoDB: allowed value would be %lu.\n"
+			"InnoDB: You may need to raise the value of"
+			" innodb_max_files_open in\n"
+			"InnoDB: my.cnf.\n",
+			(ulong) system->n_open, (ulong) system->max_n_open);
 
 		return;
 	}
@@ -849,7 +863,7 @@
 	/* Flush tablespaces so that we can close modified files in the LRU
 	list */
 
-	fil_flush_file_spaces(FIL_TABLESPACE);		
+	fil_flush_file_spaces(FIL_TABLESPACE);
 
 	count++;
 
@@ -885,15 +899,15 @@
 			space->is_in_unflushed_spaces = FALSE;
 
 			UT_LIST_REMOVE(unflushed_spaces,
-					system->unflushed_spaces,
-					space);
+				       system->unflushed_spaces,
+				       space);
 		}
 
 		fil_node_close_file(node, system);
 	}
 
 	space->size -= node->size;
-	
+
 	UT_LIST_REMOVE(chain, space->chain, node);
 
 	mem_free(node->name);
@@ -921,7 +935,7 @@
 	HASH_SEARCH(hash, system->spaces, id, space, space->id == id);
 
 	ut_a(space);
-	
+
 	while (trunc_len > 0) {
 		node = UT_LIST_GET_FIRST(space->chain);
 
@@ -930,8 +944,8 @@
 		trunc_len -= node->size * UNIV_PAGE_SIZE;
 
 		fil_node_free(node, system, space);
-	}	
-				
+	}
+
 	mutex_exit(&(system->mutex));
 }
 
@@ -948,12 +962,12 @@
 	ulint		purpose)/* in: FIL_TABLESPACE, or FIL_LOG if log */
 {
 	fil_system_t*	system		= fil_system;
-	fil_space_t*	space;	
+	fil_space_t*	space;
 	ulint		namesake_id;
 try_again:
 	/*printf(
 	"InnoDB: Adding tablespace %lu of name %s, purpose %lu\n", id, name,
-	  purpose);*/
+	purpose);*/
 
 	ut_a(system);
 	ut_a(name);
@@ -961,16 +975,18 @@
 	mutex_enter(&(system->mutex));
 
 	HASH_SEARCH(name_hash, system->name_hash, ut_fold_string(name), space,
-					0 == strcmp(name, space->name));
+		    0 == strcmp(name, space->name));
 	if (space != NULL) {
 		ut_print_timestamp(stderr);
 		fprintf(stderr,
-"  InnoDB: Warning: trying to init to the tablespace memory cache\n"
-"InnoDB: a tablespace %lu of name ", (ulong) id);
+			"  InnoDB: Warning: trying to init to the"
+			" tablespace memory cache\n"
+			"InnoDB: a tablespace %lu of name ", (ulong) id);
 		ut_print_filename(stderr, name);
 		fprintf(stderr, ",\n"
-"InnoDB: but a tablespace %lu of the same name\n"
-"InnoDB: already exists in the tablespace memory cache!\n",
+			"InnoDB: but a tablespace %lu of the same name\n"
+			"InnoDB: already exists in the"
+			" tablespace memory cache!\n",
 			(ulong) space->id);
 
 		if (id == 0 || purpose != FIL_TABLESPACE) {
@@ -981,13 +997,19 @@
 		}
 
 		fprintf(stderr,
-"InnoDB: We assume that InnoDB did a crash recovery, and you had\n"
-"InnoDB: an .ibd file for which the table did not exist in the\n"
-"InnoDB: InnoDB internal data dictionary in the ibdata files.\n"
-"InnoDB: We assume that you later removed the .ibd and .frm files,\n"
-"InnoDB: and are now trying to recreate the table. We now remove the\n"
-"InnoDB: conflicting tablespace object from the memory cache and try\n"
-"InnoDB: the init again.\n");
+			"InnoDB: We assume that InnoDB did a crash recovery,"
+			" and you had\n"
+			"InnoDB: an .ibd file for which the table"
+			" did not exist in the\n"
+			"InnoDB: InnoDB internal data dictionary in the"
+			" ibdata files.\n"
+			"InnoDB: We assume that you later removed the"
+			" .ibd and .frm files,\n"
+			"InnoDB: and are now trying to recreate the table."
+			" We now remove the\n"
+			"InnoDB: conflicting tablespace object"
+			" from the memory cache and try\n"
+			"InnoDB: the init again.\n");
 
 		namesake_id = space->id;
 
@@ -1002,14 +1024,16 @@
 
 	if (space != NULL) {
 		fprintf(stderr,
-"InnoDB: Error: trying to add tablespace %lu of name ", (ulong) id);
+			"InnoDB: Error: trying to add tablespace %lu"
+			" of name ", (ulong) id);
 		ut_print_filename(stderr, name);
 		fprintf(stderr, "\n"
-"InnoDB: to the tablespace memory cache, but tablespace\n"
-"InnoDB: %lu of name ", (ulong) space->id);
+			"InnoDB: to the tablespace memory cache,"
+			" but tablespace\n"
+			"InnoDB: %lu of name ", (ulong) space->id);
 		ut_print_filename(stderr, space->name);
 		fputs(" already exists in the tablespace\n"
-"InnoDB: memory cache!\n", stderr);
+		      "InnoDB: memory cache!\n", stderr);
 
 		mutex_exit(&(system->mutex));
 
@@ -1036,7 +1060,7 @@
 	space->size = 0;
 
 	space->n_reserved_extents = 0;
-	
+
 	space->n_pending_flushes = 0;
 	space->n_pending_ibuf_merges = 0;
 
@@ -1044,18 +1068,17 @@
 	space->magic_n = FIL_SPACE_MAGIC_N;
 
 	space->ibuf_data = NULL;
-	
-	rw_lock_create(&(space->latch));
-	rw_lock_set_level(&(space->latch), SYNC_FSP);
-	
+
+	rw_lock_create(&space->latch, SYNC_FSP);
+
 	HASH_INSERT(fil_space_t, hash, system->spaces, id, space);
 
 	HASH_INSERT(fil_space_t, name_hash, system->name_hash,
-						ut_fold_string(name), space);
+		    ut_fold_string(name), space);
 	space->is_in_unflushed_spaces = FALSE;
 
 	UT_LIST_ADD_LAST(space_list, system->space_list, space);
-				
+
 	mutex_exit(&(system->mutex));
 
 	return(TRUE);
@@ -1082,22 +1105,29 @@
 	id = system->max_assigned_id;
 
 	if (id > (SRV_LOG_SPACE_FIRST_ID / 2) && (id % 1000000UL == 0)) {
-	        ut_print_timestamp(stderr);
-	        fprintf(stderr,
-"InnoDB: Warning: you are running out of new single-table tablespace id's.\n"
-"InnoDB: Current counter is %lu and it must not exceed %lu!\n"
-"InnoDB: To reset the counter to zero you have to dump all your tables and\n"
-"InnoDB: recreate the whole InnoDB installation.\n", (ulong) id,
-					(ulong) SRV_LOG_SPACE_FIRST_ID);
+		ut_print_timestamp(stderr);
+		fprintf(stderr,
+			"InnoDB: Warning: you are running out of new"
+			" single-table tablespace id's.\n"
+			"InnoDB: Current counter is %lu and it"
+			" must not exceed %lu!\n"
+			"InnoDB: To reset the counter to zero"
+			" you have to dump all your tables and\n"
+			"InnoDB: recreate the whole InnoDB installation.\n",
+			(ulong) id,
+			(ulong) SRV_LOG_SPACE_FIRST_ID);
 	}
 
 	if (id >= SRV_LOG_SPACE_FIRST_ID) {
-	        ut_print_timestamp(stderr);
-	        fprintf(stderr,
-"InnoDB: You have run out of single-table tablespace id's!\n"
-"InnoDB: Current counter is %lu.\n"
-"InnoDB: To reset the counter to zero you have to dump all your tables and\n"
-"InnoDB: recreate the whole InnoDB installation.\n", (ulong) id);
+		ut_print_timestamp(stderr);
+		fprintf(stderr,
+			"InnoDB: You have run out of single-table"
+			" tablespace id's!\n"
+			"InnoDB: Current counter is %lu.\n"
+			"InnoDB: To reset the counter to zero you"
+			" have to dump all your tables and\n"
+			"InnoDB: recreate the whole InnoDB installation.\n",
+			(ulong) id);
 		system->max_assigned_id--;
 
 		id = ULINT_UNDEFINED;
@@ -1131,11 +1161,12 @@
 	if (!space) {
 		ut_print_timestamp(stderr);
 		fprintf(stderr,
-"  InnoDB: Error: trying to remove tablespace %lu from the cache but\n"
-"InnoDB: it is not there.\n", (ulong) id);
+			"  InnoDB: Error: trying to remove tablespace %lu"
+			" from the cache but\n"
+			"InnoDB: it is not there.\n", (ulong) id);
 
 		mutex_exit(&(system->mutex));
-		
+
 		return(FALSE);
 	}
 
@@ -1147,13 +1178,13 @@
 	ut_a(space == namespace);
 
 	HASH_DELETE(fil_space_t, name_hash, system->name_hash,
-					   ut_fold_string(space->name), space);
+		    ut_fold_string(space->name), space);
 
 	if (space->is_in_unflushed_spaces) {
 		space->is_in_unflushed_spaces = FALSE;
 
 		UT_LIST_REMOVE(unflushed_spaces, system->unflushed_spaces,
-								space);
+			       space);
 	}
 
 	UT_LIST_REMOVE(space_list, system->space_list, space);
@@ -1167,8 +1198,8 @@
 		fil_node_free(fil_node, system, space);
 
 		fil_node = UT_LIST_GET_FIRST(space->chain);
-	}	
-	
+	}
+
 	ut_a(0 == UT_LIST_GET_LEN(space->chain));
 
 	mutex_exit(&(system->mutex));
@@ -1214,7 +1245,7 @@
 			/* out: space size, 0 if space not found */
 	ulint	id)	/* in: space id */
 {
-	fil_system_t*	system 		= fil_system;
+	fil_system_t*	system		= fil_system;
 	fil_node_t*	node;
 	fil_space_t*	space;
 	ulint		size;
@@ -1247,7 +1278,7 @@
 	}
 
 	size = space->size;
-	
+
 	mutex_exit(&(system->mutex));
 
 	return(size);
@@ -1270,7 +1301,7 @@
 	}
 
 	return(FALSE);
-}		
+}
 
 /********************************************************************
 Creates a the tablespace memory cache. */
@@ -1290,9 +1321,7 @@
 
 	system = mem_alloc(sizeof(fil_system_t));
 
-	mutex_create(&(system->mutex));
-
-	mutex_set_level(&(system->mutex), SYNC_ANY_LATCH);
+	mutex_create(&system->mutex, SYNC_ANY_LATCH);
 
 	system->spaces = hash0_create(hash_size);
 	system->name_hash = hash0_create(hash_size);
@@ -1360,17 +1389,28 @@
 			while (node != NULL) {
 				if (!node->open) {
 					fil_node_open_file(node, system,
-									space);
+							   space);
 				}
 				if (system->max_n_open < 10 + system->n_open) {
 					fprintf(stderr,
-"InnoDB: Warning: you must raise the value of innodb_max_open_files in\n"
-"InnoDB: my.cnf! Remember that InnoDB keeps all log files and all system\n"
-"InnoDB: tablespace files open for the whole time mysqld is running, and\n"
-"InnoDB: needs to open also some .ibd files if the file-per-table storage\n"
-"InnoDB: model is used. Current open files %lu, max allowed open files %lu.\n",
-				     (ulong) system->n_open,
-				     (ulong) system->max_n_open);
+						"InnoDB: Warning: you must"
+						" raise the value of"
+						" innodb_max_open_files in\n"
+						"InnoDB: my.cnf! Remember that"
+						" InnoDB keeps all log files"
+						" and all system\n"
+						"InnoDB: tablespace files open"
+						" for the whole time mysqld is"
+						" running, and\n"
+						"InnoDB: needs to open also"
+						" some .ibd files if the"
+						" file-per-table storage\n"
+						"InnoDB: model is used."
+						" Current open files %lu,"
+						" max allowed"
+						" open files %lu.\n",
+						(ulong) system->n_open,
+						(ulong) system->max_n_open);
 				}
 				node = UT_LIST_GET_NEXT(chain, node);
 			}
@@ -1425,7 +1465,8 @@
 
 	if (max_id >= SRV_LOG_SPACE_FIRST_ID) {
 		fprintf(stderr,
-"InnoDB: Fatal error: max tablespace id is too high, %lu\n", (ulong) max_id);
+			"InnoDB: Fatal error: max tablespace id"
+			" is too high, %lu\n", (ulong) max_id);
 		ut_a(0);
 	}
 
@@ -1453,7 +1494,7 @@
 	space = UT_LIST_GET_FIRST(fil_system->space_list);
 
 	ut_a(space);
-        ut_a(space->purpose == FIL_TABLESPACE);	
+	ut_a(space->purpose == FIL_TABLESPACE);
 
 	space->ibuf_data = ibuf_data_init_for_space(space->id);
 }
@@ -1484,7 +1525,7 @@
 
 	fil_write(TRUE, space_id, sum_of_sizes, 0, UNIV_PAGE_SIZE, buf, NULL);
 
-	return(DB_SUCCESS);	
+	return(DB_SUCCESS);
 }
 
 /********************************************************************
@@ -1504,9 +1545,9 @@
 	ulint		err;
 
 	mutex_enter(&(fil_system->mutex));
-	
+
 	space = UT_LIST_GET_FIRST(fil_system->space_list);
-	
+
 	while (space) {
 		/* We only write the lsn to all existing data files which have
 		been open during the lifetime of the mysqld process; they are
@@ -1523,8 +1564,8 @@
 				mutex_exit(&(fil_system->mutex));
 
 				err = fil_write_lsn_and_arch_no_to_file(
-						space->id, sum_of_sizes,
-						lsn, arch_log_no);
+					space->id, sum_of_sizes, lsn,
+					arch_log_no);
 				if (err != DB_SUCCESS) {
 
 					return(err);
@@ -1568,7 +1609,7 @@
 	buf2 = ut_malloc(2 * UNIV_PAGE_SIZE);
 	/* Align the memory for a possible read from a raw device */
 	buf = ut_align(buf2, UNIV_PAGE_SIZE);
-	
+
 	os_file_read(data_file, buf, 0, 0, UNIV_PAGE_SIZE);
 
 	flushed_lsn = mach_read_from_8(buf + FIL_PAGE_FILE_FLUSH_LSN);
@@ -1616,14 +1657,15 @@
 {
 	fil_system_t*	system		= fil_system;
 	fil_space_t*	space;
-	
+
 	mutex_enter(&(system->mutex));
 
 	HASH_SEARCH(hash, system->spaces, id, space, space->id == id);
 
 	if (space == NULL) {
 		fprintf(stderr,
-"InnoDB: Error: trying to do ibuf merge to a dropped tablespace %lu\n",
+			"InnoDB: Error: trying to do ibuf merge to a"
+			" dropped tablespace %lu\n",
 			(ulong) id);
 	}
 
@@ -1645,19 +1687,20 @@
 
 void
 fil_decr_pending_ibuf_merges(
-/*========================*/
+/*=========================*/
 	ulint	id)	/* in: space id */
 {
 	fil_system_t*	system		= fil_system;
 	fil_space_t*	space;
-	
+
 	mutex_enter(&(system->mutex));
 
 	HASH_SEARCH(hash, system->spaces, id, space, space->id == id);
 
 	if (space == NULL) {
 		fprintf(stderr,
-"InnoDB: Error: decrementing ibuf merge of a dropped tablespace %lu\n",
+			"InnoDB: Error: decrementing ibuf merge of a"
+			" dropped tablespace %lu\n",
 			(ulong) id);
 	}
 
@@ -1711,7 +1754,7 @@
 	const char*	name,		/* in: table name in the familiar
 					'databasename/tablename' format, or
 					the file path in the case of
-					MLOG_FILE_DELETE */ 
+					MLOG_FILE_DELETE */
 	const char*	new_name,	/* in: if type is MLOG_FILE_RENAME,
 					the new table name in the
 					'databasename/tablename' format */
@@ -1729,7 +1772,7 @@
 	}
 
 	log_ptr = mlog_write_initial_log_record_for_file_op(type, space_id, 0,
-								log_ptr, mtr);
+							    log_ptr, mtr);
 	/* Let us store the strings as null-terminated for easier readability
 	and handling */
 
@@ -1770,13 +1813,13 @@
 byte*
 fil_op_log_parse_or_replay(
 /*=======================*/
-                        	/* out: end of log record, or NULL if the
+				/* out: end of log record, or NULL if the
 				record was not completely contained between
 				ptr and end_ptr */
-        byte*   ptr,    	/* in: buffer containing the log record body,
+	byte*	ptr,		/* in: buffer containing the log record body,
 				or an initial segment of it, if the record does
 				not fir completely between ptr and end_ptr */
-        byte*   end_ptr,	/* in: buffer end */
+	byte*	end_ptr,	/* in: buffer end */
 	ulint	type,		/* in: the type of this log record */
 	ibool	do_replay,	/* in: TRUE if we want to replay the
 				operation, and not just parse the log record */
@@ -1799,7 +1842,7 @@
 	ptr += 2;
 
 	if (end_ptr < ptr + name_len) {
-		
+
 		return(NULL);
 	}
 
@@ -1814,11 +1857,11 @@
 		}
 
 		new_name_len = mach_read_from_2(ptr);
-		
+
 		ptr += 2;
 
 		if (end_ptr < ptr + new_name_len) {
-		
+
 			return(NULL);
 		}
 
@@ -1828,14 +1871,14 @@
 	}
 
 	/* We managed to parse a full log record body */
-/*
+	/*
 	printf("Parsed log rec of type %lu space %lu\n"
-		"name %s\n", type, space_id, name);
+	"name %s\n", type, space_id, name);
 
 	if (type == MLOG_FILE_RENAME) {
-		printf("new name %s\n", new_name);
+	printf("new name %s\n", new_name);
 	}
-*/
+	*/
 	if (do_replay == FALSE) {
 
 		return(ptr);
@@ -1844,7 +1887,7 @@
 	/* Let us try to perform the file operation, if sensible. Note that
 	ibbackup has at this stage already read in all space id info to the
 	fil0fil.c data structures.
-	
+
 	NOTE that our algorithm is not guaranteed to work correctly if there
 	were renames of tables during the backup. See ibbackup code for more
 	on the problem. */
@@ -1863,7 +1906,7 @@
 			/* Create the database directory for the new name, if
 			it does not exist yet */
 			fil_create_directory_for_tablename(new_name);
-	
+
 			/* Rename the table if there is not yet a tablespace
 			with the same name */
 
@@ -1871,8 +1914,10 @@
 			    == ULINT_UNDEFINED) {
 				/* We do not care of the old name, that is
 				why we pass NULL as the first argument */
-				ut_a(fil_rename_tablespace(NULL, space_id,
-								new_name));
+				if (!fil_rename_tablespace(NULL, space_id,
+							   new_name)) {
+					ut_error;
+				}
 			}
 		}
 	} else {
@@ -1880,8 +1925,8 @@
 
 		if (fil_tablespace_exists_in_mem(space_id)) {
 			/* Do nothing */
-		} else if (fil_get_space_id_for_table(name) !=
-							ULINT_UNDEFINED) {
+		} else if (fil_get_space_id_for_table(name)
+			   != ULINT_UNDEFINED) {
 			/* Do nothing */
 		} else {
 			/* Create the database directory for name, if it does
@@ -1890,10 +1935,11 @@
 
 			ut_a(space_id != 0);
 
-			ut_a(DB_SUCCESS == 
-				fil_create_new_single_table_tablespace(
-						&space_id, name, FALSE,
-						FIL_IBD_FILE_INITIAL_SIZE));
+			if (fil_create_new_single_table_tablespace(
+				    &space_id, name, FALSE,
+				    FIL_IBD_FILE_INITIAL_SIZE) != DB_SUCCESS) {
+				ut_error;
+			}
 		}
 	}
 
@@ -1934,14 +1980,16 @@
 			goto try_again;
 		} else {
 			if (count > 5000) {
-			   ut_print_timestamp(stderr);
-			   fputs(
-"  InnoDB: Warning: trying to delete tablespace ", stderr);
-			   ut_print_filename(stderr, space->name);
-			   fprintf(stderr, ",\n"
-"InnoDB: but there are %lu pending ibuf merges on it.\n"
-"InnoDB: Loop %lu.\n", (ulong) space->n_pending_ibuf_merges,
-				   (ulong) count);
+				ut_print_timestamp(stderr);
+				fputs("  InnoDB: Warning: trying to"
+				      " delete tablespace ", stderr);
+				ut_print_filename(stderr, space->name);
+				fprintf(stderr, ",\n"
+					"InnoDB: but there are %lu pending"
+					" ibuf merges on it.\n"
+					"InnoDB: Loop %lu.\n",
+					(ulong) space->n_pending_ibuf_merges,
+					(ulong) count);
 			}
 
 			mutex_exit(&(system->mutex));
@@ -1964,14 +2012,15 @@
 	if (space == NULL) {
 		ut_print_timestamp(stderr);
 		fprintf(stderr,
-"  InnoDB: Error: cannot delete tablespace %lu\n"
-"InnoDB: because it is not found in the tablespace memory cache.\n",
+			"  InnoDB: Error: cannot delete tablespace %lu\n"
+			"InnoDB: because it is not found in the"
+			" tablespace memory cache.\n",
 			(ulong) id);
 
 		mutex_exit(&(system->mutex));
-	
+
 		return(FALSE);
-	}	
+	}
 
 	ut_a(space);
 	ut_a(space->n_pending_ibuf_merges == 0);
@@ -1984,12 +2033,14 @@
 	if (space->n_pending_flushes > 0 || node->n_pending > 0) {
 		if (count > 1000) {
 			ut_print_timestamp(stderr);
-			fputs(
-"  InnoDB: Warning: trying to delete tablespace ", stderr);
+			fputs("  InnoDB: Warning: trying to"
+			      " delete tablespace ", stderr);
 			ut_print_filename(stderr, space->name);
 			fprintf(stderr, ",\n"
-"InnoDB: but there are %lu flushes and %lu pending i/o's on it\n"
-"InnoDB: Loop %lu.\n", (ulong) space->n_pending_flushes,
+				"InnoDB: but there are %lu flushes"
+				" and %lu pending i/o's on it\n"
+				"InnoDB: Loop %lu.\n",
+				(ulong) space->n_pending_flushes,
 				(ulong) node->n_pending,
 				(ulong) count);
 		}
@@ -2072,9 +2123,11 @@
 
 	if (!success) {
 		fprintf(stderr,
-"InnoDB: Warning: cannot delete tablespace %lu in DISCARD TABLESPACE.\n"
-"InnoDB: But let us remove the insert buffer entries for this tablespace.\n",
-			(ulong) id); 
+			"InnoDB: Warning: cannot delete tablespace %lu"
+			" in DISCARD TABLESPACE.\n"
+			"InnoDB: But let us remove the"
+			" insert buffer entries for this tablespace.\n",
+			(ulong) id);
 	}
 
 	/* Remove all insert buffer entries for the tablespace */
@@ -2098,9 +2151,9 @@
 	fil_system_t*	system		= fil_system;
 	fil_space_t*	space2;
 	const char*	old_name	= space->name;
-	
+
 	HASH_SEARCH(name_hash, system->name_hash, ut_fold_string(old_name),
-			       space2, 0 == strcmp(old_name, space2->name));
+		    space2, 0 == strcmp(old_name, space2->name));
 	if (space != space2) {
 		fputs("InnoDB: Error: cannot find ", stderr);
 		ut_print_filename(stderr, old_name);
@@ -2110,17 +2163,17 @@
 	}
 
 	HASH_SEARCH(name_hash, system->name_hash, ut_fold_string(path),
-			       space2, 0 == strcmp(path, space2->name));
+		    space2, 0 == strcmp(path, space2->name));
 	if (space2 != NULL) {
 		fputs("InnoDB: Error: ", stderr);
 		ut_print_filename(stderr, path);
 		fputs(" is already in tablespace memory cache\n", stderr);
-		
+
 		return(FALSE);
 	}
 
 	HASH_DELETE(fil_space_t, name_hash, system->name_hash,
-					   ut_fold_string(space->name), space);
+		    ut_fold_string(space->name), space);
 	mem_free(space->name);
 	mem_free(node->name);
 
@@ -2128,7 +2181,7 @@
 	node->name = mem_strdup(path);
 
 	HASH_INSERT(fil_space_t, name_hash, system->name_hash,
-						ut_fold_string(path), space);
+		    ut_fold_string(path), space);
 	return(TRUE);
 }
 
@@ -2187,11 +2240,11 @@
 	fil_node_t*	node;
 	ulint		count		= 0;
 	char*		path;
-	ibool		old_name_was_specified 		= TRUE;
+	ibool		old_name_was_specified		= TRUE;
 	char*		old_path;
 
 	ut_a(id != 0);
-	
+
 	if (old_name == NULL) {
 		old_name = "(name not specified)";
 		old_name_was_specified = FALSE;
@@ -2214,8 +2267,9 @@
 
 	if (space == NULL) {
 		fprintf(stderr,
-"InnoDB: Error: cannot find space id %lu from the tablespace memory cache\n"
-"InnoDB: though the table ", (ulong) id);
+			"InnoDB: Error: cannot find space id %lu"
+			" in the tablespace memory cache\n"
+			"InnoDB: though the table ", (ulong) id);
 		ut_print_filename(stderr, old_name);
 		fputs(" in a rename operation should have that id\n", stderr);
 		mutex_exit(&(system->mutex));
@@ -2289,7 +2343,7 @@
 			to the tablespace memory cache */
 
 			ut_a(fil_rename_tablespace_in_mem(space, node,
-								old_path));
+							  old_path));
 		}
 	}
 
@@ -2300,14 +2354,14 @@
 
 	mutex_exit(&(system->mutex));
 
-#ifndef UNIV_HOTBACKUP	
+#ifndef UNIV_HOTBACKUP
 	if (success) {
 		mtr_t		mtr;
 
 		mtr_start(&mtr);
 
 		fil_op_write_log(MLOG_FILE_RENAME, id, old_name, new_name,
-								&mtr);
+				 &mtr);
 		mtr_commit(&mtr);
 	}
 #endif
@@ -2338,7 +2392,7 @@
 					tablespace file in pages,
 					must be >= FIL_IBD_FILE_INITIAL_SIZE */
 {
-	os_file_t       file;
+	os_file_t	file;
 	ibool		ret;
 	ulint		err;
 	byte*		buf2;
@@ -2349,9 +2403,9 @@
 	ut_a(size >= FIL_IBD_FILE_INITIAL_SIZE);
 
 	path = fil_make_ibd_name(tablename, is_temp);
-	
+
 	file = os_file_create(path, OS_FILE_CREATE, OS_FILE_NORMAL,
-						    OS_DATA_FILE, &ret);
+			      OS_DATA_FILE, &ret);
 	if (ret == FALSE) {
 		ut_print_timestamp(stderr);
 		fputs("  InnoDB: Error creating file ", stderr);
@@ -2359,20 +2413,26 @@
 		fputs(".\n", stderr);
 
 		/* The following call will print an error message */
-		 
+
 		err = os_file_get_last_error(TRUE);
-		
+
 		if (err == OS_FILE_ALREADY_EXISTS) {
-		        fputs(
-"InnoDB: The file already exists though the corresponding table did not\n"
-"InnoDB: exist in the InnoDB data dictionary. Have you moved InnoDB\n"
-"InnoDB: .ibd files around without using the SQL commands\n"
-"InnoDB: DISCARD TABLESPACE and IMPORT TABLESPACE, or did\n"
-"InnoDB: mysqld crash in the middle of CREATE TABLE? You can\n"
-"InnoDB: resolve the problem by removing the file ", stderr);
+			fputs("InnoDB: The file already exists though"
+			      " the corresponding table did not\n"
+			      "InnoDB: exist in the InnoDB data dictionary."
+			      " Have you moved InnoDB\n"
+			      "InnoDB: .ibd files around without using the"
+			      " SQL commands\n"
+			      "InnoDB: DISCARD TABLESPACE and"
+			      " IMPORT TABLESPACE, or did\n"
+			      "InnoDB: mysqld crash in the middle of"
+			      " CREATE TABLE? You can\n"
+			      "InnoDB: resolve the problem by"
+			      " removing the file ", stderr);
 			ut_print_filename(stderr, path);
 			fputs("\n"
-"InnoDB: under the 'datadir' of MySQL.\n", stderr);
+			      "InnoDB: under the 'datadir' of MySQL.\n",
+			      stderr);
 
 			mem_free(path);
 			return(DB_TABLESPACE_ALREADY_EXISTS);
@@ -2393,7 +2453,7 @@
 	page = ut_align(buf2, UNIV_PAGE_SIZE);
 
 	ret = os_file_set_size(path, file, size * UNIV_PAGE_SIZE, 0);
-	
+
 	if (!ret) {
 		ut_free(buf2);
 		os_file_close(file);
@@ -2411,9 +2471,9 @@
 
 	if (*space_id == ULINT_UNDEFINED) {
 		ut_free(buf2);
-	error_exit:
+error_exit:
 		os_file_close(file);
-	error_exit2:
+error_exit2:
 		os_file_delete(path);
 
 		mem_free(path);
@@ -2431,7 +2491,7 @@
 
 	memset(page, '\0', UNIV_PAGE_SIZE);
 
-	fsp_header_write_space_id(page, *space_id);		
+	fsp_header_write_space_id(page, *space_id);
 
 	buf_flush_init_for_writing(page, ut_dulint_zero, *space_id, 0);
 
@@ -2440,8 +2500,8 @@
 	ut_free(buf2);
 
 	if (!ret) {
-		fputs(
-"InnoDB: Error: could not write the first page to tablespace ", stderr);
+		fputs("InnoDB: Error: could not write the first page"
+		      " to tablespace ", stderr);
 		ut_print_filename(stderr, path);
 		putc('\n', stderr);
 		goto error_exit;
@@ -2450,8 +2510,7 @@
 	ret = os_file_flush(file);
 
 	if (!ret) {
-		fputs(
-"InnoDB: Error: file flush of tablespace ", stderr);
+		fputs("InnoDB: Error: file flush of tablespace ", stderr);
 		ut_print_filename(stderr, path);
 		fputs(" failed\n", stderr);
 		goto error_exit;
@@ -2464,22 +2523,23 @@
 	}
 
 	success = fil_space_create(path, *space_id, FIL_TABLESPACE);
-	
+
 	if (!success) {
 		goto error_exit2;
-	}	
+	}
 
 	fil_node_create(path, size, *space_id, FALSE);
 
-#ifndef UNIV_HOTBACKUP	
+#ifndef UNIV_HOTBACKUP
 	{
-	mtr_t		mtr;
+		mtr_t		mtr;
 
-	mtr_start(&mtr);
+		mtr_start(&mtr);
 
-	fil_op_write_log(MLOG_FILE_CREATE, *space_id, tablename, NULL, &mtr);
+		fil_op_write_log(MLOG_FILE_CREATE, *space_id, tablename,
+				 NULL, &mtr);
 
-	mtr_commit(&mtr);
+		mtr_commit(&mtr);
 	}
 #endif
 	mem_free(path);
@@ -2519,17 +2579,17 @@
 
 	filepath = fil_make_ibd_name(name, FALSE);
 
-	file = os_file_create_simple_no_error_handling(filepath, OS_FILE_OPEN,
-						OS_FILE_READ_WRITE, &success);
+	file = os_file_create_simple_no_error_handling(
+		filepath, OS_FILE_OPEN, OS_FILE_READ_WRITE, &success);
 	if (!success) {
 		/* The following call prints an error message */
 		os_file_get_last_error(TRUE);
 
 		ut_print_timestamp(stderr);
 
-	        fputs(
-"  InnoDB: Error: trying to open a table, but could not\n"
-"InnoDB: open the tablespace file ", stderr);
+		fputs("  InnoDB: Error: trying to open a table,"
+		      " but could not\n"
+		      "InnoDB: open the tablespace file ", stderr);
 		ut_print_filename(stderr, filepath);
 		fputs("!\n", stderr);
 		mem_free(filepath);
@@ -2561,17 +2621,19 @@
 	}
 
 	space_id = fsp_header_get_space_id(page);
-	
+
 	ut_print_timestamp(stderr);
 	fprintf(stderr,
-" InnoDB: Flush lsn in the tablespace file %lu to be imported\n"
-"InnoDB: is %lu %lu, which exceeds current system lsn %lu %lu.\n"
-"InnoDB: We reset the lsn's in the file ",
-			    (ulong) space_id,
-			    (ulong) ut_dulint_get_high(flush_lsn),
-			    (ulong) ut_dulint_get_low(flush_lsn),
-			    (ulong) ut_dulint_get_high(current_lsn),
-			    (ulong) ut_dulint_get_low(current_lsn));
+		"  InnoDB: Flush lsn in the tablespace file %lu"
+		" to be imported\n"
+		"InnoDB: is %lu %lu, which exceeds current"
+		" system lsn %lu %lu.\n"
+		"InnoDB: We reset the lsn's in the file ",
+		(ulong) space_id,
+		(ulong) ut_dulint_get_high(flush_lsn),
+		(ulong) ut_dulint_get_low(flush_lsn),
+		(ulong) ut_dulint_get_high(current_lsn),
+		(ulong) ut_dulint_get_low(current_lsn));
 	ut_print_filename(stderr, filepath);
 	fputs(".\n", stderr);
 
@@ -2582,8 +2644,8 @@
 
 	for (offset = 0; offset < file_size; offset += UNIV_PAGE_SIZE) {
 		success = os_file_read(file, page,
-				(ulint)(offset & 0xFFFFFFFFUL),
-				(ulint)(offset >> 32), UNIV_PAGE_SIZE);
+				       (ulint)(offset & 0xFFFFFFFFUL),
+				       (ulint)(offset >> 32), UNIV_PAGE_SIZE);
 		if (!success) {
 
 			goto func_exit;
@@ -2591,15 +2653,16 @@
 		if (ut_dulint_cmp(mach_read_from_8(page + FIL_PAGE_LSN),
 				  current_lsn) > 0) {
 			/* We have to reset the lsn */
-			space_id = mach_read_from_4(page
-					+ FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
+			space_id = mach_read_from_4(
+				page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
 			page_no = mach_read_from_4(page + FIL_PAGE_OFFSET);
-			
+
 			buf_flush_init_for_writing(page, current_lsn, space_id,
-								      page_no);
+						   page_no);
 			success = os_file_write(filepath, file, page,
-				(ulint)(offset & 0xFFFFFFFFUL),
-				(ulint)(offset >> 32), UNIV_PAGE_SIZE);
+						(ulint)(offset & 0xFFFFFFFFUL),
+						(ulint)(offset >> 32),
+						UNIV_PAGE_SIZE);
 			if (!success) {
 
 				goto func_exit;
@@ -2671,26 +2734,30 @@
 
 	filepath = fil_make_ibd_name(name, FALSE);
 
-	file = os_file_create_simple_no_error_handling(filepath, OS_FILE_OPEN,
-						OS_FILE_READ_ONLY, &success);
+	file = os_file_create_simple_no_error_handling(
+		filepath, OS_FILE_OPEN, OS_FILE_READ_ONLY, &success);
 	if (!success) {
 		/* The following call prints an error message */
 		os_file_get_last_error(TRUE);
 
 		ut_print_timestamp(stderr);
 
-	        fputs(
-"  InnoDB: Error: trying to open a table, but could not\n"
-"InnoDB: open the tablespace file ", stderr);
+		fputs("  InnoDB: Error: trying to open a table,"
+		      " but could not\n"
+		      "InnoDB: open the tablespace file ", stderr);
 		ut_print_filename(stderr, filepath);
 		fputs("!\n"
-"InnoDB: Have you moved InnoDB .ibd files around without using the\n"
-"InnoDB: commands DISCARD TABLESPACE and IMPORT TABLESPACE?\n"
-"InnoDB: It is also possible that this is a temporary table #sql...,\n"
-"InnoDB: and MySQL removed the .ibd file for this.\n"
-"InnoDB: Please refer to\n"
-"InnoDB: http://dev.mysql.com/doc/refman/5.0/en/innodb-troubleshooting.html\n"
-"InnoDB: for how to resolve the issue.\n", stderr);
+		      "InnoDB: Have you moved InnoDB .ibd files around"
+		      " without using the\n"
+		      "InnoDB: commands DISCARD TABLESPACE and"
+		      " IMPORT TABLESPACE?\n"
+		      "InnoDB: It is also possible that this is"
+		      " a temporary table #sql...,\n"
+		      "InnoDB: and MySQL removed the .ibd file for this.\n"
+		      "InnoDB: Please refer to\n"
+		      "InnoDB: http://dev.mysql.com/doc/refman/5.1/en/"
+		      "innodb-troubleshooting.html\n"
+		      "InnoDB: for how to resolve the issue.\n", stderr);
 
 		mem_free(filepath);
 
@@ -2720,16 +2787,19 @@
 	if (space_id != id) {
 		ut_print_timestamp(stderr);
 
-	        fputs(
-"  InnoDB: Error: tablespace id in file ", stderr);
+		fputs("  InnoDB: Error: tablespace id in file ", stderr);
 		ut_print_filename(stderr, filepath);
 		fprintf(stderr, " is %lu, but in the InnoDB\n"
-"InnoDB: data dictionary it is %lu.\n"
-"InnoDB: Have you moved InnoDB .ibd files around without using the\n"
-"InnoDB: commands DISCARD TABLESPACE and IMPORT TABLESPACE?\n"
-"InnoDB: Please refer to\n"
-"InnoDB: http://dev.mysql.com/doc/refman/5.0/en/innodb-troubleshooting.html\n"
-"InnoDB: for how to resolve the issue.\n", (ulong) space_id, (ulong) id);
+			"InnoDB: data dictionary it is %lu.\n"
+			"InnoDB: Have you moved InnoDB .ibd files"
+			" around without using the\n"
+			"InnoDB: commands DISCARD TABLESPACE and"
+			" IMPORT TABLESPACE?\n"
+			"InnoDB: Please refer to\n"
+			"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/"
+			"innodb-troubleshooting.html\n"
+			"InnoDB: for how to resolve the issue.\n",
+			(ulong) space_id, (ulong) id);
 
 		ret = FALSE;
 
@@ -2799,13 +2869,14 @@
 #ifdef UNIV_HOTBACKUP
 	fil_space_t*	space;
 #endif
-	filepath = mem_alloc(strlen(dbname) + strlen(filename) 
-			+ strlen(fil_path_to_mysql_datadir) + 3);
+	filepath = mem_alloc(strlen(dbname) + strlen(filename)
+			     + strlen(fil_path_to_mysql_datadir) + 3);
 
 	sprintf(filepath, "%s/%s/%s", fil_path_to_mysql_datadir, dbname,
-								filename);
+		filename);
 	srv_normalize_path_for_win(filepath);
 #ifdef __WIN__
+# ifndef UNIV_HOTBACKUP
 	/* If lower_case_table_names is 0 or 2, then MySQL allows database
 	directory names with upper case letters. On Windows, all table and
 	database names in InnoDB are internally always in lower case. Put the
@@ -2813,35 +2884,48 @@
 	internal data dictionary. */
 
 	dict_casedn_str(filepath);
+# endif /* !UNIV_HOTBACKUP */
 #endif
-	file = os_file_create_simple_no_error_handling(filepath, OS_FILE_OPEN,
-						OS_FILE_READ_ONLY, &success);
+	file = os_file_create_simple_no_error_handling(
+		filepath, OS_FILE_OPEN, OS_FILE_READ_ONLY, &success);
 	if (!success) {
 		/* The following call prints an error message */
 		os_file_get_last_error(TRUE);
 
-	        fprintf(stderr,
-"InnoDB: Error: could not open single-table tablespace file\n"
-"InnoDB: %s!\n"
-"InnoDB: We do not continue the crash recovery, because the table may become\n"
-"InnoDB: corrupt if we cannot apply the log records in the InnoDB log to it.\n"
-"InnoDB: To fix the problem and start mysqld:\n"
-"InnoDB: 1) If there is a permission problem in the file and mysqld cannot\n"
-"InnoDB: open the file, you should modify the permissions.\n"
-"InnoDB: 2) If the table is not needed, or you can restore it from a backup,\n"
-"InnoDB: then you can remove the .ibd file, and InnoDB will do a normal\n"
-"InnoDB: crash recovery and ignore that table.\n"
-"InnoDB: 3) If the file system or the disk is broken, and you cannot remove\n"
-"InnoDB: the .ibd file, you can set innodb_force_recovery > 0 in my.cnf\n"
-"InnoDB: and force InnoDB to continue crash recovery here.\n", filepath);
+		fprintf(stderr,
+			"InnoDB: Error: could not open single-table tablespace"
+			" file\n"
+			"InnoDB: %s!\n"
+			"InnoDB: We do not continue the crash recovery,"
+			" because the table may become\n"
+			"InnoDB: corrupt if we cannot apply the log records"
+			" in the InnoDB log to it.\n"
+			"InnoDB: To fix the problem and start mysqld:\n"
+			"InnoDB: 1) If there is a permission problem"
+			" in the file and mysqld cannot\n"
+			"InnoDB: open the file, you should"
+			" modify the permissions.\n"
+			"InnoDB: 2) If the table is not needed, or you can"
+			" restore it from a backup,\n"
+			"InnoDB: then you can remove the .ibd file,"
+			" and InnoDB will do a normal\n"
+			"InnoDB: crash recovery and ignore that table.\n"
+			"InnoDB: 3) If the file system or the"
+			" disk is broken, and you cannot remove\n"
+			"InnoDB: the .ibd file, you can set"
+			" innodb_force_recovery > 0 in my.cnf\n"
+			"InnoDB: and force InnoDB to continue crash"
+			" recovery here.\n", filepath);
 
 		mem_free(filepath);
 
 		if (srv_force_recovery > 0) {
 			fprintf(stderr,
-"InnoDB: innodb_force_recovery was set to %lu. Continuing crash recovery\n"
-"InnoDB: even though we cannot access the .ibd file of this table.\n",
-							srv_force_recovery);
+				"InnoDB: innodb_force_recovery"
+				" was set to %lu. Continuing crash recovery\n"
+				"InnoDB: even though we cannot access"
+				" the .ibd file of this table.\n",
+				srv_force_recovery);
 			return;
 		}
 
@@ -2854,29 +2938,41 @@
 		/* The following call prints an error message */
 		os_file_get_last_error(TRUE);
 
-	        fprintf(stderr,
-"InnoDB: Error: could not measure the size of single-table tablespace file\n"
-"InnoDB: %s!\n"
-"InnoDB: We do not continue crash recovery, because the table will become\n"
-"InnoDB: corrupt if we cannot apply the log records in the InnoDB log to it.\n"
-"InnoDB: To fix the problem and start mysqld:\n"
-"InnoDB: 1) If there is a permission problem in the file and mysqld cannot\n"
-"InnoDB: access the file, you should modify the permissions.\n"
-"InnoDB: 2) If the table is not needed, or you can restore it from a backup,\n"
-"InnoDB: then you can remove the .ibd file, and InnoDB will do a normal\n"
-"InnoDB: crash recovery and ignore that table.\n"
-"InnoDB: 3) If the file system or the disk is broken, and you cannot remove\n"
-"InnoDB: the .ibd file, you can set innodb_force_recovery > 0 in my.cnf\n"
-"InnoDB: and force InnoDB to continue crash recovery here.\n", filepath);
+		fprintf(stderr,
+			"InnoDB: Error: could not measure the size"
+			" of single-table tablespace file\n"
+			"InnoDB: %s!\n"
+			"InnoDB: We do not continue crash recovery,"
+			" because the table will become\n"
+			"InnoDB: corrupt if we cannot apply the log records"
+			" in the InnoDB log to it.\n"
+			"InnoDB: To fix the problem and start mysqld:\n"
+			"InnoDB: 1) If there is a permission problem"
+			" in the file and mysqld cannot\n"
+			"InnoDB: access the file, you should"
+			" modify the permissions.\n"
+			"InnoDB: 2) If the table is not needed,"
+			" or you can restore it from a backup,\n"
+			"InnoDB: then you can remove the .ibd file,"
+			" and InnoDB will do a normal\n"
+			"InnoDB: crash recovery and ignore that table.\n"
+			"InnoDB: 3) If the file system or the disk is broken,"
+			" and you cannot remove\n"
+			"InnoDB: the .ibd file, you can set"
+			" innodb_force_recovery > 0 in my.cnf\n"
+			"InnoDB: and force InnoDB to continue"
+			" crash recovery here.\n", filepath);
 
 		os_file_close(file);
 		mem_free(filepath);
 
 		if (srv_force_recovery > 0) {
 			fprintf(stderr,
-"InnoDB: innodb_force_recovery was set to %lu. Continuing crash recovery\n"
-"InnoDB: even though we cannot access the .ibd file of this table.\n",
-							srv_force_recovery);
+				"InnoDB: innodb_force_recovery"
+				" was set to %lu. Continuing crash recovery\n"
+				"InnoDB: even though we cannot access"
+				" the .ibd file of this table.\n",
+				srv_force_recovery);
 			return;
 		}
 
@@ -2892,9 +2988,11 @@
 	size = (((ib_longlong)size_high) << 32) + (ib_longlong)size_low;
 #ifndef UNIV_HOTBACKUP
 	if (size < FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE) {
-	        fprintf(stderr,
-"InnoDB: Error: the size of single-table tablespace file %s\n"
-"InnoDB: is only %lu %lu, should be at least %lu!", filepath,
+		fprintf(stderr,
+			"InnoDB: Error: the size of single-table tablespace"
+			" file %s\n"
+			"InnoDB: is only %lu %lu, should be at least %lu!",
+			filepath,
 			(ulong) size_high,
 			(ulong) size_low, (ulong) (4 * UNIV_PAGE_SIZE));
 		os_file_close(file);
@@ -2921,8 +3019,9 @@
 
 #ifndef UNIV_HOTBACKUP
 	if (space_id == ULINT_UNDEFINED || space_id == 0) {
-	        fprintf(stderr,
-"InnoDB: Error: tablespace id %lu in file %s is not sensible\n",
+		fprintf(stderr,
+			"InnoDB: Error: tablespace id %lu in file %s"
+			" is not sensible\n",
 			(ulong) space_id,
 			filepath);
 		goto func_exit;
@@ -2932,12 +3031,15 @@
 		char*	new_path;
 
 		fprintf(stderr,
-"InnoDB: Renaming tablespace %s of id %lu,\n"
-"InnoDB: to %s_ibbackup_old_vers_<timestamp>\n"
-"InnoDB: because its size %lld is too small (< 4 pages 16 kB each),\n"
-"InnoDB: or the space id in the file header is not sensible.\n"
-"InnoDB: This can happen in an ibbackup run, and is not dangerous.\n",
-				filepath, space_id, filepath, size);
+			"InnoDB: Renaming tablespace %s of id %lu,\n"
+			"InnoDB: to %s_ibbackup_old_vers_<timestamp>\n"
+			"InnoDB: because its size %lld is too small"
+			" (< 4 pages 16 kB each),\n"
+			"InnoDB: or the space id in the file header"
+			" is not sensible.\n"
+			"InnoDB: This can happen in an ibbackup run,"
+			" and is not dangerous.\n",
+			filepath, space_id, filepath, size);
 		os_file_close(file);
 
 		new_path = fil_make_ibbackup_old_name(filepath);
@@ -2965,12 +3067,14 @@
 		char*	new_path;
 
 		fprintf(stderr,
-"InnoDB: Renaming tablespace %s of id %lu,\n"
-"InnoDB: to %s_ibbackup_old_vers_<timestamp>\n"
-"InnoDB: because space %s with the same id\n"
-"InnoDB: was scanned earlier. This can happen if you have renamed tables\n"
-"InnoDB: during an ibbackup run.\n", filepath, space_id, filepath,
-								space->name);
+			"InnoDB: Renaming tablespace %s of id %lu,\n"
+			"InnoDB: to %s_ibbackup_old_vers_<timestamp>\n"
+			"InnoDB: because space %s with the same id\n"
+			"InnoDB: was scanned earlier. This can happen"
+			" if you have renamed tables\n"
+			"InnoDB: during an ibbackup run.\n",
+			filepath, space_id, filepath,
+			space->name);
 		os_file_close(file);
 
 		new_path = fil_make_ibbackup_old_name(filepath);
@@ -3031,11 +3135,13 @@
 
 			return(ret);
 		}
-		
+
 		fprintf(stderr,
-"InnoDB: Error: os_file_readdir_next_file() returned -1 in\n"
-"InnoDB: directory %s\n"
-"InnoDB: Crash recovery may have failed for some .ibd files!\n", dirname);
+			"InnoDB: Error: os_file_readdir_next_file()"
+			" returned -1 in\n"
+			"InnoDB: directory %s\n"
+			"InnoDB: Crash recovery may have failed"
+			" for some .ibd files!\n", dirname);
 
 		*err = DB_ERROR;
 	}
@@ -3063,7 +3169,7 @@
 	os_file_dir_t	dbdir;
 	os_file_stat_t	dbinfo;
 	os_file_stat_t	fileinfo;
-	ulint		err 		= DB_SUCCESS;
+	ulint		err		= DB_SUCCESS;
 
 	/* The datadir of MySQL is always the default directory of mysqld */
 
@@ -3080,7 +3186,7 @@
 	directories of MySQL. */
 
 	ret = fil_file_readdir_next_file(&err, fil_path_to_mysql_datadir, dir,
-								&dbinfo);
+					 &dbinfo);
 	while (ret == 0) {
 		ulint len;
 		/* printf("Looking at %s in datadir\n", dbinfo.name); */
@@ -3088,14 +3194,14 @@
 		if (dbinfo.type == OS_FILE_TYPE_FILE
 		    || dbinfo.type == OS_FILE_TYPE_UNKNOWN) {
 
-		        goto next_datadir_item;
+			goto next_datadir_item;
 		}
 
 		/* We found a symlink or a directory; try opening it to see
 		if a symlink is a directory */
 
 		len = strlen(fil_path_to_mysql_datadir)
-				+ strlen (dbinfo.name) + 2;
+			+ strlen (dbinfo.name) + 2;
 		if (len > dbpath_len) {
 			dbpath_len = len;
 
@@ -3106,7 +3212,7 @@
 			dbpath = mem_alloc(dbpath_len);
 		}
 		sprintf(dbpath, "%s/%s", fil_path_to_mysql_datadir,
-								dbinfo.name);
+			dbinfo.name);
 		srv_normalize_path_for_win(dbpath);
 
 		dbdir = os_file_opendir(dbpath, FALSE);
@@ -3118,53 +3224,53 @@
 			looking for possible .ibd files in it */
 
 			ret = fil_file_readdir_next_file(&err, dbpath, dbdir,
-								&fileinfo);
+							 &fileinfo);
 			while (ret == 0) {
 				/* printf(
-"     Looking at file %s\n", fileinfo.name); */
+				"     Looking at file %s\n", fileinfo.name); */
 
-			        if (fileinfo.type == OS_FILE_TYPE_DIR) {
+				if (fileinfo.type == OS_FILE_TYPE_DIR) {
 
-				        goto next_file_item;
+					goto next_file_item;
 				}
 
 				/* We found a symlink or a file */
 				if (strlen(fileinfo.name) > 4
-				    && 0 == strcmp(fileinfo.name + 
-						strlen(fileinfo.name) - 4,
-						".ibd")) {
-				        /* The name ends in .ibd; try opening
+				    && 0 == strcmp(fileinfo.name
+						   + strlen(fileinfo.name) - 4,
+						   ".ibd")) {
+					/* The name ends in .ibd; try opening
 					the file */
 					fil_load_single_table_tablespace(
 						dbinfo.name, fileinfo.name);
 				}
 next_file_item:
 				ret = fil_file_readdir_next_file(&err,
-								dbpath, dbdir,
-								&fileinfo);
+								 dbpath, dbdir,
+								 &fileinfo);
 			}
 
 			if (0 != os_file_closedir(dbdir)) {
-				fputs(
-"InnoDB: Warning: could not close database directory ", stderr);
+				fputs("InnoDB: Warning: could not"
+				      " close database directory ", stderr);
 				ut_print_filename(stderr, dbpath);
 				putc('\n', stderr);
 
 				err = DB_ERROR;
 			}
 		}
-		
+
 next_datadir_item:
 		ret = fil_file_readdir_next_file(&err,
-						fil_path_to_mysql_datadir,
-								dir, &dbinfo);
+						 fil_path_to_mysql_datadir,
+						 dir, &dbinfo);
 	}
 
 	mem_free(dbpath);
 
 	if (0 != os_file_closedir(dir)) {
 		fprintf(stderr,
-"InnoDB: Error: could not close MySQL datadir\n");
+			"InnoDB: Error: could not close MySQL datadir\n");
 
 		return(DB_ERROR);
 	}
@@ -3183,7 +3289,7 @@
 fil_print_orphaned_tablespaces(void)
 /*================================*/
 {
-	fil_system_t*	system 		= fil_system;
+	fil_system_t*	system		= fil_system;
 	fil_space_t*	space;
 
 	mutex_enter(&(system->mutex));
@@ -3191,18 +3297,19 @@
 	space = UT_LIST_GET_FIRST(system->space_list);
 
 	while (space) {
-	        if (space->purpose == FIL_TABLESPACE && space->id != 0
-							  && !space->mark) {
+		if (space->purpose == FIL_TABLESPACE && space->id != 0
+		    && !space->mark) {
 			fputs("InnoDB: Warning: tablespace ", stderr);
 			ut_print_filename(stderr, space->name);
 			fprintf(stderr, " of id %lu has no matching table in\n"
-"InnoDB: the InnoDB data dictionary.\n", (ulong) space->id);
+				"InnoDB: the InnoDB data dictionary.\n",
+				(ulong) space->id);
 		}
 
 		space = UT_LIST_GET_NEXT(space_list, space);
 	}
 
-	mutex_exit(&(system->mutex));	
+	mutex_exit(&(system->mutex));
 }
 
 /***********************************************************************
@@ -3235,7 +3342,7 @@
 	}
 
 	if (version != ((ib_longlong)-1)
-				&& space->tablespace_version != version) {
+	    && space->tablespace_version != version) {
 		mutex_exit(&(system->mutex));
 
 		return(TRUE);
@@ -3322,11 +3429,11 @@
 	directory path from the datadir to the file */
 
 	HASH_SEARCH(name_hash, system->name_hash,
-					ut_fold_string(path), namespace,
-					0 == strcmp(namespace->name, path));
+		    ut_fold_string(path), namespace,
+		    0 == strcmp(namespace->name, path));
 	if (space && space == namespace) {
 		/* Found */
-		
+
 		if (mark_space) {
 			space->mark = TRUE;
 		}
@@ -3338,43 +3445,51 @@
 	}
 
 	if (!print_error_if_does_not_exist) {
-		
+
 		mem_free(path);
 		mutex_exit(&(system->mutex));
-		
+
 		return(FALSE);
 	}
 
 	if (space == NULL) {
 		if (namespace == NULL) {
-		        ut_print_timestamp(stderr);
+			ut_print_timestamp(stderr);
 			fputs("  InnoDB: Error: table ", stderr);
 			ut_print_filename(stderr, name);
 			fprintf(stderr, "\n"
-"InnoDB: in InnoDB data dictionary has tablespace id %lu,\n"
-"InnoDB: but tablespace with that id or name does not exist. Have\n"
-"InnoDB: you deleted or moved .ibd files?\n"
-"InnoDB: This may also be a table created with CREATE TEMPORARY TABLE\n"
-"InnoDB: whose .ibd and .frm files MySQL automatically removed, but the\n"
-"InnoDB: table still exists in the InnoDB internal data dictionary.\n",
+				"InnoDB: in InnoDB data dictionary"
+				" has tablespace id %lu,\n"
+				"InnoDB: but tablespace with that id"
+				" or name does not exist. Have\n"
+				"InnoDB: you deleted or moved .ibd files?\n"
+				"InnoDB: This may also be a table created with"
+				" CREATE TEMPORARY TABLE\n"
+				"InnoDB: whose .ibd and .frm files"
+				" MySQL automatically removed, but the\n"
+				"InnoDB: table still exists in the"
+				" InnoDB internal data dictionary.\n",
 				(ulong) id);
 		} else {
-		        ut_print_timestamp(stderr);
+			ut_print_timestamp(stderr);
 			fputs("  InnoDB: Error: table ", stderr);
 			ut_print_filename(stderr, name);
 			fprintf(stderr, "\n"
-"InnoDB: in InnoDB data dictionary has tablespace id %lu,\n"
-"InnoDB: but a tablespace with that id does not exist. There is\n"
-"InnoDB: a tablespace of name %s and id %lu, though. Have\n"
-"InnoDB: you deleted or moved .ibd files?\n",
+				"InnoDB: in InnoDB data dictionary has"
+				" tablespace id %lu,\n"
+				"InnoDB: but a tablespace with that id"
+				" does not exist. There is\n"
+				"InnoDB: a tablespace of name %s and id %lu,"
+				" though. Have\n"
+				"InnoDB: you deleted or moved .ibd files?\n",
 				(ulong) id, namespace->name,
 				(ulong) namespace->id);
 		}
-	error_exit:
-		fputs(
-"InnoDB: Please refer to\n"
-"InnoDB: http://dev.mysql.com/doc/refman/5.0/en/innodb-troubleshooting.html\n"
-"InnoDB: for how to resolve the issue.\n", stderr);
+error_exit:
+		fputs("InnoDB: Please refer to\n"
+		      "InnoDB: http://dev.mysql.com/doc/refman/5.1/en/"
+		      "innodb-troubleshooting.html\n"
+		      "InnoDB: for how to resolve the issue.\n", stderr);
 
 		mem_free(path);
 		mutex_exit(&(system->mutex));
@@ -3387,14 +3502,17 @@
 		fputs("  InnoDB: Error: table ", stderr);
 		ut_print_filename(stderr, name);
 		fprintf(stderr, "\n"
-"InnoDB: in InnoDB data dictionary has tablespace id %lu,\n"
-"InnoDB: but the tablespace with that id has name %s.\n"
-"InnoDB: Have you deleted or moved .ibd files?\n", (ulong) id, space->name);
+			"InnoDB: in InnoDB data dictionary has"
+			" tablespace id %lu,\n"
+			"InnoDB: but the tablespace with that id"
+			" has name %s.\n"
+			"InnoDB: Have you deleted or moved .ibd files?\n",
+			(ulong) id, space->name);
 
 		if (namespace != NULL) {
-			fputs(
-"InnoDB: There is a tablespace with the right name\n"
-"InnoDB: ", stderr);
+			fputs("InnoDB: There is a tablespace"
+			      " with the right name\n"
+			      "InnoDB: ", stderr);
 			ut_print_filename(stderr, namespace->name);
 			fprintf(stderr, ", but its id is %lu.\n",
 				(ulong) namespace->id);
@@ -3436,11 +3554,11 @@
 	directory path to the file */
 
 	HASH_SEARCH(name_hash, system->name_hash,
-					ut_fold_string(path), namespace,
-					0 == strcmp(namespace->name, path));
+		    ut_fold_string(path), namespace,
+		    0 == strcmp(namespace->name, path));
 	if (namespace) {
 		id = namespace->id;
-	}	
+	}
 
 	mem_free(path);
 
@@ -3481,7 +3599,7 @@
 	fil_mutex_enter_and_prepare_for_io(space_id);
 
 	HASH_SEARCH(hash, system->spaces, space_id, space,
-						space->id == space_id);
+		    space->id == space_id);
 	ut_a(space);
 
 	if (space->size >= size_after_extend) {
@@ -3489,11 +3607,11 @@
 
 		*actual_size = space->size;
 
-		mutex_exit(&(system->mutex));	
+		mutex_exit(&(system->mutex));
 
 		return(TRUE);
 	}
-	
+
 	node = UT_LIST_GET_LAST(space->chain);
 
 	fil_node_prepare_for_io(node, system, space);
@@ -3503,7 +3621,7 @@
 
 	/* Extend at most 64 pages at a time */
 	buf_size = ut_min(64, size_after_extend - start_page_no)
-				* UNIV_PAGE_SIZE;
+		* UNIV_PAGE_SIZE;
 	buf2 = mem_alloc(buf_size + UNIV_PAGE_SIZE);
 	buf = ut_align(buf2, UNIV_PAGE_SIZE);
 
@@ -3511,23 +3629,23 @@
 
 	while (start_page_no < size_after_extend) {
 		ulint	n_pages = ut_min(buf_size / UNIV_PAGE_SIZE,
-				size_after_extend - start_page_no);
+					 size_after_extend - start_page_no);
 
 		offset_high = (start_page_no - file_start_page_no)
-				/ (4096 * ((1024 * 1024) / UNIV_PAGE_SIZE));
+			/ (4096 * ((1024 * 1024) / UNIV_PAGE_SIZE));
 		offset_low  = ((start_page_no - file_start_page_no)
-				% (4096 * ((1024 * 1024) / UNIV_PAGE_SIZE)))
-			      * UNIV_PAGE_SIZE;
+			       % (4096 * ((1024 * 1024) / UNIV_PAGE_SIZE)))
+			* UNIV_PAGE_SIZE;
 #ifdef UNIV_HOTBACKUP
 		success = os_file_write(node->name, node->handle, buf,
 					offset_low, offset_high,
 					UNIV_PAGE_SIZE * n_pages);
 #else
 		success = os_aio(OS_FILE_WRITE, OS_AIO_SYNC,
-			node->name, node->handle, buf,
-			offset_low, offset_high,
-			UNIV_PAGE_SIZE * n_pages,
-			NULL, NULL);
+				 node->name, node->handle, buf,
+				 offset_low, offset_high,
+				 UNIV_PAGE_SIZE * n_pages,
+				 NULL, NULL);
 #endif
 		if (success) {
 			node->size += n_pages;
@@ -3537,10 +3655,11 @@
 		} else {
 			/* Let us measure the size of the file to determine
 			how much we were able to extend it */
-			
+
 			n_pages = ((ulint)
-				(os_file_get_size_as_iblonglong(node->handle)
-				/ UNIV_PAGE_SIZE)) - node->size;
+				   (os_file_get_size_as_iblonglong
+				    (node->handle)
+				    / UNIV_PAGE_SIZE)) - node->size;
 
 			node->size += n_pages;
 			space->size += n_pages;
@@ -3564,15 +3683,15 @@
 		/* Keep the last data file size info up to date, rounded to
 		full megabytes */
 
-		srv_data_file_sizes[srv_n_data_files - 1] =
-				(node->size / pages_per_mb) * pages_per_mb;
+		srv_data_file_sizes[srv_n_data_files - 1]
+			= (node->size / pages_per_mb) * pages_per_mb;
 	}
 #endif /* !UNIV_HOTBACKUP */
 
 	/*
-        printf("Extended %s to %lu, actual size %lu pages\n", space->name,
-                                        size_after_extend, *actual_size); */
-	mutex_exit(&(system->mutex));	
+	printf("Extended %s to %lu, actual size %lu pages\n", space->name,
+	size_after_extend, *actual_size); */
+	mutex_exit(&(system->mutex));
 
 	fil_flush(space_id);
 
@@ -3590,7 +3709,7 @@
 fil_extend_tablespaces_to_stored_len(void)
 /*======================================*/
 {
-	fil_system_t*	system 		= fil_system;
+	fil_system_t*	system		= fil_system;
 	fil_space_t*	space;
 	byte*		buf;
 	ulint		actual_size;
@@ -3605,27 +3724,30 @@
 	space = UT_LIST_GET_FIRST(system->space_list);
 
 	while (space) {
-	        ut_a(space->purpose == FIL_TABLESPACE);
+		ut_a(space->purpose == FIL_TABLESPACE);
 
 		mutex_exit(&(system->mutex)); /* no need to protect with a
-					      mutex, because this is a single-
-					      threaded operation */
+					      mutex, because this is a
+					      single-threaded operation */
 		error = fil_read(TRUE, space->id, 0, 0, UNIV_PAGE_SIZE, buf,
-									NULL);
+				 NULL);
 		ut_a(error == DB_SUCCESS);
 
 		size_in_header = fsp_get_size_low(buf);
 
-		success = fil_extend_space_to_desired_size(&actual_size,
-						space->id, size_in_header);
+		success = fil_extend_space_to_desired_size(
+			&actual_size, space->id, size_in_header);
 		if (!success) {
 			fprintf(stderr,
-"InnoDB: Error: could not extend the tablespace of %s\n"
-"InnoDB: to the size stored in header, %lu pages;\n"
-"InnoDB: size after extension %lu pages\n"
-"InnoDB: Check that you have free disk space and retry!\n", space->name,
-					size_in_header, actual_size);
-			exit(1);				
+				"InnoDB: Error: could not extend the"
+				" tablespace of %s\n"
+				"InnoDB: to the size stored in header,"
+				" %lu pages;\n"
+				"InnoDB: size after extension %lu pages\n"
+				"InnoDB: Check that you have free disk space"
+				" and retry!\n",
+				space->name, size_in_header, actual_size);
+			exit(1);
 		}
 
 		mutex_enter(&(system->mutex));
@@ -3670,7 +3792,7 @@
 		space->n_reserved_extents += n_to_reserve;
 		success = TRUE;
 	}
-	
+
 	mutex_exit(&(system->mutex));
 
 	return(success);
@@ -3696,9 +3818,9 @@
 
 	ut_a(space);
 	ut_a(space->n_reserved_extents >= n_reserved);
-	
+
 	space->n_reserved_extents -= n_reserved;
-	
+
 	mutex_exit(&(system->mutex));
 }
 
@@ -3720,11 +3842,11 @@
 	mutex_enter(&(system->mutex));
 
 	HASH_SEARCH(hash, system->spaces, id, space, space->id == id);
-	
+
 	ut_a(space);
 
 	n = space->n_reserved_extents;
-	
+
 	mutex_exit(&(system->mutex));
 
 	return(n);
@@ -3751,11 +3873,12 @@
 #ifdef UNIV_SYNC_DEBUG
 	ut_ad(mutex_own(&(system->mutex)));
 #endif /* UNIV_SYNC_DEBUG */
-	
+
 	if (system->n_open > system->max_n_open + 5) {
 		ut_print_timestamp(stderr);
 		fprintf(stderr,
-"  InnoDB: Warning: open files %lu exceeds the limit %lu\n",
+			"  InnoDB: Warning: open files %lu"
+			" exceeds the limit %lu\n",
 			(ulong) system->n_open,
 			(ulong) system->max_n_open);
 	}
@@ -3768,7 +3891,7 @@
 	}
 
 	if (node->n_pending == 0 && space->purpose == FIL_TABLESPACE
-						      && space->id != 0) {
+	    && space->id != 0) {
 		/* The node is in the LRU list, remove it */
 
 		ut_a(UT_LIST_GET_LEN(system->LRU) > 0);
@@ -3799,7 +3922,7 @@
 #endif /* UNIV_SYNC_DEBUG */
 
 	ut_a(node->n_pending > 0);
-	
+
 	node->n_pending--;
 
 	if (type == OS_FILE_WRITE) {
@@ -3810,13 +3933,13 @@
 
 			node->space->is_in_unflushed_spaces = TRUE;
 			UT_LIST_ADD_FIRST(unflushed_spaces,
-					system->unflushed_spaces,
-					node->space);
+					  system->unflushed_spaces,
+					  node->space);
 		}
 	}
-	
+
 	if (node->n_pending == 0 && node->space->purpose == FIL_TABLESPACE
-					&& node->space->id != 0) {
+	    && node->space->id != 0) {
 		/* The node must be put back to the LRU list */
 		UT_LIST_ADD_FIRST(LRU, system->LRU, node);
 	}
@@ -3836,13 +3959,16 @@
 	ulint		type)		/* in: I/O type */
 {
 	fprintf(stderr,
-	"InnoDB: Error: trying to access page number %lu in space %lu,\n"
-	"InnoDB: space name %s,\n"
-	"InnoDB: which is outside the tablespace bounds.\n"
-	"InnoDB: Byte offset %lu, len %lu, i/o type %lu.\n"
-	"InnoDB: If you get this error at mysqld startup, please check that\n"
-	"InnoDB: your my.cnf matches the ibdata files that you have in the\n"
-	"InnoDB: MySQL server.\n",
+		"InnoDB: Error: trying to access page number %lu"
+		" in space %lu,\n"
+		"InnoDB: space name %s,\n"
+		"InnoDB: which is outside the tablespace bounds.\n"
+		"InnoDB: Byte offset %lu, len %lu, i/o type %lu.\n"
+		"InnoDB: If you get this error at mysqld startup,"
+		" please check that\n"
+		"InnoDB: your my.cnf matches the ibdata files"
+		" that you have in the\n"
+		"InnoDB: MySQL server.\n",
 		(ulong) block_offset, (ulong) space_id, space_name,
 		(ulong) byte_offset, (ulong) len, (ulong) type);
 }
@@ -3889,13 +4015,13 @@
 	ibool		ret;
 	ulint		is_log;
 	ulint		wake_later;
-	
+
 	is_log = type & OS_FILE_LOG;
 	type = type & ~OS_FILE_LOG;
 
 	wake_later = type & OS_AIO_SIMULATED_WAKE_LATER;
 	type = type & ~OS_AIO_SIMULATED_WAKE_LATER;
-	
+
 	ut_ad(byte_offset < UNIV_PAGE_SIZE);
 	ut_ad(buf);
 	ut_ad(len > 0);
@@ -3904,16 +4030,16 @@
 #ifndef UNIV_LOG_DEBUG
 	/* ibuf bitmap pages must be read in the sync aio mode: */
 	ut_ad(recv_no_ibuf_operations || (type == OS_FILE_WRITE)
-		|| !ibuf_bitmap_page(block_offset) || sync || is_log);
+	      || !ibuf_bitmap_page(block_offset) || sync || is_log);
 #ifdef UNIV_SYNC_DEBUG
 	ut_ad(!ibuf_inside() || is_log || (type == OS_FILE_WRITE)
-					|| ibuf_page(space_id, block_offset));
+	      || ibuf_page(space_id, block_offset));
 #endif
 #endif
 	if (sync) {
 		mode = OS_AIO_SYNC;
 	} else if (type == OS_FILE_READ && !is_log
-				&& ibuf_page(space_id, block_offset)) {
+		   && ibuf_page(space_id, block_offset)) {
 		mode = OS_AIO_IBUF;
 	} else if (is_log) {
 		mode = OS_AIO_LOG;
@@ -3921,26 +4047,28 @@
 		mode = OS_AIO_NORMAL;
 	}
 
-        if (type == OS_FILE_READ) {
-                srv_data_read+= len;
-        } else if (type == OS_FILE_WRITE) {
-                srv_data_written+= len;
-        }
+	if (type == OS_FILE_READ) {
+		srv_data_read+= len;
+	} else if (type == OS_FILE_WRITE) {
+		srv_data_written+= len;
+	}
 
 	/* Reserve the fil_system mutex and make sure that we can open at
 	least one file while holding it, if the file is not already open */
 
 	fil_mutex_enter_and_prepare_for_io(space_id);
-	
+
 	HASH_SEARCH(hash, system->spaces, space_id, space,
-							space->id == space_id);
+		    space->id == space_id);
 	if (!space) {
 		mutex_exit(&(system->mutex));
 
 		ut_print_timestamp(stderr);
 		fprintf(stderr,
-"  InnoDB: Error: trying to do i/o to a tablespace which does not exist.\n"
-"InnoDB: i/o type %lu, space id %lu, page no. %lu, i/o length %lu bytes\n",
+			"  InnoDB: Error: trying to do i/o"
+			" to a tablespace which does not exist.\n"
+			"InnoDB: i/o type %lu, space id %lu,"
+			" page no. %lu, i/o length %lu bytes\n",
 			(ulong) type, (ulong) space_id, (ulong) block_offset,
 			(ulong) len);
 
@@ -3953,9 +4081,10 @@
 
 	for (;;) {
 		if (node == NULL) {
-			fil_report_invalid_page_access(block_offset, space_id,
-				space->name, byte_offset, len, type);
- 			
+			fil_report_invalid_page_access(
+				block_offset, space_id, space->name,
+				byte_offset, len, type);
+
 			ut_error;
 		}
 
@@ -3973,8 +4102,8 @@
 			block_offset -= node->size;
 			node = UT_LIST_GET_NEXT(chain, node);
 		}
-	}		
-	
+	}
+
 	/* Open file if closed */
 	fil_node_prepare_for_io(node, system, space);
 
@@ -3983,8 +4112,9 @@
 	if (space->purpose == FIL_TABLESPACE && space->id != 0
 	    && node->size <= block_offset) {
 
-		fil_report_invalid_page_access(block_offset, space_id,
-			space->name, byte_offset, len, type);
+		fil_report_invalid_page_access(
+			block_offset, space_id, space->name, byte_offset,
+			len, type);
 
 		ut_error;
 	}
@@ -3996,10 +4126,10 @@
 
 	offset_high = (block_offset >> (32 - UNIV_PAGE_SIZE_SHIFT));
 	offset_low  = ((block_offset << UNIV_PAGE_SIZE_SHIFT) & 0xFFFFFFFFUL)
-			+ byte_offset;
+		+ byte_offset;
 
-	ut_a(node->size - block_offset >=
- 		(byte_offset + len + (UNIV_PAGE_SIZE - 1)) / UNIV_PAGE_SIZE);
+	ut_a(node->size - block_offset
+	     >= (byte_offset + len + (UNIV_PAGE_SIZE - 1)) / UNIV_PAGE_SIZE);
 
 	/* Do aio */
 
@@ -4010,22 +4140,22 @@
 	/* In ibbackup do normal i/o, not aio */
 	if (type == OS_FILE_READ) {
 		ret = os_file_read(node->handle, buf, offset_low, offset_high,
-									len);
+				   len);
 	} else {
 		ret = os_file_write(node->name, node->handle, buf,
-					offset_low, offset_high, len);
+				    offset_low, offset_high, len);
 	}
 #else
 	/* Queue the aio request */
 	ret = os_aio(type, mode | wake_later, node->name, node->handle, buf,
-				offset_low, offset_high, len, node, message);
+		     offset_low, offset_high, len, node, message);
 #endif
 	ut_a(ret);
 
 	if (mode == OS_AIO_SYNC) {
 		/* The i/o operation is already completed when we return from
 		os_aio: */
-		
+
 		mutex_enter(&(system->mutex));
 
 		fil_node_complete_io(node, system, type);
@@ -4063,7 +4193,7 @@
 				aio used, else ignored */
 {
 	return(fil_io(OS_FILE_READ, sync, space_id, block_offset,
-					  byte_offset, len, buf, message));
+		      byte_offset, len, buf, message));
 }
 
 /************************************************************************
@@ -4091,7 +4221,7 @@
 				aio used, else ignored */
 {
 	return(fil_io(OS_FILE_WRITE, sync, space_id, block_offset,
-					   byte_offset, len, buf, message));
+		      byte_offset, len, buf, message));
 }
 
 /**************************************************************************
@@ -4104,14 +4234,14 @@
 fil_aio_wait(
 /*=========*/
 	ulint	segment)	/* in: the number of the segment in the aio
-				array to wait for */ 
+				array to wait for */
 {
 	fil_system_t*	system		= fil_system;
-	ibool		ret;		
+	ibool		ret;
 	fil_node_t*	fil_node;
 	void*		message;
 	ulint		type;
-	
+
 	ut_ad(fil_validate());
 
 	if (os_aio_use_native_aio) {
@@ -4129,9 +4259,9 @@
 		srv_set_io_thread_op_info(segment, "simulated aio handle");
 
 		ret = os_aio_simulated_handle(segment, &fil_node,
-	                                               &message, &type);
+					      &message, &type);
 	}
-	
+
 	ut_a(ret);
 
 	srv_set_io_thread_op_info(segment, "complete io for fil node");
@@ -4176,9 +4306,9 @@
 	ib_longlong	old_mod_counter;
 
 	mutex_enter(&(system->mutex));
-	
+
 	HASH_SEARCH(hash, system->spaces, space_id, space,
-							space->id == space_id);
+		    space->id == space_id);
 	if (!space || space->is_being_deleted) {
 		mutex_exit(&(system->mutex));
 
@@ -4209,7 +4339,7 @@
 				goto skip_flush;
 			}
 #endif
-retry:			
+retry:
 			if (node->n_pending_flushes > 0) {
 				/* We want to avoid calling os_file_flush() on
 				the file twice at the same time, because we do
@@ -4237,9 +4367,9 @@
 			mutex_exit(&(system->mutex));
 
 			/* fprintf(stderr, "Flushing to file %s\n",
-				node->name); */
+			node->name); */
 
-			os_file_flush(file);		
+			os_file_flush(file);
 
 			mutex_enter(&(system->mutex));
 
@@ -4253,7 +4383,8 @@
 
 					space->is_in_unflushed_spaces = FALSE;
 
-					UT_LIST_REMOVE(unflushed_spaces,
+					UT_LIST_REMOVE(
+						unflushed_spaces,
 						system->unflushed_spaces,
 						space);
 				}
@@ -4267,7 +4398,7 @@
 		}
 
 		node = UT_LIST_GET_NEXT(chain, node);
-	}		
+	}
 
 	space->n_pending_flushes--;
 
@@ -4335,13 +4466,13 @@
 fil_validate(void)
 /*==============*/
 			/* out: TRUE if ok */
-{	
+{
 	fil_system_t*	system		= fil_system;
 	fil_space_t*	space;
 	fil_node_t*	fil_node;
 	ulint		n_open		= 0;
 	ulint		i;
-	
+
 	mutex_enter(&(system->mutex));
 
 	/* Look for spaces in the hash table */
@@ -4349,9 +4480,9 @@
 	for (i = 0; i < hash_get_n_cells(system->spaces); i++) {
 
 		space = HASH_GET_FIRST(system->spaces, i);
-	
+
 		while (space != NULL) {
-			UT_LIST_VALIDATE(chain, fil_node_t, space->chain); 
+			UT_LIST_VALIDATE(chain, fil_node_t, space->chain);
 
 			fil_node = UT_LIST_GET_FIRST(space->chain);
 
@@ -4383,7 +4514,7 @@
 
 		fil_node = UT_LIST_GET_NEXT(LRU, fil_node);
 	}
-	
+
 	mutex_exit(&(system->mutex));
 
 	return(TRUE);
@@ -4426,13 +4557,13 @@
 void
 fil_page_set_type(
 /*==============*/
-	byte* 	page,	/* in: file page */
+	byte*	page,	/* in: file page */
 	ulint	type)	/* in: type */
 {
 	ut_ad(page);
 
 	mach_write_to_2(page + FIL_PAGE_TYPE, type);
-}	
+}
 
 /*************************************************************************
 Gets the file page type. */
@@ -4442,7 +4573,7 @@
 /*==============*/
 			/* out: type; NOTE that if the type has not been
 			written to page, the return value not defined */
-	byte* 	page)	/* in: file page */
+	byte*	page)	/* in: file page */
 {
 	ut_ad(page);
 

--- 1.15.2.1/innobase/ha/ha0ha.c	2006-12-21 23:54:44 +01:00
+++ 1.21/storage/innobase/ha/ha0ha.c	2006-12-21 23:54:44 +01:00
@@ -40,16 +40,20 @@
 		table->adaptive = FALSE;
 	}
 
+	/* Creating MEM_HEAP_BTR_SEARCH type heaps can potentially fail,
+	but in practise it never should in this case, hence the asserts. */
+
 	if (n_mutexes == 0) {
 		if (in_btr_search) {
 			table->heap = mem_heap_create_in_btr_search(4096);
+			ut_a(table->heap);
 		} else {
 			table->heap = mem_heap_create_in_buffer(4096);
 		}
 
 		return(table);
 	}
-	
+
 	hash_create_mutexes(table, n_mutexes, mutex_level);
 
 	table->heaps = mem_alloc(n_mutexes * sizeof(void*));
@@ -57,11 +61,12 @@
 	for (i = 0; i < n_mutexes; i++) {
 		if (in_btr_search) {
 			table->heaps[i] = mem_heap_create_in_btr_search(4096);
+			ut_a(table->heaps[i]);
 		} else {
 			table->heaps[i] = mem_heap_create_in_buffer(4096);
 		}
 	}
-	
+
 	return(table);
 }
 
@@ -114,7 +119,7 @@
 
 		prev_node = prev_node->next;
 	}
-	
+
 	/* We have to allocate a new chain node */
 
 	node = mem_heap_alloc(hash_get_heap(table, fold), sizeof(ha_node_t));
@@ -127,7 +132,7 @@
 
 		return(FALSE);
 	}
-	
+
 	ha_node_set_data(node, data);
 
 	if (table->adaptive) {
@@ -146,7 +151,7 @@
 
 		return(TRUE);
 	}
-		
+
 	while (prev_node->next != NULL) {
 
 		prev_node = prev_node->next;
@@ -155,7 +160,7 @@
 	prev_node->next = node;
 
 	return(TRUE);
-}	
+}
 
 /***************************************************************
 Deletes a hash node. */
@@ -195,7 +200,7 @@
 	ut_a(node);
 
 	ha_delete_hash_node(table, node);
-}	
+}
 
 /*************************************************************
 Looks for an element when we know the pointer to the data, and updates
@@ -264,7 +269,7 @@
 	}
 #ifdef UNIV_DEBUG
 	/* Check that all nodes really got deleted */
-	
+
 	node = ha_chain_get_first(table, fold);
 
 	while (node) {
@@ -305,8 +310,9 @@
 			if (hash_calc_hash(node->fold, table) != i) {
 				ut_print_timestamp(stderr);
 				fprintf(stderr,
-"InnoDB: Error: hash table node fold value %lu does not\n"
-"InnoDB: match with the cell number %lu.\n",
+					"InnoDB: Error: hash table node"
+					" fold value %lu does not\n"
+					"InnoDB: match the cell number %lu.\n",
 					(ulong) node->fold, (ulong) i);
 
 				ok = FALSE;
@@ -317,7 +323,7 @@
 	}
 
 	return(ok);
-}	
+}
 
 /*****************************************************************
 Prints info of a hash table. */
@@ -357,7 +363,8 @@
 		if (table->heap->free_block) {
 			n_bufs++;
 		}
-				
-		fprintf(file, ", node heap has %lu buffer(s)\n", (ulong) n_bufs);
+
+		fprintf(file, ", node heap has %lu buffer(s)\n",
+			(ulong) n_bufs);
 	}
-}	
+}

--- 1.4.1.1/innobase/ha/hash0hash.c	2006-12-21 23:54:44 +01:00
+++ 1.8/storage/innobase/ha/hash0hash.c	2006-12-21 23:54:44 +01:00
@@ -19,8 +19,8 @@
 void
 hash_mutex_enter(
 /*=============*/
-	hash_table_t* 	table,	/* in: hash table */
-	ulint 		fold)	/* in: fold */
+	hash_table_t*	table,	/* in: hash table */
+	ulint		fold)	/* in: fold */
 {
 	mutex_enter(hash_get_mutex(table, fold));
 }
@@ -31,8 +31,8 @@
 void
 hash_mutex_exit(
 /*============*/
-	hash_table_t* 	table,	/* in: hash table */
-	ulint 		fold)	/* in: fold */
+	hash_table_t*	table,	/* in: hash table */
+	ulint		fold)	/* in: fold */
 {
 	mutex_exit(hash_get_mutex(table, fold));
 }
@@ -43,7 +43,7 @@
 void
 hash_mutex_enter_all(
 /*=================*/
-	hash_table_t* 	table)	/* in: hash table */
+	hash_table_t*	table)	/* in: hash table */
 {
 	ulint	i;
 
@@ -59,7 +59,7 @@
 void
 hash_mutex_exit_all(
 /*================*/
-	hash_table_t* 	table)	/* in: hash table */
+	hash_table_t*	table)	/* in: hash table */
 {
 	ulint	i;
 
@@ -84,13 +84,13 @@
 	hash_table_t*	table;
 	ulint		i;
 	hash_cell_t*	cell;
-	
+
 	prime = ut_find_prime(n);
 
 	table = mem_alloc(sizeof(hash_table_t));
 
 	array = ut_malloc(sizeof(hash_cell_t) * prime);
-	
+
 	table->adaptive = FALSE;
 	table->array = array;
 	table->n_cells = prime;
@@ -99,7 +99,7 @@
 	table->heaps = NULL;
 	table->heap = NULL;
 	table->magic_n = HASH_TABLE_MAGIC_N;
-	
+
 	/* Initialize the cell array */
 
 	for (i = 0; i < prime; i++) {
@@ -144,9 +144,7 @@
 	table->mutexes = mem_alloc(n_mutexes * sizeof(mutex_t));
 
 	for (i = 0; i < n_mutexes; i++) {
-		mutex_create(table->mutexes + i);
-
-		mutex_set_level(table->mutexes + i, sync_level);
+		mutex_create(table->mutexes + i, sync_level);
 	}
 
 	table->n_mutexes = n_mutexes;

--- 1.6.1.1/innobase/include/hash0hash.h	2006-12-21 23:54:44 +01:00
+++ 1.10/storage/innobase/include/hash0hash.h	2006-12-21 23:54:44 +01:00
@@ -109,8 +109,8 @@
 \
 		while (struct3333->NAME != DATA) {\
 \
-			ut_a(struct3333);\
 			struct3333 = struct3333->NAME;\
+			ut_a(struct3333);\
 		}\
 \
 		struct3333->NAME = DATA->NAME;\
@@ -153,8 +153,8 @@
 hash_get_nth_cell(
 /*==============*/
 				/* out: pointer to cell */
-	hash_table_t* 	table,	/* in: hash table */
-	ulint 		n);	/* in: cell index */
+	hash_table_t*	table,	/* in: hash table */
+	ulint		n);	/* in: cell index */
 /*****************************************************************
 Returns the number of cells in a hash table. */
 UNIV_INLINE
@@ -222,6 +222,32 @@
 	mem_heap_free_top(hash_get_heap(TABLE, fold111), sizeof(TYPE));\
 } while (0)
 
+/********************************************************************
+Move all hash table entries from OLD_TABLE to NEW_TABLE.*/
+
+#define HASH_MIGRATE(OLD_TABLE, NEW_TABLE, NODE_TYPE, PTR_NAME, FOLD_FUNC) \
+do {\
+	ulint		i2222;\
+	ulint		cell_count2222;\
+\
+	cell_count2222 = hash_get_n_cells(OLD_TABLE);\
+\
+	for (i2222 = 0; i2222 < cell_count2222; i2222++) {\
+		NODE_TYPE*	node2222 = HASH_GET_FIRST((OLD_TABLE), i2222);\
+\
+		while (node2222) {\
+			NODE_TYPE*	next2222 = node2222->PTR_NAME;\
+			ulint		fold2222 = FOLD_FUNC(node2222);\
+\
+			HASH_INSERT(NODE_TYPE, PTR_NAME, (NEW_TABLE),\
+				fold2222, node2222);\
+\
+			node2222 = next2222;\
+		}\
+	}\
+} while (0)
+
+
 /****************************************************************
 Gets the mutex index for a fold value in a hash table. */
 UNIV_INLINE
@@ -229,8 +255,8 @@
 hash_get_mutex_no(
 /*==============*/
 				/* out: mutex number */
-	hash_table_t* 	table,	/* in: hash table */
-	ulint 		fold);	/* in: fold */
+	hash_table_t*	table,	/* in: hash table */
+	ulint		fold);	/* in: fold */
 /****************************************************************
 Gets the nth heap in a hash table. */
 UNIV_INLINE
@@ -238,8 +264,8 @@
 hash_get_nth_heap(
 /*==============*/
 				/* out: mem heap */
-	hash_table_t* 	table,	/* in: hash table */
-	ulint 		i);	/* in: index of the heap */
+	hash_table_t*	table,	/* in: hash table */
+	ulint		i);	/* in: index of the heap */
 /****************************************************************
 Gets the heap for a fold value in a hash table. */
 UNIV_INLINE
@@ -247,8 +273,8 @@
 hash_get_heap(
 /*==========*/
 				/* out: mem heap */
-	hash_table_t* 	table,	/* in: hash table */
-	ulint 		fold);	/* in: fold */
+	hash_table_t*	table,	/* in: hash table */
+	ulint		fold);	/* in: fold */
 /****************************************************************
 Gets the nth mutex in a hash table. */
 UNIV_INLINE
@@ -256,8 +282,8 @@
 hash_get_nth_mutex(
 /*===============*/
 				/* out: mutex */
-	hash_table_t* 	table,	/* in: hash table */
-	ulint 		i);	/* in: index of the mutex */
+	hash_table_t*	table,	/* in: hash table */
+	ulint		i);	/* in: index of the mutex */
 /****************************************************************
 Gets the mutex for a fold value in a hash table. */
 UNIV_INLINE
@@ -265,38 +291,38 @@
 hash_get_mutex(
 /*===========*/
 				/* out: mutex */
-	hash_table_t* 	table,	/* in: hash table */
-	ulint 		fold);	/* in: fold */
+	hash_table_t*	table,	/* in: hash table */
+	ulint		fold);	/* in: fold */
 /****************************************************************
 Reserves the mutex for a fold value in a hash table. */
 
 void
 hash_mutex_enter(
 /*=============*/
-	hash_table_t* 	table,	/* in: hash table */
-	ulint 		fold);	/* in: fold */
+	hash_table_t*	table,	/* in: hash table */
+	ulint		fold);	/* in: fold */
 /****************************************************************
 Releases the mutex for a fold value in a hash table. */
 
 void
 hash_mutex_exit(
 /*============*/
-	hash_table_t* 	table,	/* in: hash table */
-	ulint 		fold);	/* in: fold */
+	hash_table_t*	table,	/* in: hash table */
+	ulint		fold);	/* in: fold */
 /****************************************************************
 Reserves all the mutexes of a hash table, in an ascending order. */
 
 void
 hash_mutex_enter_all(
 /*=================*/
-	hash_table_t* 	table);	/* in: hash table */
+	hash_table_t*	table);	/* in: hash table */
 /****************************************************************
 Releases all the mutexes of a hash table. */
 
 void
 hash_mutex_exit_all(
 /*================*/
-	hash_table_t* 	table);	/* in: hash table */
+	hash_table_t*	table);	/* in: hash table */
 
 
 struct hash_cell_struct{

--- 1.55.8.1/innobase/lock/lock0lock.c	2006-12-21 23:54:44 +01:00
+++ 1.71/storage/innobase/lock/lock0lock.c	2006-12-21 23:54:44 +01:00
@@ -64,7 +64,7 @@
 
 /* An explicit record lock affects both the record and the gap before it.
 An implicit x-lock does not affect the gap, it only locks the index
-record from read or update. 
+record from read or update.
 
 If a transaction has modified or inserted an index record, then
 it owns an implicit x-lock on the record. On a secondary index record,
@@ -298,11 +298,11 @@
 
 /* LOCK COMPATIBILITY MATRIX
  *    IS IX S  X  AI
- * IS +  +  +  -  +
- * IX +  +  -  -  +
- * S  +  -  +  -  -
- * X  -  -  -  -  -
- * AI +  +  -  -  -
+ * IS +	 +  +  -  +
+ * IX +	 +  -  -  +
+ * S  +	 -  +  -  -
+ * X  -	 -  -  -  -
+ * AI +	 +  -  -  -
  *
  * Note that for rows, InnoDB only acquires S or X locks.
  * For tables, InnoDB normally acquires IS or IX locks.
@@ -324,7 +324,7 @@
 struct lock_table_struct{
 	dict_table_t*	table;	/* database table in dictionary cache */
 	UT_LIST_NODE_T(lock_t)
-			locks; 	/* list of locks on the same table */
+			locks;	/* list of locks on the same table */
 };
 
 /* Record lock for a page */
@@ -340,7 +340,7 @@
 /* Lock struct */
 struct lock_struct{
 	trx_t*		trx;		/* transaction owning the lock */
-	UT_LIST_NODE_T(lock_t)		
+	UT_LIST_NODE_T(lock_t)
 			trx_locks;	/* list of the locks of the
 					transaction */
 	ulint		type_mode;	/* lock type, mode, LOCK_GAP or
@@ -396,7 +396,7 @@
 	ulint*	cost,		/* in/out: number of calculation steps thus
 				far: if this exceeds LOCK_MAX_N_STEPS_...
 				we return LOCK_VICTIM_IS_START */
-	uint depth);            /* in: recursion depth: if this exceeds
+	ulint	depth);		/* in: recursion depth: if this exceeds
 				LOCK_MAX_DEPTH_IN_DEADLOCK_CHECK, we
 				return LOCK_VICTIM_IS_START */
 
@@ -442,7 +442,7 @@
 	b = (ulint)*((byte*)lock + sizeof(lock_t) + byte_index);
 
 	return(ut_bit_get_nth(b, bit_index));
-}	
+}
 
 /*************************************************************************/
 
@@ -464,7 +464,7 @@
 					kernel mutex */
 {
 	ibool	is_ok		= TRUE;
-	
+
 	ut_ad(rec_offs_validate(rec, index, offsets));
 
 	if (!has_kernel_mutex) {
@@ -477,22 +477,24 @@
 	if (ut_dulint_cmp(trx_id, trx_sys->max_trx_id) >= 0) {
 		ut_print_timestamp(stderr);
 		fputs("  InnoDB: Error: transaction id associated"
-			" with record\n",
-			stderr);
+		      " with record\n",
+		      stderr);
 		rec_print_new(stderr, rec, offsets);
 		fputs("InnoDB: in ", stderr);
 		dict_index_name_print(stderr, NULL, index);
 		fprintf(stderr, "\n"
-"InnoDB: is %lu %lu which is higher than the global trx id counter %lu %lu!\n"
-"InnoDB: The table is corrupt. You have to do dump + drop + reimport.\n",
-			       (ulong) ut_dulint_get_high(trx_id),
-			       (ulong) ut_dulint_get_low(trx_id),
-			       (ulong) ut_dulint_get_high(trx_sys->max_trx_id),
-			       (ulong) ut_dulint_get_low(trx_sys->max_trx_id));
+			"InnoDB: is %lu %lu which is higher than the"
+			" global trx id counter %lu %lu!\n"
+			"InnoDB: The table is corrupt. You have to do"
+			" dump + drop + reimport.\n",
+			(ulong) ut_dulint_get_high(trx_id),
+			(ulong) ut_dulint_get_low(trx_id),
+			(ulong) ut_dulint_get_high(trx_sys->max_trx_id),
+			(ulong) ut_dulint_get_low(trx_sys->max_trx_id));
 
 		is_ok = FALSE;
 	}
-	
+
 	if (!has_kernel_mutex) {
 		mutex_exit(&kernel_mutex);
 	}
@@ -525,7 +527,7 @@
 	kernel mutex here! */
 
 	trx_id = row_get_rec_trx_id(rec, index, offsets);
-	
+
 	return(read_view_sees_trx_id(view, trx_id));
 }
 
@@ -549,9 +551,9 @@
 	read_view_t*	view)	/* in: consistent read view */
 {
 	dulint	max_trx_id;
-	
+
 	UT_NOT_USED(index);
-	
+
 	ut_ad(!(index->type & DICT_CLUSTERED));
 	ut_ad(page_rec_is_user_rec(rec));
 
@@ -674,8 +676,8 @@
 		} else if (!src) {
 			/* This presumably is the source table. */
 			src = tab_lock->table;
-			if (UT_LIST_GET_LEN(src->locks) != 1 ||
-			    UT_LIST_GET_FIRST(src->locks) != lock) {
+			if (UT_LIST_GET_LEN(src->locks) != 1
+			    || UT_LIST_GET_FIRST(src->locks) != lock) {
 				/* We only support the case when
 				there is only one lock on this table. */
 				return(NULL);
@@ -769,9 +771,9 @@
 {
 	ut_ad(lock);
 	ut_ad(trx->wait_lock == NULL);
-	
+
 	trx->wait_lock = lock;
- 	lock->type_mode = lock->type_mode | LOCK_WAIT;
+	lock->type_mode = lock->type_mode | LOCK_WAIT;
 }
 
 /**************************************************************************
@@ -789,7 +791,7 @@
 	/* Reset the back pointer in trx to this waiting lock request */
 
 	(lock->trx)->wait_lock = NULL;
- 	lock->type_mode = lock->type_mode & ~LOCK_WAIT;
+	lock->type_mode = lock->type_mode & ~LOCK_WAIT;
 }
 
 /*************************************************************************
@@ -863,9 +865,9 @@
 	ulint	mode2)	/* in: lock mode */
 {
 	ut_ad(mode1 == LOCK_X || mode1 == LOCK_S || mode1 == LOCK_IX
-				|| mode1 == LOCK_IS || mode1 == LOCK_AUTO_INC);
+	      || mode1 == LOCK_IS || mode1 == LOCK_AUTO_INC);
 	ut_ad(mode2 == LOCK_X || mode2 == LOCK_S || mode2 == LOCK_IX
-				|| mode2 == LOCK_IS || mode2 == LOCK_AUTO_INC);
+	      || mode2 == LOCK_IS || mode2 == LOCK_AUTO_INC);
 	if (mode1 == LOCK_X) {
 
 		return(TRUE);
@@ -875,7 +877,7 @@
 		return(TRUE);
 
 	} else if (mode1 == LOCK_S
-				&& (mode2 == LOCK_S || mode2 == LOCK_IS)) {
+		   && (mode2 == LOCK_S || mode2 == LOCK_IS)) {
 		return(TRUE);
 
 	} else if (mode1 == LOCK_IS && mode2 == LOCK_IS) {
@@ -883,7 +885,7 @@
 		return(TRUE);
 
 	} else if (mode1 == LOCK_IX && (mode2 == LOCK_IX
-						|| mode2 == LOCK_IS)) {
+					|| mode2 == LOCK_IS)) {
 		return(TRUE);
 	}
 
@@ -901,9 +903,9 @@
 	ulint	mode2)	/* in: lock mode */
 {
 	ut_ad(mode1 == LOCK_X || mode1 == LOCK_S || mode1 == LOCK_IX
-				|| mode1 == LOCK_IS || mode1 == LOCK_AUTO_INC);
+	      || mode1 == LOCK_IS || mode1 == LOCK_AUTO_INC);
 	ut_ad(mode2 == LOCK_X || mode2 == LOCK_S || mode2 == LOCK_IX
-				|| mode2 == LOCK_IS || mode2 == LOCK_AUTO_INC);
+	      || mode2 == LOCK_IS || mode2 == LOCK_AUTO_INC);
 
 	if (mode1 == LOCK_S && (mode2 == LOCK_IS || mode2 == LOCK_S)) {
 
@@ -914,18 +916,18 @@
 		return(FALSE);
 
 	} else if (mode1 == LOCK_AUTO_INC && (mode2 == LOCK_IS
-					  	|| mode2 == LOCK_IX)) {
+					      || mode2 == LOCK_IX)) {
 		return(TRUE);
 
 	} else if (mode1 == LOCK_IS && (mode2 == LOCK_IS
-					  	|| mode2 == LOCK_IX
-					  	|| mode2 == LOCK_AUTO_INC
-					  	|| mode2 == LOCK_S)) {
+					|| mode2 == LOCK_IX
+					|| mode2 == LOCK_AUTO_INC
+					|| mode2 == LOCK_S)) {
 		return(TRUE);
 
 	} else if (mode1 == LOCK_IX && (mode2 == LOCK_IS
-					  	|| mode2 == LOCK_AUTO_INC
-					  	|| mode2 == LOCK_IX)) {
+					|| mode2 == LOCK_AUTO_INC
+					|| mode2 == LOCK_IX)) {
 		return(TRUE);
 	}
 
@@ -957,7 +959,7 @@
 
 	if (trx != lock2->trx
 	    && !lock_mode_compatible(LOCK_MODE_MASK & type_mode,
-				     		lock_get_mode(lock2))) {
+				     lock_get_mode(lock2))) {
 
 		/* We have somewhat complex rules when gap type record locks
 		cause waits */
@@ -966,15 +968,15 @@
 		    && !(type_mode & LOCK_INSERT_INTENTION)) {
 
 			/* Gap type locks without LOCK_INSERT_INTENTION flag
-			do not need to wait for anything. This is because 
-			different users can have conflicting lock types 
+			do not need to wait for anything. This is because
+			different users can have conflicting lock types
 			on gaps. */
-						  
+
 			return(FALSE);
 		}
-		
+
 		if (!(type_mode & LOCK_INSERT_INTENTION)
-						&& lock_rec_get_gap(lock2)) {
+		    && lock_rec_get_gap(lock2)) {
 
 			/* Record lock (LOCK_ORDINARY or LOCK_REC_NOT_GAP
 			does not need to wait for a gap type lock */
@@ -983,8 +985,8 @@
Thread
bk commit into 5.1 tree (kent:1.2368)kent21 Dec