List:Commits« Previous MessageNext Message »
From:Marc Alff Date:January 20 2012 8:33am
Subject:bzr push into mysql-trunk-wl5259 branch (marc.alff:3354 to 3356)
View as plain text  
 3356 Marc Alff	2012-01-20
      Fixed windows XP build breaks

    modified:
      sql/hostname.cc
      sql/sql_connect.cc
 3355 Marc Alff	2012-01-20 [merge]
      Merge mysql-trunk --> mysql-trunk-wl5259

    modified:
      mysql-test/extra/rpl_tests/rpl_start_stop_slave.test
      mysql-test/include/show_slave_status.inc
      mysql-test/r/partition.result
      mysql-test/r/type_float.result
      mysql-test/suite/rpl/r/rpl_log_pos.result
      mysql-test/suite/rpl/r/rpl_manual_change_index_file.result
      mysql-test/suite/rpl/r/rpl_packet.result
      mysql-test/suite/rpl/r/rpl_stm_start_stop_slave.result
      mysql-test/suite/rpl/t/rpl_stm_start_stop_slave.test
      mysql-test/t/partition.test
      mysql-test/t/type_float.test
      sql/filesort.cc
      sql/filesort_utils.h
      sql/rpl_master.cc
      sql/share/errmsg-utf8.txt
      sql/sql_table.cc
      sql/table.h
      storage/innobase/dict/dict0boot.cc
      storage/innobase/dict/dict0crea.cc
      storage/innobase/dict/dict0dict.cc
      storage/innobase/dict/dict0load.cc
      storage/innobase/dict/dict0mem.cc
      storage/innobase/fil/fil0fil.cc
      storage/innobase/handler/ha_innodb.cc
      storage/innobase/handler/i_s.cc
      storage/innobase/include/dict0boot.h
      storage/innobase/include/dict0mem.h
      storage/innobase/include/dict0types.h
      storage/innobase/include/fil0fil.h
      storage/innobase/os/os0file.cc
      storage/innobase/pars/pars0pars.cc
      storage/innobase/row/row0merge.cc
      storage/innobase/row/row0mysql.cc
      storage/innobase/srv/srv0start.cc
      strings/dtoa.c
      unittest/gunit/filesort_buffer-t.cc
 3354 Marc Alff	2012-01-19
      Fixed windows build breaks

    modified:
      sql/hostname.cc
      sql/sql_connect.cc
=== modified file 'mysql-test/extra/rpl_tests/rpl_start_stop_slave.test'
--- a/mysql-test/extra/rpl_tests/rpl_start_stop_slave.test	2010-12-19 17:22:30 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_start_stop_slave.test	2012-01-19 20:03:07 +0000
@@ -177,3 +177,37 @@ UNLOCK TABLES;
 --connection master
 DROP TABLE t1;
 sync_slave_with_master;
+
+#
+# bug#3593869-64035 attempt to read a member of event_coordinates
+# referenced by NULL pointer crashes server.
+# Testing how out of valid range position value is handled with an error.
+#
+
+--connection master
+RESET MASTER;
+let $master_pos= query_get_value(SHOW MASTER STATUS, Position, 1);
+let $master_pos= `SELECT $master_pos + 1`;
+
+--connection slave
+--source include/stop_slave.inc
+--replace_regex /[0-9]+/MASTER_POS/
+eval CHANGE MASTER TO master_log_pos=$master_pos;
+
+START SLAVE;
+# ER_MASTER_FATAL_ERROR_READING_BINLOG 1236
+--let $slave_param=Last_IO_Errno
+--let $slave_param_value=1236
+--source include/wait_for_slave_param.inc
+
+--let $slave_field_result_replace= / at [0-9]*/ at XXX/
+--let $status_items= Last_IO_Errno, Last_IO_Error
+--source include/show_slave_status.inc
+
+--source include/stop_slave.inc
+RESET SLAVE;
+
+--connection master
+RESET MASTER;
+
+# Slave is stopped by bug#3593869-64035 tests.

=== modified file 'mysql-test/include/show_slave_status.inc'
--- a/mysql-test/include/show_slave_status.inc	2012-01-04 15:48:00 +0000
+++ b/mysql-test/include/show_slave_status.inc	2012-01-19 20:03:07 +0000
@@ -56,10 +56,17 @@
 #
 #       --let $status_items= Master_Log_File, Relay_Master_Log_File
 #
-#   $slave_io_error_replace
+#   $slave_field_result_replace
 #     If set, one or more regex patterns for replacing variable
 #     text in the error message. Syntax as --replace-regex
 #
+#   $slave_sql_mode
+#     If set, change the slave sql mode during this macro, reverting
+#     to the previous on exit. Default sql_mode is NO_BACKSLASH_ESCAPES
+#     to allow replace '\' by '/' making paths OS independent. Example:
+#
+#       --let $slave_sql_mode= NO_BACKSLASH_ESCAPES
+#
 
 
 --let $_show_slave_status_items= $status_items
@@ -69,13 +76,30 @@ if (!$status_items)
 }
 
 
+--let $_slave_sql_mode= NO_BACKSLASH_ESCAPES
+if ($slave_sql_mode)
+{
+  --let $_slave_sql_mode= $slave_sql_mode
+}
+--let $_previous_slave_sql_mode = `SELECT @@sql_mode`
+--disable_query_log
+eval SET sql_mode= '$_slave_sql_mode';
+--enable_query_log
+
+
 while ($_show_slave_status_items)
 {
   --let $_show_slave_status_name= `SELECT SUBSTRING_INDEX('$_show_slave_status_items', ',', 1)`
   --let $_show_slave_status_items= `SELECT LTRIM(SUBSTRING('$_show_slave_status_items', LENGTH('$_show_slave_status_name') + 2))`
 
   --let $_show_slave_status_value= query_get_value(SHOW SLAVE STATUS, $_show_slave_status_name, 1)
-  --replace_regex $slave_io_error_replace
+  --let $_slave_field_result_replace= /[\\]/\// $slave_field_result_replace
+  --replace_regex $_slave_field_result_replace
   --let $_show_slave_status_value= `SELECT REPLACE("$_show_slave_status_value", '$MYSQL_TEST_DIR', 'MYSQL_TEST_DIR')`
   --echo $_show_slave_status_name = '$_show_slave_status_value'
 }
+
+
+--disable_query_log
+eval SET sql_mode= '$_previous_slave_sql_mode';
+--enable_query_log

=== modified file 'mysql-test/r/partition.result'
--- a/mysql-test/r/partition.result	2011-10-06 09:50:40 +0000
+++ b/mysql-test/r/partition.result	2012-01-18 13:03:10 +0000
@@ -2429,3 +2429,25 @@ SELECT * FROM vtmp;
 1
 DROP VIEW vtmp;
 DROP TABLE t1;
+#
+# Bug#13580775 ASSERTION FAILED: RECORD_LENGTH == M_RECORD_LENGTH,
+# FILE FILESORT_UTILS.CC
+#
+CREATE TABLE t1 (
+a INT PRIMARY KEY,
+b INT,
+c CHAR(1),
+d INT,
+KEY (c,d)
+) PARTITION BY KEY () PARTITIONS 1;
+INSERT INTO t1 VALUES (1,1,'a',1), (2,2,'a',1);
+SELECT 1 FROM t1 WHERE 1 IN
+(SELECT  group_concat(b)
+FROM t1
+WHERE c > geomfromtext('point(1 1)')
+GROUP BY b
+);
+1
+1
+1
+DROP TABLE t1;

=== modified file 'mysql-test/r/type_float.result'
--- a/mysql-test/r/type_float.result	2011-07-18 08:27:05 +0000
+++ b/mysql-test/r/type_float.result	2012-01-19 07:41:28 +0000
@@ -447,3 +447,21 @@ End of 5.0 tests
 select format(truncate('1.7976931348623157E+308',-12),1,'fr_BE') as foo;
 foo
 0
+#
+# Bug #13500371 63704: CONVERSION OF '1.' TO A NUMBER GIVES ERROR 1265
+# (WARN_DATA_TRUNCATED)
+#
+CREATE TABLE t1 (f FLOAT);
+INSERT INTO t1 VALUES ('1.');
+INSERT INTO t1 VALUES ('2.0.');
+Warnings:
+Warning	1265	Data truncated for column 'f' at row 1
+INSERT INTO t1 VALUES ('.');
+Warnings:
+Warning	1265	Data truncated for column 'f' at row 1
+SELECT * FROM t1 ORDER BY f;
+f
+0
+1
+2
+DROP TABLE t1;

=== modified file 'mysql-test/suite/rpl/r/rpl_log_pos.result'
--- a/mysql-test/suite/rpl/r/rpl_log_pos.result	2012-01-04 15:48:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_log_pos.result	2012-01-19 20:03:07 +0000
@@ -12,7 +12,7 @@ change master to master_log_pos=MASTER_L
 Read_Master_Log_Pos = '75'
 start slave;
 include/wait_for_slave_io_error.inc [errno=1236]
-Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'log event entry exceeded max_allowed_packet; Increase max_allowed_packet on master; the last event was read from 'master-bin.000001' at XXX, the last byte read was read from 'master-bin.000001' at XXX.''
+Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'log event entry exceeded max_allowed_packet; Increase max_allowed_packet on master; the start event position from 'master-bin.000001' at XXX, the last event was read from 'master-bin.000001' at XXX, the last byte read was read from 'master-bin.000001' at XXX.''
 include/stop_slave_sql.inc
 show master status;
 File	Position	Binlog_Do_DB	Binlog_Ignore_DB

=== modified file 'mysql-test/suite/rpl/r/rpl_manual_change_index_file.result'
--- a/mysql-test/suite/rpl/r/rpl_manual_change_index_file.result	2012-01-04 15:48:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_manual_change_index_file.result	2012-01-19 20:03:07 +0000
@@ -8,7 +8,7 @@ CREATE TABLE t1(c1 INT);
 FLUSH LOGS;
 call mtr.add_suppression('Got fatal error 1236 from master when reading data from binary log: .*could not find next log');
 include/wait_for_slave_io_error.inc [errno=1236]
-Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'could not find next log; the last event was read from 'master-bin.000002' at XXX, the last byte read was read from 'master-bin.000002' at XXX.''
+Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'could not find next log; the start event position from 'master-bin.000001' at XXX, the last event was read from 'master-bin.000002' at XXX, the last byte read was read from 'master-bin.000002' at XXX.''
 CREATE TABLE t2(c1 INT);
 FLUSH LOGS;
 CREATE TABLE t3(c1 INT);

=== modified file 'mysql-test/suite/rpl/r/rpl_packet.result'
--- a/mysql-test/suite/rpl/r/rpl_packet.result	2012-01-04 15:48:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_packet.result	2012-01-19 20:03:07 +0000
@@ -40,7 +40,7 @@ DROP TABLE t1;
 CREATE TABLE t1 (f1 int PRIMARY KEY, f2 LONGTEXT, f3 LONGTEXT) ENGINE=MyISAM;
 INSERT INTO t1(f1, f2, f3) VALUES(1, REPEAT('a', @@global.max_allowed_packet), REPEAT('b', @@global.max_allowed_packet));
 include/wait_for_slave_io_error.inc [errno=1236]
-Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'log event entry exceeded max_allowed_packet; Increase max_allowed_packet on master; the last event was read from 'master-bin.000001' at XXX, the last byte read was read from 'master-bin.000001' at XXX.''
+Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'log event entry exceeded max_allowed_packet; Increase max_allowed_packet on master; the start event position from '' at XXX, the last event was read from 'master-bin.000001' at XXX, the last byte read was read from 'master-bin.000001' at XXX.''
 STOP SLAVE;
 RESET SLAVE;
 RESET MASTER;

=== modified file 'mysql-test/suite/rpl/r/rpl_stm_start_stop_slave.result'
--- a/mysql-test/suite/rpl/r/rpl_stm_start_stop_slave.result	2011-11-19 08:08:03 +0000
+++ b/mysql-test/suite/rpl/r/rpl_stm_start_stop_slave.result	2012-01-19 20:03:07 +0000
@@ -72,6 +72,16 @@ include/wait_for_slave_to_stop.inc
 include/start_slave.inc
 # Clean up
 DROP TABLE t1;
+RESET MASTER;
+include/stop_slave.inc
+CHANGE MASTER TO master_log_pos=MASTER_POS;
+START SLAVE;
+include/wait_for_slave_param.inc [Last_IO_Errno]
+Last_IO_Errno = '1236'
+Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'Client requested master to start replication from impossible position; the start event position from 'master-bin.000001' at XXX, the last event was read from './master-bin.000001' at XXX, the last byte read was read from './master-bin.000001' at XXX.''
+include/stop_slave.inc
+RESET SLAVE;
+RESET MASTER;
 SET @@global.innodb_flush_log_at_trx_commit= @old_innodb_flush_log_at_trx_commit;
 call mtr.add_suppression("Slave SQL.*Request to stop slave SQL Thread received while applying a group that has non-transactional changes; waiting for completion of the group");
 SET @@global.innodb_flush_log_at_trx_commit= @old_innodb_flush_log_at_trx_commit;

=== modified file 'mysql-test/suite/rpl/t/rpl_stm_start_stop_slave.test'
--- a/mysql-test/suite/rpl/t/rpl_stm_start_stop_slave.test	2011-03-17 13:20:36 +0000
+++ b/mysql-test/suite/rpl/t/rpl_stm_start_stop_slave.test	2012-01-17 22:32:29 +0000
@@ -22,5 +22,5 @@ SET @@global.innodb_flush_log_at_trx_com
 call mtr.add_suppression("Slave SQL.*Request to stop slave SQL Thread received while applying a group that has non-transactional changes; waiting for completion of the group");
 --connection master
 SET @@global.innodb_flush_log_at_trx_commit= @old_innodb_flush_log_at_trx_commit;
-
+--let $rpl_only_running_threads= 1
 --source include/rpl_end.inc

=== modified file 'mysql-test/t/partition.test'
--- a/mysql-test/t/partition.test	2011-10-06 09:50:40 +0000
+++ b/mysql-test/t/partition.test	2012-01-18 13:03:10 +0000
@@ -2433,3 +2433,27 @@ SELECT 1 FROM t1 AS t1_0 JOIN t1 ON t1_0
 SELECT * FROM vtmp;
 DROP VIEW vtmp;
 DROP TABLE t1;
+
+--echo #
+--echo # Bug#13580775 ASSERTION FAILED: RECORD_LENGTH == M_RECORD_LENGTH,
+--echo # FILE FILESORT_UTILS.CC
+--echo #
+
+CREATE TABLE t1 (
+  a INT PRIMARY KEY,
+  b INT,
+  c CHAR(1),
+  d INT,
+  KEY (c,d)
+) PARTITION BY KEY () PARTITIONS 1;
+
+INSERT INTO t1 VALUES (1,1,'a',1), (2,2,'a',1);
+
+SELECT 1 FROM t1 WHERE 1 IN
+(SELECT  group_concat(b)
+ FROM t1
+ WHERE c > geomfromtext('point(1 1)')
+ GROUP BY b
+);
+
+DROP TABLE t1;

=== modified file 'mysql-test/t/type_float.test'
--- a/mysql-test/t/type_float.test	2011-07-18 08:27:05 +0000
+++ b/mysql-test/t/type_float.test	2012-01-19 07:41:28 +0000
@@ -331,3 +331,15 @@ eval select concat((truncate((-1.7976931
 --echo #
 
 select format(truncate('1.7976931348623157E+308',-12),1,'fr_BE') as foo;
+
+--echo #
+--echo # Bug #13500371 63704: CONVERSION OF '1.' TO A NUMBER GIVES ERROR 1265
+--echo # (WARN_DATA_TRUNCATED)
+--echo #
+
+CREATE TABLE t1 (f FLOAT);
+INSERT INTO t1 VALUES ('1.');
+INSERT INTO t1 VALUES ('2.0.');
+INSERT INTO t1 VALUES ('.');
+SELECT * FROM t1 ORDER BY f;
+DROP TABLE t1;

=== modified file 'sql/filesort.cc'
--- a/sql/filesort.cc	2012-01-12 14:53:51 +0000
+++ b/sql/filesort.cc	2012-01-18 13:03:10 +0000
@@ -38,6 +38,7 @@
 #include "opt_trace.h"
 
 #include <algorithm>
+#include <utility>
 using std::max;
 using std::min;
 
@@ -284,6 +285,19 @@ ha_rows filesort(THD *thd, TABLE *table,
     {
       ha_rows keys= memory_available / (param.rec_length + sizeof(char*));
       param.max_keys_per_buffer= (uint) min(num_rows, keys);
+      if (table_sort.get_sort_keys())
+      {
+        // If we have already allocated a buffer, it better have same size!
+        if (std::make_pair(param.max_keys_per_buffer, param.rec_length) !=
+            table_sort.sort_buffer_properties())
+        {
+          /*
+           table->sort will still have a pointer to the same buffer,
+           but that will be overwritten by the assignment below.
+          */
+          table_sort.free_sort_buffer();
+        }
+      }
       table_sort.alloc_sort_buffer(param.max_keys_per_buffer, param.rec_length);
       if (table_sort.get_sort_keys())
         break;
@@ -444,7 +458,10 @@ ha_rows filesort(THD *thd, TABLE *table,
 #ifdef SKIP_DBUG_IN_FILESORT
   DBUG_POP();			/* Ok to DBUG */
 #endif
+
+  // Assign the copy back!
   table->sort= table_sort;
+
   DBUG_PRINT("exit",
              ("num_rows: %ld examined_rows: %ld found_rows: %ld",
               (long) num_rows, (long) *examined_rows, (long) *found_rows));

=== modified file 'sql/filesort_utils.h'
--- a/sql/filesort_utils.h	2011-11-07 15:32:36 +0000
+++ b/sql/filesort_utils.h	2012-01-18 13:03:10 +0000
@@ -20,6 +20,8 @@
 #include "my_base.h"
 #include "sql_array.h"
 
+#include <utility>
+
 /*
   Calculate cost of merge sort
 
@@ -86,6 +88,10 @@ public:
   /// Allocates the buffer, but does *not* initialize pointers.
   uchar **alloc_sort_buffer(uint num_records, uint record_length);
 
+  /// What is the <num_records, record_length> for the buffer?
+  std::pair<uint, uint> sort_buffer_properties()
+  { return std::make_pair(m_idx_array.size(), m_record_length); }
+
   /// Frees the buffer.
   void free_sort_buffer();
 

=== modified file 'sql/hostname.cc'
--- a/sql/hostname.cc	2012-01-19 16:02:32 +0000
+++ b/sql/hostname.cc	2012-01-20 08:32:13 +0000
@@ -446,6 +446,13 @@ bool ip_to_hostname(struct sockaddr_stor
   err_code= vio_getnameinfo(ip, hostname_buffer, NI_MAXHOST, NULL, 0,
                             NI_NAMEREQD);
 
+  /*
+  ===========================================================================
+  DEBUG code only (begin)
+  Simulate various output from vio_getnameinfo().
+  ===========================================================================
+  */
+
   DBUG_EXECUTE_IF("getnameinfo_error_noname",
                   {
                     strcpy(hostname_buffer, "<garbage>");
@@ -488,6 +495,12 @@ bool ip_to_hostname(struct sockaddr_stor
                   }
                   );
 
+  /*
+  ===========================================================================
+  DEBUG code only (end)
+  ===========================================================================
+  */
+
   if (err_code)
   {
     // NOTE: gai_strerror() returns a string ending by a dot.
@@ -588,7 +601,8 @@ bool ip_to_hostname(struct sockaddr_stor
 
   /*
   ===========================================================================
-                             DBUG CODE (begin)
+  DEBUG code only (begin)
+  Simulate various output from getaddrinfo().
   ===========================================================================
   */
   DBUG_EXECUTE_IF("getaddrinfo_error_noname",
@@ -702,19 +716,43 @@ bool ip_to_hostname(struct sockaddr_stor
                     debug_addr->sin6_family= AF_INET6;
                     ip6= & debug_addr->sin6_addr;
                     /* inet_pton not available on Windows XP. */
-                    ip6->s6_addr32[0] = htonl(0x20010db8);
-                    ip6->s6_addr32[1] = htonl(0x00000000);
-                    ip6->s6_addr32[2] = htonl(0x00000000);
-                    ip6->s6_addr32[3] = htonl(0x0006007e);
+                    ip6->s6_addr[ 0] = 0x20;
+                    ip6->s6_addr[ 1] = 0x01;
+                    ip6->s6_addr[ 2] = 0x0d;
+                    ip6->s6_addr[ 3] = 0xb8;
+                    ip6->s6_addr[ 4] = 0x00;
+                    ip6->s6_addr[ 5] = 0x00;
+                    ip6->s6_addr[ 6] = 0x00;
+                    ip6->s6_addr[ 7] = 0x00;
+                    ip6->s6_addr[ 8] = 0x00;
+                    ip6->s6_addr[ 9] = 0x00;
+                    ip6->s6_addr[10] = 0x00;
+                    ip6->s6_addr[11] = 0x00;
+                    ip6->s6_addr[12] = 0x00;
+                    ip6->s6_addr[13] = 0x06;
+                    ip6->s6_addr[14] = 0x00;
+                    ip6->s6_addr[15] = 0x7e;
 
                     /* Simulating ipv6 2001:DB8::6:7F */
                     debug_addr= & debug_sock_addr[1];
                     debug_addr->sin6_family= AF_INET6;
                     ip6= & debug_addr->sin6_addr;
-                    ip6->s6_addr32[0] = htonl(0x20010db8);
-                    ip6->s6_addr32[1] = htonl(0x00000000);
-                    ip6->s6_addr32[2] = htonl(0x00000000);
-                    ip6->s6_addr32[3] = htonl(0x0006007f);
+                    ip6->s6_addr[ 0] = 0x20;
+                    ip6->s6_addr[ 1] = 0x01;
+                    ip6->s6_addr[ 2] = 0x0d;
+                    ip6->s6_addr[ 3] = 0xb8;
+                    ip6->s6_addr[ 4] = 0x00;
+                    ip6->s6_addr[ 5] = 0x00;
+                    ip6->s6_addr[ 6] = 0x00;
+                    ip6->s6_addr[ 7] = 0x00;
+                    ip6->s6_addr[ 8] = 0x00;
+                    ip6->s6_addr[ 9] = 0x00;
+                    ip6->s6_addr[10] = 0x00;
+                    ip6->s6_addr[11] = 0x00;
+                    ip6->s6_addr[12] = 0x00;
+                    ip6->s6_addr[13] = 0x06;
+                    ip6->s6_addr[14] = 0x00;
+                    ip6->s6_addr[15] = 0x7f;
 
                     debug_addr_info[0].ai_addr= (struct sockaddr*) & debug_sock_addr[0];
                     debug_addr_info[0].ai_addrlen= sizeof (struct sockaddr_in6);
@@ -748,19 +786,43 @@ bool ip_to_hostname(struct sockaddr_stor
                     debug_addr= & debug_sock_addr[0];
                     debug_addr->sin6_family= AF_INET6;
                     ip6= & debug_addr->sin6_addr;
-                    ip6->s6_addr32[0] = htonl(0x20010db8);
-                    ip6->s6_addr32[1] = htonl(0x00000000);
-                    ip6->s6_addr32[2] = htonl(0x00000000);
-                    ip6->s6_addr32[3] = htonl(0x00060007);
+                    ip6->s6_addr[ 0] = 0x20;
+                    ip6->s6_addr[ 1] = 0x01;
+                    ip6->s6_addr[ 2] = 0x0d;
+                    ip6->s6_addr[ 3] = 0xb8;
+                    ip6->s6_addr[ 4] = 0x00;
+                    ip6->s6_addr[ 5] = 0x00;
+                    ip6->s6_addr[ 6] = 0x00;
+                    ip6->s6_addr[ 7] = 0x00;
+                    ip6->s6_addr[ 8] = 0x00;
+                    ip6->s6_addr[ 9] = 0x00;
+                    ip6->s6_addr[10] = 0x00;
+                    ip6->s6_addr[11] = 0x00;
+                    ip6->s6_addr[12] = 0x00;
+                    ip6->s6_addr[13] = 0x06;
+                    ip6->s6_addr[14] = 0x00;
+                    ip6->s6_addr[15] = 0x07;
 
                     /* Simulating ipv6 2001:DB8::6:6 */
                     debug_addr= & debug_sock_addr[1];
                     debug_addr->sin6_family= AF_INET6;
                     ip6= & debug_addr->sin6_addr;
-                    ip6->s6_addr32[0] = htonl(0x20010db8);
-                    ip6->s6_addr32[1] = htonl(0x00000000);
-                    ip6->s6_addr32[2] = htonl(0x00000000);
-                    ip6->s6_addr32[3] = htonl(0x00060006);
+                    ip6->s6_addr[ 0] = 0x20;
+                    ip6->s6_addr[ 1] = 0x01;
+                    ip6->s6_addr[ 2] = 0x0d;
+                    ip6->s6_addr[ 3] = 0xb8;
+                    ip6->s6_addr[ 4] = 0x00;
+                    ip6->s6_addr[ 5] = 0x00;
+                    ip6->s6_addr[ 6] = 0x00;
+                    ip6->s6_addr[ 7] = 0x00;
+                    ip6->s6_addr[ 8] = 0x00;
+                    ip6->s6_addr[ 9] = 0x00;
+                    ip6->s6_addr[10] = 0x00;
+                    ip6->s6_addr[11] = 0x00;
+                    ip6->s6_addr[12] = 0x00;
+                    ip6->s6_addr[13] = 0x06;
+                    ip6->s6_addr[14] = 0x00;
+                    ip6->s6_addr[15] = 0x06;
 
                     debug_addr_info[0].ai_addr= (struct sockaddr*) & debug_sock_addr[0];
                     debug_addr_info[0].ai_addrlen= sizeof (struct sockaddr_in6);
@@ -779,7 +841,7 @@ bool ip_to_hostname(struct sockaddr_stor
 
   /*
   ===========================================================================
-                             DBUG CODE (end)
+  DEBUG code only (end)
   ===========================================================================
   */
 

=== modified file 'sql/rpl_master.cc'
--- a/sql/rpl_master.cc	2011-11-18 12:48:52 +0000
+++ b/sql/rpl_master.cc	2012-01-17 22:32:29 +0000
@@ -629,8 +629,7 @@ void mysql_binlog_send(THD* thd, char* l
   String* packet = &thd->packet;
   int error;
   const char *errmsg = "Unknown error";
-  const char *fmt= "%s; the last event was read from '%s' at %s, the last byte read was read from '%s' at %s.";
-  char llbuff1[22], llbuff2[22];
+  char llbuff0[22], llbuff1[22], llbuff2[22];
   char error_text[MAX_SLAVE_ERRMSG]; // to be send to slave via my_message()
   NET* net = &thd->net;
   mysql_mutex_t *log_lock;
@@ -664,16 +663,15 @@ void mysql_binlog_send(THD* thd, char* l
   */
   ulonglong heartbeat_period= get_heartbeat_period(thd);
   struct timespec heartbeat_buf;
-  struct event_coordinates coord_buf;
   struct timespec *heartbeat_ts= NULL;
-  struct event_coordinates *coord= NULL;
+  const LOG_POS_COORD start_coord= { log_ident, pos },
+    *p_start_coord= &start_coord;
+  LOG_POS_COORD coord_buf= { log_file_name, BIN_LOG_HEADER_SIZE },
+    *p_coord= &coord_buf;
   if (heartbeat_period != LL(0))
   {
     heartbeat_ts= &heartbeat_buf;
     set_timespec_nsec(*heartbeat_ts, 0);
-    coord= &coord_buf;
-    coord->file_name= log_file_name; // initialization basing on what slave remembers
-    coord->pos= pos;
   }
   sql_print_information("Start binlog_dump to slave_server(%d), pos(%s, %lu)",
                         thd->server_id, log_ident, (ulong)pos);
@@ -794,6 +792,7 @@ impossible position";
     mysql_bin_log, and it's already inited, and it will be destroyed
     only at shutdown).
   */
+  p_coord->pos= pos; // the first hb matches the slave's last seen value
   log_lock= mysql_bin_log.get_log_lock();
   log_cond= mysql_bin_log.get_log_cond();
   if (pos > BIN_LOG_HEADER_SIZE)
@@ -915,8 +914,7 @@ impossible position";
       /*
         log's filename does not change while it's active
       */
-      if (coord)
-        coord->pos= uint4korr(packet->ptr() + ev_offset + LOG_POS_OFFSET);
+      p_coord->pos= uint4korr(packet->ptr() + ev_offset + LOG_POS_OFFSET);
 
       event_type= (Log_event_type)((*packet)[LOG_EVENT_OFFSET+ev_offset]);
       DBUG_EXECUTE_IF("dump_thread_wait_before_send_xid",
@@ -1090,8 +1088,7 @@ impossible position";
 	  /* we read successfully, so we'll need to send it to the slave */
           mysql_mutex_unlock(log_lock);
 	  read_packet = 1;
-          if (coord)
-            coord->pos= uint4korr(packet->ptr() + ev_offset + LOG_POS_OFFSET);
+          p_coord->pos= uint4korr(packet->ptr() + ev_offset + LOG_POS_OFFSET);
           event_type= (Log_event_type)((*packet)[LOG_EVENT_OFFSET+ev_offset]);
           DBUG_ASSERT(event_type != FORMAT_DESCRIPTION_EVENT);
 	  break;
@@ -1114,16 +1111,16 @@ impossible position";
           signal_cnt= mysql_bin_log.signal_cnt;
           do 
           {
-            if (coord)
+            if (heartbeat_period != 0)
             {
-              DBUG_ASSERT(heartbeat_ts && heartbeat_period != 0);
+              DBUG_ASSERT(heartbeat_ts);
               set_timespec_nsec(*heartbeat_ts, heartbeat_period);
             }
             thd->ENTER_COND(log_cond, log_lock,
                             &stage_master_has_sent_all_binlog_to_slave,
                             &old_stage);
             ret= mysql_bin_log.wait_for_update_bin_log(thd, heartbeat_ts);
-            DBUG_ASSERT(ret == 0 || (heartbeat_period != 0 && coord != NULL));
+            DBUG_ASSERT(ret == 0 || (heartbeat_period != 0));
             if (ret == ETIMEDOUT || ret == ETIME)
             {
 #ifndef DBUG_OFF
@@ -1141,7 +1138,7 @@ impossible position";
                 thd->EXIT_COND(&old_stage);
                 goto err;
               }
-              if (send_heartbeat_event(net, packet, coord, current_checksum_alg))
+              if (send_heartbeat_event(net, packet, p_coord, current_checksum_alg))
               {
                 errmsg = "Failed on my_net_write()";
                 my_errno= ER_UNKNOWN_ERROR;
@@ -1252,8 +1249,7 @@ impossible position";
 	goto err;
       }
 
-      if (coord)
-        coord->file_name= log_file_name; // reset to the next
+      p_coord->file_name= log_file_name; // reset to the next
     }
   }
 
@@ -1279,9 +1275,12 @@ err:
        detailing the fatal error message with coordinates 
        of the last position read.
     */
+    const char *fmt= "%s; the start event position from '%s' at %s, the last event was read from '%s' at %s, the last byte read was read from '%s' at %s.";
     my_snprintf(error_text, sizeof(error_text), fmt, errmsg,
-                coord->file_name, (llstr(coord->pos, llbuff1), llbuff1),
-                log_file_name, (llstr(my_b_tell(&log), llbuff2), llbuff2));
+                p_start_coord->file_name,
+                (llstr(p_start_coord->pos, llbuff0), llbuff0),
+                p_coord->file_name, (llstr(p_coord->pos, llbuff1), llbuff1),
+                log_file_name,    (llstr(my_b_tell(&log), llbuff2), llbuff2));
   }
   else
     strcpy(error_text, errmsg);

=== modified file 'sql/share/errmsg-utf8.txt'
--- a/sql/share/errmsg-utf8.txt	2011-11-28 07:42:18 +0000
+++ b/sql/share/errmsg-utf8.txt	2012-01-19 15:55:36 +0000
@@ -4701,14 +4701,14 @@ ER_NOT_SUPPORTED_YET 42000
         spa "Esta versión de MySQL no soporta todavia '%s'"
         swe "Denna version av MySQL kan ännu inte utföra '%s'"
 ER_MASTER_FATAL_ERROR_READING_BINLOG  
-        nla "Kreeg fatale fout %d: '%-.256s' van master tijdens lezen van data uit binaire log"
-        eng "Got fatal error %d from master when reading data from binary log: '%-.256s'"
-        ger "Schwerer Fehler %d: '%-.256s vom Master beim Lesen des binären Logs"
-        ita "Errore fatale %d: '%-.256s' dal master leggendo i dati dal log binario"
-        por "Obteve fatal erro %d: '%-.256s' do master quando lendo dados do binary log"
-        rus "Получена неисправимая ошибка %d: '%-.256s' от головного сервера в процес.256s' del master cuando leyendo datos del binary log"
-        swe "Fick fatalt fel %d: '%-.256s' från master vid läsning av binärloggen"
+        nla "Kreeg fatale fout %d: '%-.320s' van master tijdens lezen van data uit binaire log"
+        eng "Got fatal error %d from master when reading data from binary log: '%-.320s'"
+        ger "Schwerer Fehler %d: '%-.320s vom Master beim Lesen des binären Logs"
+        ita "Errore fatale %d: '%-.320s' dal master leggendo i dati dal log binario"
+        por "Obteve fatal erro %d: '%-.320s' do master quando lendo dados do binary log"
+        rus "Получена неисправимая ошибка %d: '%-.320s' от головного сервера в процессе выбо"
+        spa "Recibió fatal error %d: '%-.320s' del master cuando leyendo datos del binary log"
+        swe "Fick fatalt fel %d: '%-.320s' från master vid läsning av binärloggen"
 ER_SLAVE_IGNORED_TABLE  
         eng "Slave SQL thread ignored the query because of replicate-*-table rules"
         ger "Slave-SQL-Thread hat die Abfrage aufgrund von replicate-*-table-Regeln ignoriert"

=== modified file 'sql/sql_connect.cc'
--- a/sql/sql_connect.cc	2012-01-19 16:02:32 +0000
+++ b/sql/sql_connect.cc	2012-01-20 08:32:13 +0000
@@ -470,6 +470,13 @@ static int check_connection(THD *thd)
 
     peer_rc= vio_peer_addr(net->vio, ip, &thd->peer_port, NI_MAXHOST);
 
+    /*
+    ===========================================================================
+    DEBUG code only (begin)
+    Simulate various output from vio_peer_addr().
+    ===========================================================================
+    */
+
     DBUG_EXECUTE_IF("vio_peer_addr_error",
                     {
                       peer_rc= 1;
@@ -497,16 +504,34 @@ static int check_connection(THD *thd)
                       /* See RFC 3849, ipv6 2001:DB8::/32 is reserved. */
                       const char* fake= "2001:db8::6:6";
                       /* inet_pton(AF_INET6, fake, ip6); not available on Windows XP. */
-                      ip6->s6_addr32[0] = htonl(0x20010db8);
-                      ip6->s6_addr32[1] = htonl(0x00000000);
-                      ip6->s6_addr32[2] = htonl(0x00000000);
-                      ip6->s6_addr32[3] = htonl(0x00060006);
+                      ip6->s6_addr[ 0] = 0x20;
+                      ip6->s6_addr[ 1] = 0x01;
+                      ip6->s6_addr[ 2] = 0x0d;
+                      ip6->s6_addr[ 3] = 0xb8;
+                      ip6->s6_addr[ 4] = 0x00;
+                      ip6->s6_addr[ 5] = 0x00;
+                      ip6->s6_addr[ 6] = 0x00;
+                      ip6->s6_addr[ 7] = 0x00;
+                      ip6->s6_addr[ 8] = 0x00;
+                      ip6->s6_addr[ 9] = 0x00;
+                      ip6->s6_addr[10] = 0x00;
+                      ip6->s6_addr[11] = 0x00;
+                      ip6->s6_addr[12] = 0x00;
+                      ip6->s6_addr[13] = 0x06;
+                      ip6->s6_addr[14] = 0x00;
+                      ip6->s6_addr[15] = 0x06;
                       strcpy(ip, fake);
                       peer_rc= 0;
                     }
                     );
 #endif /* HAVE_IPV6 */
 
+    /*
+    ===========================================================================
+    DEBUG code only (end)
+    ===========================================================================
+    */
+
     if (peer_rc)
     {
       /*

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2012-01-17 09:27:34 +0000
+++ b/sql/sql_table.cc	2012-01-18 04:33:08 +0000
@@ -2451,6 +2451,14 @@ int mysql_rm_table_no_locks(THD *thd, TA
     }
     if (error)
     {
+      if (error == HA_ERR_TOO_MANY_CONCURRENT_TRXS)
+      {
+        my_error(HA_ERR_TOO_MANY_CONCURRENT_TRXS, MYF(0));
+        wrong_tables.free();
+        error= 1;
+        goto err;
+      }
+
       if (wrong_tables.length())
         wrong_tables.append(',');
 

=== modified file 'sql/table.h'
--- a/sql/table.h	2012-01-13 09:33:13 +0000
+++ b/sql/table.h	2012-01-18 13:03:10 +0000
@@ -337,6 +337,9 @@ public:
   uchar **alloc_sort_buffer(uint num_records, uint record_length)
   { return filesort_buffer.alloc_sort_buffer(num_records, record_length); }
 
+  std::pair<uint, uint> sort_buffer_properties()
+  { return filesort_buffer.sort_buffer_properties(); }
+
   void free_sort_buffer()
   { filesort_buffer.free_sort_buffer(); }
 

=== modified file 'storage/innobase/dict/dict0boot.cc'
--- a/storage/innobase/dict/dict0boot.cc	2011-11-08 10:32:23 +0000
+++ b/storage/innobase/dict/dict0boot.cc	2012-01-18 20:18:14 +0000
@@ -254,6 +254,24 @@ dict_boot(void)
 	mtr_t		mtr;
 	ulint		error;
 
+	/* Be sure these constants do not ever change.  To avoid bloat,
+	only check the *NUM_FIELDS* in each table */
+
+	ut_ad(DICT_NUM_COLS__SYS_TABLES == 8);
+	ut_ad(DICT_NUM_FIELDS__SYS_TABLES == 10);
+	ut_ad(DICT_NUM_FIELDS__SYS_TABLE_IDS == 2);
+	ut_ad(DICT_NUM_COLS__SYS_COLUMNS == 7);
+	ut_ad(DICT_NUM_FIELDS__SYS_COLUMNS == 9);
+	ut_ad(DICT_NUM_COLS__SYS_INDEXES == 7);
+	ut_ad(DICT_NUM_FIELDS__SYS_INDEXES == 9);
+	ut_ad(DICT_NUM_COLS__SYS_FIELDS == 3);
+	ut_ad(DICT_NUM_FIELDS__SYS_FIELDS == 5);
+	ut_ad(DICT_NUM_COLS__SYS_FOREIGN == 4);
+	ut_ad(DICT_NUM_FIELDS__SYS_FOREIGN == 6);
+	ut_ad(DICT_NUM_FIELDS__SYS_FOREIGN_FOR_NAME == 2);
+	ut_ad(DICT_NUM_COLS__SYS_FOREIGN_COLS == 4);
+	ut_ad(DICT_NUM_FIELDS__SYS_FOREIGN_COLS == 6);
+
 	mtr_start(&mtr);
 
 	/* Create the hash tables etc. */
@@ -379,20 +397,6 @@ dict_boot(void)
 	dict_mem_table_add_col(table, heap, "SPACE", DATA_INT, 0, 4);
 	dict_mem_table_add_col(table, heap, "PAGE_NO", DATA_INT, 0, 4);
 
-	/* The '+ 2' below comes from the fields DB_TRX_ID, DB_ROLL_PTR */
-#if DICT_SYS_INDEXES_PAGE_NO_FIELD != 6 + 2
-#error "DICT_SYS_INDEXES_PAGE_NO_FIELD != 6 + 2"
-#endif
-#if DICT_SYS_INDEXES_SPACE_NO_FIELD != 5 + 2
-#error "DICT_SYS_INDEXES_SPACE_NO_FIELD != 5 + 2"
-#endif
-#if DICT_SYS_INDEXES_TYPE_FIELD != 4 + 2
-#error "DICT_SYS_INDEXES_TYPE_FIELD != 4 + 2"
-#endif
-#if DICT_SYS_INDEXES_NAME_FIELD != 2 + 2
-#error "DICT_SYS_INDEXES_NAME_FIELD != 2 + 2"
-#endif
-
 	table->id = DICT_INDEXES_ID;
 
 	dict_table_add_to_cache(table, FALSE, heap);

=== modified file 'storage/innobase/dict/dict0crea.cc'
--- a/storage/innobase/dict/dict0crea.cc	2011-11-11 08:46:18 +0000
+++ b/storage/innobase/dict/dict0crea.cc	2012-01-18 15:39:14 +0000
@@ -73,12 +73,16 @@ dict_create_sys_tables_tuple(
 	dict_table_copy_types(entry, sys_tables);
 
 	/* 0: NAME -----------------------------*/
-	dfield = dtuple_get_nth_field(entry, 0/*NAME*/);
+	dfield = dtuple_get_nth_field(
+		entry, DICT_COL__SYS_TABLES__NAME);
 
 	dfield_set_data(dfield, table->name, ut_strlen(table->name));
 
+	/* 1: DB_TRX_ID added later */
+	/* 2: DB_ROLL_PTR added later */
 	/* 3: ID -------------------------------*/
-	dfield = dtuple_get_nth_field(entry, 1/*ID*/);
+	dfield = dtuple_get_nth_field(
+		entry, DICT_COL__SYS_TABLES__ID);
 
 	ptr = static_cast<byte*>(mem_heap_alloc(heap, 8));
 	mach_write_to_8(ptr, table->id);
@@ -86,7 +90,8 @@ dict_create_sys_tables_tuple(
 	dfield_set_data(dfield, ptr, 8);
 
 	/* 4: N_COLS ---------------------------*/
-	dfield = dtuple_get_nth_field(entry, 2/*N_COLS*/);
+	dfield = dtuple_get_nth_field(
+		entry, DICT_COL__SYS_TABLES__N_COLS);
 
 	ptr = static_cast<byte*>(mem_heap_alloc(heap, 4));
 	mach_write_to_4(ptr, table->n_def
@@ -94,7 +99,8 @@ dict_create_sys_tables_tuple(
 	dfield_set_data(dfield, ptr, 4);
 
 	/* 5: TYPE (table flags) -----------------------------*/
-	dfield = dtuple_get_nth_field(entry, 3/*TYPE*/);
+	dfield = dtuple_get_nth_field(
+		entry, DICT_COL__SYS_TABLES__TYPE);
 
 	ptr = static_cast<byte*>(mem_heap_alloc(heap, 4));
 
@@ -107,14 +113,16 @@ dict_create_sys_tables_tuple(
 	dfield_set_data(dfield, ptr, 4);
 
 	/* 6: MIX_ID (obsolete) ---------------------------*/
-	dfield = dtuple_get_nth_field(entry, 4/*MIX_ID*/);
+	dfield = dtuple_get_nth_field(
+		entry, DICT_COL__SYS_TABLES__MIX_ID);
 
 	ptr = static_cast<byte*>(mem_heap_zalloc(heap, 8));
 
 	dfield_set_data(dfield, ptr, 8);
 
 	/* 7: MIX_LEN (additional flags) --------------------------*/
-	dfield = dtuple_get_nth_field(entry, 5/*MIX_LEN*/);
+	dfield = dtuple_get_nth_field(
+		entry, DICT_COL__SYS_TABLES__MIX_LEN);
 
 	ptr = static_cast<byte*>(mem_heap_alloc(heap, 4));
 	/* Be sure all non-used bits are zero. */
@@ -124,11 +132,13 @@ dict_create_sys_tables_tuple(
 	dfield_set_data(dfield, ptr, 4);
 
 	/* 8: CLUSTER_NAME ---------------------*/
-	dfield = dtuple_get_nth_field(entry, 6/*CLUSTER_NAME*/);
+	dfield = dtuple_get_nth_field(
+		entry, DICT_COL__SYS_TABLES__CLUSTER_ID);
 	dfield_set_null(dfield); /* not supported */
 
 	/* 9: SPACE ----------------------------*/
-	dfield = dtuple_get_nth_field(entry, 7/*SPACE*/);
+	dfield = dtuple_get_nth_field(
+		entry, DICT_COL__SYS_TABLES__SPACE);
 
 	ptr = static_cast<byte*>(mem_heap_alloc(heap, 4));
 	mach_write_to_4(ptr, table->space);
@@ -172,47 +182,55 @@ dict_create_sys_columns_tuple(
 	dict_table_copy_types(entry, sys_columns);
 
 	/* 0: TABLE_ID -----------------------*/
-	dfield = dtuple_get_nth_field(entry, 0/*TABLE_ID*/);
+	dfield = dtuple_get_nth_field(entry, DICT_COL__SYS_COLUMNS__TABLE_ID);
 
 	ptr = static_cast<byte*>(mem_heap_alloc(heap, 8));
 	mach_write_to_8(ptr, table->id);
 
 	dfield_set_data(dfield, ptr, 8);
+
 	/* 1: POS ----------------------------*/
-	dfield = dtuple_get_nth_field(entry, 1/*POS*/);
+	dfield = dtuple_get_nth_field(entry, DICT_COL__SYS_COLUMNS__POS);
 
 	ptr = static_cast<byte*>(mem_heap_alloc(heap, 4));
 	mach_write_to_4(ptr, i);
 
 	dfield_set_data(dfield, ptr, 4);
+
+	/* 2: DB_TRX_ID added later */
+	/* 3: DB_ROLL_PTR added later */
 	/* 4: NAME ---------------------------*/
-	dfield = dtuple_get_nth_field(entry, 2/*NAME*/);
+	dfield = dtuple_get_nth_field(entry, DICT_COL__SYS_COLUMNS__NAME);
 
 	col_name = dict_table_get_col_name(table, i);
 	dfield_set_data(dfield, col_name, ut_strlen(col_name));
+
 	/* 5: MTYPE --------------------------*/
-	dfield = dtuple_get_nth_field(entry, 3/*MTYPE*/);
+	dfield = dtuple_get_nth_field(entry, DICT_COL__SYS_COLUMNS__MTYPE);
 
 	ptr = static_cast<byte*>(mem_heap_alloc(heap, 4));
 	mach_write_to_4(ptr, column->mtype);
 
 	dfield_set_data(dfield, ptr, 4);
+
 	/* 6: PRTYPE -------------------------*/
-	dfield = dtuple_get_nth_field(entry, 4/*PRTYPE*/);
+	dfield = dtuple_get_nth_field(entry, DICT_COL__SYS_COLUMNS__PRTYPE);
 
 	ptr = static_cast<byte*>(mem_heap_alloc(heap, 4));
 	mach_write_to_4(ptr, column->prtype);
 
 	dfield_set_data(dfield, ptr, 4);
+
 	/* 7: LEN ----------------------------*/
-	dfield = dtuple_get_nth_field(entry, 5/*LEN*/);
+	dfield = dtuple_get_nth_field(entry, DICT_COL__SYS_COLUMNS__LEN);
 
 	ptr = static_cast<byte*>(mem_heap_alloc(heap, 4));
 	mach_write_to_4(ptr, column->len);
 
 	dfield_set_data(dfield, ptr, 4);
+
 	/* 8: PREC ---------------------------*/
-	dfield = dtuple_get_nth_field(entry, 6/*PREC*/);
+	dfield = dtuple_get_nth_field(entry, DICT_COL__SYS_COLUMNS__PREC);
 
 	ptr = static_cast<byte*>(mem_heap_alloc(heap, 4));
 	mach_write_to_4(ptr, 0/* unused */);
@@ -370,7 +388,8 @@ dict_create_sys_indexes_tuple(
 	dict_table_copy_types(entry, sys_indexes);
 
 	/* 0: TABLE_ID -----------------------*/
-	dfield = dtuple_get_nth_field(entry, 0/*TABLE_ID*/);
+	dfield = dtuple_get_nth_field(
+		entry, DICT_COL__SYS_INDEXES__TABLE_ID);
 
 	ptr = static_cast<byte*>(mem_heap_alloc(heap, 8));
 	mach_write_to_8(ptr, table->id);
@@ -378,20 +397,25 @@ dict_create_sys_indexes_tuple(
 	dfield_set_data(dfield, ptr, 8);
 
 	/* 1: ID ----------------------------*/
-	dfield = dtuple_get_nth_field(entry, 1/*ID*/);
+	dfield = dtuple_get_nth_field(
+		entry, DICT_COL__SYS_INDEXES__ID);
 
 	ptr = static_cast<byte*>(mem_heap_alloc(heap, 8));
 	mach_write_to_8(ptr, index->id);
 
 	dfield_set_data(dfield, ptr, 8);
 
+	/* 2: DB_TRX_ID added later */
+	/* 3: DB_ROLL_PTR added later */
 	/* 4: NAME --------------------------*/
-	dfield = dtuple_get_nth_field(entry, 2/*NAME*/);
+	dfield = dtuple_get_nth_field(
+		entry, DICT_COL__SYS_INDEXES__NAME);
 
 	dfield_set_data(dfield, index->name, ut_strlen(index->name));
 
 	/* 5: N_FIELDS ----------------------*/
-	dfield = dtuple_get_nth_field(entry, 3/*N_FIELDS*/);
+	dfield = dtuple_get_nth_field(
+		entry, DICT_COL__SYS_INDEXES__N_FIELDS);
 
 	ptr = static_cast<byte*>(mem_heap_alloc(heap, 4));
 	mach_write_to_4(ptr, index->n_fields);
@@ -399,7 +423,8 @@ dict_create_sys_indexes_tuple(
 	dfield_set_data(dfield, ptr, 4);
 
 	/* 6: TYPE --------------------------*/
-	dfield = dtuple_get_nth_field(entry, 4/*TYPE*/);
+	dfield = dtuple_get_nth_field(
+		entry, DICT_COL__SYS_INDEXES__TYPE);
 
 	ptr = static_cast<byte*>(mem_heap_alloc(heap, 4));
 	mach_write_to_4(ptr, index->type);
@@ -408,11 +433,8 @@ dict_create_sys_indexes_tuple(
 
 	/* 7: SPACE --------------------------*/
 
-#if DICT_SYS_INDEXES_SPACE_NO_FIELD != 7
-#error "DICT_SYS_INDEXES_SPACE_NO_FIELD != 7"
-#endif
-
-	dfield = dtuple_get_nth_field(entry, 5/*SPACE*/);
+	dfield = dtuple_get_nth_field(
+		entry, DICT_COL__SYS_INDEXES__SPACE);
 
 	ptr = static_cast<byte*>(mem_heap_alloc(heap, 4));
 	mach_write_to_4(ptr, index->space);
@@ -421,11 +443,8 @@ dict_create_sys_indexes_tuple(
 
 	/* 8: PAGE_NO --------------------------*/
 
-#if DICT_SYS_INDEXES_PAGE_NO_FIELD != 8
-#error "DICT_SYS_INDEXES_PAGE_NO_FIELD != 8"
-#endif
-
-	dfield = dtuple_get_nth_field(entry, 6/*PAGE_NO*/);
+	dfield = dtuple_get_nth_field(
+		entry, DICT_COL__SYS_INDEXES__PAGE_NO);
 
 	ptr = static_cast<byte*>(mem_heap_alloc(heap, 4));
 	mach_write_to_4(ptr, FIL_NULL);
@@ -446,7 +465,7 @@ dtuple_t*
 dict_create_sys_fields_tuple(
 /*=========================*/
 	const dict_index_t*	index,	/*!< in: index */
-	ulint			i,	/*!< in: field number */
+	ulint			fld_no,	/*!< in: field number */
 	mem_heap_t*		heap)	/*!< in: memory heap from
 					which the memory for the built
 					tuple is allocated */
@@ -469,7 +488,7 @@ dict_create_sys_fields_tuple(
 		}
 	}
 
-	field = dict_index_get_nth_field(index, i);
+	field = dict_index_get_nth_field(index, fld_no);
 
 	sys_fields = dict_sys->sys_fields;
 
@@ -478,15 +497,16 @@ dict_create_sys_fields_tuple(
 	dict_table_copy_types(entry, sys_fields);
 
 	/* 0: INDEX_ID -----------------------*/
-	dfield = dtuple_get_nth_field(entry, 0/*INDEX_ID*/);
+	dfield = dtuple_get_nth_field(entry, DICT_COL__SYS_FIELDS__INDEX_ID);
 
 	ptr = static_cast<byte*>(mem_heap_alloc(heap, 8));
 	mach_write_to_8(ptr, index->id);
 
 	dfield_set_data(dfield, ptr, 8);
-	/* 1: POS + PREFIX LENGTH ----------------------------*/
 
-	dfield = dtuple_get_nth_field(entry, 1/*POS*/);
+	/* 1: POS; FIELD NUMBER & PREFIX LENGTH -----------------------*/
+
+	dfield = dtuple_get_nth_field(entry, DICT_COL__SYS_FIELDS__POS);
 
 	ptr = static_cast<byte*>(mem_heap_alloc(heap, 4));
 
@@ -495,18 +515,21 @@ dict_create_sys_fields_tuple(
 		we store the number of the field to the 2 HIGH bytes
 		and the prefix length to the 2 low bytes, */
 
-		mach_write_to_4(ptr, (i << 16) + field->prefix_len);
+		mach_write_to_4(ptr, (fld_no << 16) + field->prefix_len);
 	} else {
 		/* Else we store the number of the field to the 2 LOW bytes.
 		This is to keep the storage format compatible with
 		InnoDB versions < 4.0.14. */
 
-		mach_write_to_4(ptr, i);
+		mach_write_to_4(ptr, fld_no);
 	}
 
 	dfield_set_data(dfield, ptr, 4);
+
+	/* 2: DB_TRX_ID added later */
+	/* 3: DB_ROLL_PTR added later */
 	/* 4: COL_NAME -------------------------*/
-	dfield = dtuple_get_nth_field(entry, 2/*COL_NAME*/);
+	dfield = dtuple_get_nth_field(entry, DICT_COL__SYS_FIELDS__COL_NAME);
 
 	dfield_set_data(dfield, field->name,
 			ut_strlen(field->name));
@@ -670,10 +693,10 @@ dict_create_index_tree_step(
 	node->page_no = btr_create(index->type, index->space, zip_size,
 				   index->id, index, &mtr);
 	/* printf("Created a new index tree in space %lu root page %lu\n",
-	index->space, index->page_no); */
+	index->space, node->page_no); */
 
 	page_rec_write_field(btr_pcur_get_rec(&pcur),
-			     DICT_SYS_INDEXES_PAGE_NO_FIELD,
+			     DICT_FLD__SYS_INDEXES__PAGE_NO,
 			     node->page_no, &mtr);
 	btr_pcur_close(&pcur);
 	mtr_commit(&mtr);
@@ -704,7 +727,8 @@ dict_drop_index_tree(
 
 	ut_ad(mutex_own(&(dict_sys->mutex)));
 	ut_a(!dict_table_is_comp(dict_sys->sys_indexes));
-	ptr = rec_get_nth_field_old(rec, DICT_SYS_INDEXES_PAGE_NO_FIELD, &len);
+	ptr = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_INDEXES__PAGE_NO, &len);
 
 	ut_ad(len == 4);
 
@@ -716,8 +740,8 @@ dict_drop_index_tree(
 		return;
 	}
 
-	ptr = rec_get_nth_field_old(rec,
-				    DICT_SYS_INDEXES_SPACE_NO_FIELD, &len);
+	ptr = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_INDEXES__SPACE, &len);
 
 	ut_ad(len == 4);
 
@@ -744,7 +768,7 @@ dict_drop_index_tree(
 	root_page_no); */
 	btr_free_root(space, zip_size, root_page_no, mtr);
 
-	page_rec_write_field(rec, DICT_SYS_INDEXES_PAGE_NO_FIELD,
+	page_rec_write_field(rec, DICT_FLD__SYS_INDEXES__PAGE_NO,
 			     FIL_NULL, mtr);
 }
 
@@ -780,7 +804,8 @@ dict_truncate_index_tree(
 	ut_ad(mutex_own(&(dict_sys->mutex)));
 	ut_a(!dict_table_is_comp(dict_sys->sys_indexes));
 	rec = btr_pcur_get_rec(pcur);
-	ptr = rec_get_nth_field_old(rec, DICT_SYS_INDEXES_PAGE_NO_FIELD, &len);
+	ptr = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_INDEXES__PAGE_NO, &len);
 
 	ut_ad(len == 4);
 
@@ -795,8 +820,8 @@ dict_truncate_index_tree(
 		drop = FALSE;
 	}
 
-	ptr = rec_get_nth_field_old(rec,
-				    DICT_SYS_INDEXES_SPACE_NO_FIELD, &len);
+	ptr = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_INDEXES__SPACE, &len);
 
 	ut_ad(len == 4);
 
@@ -816,12 +841,12 @@ dict_truncate_index_tree(
 		return(FIL_NULL);
 	}
 
-	ptr = rec_get_nth_field_old(rec,
-				    DICT_SYS_INDEXES_TYPE_FIELD, &len);
+	ptr = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_INDEXES__TYPE, &len);
 	ut_ad(len == 4);
 	type = mach_read_from_4(ptr);
 
-	ptr = rec_get_nth_field_old(rec, 1, &len);
+	ptr = rec_get_nth_field_old(rec, DICT_FLD__SYS_INDEXES__ID, &len);
 	ut_ad(len == 8);
 	index_id = mach_read_from_8(ptr);
 
@@ -848,7 +873,7 @@ create:
 	in SYS_INDEXES, so that the database will not get into an
 	inconsistent state in case it crashes between the mtr_commit()
 	below and the following mtr_commit() call. */
-	page_rec_write_field(rec, DICT_SYS_INDEXES_PAGE_NO_FIELD,
+	page_rec_write_field(rec, DICT_FLD__SYS_INDEXES__PAGE_NO,
 			     FIL_NULL, mtr);
 
 	/* We will need to commit the mini-transaction in order to avoid

=== modified file 'storage/innobase/dict/dict0dict.cc'
--- a/storage/innobase/dict/dict0dict.cc	2011-12-19 08:43:28 +0000
+++ b/storage/innobase/dict/dict0dict.cc	2012-01-18 15:39:14 +0000
@@ -5435,7 +5435,7 @@ dict_set_corrupted(
 		ulint	len;
 		byte*	field	= rec_get_nth_field_old(
 			btr_cur_get_rec(&cursor),
-			DICT_SYS_INDEXES_TYPE_FIELD, &len);
+			DICT_FLD__SYS_INDEXES__TYPE, &len);
 		if (len != 4) {
 			goto fail;
 		}

=== modified file 'storage/innobase/dict/dict0load.cc'
--- a/storage/innobase/dict/dict0load.cc	2011-12-29 14:32:49 +0000
+++ b/storage/innobase/dict/dict0load.cc	2012-01-18 15:39:14 +0000
@@ -60,6 +60,7 @@ static const char* SYSTEM_TABLE_NAME[] =
 metadata even if it is marked as "corrupted". */
 UNIV_INTERN my_bool     srv_load_corrupted = FALSE;
 
+#ifdef UNIV_DEBUG
 /****************************************************************//**
 Compare the name of an index column.
 @return	TRUE if the i'th column of index is 'name'. */
@@ -78,6 +79,7 @@ name_of_col_is(
 
 	return(strcmp(name, dict_table_get_col_name(table, tmp)) == 0);
 }
+#endif /* UNIV_DEBUG */
 
 /********************************************************************//**
 Finds the first table name in the given database.
@@ -108,7 +110,7 @@ dict_get_first_table_name_in_db(
 
 	sys_tables = dict_table_get_low("SYS_TABLES");
 	sys_index = UT_LIST_GET_FIRST(sys_tables->indexes);
-	ut_a(!dict_table_is_comp(sys_tables));
+	ut_ad(!dict_table_is_comp(sys_tables));
 
 	tuple = dtuple_create(heap, 1);
 	dfield = dtuple_get_nth_field(tuple, 0);
@@ -131,7 +133,8 @@ loop:
 		return(NULL);
 	}
 
-	field = rec_get_nth_field_old(rec, 0, &len);
+	field = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_TABLES__NAME, &len);
 
 	if (len < strlen(name)
 	    || ut_memcmp(name, field, strlen(name)) != 0) {
@@ -329,7 +332,8 @@ dict_process_sys_tables_rec_and_mtr_comm
 	const char*	err_msg = NULL;
 	char*		table_name;
 
-	field = (const char*) rec_get_nth_field_old(rec, 0, &len);
+	field = (const char*) rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_TABLES__NAME, &len);
 
 	ut_a(!rec_get_deleted_flag(rec, 0));
 
@@ -476,11 +480,12 @@ dict_process_sys_foreign_rec(
 		return("delete-marked record in SYS_FOREIGN");
 	}
 
-	if (UNIV_UNLIKELY(rec_get_n_fields_old(rec) != 6)) {
+	if (rec_get_n_fields_old(rec) != DICT_NUM_FIELDS__SYS_FOREIGN) {
 		return("wrong number of columns in SYS_FOREIGN record");
 	}
 
-	field = rec_get_nth_field_old(rec, 0/*ID*/, &len);
+	field = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_FOREIGN__ID, &len);
 	if (UNIV_UNLIKELY(len < 1 || len == UNIV_SQL_NULL)) {
 err_len:
 		return("incorrect column length in SYS_FOREIGN");
@@ -492,34 +497,39 @@ err_len:
 	is not assigned. */
 	foreign->id = mem_heap_strdupl(heap, (const char*) field, len);
 
-	rec_get_nth_field_offs_old(rec, 1/*DB_TRX_ID*/, &len);
-	if (UNIV_UNLIKELY(len != DATA_TRX_ID_LEN && len != UNIV_SQL_NULL)) {
+	rec_get_nth_field_offs_old(
+		rec, DICT_FLD__SYS_FOREIGN__DB_TRX_ID, &len);
+	if (len != DATA_TRX_ID_LEN && len != UNIV_SQL_NULL) {
 		goto err_len;
 	}
-	rec_get_nth_field_offs_old(rec, 2/*DB_ROLL_PTR*/, &len);
-	if (UNIV_UNLIKELY(len != DATA_ROLL_PTR_LEN && len != UNIV_SQL_NULL)) {
+	rec_get_nth_field_offs_old(
+		rec, DICT_FLD__SYS_FOREIGN__DB_ROLL_PTR, &len);
+	if (len != DATA_ROLL_PTR_LEN && len != UNIV_SQL_NULL) {
 		goto err_len;
 	}
 
 	/* The _lookup versions of the referenced and foreign table names
 	 are not assigned since they are not used in this dict_foreign_t */
 
-	field = rec_get_nth_field_old(rec, 3/*FOR_NAME*/, &len);
-	if (UNIV_UNLIKELY(len < 1 || len == UNIV_SQL_NULL)) {
+	field = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_FOREIGN__FOR_NAME, &len);
+	if (len < 1 || len == UNIV_SQL_NULL) {
 		goto err_len;
 	}
 	foreign->foreign_table_name = mem_heap_strdupl(
 		heap, (const char*) field, len);
 
-	field = rec_get_nth_field_old(rec, 4/*REF_NAME*/, &len);
-	if (UNIV_UNLIKELY(len < 1 || len == UNIV_SQL_NULL)) {
+	field = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_FOREIGN__REF_NAME, &len);
+	if (len < 1 || len == UNIV_SQL_NULL) {
 		goto err_len;
 	}
 	foreign->referenced_table_name = mem_heap_strdupl(
 		heap, (const char*) field, len);
 
-	field = rec_get_nth_field_old(rec, 5/*N_COLS*/, &len);
-	if (UNIV_UNLIKELY(len != 4)) {
+	field = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_FOREIGN__N_COLS, &len);
+	if (len != 4) {
 		goto err_len;
 	}
 	n_fields_and_type = mach_read_from_4(field);
@@ -549,44 +559,50 @@ dict_process_sys_foreign_col_rec(
 	ulint		len;
 	const byte*	field;
 
-	if (UNIV_UNLIKELY(rec_get_deleted_flag(rec, 0))) {
+	if (rec_get_deleted_flag(rec, 0)) {
 		return("delete-marked record in SYS_FOREIGN_COLS");
 	}
 
-	if (UNIV_UNLIKELY(rec_get_n_fields_old(rec) != 6)) {
+	if (rec_get_n_fields_old(rec) != DICT_NUM_FIELDS__SYS_FOREIGN_COLS) {
 		return("wrong number of columns in SYS_FOREIGN_COLS record");
 	}
 
-	field = rec_get_nth_field_old(rec, 0/*ID*/, &len);
-	if (UNIV_UNLIKELY(len < 1 || len == UNIV_SQL_NULL)) {
+	field = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_FOREIGN_COLS__ID, &len);
+	if (len < 1 || len == UNIV_SQL_NULL) {
 err_len:
 		return("incorrect column length in SYS_FOREIGN_COLS");
 	}
 	*name = mem_heap_strdupl(heap, (char*) field, len);
 
-	field = rec_get_nth_field_old(rec, 1/*POS*/, &len);
-	if (UNIV_UNLIKELY(len != 4)) {
+	field = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_FOREIGN_COLS__POS, &len);
+	if (len != 4) {
 		goto err_len;
 	}
 	*pos = mach_read_from_4(field);
 
-	rec_get_nth_field_offs_old(rec, 2/*DB_TRX_ID*/, &len);
-	if (UNIV_UNLIKELY(len != DATA_TRX_ID_LEN && len != UNIV_SQL_NULL)) {
+	rec_get_nth_field_offs_old(
+		rec, DICT_FLD__SYS_FOREIGN_COLS__DB_TRX_ID, &len);
+	if (len != DATA_TRX_ID_LEN && len != UNIV_SQL_NULL) {
 		goto err_len;
 	}
-	rec_get_nth_field_offs_old(rec, 3/*DB_ROLL_PTR*/, &len);
-	if (UNIV_UNLIKELY(len != DATA_ROLL_PTR_LEN && len != UNIV_SQL_NULL)) {
+	rec_get_nth_field_offs_old(
+		rec, DICT_FLD__SYS_FOREIGN_COLS__DB_ROLL_PTR, &len);
+	if (len != DATA_ROLL_PTR_LEN && len != UNIV_SQL_NULL) {
 		goto err_len;
 	}
 
-	field = rec_get_nth_field_old(rec, 4/*FOR_COL_NAME*/, &len);
-	if (UNIV_UNLIKELY(len < 1 || len == UNIV_SQL_NULL)) {
+	field = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_FOREIGN_COLS__FOR_COL_NAME, &len);
+	if (len < 1 || len == UNIV_SQL_NULL) {
 		goto err_len;
 	}
 	*for_col_name = mem_heap_strdupl(heap, (char*) field, len);
 
-	field = rec_get_nth_field_old(rec, 5/*REF_COL_NAME*/, &len);
-	if (UNIV_UNLIKELY(len < 1 || len == UNIV_SQL_NULL)) {
+	field = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_FOREIGN_COLS__REF_COL_NAME, &len);
+	if (len < 1 || len == UNIV_SQL_NULL) {
 		goto err_len;
 	}
 	*ref_col_name = mem_heap_strdupl(heap, (char*) field, len);
@@ -609,7 +625,8 @@ dict_sys_tables_get_flags(
 	ulint		n_cols;
 
 	/* read the 4 byte flags from the TYPE field */
-	field = rec_get_nth_field_old(rec, 5/*TYPE*/, &len);
+	field = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_TABLES__TYPE, &len);
 	ut_a(len == 4);
 	type = mach_read_from_4(field);
 
@@ -621,7 +638,8 @@ dict_sys_tables_get_flags(
 	Read the 4 byte N_COLS field and look at the high order bit.  It
 	should be set for COMPACT and later.  It should not be set for
 	REDUNDANT. */
-	field = rec_get_nth_field_old(rec, 4/*N_COLS*/, &len);
+	field = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_TABLES__N_COLS, &len);
 	ut_a(len == 4);
 	n_cols = mach_read_from_4(field);
 
@@ -658,7 +676,7 @@ dict_check_tablespaces_and_store_max_id(
 
 	sys_tables = dict_table_get_low("SYS_TABLES");
 	sys_index = UT_LIST_GET_FIRST(sys_tables->indexes);
-	ut_a(!dict_table_is_comp(sys_tables));
+	ut_ad(!dict_table_is_comp(sys_tables));
 
 	max_space_id = mtr_read_ulint(dict_hdr_get(&mtr)
 				      + DICT_HDR_MAX_SPACE_ID,
@@ -699,13 +717,15 @@ loop:
 		ulint		flags;
 		char*		name;
 
-		field = rec_get_nth_field_old(rec, 0/*NAME*/, &len);
+		field = rec_get_nth_field_old(
+			rec, DICT_FLD__SYS_TABLES__NAME, &len);
 		name = mem_strdupl((char*) field, len);
 
 		flags = dict_sys_tables_get_flags(rec);
 		if (UNIV_UNLIKELY(flags == ULINT_UNDEFINED)) {
 			/* Read again the 4 bytes from rec. */
-			field = rec_get_nth_field_old(rec, 5/*TYPE*/, &len);
+			field = rec_get_nth_field_old(
+				rec, DICT_FLD__SYS_TABLES__TYPE, &len);
 			ut_ad(len == 4); /* this was checked earlier */
 			flags = mach_read_from_4(field);
 
@@ -720,7 +740,8 @@ loop:
 			goto loop;
 		}
 
-		field = rec_get_nth_field_old(rec, 9/*SPACE*/, &len);
+		field = rec_get_nth_field_old(
+			rec, DICT_FLD__SYS_TABLES__SPACE, &len);
 		ut_a(len == 4);
 
 		space_id = mach_read_from_4(field);
@@ -737,7 +758,8 @@ loop:
 			Do not print warnings for temporary tables. */
 			ibool	is_temp;
 
-			field = rec_get_nth_field_old(rec, 4/*N_COLS*/, &len);
+			field = rec_get_nth_field_old(
+				rec, DICT_FLD__SYS_TABLES__N_COLS, &len);
 			if (mach_read_from_4(field) & DICT_N_COLS_COMPACT) {
 				/* ROW_FORMAT=COMPACT: read the is_temp
 				flag from SYS_TABLES.MIX_LEN. */
@@ -811,49 +833,54 @@ dict_load_column_low(
 
 	ut_ad(table || column);
 
-	if (UNIV_UNLIKELY(rec_get_deleted_flag(rec, 0))) {
+	if (rec_get_deleted_flag(rec, 0)) {
 		return("delete-marked record in SYS_COLUMNS");
 	}
 
-	if (UNIV_UNLIKELY(rec_get_n_fields_old(rec) != 9)) {
+	if (rec_get_n_fields_old(rec) != DICT_NUM_FIELDS__SYS_COLUMNS) {
 		return("wrong number of columns in SYS_COLUMNS record");
 	}
 
-	field = rec_get_nth_field_old(rec, 0/*TABLE_ID*/, &len);
-	if (UNIV_UNLIKELY(len != 8)) {
+	field = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_COLUMNS__TABLE_ID, &len);
+	if (len != 8) {
 err_len:
 		return("incorrect column length in SYS_COLUMNS");
 	}
 
 	if (table_id) {
 		*table_id = mach_read_from_8(field);
-	} else if (UNIV_UNLIKELY(table->id != mach_read_from_8(field))) {
+	} else if (table->id != mach_read_from_8(field)) {
 		return("SYS_COLUMNS.TABLE_ID mismatch");
 	}
 
-	field = rec_get_nth_field_old(rec, 1/*POS*/, &len);
-	if (UNIV_UNLIKELY(len != 4)) {
+	field = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_COLUMNS__POS, &len);
+	if (len != 4) {
 
 		goto err_len;
 	}
 
 	pos = mach_read_from_4(field);
 
-	if (UNIV_UNLIKELY(table && table->n_def != pos)) {
+	if (table && table->n_def != pos) {
 		return("SYS_COLUMNS.POS mismatch");
 	}
 
-	rec_get_nth_field_offs_old(rec, 2/*DB_TRX_ID*/, &len);
-	if (UNIV_UNLIKELY(len != DATA_TRX_ID_LEN && len != UNIV_SQL_NULL)) {
+	rec_get_nth_field_offs_old(
+		rec, DICT_FLD__SYS_COLUMNS__DB_TRX_ID, &len);
+	if (len != DATA_TRX_ID_LEN && len != UNIV_SQL_NULL) {
 		goto err_len;
 	}
-	rec_get_nth_field_offs_old(rec, 3/*DB_ROLL_PTR*/, &len);
-	if (UNIV_UNLIKELY(len != DATA_ROLL_PTR_LEN && len != UNIV_SQL_NULL)) {
+	rec_get_nth_field_offs_old(
+		rec, DICT_FLD__SYS_COLUMNS__DB_ROLL_PTR, &len);
+	if (len != DATA_ROLL_PTR_LEN && len != UNIV_SQL_NULL) {
 		goto err_len;
 	}
 
-	field = rec_get_nth_field_old(rec, 4/*NAME*/, &len);
-	if (UNIV_UNLIKELY(len < 1 || len == UNIV_SQL_NULL)) {
+	field = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_COLUMNS__NAME, &len);
+	if (len < 1 || len == UNIV_SQL_NULL) {
 		goto err_len;
 	}
 
@@ -863,15 +890,17 @@ err_len:
 		*col_name = name;
 	}
 
-	field = rec_get_nth_field_old(rec, 5/*MTYPE*/, &len);
-	if (UNIV_UNLIKELY(len != 4)) {
+	field = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_COLUMNS__MTYPE, &len);
+	if (len != 4) {
 		goto err_len;
 	}
 
 	mtype = mach_read_from_4(field);
 
-	field = rec_get_nth_field_old(rec, 6/*PRTYPE*/, &len);
-	if (UNIV_UNLIKELY(len != 4)) {
+	field = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_COLUMNS__PRTYPE, &len);
+	if (len != 4) {
 		goto err_len;
 	}
 	prtype = mach_read_from_4(field);
@@ -897,13 +926,15 @@ err_len:
 		}
 	}
 
-	field = rec_get_nth_field_old(rec, 7/*LEN*/, &len);
-	if (UNIV_UNLIKELY(len != 4)) {
+	field = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_COLUMNS__LEN, &len);
+	if (len != 4) {
 		goto err_len;
 	}
 	col_len = mach_read_from_4(field);
-	field = rec_get_nth_field_old(rec, 8/*PREC*/, &len);
-	if (UNIV_UNLIKELY(len != 4)) {
+	field = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_COLUMNS__PREC, &len);
+	if (len != 4) {
 		goto err_len;
 	}
 
@@ -944,10 +975,12 @@ dict_load_columns(
 
 	sys_columns = dict_table_get_low("SYS_COLUMNS");
 	sys_index = UT_LIST_GET_FIRST(sys_columns->indexes);
-	ut_a(!dict_table_is_comp(sys_columns));
+	ut_ad(!dict_table_is_comp(sys_columns));
 
-	ut_a(name_of_col_is(sys_columns, sys_index, 4, "NAME"));
-	ut_a(name_of_col_is(sys_columns, sys_index, 8, "PREC"));
+	ut_ad(name_of_col_is(sys_columns, sys_index,
+			     DICT_FLD__SYS_COLUMNS__NAME, "NAME"));
+	ut_ad(name_of_col_is(sys_columns, sys_index,
+			     DICT_FLD__SYS_COLUMNS__PREC, "PREC"));
 
 	tuple = dtuple_create(heap, 1);
 	dfield = dtuple_get_nth_field(tuple, 0);
@@ -1034,7 +1067,7 @@ dict_load_field_low(
 	dict_index_t*	index,		/*!< in/out: index, could be NULL
 					if we just populate a dict_field_t
 					struct with information from
-					a SYS_FIELDSS record */
+					a SYS_FIELDS record */
 	dict_field_t*	sys_field,	/*!< out: dict_field_t to be
 					filled */
 	ulint*		pos,		/*!< out: Field position */
@@ -1053,16 +1086,17 @@ dict_load_field_low(
 	/* Either index or sys_field is supplied, not both */
 	ut_a((!index) || (!sys_field));
 
-	if (UNIV_UNLIKELY(rec_get_deleted_flag(rec, 0))) {
+	if (rec_get_deleted_flag(rec, 0)) {
 		return(dict_load_field_del);
 	}
 
-	if (UNIV_UNLIKELY(rec_get_n_fields_old(rec) != 5)) {
+	if (rec_get_n_fields_old(rec) != DICT_NUM_FIELDS__SYS_FIELDS) {
 		return("wrong number of columns in SYS_FIELDS record");
 	}
 
-	field = rec_get_nth_field_old(rec, 0/*INDEX_ID*/, &len);
-	if (UNIV_UNLIKELY(len != 8)) {
+	field = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_FIELDS__INDEX_ID, &len);
+	if (len != 8) {
 err_len:
 		return("incorrect column length in SYS_FIELDS");
 	}
@@ -1078,20 +1112,6 @@ err_len:
 		}
 	}
 
-	field = rec_get_nth_field_old(rec, 1/*POS*/, &len);
-	if (UNIV_UNLIKELY(len != 4)) {
-		goto err_len;
-	}
-
-	rec_get_nth_field_offs_old(rec, 2/*DB_TRX_ID*/, &len);
-	if (UNIV_UNLIKELY(len != DATA_TRX_ID_LEN && len != UNIV_SQL_NULL)) {
-		goto err_len;
-	}
-	rec_get_nth_field_offs_old(rec, 3/*DB_ROLL_PTR*/, &len);
-	if (UNIV_UNLIKELY(len != DATA_ROLL_PTR_LEN && len != UNIV_SQL_NULL)) {
-		goto err_len;
-	}
-
 	/* The next field stores the field position in the index and a
 	possible column prefix length if the index field does not
 	contain the whole column. The storage format is like this: if
@@ -1100,6 +1120,12 @@ err_len:
 	bytes the prefix length for the field. Otherwise the field
 	number (index->n_def) is contained in the 2 LOW bytes. */
 
+	field = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_FIELDS__POS, &len);
+	if (len != 4) {
+		goto err_len;
+	}
+
 	pos_and_prefix_len = mach_read_from_4(field);
 
 	if (index && UNIV_UNLIKELY
@@ -1116,8 +1142,20 @@ err_len:
 		position = pos_and_prefix_len & 0xFFFFUL;
 	}
 
-	field = rec_get_nth_field_old(rec, 4, &len);
-	if (UNIV_UNLIKELY(len < 1 || len == UNIV_SQL_NULL)) {
+	rec_get_nth_field_offs_old(
+		rec, DICT_FLD__SYS_FIELDS__DB_TRX_ID, &len);
+	if (len != DATA_TRX_ID_LEN && len != UNIV_SQL_NULL) {
+		goto err_len;
+	}
+	rec_get_nth_field_offs_old(
+		rec, DICT_FLD__SYS_FIELDS__DB_ROLL_PTR, &len);
+	if (len != DATA_ROLL_PTR_LEN && len != UNIV_SQL_NULL) {
+		goto err_len;
+	}
+
+	field = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_FIELDS__COL_NAME, &len);
+	if (len < 1 || len == UNIV_SQL_NULL) {
 		goto err_len;
 	}
 
@@ -1165,8 +1203,9 @@ dict_load_fields(
 
 	sys_fields = dict_table_get_low("SYS_FIELDS");
 	sys_index = UT_LIST_GET_FIRST(sys_fields->indexes);
-	ut_a(!dict_table_is_comp(sys_fields));
-	ut_a(name_of_col_is(sys_fields, sys_index, 4, "COL_NAME"));
+	ut_ad(!dict_table_is_comp(sys_fields));
+	ut_ad(name_of_col_is(sys_fields, sys_index,
+			     DICT_FLD__SYS_FIELDS__COL_NAME, "COL_NAME"));
 
 	tuple = dtuple_create(heap, 1);
 	dfield = dtuple_get_nth_field(tuple, 0);
@@ -1252,16 +1291,17 @@ dict_load_index_low(
 		*index = NULL;
 	}
 
-	if (UNIV_UNLIKELY(rec_get_deleted_flag(rec, 0))) {
+	if (rec_get_deleted_flag(rec, 0)) {
 		return(dict_load_index_del);
 	}
 
-	if (UNIV_UNLIKELY(rec_get_n_fields_old(rec) != 9)) {
+	if (rec_get_n_fields_old(rec) != DICT_NUM_FIELDS__SYS_INDEXES) {
 		return("wrong number of columns in SYS_INDEXES record");
 	}
 
-	field = rec_get_nth_field_old(rec, 0/*TABLE_ID*/, &len);
-	if (UNIV_UNLIKELY(len != 8)) {
+	field = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_INDEXES__TABLE_ID, &len);
+	if (len != 8) {
 err_len:
 		return("incorrect column length in SYS_INDEXES");
 	}
@@ -1275,53 +1315,61 @@ err_len:
 		return(dict_load_index_id_err);
 	}
 
-	field = rec_get_nth_field_old(rec, 1/*ID*/, &len);
-	if (UNIV_UNLIKELY(len != 8)) {
+	field = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_INDEXES__ID, &len);
+	if (len != 8) {
 		goto err_len;
 	}
 
 	id = mach_read_from_8(field);
 
-	rec_get_nth_field_offs_old(rec, 2/*DB_TRX_ID*/, &len);
-	if (UNIV_UNLIKELY(len != DATA_TRX_ID_LEN && len != UNIV_SQL_NULL)) {
+	rec_get_nth_field_offs_old(
+		rec, DICT_FLD__SYS_INDEXES__DB_TRX_ID, &len);
+	if (len != DATA_TRX_ID_LEN && len != UNIV_SQL_NULL) {
 		goto err_len;
 	}
-	rec_get_nth_field_offs_old(rec, 3/*DB_ROLL_PTR*/, &len);
-	if (UNIV_UNLIKELY(len != DATA_ROLL_PTR_LEN && len != UNIV_SQL_NULL)) {
+	rec_get_nth_field_offs_old(
+		rec, DICT_FLD__SYS_INDEXES__DB_ROLL_PTR, &len);
+	if (len != DATA_ROLL_PTR_LEN && len != UNIV_SQL_NULL) {
 		goto err_len;
 	}
 
-	field = rec_get_nth_field_old(rec, 4/*NAME*/, &name_len);
-	if (UNIV_UNLIKELY(name_len == UNIV_SQL_NULL)) {
+	field = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_INDEXES__NAME, &name_len);
+	if (name_len == UNIV_SQL_NULL) {
 		goto err_len;
 	}
 
 	name_buf = mem_heap_strdupl(heap, (const char*) field,
 				    name_len);
 
-	field = rec_get_nth_field_old(rec, 5/*N_FIELDS*/, &len);
-	if (UNIV_UNLIKELY(len != 4)) {
+	field = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_INDEXES__N_FIELDS, &len);
+	if (len != 4) {
 		goto err_len;
 	}
 	n_fields = mach_read_from_4(field);
 
-	field = rec_get_nth_field_old(rec, 6/*TYPE*/, &len);
-	if (UNIV_UNLIKELY(len != 4)) {
+	field = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_INDEXES__TYPE, &len);
+	if (len != 4) {
 		goto err_len;
 	}
 	type = mach_read_from_4(field);
-	if (UNIV_UNLIKELY(type & (~0 << DICT_IT_BITS))) {
+	if (type & (~0 << DICT_IT_BITS)) {
 		return("unknown SYS_INDEXES.TYPE bits");
 	}
 
-	field = rec_get_nth_field_old(rec, 7/*SPACE*/, &len);
-	if (UNIV_UNLIKELY(len != 4)) {
+	field = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_INDEXES__SPACE, &len);
+	if (len != 4) {
 		goto err_len;
 	}
 	space = mach_read_from_4(field);
 
-	field = rec_get_nth_field_old(rec, 8/*PAGE_NO*/, &len);
-	if (UNIV_UNLIKELY(len != 4)) {
+	field = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_INDEXES__PAGE_NO, &len);
+	if (len != 4) {
 		goto err_len;
 	}
 
@@ -1373,9 +1421,11 @@ dict_load_indexes(
 
 	sys_indexes = dict_table_get_low("SYS_INDEXES");
 	sys_index = UT_LIST_GET_FIRST(sys_indexes->indexes);
-	ut_a(!dict_table_is_comp(sys_indexes));
-	ut_a(name_of_col_is(sys_indexes, sys_index, 4, "NAME"));
-	ut_a(name_of_col_is(sys_indexes, sys_index, 8, "PAGE_NO"));
+	ut_ad(!dict_table_is_comp(sys_indexes));
+	ut_ad(name_of_col_is(sys_indexes, sys_index,
+			     DICT_FLD__SYS_INDEXES__NAME, "NAME"));
+	ut_ad(name_of_col_is(sys_indexes, sys_index,
+			     DICT_FLD__SYS_INDEXES__PAGE_NO, "PAGE_NO"));
 
 	tuple = dtuple_create(heap, 1);
 	dfield = dtuple_get_nth_field(tuple, 0);
@@ -1570,52 +1620,58 @@ dict_load_table_low(
 	ulint		flags = 0;
 	ulint		flags2;
 
-	if (UNIV_UNLIKELY(rec_get_deleted_flag(rec, 0))) {
+	if (rec_get_deleted_flag(rec, 0)) {
 		return("delete-marked record in SYS_TABLES");
 	}
 
-	if (UNIV_UNLIKELY(rec_get_n_fields_old(rec) != 10)) {
+	if (rec_get_n_fields_old(rec) != DICT_NUM_FIELDS__SYS_TABLES) {
 		return("wrong number of columns in SYS_TABLES record");
 	}
 
-	rec_get_nth_field_offs_old(rec, 0/*NAME*/, &len);
-	if (UNIV_UNLIKELY(len < 1 || len == UNIV_SQL_NULL)) {
+	rec_get_nth_field_offs_old(
+		rec, DICT_FLD__SYS_TABLES__NAME, &len);
+	if (len < 1 || len == UNIV_SQL_NULL) {
 err_len:
 		return("incorrect column length in SYS_TABLES");
 	}
-	rec_get_nth_field_offs_old(rec, 1/*DB_TRX_ID*/, &len);
-	if (UNIV_UNLIKELY(len != DATA_TRX_ID_LEN && len != UNIV_SQL_NULL)) {
+	rec_get_nth_field_offs_old(
+		rec, DICT_FLD__SYS_TABLES__DB_TRX_ID, &len);
+	if (len != DATA_TRX_ID_LEN && len != UNIV_SQL_NULL) {
 		goto err_len;
 	}
-	rec_get_nth_field_offs_old(rec, 2/*DB_ROLL_PTR*/, &len);
-	if (UNIV_UNLIKELY(len != DATA_ROLL_PTR_LEN && len != UNIV_SQL_NULL)) {
+	rec_get_nth_field_offs_old(
+		rec, DICT_FLD__SYS_TABLES__DB_ROLL_PTR, &len);
+	if (len != DATA_ROLL_PTR_LEN && len != UNIV_SQL_NULL) {
 		goto err_len;
 	}
 
-	rec_get_nth_field_offs_old(rec, 3/*ID*/, &len);
-	if (UNIV_UNLIKELY(len != 8)) {
+	rec_get_nth_field_offs_old(rec, DICT_FLD__SYS_TABLES__ID, &len);
+	if (len != 8) {
 		goto err_len;
 	}
 
-	field = rec_get_nth_field_old(rec, 4/*N_COLS*/, &len);
-	if (UNIV_UNLIKELY(len != 4)) {
+	field = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_TABLES__N_COLS, &len);
+	if (len != 4) {
 		goto err_len;
 	}
 
 	n_cols = mach_read_from_4(field);
 
-	rec_get_nth_field_offs_old(rec, 5/*TYPE*/, &len);
-	if (UNIV_UNLIKELY(len != 4)) {
+	rec_get_nth_field_offs_old(rec, DICT_FLD__SYS_TABLES__TYPE, &len);
+	if (len != 4) {
 		goto err_len;
 	}
 
-	rec_get_nth_field_offs_old(rec, 6/*MIX_ID*/, &len);
-	if (UNIV_UNLIKELY(len != 8)) {
+	rec_get_nth_field_offs_old(
+		rec, DICT_FLD__SYS_TABLES__MIX_ID, &len);
+	if (len != 8) {
 		goto err_len;
 	}
 
-	field = rec_get_nth_field_old(rec, 7/*MIX_LEN*/, &len);
-	if (UNIV_UNLIKELY(len != 4)) {
+	field = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_TABLES__MIX_LEN, &len);
+	if (len != 4) {
 		goto err_len;
 	}
 
@@ -1625,14 +1681,15 @@ err_len:
 	/* DICT_TF2_FTS will be set when indexes is being loaded */
 	flags2 &= ~DICT_TF2_FTS;
 
-	rec_get_nth_field_offs_old(rec, 8/*CLUSTER_ID*/, &len);
-	if (UNIV_UNLIKELY(len != UNIV_SQL_NULL)) {
+	rec_get_nth_field_offs_old(
+		rec, DICT_FLD__SYS_TABLES__CLUSTER_ID, &len);
+	if (len != UNIV_SQL_NULL) {
 		goto err_len;
 	}
 
-	field = rec_get_nth_field_old(rec, 9/*SPACE*/, &len);
-
-	if (UNIV_UNLIKELY(len != 4)) {
+	field = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_TABLES__SPACE, &len);
+	if (len != 4) {
 		goto err_len;
 	}
 
@@ -1642,7 +1699,8 @@ err_len:
 	flags = dict_sys_tables_get_flags(rec);
 
 	if (UNIV_UNLIKELY(flags == ULINT_UNDEFINED)) {
-		field = rec_get_nth_field_old(rec, 5/*TYPE*/, &len);
+		field = rec_get_nth_field_old(
+			rec, DICT_FLD__SYS_TABLES__TYPE, &len);
 		ut_ad(len == 4); /* this was checked earlier */
 		flags = mach_read_from_4(field);
 
@@ -1683,7 +1741,7 @@ err_len:
 	*table = dict_mem_table_create(
 		name, space, n_cols & ~DICT_N_COLS_COMPACT, flags, flags2);
 
-	field = rec_get_nth_field_old(rec, 3/*ID*/, &len);
+	field = rec_get_nth_field_old(rec, DICT_FLD__SYS_TABLES__ID, &len);
 	ut_ad(len == 8); /* this was checked earlier */
 
 	(*table)->id = mach_read_from_8(field);
@@ -1735,12 +1793,17 @@ dict_load_table(
 
 	sys_tables = dict_table_get_low("SYS_TABLES");
 	sys_index = UT_LIST_GET_FIRST(sys_tables->indexes);
-	ut_a(!dict_table_is_comp(sys_tables));
-	ut_a(name_of_col_is(sys_tables, sys_index, 3, "ID"));
-	ut_a(name_of_col_is(sys_tables, sys_index, 4, "N_COLS"));
-	ut_a(name_of_col_is(sys_tables, sys_index, 5, "TYPE"));
-	ut_a(name_of_col_is(sys_tables, sys_index, 7, "MIX_LEN"));
-	ut_a(name_of_col_is(sys_tables, sys_index, 9, "SPACE"));
+	ut_ad(!dict_table_is_comp(sys_tables));
+	ut_ad(name_of_col_is(sys_tables, sys_index,
+			     DICT_FLD__SYS_TABLES__ID, "ID"));
+	ut_ad(name_of_col_is(sys_tables, sys_index,
+			     DICT_FLD__SYS_TABLES__N_COLS, "N_COLS"));
+	ut_ad(name_of_col_is(sys_tables, sys_index,
+			     DICT_FLD__SYS_TABLES__TYPE, "TYPE"));
+	ut_ad(name_of_col_is(sys_tables, sys_index,
+			     DICT_FLD__SYS_TABLES__MIX_LEN, "MIX_LEN"));
+	ut_ad(name_of_col_is(sys_tables, sys_index,
+			     DICT_FLD__SYS_TABLES__SPACE, "SPACE"));
 
 	tuple = dtuple_create(heap, 1);
 	dfield = dtuple_get_nth_field(tuple, 0);
@@ -1763,7 +1826,8 @@ err_exit:
 		return(NULL);
 	}
 
-	field = rec_get_nth_field_old(rec, 0, &len);
+	field = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_TABLES__NAME, &len);
 
 	/* Check if the table name in record is the searched one */
 	if (len != ut_strlen(name) || ut_memcmp(name, field, len) != 0) {
@@ -1957,7 +2021,7 @@ dict_load_table_on_id(
 	sys_tables = dict_sys->sys_tables;
 	sys_table_ids = dict_table_get_next_index(
 		dict_table_get_first_index(sys_tables));
-	ut_a(!dict_table_is_comp(sys_tables));
+	ut_ad(!dict_table_is_comp(sys_tables));
 	heap = mem_heap_create(256);
 
 	tuple  = dtuple_create(heap, 1);
@@ -1980,7 +2044,8 @@ check_rec:
 		/* Now we have the record in the secondary index
 		containing the table ID and NAME */
 
-		field = rec_get_nth_field_old(rec, 0, &len);
+		field = rec_get_nth_field_old(
+			rec, DICT_FLD__SYS_TABLE_IDS__ID, &len);
 		ut_ad(len == 8);
 
 		/* Check if the table id in record is the one searched for */
@@ -1997,7 +2062,8 @@ check_rec:
 				}
 			} else {
 				/* Now we get the table name from the record */
-				field = rec_get_nth_field_old(rec, 1, &len);
+				field = rec_get_nth_field_old(rec,
+					DICT_FLD__SYS_TABLE_IDS__NAME, &len);
 				/* Load the table definition to memory */
 				table = dict_load_table(
 					mem_heap_strdupl(
@@ -2072,7 +2138,7 @@ dict_load_foreign_cols(
 	sys_foreign_cols = dict_table_get_low("SYS_FOREIGN_COLS");
 
 	sys_index = UT_LIST_GET_FIRST(sys_foreign_cols->indexes);
-	ut_a(!dict_table_is_comp(sys_foreign_cols));
+	ut_ad(!dict_table_is_comp(sys_foreign_cols));
 
 	tuple = dtuple_create(foreign->heap, 1);
 	dfield = dtuple_get_nth_field(tuple, 0);
@@ -2089,19 +2155,23 @@ dict_load_foreign_cols(
 		ut_a(btr_pcur_is_on_user_rec(&pcur));
 		ut_a(!rec_get_deleted_flag(rec, 0));
 
-		field = rec_get_nth_field_old(rec, 0, &len);
+		field = rec_get_nth_field_old(
+			rec, DICT_FLD__SYS_FOREIGN_COLS__ID, &len);
 		ut_a(len == id_len);
 		ut_a(ut_memcmp(id, field, len) == 0);
 
-		field = rec_get_nth_field_old(rec, 1, &len);
+		field = rec_get_nth_field_old(
+			rec, DICT_FLD__SYS_FOREIGN_COLS__POS, &len);
 		ut_a(len == 4);
 		ut_a(i == mach_read_from_4(field));
 
-		field = rec_get_nth_field_old(rec, 4, &len);
+		field = rec_get_nth_field_old(
+			rec, DICT_FLD__SYS_FOREIGN_COLS__FOR_COL_NAME, &len);
 		foreign->foreign_col_names[i] = mem_heap_strdupl(
 			foreign->heap, (char*) field, len);
 
-		field = rec_get_nth_field_old(rec, 5, &len);
+		field = rec_get_nth_field_old(
+			rec, DICT_FLD__SYS_FOREIGN_COLS__REF_COL_NAME, &len);
 		foreign->referenced_col_names[i] = mem_heap_strdupl(
 			foreign->heap, (char*) field, len);
 
@@ -2153,7 +2223,7 @@ dict_load_foreign(
 	sys_foreign = dict_table_get_low("SYS_FOREIGN");
 
 	sys_index = UT_LIST_GET_FIRST(sys_foreign->indexes);
-	ut_a(!dict_table_is_comp(sys_foreign));
+	ut_ad(!dict_table_is_comp(sys_foreign));
 
 	tuple = dtuple_create(heap2, 1);
 	dfield = dtuple_get_nth_field(tuple, 0);
@@ -2180,7 +2250,7 @@ dict_load_foreign(
 		return(DB_ERROR);
 	}
 
-	field = rec_get_nth_field_old(rec, 0, &len);
+	field = rec_get_nth_field_old(rec, DICT_FLD__SYS_FOREIGN__ID, &len);
 
 	/* Check if the id in record is the searched one */
 	if (len != id_len || ut_memcmp(id, field, len) != 0) {
@@ -2204,7 +2274,8 @@ dict_load_foreign(
 	foreign = dict_mem_foreign_create();
 
 	n_fields_and_type = mach_read_from_4(
-		rec_get_nth_field_old(rec, 5, &len));
+		rec_get_nth_field_old(
+			rec, DICT_FLD__SYS_FOREIGN__N_COLS, &len));
 
 	ut_a(len == 4);
 
@@ -2215,13 +2286,15 @@ dict_load_foreign(
 
 	foreign->id = mem_heap_strdupl(foreign->heap, id, id_len);
 
-	field = rec_get_nth_field_old(rec, 3, &len);
+	field = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_FOREIGN__FOR_NAME, &len);
 
 	foreign->foreign_table_name = mem_heap_strdupl(
 		foreign->heap, (char*) field, len);
 	dict_mem_foreign_table_name_lookup_set(foreign, TRUE);
 
-	field = rec_get_nth_field_old(rec, 4, &len);
+	field = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_FOREIGN__REF_NAME, &len);
 	foreign->referenced_table_name = mem_heap_strdupl(
 		foreign->heap, (char*) field, len);
 	dict_mem_referenced_table_name_lookup_set(foreign, TRUE);
@@ -2334,7 +2407,7 @@ dict_load_foreigns(
 		return(DB_ERROR);
 	}
 
-	ut_a(!dict_table_is_comp(sys_foreign));
+	ut_ad(!dict_table_is_comp(sys_foreign));
 	mtr_start(&mtr);
 
 	/* Get the secondary index based on FOR_NAME from table
@@ -2365,7 +2438,8 @@ loop:
 	name and a foreign constraint ID */
 
 	rec = btr_pcur_get_rec(&pcur);
-	field = rec_get_nth_field_old(rec, 0, &len);
+	field = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_FOREIGN_FOR_NAME__NAME, &len);
 
 	/* Check if the table name in the record is the one searched for; the
 	following call does the comparison in the latin1_swedish_ci
@@ -2399,7 +2473,8 @@ loop:
 	}
 
 	/* Now we get a foreign key constraint id */
-	field = rec_get_nth_field_old(rec, 1, &len);
+	field = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_FOREIGN_FOR_NAME__ID, &len);
 
 	btr_pcur_store_position(&pcur, &mtr);
 

=== modified file 'storage/innobase/dict/dict0mem.cc'
--- a/storage/innobase/dict/dict0mem.cc	2011-12-20 09:45:15 +0000
+++ b/storage/innobase/dict/dict0mem.cc	2012-01-18 15:39:14 +0000
@@ -113,12 +113,12 @@ dict_mem_table_create(
 	if (dict_table_has_fts_index(table)
 	    || DICT_TF2_FLAG_IS_SET(table, DICT_TF2_FTS_HAS_DOC_ID)
 	    || DICT_TF2_FLAG_IS_SET(table, DICT_TF2_FTS_ADD_DOC_ID)) {
-                table->fts = fts_create(table);
+		table->fts = fts_create(table);
 		table->fts->cache = fts_cache_create(table);
 		fts_optimize_add_table(table);
-        } else {
-                table->fts = NULL;
-        }
+	} else {
+		table->fts = NULL;
+	}
 #endif /* !UNIV_HOTBACKUP */
 
 	return(table);

=== modified file 'storage/innobase/fil/fil0fil.cc'
--- a/storage/innobase/fil/fil0fil.cc	2011-12-19 08:43:28 +0000
+++ b/storage/innobase/fil/fil0fil.cc	2012-01-18 15:39:14 +0000
@@ -1178,9 +1178,8 @@ fil_space_truncate_start(
 #endif /* UNIV_LOG_ARCHIVE */
 
 /*******************************************************************//**
-Creates a tablespace memory object and puts it to the tablespace memory
-cache.  If there is an error, prints an error message to the .err log.
-This function is not called for the system tablespace.
+Creates a space memory object and puts it to the 'fil system' hash table.
+If there is an error, prints an error message to the .err log.
 @return	TRUE if success */
 UNIV_INTERN
 ibool
@@ -3695,7 +3694,7 @@ next_datadir_item:
 /*******************************************************************//**
 Returns TRUE if a single-table tablespace does not exist in the memory cache,
 or is being deleted there.
-@return	TRUE if does not exist or is being\ deleted */
+@return	TRUE if does not exist or is being deleted */
 UNIV_INTERN
 ibool
 fil_tablespace_deleted_or_being_deleted_in_mem(

=== modified file 'storage/innobase/handler/ha_innodb.cc'
--- a/storage/innobase/handler/ha_innodb.cc	2012-01-17 15:43:31 +0000
+++ b/storage/innobase/handler/ha_innodb.cc	2012-01-18 15:39:14 +0000
@@ -35,12 +35,8 @@ this program; if not, write to the Free
 			// EXPLAIN_FILENAME_MAX_EXTRA_LENGTH
 
 #include <sql_acl.h>	// PROCESS_ACL
-#include <m_ctype.h>
 #include <mysys_err.h>
-#include <mysql/plugin.h>
 #include <mysql/innodb_priv.h>
-#include <mysql/psi/psi.h>
-#include <my_sys.h>
 
 /** @file ha_innodb.cc */
 

=== modified file 'storage/innobase/handler/i_s.cc'
--- a/storage/innobase/handler/i_s.cc	2011-11-30 10:34:38 +0000
+++ b/storage/innobase/handler/i_s.cc	2012-01-19 10:34:18 +0000
@@ -2596,6 +2596,11 @@ i_s_fts_deleted_generic_fill(
 
 	DBUG_ENTER("i_s_fts_deleted_generic_fill");
 
+	/* deny access to non-superusers */
+	if (check_global_access(thd, PROCESS_ACL)) {
+		DBUG_RETURN(0);
+	}
+
 	if (!fts_internal_tbl_name) {
 		DBUG_RETURN(0);
 	}
@@ -2833,6 +2838,11 @@ i_s_fts_inserted_fill(
 
 	DBUG_ENTER("i_s_fts_inserted_fill");
 
+	/* deny access to non-superusers */
+	if (check_global_access(thd, PROCESS_ACL)) {
+		DBUG_RETURN(0);
+	}
+
 	if (!fts_internal_tbl_name) {
 		DBUG_RETURN(0);
 	}
@@ -3107,6 +3117,11 @@ i_s_fts_index_cache_fill(
 
 	DBUG_ENTER("i_s_fts_index_cache_fill");
 
+	/* deny access to non-superusers */
+	if (check_global_access(thd, PROCESS_ACL)) {
+		DBUG_RETURN(0);
+	}
+
 	if (!fts_internal_tbl_name) {
 		DBUG_RETURN(0);
 	}
@@ -3412,6 +3427,11 @@ i_s_fts_index_table_fill(
 
 	DBUG_ENTER("i_s_fts_index_table_fill");
 
+	/* deny access to non-superusers */
+	if (check_global_access(thd, PROCESS_ACL)) {
+		DBUG_RETURN(0);
+	}
+
 	if (!fts_internal_tbl_name) {
 		DBUG_RETURN(0);
 	}
@@ -3566,6 +3586,11 @@ i_s_fts_config_fill(
 
 	DBUG_ENTER("i_s_fts_config_fill");
 
+	/* deny access to non-superusers */
+	if (check_global_access(thd, PROCESS_ACL)) {
+		DBUG_RETURN(0);
+	}
+
 	if (!fts_internal_tbl_name) {
 		DBUG_RETURN(0);
 	}
@@ -6189,7 +6214,7 @@ innodb_sys_indexes_init(
 {
 	ST_SCHEMA_TABLE*	schema;
 
-	DBUG_ENTER("innodb_sys_index_init");
+	DBUG_ENTER("innodb_sys_indexes_init");
 
 	schema = (ST_SCHEMA_TABLE*) p;
 

=== modified file 'storage/innobase/include/dict0boot.h'
--- a/storage/innobase/include/dict0boot.h	2011-11-08 10:32:23 +0000
+++ b/storage/innobase/include/dict0boot.h	2012-01-18 15:39:14 +0000
@@ -120,30 +120,159 @@ dict_create(void);
 /*-------------------------------------------------------------*/
 /* Dictionary header offsets */
 #define DICT_HDR_ROW_ID		0	/* The latest assigned row id */
-#define	DICT_HDR_TABLE_ID	8	/* The latest assigned table id */
-#define	DICT_HDR_INDEX_ID	16	/* The latest assigned index id */
-#define DICT_HDR_MAX_SPACE_ID	24	/* The latest assigned space id, or 0*/
-#define	DICT_HDR_MIX_ID_LOW	28	/* Obsolete,always DICT_HDR_FIRST_ID */
-#define	DICT_HDR_TABLES		32	/* Root of the table index tree */
-#define	DICT_HDR_TABLE_IDS	36	/* Root of the table index tree */
-#define	DICT_HDR_COLUMNS	40	/* Root of the column index tree */
-#define	DICT_HDR_INDEXES	44	/* Root of the index index tree */
-#define	DICT_HDR_FIELDS		48	/* Root of the index field
-					index tree */
+#define DICT_HDR_TABLE_ID	8	/* The latest assigned table id */
+#define DICT_HDR_INDEX_ID	16	/* The latest assigned index id */
+#define DICT_HDR_MAX_SPACE_ID	24	/* The latest assigned space id,or 0*/
+#define DICT_HDR_MIX_ID_LOW	28	/* Obsolete,always DICT_HDR_FIRST_ID*/
+#define DICT_HDR_TABLES		32	/* Root of SYS_TABLES clust index */
+#define DICT_HDR_TABLE_IDS	36	/* Root of SYS_TABLE_IDS sec index */
+#define DICT_HDR_COLUMNS	40	/* Root of SYS_COLUMNS clust index */
+#define DICT_HDR_INDEXES	44	/* Root of SYS_INDEXES clust index */
+#define DICT_HDR_FIELDS		48	/* Root of SYS_FIELDS clust index */
 
 #define DICT_HDR_FSEG_HEADER	56	/* Segment header for the tablespace
 					segment into which the dictionary
 					header is created */
 /*-------------------------------------------------------------*/
 
+/* The columns in SYS_TABLES */
+enum dict_col_sys_tables_enum {
+	DICT_COL__SYS_TABLES__NAME		= 0,
+	DICT_COL__SYS_TABLES__ID		= 1,
+	DICT_COL__SYS_TABLES__N_COLS		= 2,
+	DICT_COL__SYS_TABLES__TYPE		= 3,
+	DICT_COL__SYS_TABLES__MIX_ID		= 4,
+	DICT_COL__SYS_TABLES__MIX_LEN		= 5,
+	DICT_COL__SYS_TABLES__CLUSTER_ID	= 6,
+	DICT_COL__SYS_TABLES__SPACE		= 7,
+	DICT_NUM_COLS__SYS_TABLES		= 8
+};
 /* The field numbers in the SYS_TABLES clustered index */
-#define DICT_SYS_TABLES_TYPE_FIELD		5
-
+enum dict_fld_sys_tables_enum {
+	DICT_FLD__SYS_TABLES__NAME		= 0,
+	DICT_FLD__SYS_TABLES__DB_TRX_ID		= 1,
+	DICT_FLD__SYS_TABLES__DB_ROLL_PTR	= 2,
+	DICT_FLD__SYS_TABLES__ID		= 3,
+	DICT_FLD__SYS_TABLES__N_COLS		= 4,
+	DICT_FLD__SYS_TABLES__TYPE		= 5,
+	DICT_FLD__SYS_TABLES__MIX_ID		= 6,
+	DICT_FLD__SYS_TABLES__MIX_LEN		= 7,
+	DICT_FLD__SYS_TABLES__CLUSTER_ID	= 8,
+	DICT_FLD__SYS_TABLES__SPACE		= 9,
+	DICT_NUM_FIELDS__SYS_TABLES		= 10
+};
+/* The field numbers in the SYS_TABLE_IDS index */
+enum dict_fld_sys_table_ids_enum {
+	DICT_FLD__SYS_TABLE_IDS__ID		= 0,
+	DICT_FLD__SYS_TABLE_IDS__NAME		= 1,
+	DICT_NUM_FIELDS__SYS_TABLE_IDS		= 2
+};
+/* The columns in SYS_COLUMNS */
+enum dict_col_sys_columns_enum {
+	DICT_COL__SYS_COLUMNS__TABLE_ID		= 0,
+	DICT_COL__SYS_COLUMNS__POS		= 1,
+	DICT_COL__SYS_COLUMNS__NAME		= 2,
+	DICT_COL__SYS_COLUMNS__MTYPE		= 3,
+	DICT_COL__SYS_COLUMNS__PRTYPE		= 4,
+	DICT_COL__SYS_COLUMNS__LEN		= 5,
+	DICT_COL__SYS_COLUMNS__PREC		= 6,
+	DICT_NUM_COLS__SYS_COLUMNS		= 7
+};
+/* The field numbers in the SYS_TABLES clustered index */
+enum dict_fld_sys_columns_enum {
+	DICT_FLD__SYS_COLUMNS__TABLE_ID		= 0,
+	DICT_FLD__SYS_COLUMNS__POS		= 1,
+	DICT_FLD__SYS_COLUMNS__DB_TRX_ID	= 2,
+	DICT_FLD__SYS_COLUMNS__DB_ROLL_PTR	= 3,
+	DICT_FLD__SYS_COLUMNS__NAME		= 4,
+	DICT_FLD__SYS_COLUMNS__MTYPE		= 5,
+	DICT_FLD__SYS_COLUMNS__PRTYPE		= 6,
+	DICT_FLD__SYS_COLUMNS__LEN		= 7,
+	DICT_FLD__SYS_COLUMNS__PREC		= 8,
+	DICT_NUM_FIELDS__SYS_COLUMNS		= 9
+};
+/* The columns in SYS_INDEXES */
+enum dict_col_sys_indexes_enum {
+	DICT_COL__SYS_INDEXES__TABLE_ID		= 0,
+	DICT_COL__SYS_INDEXES__ID		= 1,
+	DICT_COL__SYS_INDEXES__NAME		= 2,
+	DICT_COL__SYS_INDEXES__N_FIELDS		= 3,
+	DICT_COL__SYS_INDEXES__TYPE		= 4,
+	DICT_COL__SYS_INDEXES__SPACE		= 5,
+	DICT_COL__SYS_INDEXES__PAGE_NO		= 6,
+	DICT_NUM_COLS__SYS_INDEXES		= 7
+};
+/* The field numbers in the SYS_INDEXES clustered index */
+enum dict_fld_sys_indexes_enum {
+	DICT_FLD__SYS_INDEXES__TABLE_ID		= 0,
+	DICT_FLD__SYS_INDEXES__ID		= 1,
+	DICT_FLD__SYS_INDEXES__DB_TRX_ID	= 2,
+	DICT_FLD__SYS_INDEXES__DB_ROLL_PTR	= 3,
+	DICT_FLD__SYS_INDEXES__NAME		= 4,
+	DICT_FLD__SYS_INDEXES__N_FIELDS		= 5,
+	DICT_FLD__SYS_INDEXES__TYPE		= 6,
+	DICT_FLD__SYS_INDEXES__SPACE		= 7,
+	DICT_FLD__SYS_INDEXES__PAGE_NO		= 8,
+	DICT_NUM_FIELDS__SYS_INDEXES		= 9
+};
+/* The columns in SYS_FIELDS */
+enum dict_col_sys_fields_enum {
+	DICT_COL__SYS_FIELDS__INDEX_ID		= 0,
+	DICT_COL__SYS_FIELDS__POS		= 1,
+	DICT_COL__SYS_FIELDS__COL_NAME		= 2,
+	DICT_NUM_COLS__SYS_FIELDS		= 3
+};
 /* The field numbers in the SYS_INDEXES clustered index */
-#define DICT_SYS_INDEXES_PAGE_NO_FIELD	 8
-#define DICT_SYS_INDEXES_SPACE_NO_FIELD	 7
-#define DICT_SYS_INDEXES_TYPE_FIELD	 6
-#define DICT_SYS_INDEXES_NAME_FIELD	 4
+enum dict_fld_sys_fields_enum {
+	DICT_FLD__SYS_FIELDS__INDEX_ID		= 0,
+	DICT_FLD__SYS_FIELDS__POS		= 1,
+	DICT_FLD__SYS_FIELDS__DB_TRX_ID		= 2,
+	DICT_FLD__SYS_FIELDS__DB_ROLL_PTR	= 3,
+	DICT_FLD__SYS_FIELDS__COL_NAME		= 4,
+	DICT_NUM_FIELDS__SYS_FIELDS		= 5
+};
+/* The columns in SYS_FOREIGN */
+enum dict_col_sys_foreign_enum {
+	DICT_COL__SYS_FOREIGN__ID		= 0,
+	DICT_COL__SYS_FOREIGN__FOR_NAME		= 1,
+	DICT_COL__SYS_FOREIGN__REF_NAME		= 2,
+	DICT_COL__SYS_FOREIGN__N_COLS		= 3,
+	DICT_NUM_COLS__SYS_FOREIGN		= 4
+};
+/* The field numbers in the SYS_FOREIGN clustered index */
+enum dict_fld_sys_foreign_enum {
+	DICT_FLD__SYS_FOREIGN__ID		= 0,
+	DICT_FLD__SYS_FOREIGN__DB_TRX_ID	= 1,
+	DICT_FLD__SYS_FOREIGN__DB_ROLL_PTR	= 2,
+	DICT_FLD__SYS_FOREIGN__FOR_NAME		= 3,
+	DICT_FLD__SYS_FOREIGN__REF_NAME		= 4,
+	DICT_FLD__SYS_FOREIGN__N_COLS		= 5,
+	DICT_NUM_FIELDS__SYS_FOREIGN		= 6
+};
+/* The field numbers in the SYS_FOREIGN_FOR_NAME secondary index */
+enum dict_fld_sys_foreign_for_name_enum {
+	DICT_FLD__SYS_FOREIGN_FOR_NAME__NAME	= 0,
+	DICT_FLD__SYS_FOREIGN_FOR_NAME__ID	= 1,
+	DICT_NUM_FIELDS__SYS_FOREIGN_FOR_NAME	= 2
+};
+/* The columns in SYS_FOREIGN_COLS */
+enum dict_col_sys_foreign_cols_enum {
+	DICT_COL__SYS_FOREIGN_COLS__ID			= 0,
+	DICT_COL__SYS_FOREIGN_COLS__POS			= 1,
+	DICT_COL__SYS_FOREIGN_COLS__FOR_COL_NAME	= 2,
+	DICT_COL__SYS_FOREIGN_COLS__REF_COL_NAME	= 3,
+	DICT_NUM_COLS__SYS_FOREIGN_COLS			= 4
+};
+/* The field numbers in the SYS_FOREIGN_COLS clustered index */
+enum dict_fld_sys_foreign_cols_enum {
+	DICT_FLD__SYS_FOREIGN_COLS__ID			= 0,
+	DICT_FLD__SYS_FOREIGN_COLS__POS			= 1,
+	DICT_FLD__SYS_FOREIGN_COLS__DB_TRX_ID		= 2,
+	DICT_FLD__SYS_FOREIGN_COLS__DB_ROLL_PTR		= 3,
+	DICT_FLD__SYS_FOREIGN_COLS__FOR_COL_NAME	= 4,
+	DICT_FLD__SYS_FOREIGN_COLS__REF_COL_NAME	= 5,
+	DICT_NUM_FIELDS__SYS_FOREIGN_COLS		= 6
+};
 
 /* When a row id which is zero modulo this number (which must be a power of
 two) is assigned, the field DICT_HDR_ROW_ID on the dictionary header page is

=== modified file 'storage/innobase/include/dict0mem.h'
--- a/storage/innobase/include/dict0mem.h	2011-12-19 08:43:28 +0000
+++ b/storage/innobase/include/dict0mem.h	2012-01-18 15:39:14 +0000
@@ -119,8 +119,6 @@ to cache the BLOB prefixes. */
 #define DICT_TF_BITS	(DICT_TF_WIDTH_COMPACT		\
 			+ DICT_TF_WIDTH_ZIP_SSIZE	\
 			+ DICT_TF_WIDTH_ATOMIC_BLOBS)
-/** Width of all the currently unknown/unused table flags */
-#define DICT_TF_WIDTH_UNUSED	((UNIV_WORD_SIZE * 8) - DICT_TF_BITS)
 
 /** A mask of all the known/used bits in table flags */
 #define DICT_TF_BIT_MASK	(~(~0 << DICT_TF_BITS))
@@ -581,7 +579,6 @@ a foreign key constraint is enforced, th
 #define DICT_FOREIGN_ON_UPDATE_NO_ACTION 32	/*!< ON UPDATE NO ACTION */
 /* @} */
 
-
 /** Data structure for a database table.  Most fields will be
 initialized to 0, NULL or FALSE in dict_mem_table_create(). */
 struct dict_table_struct{
@@ -714,7 +711,7 @@ struct dict_table_struct{
 				lock we keep a pointer to the transaction
 				here in the autoinc_trx variable. This is to
 				avoid acquiring the lock_sys_t::mutex and
-			       	scanning the vector in trx_t.
+				scanning the vector in trx_t.
 
 				When an AUTOINC lock has to wait, the
 				corresponding lock instance is created on
@@ -762,8 +759,8 @@ struct dict_table_struct{
 				MySQL does NOT itself check the number of
 				open handles at drop */
 	UT_LIST_BASE_NODE_T(lock_t)
-			locks; /*!< list of locks on the table; protected
-			       by lock_sys->mutex */
+			locks;	/*!< list of locks on the table; protected
+				by lock_sys->mutex */
 #endif /* !UNIV_HOTBACKUP */
 
 #ifdef UNIV_DEBUG

=== modified file 'storage/innobase/include/dict0types.h'
--- a/storage/innobase/include/dict0types.h	2011-11-08 10:32:23 +0000
+++ b/storage/innobase/include/dict0types.h	2012-01-18 15:39:14 +0000
@@ -42,7 +42,7 @@ typedef struct tab_node_struct		tab_node
 
 /* The ibuf table and indexes's ID are assigned as the number
 DICT_IBUF_ID_MIN plus the space id */
-#define DICT_IBUF_ID_MIN        0xFFFFFFFF00000000ULL
+#define DICT_IBUF_ID_MIN	0xFFFFFFFF00000000ULL
 
 typedef ib_id_t		table_id_t;
 typedef ib_id_t		index_id_t;
@@ -53,11 +53,11 @@ be responsible to deal with corrupted ta
 Note: please define the IGNORE_ERR_* as bits, so their value can
 be or-ed together */
 enum dict_err_ignore {
-        DICT_ERR_IGNORE_NONE = 0,        /*!< no error to ignore */
-        DICT_ERR_IGNORE_INDEX_ROOT = 1, /*!< ignore error if index root
+	DICT_ERR_IGNORE_NONE = 0,	/*!< no error to ignore */
+	DICT_ERR_IGNORE_INDEX_ROOT = 1,	/*!< ignore error if index root
 					page is FIL_NULL or incorrect value */
 	DICT_ERR_IGNORE_CORRUPT = 2,	/*!< skip corrupted indexes */
-        DICT_ERR_IGNORE_ALL = 0xFFFF	/*!< ignore all errors */
+	DICT_ERR_IGNORE_ALL = 0xFFFF	/*!< ignore all errors */
 };
 
 typedef enum dict_err_ignore		dict_err_ignore_t;

=== modified file 'storage/innobase/include/fil0fil.h'
--- a/storage/innobase/include/fil0fil.h	2011-12-08 20:20:49 +0000
+++ b/storage/innobase/include/fil0fil.h	2012-01-18 15:39:14 +0000
@@ -225,8 +225,8 @@ fil_space_truncate_start(
 				some initial files in the space */
 #endif /* UNIV_LOG_ARCHIVE */
 /*******************************************************************//**
-Creates a space memory object and puts it to the 'fil system' hash table. If
-there is an error, prints an error message to the .err log.
+Creates a space memory object and puts it to the 'fil system' hash table.
+If there is an error, prints an error message to the .err log.
 @return	TRUE if success */
 UNIV_INTERN
 ibool
@@ -526,7 +526,7 @@ fil_load_single_table_tablespaces(void);
 /*******************************************************************//**
 Returns TRUE if a single-table tablespace does not exist in the memory cache,
 or is being deleted there.
-@return	TRUE if does not exist or is being\ deleted */
+@return	TRUE if does not exist or is being deleted */
 UNIV_INTERN
 ibool
 fil_tablespace_deleted_or_being_deleted_in_mem(

=== modified file 'storage/innobase/os/os0file.cc'
--- a/storage/innobase/os/os0file.cc	2011-12-21 19:35:09 +0000
+++ b/storage/innobase/os/os0file.cc	2012-01-19 14:15:22 +0000
@@ -3200,6 +3200,87 @@ retry:
 		" setting innodb_native_aio = off in my.cnf\n");
 	return(FALSE);
 }
+
+/******************************************************************//**
+Checks if the system supports native linux aio. On some kernel
+versions where native aio is supported it won't work on tmpfs. In such
+cases we can't use native aio as it is not possible to mix simulated
+and native aio.
+@return: TRUE if supported, FALSE otherwise. */
+static
+ibool
+os_aio_native_aio_supported(void)
+/*=============================*/
+{
+	int			fd;
+	byte*			buf;
+	byte*			ptr;
+	struct io_event		io_event;
+	io_context_t		io_ctx;
+	struct iocb		iocb;
+	struct iocb*		p_iocb;
+	int			err;
+
+	if (!os_aio_linux_create_io_ctx(1, &io_ctx)) {
+		/* The platform does not support native aio. */
+		return(FALSE);
+	}
+
+	/* Now check if tmpdir supports native aio ops. */
+	fd = innobase_mysql_tmpfile();
+
+	if (fd < 0) {
+		ut_print_timestamp(stderr);
+		fprintf(stderr, " InnoDB: Error: unable to create "
+			"temp file to check native AIO support.\n");
+
+		return(FALSE);
+	}
+
+	memset(&io_event, 0x0, sizeof(io_event));
+
+	buf = static_cast<byte*>(ut_malloc(UNIV_PAGE_SIZE * 2));
+	ptr = static_cast<byte*>(ut_align(buf, UNIV_PAGE_SIZE));
+
+	memset(&iocb, 0x0, sizeof(iocb));
+	p_iocb = &iocb;
+	io_prep_pwrite(p_iocb, fd, ptr, UNIV_PAGE_SIZE, 0);
+
+	err = io_submit(io_ctx, 1, &p_iocb);
+	if (err >= 1) {
+		/* Now collect the submitted IO request. */
+		err = io_getevents(io_ctx, 1, 1, &io_event, NULL);
+	}
+
+	ut_free(buf);
+	close(fd);
+
+	switch (err) {
+	case 1:
+		return(TRUE);
+
+	case -EINVAL:
+	case -ENOSYS:
+		ut_print_timestamp(stderr);
+		fprintf(stderr,
+			" InnoDB: Error: Linux Native AIO is not"
+			" supported on tmpdir.\n"
+			"InnoDB: You can either move tmpdir to a"
+			" file system that supports native AIO\n"
+			"InnoDB: or you can set"
+			" innodb_use_native_aio to FALSE to avoid"
+			" this message.\n");
+
+		/* fall through. */
+	default:
+		ut_print_timestamp(stderr);
+		fprintf(stderr,
+			" InnoDB: Error: Linux Native AIO check"
+			" on tmpdir returned error[%d]\n", -err);
+	}
+
+	return(FALSE);
+}
 #endif /* LINUX_NATIVE_AIO */
 
 /******************************************************************//**
@@ -3369,6 +3450,19 @@ os_aio_init(
 
 	os_io_init_simple();
 
+#if defined(LINUX_NATIVE_AIO)
+	/* Check if native aio is supported on this system and tmpfs */
+	if (srv_use_native_aio
+	    && !os_aio_native_aio_supported()) {
+
+		ut_print_timestamp(stderr);
+		fprintf(stderr,
+			" InnoDB: Warning: Linux Native AIO"
+			" disabled.\n");
+		srv_use_native_aio = FALSE;
+	}
+#endif /* LINUX_NATIVE_AIO */
+
 	for (i = 0; i < n_segments; i++) {
 		srv_set_io_thread_op_info(i, "not started yet");
 	}

=== modified file 'storage/innobase/pars/pars0pars.cc'
--- a/storage/innobase/pars/pars0pars.cc	2011-12-29 14:32:49 +0000
+++ b/storage/innobase/pars/pars0pars.cc	2012-01-18 15:39:14 +0000
@@ -1957,12 +1957,12 @@ pars_create_table(
 			dfield_get_data(dfield)));
 
 
-                switch (size) {
+		switch (size) {
 		case 0:
 			break;
 
-                case 1: case 2: case 4: case 8: case 16:
-                	flags |= DICT_TF_COMPACT;
+		case 1: case 2: case 4: case 8: case 16:
+			flags |= DICT_TF_COMPACT;
 			/* FTS-FIXME: needs the zip changes */
 			/* flags |= size << DICT_TF_COMPRESSED_SHIFT; */
 			break;

=== modified file 'storage/innobase/row/row0merge.cc'
--- a/storage/innobase/row/row0merge.cc	2011-12-20 09:45:15 +0000
+++ b/storage/innobase/row/row0merge.cc	2012-01-18 15:39:14 +0000
@@ -2334,8 +2334,8 @@ row_merge_drop_temp_indexes(void)
 		}
 
 		rec = btr_pcur_get_rec(&pcur);
-		field = rec_get_nth_field_old(rec, DICT_SYS_INDEXES_NAME_FIELD,
-					      &len);
+		field = rec_get_nth_field_old(
+			rec, DICT_FLD__SYS_INDEXES__NAME, &len);
 		if (len == UNIV_SQL_NULL || len == 0
 		    || (char) *field != TEMP_INDEX_PREFIX) {
 			continue;
@@ -2343,7 +2343,8 @@ row_merge_drop_temp_indexes(void)
 
 		/* This is a temporary index. */
 
-		field = rec_get_nth_field_old(rec, 0/*TABLE_ID*/, &len);
+		field = rec_get_nth_field_old(
+			rec, DICT_FLD__SYS_INDEXES__TABLE_ID, &len);
 		if (len != 8) {
 			/* Corrupted TABLE_ID */
 			continue;

=== modified file 'storage/innobase/row/row0mysql.cc'
--- a/storage/innobase/row/row0mysql.cc	2012-01-10 05:26:29 +0000
+++ b/storage/innobase/row/row0mysql.cc	2012-01-18 15:39:14 +0000
@@ -2148,7 +2148,7 @@ err_exit:
 		ut_a(mem_validate());
 		fputs("Memory validated\n", stderr);
 #endif /* UNIV_MEM_DEBUG */
-        }
+	}
 
 
 	heap = mem_heap_create(512);
@@ -3190,7 +3190,8 @@ row_truncate_table_for_mysql(
 
 		rec = btr_pcur_get_rec(&pcur);
 
-		field = rec_get_nth_field_old(rec, 0, &len);
+		field = rec_get_nth_field_old(
+			rec, DICT_FLD__SYS_INDEXES__TABLE_ID, &len);
 		ut_ad(len == 8);
 
 		if (memcmp(buf, field, len) != 0) {
@@ -3212,7 +3213,7 @@ row_truncate_table_for_mysql(
 
 		if (root_page_no != FIL_NULL) {
 			page_rec_write_field(
-				rec, DICT_SYS_INDEXES_PAGE_NO_FIELD,
+				rec, DICT_FLD__SYS_INDEXES__PAGE_NO,
 				root_page_no, &mtr);
 			/* We will need to commit and restart the
 			mini-transaction in order to avoid deadlocks.
@@ -3393,7 +3394,7 @@ row_drop_table_for_mysql(
 	ulint		namelen;
 	ibool		locked_dictionary	= FALSE;
 	ibool		fts_bg_thread_exited	= FALSE;
-	pars_info_t*    info			= NULL;
+	pars_info_t*	info			= NULL;
 
 	ut_a(name != NULL);
 
@@ -3927,7 +3928,8 @@ row_mysql_drop_temp_tables(void)
 		/* The high order bit of N_COLS is set unless
 		ROW_FORMAT=REDUNDANT. */
 		rec = btr_pcur_get_rec(&pcur);
-		field = rec_get_nth_field_old(rec, 4/*N_COLS*/, &len);
+		field = rec_get_nth_field_old(
+			rec, DICT_FLD__SYS_TABLES__N_COLS, &len);
 		if (len != 4
 		    || !(mach_read_from_4(field) & DICT_N_COLS_COMPACT)) {
 			continue;
@@ -3937,14 +3939,16 @@ row_mysql_drop_temp_tables(void)
 		in ROW_FORMAT=REDUNDANT could write garbage to
 		SYS_TABLES.MIX_LEN, where we now store the is_temp flag.
 		Above, we assumed is_temp=0 if ROW_FORMAT=REDUNDANT. */
-		field = rec_get_nth_field_old(rec, 7/*MIX_LEN*/, &len);
+		field = rec_get_nth_field_old(
+			rec, DICT_FLD__SYS_TABLES__MIX_LEN, &len);
 		if (len != 4
 		    || !(mach_read_from_4(field) & DICT_TF2_TEMPORARY)) {
 			continue;
 		}
 
 		/* This is a temporary table. */
-		field = rec_get_nth_field_old(rec, 0/*NAME*/, &len);
+		field = rec_get_nth_field_old(
+			rec, DICT_FLD__SYS_TABLES__NAME, &len);
 		if (len == UNIV_SQL_NULL || len == 0) {
 			/* Corrupted SYS_TABLES.NAME */
 			continue;

=== modified file 'storage/innobase/srv/srv0start.cc'
--- a/storage/innobase/srv/srv0start.cc	2011-12-28 08:37:08 +0000
+++ b/storage/innobase/srv/srv0start.cc	2012-01-18 15:39:14 +0000
@@ -2194,8 +2194,8 @@ innobase_start_or_create_for_mysql(void)
 
 	srv_is_being_started = FALSE;
 
+	/* Create the SYS_FOREIGN and SYS_FOREIGN_COLS system tables */
 	err = dict_create_or_check_foreign_constraint_tables();
-
 	if (err != DB_SUCCESS) {
 		return((int)DB_ERROR);
 	}

=== modified file 'strings/dtoa.c'
--- a/strings/dtoa.c	2011-09-26 12:42:12 +0000
+++ b/strings/dtoa.c	2012-01-19 07:41:28 +0000
@@ -1397,7 +1397,7 @@ static double my_strtod_int(const char *
     else if (nd < 16)
       z= 10*z + c - '0';
   nd0= nd;
-  if (s < end - 1 && c == '.')
+  if (s < end && c == '.')
   {
     c= *++s;
     if (!nd)

=== modified file 'unittest/gunit/filesort_buffer-t.cc'
--- a/unittest/gunit/filesort_buffer-t.cc	2011-12-20 09:51:05 +0000
+++ b/unittest/gunit/filesort_buffer-t.cc	2012-01-18 13:03:10 +0000
@@ -16,11 +16,11 @@
 // First include (the generated) my_config.h, to get correct platform defines.
 #include "my_config.h"
 #include <gtest/gtest.h>
+#include <utility>
 
 #include "filesort_utils.h"
 #include "table.h"
 
-
 namespace {
 
 class FileSortBufferTest : public ::testing::Test
@@ -38,7 +38,15 @@ protected:
 TEST_F(FileSortBufferTest, FileSortBuffer)
 {
   const char letters[10]= "abcdefghi";
+  std::pair<uint, uint> buffer_properties= fs_info.sort_buffer_properties();
+  EXPECT_EQ(0U, buffer_properties.first);
+  EXPECT_EQ(0U, buffer_properties.second);
+
   uchar **sort_keys= fs_info.alloc_sort_buffer(10, sizeof(char));
+  buffer_properties= fs_info.sort_buffer_properties();
+  EXPECT_EQ(10U, buffer_properties.first);
+  EXPECT_EQ(sizeof(char), buffer_properties.second);
+
   uchar **null_sort_keys= NULL;
   EXPECT_NE(null_sort_keys, sort_keys);
   for (uint ix= 0; ix < 10; ++ix)

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk-wl5259 branch (marc.alff:3354 to 3356) Marc Alff20 Jan